@@ -148,13 +148,10 @@ export function useAppContextSelectors(
148148 // more "sidebar says A while the list shows B" drift.
149149 const params = new URLSearchParams ( location . search ) ;
150150
151- // Re-apply a remembered scope once, on first mount, so a selection
152- // survives a full page reload (when the URL comes back without the
153- // query param). Subsequent navigation is driven purely by the URL.
154- const seededRef = React . useRef ( false ) ;
151+ // Re-apply a remembered scope whenever navigation drops the query param.
152+ // The selector is mandatory for Studio: package-scoped pages should never
153+ // sit at a blank package value just because a nav link omitted `?package=`.
155154 React . useEffect ( ( ) => {
156- if ( seededRef . current ) return ;
157- seededRef . current = true ;
158155 const p = new URLSearchParams ( location . search ) ;
159156 let changed = false ;
160157 for ( const sel of list ) {
@@ -168,8 +165,7 @@ export function useAppContextSelectors(
168165 if ( changed ) {
169166 navigate ( { pathname : location . pathname , search : p . toString ( ) } , { replace : true } ) ;
170167 }
171- // eslint-disable-next-line react-hooks/exhaustive-deps
172- } , [ ] ) ;
168+ } , [ appName , list , location . pathname , location . search , navigate ] ) ;
173169
174170 const setValue = React . useCallback ( ( sel : ContextSelectorDef , raw : string ) => {
175171 const value = raw === ALL_SENTINEL ? ( sel . allValue ?? '' ) : raw ;
@@ -190,7 +186,11 @@ export function useAppContextSelectors(
190186
191187 const contextValues : Record < string , string > = { } ;
192188 for ( const sel of list ) {
193- contextValues [ sel . id ] = params . get ( 'package' ) ?? ( sel . allValue ?? '' ) ;
189+ let saved = '' ;
190+ try {
191+ saved = sessionStorage . getItem ( `objectui-ctx-${ appName } -${ sel . id } ` ) ?? '' ;
192+ } catch { /* storage disabled */ }
193+ contextValues [ sel . id ] = ( params . get ( 'package' ) ?? saved ) || ( sel . allValue ?? '' ) ;
194194 }
195195
196196 const element = list . length === 0 ? null : (
@@ -238,34 +238,31 @@ function SelectorControl({
238238 // `includeAll`, never render an "All" row, and auto-select the first option
239239 // as soon as the list resolves when nothing concrete is selected yet.
240240 const hasConcrete = ! ! value && value !== ( def . allValue ?? '' ) ;
241- const seededRef = React . useRef ( false ) ;
242241 React . useEffect ( ( ) => {
243- if ( seededRef . current ) return ;
244242 if ( hasConcrete ) {
245- seededRef . current = true ;
246243 return ;
247244 }
248245 if ( options . length > 0 ) {
249- seededRef . current = true ;
250246 onChange ( options [ 0 ] . value ) ;
251247 }
252- // eslint-disable-next-line react-hooks/exhaustive-deps
253- } , [ options , hasConcrete ] ) ;
248+ } , [ hasConcrete , onChange , options ] ) ;
254249
255250 const current = hasConcrete ? value : '' ;
256251
257252 return (
258253 < Select value = { current } onValueChange = { onChange } >
259254 < SelectTrigger
260255 aria-label = { label }
261- className = "h-8 w-full gap-1.5 rounded-md border-sidebar-border/60 bg-sidebar-accent/40 px-2 text-xs font-medium text-sidebar-foreground shadow-none hover:bg-sidebar-accent focus:ring-1 focus:ring-sidebar-ring data-[state=open]:bg-sidebar-accent"
256+ className = "h-9 w-full gap-2 rounded-md border-sidebar-border/70 bg-sidebar/80 px-2 text-xs font-medium text-sidebar-foreground shadow-none transition-colors hover:bg-sidebar-accent focus:ring-1 focus:ring-sidebar-ring data-[state=open]:bg-sidebar-accent [&>svg]:h-3.5 [&>svg]:w-3.5 [&>svg]:shrink-0 "
262257 >
263- < span className = "flex min-w-0 items-center gap-1.5 truncate" >
264- < Icon className = "h-3.5 w-3.5 shrink-0 opacity-60" />
265- < SelectValue placeholder = { placeholder } />
266- </ span >
258+ < div className = "flex min-w-0 flex-1 items-center gap-2 overflow-hidden" >
259+ < span className = "flex h-5 w-5 shrink-0 items-center justify-center rounded border border-sidebar-border/70 bg-sidebar-accent text-sidebar-foreground/70" >
260+ < Icon className = "h-3 w-3" />
261+ </ span >
262+ < SelectValue placeholder = { placeholder } className = "truncate" />
263+ </ div >
267264 </ SelectTrigger >
268- < SelectContent >
265+ < SelectContent className = "w-[var(--radix-select-trigger-width)]" >
269266 { options . map ( ( opt ) => (
270267 < SelectItem key = { opt . value } value = { opt . value } >
271268 { opt . label }
0 commit comments