From 8490f4435d4b1ebd1b4704f7b4b9bf20f5362e06 Mon Sep 17 00:00:00 2001 From: centdix Date: Sat, 21 Feb 2026 15:27:43 +0000 Subject: [PATCH] feat: extract CreateWorktreeDialog component and fix Enter to confirm Extract inline create dialog into its own component. Wrap both dialogs in forms so Enter submits, and autofocus the confirm button in ConfirmDialog so Enter triggers confirm instead of cancel. Co-Authored-By: Claude Opus 4.6 --- dev-dashboard/frontend/src/App.svelte | 66 +++--------------- .../frontend/src/lib/ConfirmDialog.svelte | 24 ++++--- .../src/lib/CreateWorktreeDialog.svelte | 68 +++++++++++++++++++ 3 files changed, 90 insertions(+), 68 deletions(-) create mode 100644 dev-dashboard/frontend/src/lib/CreateWorktreeDialog.svelte diff --git a/dev-dashboard/frontend/src/App.svelte b/dev-dashboard/frontend/src/App.svelte index 68ffa5fc28..e75ec33412 100644 --- a/dev-dashboard/frontend/src/App.svelte +++ b/dev-dashboard/frontend/src/App.svelte @@ -4,24 +4,17 @@ import TopBar from "./lib/TopBar.svelte"; import Terminal from "./lib/Terminal.svelte"; import ConfirmDialog from "./lib/ConfirmDialog.svelte"; + import CreateWorktreeDialog from "./lib/CreateWorktreeDialog.svelte"; import type { WorktreeInfo } from "./lib/types"; import type { Profile } from "./lib/api"; import * as api from "./lib/api"; - const PROFILES: { value: Profile; label: string }[] = [ - { value: "agent-only", label: "Agent only" }, - { value: "agent-yolo", label: "Agent (skip permissions)" }, - { value: "full", label: "Full (agent + backend + frontend)" }, - ]; - let worktrees = $state([]); let selectedBranch = $state(null); let removeBranch = $state(null); let removingBranches = $state>(new Set()); let showCreateDialog = $state(false); let creating = $state(false); - let createProfile = $state("agent-only"); - let createName = $state(""); let visibleWorktrees = $derived( worktrees.filter((w) => w.path === "(here)" || w.branch === "main" || w.mux === "✓") @@ -47,14 +40,13 @@ return result; } - async function handleCreate() { - const branch = createName.trim() || randomName(8); + async function handleCreate(name: string, profile: Profile) { + const branch = name || randomName(8); creating = true; try { - await api.createWorktree(branch, createProfile); + await api.createWorktree(branch, profile); await api.openWorktree(branch); showCreateDialog = false; - createName = ""; await refresh(); selectedBranch = branch; } catch (err) { @@ -135,51 +127,11 @@ {#if showCreateDialog} - {@const btn = "px-3 py-1.5 rounded-md border border-edge bg-surface text-primary text-xs cursor-pointer hover:bg-hover"} - -

New Worktree

-
- - -
-
- {#each PROFILES as profile} - - {/each} -
-
- - -
-
-
(showCreateDialog = false)}>
+ (showCreateDialog = false)} + /> {/if} {#if removeBranch} diff --git a/dev-dashboard/frontend/src/lib/ConfirmDialog.svelte b/dev-dashboard/frontend/src/lib/ConfirmDialog.svelte index 22aaa3e4fc..fa90579d85 100644 --- a/dev-dashboard/frontend/src/lib/ConfirmDialog.svelte +++ b/dev-dashboard/frontend/src/lib/ConfirmDialog.svelte @@ -16,15 +16,17 @@ -

Confirm

-

{message}

-
- - -
+
{ e.preventDefault(); onconfirm(); }}> +

Confirm

+

{message}

+
+ + +
+
diff --git a/dev-dashboard/frontend/src/lib/CreateWorktreeDialog.svelte b/dev-dashboard/frontend/src/lib/CreateWorktreeDialog.svelte new file mode 100644 index 0000000000..d49aa7d9f9 --- /dev/null +++ b/dev-dashboard/frontend/src/lib/CreateWorktreeDialog.svelte @@ -0,0 +1,68 @@ + + + +
{ e.preventDefault(); oncreate(name.trim(), profile); }}> +

New Worktree

+
+ + +
+
+ {#each PROFILES as p} + + {/each} +
+
+ + +
+
+