-
Notifications
You must be signed in to change notification settings - Fork 878
Expand file tree
/
Copy path_chat.settings.tsx
More file actions
853 lines (801 loc) · 35.8 KB
/
_chat.settings.tsx
File metadata and controls
853 lines (801 loc) · 35.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
import { createFileRoute } from "@tanstack/react-router";
import { useQuery } from "@tanstack/react-query";
import { useCallback, useState } from "react";
import { type ProviderKind } from "@t3tools/contracts";
import { getModelOptions, normalizeModelSlug } from "@t3tools/shared/model";
import { MAX_CUSTOM_MODEL_LENGTH, useAppSettings } from "../appSettings";
import { resolveAndPersistPreferredEditor } from "../editorPreferences";
import { isElectron } from "../env";
import { useTheme } from "../hooks/useTheme";
import { serverConfigQueryOptions } from "../lib/serverReactQuery";
import { ensureNativeApi } from "../nativeApi";
import { Button } from "../components/ui/button";
import { Input } from "../components/ui/input";
import {
Select,
SelectItem,
SelectPopup,
SelectTrigger,
SelectValue,
} from "../components/ui/select";
import { Switch } from "../components/ui/switch";
import { APP_VERSION } from "../branding";
import { SidebarInset } from "~/components/ui/sidebar";
const THEME_OPTIONS = [
{
value: "system",
label: "System",
description: "Match your OS appearance setting.",
},
{
value: "light",
label: "Light",
description: "Always use the light theme.",
},
{
value: "dark",
label: "Dark",
description: "Always use the dark theme.",
},
] as const;
const MODEL_PROVIDER_SETTINGS: Array<{
provider: ProviderKind;
title: string;
description: string;
placeholder: string;
example: string;
}> = [
{
provider: "codex",
title: "Codex",
description: "Save additional Codex model slugs for the picker and `/model` command.",
placeholder: "your-codex-model-slug",
example: "gpt-6.7-codex-ultra-preview",
},
] as const;
const TIMESTAMP_FORMAT_LABELS = {
locale: "System default",
"12-hour": "12-hour",
"24-hour": "24-hour",
} as const;
function getCustomModelsForProvider(
settings: ReturnType<typeof useAppSettings>["settings"],
provider: ProviderKind,
) {
switch (provider) {
case "codex":
default:
return settings.customCodexModels;
}
}
function getDefaultCustomModelsForProvider(
defaults: ReturnType<typeof useAppSettings>["defaults"],
provider: ProviderKind,
) {
switch (provider) {
case "codex":
default:
return defaults.customCodexModels;
}
}
function patchCustomModels(provider: ProviderKind, models: string[]) {
switch (provider) {
case "codex":
default:
return { customCodexModels: models };
}
}
function SettingsRouteView() {
const { theme, setTheme, resolvedTheme } = useTheme();
const { settings, defaults, updateSettings } = useAppSettings();
const serverConfigQuery = useQuery(serverConfigQueryOptions());
const [isOpeningKeybindings, setIsOpeningKeybindings] = useState(false);
const [openKeybindingsError, setOpenKeybindingsError] = useState<string | null>(null);
const [customModelInputByProvider, setCustomModelInputByProvider] = useState<
Record<ProviderKind, string>
>({
codex: "",
claudeCode: "",
});
const [customModelErrorByProvider, setCustomModelErrorByProvider] = useState<
Partial<Record<ProviderKind, string | null>>
>({});
const codexBinaryPath = settings.codexBinaryPath;
const codexHomePath = settings.codexHomePath;
const keybindingsConfigPath = serverConfigQuery.data?.keybindingsConfigPath ?? null;
const availableEditors = serverConfigQuery.data?.availableEditors;
const openKeybindingsFile = useCallback(() => {
if (!keybindingsConfigPath) return;
setOpenKeybindingsError(null);
setIsOpeningKeybindings(true);
const api = ensureNativeApi();
const editor = resolveAndPersistPreferredEditor(availableEditors ?? []);
if (!editor) {
setOpenKeybindingsError("No available editors found.");
setIsOpeningKeybindings(false);
return;
}
void api.shell
.openInEditor(keybindingsConfigPath, editor)
.catch((error) => {
setOpenKeybindingsError(
error instanceof Error ? error.message : "Unable to open keybindings file.",
);
})
.finally(() => {
setIsOpeningKeybindings(false);
});
}, [availableEditors, keybindingsConfigPath]);
const addCustomModel = useCallback(
(provider: ProviderKind) => {
const customModelInput = customModelInputByProvider[provider];
const customModels = getCustomModelsForProvider(settings, provider);
const normalized = normalizeModelSlug(customModelInput, provider);
if (!normalized) {
setCustomModelErrorByProvider((existing) => ({
...existing,
[provider]: "Enter a model slug.",
}));
return;
}
if (getModelOptions(provider).some((option) => option.slug === normalized)) {
setCustomModelErrorByProvider((existing) => ({
...existing,
[provider]: "That model is already built in.",
}));
return;
}
if (normalized.length > MAX_CUSTOM_MODEL_LENGTH) {
setCustomModelErrorByProvider((existing) => ({
...existing,
[provider]: `Model slugs must be ${MAX_CUSTOM_MODEL_LENGTH} characters or less.`,
}));
return;
}
if (customModels.includes(normalized)) {
setCustomModelErrorByProvider((existing) => ({
...existing,
[provider]: "That custom model is already saved.",
}));
return;
}
updateSettings(patchCustomModels(provider, [...customModels, normalized]));
setCustomModelInputByProvider((existing) => ({
...existing,
[provider]: "",
}));
setCustomModelErrorByProvider((existing) => ({
...existing,
[provider]: null,
}));
},
[customModelInputByProvider, settings, updateSettings],
);
const removeCustomModel = useCallback(
(provider: ProviderKind, slug: string) => {
const customModels = getCustomModelsForProvider(settings, provider);
updateSettings(
patchCustomModels(
provider,
customModels.filter((model) => model !== slug),
),
);
setCustomModelErrorByProvider((existing) => ({
...existing,
[provider]: null,
}));
},
[settings, updateSettings],
);
return (
<SidebarInset className="h-dvh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground isolate">
<div className="flex min-h-0 min-w-0 flex-1 flex-col bg-background text-foreground">
{isElectron && (
<div className="drag-region flex h-[52px] shrink-0 items-center border-b border-border px-5">
<span className="text-xs font-medium tracking-wide text-muted-foreground/70">
Settings
</span>
</div>
)}
<div className="flex-1 overflow-y-auto p-6">
<div className="mx-auto flex w-full max-w-3xl flex-col gap-6">
<header className="space-y-1">
<h1 className="text-2xl font-semibold tracking-tight text-foreground">Settings</h1>
<p className="text-sm text-muted-foreground">
Configure app-level preferences for this device.
</p>
</header>
<section className="rounded-2xl border border-border bg-card p-5">
<div className="mb-4">
<h2 className="text-sm font-medium text-foreground">Appearance</h2>
<p className="mt-1 text-xs text-muted-foreground">
Choose how T3 Code looks across the app.
</p>
</div>
<div className="space-y-4">
<div className="space-y-2" role="radiogroup" aria-label="Theme preference">
{THEME_OPTIONS.map((option) => {
const selected = theme === option.value;
return (
<button
key={option.value}
type="button"
role="radio"
aria-checked={selected}
className={`flex w-full items-start justify-between rounded-lg border px-3 py-2 text-left transition-colors ${
selected
? "border-primary/60 bg-primary/8 text-foreground"
: "border-border bg-background text-muted-foreground hover:bg-accent"
}`}
onClick={() => setTheme(option.value)}
>
<span className="flex flex-col">
<span className="text-sm font-medium">{option.label}</span>
<span className="text-xs">{option.description}</span>
</span>
{selected ? (
<span className="rounded bg-primary/14 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary">
Selected
</span>
) : null}
</button>
);
})}
</div>
<p className="text-xs text-muted-foreground">
Active theme: <span className="font-medium text-foreground">{resolvedTheme}</span>
</p>
<div className="flex items-center justify-between rounded-lg border border-border bg-background px-3 py-2">
<div>
<p className="text-sm font-medium text-foreground">Timestamp format</p>
<p className="text-xs text-muted-foreground">
System default follows your browser or OS time format. <code>12-hour</code>{" "}
and <code>24-hour</code> force the hour cycle.
</p>
</div>
<Select
value={settings.timestampFormat}
onValueChange={(value) => {
if (value !== "locale" && value !== "12-hour" && value !== "24-hour") return;
updateSettings({
timestampFormat: value,
});
}}
>
<SelectTrigger className="w-40" aria-label="Timestamp format">
<SelectValue>{TIMESTAMP_FORMAT_LABELS[settings.timestampFormat]}</SelectValue>
</SelectTrigger>
<SelectPopup align="end">
<SelectItem value="locale">{TIMESTAMP_FORMAT_LABELS.locale}</SelectItem>
<SelectItem value="12-hour">{TIMESTAMP_FORMAT_LABELS["12-hour"]}</SelectItem>
<SelectItem value="24-hour">{TIMESTAMP_FORMAT_LABELS["24-hour"]}</SelectItem>
</SelectPopup>
</Select>
</div>
{settings.timestampFormat !== defaults.timestampFormat ? (
<div className="flex justify-end">
<Button
size="xs"
variant="outline"
onClick={() =>
updateSettings({
timestampFormat: defaults.timestampFormat,
})
}
>
Restore default
</Button>
</div>
) : null}
</div>
</section>
<section className="rounded-2xl border border-border bg-card p-5">
<div className="mb-4">
<h2 className="text-sm font-medium text-foreground">Codex App Server</h2>
<p className="mt-1 text-xs text-muted-foreground">
These overrides apply to new sessions and let you use a non-default Codex install.
</p>
</div>
<div className="space-y-4">
<label htmlFor="codex-binary-path" className="block space-y-1">
<span className="text-xs font-medium text-foreground">Codex binary path</span>
<Input
id="codex-binary-path"
value={codexBinaryPath}
onChange={(event) => updateSettings({ codexBinaryPath: event.target.value })}
placeholder="codex"
spellCheck={false}
/>
<span className="text-xs text-muted-foreground">
Leave blank to use <code>codex</code> from your PATH.
</span>
</label>
<label htmlFor="codex-home-path" className="block space-y-1">
<span className="text-xs font-medium text-foreground">CODEX_HOME path</span>
<Input
id="codex-home-path"
value={codexHomePath}
onChange={(event) => updateSettings({ codexHomePath: event.target.value })}
placeholder="/Users/you/.codex"
spellCheck={false}
/>
<span className="text-xs text-muted-foreground">
Optional custom Codex home/config directory.
</span>
</label>
<div className="flex flex-col gap-3 text-xs text-muted-foreground sm:flex-row sm:items-start sm:justify-between">
<div className="min-w-0 flex-1">
<p>Binary source</p>
<p className="mt-1 break-all font-mono text-[11px] text-foreground">
{codexBinaryPath || "PATH"}
</p>
</div>
<Button
size="xs"
variant="outline"
className="self-start"
onClick={() =>
updateSettings({
codexBinaryPath: defaults.codexBinaryPath,
codexHomePath: defaults.codexHomePath,
})
}
>
Reset codex overrides
</Button>
</div>
</div>
</section>
<section className="rounded-2xl border border-border bg-card p-5">
<div className="mb-4">
<h2 className="text-sm font-medium text-foreground">Claude Code</h2>
<p className="mt-1 text-xs text-muted-foreground">
Configure Claude Code for use with AWS Bedrock. Once enabled, Claude Code will
appear as an available provider in the chat model picker.
</p>
</div>
<div className="space-y-4">
<label htmlFor="claude-code-binary-path" className="block space-y-1">
<span className="text-xs font-medium text-foreground">
Claude Code binary path
</span>
<Input
id="claude-code-binary-path"
value={settings.claudeCodeBinaryPath}
onChange={(event) =>
updateSettings({ claudeCodeBinaryPath: event.target.value })
}
placeholder="claude"
spellCheck={false}
/>
<span className="text-xs text-muted-foreground">
Leave blank to use <code>claude</code> from your PATH.
</span>
</label>
<div className="flex items-center justify-between rounded-lg border border-border bg-background px-3 py-2">
<div>
<p className="text-sm font-medium text-foreground">Use AWS Bedrock</p>
<p className="text-xs text-muted-foreground">
Route Claude Code requests through your AWS account via{" "}
<code>CLAUDE_CODE_USE_BEDROCK</code>. Requires AWS credentials and Bedrock
model access.
</p>
</div>
<Switch
checked={settings.claudeCodeUseBedrock}
onCheckedChange={(checked) =>
updateSettings({ claudeCodeUseBedrock: Boolean(checked) })
}
aria-label="Use AWS Bedrock for Claude Code"
/>
</div>
{settings.claudeCodeUseBedrock && (
<div className="space-y-4 rounded-xl border border-border bg-background/50 p-4">
<label htmlFor="claude-code-aws-region" className="block space-y-1">
<span className="text-xs font-medium text-foreground">AWS region</span>
<Input
id="claude-code-aws-region"
value={settings.claudeCodeAwsRegion}
onChange={(event) =>
updateSettings({ claudeCodeAwsRegion: event.target.value })
}
placeholder="us-east-1"
spellCheck={false}
/>
<span className="text-xs text-muted-foreground">
The AWS region where your Bedrock models are available.
</span>
</label>
<label htmlFor="claude-code-aws-profile" className="block space-y-1">
<span className="text-xs font-medium text-foreground">
AWS profile{" "}
<span className="font-normal text-muted-foreground">(optional)</span>
</span>
<Input
id="claude-code-aws-profile"
value={settings.claudeCodeAwsProfile}
onChange={(event) =>
updateSettings({ claudeCodeAwsProfile: event.target.value })
}
placeholder="default"
spellCheck={false}
/>
<span className="text-xs text-muted-foreground">
Named AWS profile from <code>~/.aws/credentials</code>. Leave blank to use
the default credential chain.
</span>
</label>
<div className="space-y-1">
<p className="text-xs font-medium text-foreground">
Model ARN overrides{" "}
<span className="font-normal text-muted-foreground">(optional)</span>
</p>
<p className="text-xs text-muted-foreground">
Override the default Bedrock model IDs with specific inference profile ARNs.
Leave blank to use the default model IDs.
</p>
</div>
{(
[
{
id: "claude-code-bedrock-arn-haiku",
label: "Haiku ARN",
settingKey: "claudeCodeBedrockArnHaiku",
placeholder: "arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-haiku-...",
},
{
id: "claude-code-bedrock-arn-sonnet",
label: "Sonnet ARN",
settingKey: "claudeCodeBedrockArnSonnet",
placeholder: "arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-sonnet-...",
},
{
id: "claude-code-bedrock-arn-opus",
label: "Opus ARN",
settingKey: "claudeCodeBedrockArnOpus",
placeholder: "arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-opus-...",
},
] as const
).map((field) => (
<label key={field.id} htmlFor={field.id} className="block space-y-1">
<span className="text-xs font-medium text-foreground">{field.label}</span>
<Input
id={field.id}
value={settings[field.settingKey]}
onChange={(event) =>
updateSettings({ [field.settingKey]: event.target.value })
}
placeholder={field.placeholder}
spellCheck={false}
className="font-mono text-xs"
/>
</label>
))}
</div>
)}
<div className="flex justify-end">
<Button
size="xs"
variant="outline"
onClick={() =>
updateSettings({
claudeCodeBinaryPath: defaults.claudeCodeBinaryPath,
claudeCodeUseBedrock: defaults.claudeCodeUseBedrock,
claudeCodeAwsRegion: defaults.claudeCodeAwsRegion,
claudeCodeAwsProfile: defaults.claudeCodeAwsProfile,
claudeCodeBedrockArnHaiku: defaults.claudeCodeBedrockArnHaiku,
claudeCodeBedrockArnSonnet: defaults.claudeCodeBedrockArnSonnet,
claudeCodeBedrockArnOpus: defaults.claudeCodeBedrockArnOpus,
})
}
>
Reset Claude Code overrides
</Button>
</div>
</div>
</section>
<section className="rounded-2xl border border-border bg-card p-5">
<div className="mb-4">
<h2 className="text-sm font-medium text-foreground">Models</h2>
<p className="mt-1 text-xs text-muted-foreground">
Save additional provider model slugs so they appear in the chat model picker and
`/model` command suggestions.
</p>
</div>
<div className="space-y-5">
{MODEL_PROVIDER_SETTINGS.map((providerSettings) => {
const provider = providerSettings.provider;
const customModels = getCustomModelsForProvider(settings, provider);
const customModelInput = customModelInputByProvider[provider];
const customModelError = customModelErrorByProvider[provider] ?? null;
return (
<div
key={provider}
className="rounded-xl border border-border bg-background/50 p-4"
>
<div className="mb-4">
<h3 className="text-sm font-medium text-foreground">
{providerSettings.title}
</h3>
<p className="mt-1 text-xs text-muted-foreground">
{providerSettings.description}
</p>
</div>
<div className="space-y-4">
<div className="flex flex-col gap-3 sm:flex-row sm:items-start">
<label
htmlFor={`custom-model-slug-${provider}`}
className="block flex-1 space-y-1"
>
<span className="text-xs font-medium text-foreground">
Custom model slug
</span>
<Input
id={`custom-model-slug-${provider}`}
value={customModelInput}
onChange={(event) => {
const value = event.target.value;
setCustomModelInputByProvider((existing) => ({
...existing,
[provider]: value,
}));
if (customModelError) {
setCustomModelErrorByProvider((existing) => ({
...existing,
[provider]: null,
}));
}
}}
onKeyDown={(event) => {
if (event.key !== "Enter") return;
event.preventDefault();
addCustomModel(provider);
}}
placeholder={providerSettings.placeholder}
spellCheck={false}
/>
<span className="text-xs text-muted-foreground">
Example: <code>{providerSettings.example}</code>
</span>
</label>
<Button
className="sm:mt-6"
type="button"
onClick={() => addCustomModel(provider)}
>
Add model
</Button>
</div>
{customModelError ? (
<p className="text-xs text-destructive">{customModelError}</p>
) : null}
<div className="space-y-2">
<div className="flex items-center justify-between gap-2 text-xs text-muted-foreground">
<p>Saved custom models: {customModels.length}</p>
{customModels.length > 0 ? (
<Button
size="xs"
variant="outline"
onClick={() =>
updateSettings(
patchCustomModels(provider, [
...getDefaultCustomModelsForProvider(defaults, provider),
]),
)
}
>
Reset custom models
</Button>
) : null}
</div>
{customModels.length > 0 ? (
<div className="space-y-2">
{customModels.map((slug) => (
<div
key={`${provider}:${slug}`}
className="flex items-center justify-between gap-3 rounded-lg border border-border bg-background px-3 py-2"
>
<code className="min-w-0 flex-1 truncate text-xs text-foreground">
{slug}
</code>
<Button
size="xs"
variant="ghost"
onClick={() => removeCustomModel(provider, slug)}
>
Remove
</Button>
</div>
))}
</div>
) : (
<div className="rounded-lg border border-dashed border-border bg-background px-3 py-4 text-xs text-muted-foreground">
No custom models saved yet.
</div>
)}
</div>
</div>
</div>
);
})}
</div>
</section>
<section className="rounded-2xl border border-border bg-card p-5">
<div className="mb-4">
<h2 className="text-sm font-medium text-foreground">Threads</h2>
<p className="mt-1 text-xs text-muted-foreground">
Choose the default workspace mode for newly created draft threads.
</p>
</div>
<div className="flex items-center justify-between rounded-lg border border-border bg-background px-3 py-2">
<div>
<p className="text-sm font-medium text-foreground">Default to New worktree</p>
<p className="text-xs text-muted-foreground">
New threads start in New worktree mode instead of Local.
</p>
</div>
<Switch
checked={settings.defaultThreadEnvMode === "worktree"}
onCheckedChange={(checked) =>
updateSettings({
defaultThreadEnvMode: checked ? "worktree" : "local",
})
}
aria-label="Default new threads to New worktree mode"
/>
</div>
{settings.defaultThreadEnvMode !== defaults.defaultThreadEnvMode ? (
<div className="mt-3 flex justify-end">
<Button
size="xs"
variant="outline"
onClick={() =>
updateSettings({
defaultThreadEnvMode: defaults.defaultThreadEnvMode,
})
}
>
Restore default
</Button>
</div>
) : null}
</section>
<section className="rounded-2xl border border-border bg-card p-5">
<div className="mb-4">
<h2 className="text-sm font-medium text-foreground">Responses</h2>
<p className="mt-1 text-xs text-muted-foreground">
Control how assistant output is rendered during a turn.
</p>
</div>
<div className="flex items-center justify-between rounded-lg border border-border bg-background px-3 py-2">
<div>
<p className="text-sm font-medium text-foreground">Stream assistant messages</p>
<p className="text-xs text-muted-foreground">
Show token-by-token output while a response is in progress.
</p>
</div>
<Switch
checked={settings.enableAssistantStreaming}
onCheckedChange={(checked) =>
updateSettings({
enableAssistantStreaming: Boolean(checked),
})
}
aria-label="Stream assistant messages"
/>
</div>
{settings.enableAssistantStreaming !== defaults.enableAssistantStreaming ? (
<div className="mt-3 flex justify-end">
<Button
size="xs"
variant="outline"
onClick={() =>
updateSettings({
enableAssistantStreaming: defaults.enableAssistantStreaming,
})
}
>
Restore default
</Button>
</div>
) : null}
</section>
<section className="rounded-2xl border border-border bg-card p-5">
<div className="mb-4">
<h2 className="text-sm font-medium text-foreground">Keybindings</h2>
<p className="mt-1 text-xs text-muted-foreground">
Open the persisted <code>keybindings.json</code> file to edit advanced bindings
directly.
</p>
</div>
<div className="space-y-3">
<div className="flex items-center justify-between gap-3 rounded-lg border border-border bg-background px-3 py-2">
<div className="min-w-0 flex-1">
<p className="text-xs font-medium text-foreground">Config file path</p>
<p className="mt-1 break-all font-mono text-[11px] text-muted-foreground">
{keybindingsConfigPath ?? "Resolving keybindings path..."}
</p>
</div>
<Button
size="xs"
variant="outline"
disabled={!keybindingsConfigPath || isOpeningKeybindings}
onClick={openKeybindingsFile}
>
{isOpeningKeybindings ? "Opening..." : "Open keybindings.json"}
</Button>
</div>
<p className="text-xs text-muted-foreground">
Opens in your preferred editor selection.
</p>
{openKeybindingsError ? (
<p className="text-xs text-destructive">{openKeybindingsError}</p>
) : null}
</div>
</section>
<section className="rounded-2xl border border-border bg-card p-5">
<div className="mb-4">
<h2 className="text-sm font-medium text-foreground">Safety</h2>
<p className="mt-1 text-xs text-muted-foreground">
Additional guardrails for destructive local actions.
</p>
</div>
<div className="flex items-center justify-between rounded-lg border border-border bg-background px-3 py-2">
<div>
<p className="text-sm font-medium text-foreground">Confirm thread deletion</p>
<p className="text-xs text-muted-foreground">
Ask for confirmation before deleting a thread and its chat history.
</p>
</div>
<Switch
checked={settings.confirmThreadDelete}
onCheckedChange={(checked) =>
updateSettings({
confirmThreadDelete: Boolean(checked),
})
}
aria-label="Confirm thread deletion"
/>
</div>
{settings.confirmThreadDelete !== defaults.confirmThreadDelete ? (
<div className="mt-3 flex justify-end">
<Button
size="xs"
variant="outline"
onClick={() =>
updateSettings({
confirmThreadDelete: defaults.confirmThreadDelete,
})
}
>
Restore default
</Button>
</div>
) : null}
</section>
<section className="rounded-2xl border border-border bg-card p-5">
<div className="mb-4">
<h2 className="text-sm font-medium text-foreground">About</h2>
<p className="mt-1 text-xs text-muted-foreground">
Application version and environment information.
</p>
</div>
<div className="flex items-center justify-between rounded-lg border border-border bg-background px-3 py-2">
<div>
<p className="text-sm font-medium text-foreground">Version</p>
<p className="text-xs text-muted-foreground">
Current version of the application.
</p>
</div>
<code className="text-xs font-medium text-muted-foreground">{APP_VERSION}</code>
</div>
</section>
</div>
</div>
</div>
</SidebarInset>
);
}
export const Route = createFileRoute("/_chat/settings")({
component: SettingsRouteView,
});