-
Notifications
You must be signed in to change notification settings - Fork 598
Expand file tree
/
Copy pathagents-preferences-tab.tsx
More file actions
495 lines (475 loc) · 19.1 KB
/
agents-preferences-tab.tsx
File metadata and controls
495 lines (475 loc) · 19.1 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
import { useAtom } from "jotai"
import { useEffect, useState } from "react"
import {
analyticsOptOutAtom,
autoAdvanceTargetAtom,
ctrlTabTargetAtom,
defaultAgentModeAtom,
desktopNotificationsEnabledAtom,
notifyWhenFocusedAtom,
soundNotificationsEnabledAtom,
preferredEditorAtom,
type AgentMode,
type AutoAdvanceTarget,
type CtrlTabTarget,
} from "../../../lib/atoms"
import { lastSelectedClaudeThinkingAtom } from "../../../features/agents/atoms"
import {
formatClaudeThinkingLabel,
type ClaudeThinkingLevel,
} from "../../../features/agents/lib/models"
import { APP_META, type ExternalApp } from "../../../../shared/external-apps"
// Editor icon imports
import cursorIcon from "../../../assets/app-icons/cursor.svg"
import vscodeIcon from "../../../assets/app-icons/vscode.svg"
import vscodeInsidersIcon from "../../../assets/app-icons/vscode-insiders.svg"
import zedIcon from "../../../assets/app-icons/zed.png"
import sublimeIcon from "../../../assets/app-icons/sublime.svg"
import xcodeIcon from "../../../assets/app-icons/xcode.svg"
import intellijIcon from "../../../assets/app-icons/intellij.svg"
import webstormIcon from "../../../assets/app-icons/webstorm.svg"
import pycharmIcon from "../../../assets/app-icons/pycharm.svg"
import phpstormIcon from "../../../assets/app-icons/phpstorm.svg"
import golandIcon from "../../../assets/app-icons/goland.svg"
import clionIcon from "../../../assets/app-icons/clion.svg"
import riderIcon from "../../../assets/app-icons/rider.svg"
import fleetIcon from "../../../assets/app-icons/fleet.svg"
import rustroverIcon from "../../../assets/app-icons/rustrover.svg"
import windsurfIcon from "../../../assets/app-icons/windsurf.svg"
import traeIcon from "../../../assets/app-icons/trae.svg"
import itermIcon from "../../../assets/app-icons/iterm.png"
import warpIcon from "../../../assets/app-icons/warp.png"
import terminalIcon from "../../../assets/app-icons/terminal.png"
import ghosttyIcon from "../../../assets/app-icons/ghostty.svg"
const EDITOR_ICONS: Partial<Record<ExternalApp, string>> = {
cursor: cursorIcon,
vscode: vscodeIcon,
"vscode-insiders": vscodeInsidersIcon,
zed: zedIcon,
windsurf: windsurfIcon,
sublime: sublimeIcon,
xcode: xcodeIcon,
trae: traeIcon,
iterm: itermIcon,
warp: warpIcon,
terminal: terminalIcon,
ghostty: ghosttyIcon,
intellij: intellijIcon,
webstorm: webstormIcon,
pycharm: pycharmIcon,
phpstorm: phpstormIcon,
goland: golandIcon,
clion: clionIcon,
rider: riderIcon,
fleet: fleetIcon,
rustrover: rustroverIcon,
}
interface EditorOption {
id: ExternalApp
label: string
}
// Order matches Superset: editors, terminals, VS Code, JetBrains
const EDITORS: EditorOption[] = [
{ id: "cursor", label: "Cursor" },
{ id: "zed", label: "Zed" },
{ id: "sublime", label: "Sublime Text" },
{ id: "xcode", label: "Xcode" },
{ id: "windsurf", label: "Windsurf" },
{ id: "trae", label: "Trae" },
]
const TERMINALS: EditorOption[] = [
{ id: "iterm", label: "iTerm" },
{ id: "warp", label: "Warp" },
{ id: "terminal", label: "Terminal" },
{ id: "ghostty", label: "Ghostty" },
]
const VSCODE: EditorOption[] = [
{ id: "vscode", label: "VS Code" },
{ id: "vscode-insiders", label: "VS Code Insiders" },
]
const JETBRAINS: EditorOption[] = [
{ id: "intellij", label: "IntelliJ IDEA" },
{ id: "webstorm", label: "WebStorm" },
{ id: "pycharm", label: "PyCharm" },
{ id: "phpstorm", label: "PhpStorm" },
{ id: "goland", label: "GoLand" },
{ id: "clion", label: "CLion" },
{ id: "rider", label: "Rider" },
{ id: "fleet", label: "Fleet" },
{ id: "rustrover", label: "RustRover" },
]
import vscodeBaseIcon from "../../../assets/app-icons/vscode.svg"
import jetbrainsBaseIcon from "../../../assets/app-icons/jetbrains.svg"
import { Kbd } from "../../ui/kbd"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
} from "../../ui/select"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuTrigger,
} from "../../ui/dropdown-menu"
import { ChevronDown } from "lucide-react"
import { Switch } from "../../ui/switch"
import { trpc } from "../../../lib/trpc"
// Hook to detect narrow screen
function useIsNarrowScreen(): boolean {
const [isNarrow, setIsNarrow] = useState(false)
useEffect(() => {
const checkWidth = () => {
setIsNarrow(window.innerWidth <= 768)
}
checkWidth()
window.addEventListener("resize", checkWidth)
return () => window.removeEventListener("resize", checkWidth)
}, [])
return isNarrow
}
export function AgentsPreferencesTab() {
const [claudeThinking, setClaudeThinking] = useAtom(
lastSelectedClaudeThinkingAtom,
)
const [soundEnabled, setSoundEnabled] = useAtom(soundNotificationsEnabledAtom)
const [desktopNotificationsEnabled, setDesktopNotificationsEnabled] = useAtom(desktopNotificationsEnabledAtom)
const [notifyWhenFocused, setNotifyWhenFocused] = useAtom(notifyWhenFocusedAtom)
const [analyticsOptOut, setAnalyticsOptOut] = useAtom(analyticsOptOutAtom)
const [ctrlTabTarget, setCtrlTabTarget] = useAtom(ctrlTabTargetAtom)
const [autoAdvanceTarget, setAutoAdvanceTarget] = useAtom(autoAdvanceTargetAtom)
const [defaultAgentMode, setDefaultAgentMode] = useAtom(defaultAgentModeAtom)
const [preferredEditor, setPreferredEditor] = useAtom(preferredEditorAtom)
const isNarrowScreen = useIsNarrowScreen()
// Co-authored-by setting from Claude settings.json
const { data: includeCoAuthoredBy, refetch: refetchCoAuthoredBy } =
trpc.claudeSettings.getIncludeCoAuthoredBy.useQuery()
const setCoAuthoredByMutation =
trpc.claudeSettings.setIncludeCoAuthoredBy.useMutation({
onSuccess: () => {
refetchCoAuthoredBy()
},
})
const handleCoAuthoredByToggle = (enabled: boolean) => {
setCoAuthoredByMutation.mutate({ enabled })
}
// Sync opt-out status to main process
const handleAnalyticsToggle = async (optedOut: boolean) => {
setAnalyticsOptOut(optedOut)
// Notify main process
try {
await window.desktopApi?.setAnalyticsOptOut(optedOut)
} catch (error) {
console.error("Failed to sync analytics opt-out to main process:", error)
}
}
return (
<div className="p-6 space-y-6">
{/* Header - hidden on narrow screens since it's in the navigation bar */}
{!isNarrowScreen && (
<div className="flex flex-col space-y-1.5 text-center sm:text-left">
<h3 className="text-sm font-semibold text-foreground">Preferences</h3>
<p className="text-xs text-muted-foreground">
Configure Claude's behavior and features
</p>
</div>
)}
{/* Agent Behavior */}
<div className="bg-background rounded-lg border border-border overflow-hidden">
<div className="flex items-center justify-between p-4">
<div className="flex flex-col space-y-1">
<span className="text-sm font-medium text-foreground">
Thinking Effort
</span>
<span className="text-xs text-muted-foreground">
Default effort level for Claude's reasoning. Higher levels think
longer and use more credits.
</span>
</div>
<Select
value={claudeThinking}
onValueChange={(value: ClaudeThinkingLevel) =>
setClaudeThinking(value)
}
>
<SelectTrigger className="w-auto px-2">
<span className="text-xs">
{formatClaudeThinkingLabel(claudeThinking)}
</span>
</SelectTrigger>
<SelectContent>
{(
["off", "low", "medium", "high", "xhigh", "max"] as const
).map((level) => (
<SelectItem key={level} value={level}>
{formatClaudeThinkingLabel(level)}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
<div className="flex items-center justify-between p-4 border-t border-border">
<div className="flex flex-col space-y-1">
<span className="text-sm font-medium text-foreground">
Default Mode
</span>
<span className="text-xs text-muted-foreground">
Mode for new agents (Plan = read-only, Agent = can edit)
</span>
</div>
<Select
value={defaultAgentMode}
onValueChange={(value: AgentMode) => setDefaultAgentMode(value)}
>
<SelectTrigger className="w-auto px-2">
<span className="text-xs">
{defaultAgentMode === "agent" ? "Agent" : "Plan"}
</span>
</SelectTrigger>
<SelectContent>
<SelectItem value="agent">Agent</SelectItem>
<SelectItem value="plan">Plan</SelectItem>
</SelectContent>
</Select>
</div>
<div className="flex items-center justify-between p-4 border-t border-border">
<div className="flex flex-col space-y-1">
<span className="text-sm font-medium text-foreground">
Include Co-Authored-By
</span>
<span className="text-xs text-muted-foreground">
Add "Co-authored-by: Claude" to git commits made by Claude
</span>
</div>
<Switch
checked={includeCoAuthoredBy ?? true}
onCheckedChange={handleCoAuthoredByToggle}
disabled={setCoAuthoredByMutation.isPending}
/>
</div>
</div>
{/* Notifications */}
<div className="bg-background rounded-lg border border-border overflow-hidden">
<div className="flex items-center justify-between p-4">
<div className="flex flex-col space-y-1">
<span className="text-sm font-medium text-foreground">
Desktop Notifications
</span>
<span className="text-xs text-muted-foreground">
Show system notifications when agent needs input or completes work
</span>
</div>
<Switch checked={desktopNotificationsEnabled} onCheckedChange={setDesktopNotificationsEnabled} />
</div>
<div className="flex items-center justify-between p-4 border-t border-border">
<div className="flex flex-col space-y-1">
<span className="text-sm font-medium text-foreground">
Sound Notifications
</span>
<span className="text-xs text-muted-foreground">
Play a sound when agent completes work while you're away
</span>
</div>
<Switch checked={soundEnabled} onCheckedChange={setSoundEnabled} />
</div>
<div className="flex items-center justify-between p-4 border-t border-border">
<div className="flex flex-col space-y-1">
<span className="text-sm font-medium text-foreground">
Notify When Focused
</span>
<span className="text-xs text-muted-foreground">
Show notifications even when the app window is active
</span>
</div>
<Switch
checked={notifyWhenFocused}
onCheckedChange={setNotifyWhenFocused}
disabled={!desktopNotificationsEnabled}
/>
</div>
</div>
{/* Navigation */}
<div className="bg-background rounded-lg border border-border overflow-hidden">
<div className="flex items-center justify-between p-4">
<div className="flex flex-col space-y-1">
<span className="text-sm font-medium text-foreground">
Quick Switch
</span>
<span className="text-xs text-muted-foreground">
What <Kbd>⌃Tab</Kbd> switches between
</span>
</div>
<Select
value={ctrlTabTarget}
onValueChange={(value: CtrlTabTarget) => setCtrlTabTarget(value)}
>
<SelectTrigger className="w-auto px-2">
<span className="text-xs">
{ctrlTabTarget === "workspaces" ? "Workspaces" : "Agents"}
</span>
</SelectTrigger>
<SelectContent>
<SelectItem value="workspaces">Workspaces</SelectItem>
<SelectItem value="agents">Agents</SelectItem>
</SelectContent>
</Select>
</div>
<div className="flex items-center justify-between p-4 border-t border-border">
<div className="flex flex-col space-y-1">
<span className="text-sm font-medium text-foreground">
Auto-advance
</span>
<span className="text-xs text-muted-foreground">
Where to go after archiving a workspace
</span>
</div>
<Select
value={autoAdvanceTarget}
onValueChange={(value: AutoAdvanceTarget) => setAutoAdvanceTarget(value)}
>
<SelectTrigger className="w-auto px-2">
<span className="text-xs">
{autoAdvanceTarget === "next"
? "Go to next workspace"
: autoAdvanceTarget === "previous"
? "Go to previous workspace"
: "Close workspace"}
</span>
</SelectTrigger>
<SelectContent>
<SelectItem value="next">Go to next workspace</SelectItem>
<SelectItem value="previous">Go to previous workspace</SelectItem>
<SelectItem value="close">Close workspace</SelectItem>
</SelectContent>
</Select>
</div>
<div className="flex items-center justify-between p-4 border-t border-border">
<div className="flex flex-col space-y-1">
<span className="text-sm font-medium text-foreground">
Preferred Editor
</span>
<span className="text-xs text-muted-foreground">
Default app for opening workspaces
</span>
</div>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<button
type="button"
className="inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground transition-colors"
>
{EDITOR_ICONS[preferredEditor] && (
<img
src={EDITOR_ICONS[preferredEditor]}
alt=""
className="h-4 w-4 flex-shrink-0"
/>
)}
<span className="truncate">
{APP_META[preferredEditor].label}
</span>
<ChevronDown className="h-3 w-3 opacity-50" />
</button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-48">
{EDITORS.map((editor) => (
<DropdownMenuItem
key={editor.id}
onClick={() => setPreferredEditor(editor.id)}
className="flex items-center gap-2"
>
{EDITOR_ICONS[editor.id] ? (
<img src={EDITOR_ICONS[editor.id]} alt="" className="h-4 w-4 flex-shrink-0 object-contain" />
) : (
<div className="h-4 w-4 flex-shrink-0" />
)}
<span>{editor.label}</span>
</DropdownMenuItem>
))}
{TERMINALS.map((app) => (
<DropdownMenuItem
key={app.id}
onClick={() => setPreferredEditor(app.id)}
className="flex items-center gap-2"
>
{EDITOR_ICONS[app.id] ? (
<img src={EDITOR_ICONS[app.id]} alt="" className="h-4 w-4 flex-shrink-0 object-contain" />
) : (
<div className="h-4 w-4 flex-shrink-0" />
)}
<span>{app.label}</span>
</DropdownMenuItem>
))}
<DropdownMenuSub>
<DropdownMenuSubTrigger className="flex items-center gap-2">
<img src={vscodeBaseIcon} alt="" className="h-4 w-4 flex-shrink-0 object-contain" />
<span>VS Code</span>
</DropdownMenuSubTrigger>
<DropdownMenuSubContent className="w-48" sideOffset={6} alignOffset={-4}>
{VSCODE.map((app) => (
<DropdownMenuItem
key={app.id}
onClick={() => setPreferredEditor(app.id)}
className="flex items-center gap-2"
>
{EDITOR_ICONS[app.id] ? (
<img src={EDITOR_ICONS[app.id]} alt="" className="h-4 w-4 flex-shrink-0 object-contain" />
) : (
<div className="h-4 w-4 flex-shrink-0" />
)}
<span>{app.label}</span>
</DropdownMenuItem>
))}
</DropdownMenuSubContent>
</DropdownMenuSub>
<DropdownMenuSub>
<DropdownMenuSubTrigger className="flex items-center gap-2">
<img src={jetbrainsBaseIcon} alt="" className="h-4 w-4 flex-shrink-0 object-contain" />
<span>JetBrains</span>
</DropdownMenuSubTrigger>
<DropdownMenuSubContent className="w-48 max-h-[300px] overflow-y-auto" sideOffset={6} alignOffset={-4}>
{JETBRAINS.map((app) => (
<DropdownMenuItem
key={app.id}
onClick={() => setPreferredEditor(app.id)}
className="flex items-center gap-2"
>
{EDITOR_ICONS[app.id] ? (
<img src={EDITOR_ICONS[app.id]} alt="" className="h-4 w-4 flex-shrink-0 object-contain" />
) : (
<div className="h-4 w-4 flex-shrink-0" />
)}
<span>{app.label}</span>
</DropdownMenuItem>
))}
</DropdownMenuSubContent>
</DropdownMenuSub>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
{/* Privacy */}
<div className="bg-background rounded-lg border border-border overflow-hidden">
<div className="flex items-center justify-between gap-6 p-4">
<div className="flex flex-col space-y-1">
<span className="text-sm font-medium text-foreground">
Share Usage Analytics
</span>
<span className="text-xs text-muted-foreground">
Help us improve Agents by sharing anonymous usage data. We only track feature usage and app performance–never your code, prompts, or messages. No AI training on your data.
</span>
</div>
<Switch
checked={!analyticsOptOut}
onCheckedChange={(enabled) => handleAnalyticsToggle(!enabled)}
/>
</div>
</div>
</div>
)
}