The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 05:30 UTC
perf(web): typing in form dialogs no longer re-renders the dialog chrome (#20842)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 17, 2026 at 03:41 UTC
812b7006f8a12c5c8e55ea65a9cfcebfd328872f
4 files changed
+969
-840
apps/web/src/components/chat/ProposedPlanCard.tsx
+66
-40
@@ -56,7 +56,8 @@ export const ProposedPlanCard = memo(function ProposedPlanCard({
56
const [expanded, setExpanded] = useState(false);
57
const canWriteFiles = useEnvironmentScope(environmentId, AuthFilesystemWriteScope);
58
const [isSaveDialogOpen, setIsSaveDialogOpen] = useState(false);
59
- const [savePath, setSavePath] = useState("");
59
+ // The path last submitted, so reopening the dialog offers it again.
60
+ const [lastSavePath, setLastSavePath] = useState("");
61
const [isSavingToWorkspace, setIsSavingToWorkspace] = useState(false);
62
const writeProjectFile = useAtomCommand(projectEnvironment.writeFile, {
63
reportFailure: false,
@@ -73,7 +74,6 @@ export const ProposedPlanCard = memo(function ProposedPlanCard({
74
);
75
},
76
});
76
- const savePathInputId = useId();
77
const title = proposedPlanTitle(planMarkdown) ?? "Proposed plan";
78
const lineCount = planMarkdown.split("\n").length;
79
const canCollapse = planMarkdown.length > 900 || lineCount > 20;
@@ -109,11 +109,10 @@ export const ProposedPlanCard = memo(function ProposedPlanCard({
109
);
110
return;
111
}
112
- setSavePath((existing) => (existing.length > 0 ? existing : downloadFilename));
112
setIsSaveDialogOpen(true);
113
};
114
116
- const handleSaveToWorkspace = () => {
115
+ const handleSaveToWorkspace = (savePath: string) => {
116
const relativePath = savePath.trim();
117
if (!workspaceRoot || !readEnvironmentScope(environmentId, AuthFilesystemWriteScope)) {
118
return;
@@ -126,6 +125,7 @@ export const ProposedPlanCard = memo(function ProposedPlanCard({
125
return;
126
}
127
128
+ setLastSavePath(savePath);
129
setIsSavingToWorkspace(true);
130
void (async () => {
131
const result = await writeProjectFile({
@@ -241,45 +241,71 @@ export const ProposedPlanCard = memo(function ProposedPlanCard({
241
}
242
}}
243
>
244
+ {/* The form owns the path so a keystroke re-renders it, not the dialog chrome. */}
245
<DialogPopup className="max-w-xl">
245
- <DialogHeader>
246
- <DialogTitle>Save plan to workspace</DialogTitle>
247
- <DialogDescription>
248
- Enter a path relative to <code>{workspaceRoot ?? "the workspace"}</code>.
249
- </DialogDescription>
250
- </DialogHeader>
251
- <DialogPanel>
252
- <label htmlFor={savePathInputId} className="grid gap-1.5">
253
- <span className="text-xs font-medium text-foreground">Workspace path</span>
254
- <Input
255
- id={savePathInputId}
256
- value={savePath}
257
- onChange={(event) => setSavePath(event.target.value)}
258
- placeholder={downloadFilename}
259
- spellCheck={false}
260
- disabled={isSavingToWorkspace}
261
- />
262
- </label>
263
- </DialogPanel>
264
- <DialogFooter>
265
- <Button
266
- variant="outline"
267
- size="sm"
268
- onClick={() => setIsSaveDialogOpen(false)}
269
- disabled={isSavingToWorkspace}
270
- >
271
- Cancel
272
- </Button>
273
- <Button
274
- size="sm"
275
- onClick={() => void handleSaveToWorkspace()}
276
- disabled={!canWriteFiles || isSavingToWorkspace}
277
- >
278
- {isSavingToWorkspace ? "Saving..." : "Save"}
279
- </Button>
280
- </DialogFooter>
246
+ <SavePlanToWorkspaceForm
247
+ initialPath={lastSavePath || downloadFilename}
248
+ placeholder={downloadFilename}
249
+ workspaceRoot={workspaceRoot}
250
+ canWriteFiles={canWriteFiles}
251
+ saving={isSavingToWorkspace}
252
+ onCancel={() => setIsSaveDialogOpen(false)}
253
+ onSave={handleSaveToWorkspace}
254
+ />
255
</DialogPopup>
256
</Dialog>
257
</div>
258
);
259
});
260
+
261
+function SavePlanToWorkspaceForm({
262
+ initialPath,
263
+ placeholder,
264
+ workspaceRoot,
265
+ canWriteFiles,
266
+ saving,
267
+ onCancel,
268
+ onSave,
269
+}: {
270
+ initialPath: string;
271
+ placeholder: string;
272
+ workspaceRoot: string | undefined;
273
+ canWriteFiles: boolean;
274
+ saving: boolean;
275
+ onCancel: () => void;
276
+ onSave: (path: string) => void;
277
+}) {
278
+ const [savePath, setSavePath] = useState(initialPath);
279
+ const savePathInputId = useId();
280
+ return (
281
+ <>
282
+ <DialogHeader>
283
+ <DialogTitle>Save plan to workspace</DialogTitle>
284
+ <DialogDescription>
285
+ Enter a path relative to <code>{workspaceRoot ?? "the workspace"}</code>.
286
+ </DialogDescription>
287
+ </DialogHeader>
288
+ <DialogPanel>
289
+ <label htmlFor={savePathInputId} className="grid gap-1.5">
290
+ <span className="text-xs font-medium text-foreground">Workspace path</span>
291
+ <Input
292
+ id={savePathInputId}
293
+ value={savePath}
294
+ onChange={(event) => setSavePath(event.target.value)}
295
+ placeholder={placeholder}
296
+ spellCheck={false}
297
+ disabled={saving}
298
+ />
299
+ </label>
300
+ </DialogPanel>
301
+ <DialogFooter>
302
+ <Button variant="outline" size="sm" onClick={onCancel} disabled={saving}>
303
+ Cancel
304
+ </Button>
305
+ <Button size="sm" onClick={() => onSave(savePath)} disabled={!canWriteFiles || saving}>
306
+ {saving ? "Saving..." : "Save"}
307
+ </Button>
308
+ </DialogFooter>
309
+ </>
310
+ );
311
+}
apps/web/src/components/projectScriptEditor.tsx
+247
-198
@@ -156,6 +156,98 @@ export function ProjectScriptEditorDialog({
156
) => Promise<ProjectScriptActionResult>;
157
onDelete: (scriptId: string) => void;
158
onClose: () => void;
159
+}) {
160
+ const canEditActions = useEnvironmentScope(environmentId, editScope);
161
+ const [validationError, setValidationError] = useState<string | null>(null);
162
+ const [deleteConfirmOpen, setDeleteConfirmOpen] = useComposerMenuState(!canEditActions);
163
+ const [deleteName, setDeleteName] = useState("");
164
+ const [errorRequest, setErrorRequest] = useState<ProjectScriptEditorRequest | null>(null);
165
+ if (request !== errorRequest) {
166
+ setErrorRequest(request);
167
+ if (request) setValidationError(request.error ?? null);
168
+ }
169
+
170
+ return (
171
+ <>
172
+ <Dialog
173
+ open={request !== null}
174
+ onOpenChange={(open) => {
175
+ if (!open) onClose();
176
+ }}
177
+ >
178
+ {/* The form owns its fields so a keystroke re-renders it, not the dialog chrome. */}
179
+ <DialogPopup>
180
+ <ProjectScriptEditorForm
181
+ environmentId={environmentId}
182
+ editScope={editScope}
183
+ request={request}
184
+ scripts={scripts}
185
+ validationError={validationError}
186
+ onValidationError={setValidationError}
187
+ onSubmit={onSubmit}
188
+ onRequestDelete={(name) => {
189
+ setDeleteName(name);
190
+ setDeleteConfirmOpen(true);
191
+ }}
192
+ onClose={onClose}
193
+ />
194
+ </DialogPopup>
195
+ </Dialog>
196
+
197
+ <AlertDialog open={deleteConfirmOpen && canEditActions} onOpenChange={setDeleteConfirmOpen}>
198
+ <AlertDialogPopup>
199
+ <AlertDialogHeader>
200
+ <AlertDialogTitle>Delete action "{deleteName}"?</AlertDialogTitle>
201
+ <AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>
202
+ </AlertDialogHeader>
203
+ <AlertDialogFooter>
204
+ <AlertDialogClose render={<Button variant="outline" />}>Cancel</AlertDialogClose>
205
+ <Button
206
+ variant="destructive"
207
+ disabled={!canEditActions}
208
+ onClick={() => {
209
+ if (!request?.scriptId) return;
210
+ if (!readEnvironmentScope(environmentId, editScope)) {
211
+ setValidationError("This connection cannot change project actions.");
212
+ return;
213
+ }
214
+ setDeleteConfirmOpen(false);
215
+ onClose();
216
+ onDelete(request.scriptId);
217
+ }}
218
+ >
219
+ Delete action
220
+ </Button>
221
+ </AlertDialogFooter>
222
+ </AlertDialogPopup>
223
+ </AlertDialog>
224
+ </>
225
+ );
226
+}
227
+
228
+function ProjectScriptEditorForm({
229
+ environmentId,
230
+ editScope,
231
+ request,
232
+ scripts,
233
+ validationError,
234
+ onValidationError: setValidationError,
235
+ onSubmit,
236
+ onRequestDelete,
237
+ onClose,
238
+}: {
239
+ environmentId: EnvironmentId;
240
+ editScope: typeof AuthOrchestrationOperateScope | typeof AuthSettingsWriteScope;
241
+ request: ProjectScriptEditorRequest | null;
242
+ scripts: ReadonlyArray<ProjectScript>;
243
+ validationError: string | null;
244
+ onValidationError: (error: string | null) => void;
245
+ onSubmit: (
246
+ scriptId: string | null,
247
+ input: NewProjectScriptInput,
248
+ ) => Promise<ProjectScriptActionResult>;
249
+ onRequestDelete: (name: string) => void;
250
+ onClose: () => void;
251
}) {
252
const canEditActions = useEnvironmentScope(environmentId, editScope);
253
const canWriteSettings = useEnvironmentScope(environmentId, AuthSettingsWriteScope);
@@ -170,12 +262,9 @@ export function ProjectScriptEditorDialog({
262
const [keybinding, setKeybinding] = useState("");
263
const [previewUrl, setPreviewUrl] = useState("");
264
const [autoOpenPreview, setAutoOpenPreview] = useState(false);
173
- const [validationError, setValidationError] = useState<string | null>(null);
174
- const [deleteConfirmOpen, setDeleteConfirmOpen] = useComposerMenuState(!canEditActions);
265
const [savingRequest, setSavingRequest] = useState<ProjectScriptEditorRequest | null>(null);
266
const pendingSubmissionRef = useRef<{ request: ProjectScriptEditorRequest } | null>(null);
267
178
- const isOpen = request !== null;
268
const isEditing = request?.scriptId != null;
269
const isSaving = request !== null && savingRequest === request;
270
@@ -202,7 +291,6 @@ export function ProjectScriptEditorDialog({
291
setKeybinding(request.initial.keybinding ?? "");
292
setPreviewUrl(request.initial.previewUrl ?? "");
293
setAutoOpenPreview(request.initial.autoOpenPreview);
205
- setValidationError(request.error ?? null);
294
setSavingRequest(null);
295
}
296
}
@@ -314,202 +402,163 @@ export function ProjectScriptEditorDialog({
402
403
return (
404
<>
317
- <Dialog
318
- open={isOpen}
319
- onOpenChange={(open) => {
320
- if (!open) {
321
- close();
322
- }
323
- }}
324
- >
325
- <DialogPopup>
326
- <DialogHeader>
327
- <DialogTitle>{isEditing ? "Edit Action" : "Add Action"}</DialogTitle>
328
- <DialogDescription>
329
- Actions are project-scoped commands you can run from the top bar or keybindings.
330
- </DialogDescription>
331
- </DialogHeader>
332
- <DialogPanel>
333
- <form id={formId} onSubmit={submit}>
334
- <fieldset className="space-y-4" disabled={isSaving || !canEditActions}>
335
- <div className="space-y-1.5">
336
- <Label htmlFor="script-name">Name</Label>
337
- <div className="flex items-center gap-2">
338
- <Popover onOpenChange={setIconPickerOpen} open={iconPickerOpen}>
339
- <PopoverTrigger
340
- render={
341
- <Button
405
+ <DialogHeader>
406
+ <DialogTitle>{isEditing ? "Edit Action" : "Add Action"}</DialogTitle>
407
+ <DialogDescription>
408
+ Actions are project-scoped commands you can run from the top bar or keybindings.
409
+ </DialogDescription>
410
+ </DialogHeader>
411
+ <DialogPanel>
412
+ <form id={formId} onSubmit={submit}>
413
+ <fieldset className="space-y-4" disabled={isSaving || !canEditActions}>
414
+ <div className="space-y-1.5">
415
+ <Label htmlFor="script-name">Name</Label>
416
+ <div className="flex items-center gap-2">
417
+ <Popover onOpenChange={setIconPickerOpen} open={iconPickerOpen}>
418
+ <PopoverTrigger
419
+ render={
420
+ <Button
421
+ type="button"
422
+ variant="outline"
423
+ className="size-9 shrink-0"
424
+ aria-label="Choose icon"
425
+ />
426
+ }
427
+ >
428
+ <ScriptIcon icon={icon} className="size-4.5" />
429
+ </PopoverTrigger>
430
+ <PopoverPopup align="start">
431
+ <div className="grid grid-cols-3 gap-2">
432
+ {SCRIPT_ICONS.map((entry) => {
433
+ const isSelected = entry.id === icon;
434
+ return (
435
+ <button
436
+ key={entry.id}
437
type="button"
343
- variant="outline"
344
- className="size-9 shrink-0"
345
- aria-label="Choose icon"
346
- />
347
- }
348
- >
349
- <ScriptIcon icon={icon} className="size-4.5" />
350
- </PopoverTrigger>
351
- <PopoverPopup align="start">
352
- <div className="grid grid-cols-3 gap-2">
353
- {SCRIPT_ICONS.map((entry) => {
354
- const isSelected = entry.id === icon;
355
- return (
356
- <button
357
- key={entry.id}
358
- type="button"
359
- className={`relative flex flex-col items-center gap-2 rounded-md border px-2 py-2 text-xs dark:border-transparent ${
360
- isSelected
361
- ? "border-primary/70 bg-primary/10 ring-inset dark:ring-1 dark:ring-primary/30"
362
- : "border-border/70 hover:bg-accent/60 dark:bg-white/[0.035]"
363
- }`}
364
- onClick={() => {
365
- setIcon(entry.id);
366
- setIconPickerOpen(false);
367
- }}
368
- >
369
- <ScriptIcon icon={entry.id} className="size-4" />
370
- <span>{entry.label}</span>
371
- </button>
372
- );
373
- })}
374
- </div>
375
- </PopoverPopup>
376
- </Popover>
377
- <Input
378
- id="script-name"
379
- autoFocus
380
- placeholder="Test"
381
- value={name}
382
- onChange={(event) => setName(event.target.value)}
383
- />
384
- </div>
385
- </div>
386
- <div className="space-y-1.5">
387
- <Label htmlFor="script-keybinding">Keybinding</Label>
388
- <Input
389
- disabled={!canWriteSettings}
390
- id="script-keybinding"
391
- placeholder="Press shortcut"
392
- value={keybinding}
393
- readOnly
394
- onKeyDown={captureKeybinding}
395
- />
396
- <p className="text-xs text-muted-foreground">
397
- Press a shortcut. Use <code>Backspace</code> to clear. Shortcuts are
398
- environment-wide. Projects using the same action share its shortcut.
399
- </p>
400
- </div>
401
- <div className="space-y-1.5">
402
- <Label htmlFor="script-command">Command</Label>
403
- <Textarea
404
- id="script-command"
405
- placeholder="bun test"
406
- value={command}
407
- onChange={(event) => setCommand(event.target.value)}
408
- />
409
- </div>
410
- <div className="space-y-1.5">
411
- <Label htmlFor="script-preview-url">Preview URL (optional)</Label>
412
- <Input
413
- id="script-preview-url"
414
- placeholder="http://localhost:5173"
415
- value={previewUrl}
416
- onChange={(event) => setPreviewUrl(event.target.value)}
417
- />
418
- <p className="text-xs text-muted-foreground">
419
- Open this URL in the in-app preview when this action runs.
420
- </p>
421
- </div>
422
- <label className="flex items-center justify-between gap-3 rounded-md border border-border/70 px-3 py-2 text-sm dark:border-transparent dark:bg-white/[0.035]">
423
- <span>Run automatically on worktree creation</span>
424
- <Switch
425
- checked={runOnWorktreeCreate}
426
- onCheckedChange={(checked) => setRunOnWorktreeCreate(Boolean(checked))}
427
- />
428
- </label>
429
- <label
430
- className={`flex items-center justify-between gap-3 rounded-md border border-border/70 px-3 py-2 text-sm dark:border-transparent dark:bg-white/[0.035] ${
431
- runOnWorktreeCreate ? "" : "opacity-60"
432
- }`}
433
- >
434
- <span>Wait for it to finish before the agent starts</span>
435
- <Switch
436
- checked={waitForSetup}
437
- disabled={!runOnWorktreeCreate}
438
- onCheckedChange={(checked) => setWaitForSetup(Boolean(checked))}
439
- />
440
- </label>
441
- <label className="flex items-center justify-between gap-3 rounded-md border border-border/70 px-3 py-2 text-sm dark:border-transparent dark:bg-white/[0.035]">
442
- <span>Run in the thread's worktree when the thread settles</span>
443
- <Switch
444
- checked={runOnSettle}
445
- onCheckedChange={(checked) => setRunOnSettle(Boolean(checked))}
446
- />
447
- </label>
448
- <label
449
- className={`flex items-center justify-between gap-3 rounded-md border border-border/70 px-3 py-2 text-sm dark:border-transparent dark:bg-white/[0.035] ${
450
- previewUrl.trim().length === 0 ? "opacity-60" : ""
451
- }`}
452
- >
453
- <span>Open preview automatically when this action runs</span>
454
- <Switch
455
- checked={autoOpenPreview}
456
- disabled={previewUrl.trim().length === 0}
457
- onCheckedChange={(checked) => setAutoOpenPreview(Boolean(checked))}
458
- />
459
- </label>
460
- {validationError && <p className="text-sm text-destructive">{validationError}</p>}
461
- </fieldset>
462
- </form>
463
- </DialogPanel>
464
- <DialogFooter variant="bare">
465
- {isEditing && (
466
- <Button
467
- type="button"
468
- variant="destructive-outline"
469
- className="mr-auto"
470
- disabled={isSaving || !canEditActions}
471
- onClick={() => setDeleteConfirmOpen(true)}
472
- >
473
- Delete
474
- </Button>
475
- )}
476
- <Button type="button" variant="outline" onClick={close}>
477
- Cancel
478
- </Button>
479
- <Button form={formId} type="submit" disabled={isSaving || !canEditActions}>
480
- {isSaving ? "Saving…" : isEditing ? "Save changes" : "Save action"}
481
- </Button>
482
- </DialogFooter>
483
- </DialogPopup>
484
- </Dialog>
485
-
486
- <AlertDialog open={deleteConfirmOpen && canEditActions} onOpenChange={setDeleteConfirmOpen}>
487
- <AlertDialogPopup>
488
- <AlertDialogHeader>
489
- <AlertDialogTitle>Delete action "{name}"?</AlertDialogTitle>
490
- <AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>
491
- </AlertDialogHeader>
492
- <AlertDialogFooter>
493
- <AlertDialogClose render={<Button variant="outline" />}>Cancel</AlertDialogClose>
494
- <Button
495
- variant="destructive"
496
- disabled={isSaving || !canEditActions}
497
- onClick={() => {
498
- if (!request?.scriptId) return;
499
- if (!readEnvironmentScope(environmentId, editScope)) {
500
- setValidationError("This connection cannot change project actions.");
501
- return;
502
- }
503
- setDeleteConfirmOpen(false);
504
- close();
505
- onDelete(request.scriptId);
506
- }}
438
+ className={`relative flex flex-col items-center gap-2 rounded-md border px-2 py-2 text-xs dark:border-transparent ${
439
+ isSelected
440
+ ? "border-primary/70 bg-primary/10 ring-inset dark:ring-1 dark:ring-primary/30"
441
+ : "border-border/70 hover:bg-accent/60 dark:bg-white/[0.035]"
442
+ }`}
443
+ onClick={() => {
444
+ setIcon(entry.id);
445
+ setIconPickerOpen(false);
446
+ }}
447
+ >
448
+ <ScriptIcon icon={entry.id} className="size-4" />
449
+ <span>{entry.label}</span>
450
+ </button>
451
+ );
452
+ })}
453
+ </div>
454
+ </PopoverPopup>
455
+ </Popover>
456
+ <Input
457
+ id="script-name"
458
+ autoFocus
459
+ placeholder="Test"
460
+ value={name}
461
+ onChange={(event) => setName(event.target.value)}
462
+ />
463
+ </div>
464
+ </div>
465
+ <div className="space-y-1.5">
466
+ <Label htmlFor="script-keybinding">Keybinding</Label>
467
+ <Input
468
+ disabled={!canWriteSettings}
469
+ id="script-keybinding"
470
+ placeholder="Press shortcut"
471
+ value={keybinding}
472
+ readOnly
473
+ onKeyDown={captureKeybinding}
474
+ />
475
+ <p className="text-xs text-muted-foreground">
476
+ Press a shortcut. Use <code>Backspace</code> to clear. Shortcuts are
477
+ environment-wide. Projects using the same action share its shortcut.
478
+ </p>
479
+ </div>
480
+ <div className="space-y-1.5">
481
+ <Label htmlFor="script-command">Command</Label>
482
+ <Textarea
483
+ id="script-command"
484
+ placeholder="bun test"
485
+ value={command}
486
+ onChange={(event) => setCommand(event.target.value)}
487
+ />
488
+ </div>
489
+ <div className="space-y-1.5">
490
+ <Label htmlFor="script-preview-url">Preview URL (optional)</Label>
491
+ <Input
492
+ id="script-preview-url"
493
+ placeholder="http://localhost:5173"
494
+ value={previewUrl}
495
+ onChange={(event) => setPreviewUrl(event.target.value)}
496
+ />
497
+ <p className="text-xs text-muted-foreground">
498
+ Open this URL in the in-app preview when this action runs.
499
+ </p>
500
+ </div>
501
+ <label className="flex items-center justify-between gap-3 rounded-md border border-border/70 px-3 py-2 text-sm dark:border-transparent dark:bg-white/[0.035]">
502
+ <span>Run automatically on worktree creation</span>
503
+ <Switch
504
+ checked={runOnWorktreeCreate}
505
+ onCheckedChange={(checked) => setRunOnWorktreeCreate(Boolean(checked))}
506
+ />
507
+ </label>
508
+ <label
509
+ className={`flex items-center justify-between gap-3 rounded-md border border-border/70 px-3 py-2 text-sm dark:border-transparent dark:bg-white/[0.035] ${
510
+ runOnWorktreeCreate ? "" : "opacity-60"
511
+ }`}
512
>
508
- Delete action
509
- </Button>
510
- </AlertDialogFooter>
511
- </AlertDialogPopup>
512
- </AlertDialog>
513
+ <span>Wait for it to finish before the agent starts</span>
514
+ <Switch
515
+ checked={waitForSetup}
516
+ disabled={!runOnWorktreeCreate}
517
+ onCheckedChange={(checked) => setWaitForSetup(Boolean(checked))}
518
+ />
519
+ </label>
520
+ <label className="flex items-center justify-between gap-3 rounded-md border border-border/70 px-3 py-2 text-sm dark:border-transparent dark:bg-white/[0.035]">
521
+ <span>Run in the thread's worktree when the thread settles</span>
522
+ <Switch
523
+ checked={runOnSettle}
524
+ onCheckedChange={(checked) => setRunOnSettle(Boolean(checked))}
525
+ />
526
+ </label>
527
+ <label
528
+ className={`flex items-center justify-between gap-3 rounded-md border border-border/70 px-3 py-2 text-sm dark:border-transparent dark:bg-white/[0.035] ${
529
+ previewUrl.trim().length === 0 ? "opacity-60" : ""
530
+ }`}
531
+ >
532
+ <span>Open preview automatically when this action runs</span>
533
+ <Switch
534
+ checked={autoOpenPreview}
535
+ disabled={previewUrl.trim().length === 0}
536
+ onCheckedChange={(checked) => setAutoOpenPreview(Boolean(checked))}
537
+ />
538
+ </label>
539
+ {validationError && <p className="text-sm text-destructive">{validationError}</p>}
540
+ </fieldset>
541
+ </form>
542
+ </DialogPanel>
543
+ <DialogFooter variant="bare">
544
+ {isEditing && (
545
+ <Button
546
+ type="button"
547
+ variant="destructive-outline"
548
+ className="mr-auto"
549
+ disabled={isSaving || !canEditActions}
550
+ onClick={() => onRequestDelete(name)}
551
+ >
552
+ Delete
553
+ </Button>
554
+ )}
555
+ <Button type="button" variant="outline" onClick={close}>
556
+ Cancel
557
+ </Button>
558
+ <Button form={formId} type="submit" disabled={isSaving || !canEditActions}>
559
+ {isSaving ? "Saving…" : isEditing ? "Save changes" : "Save action"}
560
+ </Button>
561
+ </DialogFooter>
562
</>
563
);
564
}
apps/web/src/components/settings/DeviceHostEditor.tsx
+221
-188
@@ -37,6 +37,43 @@ export function DeviceHostEditor({
37
busy: boolean;
38
onSave: (host: SshDeviceHostConfig) => void;
39
onClose: () => void;
40
+}) {
41
+ return (
42
+ <Dialog
43
+ open
44
+ onOpenChange={(open) => {
45
+ if (!open && !busy) onClose();
46
+ }}
47
+ >
48
+ {/* The form owns the draft so a keystroke re-renders it, not the dialog chrome. */}
49
+ <DialogPopup showCloseButton={!busy}>
50
+ <DeviceHostEditorForm
51
+ host={host}
52
+ isNew={isNew}
53
+ targets={targets}
54
+ busy={busy}
55
+ onSave={onSave}
56
+ onClose={onClose}
57
+ />
58
+ </DialogPopup>
59
+ </Dialog>
60
+ );
61
+}
62
+
63
+function DeviceHostEditorForm({
64
+ host,
65
+ isNew,
66
+ targets,
67
+ busy,
68
+ onSave,
69
+ onClose,
70
+}: {
71
+ host: SshDeviceHostConfig;
72
+ isNew: boolean;
73
+ targets: ReadonlyArray<DeviceHostCheckTarget>;
74
+ busy: boolean;
75
+ onSave: (host: SshDeviceHostConfig) => void;
76
+ onClose: () => void;
77
}) {
78
const [draft, setDraft] = useState(host);
79
const [expandedChecks, setExpandedChecks] = useState<{ key: string; open: boolean } | null>(null);
@@ -58,199 +95,195 @@ export function DeviceHostEditor({
95
: "Connection checks passed"
96
: "Check access before saving";
97
return (
61
- <Dialog
62
- open
63
- onOpenChange={(open) => {
64
- if (!open && !busy) onClose();
98
+ <form
99
+ className="flex min-h-0 flex-col"
100
+ onSubmit={(event) => {
101
+ event.preventDefault();
102
+ if (Option.isSome(input) && draft.label.trim() && !busy && !checking) onSave(input.value);
103
}}
104
>
67
- <DialogPopup
68
- showCloseButton={!busy}
69
- render={
70
- <form
71
- onSubmit={(event) => {
72
- event.preventDefault();
73
- if (Option.isSome(input) && draft.label.trim() && !busy && !checking)
74
- onSave(input.value);
105
+ <DialogHeader>
106
+ <DialogTitle>{isNew ? "Add device host" : "Edit device host"}</DialogTitle>
107
+ <DialogDescription>
108
+ {targets.length === 1
109
+ ? `Connect from ${targets[0]?.label}.`
110
+ : `Connect from ${targets.length} selected environments.`}{" "}
111
+ Hosts on the same machine are skipped.
112
+ </DialogDescription>
113
+ </DialogHeader>
114
+ <DialogPanel>
115
+ <label className="block space-y-1.5 text-sm">
116
+ <span>Name</span>
117
+ <Input
118
+ autoFocus
119
+ required
120
+ value={draft.label}
121
+ disabled={busy}
122
+ onChange={(event) => {
123
+ const label = event.target.value;
124
+ setDraft((current) => ({ ...current, label }));
125
}}
126
+ placeholder="Mac mini"
127
/>
77
- }
78
- >
79
- <DialogHeader>
80
- <DialogTitle>{isNew ? "Add device host" : "Edit device host"}</DialogTitle>
81
- <DialogDescription>
82
- {targets.length === 1
83
- ? `Connect from ${targets[0]?.label}.`
84
- : `Connect from ${targets.length} selected environments.`}{" "}
85
- Hosts on the same machine are skipped.
86
- </DialogDescription>
87
- </DialogHeader>
88
- <DialogPanel>
89
- <label className="block space-y-1.5 text-sm">
90
- <span>Name</span>
91
- <Input
92
- autoFocus
93
- required
94
- value={draft.label}
95
- disabled={busy}
96
- onChange={(event) => setDraft({ ...draft, label: event.target.value })}
97
- placeholder="Mac mini"
98
- />
99
- </label>
100
- <label className="block space-y-1.5 text-sm">
101
- <span>SSH target</span>
102
- <Input
103
- required
104
- value={draft.target}
105
- disabled={busy}
106
- onChange={(event) => setDraft({ ...draft, target: event.target.value })}
107
- placeholder="user@host or SSH alias"
108
- />
109
- </label>
110
- <details
111
- open={host.port !== undefined || host.identityFile !== undefined || undefined}
112
- className="text-sm"
113
- >
114
- <summary className="cursor-pointer text-muted-foreground">SSH options</summary>
115
- <div className="mt-3 grid grid-cols-[minmax(0,1fr)_7rem] gap-3">
116
- <label className="block space-y-1.5">
117
- <span>Identity file</span>
118
- <Input
119
- value={draft.identityFile ?? ""}
120
- disabled={busy}
121
- onChange={(event) => {
122
- const { identityFile: _, ...rest } = draft;
123
- setDraft(
124
- event.target.value ? { ...rest, identityFile: event.target.value } : rest,
125
- );
126
- }}
127
- placeholder="SSH config default"
128
- />
129
- </label>
130
- <label className="block space-y-1.5">
131
- <span>Port</span>
132
- <Input
133
- type="number"
134
- min={1}
135
- max={65535}
136
- value={draft.port ?? ""}
137
- disabled={busy}
138
- onChange={(event) => {
139
- const { port: _, ...rest } = draft;
140
- setDraft(
141
- event.target.value ? { ...rest, port: Number(event.target.value) } : rest,
142
- );
143
- }}
144
- placeholder="Default"
145
- />
146
- </label>
147
- </div>
148
- <p className="mt-2 text-xs text-muted-foreground">
149
- Optional. Resolved separately on each environment.
150
- </p>
151
- </details>
152
- <Collapsible
153
- open={checksOpen}
154
- onOpenChange={(open) => setExpandedChecks({ key: connectionKey, open })}
155
- render={<div className="rounded-lg border border-border/60" />}
156
- >
157
- <div className="flex items-center justify-between gap-3 px-3 py-2.5">
158
- {targets.length === 1 ? (
159
- <p role="status" className="text-xs text-muted-foreground">
160
- {checkSummary}
161
- </p>
162
- ) : (
163
- <div className="min-w-0 text-xs [--inline-button-white-space:normal]">
164
- <CollapsibleTrigger
165
- disabled={!results}
166
- aria-label={`${checkSummary}. Per-machine results`}
167
- render={<InlineButton tone="muted" />}
168
- >
169
- <span role="status" className="text-left">
170
- {checkSummary}
171
- </span>
172
- {results ? (
173
- <ChevronDownIcon
174
- className={`size-3 shrink-0 ${checksOpen ? "rotate-180" : ""}`}
175
- />
176
- ) : null}
177
- </CollapsibleTrigger>
178
- </div>
179
- )}
180
- <Button
181
- type="button"
182
- size="sm"
183
- variant="outline"
184
- disabled={busy || checking || !valid}
185
- onClick={() => {
186
- if (Option.isSome(input)) void testConnection(input.value);
128
+ </label>
129
+ <label className="block space-y-1.5 text-sm">
130
+ <span>SSH target</span>
131
+ <Input
132
+ required
133
+ value={draft.target}
134
+ disabled={busy}
135
+ onChange={(event) => {
136
+ const target = event.target.value;
137
+ setDraft((current) => ({ ...current, target }));
138
+ }}
139
+ placeholder="user@host or SSH alias"
140
+ />
141
+ </label>
142
+ <details
143
+ open={host.port !== undefined || host.identityFile !== undefined || undefined}
144
+ className="text-sm"
145
+ >
146
+ <summary className="cursor-pointer text-muted-foreground">SSH options</summary>
147
+ <div className="mt-3 grid grid-cols-[minmax(0,1fr)_7rem] gap-3">
148
+ <label className="block space-y-1.5">
149
+ <span>Identity file</span>
150
+ <Input
151
+ value={draft.identityFile ?? ""}
152
+ disabled={busy}
153
+ onChange={(event) => {
154
+ const identityFile = event.target.value;
155
+ setDraft((current) => {
156
+ const { identityFile: _, ...rest } = current;
157
+ return identityFile ? { ...rest, identityFile } : rest;
158
+ });
159
+ }}
160
+ placeholder="SSH config default"
161
+ />
162
+ </label>
163
+ <label className="block space-y-1.5">
164
+ <span>Port</span>
165
+ <Input
166
+ type="number"
167
+ min={1}
168
+ max={65535}
169
+ value={draft.port ?? ""}
170
+ disabled={busy}
171
+ onChange={(event) => {
172
+ const port = event.target.value;
173
+ setDraft((current) => {
174
+ const { port: _, ...rest } = current;
175
+ return port ? { ...rest, port: Number(port) } : rest;
176
+ });
177
}}
188
- >
189
- {checking ? <Spinner size="xs" /> : null} Test connection
190
- </Button>
191
- </div>
192
- {results ? (
193
- <CollapsiblePanel
194
- render={<ul className="border-t border-border/60 divide-y divide-border/40" />}
195
- >
196
- {targets.map((target) => {
197
- const result = results[target.environmentId];
198
- if (!result) return null;
199
- return (
200
- <li key={target.environmentId} className="px-3 py-2.5 text-xs">
201
- <div className="flex items-center justify-between gap-3">
202
- <span className="truncate font-medium">{target.label}</span>
203
- <span
204
- className={`flex shrink-0 items-center gap-1.5 ${result.status === "failed" ? "text-destructive" : "text-muted-foreground"}`}
205
- >
206
- {result.status === "pending" ? (
207
- <>
208
- <Spinner size="xs" /> Checking…
209
- </>
210
- ) : result.status === "local" ? (
211
- <>
212
- <MonitorIcon className="size-3" /> Already available locally
213
- </>
214
- ) : result.status === "failed" ? (
215
- <>
216
- <XIcon className="size-3" /> Failed
217
- </>
218
- ) : (
219
- <>
220
- <CheckIcon className="size-3" /> Connected
221
- </>
222
- )}
223
- </span>
178
+ placeholder="Default"
179
+ />
180
+ </label>
181
+ </div>
182
+ <p className="mt-2 text-xs text-muted-foreground">
183
+ Optional. Resolved separately on each environment.
184
+ </p>
185
+ </details>
186
+ <Collapsible
187
+ open={checksOpen}
188
+ onOpenChange={(open) => setExpandedChecks({ key: connectionKey, open })}
189
+ render={<div className="rounded-lg border border-border/60" />}
190
+ >
191
+ <div className="flex items-center justify-between gap-3 px-3 py-2.5">
192
+ {targets.length === 1 ? (
193
+ <p role="status" className="text-xs text-muted-foreground">
194
+ {checkSummary}
195
+ </p>
196
+ ) : (
197
+ <div className="min-w-0 text-xs [--inline-button-white-space:normal]">
198
+ <CollapsibleTrigger
199
+ disabled={!results}
200
+ aria-label={`${checkSummary}. Per-machine results`}
201
+ render={<InlineButton tone="muted" />}
202
+ >
203
+ <span role="status" className="text-left">
204
+ {checkSummary}
205
+ </span>
206
+ {results ? (
207
+ <ChevronDownIcon
208
+ className={`size-3 shrink-0 ${checksOpen ? "rotate-180" : ""}`}
209
+ />
210
+ ) : null}
211
+ </CollapsibleTrigger>
212
+ </div>
213
+ )}
214
+ <Button
215
+ type="button"
216
+ size="sm"
217
+ variant="outline"
218
+ disabled={busy || checking || !valid}
219
+ onClick={() => {
220
+ if (Option.isSome(input)) void testConnection(input.value);
221
+ }}
222
+ >
223
+ {checking ? <Spinner size="xs" /> : null} Test connection
224
+ </Button>
225
+ </div>
226
+ {results ? (
227
+ <CollapsiblePanel
228
+ render={<ul className="border-t border-border/60 divide-y divide-border/40" />}
229
+ >
230
+ {targets.map((target) => {
231
+ const result = results[target.environmentId];
232
+ if (!result) return null;
233
+ return (
234
+ <li key={target.environmentId} className="px-3 py-2.5 text-xs">
235
+ <div className="flex items-center justify-between gap-3">
236
+ <span className="truncate font-medium">{target.label}</span>
237
+ <span
238
+ className={`flex shrink-0 items-center gap-1.5 ${result.status === "failed" ? "text-destructive" : "text-muted-foreground"}`}
239
+ >
240
+ {result.status === "pending" ? (
241
+ <>
242
+ <Spinner size="xs" /> Checking…
243
+ </>
244
+ ) : result.status === "local" ? (
245
+ <>
246
+ <MonitorIcon className="size-3" /> Already available locally
247
+ </>
248
+ ) : result.status === "failed" ? (
249
+ <>
250
+ <XIcon className="size-3" /> Failed
251
+ </>
252
+ ) : (
253
+ <>
254
+ <CheckIcon className="size-3" /> Connected
255
+ </>
256
+ )}
257
+ </span>
258
+ </div>
259
+ {result.status === "connected" ? (
260
+ <div className="mt-1.5">
261
+ <DeviceHostAvailability platforms={result.platforms} />
262
</div>
225
- {result.status === "connected" ? (
226
- <div className="mt-1.5">
227
- <DeviceHostAvailability platforms={result.platforms} />
228
- </div>
229
- ) : null}
230
- {result.status === "failed" ? (
231
- <details className="mt-1.5 text-muted-foreground">
232
- <summary className="cursor-pointer">Show error</summary>
233
- <p className="mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-words">
234
- {result.error}
235
- </p>
236
- </details>
237
- ) : null}
238
- </li>
239
- );
240
- })}
241
- </CollapsiblePanel>
242
- ) : null}
243
- </Collapsible>
244
- </DialogPanel>
245
- <DialogFooter>
246
- <Button type="button" variant="ghost" disabled={busy} onClick={onClose}>
247
- Cancel
248
- </Button>
249
- <Button type="submit" disabled={busy || checking || !valid || !draft.label.trim()}>
250
- {busy ? <Spinner size="xs" /> : null} Save host
251
- </Button>
252
- </DialogFooter>
253
- </DialogPopup>
254
- </Dialog>
263
+ ) : null}
264
+ {result.status === "failed" ? (
265
+ <details className="mt-1.5 text-muted-foreground">
266
+ <summary className="cursor-pointer">Show error</summary>
267
+ <p className="mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-words">
268
+ {result.error}
269
+ </p>
270
+ </details>
271
+ ) : null}
272
+ </li>
273
+ );
274
+ })}
275
+ </CollapsiblePanel>
276
+ ) : null}
277
+ </Collapsible>
278
+ </DialogPanel>
279
+ <DialogFooter>
280
+ <Button type="button" variant="ghost" disabled={busy} onClick={onClose}>
281
+ Cancel
282
+ </Button>
283
+ <Button type="submit" disabled={busy || checking || !valid || !draft.label.trim()}>
284
+ {busy ? <Spinner size="xs" /> : null} Save host
285
+ </Button>
286
+ </DialogFooter>
287
+ </form>
288
);
289
}
apps/web/src/components/settings/ScheduledTasksSettings.tsx
+435
-414
@@ -922,6 +922,41 @@ function ScheduledTaskEditorDialog({
922
readonly initialEnvironmentId: EnvironmentId;
923
readonly task: ScheduledTask | null;
924
readonly onClose: () => void;
925
+}) {
926
+ const [saving, setSaving] = useState(false);
927
+ return (
928
+ <Dialog
929
+ open
930
+ onOpenChange={(open) => {
931
+ if (!open && !saving) onClose();
932
+ }}
933
+ >
934
+ {/* The form owns the draft so a keystroke re-renders it, not the dialog chrome. */}
935
+ <DialogPopup className="max-w-xl">
936
+ <ScheduledTaskEditorForm
937
+ initialEnvironmentId={initialEnvironmentId}
938
+ task={task}
939
+ saving={saving}
940
+ onSavingChange={setSaving}
941
+ onClose={onClose}
942
+ />
943
+ </DialogPopup>
944
+ </Dialog>
945
+ );
946
+}
947
+
948
+function ScheduledTaskEditorForm({
949
+ initialEnvironmentId,
950
+ task,
951
+ saving,
952
+ onSavingChange: setSaving,
953
+ onClose,
954
+}: {
955
+ readonly initialEnvironmentId: EnvironmentId;
956
+ readonly task: ScheduledTask | null;
957
+ readonly saving: boolean;
958
+ readonly onSavingChange: (saving: boolean) => void;
959
+ readonly onClose: () => void;
960
}) {
961
const { scope, connectedEnvironments } = useSettingsScope();
962
const [environmentId, setEnvironmentId] = useState(initialEnvironmentId);
@@ -949,7 +984,6 @@ function ScheduledTaskEditorDialog({
984
const [draft, setDraft] = useState<DraftState>(() =>
985
task ? taskToDraft(task) : { ...EMPTY_DRAFT, projectId: projects[0]?.id ?? "" },
986
);
952
- const [saving, setSaving] = useState(false);
987
const submissionPending = useRef(false);
988
const editingTaskMissing =
989
draft.editingId !== null &&
@@ -1090,459 +1124,446 @@ function ScheduledTaskEditorDialog({
1124
};
1125
1126
return (
1093
- <Dialog
1094
- open
1095
- onOpenChange={(open) => {
1096
- if (!open && !saving) onClose();
1097
- }}
1098
- >
1099
- <DialogPopup className="max-w-xl">
1100
- <DialogHeader>
1101
- <DialogTitle>{draft.editingId ? "Edit task" : "New task"}</DialogTitle>
1102
- <DialogDescription>
1103
- Run a prompt automatically — on an interval, at a fixed time, or when a webhook is
1104
- called.
1105
- </DialogDescription>
1106
- </DialogHeader>
1127
+ <>
1128
+ <DialogHeader>
1129
+ <DialogTitle>{draft.editingId ? "Edit task" : "New task"}</DialogTitle>
1130
+ <DialogDescription>
1131
+ Run a prompt automatically — on an interval, at a fixed time, or when a webhook is called.
1132
+ </DialogDescription>
1133
+ </DialogHeader>
1134
1108
- <DialogPanel>
1109
- <fieldset disabled={saving} className="space-y-5">
1110
- {!connected ? (
1111
- <p className="text-sm text-destructive">Reconnect this environment before saving.</p>
1112
- ) : null}
1113
- <Field label="Runs on" htmlFor="scheduled-task-environment">
1135
+ <DialogPanel>
1136
+ <fieldset disabled={saving} className="space-y-5">
1137
+ {!connected ? (
1138
+ <p className="text-sm text-destructive">Reconnect this environment before saving.</p>
1139
+ ) : null}
1140
+ <Field label="Runs on" htmlFor="scheduled-task-environment">
1141
+ <Select
1142
+ value={environmentId}
1143
+ disabled={task !== null || saving}
1144
+ onValueChange={(id) => {
1145
+ const next = connectedEnvironments.find((entry) => entry.environmentId === id);
1146
+ if (!next) return;
1147
+ setEnvironmentId(next.environmentId);
1148
+ setDraft((current) => ({
1149
+ ...current,
1150
+ projectId: "",
1151
+ modelKey: "",
1152
+ baseModelSelection: null,
1153
+ baseRef: "main",
1154
+ startFromOrigin: true,
1155
+ existingWorktreePath: "",
1156
+ }));
1157
+ }}
1158
+ >
1159
+ <SelectTrigger id="scheduled-task-environment" size="sm">
1160
+ <SelectValue>
1161
+ <span className="flex items-center gap-2">
1162
+ <EnvironmentMachineIcon
1163
+ kind={resolveEnvironmentMachineKind(environment?.serverConfig ?? null)}
1164
+ className="size-4"
1165
+ />
1166
+ {environment?.label ?? "Unavailable environment"}
1167
+ </span>
1168
+ </SelectValue>
1169
+ </SelectTrigger>
1170
+ <SelectPopup>
1171
+ {connectedEnvironments.map((entry) => {
1172
+ const { secondary } = settingsScopeEnvironmentLabels(
1173
+ entry,
1174
+ connectedEnvironments,
1175
+ );
1176
+ return (
1177
+ <SelectItem
1178
+ key={entry.environmentId}
1179
+ value={entry.environmentId}
1180
+ label={entry.label}
1181
+ >
1182
+ <span className="flex min-w-0 items-center gap-2">
1183
+ <EnvironmentMachineIcon
1184
+ kind={resolveEnvironmentMachineKind(entry.serverConfig)}
1185
+ className="size-4"
1186
+ />
1187
+ <span className="min-w-0">
1188
+ <span className="block truncate">{entry.label}</span>
1189
+ {secondary ? (
1190
+ <span className="block max-w-72 truncate text-xs text-muted-foreground">
1191
+ {secondary}
1192
+ </span>
1193
+ ) : null}
1194
+ </span>
1195
+ </span>
1196
+ </SelectItem>
1197
+ );
1198
+ })}
1199
+ </SelectPopup>
1200
+ </Select>
1201
+ </Field>
1202
+ {tasksQuery.error ? (
1203
+ <p className="text-sm text-destructive" role="status">
1204
+ {tasksQuery.error}
1205
+ </p>
1206
+ ) : null}
1207
+ {editingTaskMissing ? (
1208
+ <p className="text-xs text-destructive" role="status">
1209
+ This scheduled task no longer exists.
1210
+ </p>
1211
+ ) : null}
1212
+ <Field label="Name" htmlFor="scheduled-task-title">
1213
+ <Input
1214
+ id="scheduled-task-title"
1215
+ placeholder="e.g. Check for Sentry issues"
1216
+ value={draft.title}
1217
+ onChange={(event) =>
1218
+ setDraft((current) => ({ ...current, title: event.target.value }))
1219
+ }
1220
+ />
1221
+ </Field>
1222
+
1223
+ <div className="grid gap-3 sm:grid-cols-2">
1224
+ <Field label="Project" htmlFor="scheduled-task-project">
1225
<Select
1115
- value={environmentId}
1116
- disabled={task !== null || saving}
1117
- onValueChange={(id) => {
1118
- const next = connectedEnvironments.find((entry) => entry.environmentId === id);
1119
- if (!next) return;
1120
- setEnvironmentId(next.environmentId);
1121
- setDraft((current) => ({
1122
- ...current,
1123
- projectId: "",
1124
- modelKey: "",
1125
- baseModelSelection: null,
1126
- baseRef: "main",
1127
- startFromOrigin: true,
1128
- existingWorktreePath: "",
1129
- }));
1130
- }}
1226
+ value={selectedProjectId}
1227
+ onValueChange={(projectId) =>
1228
+ setDraft((current) => ({ ...current, projectId: projectId ?? "" }))
1229
+ }
1230
>
1132
- <SelectTrigger id="scheduled-task-environment" size="sm">
1133
- <SelectValue>
1134
- <span className="flex items-center gap-2">
1135
- <EnvironmentMachineIcon
1136
- kind={resolveEnvironmentMachineKind(environment?.serverConfig ?? null)}
1137
- className="size-4"
1138
- />
1139
- {environment?.label ?? "Unavailable environment"}
1140
- </span>
1141
- </SelectValue>
1231
+ <SelectTrigger size="sm" id="scheduled-task-project">
1232
+ <SelectValue placeholder="Select a project">{selectedProject?.title}</SelectValue>
1233
</SelectTrigger>
1234
<SelectPopup>
1144
- {connectedEnvironments.map((entry) => {
1145
- const { secondary } = settingsScopeEnvironmentLabels(
1146
- entry,
1147
- connectedEnvironments,
1148
- );
1149
- return (
1150
- <SelectItem
1151
- key={entry.environmentId}
1152
- value={entry.environmentId}
1153
- label={entry.label}
1154
- >
1155
- <span className="flex min-w-0 items-center gap-2">
1156
- <EnvironmentMachineIcon
1157
- kind={resolveEnvironmentMachineKind(entry.serverConfig)}
1158
- className="size-4"
1159
- />
1160
- <span className="min-w-0">
1161
- <span className="block truncate">{entry.label}</span>
1162
- {secondary ? (
1163
- <span className="block max-w-72 truncate text-xs text-muted-foreground">
1164
- {secondary}
1165
- </span>
1166
- ) : null}
1167
- </span>
1235
+ {projects.map((project) => (
1236
+ <SelectItem key={project.id} value={project.id} label={project.title}>
1237
+ <span className="block truncate">{project.title}</span>
1238
+ {allProjects.some(
1239
+ (other) =>
1240
+ other.title === project.title &&
1241
+ (other.environmentId !== project.environmentId ||
1242
+ other.id !== project.id),
1243
+ ) ? (
1244
+ <span className="block max-w-72 truncate text-xs text-muted-foreground">
1245
+ {project.workspaceRoot}
1246
</span>
1169
- </SelectItem>
1170
- );
1171
- })}
1247
+ ) : null}
1248
+ </SelectItem>
1249
+ ))}
1250
</SelectPopup>
1251
</Select>
1252
</Field>
1175
- {tasksQuery.error ? (
1176
- <p className="text-sm text-destructive" role="status">
1177
- {tasksQuery.error}
1178
- </p>
1179
- ) : null}
1180
- {editingTaskMissing ? (
1181
- <p className="text-xs text-destructive" role="status">
1182
- This scheduled task no longer exists.
1183
- </p>
1184
- ) : null}
1185
- <Field label="Name" htmlFor="scheduled-task-title">
1253
+
1254
+ <Field label="Workspace" htmlFor="scheduled-task-workspace">
1255
+ <Select
1256
+ value={draft.workspaceMode}
1257
+ onValueChange={(value) =>
1258
+ setDraft((current) => ({ ...current, workspaceMode: value as WorkspaceMode }))
1259
+ }
1260
+ >
1261
+ <SelectTrigger size="sm" id="scheduled-task-workspace">
1262
+ <SelectValue>{WORKSPACE_MODE_LABELS[draft.workspaceMode]}</SelectValue>
1263
+ </SelectTrigger>
1264
+ <SelectPopup>
1265
+ <SelectItem value="worktree">Create a new worktree</SelectItem>
1266
+ <SelectItem value="root">Use the project checkout</SelectItem>
1267
+ <SelectItem value="existing_worktree">Use a specific checkout</SelectItem>
1268
+ </SelectPopup>
1269
+ </Select>
1270
+ </Field>
1271
+ </div>
1272
+
1273
+ {draft.workspaceMode === "worktree" ? (
1274
+ <Field label="Base branch" htmlFor="scheduled-task-base-ref">
1275
+ <WorktreeBaseBranchPicker
1276
+ key={`${environmentId}:${selectedProjectId}`}
1277
+ id="scheduled-task-base-ref"
1278
+ environmentId={environmentId}
1279
+ cwd={selectedProject?.workspaceRoot ?? null}
1280
+ value={draft.baseRef}
1281
+ onValueChange={(baseRef) => setDraft((current) => ({ ...current, baseRef }))}
1282
+ startFromOrigin={draft.startFromOrigin}
1283
+ onStartFromOriginChange={(startFromOrigin) =>
1284
+ setDraft((current) => ({ ...current, startFromOrigin }))
1285
+ }
1286
+ disabled={saving || !connected}
1287
+ />
1288
+ </Field>
1289
+ ) : null}
1290
+ {draft.workspaceMode === "existing_worktree" ? (
1291
+ <Field label="Checkout path" htmlFor="scheduled-task-checkout">
1292
<Input
1187
- id="scheduled-task-title"
1188
- placeholder="e.g. Check for Sentry issues"
1189
- value={draft.title}
1293
+ id="scheduled-task-checkout"
1294
+ value={draft.existingWorktreePath}
1295
+ placeholder="/path/to/checkout"
1296
onChange={(event) =>
1191
- setDraft((current) => ({ ...current, title: event.target.value }))
1297
+ setDraft((current) => ({
1298
+ ...current,
1299
+ existingWorktreePath: event.target.value,
1300
+ }))
1301
}
1302
/>
1303
</Field>
1304
+ ) : null}
1305
1196
- <div className="grid gap-3 sm:grid-cols-2">
1197
- <Field label="Project" htmlFor="scheduled-task-project">
1198
- <Select
1199
- value={selectedProjectId}
1200
- onValueChange={(projectId) =>
1201
- setDraft((current) => ({ ...current, projectId: projectId ?? "" }))
1202
- }
1203
- >
1204
- <SelectTrigger size="sm" id="scheduled-task-project">
1205
- <SelectValue placeholder="Select a project">
1206
- {selectedProject?.title}
1207
- </SelectValue>
1208
- </SelectTrigger>
1209
- <SelectPopup>
1210
- {projects.map((project) => (
1211
- <SelectItem key={project.id} value={project.id} label={project.title}>
1212
- <span className="block truncate">{project.title}</span>
1213
- {allProjects.some(
1214
- (other) =>
1215
- other.title === project.title &&
1216
- (other.environmentId !== project.environmentId ||
1217
- other.id !== project.id),
1218
- ) ? (
1219
- <span className="block max-w-72 truncate text-xs text-muted-foreground">
1220
- {project.workspaceRoot}
1221
- </span>
1222
- ) : null}
1223
- </SelectItem>
1224
- ))}
1225
- </SelectPopup>
1226
- </Select>
1227
- </Field>
1306
+ <Field label="Prompt" htmlFor="scheduled-task-prompt">
1307
+ <Textarea
1308
+ id="scheduled-task-prompt"
1309
+ className="max-h-64 overflow-y-auto"
1310
+ placeholder="What should the agent do each time this runs?"
1311
+ value={draft.prompt}
1312
+ onChange={(event) =>
1313
+ setDraft((current) => ({ ...current, prompt: event.target.value }))
1314
+ }
1315
+ />
1316
+ </Field>
1317
1229
- <Field label="Workspace" htmlFor="scheduled-task-workspace">
1230
- <Select
1231
- value={draft.workspaceMode}
1232
- onValueChange={(value) =>
1233
- setDraft((current) => ({ ...current, workspaceMode: value as WorkspaceMode }))
1234
- }
1235
- >
1236
- <SelectTrigger size="sm" id="scheduled-task-workspace">
1237
- <SelectValue>{WORKSPACE_MODE_LABELS[draft.workspaceMode]}</SelectValue>
1238
- </SelectTrigger>
1239
- <SelectPopup>
1240
- <SelectItem value="worktree">Create a new worktree</SelectItem>
1241
- <SelectItem value="root">Use the project checkout</SelectItem>
1242
- <SelectItem value="existing_worktree">Use a specific checkout</SelectItem>
1243
- </SelectPopup>
1244
- </Select>
1245
- </Field>
1318
+ <Field label="Model">
1319
+ <div>
1320
+ <ProviderModelPicker
1321
+ environmentId={environmentId}
1322
+ disabled={saving || !connected}
1323
+ activeInstanceId={activeInstanceId}
1324
+ model={activeModel}
1325
+ lockedProvider={null}
1326
+ instanceEntries={instanceEntries}
1327
+ modelOptionsByInstance={modelOptionsByInstance}
1328
+ isComposerOwned={false}
1329
+ triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME}
1330
+ onInstanceModelChange={(instanceId, model) =>
1331
+ setDraft((current) => ({ ...current, modelKey: `${instanceId}:${model}` }))
1332
+ }
1333
+ />
1334
</div>
1335
+ </Field>
1336
1248
- {draft.workspaceMode === "worktree" ? (
1249
- <Field label="Base branch" htmlFor="scheduled-task-base-ref">
1250
- <WorktreeBaseBranchPicker
1251
- key={`${environmentId}:${selectedProjectId}`}
1252
- id="scheduled-task-base-ref"
1253
- environmentId={environmentId}
1254
- cwd={selectedProject?.workspaceRoot ?? null}
1255
- value={draft.baseRef}
1256
- onValueChange={(baseRef) => setDraft((current) => ({ ...current, baseRef }))}
1257
- startFromOrigin={draft.startFromOrigin}
1258
- onStartFromOriginChange={(startFromOrigin) =>
1259
- setDraft((current) => ({ ...current, startFromOrigin }))
1260
- }
1261
- disabled={saving || !connected}
1262
- />
1263
- </Field>
1337
+ <div className="space-y-3">
1338
+ {task?.schedule.type === "interval" &&
1339
+ task.schedule.everyMs < MIN_SCHEDULED_TASK_INTERVAL_MS ? (
1340
+ <p className="text-sm text-muted-foreground" role="status">
1341
+ This task uses a legacy interval below one minute. Saving updates it to at least one
1342
+ minute.
1343
+ </p>
1344
) : null}
1265
- {draft.workspaceMode === "existing_worktree" ? (
1266
- <Field label="Checkout path" htmlFor="scheduled-task-checkout">
1267
- <Input
1268
- id="scheduled-task-checkout"
1269
- value={draft.existingWorktreePath}
1270
- placeholder="/path/to/checkout"
1271
- onChange={(event) =>
1345
+ <div className="flex items-center justify-between gap-2">
1346
+ <Label>Schedule</Label>
1347
+ <ToggleGroup
1348
+ aria-label="Schedule type"
1349
+ value={[draft.scheduleMode]}
1350
+ onValueChange={(values) => {
1351
+ const mode = values[0] as ScheduleMode | undefined;
1352
+ if (mode === "fixed" || mode === "interval" || mode === "webhook")
1353
setDraft((current) => ({
1354
...current,
1274
- existingWorktreePath: event.target.value,
1275
- }))
1276
- }
1277
- />
1278
- </Field>
1279
- ) : null}
1280
-
1281
- <Field label="Prompt" htmlFor="scheduled-task-prompt">
1282
- <Textarea
1283
- id="scheduled-task-prompt"
1284
- className="max-h-64 overflow-y-auto"
1285
- placeholder="What should the agent do each time this runs?"
1286
- value={draft.prompt}
1287
- onChange={(event) =>
1288
- setDraft((current) => ({ ...current, prompt: event.target.value }))
1289
- }
1290
- />
1291
- </Field>
1355
+ scheduleMode: mode,
1356
+ prompt:
1357
+ mode === "webhook" && !current.prompt.trim()
1358
+ ? DEFAULT_WEBHOOK_PROMPT
1359
+ : current.prompt,
1360
+ }));
1361
+ }}
1362
+ >
1363
+ <Toggle value="fixed">At a time</Toggle>
1364
+ <Toggle value="interval">Every interval</Toggle>
1365
+ <Toggle value="webhook">On webhook</Toggle>
1366
+ </ToggleGroup>
1367
+ </div>
1368
1293
- <Field label="Model">
1294
- <div>
1295
- <ProviderModelPicker
1296
- environmentId={environmentId}
1297
- disabled={saving || !connected}
1298
- activeInstanceId={activeInstanceId}
1299
- model={activeModel}
1300
- lockedProvider={null}
1301
- instanceEntries={instanceEntries}
1302
- modelOptionsByInstance={modelOptionsByInstance}
1303
- isComposerOwned={false}
1304
- triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME}
1305
- onInstanceModelChange={(instanceId, model) =>
1306
- setDraft((current) => ({ ...current, modelKey: `${instanceId}:${model}` }))
1369
+ {draft.scheduleMode === "webhook" ? (
1370
+ <div className="space-y-4">
1371
+ <WebhookEndpointField environmentId={environmentId} task={liveTask} />
1372
+ <p className="text-xs text-muted-foreground">
1373
+ {
1374
+ "Each request runs the prompt. Use {{body.path}}, {{headers.name}}, {{query.name}}, {{body}} or {{request}} in the prompt; only what it names reaches the agent."
1375
}
1308
- />
1309
- </div>
1310
- </Field>
1311
-
1312
- <div className="space-y-3">
1313
- {task?.schedule.type === "interval" &&
1314
- task.schedule.everyMs < MIN_SCHEDULED_TASK_INTERVAL_MS ? (
1315
- <p className="text-sm text-muted-foreground" role="status">
1316
- This task uses a legacy interval below one minute. Saving updates it to at least
1317
- one minute.
1376
</p>
1319
- ) : null}
1320
- <div className="flex items-center justify-between gap-2">
1321
- <Label>Schedule</Label>
1322
- <ToggleGroup
1323
- aria-label="Schedule type"
1324
- value={[draft.scheduleMode]}
1325
- onValueChange={(values) => {
1326
- const mode = values[0] as ScheduleMode | undefined;
1327
- if (mode === "fixed" || mode === "interval" || mode === "webhook")
1377
+ <Field
1378
+ label="Skip requests older than"
1379
+ hint="minutes, optional"
1380
+ htmlFor="scheduled-task-max-age"
1381
+ >
1382
+ <Input
1383
+ id="scheduled-task-max-age"
1384
+ type="number"
1385
+ nativeInput
1386
+ min={1}
1387
+ max={MAX_WEBHOOK_DELIVERY_AGE_MINUTES}
1388
+ placeholder="Run every request"
1389
+ value={draft.maxDeliveryAgeMinutes}
1390
+ onChange={(event) =>
1391
setDraft((current) => ({
1392
...current,
1330
- scheduleMode: mode,
1331
- prompt:
1332
- mode === "webhook" && !current.prompt.trim()
1333
- ? DEFAULT_WEBHOOK_PROMPT
1334
- : current.prompt,
1335
- }));
1336
- }}
1337
- >
1338
- <Toggle value="fixed">At a time</Toggle>
1339
- <Toggle value="interval">Every interval</Toggle>
1340
- <Toggle value="webhook">On webhook</Toggle>
1341
- </ToggleGroup>
1342
- </div>
1343
-
1344
- {draft.scheduleMode === "webhook" ? (
1345
- <div className="space-y-4">
1346
- <WebhookEndpointField environmentId={environmentId} task={liveTask} />
1347
- <p className="text-xs text-muted-foreground">
1348
- {
1349
- "Each request runs the prompt. Use {{body.path}}, {{headers.name}}, {{query.name}}, {{body}} or {{request}} in the prompt; only what it names reaches the agent."
1393
+ maxDeliveryAgeMinutes: event.target.value,
1394
+ }))
1395
}
1351
- </p>
1352
- <Field
1353
- label="Skip requests older than"
1354
- hint="minutes, optional"
1355
- htmlFor="scheduled-task-max-age"
1356
- >
1357
- <Input
1358
- id="scheduled-task-max-age"
1359
- type="number"
1360
- nativeInput
1361
- min={1}
1362
- max={MAX_WEBHOOK_DELIVERY_AGE_MINUTES}
1363
- placeholder="Run every request"
1364
- value={draft.maxDeliveryAgeMinutes}
1365
- onChange={(event) =>
1366
- setDraft((current) => ({
1367
- ...current,
1368
- maxDeliveryAgeMinutes: event.target.value,
1369
- }))
1370
- }
1371
- />
1372
- </Field>
1373
- <div className="flex items-center justify-between gap-4">
1374
- <div className="min-w-0 space-y-1">
1375
- <Label htmlFor="scheduled-task-signature">Require signature</Label>
1376
- <p className="text-sm text-muted-foreground">
1377
- Reject requests without a valid HMAC-SHA256 signature of the body.
1378
- </p>
1379
- </div>
1380
- <Switch
1381
- id="scheduled-task-signature"
1382
- checked={draft.signatureEnabled}
1383
- onCheckedChange={(signatureEnabled) =>
1384
- setDraft((current) => ({ ...current, signatureEnabled }))
1385
- }
1386
- />
1396
+ />
1397
+ </Field>
1398
+ <div className="flex items-center justify-between gap-4">
1399
+ <div className="min-w-0 space-y-1">
1400
+ <Label htmlFor="scheduled-task-signature">Require signature</Label>
1401
+ <p className="text-sm text-muted-foreground">
1402
+ Reject requests without a valid HMAC-SHA256 signature of the body.
1403
+ </p>
1404
</div>
1388
- {draft.signatureEnabled ? (
1389
- <div className="grid gap-3 sm:grid-cols-2">
1390
- <Field label="Header" htmlFor="scheduled-task-signature-header">
1391
- <Input
1392
- id="scheduled-task-signature-header"
1393
- value={draft.signatureHeader}
1394
- onChange={(event) =>
1395
- setDraft((current) => ({
1396
- ...current,
1397
- signatureHeader: event.target.value,
1398
- }))
1399
- }
1400
- />
1401
- </Field>
1402
- <Field label="Prefix" htmlFor="scheduled-task-signature-prefix">
1403
- <Input
1404
- id="scheduled-task-signature-prefix"
1405
- value={draft.signaturePrefix}
1406
- placeholder="None"
1407
- onChange={(event) =>
1408
- setDraft((current) => ({
1409
- ...current,
1410
- signaturePrefix: event.target.value,
1411
- }))
1412
- }
1413
- />
1414
- </Field>
1415
- <Field label="Encoding" htmlFor="scheduled-task-signature-encoding">
1416
- <Select
1417
- value={draft.signatureEncoding}
1418
- onValueChange={(value) =>
1419
- setDraft((current) => ({
1420
- ...current,
1421
- signatureEncoding: value === "base64" ? "base64" : "hex",
1422
- }))
1423
- }
1424
- >
1425
- <SelectTrigger size="sm" id="scheduled-task-signature-encoding">
1426
- <SelectValue>{draft.signatureEncoding}</SelectValue>
1427
- </SelectTrigger>
1428
- <SelectPopup>
1429
- <SelectItem value="hex">hex</SelectItem>
1430
- <SelectItem value="base64">base64</SelectItem>
1431
- </SelectPopup>
1432
- </Select>
1433
- </Field>
1434
- <Field label="Secret" htmlFor="scheduled-task-signature-secret">
1435
- <Input
1436
- id="scheduled-task-signature-secret"
1437
- type="password"
1438
- autoComplete="off"
1439
- value={draft.signatureSecret}
1440
- placeholder={
1441
- liveTask?.schedule.type === "webhook" && liveTask.webhook?.hasSecret
1442
- ? "Unchanged"
1443
- : "Shared secret"
1444
- }
1445
- onChange={(event) =>
1446
- setDraft((current) => ({
1447
- ...current,
1448
- signatureSecret: event.target.value,
1449
- }))
1450
- }
1451
- />
1452
- </Field>
1453
- </div>
1454
- ) : null}
1405
+ <Switch
1406
+ id="scheduled-task-signature"
1407
+ checked={draft.signatureEnabled}
1408
+ onCheckedChange={(signatureEnabled) =>
1409
+ setDraft((current) => ({ ...current, signatureEnabled }))
1410
+ }
1411
+ />
1412
</div>
1456
- ) : draft.scheduleMode === "fixed" ? (
1457
- <div className="flex flex-wrap items-center gap-3">
1458
- <div className="flex items-center gap-2">
1459
- <Label htmlFor="scheduled-task-time">Run at</Label>
1460
- <Input
1461
- type="time"
1462
- id="scheduled-task-time"
1463
- nativeInput
1464
- className="w-32"
1465
- value={draft.timeOfDay}
1466
- onChange={(event) =>
1467
- setDraft((current) => ({ ...current, timeOfDay: event.target.value }))
1468
- }
1469
- />
1470
- <span className="text-xs text-muted-foreground">on</span>
1413
+ {draft.signatureEnabled ? (
1414
+ <div className="grid gap-3 sm:grid-cols-2">
1415
+ <Field label="Header" htmlFor="scheduled-task-signature-header">
1416
+ <Input
1417
+ id="scheduled-task-signature-header"
1418
+ value={draft.signatureHeader}
1419
+ onChange={(event) =>
1420
+ setDraft((current) => ({
1421
+ ...current,
1422
+ signatureHeader: event.target.value,
1423
+ }))
1424
+ }
1425
+ />
1426
+ </Field>
1427
+ <Field label="Prefix" htmlFor="scheduled-task-signature-prefix">
1428
+ <Input
1429
+ id="scheduled-task-signature-prefix"
1430
+ value={draft.signaturePrefix}
1431
+ placeholder="None"
1432
+ onChange={(event) =>
1433
+ setDraft((current) => ({
1434
+ ...current,
1435
+ signaturePrefix: event.target.value,
1436
+ }))
1437
+ }
1438
+ />
1439
+ </Field>
1440
+ <Field label="Encoding" htmlFor="scheduled-task-signature-encoding">
1441
+ <Select
1442
+ value={draft.signatureEncoding}
1443
+ onValueChange={(value) =>
1444
+ setDraft((current) => ({
1445
+ ...current,
1446
+ signatureEncoding: value === "base64" ? "base64" : "hex",
1447
+ }))
1448
+ }
1449
+ >
1450
+ <SelectTrigger size="sm" id="scheduled-task-signature-encoding">
1451
+ <SelectValue>{draft.signatureEncoding}</SelectValue>
1452
+ </SelectTrigger>
1453
+ <SelectPopup>
1454
+ <SelectItem value="hex">hex</SelectItem>
1455
+ <SelectItem value="base64">base64</SelectItem>
1456
+ </SelectPopup>
1457
+ </Select>
1458
+ </Field>
1459
+ <Field label="Secret" htmlFor="scheduled-task-signature-secret">
1460
+ <Input
1461
+ id="scheduled-task-signature-secret"
1462
+ type="password"
1463
+ autoComplete="off"
1464
+ value={draft.signatureSecret}
1465
+ placeholder={
1466
+ liveTask?.schedule.type === "webhook" && liveTask.webhook?.hasSecret
1467
+ ? "Unchanged"
1468
+ : "Shared secret"
1469
+ }
1470
+ onChange={(event) =>
1471
+ setDraft((current) => ({
1472
+ ...current,
1473
+ signatureSecret: event.target.value,
1474
+ }))
1475
+ }
1476
+ />
1477
+ </Field>
1478
</div>
1472
- <ToggleGroup
1473
- multiple
1474
- variant="outline"
1475
- size="sm"
1476
- aria-label="Days to run"
1477
- value={[...draft.weekdays].map(String)}
1478
- onValueChange={(values) => {
1479
- if (values.length === 0) return;
1480
- setDraft((current) => ({
1481
- ...current,
1482
- weekdays: new Set(values.map(Number)),
1483
- }));
1484
- }}
1485
- >
1486
- {WEEKDAY_ORDER.map((day) => (
1487
- <Toggle key={day} value={String(day)} aria-label={WEEKDAY_LABELS[day]}>
1488
- {WEEKDAY_SHORT[day]}
1489
- </Toggle>
1490
- ))}
1491
- </ToggleGroup>
1492
- </div>
1493
- ) : (
1479
+ ) : null}
1480
+ </div>
1481
+ ) : draft.scheduleMode === "fixed" ? (
1482
+ <div className="flex flex-wrap items-center gap-3">
1483
<div className="flex items-center gap-2">
1495
- <Label htmlFor="scheduled-task-interval">Run every</Label>
1484
+ <Label htmlFor="scheduled-task-time">Run at</Label>
1485
<Input
1497
- type="number"
1498
- id="scheduled-task-interval"
1486
+ type="time"
1487
+ id="scheduled-task-time"
1488
nativeInput
1500
- min={1}
1501
- step="any"
1502
- className="w-24"
1503
- value={draft.intervalMinutes}
1489
+ className="w-32"
1490
+ value={draft.timeOfDay}
1491
onChange={(event) =>
1505
- setDraft((current) => ({ ...current, intervalMinutes: event.target.value }))
1492
+ setDraft((current) => ({ ...current, timeOfDay: event.target.value }))
1493
}
1494
/>
1508
- <span className="text-xs text-muted-foreground">minutes</span>
1495
+ <span className="text-xs text-muted-foreground">on</span>
1496
</div>
1510
- )}
1511
- </div>
1512
-
1513
- <div className="flex items-center justify-between gap-4">
1514
- <div className="min-w-0 space-y-1">
1515
- <Label htmlFor="scheduled-task-enabled">Enabled</Label>
1516
- <p
1517
- id="scheduled-task-enabled-description"
1518
- className="text-sm text-muted-foreground"
1497
+ <ToggleGroup
1498
+ multiple
1499
+ variant="outline"
1500
+ size="sm"
1501
+ aria-label="Days to run"
1502
+ value={[...draft.weekdays].map(String)}
1503
+ onValueChange={(values) => {
1504
+ if (values.length === 0) return;
1505
+ setDraft((current) => ({
1506
+ ...current,
1507
+ weekdays: new Set(values.map(Number)),
1508
+ }));
1509
+ }}
1510
>
1520
- Disabled tasks stay saved but do not run.
1521
- </p>
1511
+ {WEEKDAY_ORDER.map((day) => (
1512
+ <Toggle key={day} value={String(day)} aria-label={WEEKDAY_LABELS[day]}>
1513
+ {WEEKDAY_SHORT[day]}
1514
+ </Toggle>
1515
+ ))}
1516
+ </ToggleGroup>
1517
</div>
1523
- <Switch
1524
- id="scheduled-task-enabled"
1525
- aria-describedby="scheduled-task-enabled-description"
1526
- checked={draft.enabled}
1527
- onCheckedChange={(enabled) => setDraft((current) => ({ ...current, enabled }))}
1528
- />
1518
+ ) : (
1519
+ <div className="flex items-center gap-2">
1520
+ <Label htmlFor="scheduled-task-interval">Run every</Label>
1521
+ <Input
1522
+ type="number"
1523
+ id="scheduled-task-interval"
1524
+ nativeInput
1525
+ min={1}
1526
+ step="any"
1527
+ className="w-24"
1528
+ value={draft.intervalMinutes}
1529
+ onChange={(event) =>
1530
+ setDraft((current) => ({ ...current, intervalMinutes: event.target.value }))
1531
+ }
1532
+ />
1533
+ <span className="text-xs text-muted-foreground">minutes</span>
1534
+ </div>
1535
+ )}
1536
+ </div>
1537
+
1538
+ <div className="flex items-center justify-between gap-4">
1539
+ <div className="min-w-0 space-y-1">
1540
+ <Label htmlFor="scheduled-task-enabled">Enabled</Label>
1541
+ <p id="scheduled-task-enabled-description" className="text-sm text-muted-foreground">
1542
+ Disabled tasks stay saved but do not run.
1543
+ </p>
1544
</div>
1530
- </fieldset>
1531
- </DialogPanel>
1545
+ <Switch
1546
+ id="scheduled-task-enabled"
1547
+ aria-describedby="scheduled-task-enabled-description"
1548
+ checked={draft.enabled}
1549
+ onCheckedChange={(enabled) => setDraft((current) => ({ ...current, enabled }))}
1550
+ />
1551
+ </div>
1552
+ </fieldset>
1553
+ </DialogPanel>
1554
1533
- <DialogFooter>
1534
- <DialogClose render={<Button variant="outline" size="sm" disabled={saving} />}>
1535
- Cancel
1536
- </DialogClose>
1537
- <Button
1538
- size="sm"
1539
- disabled={!canOperate || saving || editingTaskMissing || !connected || !tasksQuery.data}
1540
- onClick={() => void submit()}
1541
- >
1542
- {draft.editingId ? "Save task" : "Create task"}
1543
- </Button>
1544
- </DialogFooter>
1545
- </DialogPopup>
1546
- </Dialog>
1555
+ <DialogFooter>
1556
+ <DialogClose render={<Button variant="outline" size="sm" disabled={saving} />}>
1557
+ Cancel
1558
+ </DialogClose>
1559
+ <Button
1560
+ size="sm"
1561
+ disabled={!canOperate || saving || editingTaskMissing || !connected || !tasksQuery.data}
1562
+ onClick={() => void submit()}
1563
+ >
1564
+ {draft.editingId ? "Save task" : "Create task"}
1565
+ </Button>
1566
+ </DialogFooter>
1567
+ </>
1568
);
1569
}