@adea-ai/ui 0.153.0 → 0.154.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/NOTICE +10 -1
  2. package/dist/components/composites/model-selector/model-selector.d.ts +15 -1
  3. package/dist/components/composites/model-selector/model-selector.d.ts.map +1 -1
  4. package/dist/components/composites/model-selector/model-selector.js +263 -29
  5. package/dist/components/composites/model-selector/model-selector.js.map +1 -1
  6. package/dist/components/layout/side-rail/side-rail.d.ts.map +1 -1
  7. package/dist/components/layout/side-rail/side-rail.js +46 -42
  8. package/dist/components/layout/side-rail/side-rail.js.map +1 -1
  9. package/dist/components/layout/top-bar/top-bar.d.ts.map +1 -1
  10. package/dist/components/layout/top-bar/top-bar.js +13 -12
  11. package/dist/components/layout/top-bar/top-bar.js.map +1 -1
  12. package/dist/components/ui/dialog/dialog-layer.d.ts.map +1 -1
  13. package/dist/components/ui/dialog/dialog-layer.js +10 -10
  14. package/dist/components/ui/dialog/dialog-layer.js.map +1 -1
  15. package/dist/components/ui/kbd/kbd.d.ts +23 -10
  16. package/dist/components/ui/kbd/kbd.d.ts.map +1 -1
  17. package/dist/components/ui/kbd/kbd.js +42 -11
  18. package/dist/components/ui/kbd/kbd.js.map +1 -1
  19. package/dist/lib/overlay.d.ts +1 -1
  20. package/dist/lib/overlay.d.ts.map +1 -1
  21. package/dist/lib/overlay.js +1 -1
  22. package/dist/lib/overlay.js.map +1 -1
  23. package/dist/r/model-selector.json +1 -0
  24. package/dist/r/registry.json +3 -0
  25. package/dist/r/side-rail.json +1 -0
  26. package/dist/r/src/components/composites/model-selector/model-selector.tsx +186 -10
  27. package/dist/r/src/components/layout/side-rail/side-rail.tsx +16 -19
  28. package/dist/r/src/components/layout/top-bar/top-bar.tsx +3 -7
  29. package/dist/r/src/components/ui/dialog/dialog-layer.tsx +16 -18
  30. package/dist/r/src/components/ui/kbd/kbd.tsx +53 -12
  31. package/dist/r/src/lib/overlay.ts +1 -1
  32. package/dist/r/top-bar.json +1 -0
  33. package/package.json +1 -1
  34. package/registry.json +3 -0
  35. package/src/components/composites/model-selector/model-selector.tsx +186 -10
  36. package/src/components/layout/side-rail/side-rail.tsx +16 -19
  37. package/src/components/layout/top-bar/top-bar.tsx +3 -7
  38. package/src/components/ui/dialog/dialog-layer.tsx +16 -18
  39. package/src/components/ui/kbd/kbd.tsx +53 -12
  40. package/src/lib/overlay.ts +1 -1
@@ -3,6 +3,7 @@ import { Show, splitProps } from 'solid-js'
3
3
  import { Search } from 'lucide-solid'
4
4
  import { callHandler } from '../../../lib/events'
5
5
  import { cn } from '../../../lib/utils'
6
+ import { KbdChord } from '../../ui/kbd'
6
7
  import { windowChromeClass, type WindowChromeProps } from './window-chrome'
7
8
 
8
9
  /**
@@ -186,13 +187,8 @@ export function TopBarSearch(props: TopBarSearchProps) {
186
187
  <Search aria-hidden="true" class="size-4 shrink-0 sm:hidden" />
187
188
  <span class="sr-only sm:not-sr-only sm:truncate">{local.placeholder ?? 'Search'}</span>
188
189
  <Show when={local.shortcut}>
189
- {(shortcutSlot) => (
190
- <kbd
191
- aria-hidden="true"
192
- class="bg-muted ms-auto hidden h-5 shrink-0 items-center rounded-sm border border-border px-1.5 font-code text-code sm:flex"
193
- >
194
- {shortcutSlot()}
195
- </kbd>
190
+ {(shortcut) => (
191
+ <KbdChord keys={shortcut()} class="ms-auto hidden shrink-0 sm:inline-flex" />
196
192
  )}
197
193
  </Show>
198
194
  </button>
@@ -34,8 +34,8 @@ type FocusCycle = {
34
34
  closed: boolean
35
35
  focusMovedOutside: boolean
36
36
  closeAutoFocusScheduled: boolean
37
- /** The restore deadline passed: stop waiting on the opener after the frame that is due. */
38
- deadlinePassed: boolean
37
+ /** Restore frames that found the opener still hidden; see FOCUS_RESTORE_FRAME_BUDGET. */
38
+ hiddenFrames: number
39
39
  frame?: number
40
40
  fallbackTimer?: number
41
41
  observer?: MutationObserver
@@ -78,8 +78,13 @@ function anotherLayerOpen(content: HTMLElement, opener: HTMLElement): boolean {
78
78
  * The focus-return half of the layer rules, for a layer whose open state is
79
79
  * `open`. Returns the autofocus handlers to give the Kobalte content.
80
80
  */
81
- /** How long a closed layer may wait for its opener to become focusable again. */
82
- const FOCUS_RESTORE_DEADLINE_MS = 1000
81
+ /**
82
+ * How many restore frames a closed layer may spend on an opener that is still
83
+ * hidden. It counts frames, not time: Kobalte clears its own markers when the
84
+ * overlay finishes unmounting, which on a loaded machine (WebKit in CI) can be
85
+ * well over a second, and a frame count slows down with the page.
86
+ */
87
+ const FOCUS_RESTORE_FRAME_BUDGET = 120
83
88
 
84
89
  export function createDialogFocusReturn(
85
90
  open: Accessor<boolean>,
@@ -150,7 +155,8 @@ export function createDialogFocusReturn(
150
155
  // Kobalte removes the `inert` / `aria-hidden` it put on the background
151
156
  // only after the layer unmounts; the observer below brings us back here.
152
157
  if (opener.closest('[inert], [aria-hidden="true"]')) {
153
- if (cycle.deadlinePassed) finishFocusCycle(cycle)
158
+ cycle.hiddenFrames += 1
159
+ if (cycle.hiddenFrames >= FOCUS_RESTORE_FRAME_BUDGET) finishFocusCycle(cycle)
154
160
  return
155
161
  }
156
162
  if (cycle.openerEligible && canRestoreFocus(opener)) {
@@ -180,7 +186,7 @@ export function createDialogFocusReturn(
180
186
  closed: false,
181
187
  focusMovedOutside: false,
182
188
  closeAutoFocusScheduled: false,
183
- deadlinePassed: false,
189
+ hiddenFrames: 0,
184
190
  onFocusIn: (focusEvent) => {
185
191
  const target = focusEvent.target
186
192
  if (
@@ -231,19 +237,11 @@ export function createDialogFocusReturn(
231
237
  childList: true,
232
238
  subtree: true,
233
239
  })
234
- scheduleFocusRestore(cycle)
235
240
  // The observer watches every mutation in the document. If the opener stays
236
- // under an `inert` or `aria-hidden` that is not this layer's, nothing above
237
- // finishes the cycle, and a streaming page would schedule a frame per DOM
238
- // change for good. Kobalte clears its own markers within a frame or two.
239
- // The deadline stops the watching, not a restore already asked for: a busy
240
- // or throttled page (WebKit under load) can hold the frame past it.
241
- cycle.fallbackTimer = window.setTimeout(() => {
242
- cycle.fallbackTimer = undefined
243
- cycle.deadlinePassed = true
244
- cycle.observer?.disconnect()
245
- if (cycle.frame === undefined) finishFocusCycle(cycle)
246
- }, FOCUS_RESTORE_DEADLINE_MS)
241
+ // under an `inert` or `aria-hidden` that is not this layer's, a streaming
242
+ // page would schedule a frame per DOM change for good, so the frames that
243
+ // find it hidden are capped. A quiet page schedules none while it waits.
244
+ scheduleFocusRestore(cycle)
247
245
  }
248
246
 
249
247
  onCleanup(() => {
@@ -6,21 +6,28 @@ import { cn } from '../../../lib/utils'
6
6
  /**
7
7
  * Kbd.
8
8
  *
9
- * A keyboard key, in the order the user presses them. The element is a real
10
- * `<kbd>` so the semantics survive copy-paste, and the mono face is what makes
11
- * a shortcut visually distinct from the sentence around it.
9
+ * A keyboard key, ported from shadcn/ui's `Kbd` (MIT, see NOTICE). The element
10
+ * is a real `<kbd>` so the semantics survive copy-paste.
11
+ *
12
+ * The cap is set in the UI face at `text-xs`, as shadcn draws it, not in the
13
+ * code face. Monospace faces carry letters but rarely the modifier glyphs, so
14
+ * a mono `⌘` fell back to another font and sat visibly smaller than the mono
15
+ * `K` beside it. The UI face draws `⌘ ⇧ ⌥ ⌃` and letters as one family, so
16
+ * every cap in a chord reads at the same size.
12
17
  *
13
18
  * `size="compact"` exists for the dense rows a default cap would outweigh, a
14
19
  * rail search row, a sidebar shortcut hint. It drops a height rung, and it
15
20
  * lightens the fill and weight with it because at that size a solid muted cap
16
- * reads heavier than the row text it sits in. The default rendering is every
17
- * cap that is not inside such a row, and it is untouched by the rung.
21
+ * reads heavier than the row text it sits in.
18
22
  *
19
23
  * `KbdGroup` exists because a shortcut is a sequence: typing `⌘` then `K`
20
24
  * needs a gap between them that is a layout concern, not punctuation.
21
25
  */
22
26
  export const kbdVariants = cva(
23
- 'bg-muted text-muted-foreground pointer-events-none inline-flex min-h-5 min-w-5 items-center justify-center gap-1 rounded-sm border border-border px-1 font-code text-code font-medium select-none',
27
+ [
28
+ 'bg-muted text-muted-foreground pointer-events-none inline-flex min-h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none',
29
+ "[&_svg:not([class*='size-'])]:size-3",
30
+ ],
24
31
  {
25
32
  variants: {
26
33
  size: {
@@ -57,6 +64,10 @@ export const kbdGroupVariants = cva('inline-flex items-center gap-1', {
57
64
  },
58
65
  })
59
66
 
67
+ /**
68
+ * shadcn renders the group as a `<kbd>`; it stays a `<span>` here so a
69
+ * `kbd` selector still finds exactly the caps, which hosts and tests count.
70
+ */
60
71
  export function KbdGroup(props: ComponentProps<'span'> & { size?: KbdSize }) {
61
72
  const [local, rest] = splitProps(props, ['size', 'class'])
62
73
 
@@ -69,17 +80,47 @@ export function KbdGroup(props: ComponentProps<'span'> & { size?: KbdSize }) {
69
80
  )
70
81
  }
71
82
 
83
+ /** Key names that are drawn as one word on one cap. */
84
+ const NAMED_KEY =
85
+ /^(?:Ctrl|Control|Alt|Option|Opt|Shift|Cmd|Command|Meta|Super|Win|Fn|Enter|Return|Escape|Esc|Tab|Space|Backspace|Delete|Del|Insert|Home|End|PageUp|PageDown|PgUp|PgDn|Up|Down|Left|Right|F(?:1\d|2[0-4]|[1-9]))/
86
+
72
87
  /**
73
- * Split a written chord into one entry per key cap. Every character is a key:
74
- * `⌘K` renders as `⌘` + `K`, and a longer chord like `⇧⌘P` stays three caps
75
- * wide, which matches how the system draws chords in menus.
88
+ * Split a written chord into one entry per key cap.
89
+ *
90
+ * - Glyph chords draw one cap per character: `⌘K` is `⌘` + `K`, and `⇧⌘P`
91
+ * stays three caps wide, which matches how the system draws chords in menus.
92
+ * - Spelled-out names stay whole: `CtrlK` is `Ctrl` + `K`, `⇧Enter` is
93
+ * `⇧` + `Enter`.
94
+ * - `+` and spaces separate keys and are not drawn (`Ctrl+K`, `Ctrl Shift P`),
95
+ * except a `+` that is itself the key (`Ctrl++`, `⌘+`).
76
96
  */
77
97
  export function kbdChordKeys(keys: string): string[] {
78
- return [...keys]
98
+ const caps: string[] = []
99
+ let rest = keys
100
+ let separated = true
101
+ while (rest.length > 0) {
102
+ const first = rest[0]!
103
+ if (first === ' ' || (first === '+' && !separated && rest.length > 1)) {
104
+ rest = rest.slice(1)
105
+ separated = true
106
+ continue
107
+ }
108
+ const named = NAMED_KEY.exec(rest)?.[0]
109
+ // A name only counts when a lowercase letter does not continue it: `Tab`
110
+ // in `Table` is not a key, so a caller's literal text is drawn as written.
111
+ const cap =
112
+ named && !/^[a-z]/.test(rest.charAt(named.length))
113
+ ? named
114
+ : String.fromCodePoint(rest.codePointAt(0)!)
115
+ caps.push(cap)
116
+ rest = rest.slice(cap.length)
117
+ separated = false
118
+ }
119
+ return caps
79
120
  }
80
121
 
81
122
  export type KbdChordProps = Omit<ComponentProps<'span'>, 'children'> & {
82
- /** The chord as it is drawn, e.g. `"⌘K"` or `"⇧⌘P"`. One cap per character. */
123
+ /** The chord as it is drawn, e.g. `"⌘K"`, `"⇧⌘P"` or `"Ctrl+K"`. See `kbdChordKeys`. */
83
124
  keys: string
84
125
  size?: KbdSize
85
126
  }
@@ -87,7 +128,7 @@ export type KbdChordProps = Omit<ComponentProps<'span'>, 'children'> & {
87
128
  /**
88
129
  * KbdChord.
89
130
  *
90
- * A written chord drawn as caps, one per character. Decoration only: the
131
+ * A written chord drawn as caps, one per key (see `kbdChordKeys`). Decoration only: the
91
132
  * composition renders `aria-hidden`, so the accessible name and the parseable
92
133
  * `aria-keyshortcuts` stay on the control the chord belongs to. That is why
93
134
  * there is no children, the chord says what was drawn, nothing more.
@@ -130,7 +130,7 @@ export const menuLabel =
130
130
  'px-2 py-1.5 text-2xs font-medium tracking-wide text-muted-foreground uppercase'
131
131
 
132
132
  /** The chord drawn at a row's trailing edge: menus and the command palette. */
133
- export const menuShortcut = 'text-muted-foreground ms-auto font-code text-code tracking-widest'
133
+ export const menuShortcut = 'text-muted-foreground ms-auto text-xs tracking-widest'
134
134
 
135
135
  /** The rule between menu groups. */
136
136
  export const menuSeparator = 'bg-border -mx-1 my-1 h-px'
@@ -7,6 +7,7 @@
7
7
  "lucide-solid@^1.71.0"
8
8
  ],
9
9
  "registryDependencies": [
10
+ "@adea-ai/ui/kbd",
10
11
  "lib"
11
12
  ],
12
13
  "files": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adea-ai/ui",
3
- "version": "0.153.0",
3
+ "version": "0.154.0",
4
4
  "description": "The Adea design system: Kobalte-backed Solid components, semantic OKLCH tokens, and the app-shell layout primitives shared by Adea and Cortana.",
5
5
  "keywords": [
6
6
  "adea",
package/registry.json CHANGED
@@ -2017,6 +2017,7 @@
2017
2017
  "@kobalte/core@^0.13.14"
2018
2018
  ],
2019
2019
  "registryDependencies": [
2020
+ "@adea-ai/ui/kbd",
2020
2021
  "lib"
2021
2022
  ],
2022
2023
  "files": [
@@ -2175,6 +2176,7 @@
2175
2176
  "lucide-solid@^1.71.0"
2176
2177
  ],
2177
2178
  "registryDependencies": [
2179
+ "@adea-ai/ui/kbd",
2178
2180
  "lib"
2179
2181
  ],
2180
2182
  "files": [
@@ -2803,6 +2805,7 @@
2803
2805
  "@adea-ai/ui/command",
2804
2806
  "@adea-ai/ui/dropdown-menu",
2805
2807
  "@adea-ai/ui/popover",
2808
+ "@adea-ai/ui/tabs",
2806
2809
  "lib"
2807
2810
  ],
2808
2811
  "files": [
@@ -7,6 +7,7 @@ import {
7
7
  For,
8
8
  Show,
9
9
  splitProps,
10
+ type JSX,
10
11
  } from 'solid-js'
11
12
  import { cn } from '#lib/utils'
12
13
  import { Button } from '../../ui/button'
@@ -28,6 +29,7 @@ import {
28
29
  DropdownMenuTrigger,
29
30
  } from '../../ui/dropdown-menu'
30
31
  import { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover'
32
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from '../../ui/tabs'
31
33
  import { REASON_TEXT_LIMIT, boundText } from '#lib/text'
32
34
  import {
33
35
  findModel,
@@ -74,6 +76,15 @@ import {
74
76
  * search box, because scanning thirty rows is slower than typing four letters.
75
77
  * Both close on choice and return focus to the trigger. Triggers use
76
78
  * `aria-disabled` so a blocked control is still reachable and its reason read.
79
+ *
80
+ * ## Tabs
81
+ *
82
+ * `layout="tabs"` is for a list whose providers are the first choice, such as
83
+ * one row of harnesses. The popover opens with one tab per provider, in the
84
+ * order they first appear (the host's order), each drawn with `providerIcon`
85
+ * or the provider's initial and named by its tooltip. Under the tabs, a search
86
+ * box and the list cover the selected tab's models only. The tab starts on the
87
+ * selected model's provider. Effort stays its own menu.
77
88
  */
78
89
  export type ModelSelectorProps = {
79
90
  models: readonly ModelOption[]
@@ -89,6 +100,10 @@ export type ModelSelectorProps = {
89
100
  disabledReason?: string
90
101
  /** The group's accessible name. */
91
102
  label?: string
103
+ /** `tabs`: one tab per provider above a searchable list of that provider's models. */
104
+ layout?: 'list' | 'tabs'
105
+ /** The provider's mark, drawn with `currentColor`, for the tabs and the trigger. */
106
+ providerIcon?: (provider: string) => JSX.Element
92
107
  class?: string
93
108
  }
94
109
 
@@ -102,6 +117,8 @@ export function ModelSelector(props: ModelSelectorProps) {
102
117
  'searchThreshold',
103
118
  'disabledReason',
104
119
  'label',
120
+ 'layout',
121
+ 'providerIcon',
105
122
  'class',
106
123
  ])
107
124
  const blocked = () => local.disabledReason !== undefined
@@ -132,26 +149,41 @@ export function ModelSelector(props: ModelSelectorProps) {
132
149
  }
133
150
  >
134
151
  <Show
135
- when={needsSearch(local.models.length, local.searchThreshold)}
152
+ when={local.layout !== 'tabs'}
136
153
  fallback={
137
- <ModelMenu
154
+ <ModelTabs
138
155
  models={local.models}
139
156
  selected={selected()}
140
157
  value={local.value}
141
158
  blocked={blocked()}
142
159
  describedBy={describedBy()}
160
+ providerIcon={local.providerIcon}
143
161
  onChange={(id) => local.onChange?.(id)}
144
162
  />
145
163
  }
146
164
  >
147
- <ModelSearch
148
- models={local.models}
149
- selected={selected()}
150
- value={local.value}
151
- blocked={blocked()}
152
- describedBy={describedBy()}
153
- onChange={(id) => local.onChange?.(id)}
154
- />
165
+ <Show
166
+ when={needsSearch(local.models.length, local.searchThreshold)}
167
+ fallback={
168
+ <ModelMenu
169
+ models={local.models}
170
+ selected={selected()}
171
+ value={local.value}
172
+ blocked={blocked()}
173
+ describedBy={describedBy()}
174
+ onChange={(id) => local.onChange?.(id)}
175
+ />
176
+ }
177
+ >
178
+ <ModelSearch
179
+ models={local.models}
180
+ selected={selected()}
181
+ value={local.value}
182
+ blocked={blocked()}
183
+ describedBy={describedBy()}
184
+ onChange={(id) => local.onChange?.(id)}
185
+ />
186
+ </Show>
155
187
  </Show>
156
188
  </Show>
157
189
  <Show when={efforts().length > 0}>
@@ -361,6 +393,150 @@ function ModelSearch(props: PickerProps) {
361
393
  )
362
394
  }
363
395
 
396
+ /** The provider's mark, or its initial when the host gives none. */
397
+ function ProviderGlyph(props: { provider: string; icon?: (provider: string) => JSX.Element }) {
398
+ return (
399
+ <Show
400
+ when={props.icon?.(props.provider)}
401
+ fallback={
402
+ <span aria-hidden="true" class="text-xs font-semibold uppercase">
403
+ {props.provider.charAt(0)}
404
+ </span>
405
+ }
406
+ >
407
+ {(icon) => (
408
+ <span aria-hidden="true" class="inline-flex size-4 shrink-0 items-center justify-center">
409
+ {icon()}
410
+ </span>
411
+ )}
412
+ </Show>
413
+ )
414
+ }
415
+
416
+ function ModelTabs(props: PickerProps & { providerIcon?: (provider: string) => JSX.Element }) {
417
+ const [open, setOpen] = createSignal(false)
418
+ const groups = createMemo(() => groupModels(props.models))
419
+ const inert = () => props.blocked || props.models.length === 0
420
+ const groupOf = (model: ModelOption | undefined) =>
421
+ model ? groups().find((group) => group.models.includes(model))?.provider : undefined
422
+ const [tab, setTab] = createSignal<string>()
423
+ // Each opening starts on the selected model's provider, else the first.
424
+ const current = () => {
425
+ const chosen = tab()
426
+ return chosen && groups().some((group) => group.provider === chosen)
427
+ ? chosen
428
+ : (groupOf(props.selected) ?? groups()[0]?.provider)
429
+ }
430
+ let content: HTMLDivElement | undefined
431
+ const focusSearch = () =>
432
+ queueMicrotask(() => content?.querySelector<HTMLInputElement>('[cmdk-input]')?.focus())
433
+
434
+ createEffect(() => {
435
+ if (inert()) setOpen(false)
436
+ })
437
+
438
+ return (
439
+ <Popover
440
+ open={open()}
441
+ onOpenChange={(next) => {
442
+ setOpen(next && !inert())
443
+ if (!next) setTab(undefined)
444
+ }}
445
+ placement="top-start"
446
+ gutter={6}
447
+ >
448
+ <PopoverTrigger
449
+ as={Button}
450
+ variant="ghost"
451
+ size="sm"
452
+ aria-label={`Model: ${props.models.length === 0 ? 'No models available' : triggerText(props)}`}
453
+ aria-disabled={inert() || undefined}
454
+ aria-describedby={props.describedBy}
455
+ >
456
+ <Show when={groupOf(props.selected)}>
457
+ {(provider) => <ProviderGlyph provider={provider()} icon={props.providerIcon} />}
458
+ </Show>
459
+ <ModelTrigger
460
+ selected={props.selected}
461
+ value={props.value}
462
+ empty={props.models.length === 0}
463
+ />
464
+ </PopoverTrigger>
465
+ <PopoverContent
466
+ ref={(element: HTMLDivElement) => (content = element)}
467
+ hideArrow
468
+ class="w-80 max-w-full p-0"
469
+ onOpenAutoFocus={(event: Event) => {
470
+ event.preventDefault()
471
+ focusSearch()
472
+ }}
473
+ >
474
+ <Tabs
475
+ value={current()}
476
+ onChange={(next: string) => {
477
+ setTab(next)
478
+ focusSearch()
479
+ }}
480
+ class="gap-0"
481
+ >
482
+ <TabsList fill scrollable aria-label="Providers" class="px-1.5 pt-1">
483
+ <For each={groups()}>
484
+ {(group) => (
485
+ <TabsTrigger
486
+ value={group.provider}
487
+ aria-label={group.provider}
488
+ title={group.provider}
489
+ class="h-8 min-w-8 px-1.5 pb-1.5 text-muted-foreground data-[selected]:text-foreground"
490
+ >
491
+ <ProviderGlyph provider={group.provider} icon={props.providerIcon} />
492
+ </TabsTrigger>
493
+ )}
494
+ </For>
495
+ </TabsList>
496
+ <For each={groups()}>
497
+ {(group) => (
498
+ <TabsContent value={group.provider}>
499
+ <Command
500
+ label={`${group.provider} models`}
501
+ defaultValue={
502
+ props.selected && group.models.includes(props.selected)
503
+ ? modelSearchValue(props.selected).trim()
504
+ : undefined
505
+ }
506
+ >
507
+ <CommandInput placeholder="Search models" />
508
+ <CommandList>
509
+ <CommandEmpty>No model matches.</CommandEmpty>
510
+ <For each={group.models}>
511
+ {(model) => (
512
+ <CommandItem
513
+ value={modelSearchValue(model)}
514
+ disabled={props.blocked || model.disabledReason !== undefined}
515
+ onSelect={() => {
516
+ if (props.blocked || model.disabledReason !== undefined) return
517
+ props.onChange(model.id)
518
+ setOpen(false)
519
+ }}
520
+ >
521
+ <ModelOptionBody model={model} />
522
+ <Show when={model.id === props.value}>
523
+ <Check aria-hidden="true" class="ms-auto text-primary" />
524
+ <span class="visually-hidden">Current model</span>
525
+ </Show>
526
+ </CommandItem>
527
+ )}
528
+ </For>
529
+ </CommandList>
530
+ </Command>
531
+ </TabsContent>
532
+ )}
533
+ </For>
534
+ </Tabs>
535
+ </PopoverContent>
536
+ </Popover>
537
+ )
538
+ }
539
+
364
540
  function EffortMenu(props: {
365
541
  efforts: ReturnType<typeof normalizeEfforts>
366
542
  value?: string
@@ -11,6 +11,7 @@ import {
11
11
  import { Portal } from 'solid-js/web'
12
12
  import { tooltipTip } from '#lib/overlay'
13
13
  import { cn } from '#lib/utils'
14
+ import { KbdChord } from '../../ui/kbd'
14
15
  import { SideRailContext } from './side-rail-context'
15
16
 
16
17
  /**
@@ -227,11 +228,7 @@ function RailTip(props: {
227
228
  </span>
228
229
  {props.label}
229
230
  <Show when={props.shortcut}>
230
- {(shortcutSlot) => (
231
- <span class="text-muted-foreground shrink-0 font-code text-code leading-none">
232
- {shortcutSlot()}
233
- </span>
234
- )}
231
+ {(shortcut) => <KbdChord keys={shortcut()} class="shrink-0" />}
235
232
  </Show>
236
233
  </div>
237
234
  </Portal>
@@ -362,13 +359,14 @@ export function SideRailItem<T extends ValidComponent = 'a'>(props: SideRailItem
362
359
  )}
363
360
  </Show>
364
361
 
365
- <Show when={local.shortcut && trailing() === undefined}>
366
- <span
367
- aria-hidden="true"
368
- class="text-sidebar-muted-foreground shrink-0 font-code text-code leading-none opacity-0 transition-opacity group-hover/rail-item:opacity-100 group-focus-visible/rail-item:opacity-100 group-data-[collapsed=true]/rail:hidden"
369
- >
370
- {local.shortcut}
371
- </span>
362
+ <Show when={trailing() === undefined && local.shortcut}>
363
+ {(shortcut) => (
364
+ <KbdChord
365
+ keys={shortcut()}
366
+ size="compact"
367
+ class="shrink-0 opacity-0 transition-opacity group-hover/rail-item:opacity-100 group-focus-visible/rail-item:opacity-100 group-data-[collapsed=true]/rail:hidden"
368
+ />
369
+ )}
372
370
  </Show>
373
371
 
374
372
  <Show when={trailing()}>
@@ -424,13 +422,12 @@ export function SideRailButton(
424
422
  {local.label}
425
423
  </span>
426
424
  <Show when={local.shortcut}>
427
- {(shortcutSlot) => (
428
- <span
429
- aria-hidden="true"
430
- class="text-sidebar-muted-foreground shrink-0 font-code text-code leading-none opacity-0 transition-opacity group-hover/rail-item:opacity-100 group-focus-visible/rail-item:opacity-100 group-data-[collapsed=true]/rail:hidden"
431
- >
432
- {shortcutSlot()}
433
- </span>
425
+ {(shortcut) => (
426
+ <KbdChord
427
+ keys={shortcut()}
428
+ size="compact"
429
+ class="shrink-0 opacity-0 transition-opacity group-hover/rail-item:opacity-100 group-focus-visible/rail-item:opacity-100 group-data-[collapsed=true]/rail:hidden"
430
+ />
434
431
  )}
435
432
  </Show>
436
433
  </button>
@@ -3,6 +3,7 @@ import { Show, splitProps } from 'solid-js'
3
3
  import { Search } from 'lucide-solid'
4
4
  import { callHandler } from '#lib/events'
5
5
  import { cn } from '#lib/utils'
6
+ import { KbdChord } from '../../ui/kbd'
6
7
  import { windowChromeClass, type WindowChromeProps } from './window-chrome'
7
8
 
8
9
  /**
@@ -186,13 +187,8 @@ export function TopBarSearch(props: TopBarSearchProps) {
186
187
  <Search aria-hidden="true" class="size-4 shrink-0 sm:hidden" />
187
188
  <span class="sr-only sm:not-sr-only sm:truncate">{local.placeholder ?? 'Search'}</span>
188
189
  <Show when={local.shortcut}>
189
- {(shortcutSlot) => (
190
- <kbd
191
- aria-hidden="true"
192
- class="bg-muted ms-auto hidden h-5 shrink-0 items-center rounded-sm border border-border px-1.5 font-code text-code sm:flex"
193
- >
194
- {shortcutSlot()}
195
- </kbd>
190
+ {(shortcut) => (
191
+ <KbdChord keys={shortcut()} class="ms-auto hidden shrink-0 sm:inline-flex" />
196
192
  )}
197
193
  </Show>
198
194
  </button>
@@ -34,8 +34,8 @@ type FocusCycle = {
34
34
  closed: boolean
35
35
  focusMovedOutside: boolean
36
36
  closeAutoFocusScheduled: boolean
37
- /** The restore deadline passed: stop waiting on the opener after the frame that is due. */
38
- deadlinePassed: boolean
37
+ /** Restore frames that found the opener still hidden; see FOCUS_RESTORE_FRAME_BUDGET. */
38
+ hiddenFrames: number
39
39
  frame?: number
40
40
  fallbackTimer?: number
41
41
  observer?: MutationObserver
@@ -78,8 +78,13 @@ function anotherLayerOpen(content: HTMLElement, opener: HTMLElement): boolean {
78
78
  * The focus-return half of the layer rules, for a layer whose open state is
79
79
  * `open`. Returns the autofocus handlers to give the Kobalte content.
80
80
  */
81
- /** How long a closed layer may wait for its opener to become focusable again. */
82
- const FOCUS_RESTORE_DEADLINE_MS = 1000
81
+ /**
82
+ * How many restore frames a closed layer may spend on an opener that is still
83
+ * hidden. It counts frames, not time: Kobalte clears its own markers when the
84
+ * overlay finishes unmounting, which on a loaded machine (WebKit in CI) can be
85
+ * well over a second, and a frame count slows down with the page.
86
+ */
87
+ const FOCUS_RESTORE_FRAME_BUDGET = 120
83
88
 
84
89
  export function createDialogFocusReturn(
85
90
  open: Accessor<boolean>,
@@ -150,7 +155,8 @@ export function createDialogFocusReturn(
150
155
  // Kobalte removes the `inert` / `aria-hidden` it put on the background
151
156
  // only after the layer unmounts; the observer below brings us back here.
152
157
  if (opener.closest('[inert], [aria-hidden="true"]')) {
153
- if (cycle.deadlinePassed) finishFocusCycle(cycle)
158
+ cycle.hiddenFrames += 1
159
+ if (cycle.hiddenFrames >= FOCUS_RESTORE_FRAME_BUDGET) finishFocusCycle(cycle)
154
160
  return
155
161
  }
156
162
  if (cycle.openerEligible && canRestoreFocus(opener)) {
@@ -180,7 +186,7 @@ export function createDialogFocusReturn(
180
186
  closed: false,
181
187
  focusMovedOutside: false,
182
188
  closeAutoFocusScheduled: false,
183
- deadlinePassed: false,
189
+ hiddenFrames: 0,
184
190
  onFocusIn: (focusEvent) => {
185
191
  const target = focusEvent.target
186
192
  if (
@@ -231,19 +237,11 @@ export function createDialogFocusReturn(
231
237
  childList: true,
232
238
  subtree: true,
233
239
  })
234
- scheduleFocusRestore(cycle)
235
240
  // The observer watches every mutation in the document. If the opener stays
236
- // under an `inert` or `aria-hidden` that is not this layer's, nothing above
237
- // finishes the cycle, and a streaming page would schedule a frame per DOM
238
- // change for good. Kobalte clears its own markers within a frame or two.
239
- // The deadline stops the watching, not a restore already asked for: a busy
240
- // or throttled page (WebKit under load) can hold the frame past it.
241
- cycle.fallbackTimer = window.setTimeout(() => {
242
- cycle.fallbackTimer = undefined
243
- cycle.deadlinePassed = true
244
- cycle.observer?.disconnect()
245
- if (cycle.frame === undefined) finishFocusCycle(cycle)
246
- }, FOCUS_RESTORE_DEADLINE_MS)
241
+ // under an `inert` or `aria-hidden` that is not this layer's, a streaming
242
+ // page would schedule a frame per DOM change for good, so the frames that
243
+ // find it hidden are capped. A quiet page schedules none while it waits.
244
+ scheduleFocusRestore(cycle)
247
245
  }
248
246
 
249
247
  onCleanup(() => {