chat-js 1.0.0-alpha.8 → 1.0.0-beta.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 (84) hide show
  1. package/README.md +7 -5
  2. package/dist/index.js +7161 -6308
  3. package/package.json +2 -2
  4. package/templates/chat-app/agent/agent.ts +0 -2
  5. package/templates/chat-app/app/editor.css +0 -6
  6. package/templates/chat-app/app/layout.tsx +11 -18
  7. package/templates/chat-app/app/opengraph-image.png +0 -0
  8. package/templates/chat-app/chat.config.ts +0 -44
  9. package/templates/chat-app/chatjs/core/gateway/runtime.ts +0 -7
  10. package/templates/chat-app/chatjs/core/ui/slots.tsx +15 -5
  11. package/templates/chat-app/chatjs/generated/installed-chat-ui.ts +4 -0
  12. package/templates/chat-app/chatjs/generated/installed.ts +2 -0
  13. package/templates/chat-app/chatjs/plugins/guest-chat/signed-out.tsx +7 -4
  14. package/templates/chat-app/chatjs/plugins/mcp/routes/connectors-page.tsx +4 -1
  15. package/templates/chat-app/chatjs/plugins/mcp/ui/connectors-settings.tsx +1 -1
  16. package/templates/chat-app/chatjs/plugins/mcp/ui/mcp-connect-dialog.tsx +1 -1
  17. package/templates/chat-app/chatjs/plugins/mcp/ui/mcp-create-dialog.tsx +1 -1
  18. package/templates/chat-app/chatjs/plugins/model-preferences/model-row.tsx +3 -0
  19. package/templates/chat-app/chatjs/plugins/model-preferences/models-settings.tsx +1 -0
  20. package/templates/chat-app/chatjs/plugins/projects/routes/project-page.tsx +10 -1
  21. package/templates/chat-app/chatjs/plugins/projects/ui/delete-project-dialog.tsx +0 -3
  22. package/templates/chat-app/chatjs/plugins/projects/ui/project-icon-picker.tsx +1 -0
  23. package/templates/chat-app/chatjs/plugins/streamdown-math/chat-ui.ts +11 -0
  24. package/templates/chat-app/chatjs/plugins/streamdown-math/plugin.json +6 -0
  25. package/templates/chat-app/chatjs/plugins/streamdown-mermaid/chat-ui.ts +10 -0
  26. package/templates/chat-app/chatjs/plugins/streamdown-mermaid/plugin.json +6 -0
  27. package/templates/chat-app/chatjs/providers/gateway.ts +49 -55
  28. package/templates/chat-app/chatjs/tools/generate-image/tool.test.ts +3 -14
  29. package/templates/chat-app/components/ai-elements/response.tsx +16 -15
  30. package/templates/chat-app/components/auth-form-view.tsx +35 -43
  31. package/templates/chat-app/components/chat/chat-composer.tsx +55 -20
  32. package/templates/chat-app/components/chat/chat-sidebar.tsx +5 -3
  33. package/templates/chat-app/components/composer/prompt-form.tsx +7 -1
  34. package/templates/chat-app/components/eve/eve-chat-error.tsx +12 -2
  35. package/templates/chat-app/components/eve/eve-conversation.tsx +223 -154
  36. package/templates/chat-app/components/eve/eve-creation-recovery.tsx +32 -1
  37. package/templates/chat-app/components/eve/eve-history-list.tsx +1 -1
  38. package/templates/chat-app/components/model-selection-indicator.tsx +12 -10
  39. package/templates/chat-app/components/model-selector-view.tsx +211 -186
  40. package/templates/chat-app/components/new-chat-button.tsx +1 -1
  41. package/templates/chat-app/components/settings/settings-nav.tsx +1 -1
  42. package/templates/chat-app/components/settings/settings-navigation-link.tsx +1 -0
  43. package/templates/chat-app/components/sidebar-top-row.tsx +1 -1
  44. package/templates/chat-app/components/ui/sidebar.tsx +1 -1
  45. package/templates/chat-app/components/ui/trace.tsx +1 -1
  46. package/templates/chat-app/hooks/use-auto-focus.ts +12 -13
  47. package/templates/chat-app/lib/ai/active-gateway.ts +0 -9
  48. package/templates/chat-app/lib/ai/app-models.test.ts +0 -4
  49. package/templates/chat-app/lib/ai/app-models.ts +11 -6
  50. package/templates/chat-app/lib/ai/gateways/registry.ts +4 -31
  51. package/templates/chat-app/lib/ai/model-catalog.ts +50 -0
  52. package/templates/chat-app/lib/ai/models.ts +4 -39
  53. package/templates/chat-app/lib/ai/providers.ts +2 -16
  54. package/templates/chat-app/lib/config-schema.ts +0 -96
  55. package/templates/chat-app/lib/devtools-disabled.ts +1 -0
  56. package/templates/chat-app/lib/eve/model-selection.test.ts +47 -50
  57. package/templates/chat-app/lib/eve/model-selection.ts +5 -37
  58. package/templates/chat-app/lib/eve/tool-cost.test.ts +18 -6
  59. package/templates/chat-app/lib/eve/tool-cost.ts +10 -18
  60. package/templates/chat-app/oxfmt.config.ts +0 -2
  61. package/templates/chat-app/package.json +7 -9
  62. package/templates/chat-app/proxy.ts +2 -4
  63. package/templates/chat-app/scripts/build-eve.test.ts +56 -0
  64. package/templates/chat-app/scripts/build-eve.ts +12 -5
  65. package/templates/chat-app/scripts/check-env.ts +2 -17
  66. package/templates/chat-app/scripts/environment-validation-report.ts +1 -20
  67. package/templates/chat-app/trpc/react.tsx +2 -2
  68. package/templates/electron/forge.config.ts +1 -19
  69. package/templates/electron/scripts/write-branding.ts +1 -5
  70. package/templates/chat-app/app/privacy/page.tsx +0 -153
  71. package/templates/chat-app/app/terms/page.tsx +0 -270
  72. package/templates/chat-app/components/ai-elements/context-hover.radix.tsx +0 -15
  73. package/templates/chat-app/components/ai-elements/context-hover.tsx +0 -17
  74. package/templates/chat-app/components/ai-elements/context.tsx +0 -405
  75. package/templates/chat-app/components/composer/editor.css +0 -96
  76. package/templates/chat-app/components/lexical-chat-input.tsx +0 -276
  77. package/templates/chat-app/components/model-selection-indicator.radix.tsx +0 -17
  78. package/templates/chat-app/components/ui/resizable.tsx +0 -49
  79. package/templates/chat-app/lib/ai/gateways/fallback-models.ts +0 -29
  80. package/templates/chat-app/lib/ai/models.generated.ts +0 -4242
  81. package/templates/chat-app/lib/ai/usage-token-details.test.ts +0 -76
  82. package/templates/chat-app/lib/ai/usage-token-details.ts +0 -33
  83. package/templates/chat-app/scripts/fetch-models.ts +0 -30
  84. package/templates/chat-app/scripts/gateway-snapshot-warning.test.ts +0 -9
@@ -12,10 +12,12 @@ import {
12
12
  ChevronDownIcon,
13
13
  ChevronUpIcon,
14
14
  FilterIcon,
15
+ SearchIcon,
15
16
  } from "lucide-react";
16
17
  import React, {
17
18
  memo,
18
19
  useCallback,
20
+ useId,
19
21
  useMemo,
20
22
  useOptimistic,
21
23
  useState,
@@ -26,14 +28,9 @@ import { Badge } from "@/components/ui/badge";
26
28
 
27
29
  import { Button } from "@/components/ui/button";
28
30
 
29
- import {
30
- Command,
31
- CommandEmpty,
32
- CommandGroup,
33
- CommandInput,
34
- CommandList,
35
- CommandItem as UICommandItem,
36
- } from "@/components/ui/command";
31
+ import { Combobox } from "@base-ui/react/combobox";
32
+ import { defaultFilter } from "cmdk";
33
+ import { InputGroup, InputGroupAddon } from "@/components/ui/input-group";
37
34
 
38
35
  import {
39
36
  DropdownMenu,
@@ -148,7 +145,6 @@ const PureCommandItem = ({
148
145
  isSelected,
149
146
  count,
150
147
  showSelectionControl,
151
- onSelect,
152
148
  onCountChange,
153
149
  enabledFeatures,
154
150
  }: {
@@ -158,19 +154,12 @@ const PureCommandItem = ({
158
154
  readonly isSelected: boolean;
159
155
  readonly count?: number;
160
156
  readonly showSelectionControl: boolean;
161
- readonly onSelect: (id: AppModelId) => void;
162
157
  readonly onCountChange?: (id: AppModelId, delta: number) => void;
163
158
  }): ReactJSX.Element => {
164
159
  const featureIcons = useMemo(
165
160
  () => getFeatureIcons(model, enabledFeatures),
166
161
  [model, enabledFeatures]
167
162
  );
168
- const searchValue = useMemo(
169
- () =>
170
- `${model.name} ${model.reasoning ? "reasoning" : ""} ${model.owned_by} `.toLowerCase(),
171
- [model]
172
- );
173
-
174
163
  const reasoningConfig = useMemo(
175
164
  () =>
176
165
  enabledFeatures.find(
@@ -178,85 +167,111 @@ const PureCommandItem = ({
178
167
  ),
179
168
  [enabledFeatures]
180
169
  );
181
- const handleSelect = useCallback((): void => {
182
- if (disabled !== true) {
183
- onSelect(model.id);
184
- }
185
- }, [disabled, model, onSelect]);
186
-
187
170
  return (
188
- <UICommandItem
189
- aria-label={model.reasoning ? `${model.name} (reasoning)` : model.name}
190
- className={cn(
191
- "flex h-9 w-full cursor-pointer items-center justify-between px-3 py-1.5 transition-all",
192
- isSelected && "border-l-primary bg-primary/10 border-l-2",
193
- disabled === true && "cursor-not-allowed opacity-50"
194
- )}
195
- onSelect={handleSelect}
196
- value={searchValue}
197
- >
198
- <div className="flex min-w-0 flex-1 items-center gap-2.5">
199
- {showSelectionControl && (
200
- <ModelSelectionIndicator selected={isSelected} />
171
+ <div className="flex items-center gap-1">
172
+ <Combobox.Item
173
+ value={model.id}
174
+ disabled={disabled}
175
+ aria-label={model.reasoning ? `${model.name} (reasoning)` : model.name}
176
+ className={cn(
177
+ "data-highlighted:bg-muted flex h-9 min-w-0 flex-1 cursor-pointer items-center justify-between gap-2 rounded-xl border-s-2 border-transparent px-2.5 py-1.5 text-sm",
178
+ isSelected && "border-s-primary bg-primary/10",
179
+ disabled === true && "cursor-not-allowed opacity-50"
201
180
  )}
202
- <div className="shrink-0">
203
- <ModelSelectorLogo modelId={model.id} />
204
- </div>
205
- <span className="flex items-center gap-1.5 truncate text-sm font-medium">
206
- {model.name}
207
- {model.reasoning && reasoningConfig && (
208
- <span
209
- className="inline-flex shrink-0 items-center gap-1"
210
- title={reasoningConfig.description}
211
- >
212
- <reasoningConfig.icon className="text-muted-foreground h-3 w-3" />
213
- </span>
181
+ >
182
+ <div className="flex min-w-0 flex-1 items-center gap-2.5">
183
+ {showSelectionControl && (
184
+ <ModelSelectionIndicator selected={isSelected} />
214
185
  )}
215
- </span>
216
- </div>
217
- <div className="flex shrink-0 items-center gap-1">
218
- {featureIcons}
219
- {isSelected && onCountChange && count !== undefined && (
220
- <DropdownMenu>
221
- <DropdownMenuTrigger
222
- aria-label={`${count}×`}
223
- className="bg-primary/15 text-foreground hover:bg-primary/25 flex items-center gap-0.5 rounded-full px-1.5 py-0.5 text-xs font-semibold tabular-nums"
224
- type="button"
225
- onClick={stopEventPropagation}
226
- onMouseDown={stopEventPropagation}
227
- >
228
- {count}×
229
- <ChevronDownIcon className="h-2.5 w-2.5" />
230
- </DropdownMenuTrigger>
231
- <DropdownMenuContent align="end" onKeyDown={stopEventPropagation}>
232
- <DropdownMenuGroup>
233
- {[1, 2, 3, 4].map((modelCount): React.JSX.Element => (
234
- <DropdownMenuItem
235
- key={modelCount}
236
- onClick={(event: {
237
- readonly stopPropagation: () => void;
238
- }) => {
239
- event.stopPropagation();
240
- onCountChange(model.id, modelCount - count);
241
- }}
242
- >
243
- {modelCount}x
244
- {modelCount === count && (
245
- <CheckIcon className="ml-auto h-3 w-3" />
246
- )}
247
- </DropdownMenuItem>
248
- ))}
249
- </DropdownMenuGroup>
250
- </DropdownMenuContent>
251
- </DropdownMenu>
252
- )}
253
- </div>
254
- </UICommandItem>
186
+ <div className="shrink-0">
187
+ <ModelSelectorLogo modelId={model.id} />
188
+ </div>
189
+ <span className="flex items-center gap-1.5 truncate text-sm font-medium">
190
+ {model.name}
191
+ {model.reasoning && reasoningConfig && (
192
+ <span
193
+ className="inline-flex shrink-0 items-center gap-1"
194
+ title={reasoningConfig.description}
195
+ >
196
+ <reasoningConfig.icon className="text-muted-foreground h-3 w-3" />
197
+ </span>
198
+ )}
199
+ </span>
200
+ </div>
201
+ <div className="flex shrink-0 items-center gap-1">{featureIcons}</div>
202
+ </Combobox.Item>
203
+ {isSelected && onCountChange && count !== undefined && (
204
+ <DropdownMenu>
205
+ <DropdownMenuTrigger
206
+ aria-label={`${count}× ${model.name}`}
207
+ className="bg-primary/15 text-foreground hover:bg-primary/25 flex items-center gap-0.5 rounded-full px-1.5 py-0.5 text-xs font-semibold tabular-nums"
208
+ type="button"
209
+ onClick={stopEventPropagation}
210
+ onMouseDown={stopEventPropagation}
211
+ >
212
+ {count}×
213
+ <ChevronDownIcon className="h-2.5 w-2.5" />
214
+ </DropdownMenuTrigger>
215
+ <DropdownMenuContent align="end" onKeyDown={stopEventPropagation}>
216
+ <DropdownMenuGroup>
217
+ {[1, 2, 3, 4].map((modelCount): React.JSX.Element => (
218
+ <DropdownMenuItem
219
+ key={modelCount}
220
+ onClick={(event: {
221
+ readonly stopPropagation: () => void;
222
+ }) => {
223
+ event.stopPropagation();
224
+ onCountChange(model.id, modelCount - count);
225
+ }}
226
+ >
227
+ {modelCount}x
228
+ {modelCount === count && (
229
+ <CheckIcon className="ml-auto h-3 w-3" />
230
+ )}
231
+ </DropdownMenuItem>
232
+ ))}
233
+ </DropdownMenuGroup>
234
+ </DropdownMenuContent>
235
+ </DropdownMenu>
236
+ )}
237
+ </div>
255
238
  );
256
239
  };
257
240
 
258
241
  const CommandItem = memo(PureCommandItem);
259
242
 
243
+ const MultipleModelsSetting = ({
244
+ checked,
245
+ onCheckedChange,
246
+ }: {
247
+ readonly checked: boolean;
248
+ readonly onCheckedChange: (checked: boolean) => void;
249
+ }): ReactJSX.Element => {
250
+ const id = useId();
251
+ const descriptionId = `${id}-description`;
252
+ return (
253
+ <div className="space-y-1.5 border-b px-3 py-2">
254
+ <div className="flex items-center justify-between">
255
+ <Label className="cursor-pointer text-sm" htmlFor={id}>
256
+ Use Multiple Models
257
+ </Label>
258
+ <Switch
259
+ aria-describedby={checked ? descriptionId : undefined}
260
+ checked={checked}
261
+ id={id}
262
+ onCheckedChange={onCheckedChange}
263
+ />
264
+ </div>
265
+ {checked && (
266
+ <p className="text-muted-foreground text-xs" id={descriptionId}>
267
+ Each model replies in its own branch. Replies run one at a time and
268
+ share workspace files.
269
+ </p>
270
+ )}
271
+ </div>
272
+ );
273
+ };
274
+
260
275
  const PureModelSelector = ({
261
276
  allowMultiple = true,
262
277
  selectedModelId,
@@ -296,6 +311,7 @@ const PureModelSelector = ({
296
311
 
297
312
  const [, startTransition] = useTransition();
298
313
  const [open, setOpen] = useState(false);
314
+ const [search, setSearch] = useState("");
299
315
  const [filterOpen, setFilterOpen] = useState(false);
300
316
  const [optimisticSelection, setOptimisticSelection] = useOptimistic(
301
317
  selectedModelSelection
@@ -342,6 +358,11 @@ const PureModelSelector = ({
342
358
  );
343
359
  }, [optimisticSelection]);
344
360
 
361
+ const pickerValue = useMemo(
362
+ () => (useMultipleModels ? [...selectedModelIds] : optimisticModelId),
363
+ [useMultipleModels, selectedModelIds, optimisticModelId]
364
+ );
365
+
345
366
  const models = useMemo<ModelItem[]>(
346
367
  () =>
347
368
  chatModels.map(
@@ -414,6 +435,21 @@ const PureModelSelector = ({
414
435
  );
415
436
  }, [models, featureFilters]);
416
437
 
438
+ const matches = useMemo(() => {
439
+ if (!search.trim()) {
440
+ return filteredModels;
441
+ }
442
+ return filteredModels
443
+ .map((item) => {
444
+ const { model } = item;
445
+ const label = `${model.name} ${model.reasoning ? "reasoning" : ""} ${model.owned_by}`;
446
+ return { item, score: defaultFilter(label, search) };
447
+ })
448
+ .filter(({ score }) => score > 0)
449
+ .toSorted((a, b) => b.score - a.score)
450
+ .map(({ item }) => item);
451
+ }, [filteredModels, search]);
452
+
417
453
  const selectedItem = useMemo<ModelItem | null>(() => {
418
454
  // First try to find in filtered models (user's enabled models)
419
455
  const found = models.find(
@@ -478,45 +514,18 @@ const PureModelSelector = ({
478
514
  [onModelSelectionChangeAction, setOptimisticSelection, startTransition]
479
515
  );
480
516
 
481
- const selectSingleModel = useCallback(
482
- (id: AppModelId) => {
483
- dispatchSelection(id);
517
+ const changeModels = (value: string | string[] | null): void => {
518
+ if (typeof value === "string") {
519
+ dispatchSelection(value);
484
520
  setOpen(false);
485
- },
486
- [dispatchSelection, setOpen]
487
- );
488
-
489
- const toggleMultiModel = useCallback(
490
- (id: AppModelId) => {
491
- const current = optimisticSelection;
492
- const currentCounts: SelectedModelCounts =
493
- typeof current === "string" ? { [current]: 1 } : current;
494
-
495
- const isAlreadySelected = (currentCounts[id] ?? 0) > 0;
496
-
497
- let nextSelection: SelectedModelCounts;
498
- if (isAlreadySelected) {
499
- const remaining = Object.entries(currentCounts).filter(
500
- ([candidateId, selectionCount]: readonly [
501
- string,
502
- number | undefined,
503
- ]) =>
504
- candidateId !== id &&
505
- typeof selectionCount === "number" &&
506
- selectionCount > 0
507
- );
508
- if (remaining.length === 0) {
509
- return;
510
- }
511
- nextSelection = Object.fromEntries(remaining);
512
- } else {
513
- nextSelection = { ...currentCounts, [id]: 1 };
514
- }
515
-
516
- dispatchSelection(nextSelection);
517
- },
518
- [dispatchSelection, optimisticSelection]
519
- );
521
+ } else if (value && value.length > 0) {
522
+ const counts =
523
+ typeof optimisticSelection === "string" ? {} : optimisticSelection;
524
+ dispatchSelection(
525
+ Object.fromEntries(value.map((id) => [id, counts[id] ?? 1]))
526
+ );
527
+ }
528
+ };
520
529
 
521
530
  const handleCountChange = useCallback(
522
531
  (id: AppModelId, delta: number) => {
@@ -565,7 +574,15 @@ const PureModelSelector = ({
565
574
  );
566
575
 
567
576
  return (
568
- <Popover onOpenChange={setOpen} open={open}>
577
+ <Popover
578
+ onOpenChange={(nextOpen) => {
579
+ setOpen(nextOpen);
580
+ if (nextOpen) {
581
+ setSearch("");
582
+ }
583
+ }}
584
+ open={open}
585
+ >
569
586
  <PopoverButton
570
587
  aria-expanded={open}
571
588
  className={cn("flex w-fit justify-between gap-2 md:px-2", className)}
@@ -597,16 +614,40 @@ const PureModelSelector = ({
597
614
  )}
598
615
  />
599
616
  </PopoverButton>
600
- <PopoverContent align="start" className="w-[350px] p-0">
617
+ <PopoverContent
618
+ align="start"
619
+ className="w-[350px] max-w-[calc(100vw-1rem)] p-0"
620
+ >
601
621
  {open && (
602
- <Command>
603
- <div className="flex items-center border-b">
604
- <CommandInput
605
- className="px-3"
606
- onClick={stopEventPropagation}
607
- aria-label="Search models"
608
- placeholder="Search models..."
609
- />
622
+ <Combobox.Root<string, boolean>
623
+ inline
624
+ open
625
+ autoHighlight
626
+ multiple={useMultipleModels}
627
+ filteredItems={matches.map(({ model }) => model.id)}
628
+ value={pickerValue}
629
+ onValueChange={changeModels}
630
+ inputValue={search}
631
+ onInputValueChange={(value, details) => {
632
+ if (
633
+ details.reason === "input-change" ||
634
+ details.reason === "input-clear"
635
+ ) {
636
+ setSearch(value);
637
+ }
638
+ }}
639
+ >
640
+ <div className="flex items-center gap-1 border-b p-2">
641
+ <InputGroup className="h-8! min-w-0 flex-1">
642
+ <Combobox.Input
643
+ aria-label="Search models"
644
+ placeholder="Search models..."
645
+ className="w-full min-w-0 text-sm outline-hidden"
646
+ />
647
+ <InputGroupAddon>
648
+ <SearchIcon className="size-4 opacity-50" />
649
+ </InputGroupAddon>
650
+ </InputGroup>
610
651
  <Popover onOpenChange={setFilterOpen} open={filterOpen}>
611
652
  <PopoverButton
612
653
  aria-label="Filter models"
@@ -698,64 +739,48 @@ const PureModelSelector = ({
698
739
  </Popover>
699
740
  </div>
700
741
  {allowMultiple && (
701
- <div className="flex items-center justify-between border-b px-3 py-2">
702
- <Label
703
- className="cursor-pointer text-sm"
704
- htmlFor="use-multiple-models"
705
- >
706
- Use Multiple Models
707
- </Label>
708
- <Switch
709
- checked={useMultipleModels}
710
- id="use-multiple-models"
711
- onCheckedChange={handleMultipleModelsToggle}
712
- />
713
- </div>
742
+ <MultipleModelsSetting
743
+ checked={useMultipleModels}
744
+ onCheckedChange={handleMultipleModelsToggle}
745
+ />
714
746
  )}
715
747
  {hasDisabledModels && (
716
748
  <div className="p-3">{disabledModelsNotice}</div>
717
749
  )}
718
- <CommandList
719
- className="max-h-[min(40dvh,400px)]"
750
+ <Combobox.Empty className="text-center text-sm not-empty:py-6">
751
+ No model found.
752
+ </Combobox.Empty>
753
+ <Combobox.List
754
+ aria-label="Models"
755
+ className="max-h-[min(40dvh,400px)] overflow-y-auto p-2 empty:p-0"
720
756
  onMouseDown={stopEventPropagation}
721
757
  >
722
- <CommandEmpty>No model found.</CommandEmpty>
723
- <CommandGroup>
724
- {filteredModels.map(
725
- ({ model, disabled }: Readonly<ModelItem>) => {
726
- const isSelected = useMultipleModels
727
- ? selectedModelIds.has(model.id)
728
- : model.id === optimisticModelId;
729
- const count =
730
- useMultipleModels &&
731
- typeof optimisticSelection !== "string"
732
- ? (optimisticSelection[model.id] ?? 0)
733
- : undefined;
734
- return (
735
- <CommandItem
736
- count={isSelected ? count : undefined}
737
- disabled={disabled}
738
- isSelected={isSelected}
739
- key={model.id}
740
- model={model}
741
- enabledFeatures={enabledFeatures}
742
- onCountChange={
743
- useMultipleModels ? handleCountChange : undefined
744
- }
745
- onSelect={
746
- useMultipleModels
747
- ? toggleMultiModel
748
- : selectSingleModel
749
- }
750
- showSelectionControl={useMultipleModels}
751
- />
752
- );
753
- }
754
- )}
755
- </CommandGroup>
756
- </CommandList>
758
+ {matches.map(({ model, disabled }: Readonly<ModelItem>) => {
759
+ const isSelected = useMultipleModels
760
+ ? selectedModelIds.has(model.id)
761
+ : model.id === optimisticModelId;
762
+ const count =
763
+ useMultipleModels && typeof optimisticSelection !== "string"
764
+ ? (optimisticSelection[model.id] ?? 0)
765
+ : undefined;
766
+ return (
767
+ <CommandItem
768
+ count={isSelected ? count : undefined}
769
+ disabled={disabled}
770
+ isSelected={isSelected}
771
+ key={model.id}
772
+ model={model}
773
+ enabledFeatures={enabledFeatures}
774
+ onCountChange={
775
+ useMultipleModels ? handleCountChange : undefined
776
+ }
777
+ showSelectionControl={useMultipleModels}
778
+ />
779
+ );
780
+ })}
781
+ </Combobox.List>
757
782
  {footer}
758
- </Command>
783
+ </Combobox.Root>
759
784
  )}
760
785
  </PopoverContent>
761
786
  </Popover>
@@ -31,7 +31,7 @@ export const NewChatButton = (): ReactJSX.Element => {
31
31
  globalThis.dispatchEvent(new Event("chatjs:new-chat"));
32
32
  }}
33
33
  >
34
- <Plus aria-label="New Chat" size={16} />
34
+ <Plus aria-hidden size={16} />
35
35
  <span>New Chat</span>
36
36
  <span className="text-muted-foreground ml-auto text-xs">
37
37
  {shortcutText}
@@ -12,7 +12,7 @@ export const SettingsNav = ({
12
12
  <nav
13
13
  className={cn(
14
14
  "flex gap-1 sm:overflow-auto sm:pb-2",
15
- orientation === "vertical" ? "w-56 flex-col" : "flex-row"
15
+ orientation === "vertical" ? "w-56 flex-col" : "flex-row flex-wrap"
16
16
  )}
17
17
  >
18
18
  <SettingsLink href="/settings">
@@ -17,6 +17,7 @@ export const SettingsLink = ({
17
17
  href === "/settings" ? pathname === href : pathname.startsWith(href);
18
18
  return (
19
19
  <InternalLink
20
+ aria-current={active ? "page" : undefined}
20
21
  href={href}
21
22
  className={cn(
22
23
  "text-muted-foreground hover:bg-muted hover:text-foreground flex items-center gap-2 rounded-md px-3 py-2.5 transition-colors",
@@ -31,7 +31,7 @@ export const SidebarTopRow = (): ReactJSX.Element => {
31
31
  >
32
32
  <span className="hover:bg-muted flex cursor-pointer items-center gap-2 rounded-md p-1 text-lg font-semibold">
33
33
  <Image
34
- alt={config.appName}
34
+ alt=""
35
35
  className="h-5 w-5"
36
36
  height={20}
37
37
  src="/icon.svg"
@@ -362,7 +362,7 @@ function SidebarSeparator({
362
362
  <Separator
363
363
  data-slot="sidebar-separator"
364
364
  data-sidebar="separator"
365
- className={cn("mx-2 w-auto bg-sidebar-border", className)}
365
+ className={cn("mx-2 bg-sidebar-border data-horizontal:w-auto", className)}
366
366
  {...props}
367
367
  />
368
368
  )
@@ -73,7 +73,7 @@ function TraceDescription({
73
73
  <span
74
74
  data-slot="trace-description"
75
75
  className={cn(
76
- "shrink-0 text-muted-foreground/70 tabular-nums",
76
+ "shrink-0 text-muted-foreground tabular-nums",
77
77
  className
78
78
  )}
79
79
  {...props}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
- import type { LexicalEditor } from "lexical";
4
- import { useEffect } from "react";
3
+ import type { RefObject } from "react";
4
+ import { useEffect, useRef } from "react";
5
5
 
6
6
  const FALLBACK_FOCUS_TIMEOUT_MS = 120;
7
7
 
@@ -15,15 +15,13 @@ const isTypingSurface = (element: unknown): boolean =>
15
15
  !element.disabled) ||
16
16
  (element instanceof HTMLElement && element.isContentEditable);
17
17
 
18
- export const useAutoFocus = ({
19
- autoFocus,
20
- editor,
21
- }: {
22
- readonly autoFocus: boolean;
23
- readonly editor: Readonly<Pick<LexicalEditor, "focus">> | null;
24
- }): void => {
18
+ export const useAutoFocus = (
19
+ autoFocus: boolean
20
+ ): RefObject<HTMLTextAreaElement | null> => {
21
+ const ref = useRef<HTMLTextAreaElement>(null);
25
22
  useEffect((): (() => void) | undefined => {
26
- if (!(autoFocus && editor)) {
23
+ const input = ref.current;
24
+ if (!autoFocus || !input) {
27
25
  return undefined;
28
26
  }
29
27
 
@@ -34,14 +32,14 @@ export const useAutoFocus = ({
34
32
  const isUserTypingElsewhere = isTypingSurface(active);
35
33
 
36
34
  if (!isUserTypingElsewhere) {
37
- editor.focus();
35
+ input.focus({ preventScroll: true });
38
36
  // Minimal fallback for hydration/layout races where focus is stolen.
39
37
  fallbackTimeout = window.setTimeout(() => {
40
38
  const currentActive = document.activeElement;
41
39
  const canSafelyStealFocus = !isTypingSurface(currentActive);
42
40
 
43
41
  if (canSafelyStealFocus) {
44
- editor.focus();
42
+ input.focus({ preventScroll: true });
45
43
  }
46
44
  }, FALLBACK_FOCUS_TIMEOUT_MS);
47
45
  }
@@ -53,5 +51,6 @@ export const useAutoFocus = ({
53
51
  globalThis.clearTimeout(fallbackTimeout);
54
52
  }
55
53
  };
56
- }, [autoFocus, editor]);
54
+ }, [autoFocus]);
55
+ return ref;
57
56
  };
@@ -1,23 +1,14 @@
1
1
  import { createGateway } from "@/integrations/providers/gateway";
2
2
  import type { GatewayProvider } from "./gateways/registry";
3
- import type { ReadonlyNativeSurface } from "@/lib/readonly-native-surface";
4
3
  import { config } from "@/lib/config";
5
4
  import { createModuleLogger } from "@/lib/logger";
6
5
  import { gatewayEnv } from "@/lib/env";
7
- import { getFallbackModels } from "./gateways/fallback-models";
8
6
 
9
7
  let activeGateway: GatewayProvider | null = null;
10
8
 
11
9
  export const getActiveGateway = (): GatewayProvider => {
12
10
  activeGateway ??= createGateway({
13
11
  env: gatewayEnv,
14
- fetch: async (
15
- input: string | ReadonlyNativeSurface<URL | Request>,
16
-
17
- init
18
- ): Promise<Response> =>
19
- await fetch(input, { ...init, next: { revalidate: 3600 } }),
20
- getFallbackModels,
21
12
  logger: createModuleLogger(`ai/gateways/${config.ai.gateway}`),
22
13
  });
23
14
  return activeGateway;
@@ -7,10 +7,6 @@ import { getDefaultWebChatModelId } from "./web-chat-models";
7
7
 
8
8
  const modelSettings = vi.hoisted((): { modelIds?: string[] } => ({}));
9
9
 
10
- vi.mock("next/cache", () => ({
11
- unstable_cache: <Result>(operation: () => Result): (() => Result) =>
12
- operation,
13
- }));
14
10
  vi.mock("@/lib/config", () => ({
15
11
  config: {
16
12
  ai: {