@laoyuehanni/dsh-git-worktree 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -8,6 +8,7 @@ window.__ModuleLoader__.load({
8
8
  let react_dom = require("react-dom");
9
9
  let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
10
10
  let react_jsx_runtime = require("react/jsx-runtime");
11
+ let _deepseek_ai_dsh_client_runtime_client = require("@deepseek-ai/dsh-client-runtime/client");
11
12
  //#region src/normalize.ts
12
13
  /**
13
14
  * Local branch name for a display name: strip the leading `<remote>/` segment
@@ -21,6 +22,29 @@ window.__ModuleLoader__.load({
21
22
  const at = branch.indexOf("/");
22
23
  return at <= 0 ? branch : branch.slice(at + 1);
23
24
  }
25
+ /**
26
+ * Pre-flight check of a user-typed NEW branch name against git's ref-name
27
+ * rules (git check-ref-format's reject list, the subset typing can hit):
28
+ * non-empty; no leading `-` (git would parse it as a flag); no space, `~^:?*[\`
29
+ * or control character; no `..`, `@{`, `//`, leading/trailing `/`; no component
30
+ * starting with `.` or ending with `.lock`; no trailing `.`; not the lone `@`.
31
+ * `git switch -c` stays the authority — a miss here surfaces through the
32
+ * error envelope — this only feeds immediate form feedback.
33
+ * @param name - raw draft text (NOT trimmed: a space is a real issue).
34
+ * @returns the issue kind, or null when the name is acceptable.
35
+ */
36
+ function branchNameIssue(name) {
37
+ if (name.trim() === "") return "empty";
38
+ if (name.startsWith("-")) return "leadingDash";
39
+ if (name === "@") return "illegal";
40
+ if (/[\s~^:?*[\\\u0000-\u001f]/.test(name)) return "illegal";
41
+ if (name.includes("..") || name.includes("@{") || name.includes("//")) return "illegal";
42
+ if (name.startsWith("/") || name.endsWith("/")) return "illegal";
43
+ if (name.endsWith(".")) return "illegal";
44
+ if (/(^|\/)\./.test(name)) return "illegal";
45
+ if (/(^|\/)[^/]+\.lock($|\/)/.test(name)) return "illegal";
46
+ return null;
47
+ }
24
48
  //#endregion
25
49
  //#region src/wire.ts
26
50
  /**
@@ -37,6 +61,14 @@ window.__ModuleLoader__.load({
37
61
  const ROUTE_WORKTREE = `${ROUTE_PREFIX}/worktree`;
38
62
  /** POST ROUTE_PREFIX/switch — in-place branch switch of the main checkout. */
39
63
  const ROUTE_SWITCH = `${ROUTE_PREFIX}/switch`;
64
+ /** POST ROUTE_PREFIX/branch — create a NEW branch from the current checkout and switch to it. */
65
+ const ROUTE_BRANCH = `${ROUTE_PREFIX}/branch`;
66
+ /** POST ROUTE_PREFIX/fetch — sync remote-tracking refs (fetch every remote + prune). */
67
+ const ROUTE_FETCH = `${ROUTE_PREFIX}/fetch`;
68
+ /** POST ROUTE_PREFIX/update — fast-forward the current branch to its upstream. */
69
+ const ROUTE_UPDATE = `${ROUTE_PREFIX}/update`;
70
+ /** POST ROUTE_PREFIX/group — git belonging facts for a batch of workspace paths. */
71
+ const ROUTE_GROUP = `${ROUTE_PREFIX}/group`;
40
72
  //#endregion
41
73
  //#region src/client/api.ts
42
74
  /** POST one JSON body and parse the uniform envelope. */
@@ -105,12 +137,15 @@ window.__ModuleLoader__.load({
105
137
  * worktree (the current branch itself is occupied by the main worktree).
106
138
  * @param repoPath - absolute directory inside the repository.
107
139
  * @param branch - the current checkout's branch (or `HEAD` when detached).
140
+ * @param name - explicit name for the new branch; omitted, the host
141
+ * derives `<branch>-wt`, suffixing past taken names.
108
142
  */
109
- function requestWorktreeCutout(repoPath, branch) {
143
+ function requestWorktreeCutout(repoPath, branch, name) {
110
144
  return post(ROUTE_WORKTREE, {
111
145
  repoPath,
112
146
  branch,
113
- cutout: true
147
+ cutout: true,
148
+ ...name === void 0 ? {} : { name }
114
149
  });
115
150
  }
116
151
  /**
@@ -124,15 +159,51 @@ window.__ModuleLoader__.load({
124
159
  branch
125
160
  });
126
161
  }
162
+ /**
163
+ * Create a NEW branch from the directory's current checkout and switch to it
164
+ * in place.
165
+ * @param repoPath - absolute directory whose HEAD the branch is cut from.
166
+ * @param name - user-typed new branch name (validated client-side already).
167
+ */
168
+ function requestCreateBranch(repoPath, name) {
169
+ return post(ROUTE_BRANCH, {
170
+ repoPath,
171
+ name
172
+ });
173
+ }
174
+ /**
175
+ * Sync remote-tracking refs (fetch every remote + prune) for the repository.
176
+ * @param repoPath - absolute directory inside the repository.
177
+ */
178
+ function requestFetch(repoPath) {
179
+ return post(ROUTE_FETCH, { repoPath });
180
+ }
181
+ /**
182
+ * Update the CURRENT checkout: fetch every remote, then fast-forward the
183
+ * checked-out branch to its upstream.
184
+ * @param repoPath - absolute directory whose checked-out branch is updated.
185
+ */
186
+ function requestUpdate(repoPath) {
187
+ return post(ROUTE_UPDATE, { repoPath });
188
+ }
189
+ /**
190
+ * Git belonging facts for a batch of workspace directories; a path outside
191
+ * any git repository answers null, a failed route call answers the error
192
+ * envelope (the sidebar then renders flat, its degrade shape).
193
+ * @param paths - absolute workspace directories to probe.
194
+ */
195
+ async function requestGroupWorktrees(paths) {
196
+ return post(ROUTE_GROUP, { paths });
197
+ }
127
198
  //#endregion
128
199
  //#region \0git-worktree-css:D:\Code\dsh-worktree\src\client\BranchChip.module.css?inline
129
- const css$1 = "/* Branch chip row inside the composer tool row (conversation.input_2006230319.left_2006230319,\n * right of the mode chips). Modeled as a single rounded-rectangle\n * segmented control: the branch picker and the worktree toggle share one\n * container with a thin divider between them, so they read as one\n * affordance instead of two loose buttons.\n *\n * Geometry mirrors the composer trigger chips in the DSH base (see\n * PermissionSelect / ModelSelect): 28px height, 13/20 medium-secondary\n * label, transparent fill, no outline 鈥?the dock stays at the same\n * visual weight as the surrounding chips (dsh-worktree select, standard\n * mode select, Workspace Write, MiniMax-M3 High). The corners stop short\n * of the base's full pill (24px) so the silhouette stays a chip rather\n * than a capsule, per the design brief. */\n\n/* Shared trigger geometry 鈥?copied 1:1 from the base composer triggers\n * (PermissionSelect .trigger_2006230319 / ModelSelect .trigger_2006230319). Centralizing here\n * keeps the two segments visually fused so the divider reads as part of\n * one component, not two loose buttons. */\n.dock_2006230319 {\n display: inline-flex;\n align-items: stretch;\n height: 28px;\n border-radius: 6px;\n background: transparent;\n color: var(--dsw-alias-label-secondary, #81858c);\n font-size: 13px;\n line-height: 20px;\n font-weight: 500;\n min-height: 28px;\n overflow: hidden;\n}\n\n/* Vertical separator between the two segments. Uses the secondary label\n * color so it stays in the same tonal family as the surrounding trigger\n * outlines and chevrons. */\n.divider_2006230319 {\n width: 1px;\n margin: 6px 0;\n background: color-mix(in srgb, currentColor 22%, transparent);\n flex-shrink: 0;\n}\n\n.chip_2006230319 {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 100%;\n padding: 0 8px 0 8px;\n border: none;\n border-radius: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n font-weight: 500;\n cursor: pointer;\n}\n\n.chip_2006230319:hover {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* The leftmost segment rounds only its left corners so it tucks into the dock. */\n.chip_2006230319:first-child {\n border-top-left-radius: 6px;\n border-bottom-left-radius: 6px;\n}\n\n/* Started sessions drop the worktree segment: the lone chip rounds all\n * corners and reads as a plain button, not a broken-off half control. */\n.chip_2006230319:only-child {\n border-radius: 6px;\n}\n\n.branch_2006230319 {\n max-width: 16em;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.check_2006230319,\n.checkOn_2006230319 {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 100%;\n padding: 0 4px 0 8px;\n border: none;\n border-radius: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n font-weight: 500;\n cursor: pointer;\n}\n\n.check_2006230319:hover,\n.checkOn_2006230319:hover {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* The rightmost segment rounds only its right corners. */\n.check_2006230319:last-child,\n.checkOn_2006230319:last-child {\n border-top-right-radius: 6px;\n border-bottom-right-radius: 6px;\n}\n\n.box_2006230319 {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n border: 1px solid color-mix(in srgb, currentColor 45%, transparent);\n border-radius: 4px;\n}\n\n/* Selected worktree: only the checkbox itself turns bluish and fills 鈥?the\n * surrounding button stays transparent so the label keeps the same\n * secondary tone. Mirrors the Claude Code toggle treatment. The inner\n * check rides the bluish fill with an inverted foreground token so the\n * glyph stays legible. */\n.checkOn_2006230319 .box_2006230319 {\n border-color: var(--dsw-alias-label-primary-bluish, #4186f0);\n background: var(--dsw-alias-label-primary-bluish, #4186f0);\n color: var(--dsw-alias-label-primary-foreground, #ffffff);\n}\n\n.checkLabel_2006230319 {\n white-space: nowrap;\n}\n\n/* Confirm flyout: the second-level panel opening right of the branch\n * card (the base Menu's submenu posture: r12, inverted hairline,\n * shadow-lv3, --dsw-specific-menu). Width is content-driven — it follows\n * the branch name in the ask line — floored at 168px (the Cancel/Confirm\n * pair plus padding: short branch names must not squeeze the buttons into\n * wrapping \"切换中…\" mid-word) and capped at 400px; BranchMenu also clamps\n * it inline to the room right of the card. Beyond the cap the ask wraps.\n * border-box so every width arm includes the card chrome. */\n.popCard_2006230319 {\n box-sizing: border-box;\n position: fixed;\n z-index: 1000;\n width: max-content;\n min-width: 168px;\n max-width: min(400px, 80vw);\n padding: 4px;\n border: 1px solid var(--dsw-alias-border-inverted);\n border-radius: 12px;\n background: var(--dsw-specific-menu, var(--dsw-alias-surface-raised, #ffffff));\n box-shadow: var(--dsw-shadow-lv3);\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.popAsk_2006230319 {\n margin: 0;\n padding: 6px 8px;\n font-size: 13px;\n line-height: 20px;\n color: inherit;\n /* Branch names are long unbroken tokens — plain wrapping would let them\n * overflow the capped card instead of breaking. */\n overflow-wrap: anywhere;\n}\n\n.popActions_2006230319 {\n display: flex;\n gap: 2px;\n padding: 2px;\n}\n\n/* Menu-row-like buttons: transparent fill, hover tint, same 13px type.\n * nowrap keeps labels like 切换中… from splitting mid-word when the flyout\n * is pinned to its minimum width by a short branch name. */\n.popActions_2006230319 button {\n flex: 1 1 0;\n height: 28px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n white-space: nowrap;\n cursor: pointer;\n}\n\n.popActions_2006230319 button:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.popActions_2006230319 button:disabled {\n opacity: 0.5;\n cursor: default;\n}\n\n.popActions_2006230319 button:last-child {\n color: var(--dsw-alias-label-primary-bluish, #4186f0);\n font-weight: 500;\n}\n\n/* ── Branch picker popup (BranchMenu) ──────────────────────────────\n * Upward-opening card pinned above the chip, in the Menu's card chrome\n * (r12, inverted hairline, shadow-lv3, --dsw-specific-menu — same family\n * as .popCard_2006230319). Three owner requirements shape the geometry:\n *\n * 1. height cap: min(420px, 60vh) on the card, only the rows area\n * scrolls (.menuRows_2006230319) — heading and search stay pinned;\n * 2. the search field sits pinned at the card's bottom edge, directly\n * above the chip, with the scrolling rows above it;\n * 3. the card is CSS-`bottom`-pinned ~6px above the chip's top and so\n * grows entirely upward — it can never cover the composer or fill\n * the viewport, whatever the branch count.\n *\n * The inline `left`/`bottom` come from BranchMenu's placement pass; the\n * width is fixed here (design 360px — 320 tree + 40 tool strip — and\n * viewport-capped) so horizontal clamping stays deterministic without\n * measuring the card. */\n\n/* The portal lands directly under document.body_2006230319, outside the shell's\n * box-sizing reset — content-box default would add padding/border on top\n * of the declared width (360 became 370, and the width:100% children\n * padded 16px past the card's right clip, shearing off their rounded\n * corners). Every width-declared box in this popup opts back into\n * border-box: the card, the toolbar, the rows, and the search input. */\n.menuCard_2006230319 {\n box-sizing: border-box;\n position: fixed;\n z-index: 1000;\n display: flex;\n flex-direction: row;\n width: min(360px, calc(100vw - 24px));\n max-height: min(420px, 60vh);\n overflow: hidden;\n padding: 4px;\n border: 1px solid var(--dsw-alias-border-inverted);\n border-radius: 12px;\n background: var(--dsw-specific-menu, var(--dsw-alias-surface-raised, #ffffff));\n box-shadow: var(--dsw-shadow-lv3);\n}\n\n/* Left tool strip (IDEA branch-panel posture at popup scale): a narrow\n * column of icon-only buttons for actions that do not belong in the tree\n * — locate the checked-out branch, expand/collapse the whole tree.\n * Buttons stack from the BOTTOM up: the card's height shrinks when the\n * repo has few branches, so a top-anchored strip would drift around and\n * the buttons would sit far from the search bar; anchoring to the bottom\n * pins them at a stable spot (beside the search row) whatever the height. */\n.menuToolbar_2006230319 {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n gap: 2px;\n flex-shrink: 0;\n width: 32px;\n padding: 0 2px;\n margin-right: 4px;\n border-right: 1px solid color-mix(in srgb, currentColor 12%, transparent);\n}\n\n.menuToolButton_2006230319 {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n margin: 0 auto;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n cursor: pointer;\n}\n\n.menuToolButton_2006230319:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n.menuToolButton_2006230319:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n/* The main column: heading + scrollable rows + pinned search. */\n.menuMain_2006230319 {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n min-width: 0;\n}\n\n/* Non-interactive group heading — the Menu label row's posture. */\n.menuHeading_2006230319 {\n padding: 6px 8px 4px;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary, #81858c);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n flex-shrink: 0;\n}\n\n/* The only scrollable region: shrinks within the capped card so the\n * heading above and the search below stay visible while rows scroll. */\n.menuRows_2006230319 {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n}\n\n/* Menu-row-like buttons: transparent fill, hover tint, same 13px type.\n * Weight 500 mirrors the chip's branch label (the portal escapes the\n * composer's font context, so the match must be explicit — the inherited\n * body weight is 400 and reads visibly lighter than the chip beside it). */\n.menuRow_2006230319 {\n box-sizing: border-box; /* width:100% + padding must stay inside .menuRows_2006230319 */\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n min-height: 28px;\n padding: 4px 8px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n font-weight: 500;\n line-height: 20px;\n text-align: left;\n cursor: pointer;\n}\n\n.menuRow_2006230319:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* The checked-out branch: a persistent tint a step above the resting rows\n * so it reads as \"you are here\" the moment the list scrolls it into view\n * (BranchMenu centers it on open) — the trailing check alone is easy to\n * miss from a distance. */\n.menuRowSelected_2006230319,\n.menuRowSelected_2006230319:hover:not(:disabled) {\n background: color-mix(in srgb, currentColor 10%, transparent);\n}\n\n/* IDEA-style selection: the clicked row gets a bluish fill, layering over\n * the HEAD tint when the same row is both — selection communicates intent,\n * the HEAD tint communicates position, and they coexist (IDEA 4.4). */\n.menuRowPicked_2006230319,\n.menuRowPicked_2006230319:hover:not(:disabled) {\n background: color-mix(in srgb, var(--dsw-alias-label-primary-bluish, #4186f0) 18%, transparent);\n}\n\n/* Occupied-worktree branches: dimmed, not clickable. */\n.menuRow_2006230319:disabled {\n opacity: 0.45;\n cursor: default;\n}\n\n.menuRowLabel_2006230319 {\n flex: 1 1 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* Search hit highlight (IDEA): the matched substring gets a warm tint\n * behind it — theme-agnostic, legible in both light and dark cards. */\n.menuSearchMark_2006230319 {\n background: color-mix(in srgb, #b58900 38%, transparent);\n border-radius: 2px;\n}\n\n/* Tree group rows (folder headers) — BranchMenu's '/' prefix tree: the\n * same row geometry as .menuRow_2006230319, but labeled in the secondary tone so the\n * leaf rows pop, with a count badge and a chevron that turns on expand. */\n.menuGroup_2006230319 {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: 6px;\n width: 100%;\n min-height: 28px;\n padding: 4px 8px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: var(--dsw-alias-label-secondary, #81858c);\n font: inherit;\n font-size: 13px;\n font-weight: 500;\n line-height: 20px;\n text-align: left;\n cursor: pointer;\n}\n\n.menuGroup_2006230319:hover {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n.menuGroupLabel_2006230319 {\n flex: 1 1 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.menuGroupChevron_2006230319 {\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 12px;\n height: 12px;\n transition: transform 120ms ease;\n}\n\n.menuGroupChevronOpen_2006230319 {\n transform: rotate(90deg);\n}\n\n.menuGroupCount_2006230319 {\n flex-shrink: 0;\n font-size: 12px;\n line-height: 20px;\n font-weight: 400;\n color: color-mix(in srgb, currentColor 55%, transparent);\n}\n\n/* Zero-search-hit state: centered secondary line inside the rows area. */\n.menuEmpty_2006230319 {\n padding: 10px 8px;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary, #81858c);\n text-align: center;\n}\n\n/* Bottom-pinned search field, separated from the rows by a hairline.\n * Borderless so it reads as part of the card, focus shown as the\n * standard hover tint rather than an outline. */\n.menuSearchWrap_2006230319 {\n flex-shrink: 0;\n margin-top: 2px;\n padding-top: 4px;\n border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent);\n}\n\n.menuSearch_2006230319 {\n box-sizing: border-box; /* width:100% + padding must stay inside the wrap */\n width: 100%;\n height: 30px;\n padding: 0 8px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n /* Weight 500 mirrors the chip's branch label (see .menuRow_2006230319) — the portal\n * escapes the composer's font context and would inherit body's 400. */\n font-weight: 500;\n line-height: 20px;\n}\n\n.menuSearch_2006230319::placeholder {\n color: var(--dsw-alias-label-secondary, #81858c);\n}\n\n.menuSearch_2006230319:focus {\n outline: none;\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n";
130
- const tagId$1 = "@laoyuehanni/dsh-git-worktree/BranchChip.module.css";
131
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId$1 + "\"]") === null) {
200
+ const css$3 = "/* Branch chip row inside the composer tool row (conversation.input_2006230319.left_2006230319,\n * right of the mode chips). Modeled as a single rounded-rectangle\n * segmented control: the branch picker and the worktree toggle share one\n * container with a thin divider between them, so they read as one\n * affordance instead of two loose buttons.\n *\n * Geometry mirrors the composer trigger chips in the DSH base (see\n * PermissionSelect / ModelSelect): 28px height, 13/20 medium-secondary\n * label, transparent fill, no outline 鈥?the dock stays at the same\n * visual weight as the surrounding chips (dsh-worktree select, standard\n * mode select, Workspace Write, MiniMax-M3 High). The corners stop short\n * of the base's full pill (24px) so the silhouette stays a chip rather\n * than a capsule, per the design brief. */\n\n/* Shared trigger geometry 鈥?copied 1:1 from the base composer triggers\n * (PermissionSelect .trigger_2006230319 / ModelSelect .trigger_2006230319). Centralizing here\n * keeps the two segments visually fused so the divider reads as part of\n * one component, not two loose buttons. */\n.dock_2006230319 {\n display: inline-flex;\n align-items: stretch;\n height: 28px;\n border-radius: 6px;\n background: transparent;\n color: var(--dsw-alias-label-secondary, #81858c);\n font-size: 13px;\n line-height: 20px;\n font-weight: 500;\n min-height: 28px;\n overflow: hidden;\n}\n\n/* Vertical separator between the two segments. Uses the secondary label\n * color so it stays in the same tonal family as the surrounding trigger\n * outlines and chevrons. */\n.divider_2006230319 {\n width: 1px;\n margin: 6px 0;\n background: color-mix(in srgb, currentColor 22%, transparent);\n flex-shrink: 0;\n}\n\n.chip_2006230319 {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 100%;\n padding: 0 8px 0 8px;\n border: none;\n border-radius: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n font-weight: 500;\n cursor: pointer;\n}\n\n.chip_2006230319:hover {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* The leftmost segment rounds only its left corners so it tucks into the dock. */\n.chip_2006230319:first-child {\n border-top-left-radius: 6px;\n border-bottom-left-radius: 6px;\n}\n\n/* Started sessions drop the worktree segment: the lone chip rounds all\n * corners and reads as a plain button, not a broken-off half control. */\n.chip_2006230319:only-child {\n border-radius: 6px;\n}\n\n.branch_2006230319 {\n max-width: 16em;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.check_2006230319,\n.checkOn_2006230319 {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 100%;\n padding: 0 4px 0 8px;\n border: none;\n border-radius: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n font-weight: 500;\n cursor: pointer;\n}\n\n.check_2006230319:hover,\n.checkOn_2006230319:hover {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* The rightmost segment rounds only its right corners. */\n.check_2006230319:last-child,\n.checkOn_2006230319:last-child {\n border-top-right-radius: 6px;\n border-bottom-right-radius: 6px;\n}\n\n.box_2006230319 {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n border: 1px solid color-mix(in srgb, currentColor 45%, transparent);\n border-radius: 4px;\n}\n\n/* Selected worktree: only the checkbox itself turns bluish and fills 鈥?the\n * surrounding button stays transparent so the label keeps the same\n * secondary tone. Mirrors the Claude Code toggle treatment. The inner\n * check rides the bluish fill with an inverted foreground token so the\n * glyph stays legible. */\n.checkOn_2006230319 .box_2006230319 {\n border-color: var(--dsw-alias-label-primary-bluish, #4186f0);\n background: var(--dsw-alias-label-primary-bluish, #4186f0);\n color: var(--dsw-alias-label-primary-foreground, #ffffff);\n}\n\n.checkLabel_2006230319 {\n white-space: nowrap;\n}\n\n/* Confirm flyout: the second-level panel opening right of the branch\n * card (the base Menu's submenu posture: r12, inverted hairline,\n * shadow-lv3, --dsw-specific-menu). Width is content-driven — it follows\n * the longest line (for remote picks that is the subject line's branch\n * name) — floored at 168px (the Cancel/Confirm pair plus padding: short\n * branch names must not squeeze the buttons into wrapping \"切换中…\"\n * mid-word) and capped at 400px; BranchMenu also clamps it inline to the\n * room right of the card. Beyond the cap the lines wrap. border-box so\n * every width arm includes the card chrome. */\n.popCard_2006230319 {\n box-sizing: border-box;\n position: fixed;\n z-index: 1000;\n width: max-content;\n min-width: 168px;\n max-width: min(400px, 80vw);\n padding: 4px;\n border: 1px solid var(--dsw-alias-border-inverted);\n border-radius: 12px;\n background: var(--dsw-specific-menu, var(--dsw-alias-surface-raised, #ffffff));\n box-shadow: var(--dsw-shadow-lv3);\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.popAsk_2006230319 {\n margin: 0;\n padding: 6px 8px;\n font-size: 13px;\n line-height: 20px;\n color: inherit;\n /* Branch names are long unbroken tokens — plain wrapping would let them\n * overflow the capped card instead of breaking. */\n overflow-wrap: anywhere;\n}\n\n/* Remote confirm's name line: the branch itself, weight 500 like the leaf\n * rows — the subject the ask line refers to (\"该远程分支\"). A dedicated\n * line keeps the long unbroken token away from the sentence, so wraps\n * happen inside the name instead of shredding the Chinese around it. */\n.popSubject_2006230319 {\n margin: 0;\n padding: 0 8px 2px;\n font-size: 13px;\n line-height: 20px;\n font-weight: 500;\n color: inherit;\n overflow-wrap: anywhere;\n}\n\n.popActions_2006230319 {\n display: flex;\n gap: 2px;\n padding: 2px;\n}\n\n/* Menu-row-like buttons: transparent fill, hover tint, same 13px type.\n * nowrap keeps labels like 切换中… from splitting mid-word when the flyout\n * is pinned to its minimum width by a short branch name. */\n.popActions_2006230319 button {\n flex: 1 1 0;\n height: 28px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n white-space: nowrap;\n cursor: pointer;\n}\n\n.popActions_2006230319 button:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.popActions_2006230319 button:disabled {\n opacity: 0.5;\n cursor: default;\n}\n\n.popActions_2006230319 button:last-child {\n color: var(--dsw-alias-label-primary-bluish, #4186f0);\n font-weight: 500;\n}\n\n/* ── Branch picker popup (BranchMenu) ──────────────────────────────\n * Upward-opening card pinned above the chip, in the Menu's card chrome\n * (r12, inverted hairline, shadow-lv3, --dsw-specific-menu — same family\n * as .popCard_2006230319). Three owner requirements shape the geometry:\n *\n * 1. height cap: min(420px, 60vh) on the card, only the rows area\n * scrolls (.menuRows_2006230319) — heading and search stay pinned;\n * 2. the search field sits pinned at the card's bottom edge, directly\n * above the chip, with the scrolling rows above it;\n * 3. the card is CSS-`bottom`-pinned ~6px above the chip's top and so\n * grows entirely upward — it can never cover the composer or fill\n * the viewport, whatever the branch count.\n *\n * The inline `left`/`bottom` come from BranchMenu's placement pass; the\n * width is fixed here (design 360px — 320 tree + 40 tool strip — and\n * viewport-capped) so horizontal clamping stays deterministic without\n * measuring the card. */\n\n/* The portal lands directly under document.body_2006230319, outside the shell's\n * box-sizing reset — content-box default would add padding/border on top\n * of the declared width (360 became 370, and the width:100% children\n * padded 16px past the card's right clip, shearing off their rounded\n * corners). Every width-declared box in this popup opts back into\n * border-box: the card, the toolbar, the rows, and the search input. */\n.menuCard_2006230319 {\n box-sizing: border-box;\n position: fixed;\n z-index: 1000;\n display: flex;\n flex-direction: row;\n width: min(360px, calc(100vw - 24px));\n max-height: min(420px, 60vh);\n overflow: hidden;\n padding: 4px;\n border: 1px solid var(--dsw-alias-border-inverted);\n border-radius: 12px;\n background: var(--dsw-specific-menu, var(--dsw-alias-surface-raised, #ffffff));\n box-shadow: var(--dsw-shadow-lv3);\n}\n\n/* Left tool strip (IDEA branch-panel posture at popup scale): a narrow\n * column of icon-only buttons for actions that do not belong in the tree\n * — locate the checked-out branch, expand/collapse the whole tree.\n * Buttons stack from the BOTTOM up: the card's height shrinks when the\n * repo has few branches, so a top-anchored strip would drift around and\n * the buttons would sit far from the search bar; anchoring to the bottom\n * pins them at a stable spot (beside the search row) whatever the height. */\n.menuToolbar_2006230319 {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n gap: 2px;\n flex-shrink: 0;\n width: 32px;\n padding: 0 2px;\n margin-right: 4px;\n border-right: 1px solid color-mix(in srgb, currentColor 12%, transparent);\n}\n\n.menuToolButton_2006230319 {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n margin: 0 auto;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n cursor: pointer;\n}\n\n.menuToolButton_2006230319:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n.menuToolButton_2006230319:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n/* The sync tools while their action runs: a soft opacity pulse. The glyph\n * is a directional arrow, so the circular-refresh spin read as garbled\n * rotation — pulsing keeps the arrow legible while clearly \"live\", and the\n * button keeps full opacity (the usual disabled dim would read as broken\n * for an in-flight network operation). */\n.menuToolButtonRunning_2006230319 svg {\n animation: menuToolPulse 700ms ease-in-out infinite alternate;\n}\n\n.menuToolButtonRunning_2006230319:disabled {\n opacity: 1;\n cursor: progress;\n}\n\n@keyframes menuToolPulse {\n from { opacity: 1; }\n to { opacity: 0.25; }\n}\n\n/* The main column: heading + scrollable rows + pinned search. */\n.menuMain_2006230319 {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n min-width: 0;\n}\n\n/* Non-interactive group heading — the Menu label row's posture. */\n.menuHeading_2006230319 {\n padding: 6px 8px 4px;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary, #81858c);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n flex-shrink: 0;\n}\n\n/* The only scrollable region: shrinks within the capped card so the\n * heading above and the search below stay visible while rows scroll. */\n.menuRows_2006230319 {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n}\n\n/* Menu-row-like buttons: transparent fill, hover tint, same 13px type.\n * Weight 500 mirrors the chip's branch label (the portal escapes the\n * composer's font context, so the match must be explicit — the inherited\n * body weight is 400 and reads visibly lighter than the chip beside it). */\n.menuRow_2006230319 {\n box-sizing: border-box; /* width:100% + padding must stay inside .menuRows_2006230319 */\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n min-height: 28px;\n padding: 4px 8px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n font-weight: 500;\n line-height: 20px;\n text-align: left;\n cursor: pointer;\n}\n\n.menuRow_2006230319:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* Locked rows (a linked-worktree session answers every non-current pick\n * with the main-checkout toast): dimmed with a default cursor, but KEEP\n * the click path alive — no disabled attribute, the double-click is the\n * toast's stage. Hover stays quiet: nothing is on offer here. */\n.menuRowLocked_2006230319 {\n opacity: 0.45;\n cursor: default;\n}\n\n.menuRowLocked_2006230319:hover {\n background: transparent;\n}\n\n/* The checked-out branch: a persistent tint a step above the resting rows\n * so it reads as \"you are here\" the moment the list scrolls it into view\n * (BranchMenu centers it on open) — the trailing check alone is easy to\n * miss from a distance. */\n.menuRowSelected_2006230319,\n.menuRowSelected_2006230319:hover:not(:disabled) {\n background: color-mix(in srgb, currentColor 10%, transparent);\n}\n\n/* IDEA-style selection: the clicked row gets a bluish fill, layering over\n * the HEAD tint when the same row is both — selection communicates intent,\n * the HEAD tint communicates position, and they coexist (IDEA 4.4). */\n.menuRowPicked_2006230319,\n.menuRowPicked_2006230319:hover:not(:disabled) {\n background: color-mix(in srgb, var(--dsw-alias-label-primary-bluish, #4186f0) 18%, transparent);\n}\n\n.menuRowLabel_2006230319 {\n flex: 1 1 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* Upstream divergence arrows (↑N/↓N) trailing a local branch row, before\n * the HEAD check: the count badge tone at a smaller size so a busy list\n * still reads the name first. Plain text arrows — no base-set icon pairs\n * a direction with a count. tabular-nums keeps ↑10 from nudging neighbors\n * as the digits tick. */\n.menuRowArrow_2006230319 {\n flex-shrink: 0;\n font-size: 11px;\n line-height: 20px;\n font-weight: 400;\n font-variant-numeric: tabular-nums;\n color: color-mix(in srgb, currentColor 55%, transparent);\n}\n\n/* Search hit highlight (IDEA): the matched substring gets a warm tint\n * behind it — theme-agnostic, legible in both light and dark cards. */\n.menuSearchMark_2006230319 {\n background: color-mix(in srgb, #b58900 38%, transparent);\n border-radius: 2px;\n}\n\n/* Tree group rows (folder headers) — BranchMenu's '/' prefix tree: the\n * same row geometry as .menuRow_2006230319, but labeled in the secondary tone so the\n * leaf rows pop, with a count badge and a chevron that turns on expand. */\n.menuGroup_2006230319 {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: 6px;\n width: 100%;\n min-height: 28px;\n padding: 4px 8px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: var(--dsw-alias-label-secondary, #81858c);\n font: inherit;\n font-size: 13px;\n font-weight: 500;\n line-height: 20px;\n text-align: left;\n cursor: pointer;\n}\n\n.menuGroup_2006230319:hover {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* The two top-level section headers (local/remote branches) step ABOVE the\n * folder headers they contain: primary label tone like the leaf rows plus\n * a heavier weight, so the nav hierarchy reads group > row > folder — the\n * folder headers keep the secondary tone that alone would leave the\n * sections as the faintest (and most important) rows on the list. */\n.menuGroupTop_2006230319 {\n color: inherit;\n font-weight: 600;\n}\n\n.menuGroupLabel_2006230319 {\n flex: 1 1 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.menuGroupChevron_2006230319 {\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 12px;\n height: 12px;\n transition: transform 120ms ease;\n}\n\n.menuGroupChevronOpen_2006230319 {\n transform: rotate(90deg);\n}\n\n.menuGroupCount_2006230319 {\n flex-shrink: 0;\n font-size: 12px;\n line-height: 20px;\n font-weight: 400;\n color: color-mix(in srgb, currentColor 55%, transparent);\n}\n\n/* Zero-search-hit state: centered secondary line inside the rows area. */\n.menuEmpty_2006230319 {\n padding: 10px 8px;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary, #81858c);\n text-align: center;\n}\n\n/* Bottom-pinned search field, separated from the rows by a hairline.\n * Borderless so it reads as part of the card, focus shown as the\n * standard hover tint rather than an outline. */\n.menuSearchWrap_2006230319 {\n flex-shrink: 0;\n margin-top: 2px;\n padding-top: 4px;\n border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent);\n}\n\n.menuSearch_2006230319 {\n box-sizing: border-box; /* width:100% + padding must stay inside the wrap */\n width: 100%;\n height: 30px;\n padding: 0 8px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n /* Weight 500 mirrors the chip's branch label (see .menuRow_2006230319) — the portal\n * escapes the composer's font context and would inherit body's 400. */\n font-weight: 500;\n line-height: 20px;\n}\n\n.menuSearch_2006230319::placeholder {\n color: var(--dsw-alias-label-secondary, #81858c);\n}\n\n.menuSearch_2006230319:focus {\n outline: none;\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* ── New-branch create flyout (BranchMenu toolbar plus) ─────────────\n * Opens to the RIGHT of the card (the confirm flyout's posture) and holds\n * the whole flow in one panel: ask line, naming input, live hint, and the\n * Cancel/Create pair — typing the name and pressing Create fires the\n * create in one stroke, no second confirm step. */\n\n/* The toolbar plus in its active (flyout open) state: a bluish tint\n * layering the same way the picked row does, so the toggled state reads at\n * a glance. */\n.menuToolButtonOn_2006230319,\n.menuToolButtonOn_2006230319:hover:not(:disabled) {\n background: color-mix(in srgb, var(--dsw-alias-label-primary-bluish, #4186f0) 18%, transparent);\n color: var(--dsw-alias-label-primary-bluish, #4186f0);\n}\n\n/* The naming input inside the flyout: borderless, part of the card, focus\n * shown as the standard hover tint. Fixed width — the popCard is\n * max-content, so a percentage width would chase the input's own default\n * size instead of the design width. */\n.menuCreate_2006230319 {\n box-sizing: border-box;\n width: 248px;\n height: 30px;\n padding: 0 8px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n /* Weight 500 mirrors the chip's branch label (see .menuSearch_2006230319). */\n font-weight: 500;\n line-height: 20px;\n}\n\n.menuCreate_2006230319::placeholder {\n color: var(--dsw-alias-label-secondary, #81858c);\n}\n\n.menuCreate_2006230319:focus {\n outline: none;\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n.menuCreate_2006230319:disabled {\n opacity: 0.5;\n}\n\n/* The error line under the input — only rendered while the draft is\n * unacceptable with a non-empty reason; the input itself stays neutral,\n * the line carries the state. */\n.menuCreateHintBad_2006230319 {\n margin: 0;\n padding: 0 8px;\n font-size: 12px;\n line-height: 16px;\n color: var(--dsw-alias-label-error);\n}\n";
201
+ const tagId$3 = "@laoyuehanni/dsh-git-worktree/BranchChip.module.css";
202
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId$3 + "\"]") === null) {
132
203
  const tag = document.createElement("style");
133
204
  tag.dataset.plugin = "@laoyuehanni/dsh-git-worktree";
134
- tag.dataset.pluginCss = tagId$1;
135
- tag.textContent = css$1;
205
+ tag.dataset.pluginCss = tagId$3;
206
+ tag.textContent = css$3;
136
207
  document.head.appendChild(tag);
137
208
  }
138
209
  var BranchChip_module_default = {
@@ -149,27 +220,35 @@ window.__ModuleLoader__.load({
149
220
  "checkLabel": "checkLabel_2006230319",
150
221
  "popCard": "popCard_2006230319",
151
222
  "popAsk": "popAsk_2006230319",
223
+ "popSubject": "popSubject_2006230319",
152
224
  "popActions": "popActions_2006230319",
153
225
  "menuRows": "menuRows_2006230319",
154
226
  "body": "body_2006230319",
155
227
  "menuCard": "menuCard_2006230319",
156
228
  "menuToolbar": "menuToolbar_2006230319",
157
229
  "menuToolButton": "menuToolButton_2006230319",
230
+ "menuToolButtonRunning": "menuToolButtonRunning_2006230319",
158
231
  "menuMain": "menuMain_2006230319",
159
232
  "menuHeading": "menuHeading_2006230319",
160
233
  "menuRow": "menuRow_2006230319",
234
+ "menuRowLocked": "menuRowLocked_2006230319",
161
235
  "menuRowSelected": "menuRowSelected_2006230319",
162
236
  "menuRowPicked": "menuRowPicked_2006230319",
163
237
  "menuRowLabel": "menuRowLabel_2006230319",
238
+ "menuRowArrow": "menuRowArrow_2006230319",
164
239
  "menuSearchMark": "menuSearchMark_2006230319",
165
240
  "menuGroup": "menuGroup_2006230319",
241
+ "menuGroupTop": "menuGroupTop_2006230319",
166
242
  "menuGroupLabel": "menuGroupLabel_2006230319",
167
243
  "menuGroupChevron": "menuGroupChevron_2006230319",
168
244
  "menuGroupChevronOpen": "menuGroupChevronOpen_2006230319",
169
245
  "menuGroupCount": "menuGroupCount_2006230319",
170
246
  "menuEmpty": "menuEmpty_2006230319",
171
247
  "menuSearchWrap": "menuSearchWrap_2006230319",
172
- "menuSearch": "menuSearch_2006230319"
248
+ "menuSearch": "menuSearch_2006230319",
249
+ "menuToolButtonOn": "menuToolButtonOn_2006230319",
250
+ "menuCreate": "menuCreate_2006230319",
251
+ "menuCreateHintBad": "menuCreateHintBad_2006230319"
173
252
  };
174
253
  //#endregion
175
254
  //#region src/client/BranchMenu.tsx
@@ -192,15 +271,35 @@ window.__ModuleLoader__.load({
192
271
  * never cover the composer, whatever the branch count.
193
272
  *
194
273
  * Layout (IDEA branch-panel posture at popup scale): a narrow tool strip
195
- * on the left (locate-current + expand/collapse-all), then a main column
196
- * of heading / tree / search. Selection model borrowed from IDEA: a
197
- * single click SELECTS a row (blue); double-click or Enter then OPENS the
274
+ * on the left (locate-current + expand/collapse-all + new-branch), then a
275
+ * main column of heading / tree / search. The list renders in TWO
276
+ * top-level collapsible groups — local branches first, then remote
277
+ * branches (each a folder-header-style row with chevron + count): under a
278
+ * SINGLE remote the remote rows drop their `<remote>/` prefix (the header
279
+ * already says "remote"; a stripped display name can never collide with a
280
+ * local row because the host hides remote branches that have a local
281
+ * twin), with SEVERAL remotes the full names stay so `origin`/`upstream`
282
+ * become the folder layer beneath the header. Picking a remote row hands
283
+ * the owner the real `<remote>/name` (see pick) — the remote confirms are
284
+ * the owner's wording (tracking-twin switch / twin-in-worktree).
285
+ * Selection model borrowed from
286
+ * IDEA: a single click SELECTS a row (blue); double-click or Enter then OPENS the
198
287
  * right-side confirm flyout for that row — the switch itself always goes
199
288
  * through the confirmation step, never straight away. While the confirm
200
289
  * flyout is open, clicking another row re-anchors it (the old one-click
201
290
  * pick flow).
202
291
  *
203
- * The confirm step is a second-level flyout opening to the RIGHT of the
292
+ * The new-branch tool (the toolbar's plus) opens the create flyout to the
293
+ * RIGHT of the card (the confirm flyout's submenu posture): the flyout
294
+ * holds the naming input — validated as you type (git ref-name rules plus
295
+ * a duplicate check against the rows) with a live hint naming the issue
296
+ * or, while the draft is acceptable, the branch the cut starts from — and
297
+ * the Cancel/Create pair. Confirming fires the create in ONE stroke
298
+ * (create AND in-place switch; no second confirm step — typing the name
299
+ * into the flyout and pressing Create IS the intent). While the create
300
+ * runs the flyout freezes (busy disables input and buttons); a failure
301
+ * toasts and leaves the flyout open for a renamed retry.
302
+ * The confirm flyout is a second-level portal opening to the RIGHT of the
204
303
  * branch card (the base Menu's submenu posture): the chip sits in the
205
304
  * bottom composer, so the old below-the-chip bubble landed off-viewport.
206
305
  * The flyout is a separate portal (not clipped by the card's
@@ -208,20 +307,53 @@ window.__ModuleLoader__.load({
208
307
  * can never overlap the branch list — and vertically centered on the
209
308
  * picked row. Its width is content-driven, capped in CSS, wrapping.
210
309
  *
211
- * Close semantics: outside pointerdown (card, flyout, and chip excluded)
310
+ * Close semantics: outside pointerdown (card, flyouts, and chip excluded)
212
311
  * cancels the confirm and closes the menu; Escape unwinds tier by tier —
213
- * confirm, then search text, then selection, then the menu; Enter in the
214
- * search field commits the first enabled visible row.
312
+ * confirm, then the create flyout, then search text, then selection, then
313
+ * the menu; Enter in the search field commits the first enabled visible row.
215
314
  *
216
315
  * Long names and many branches: a clipped label shows the full name on
217
- * hover via the native title (gated to actually-clipped rows only). When
218
- * the list grows past TREE_MIN_ROWS it renders as a full-depth '/' prefix
219
- * tree instead: folder-header rows (chevron + count) toggle; under an
220
- * expanded folder, child rows show only their own segment (indentation
221
- * carries the hierarchy — no repeated path, no color distinction); linear
222
- * chains compress into one row; the checked-out branch's chain opens by
223
- * default (centering still lands it mid-viewport).
316
+ * hover via the native title (gated to actually-clipped rows only). The
317
+ * list ALWAYS renders as a full-depth '/' prefix tree: folder-header rows
318
+ * (chevron + count) toggle; under an expanded folder, child rows show only
319
+ * their own segment (indentation carries the hierarchy — no repeated path,
320
+ * no color distinction); linear chains compress into one row. TREE_MIN_ROWS
321
+ * only sets the DEFAULT opening depth: past it, just the checked-out
322
+ * branch's chain starts open (centering still lands it mid-viewport); at
323
+ * or under it, every folder starts open — few branches have nothing to hide.
324
+ */
325
+ /**
326
+ * The fetch/update glyph in IDEA's posture: a diagonal running from the
327
+ * top-right down to a bottom-left arrowhead. `dashed` marks the metadata
328
+ * move (fetch touches remote-tracking refs only, never working-tree
329
+ * content); the solid variant is the in-place branch update (fetch +
330
+ * fast-forward) — the pairing is IDEA's dashed/solid synchronize/update
331
+ * language. The base library has no such glyph, so both are drawn here,
332
+ * local to the menu; the sync spin animation targets `svg` descendants of
333
+ * the tool button and applies to them unchanged.
224
334
  */
335
+ function FetchGlyph({ size = 16, dashed = true }) {
336
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
337
+ width: size,
338
+ height: size,
339
+ viewBox: "0 0 16 16",
340
+ fill: "none",
341
+ "aria-hidden": "true",
342
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
343
+ d: "M13 3 L5.9 10.1",
344
+ stroke: "currentColor",
345
+ strokeWidth: "1.3",
346
+ strokeLinecap: "round",
347
+ strokeDasharray: dashed ? "2.4 1.6" : void 0
348
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
349
+ d: "M5 5.9 V11 H10.1",
350
+ stroke: "currentColor",
351
+ strokeWidth: "1.3",
352
+ strokeLinecap: "round",
353
+ strokeLinejoin: "round"
354
+ })]
355
+ });
356
+ }
225
357
  /** Viewport edge clearance, mirroring the base Menu portal margin. */
226
358
  const MARGIN = 12;
227
359
  /** Gap kept between the chip's top edge and the card's bottom edge. */
@@ -240,13 +372,58 @@ window.__ModuleLoader__.load({
240
372
  top: "0px",
241
373
  visibility: "hidden"
242
374
  };
243
- /** Below this many rows the picker stays a flat list: in small repos a
244
- * tree would hide real branches behind one-entry folders, buying nothing. */
375
+ /** Past this many rows the tree starts with ONLY the checked-out branch's
376
+ * chain open; at or under it every folder starts open (few branches have
377
+ * nothing to hide). The tree itself always renders — this threshold is
378
+ * about the default opening depth, never about flat vs tree. */
245
379
  const TREE_MIN_ROWS = 8;
380
+ /** Leaf rows indent one chevron slot PAST their tree depth. Folder headers
381
+ * lead with a collapsing chevron (12px icon + 6px gap) that leaf rows lack
382
+ * — without compensation a leaf's text starts LEFT of its own group header's
383
+ * text and same-level leaves read shallower than folders. The extra 18px
384
+ * aligns same-level leaf TEXT with folder TEXT (the VS Code file-tree
385
+ * posture: a chevron column marks foldable rows, a text column carries
386
+ * content), so leaf padding is 8 + 12×depth + 18. */
387
+ const LEAF_CHEVRON_SLOT = 18;
388
+ /** Every folder path that renders a header, walking the tree depth-first. */
389
+ function collectFolderPaths(nodes, out = []) {
390
+ for (const node of nodes) if (node.children.length > 0) {
391
+ out.push(node.path);
392
+ collectFolderPaths(node.children, out);
393
+ }
394
+ return out;
395
+ }
246
396
  const segCmp = (a, b) => a.localeCompare(b, void 0, {
247
397
  numeric: true,
248
398
  sensitivity: "base"
249
399
  });
400
+ /** Split rows into the three groups and derive the remote display names. */
401
+ function groupRows(rows) {
402
+ const localRows = [];
403
+ const remoteRows = [];
404
+ const worktreeRows = [];
405
+ for (const row of rows) if (row.kind === "remote") remoteRows.push(row);
406
+ else if (row.kind === "worktree") worktreeRows.push(row);
407
+ else localRows.push(row);
408
+ const first = remoteRows[0]?.name ?? "";
409
+ const slash = first.indexOf("/");
410
+ const soleRemote = slash > 0 && remoteRows.every((row) => row.name.startsWith(first.slice(0, slash + 1))) ? first.slice(0, slash) : void 0;
411
+ const display = (name) => soleRemote === void 0 ? name : name.slice(soleRemote.length + 1);
412
+ return {
413
+ localRows,
414
+ remoteDisplayRows: remoteRows.map((row) => ({
415
+ ...row,
416
+ name: display(row.name)
417
+ })),
418
+ worktreeRows,
419
+ remoteNameMap: new Map(remoteRows.map((row) => [display(row.name), row.name]))
420
+ };
421
+ }
422
+ /** Expanded-key space: folder paths carry their group prefix so a local
423
+ * folder can never share a toggle state with a same-named remote display
424
+ * folder (`feat/x` on both sides). Group OPEN flags stay booleans beside
425
+ * this set — they are not part of the path namespace at all. */
426
+ const groupKey = (group, path) => `${group}:${path}`;
250
427
  /** Build the prefix tree of the rows (see TreeNode). */
251
428
  function buildTree(rows) {
252
429
  const root = [];
@@ -256,11 +433,13 @@ window.__ModuleLoader__.load({
256
433
  let level = root;
257
434
  let path = "";
258
435
  for (let i = 0; i < segs.length; i += 1) {
259
- path = path === "" ? segs[i] : `${path}/${segs[i]}`;
260
- let node = find(level, segs[i]);
436
+ const seg = segs[i];
437
+ if (seg === void 0) break;
438
+ path = path === "" ? seg : `${path}/${seg}`;
439
+ let node = find(level, seg);
261
440
  if (node === void 0) {
262
441
  node = {
263
- segment: segs[i],
442
+ segment: seg,
264
443
  path,
265
444
  depth: i,
266
445
  leaf: null,
@@ -298,7 +477,9 @@ window.__ModuleLoader__.load({
298
477
  const set = /* @__PURE__ */ new Set();
299
478
  let path = "";
300
479
  for (let i = 0; i < segs.length - 1; i += 1) {
301
- path = path === "" ? segs[i] : `${path}/${segs[i]}`;
480
+ const seg = segs[i];
481
+ if (seg === void 0) break;
482
+ path = path === "" ? seg : `${path}/${seg}`;
302
483
  set.add(path);
303
484
  }
304
485
  return set;
@@ -322,7 +503,7 @@ window.__ModuleLoader__.load({
322
503
  * @param props - anchor, rows, confirm bundle, callbacks, and the class sheet.
323
504
  * @returns null while closed or unplaced; otherwise the portaled card (+flyout).
324
505
  */
325
- function BranchMenu({ open, anchorRef, rows, currentBranch, confirm, onSelect, onClose, t }) {
506
+ function BranchMenu({ open, anchorRef, rows, currentBranch, confirm, onSelect, canCreate, canAdopt, onCreate, busy, onFetch, fetchBusy, onUpdate, updateBusy, onClose, t }) {
326
507
  const cardRef = (0, react.useRef)(null);
327
508
  const inputRef = (0, react.useRef)(null);
328
509
  /**
@@ -332,10 +513,29 @@ window.__ModuleLoader__.load({
332
513
  * still unmounted — its focus() no-ops against a null ref. Focusing at
333
514
  * mount time is immune to that race by construction.
334
515
  */
335
- const holdSearchFocus = (el) => {
516
+ /**
517
+ * Search-field ref callback: focus the field the moment it mounts. The
518
+ * card mounts in two stages (open flips, then pos resolves a render
519
+ * later), so an [open]-keyed passive effect fires while the input is
520
+ * still unmounted — its focus() no-ops against a null ref. Focusing at
521
+ * mount time is immune to that race by construction. The callback MUST
522
+ * be referentially stable: a fresh closure per render makes React
523
+ * detach and re-attach it on every commit, and the re-attach runs
524
+ * focus() again — each re-render (a click selection, a status refresh,
525
+ * a sessions push) would yank focus back to the field, flickering its
526
+ * focus tint. Stable identity = attach happens only at mount.
527
+ */
528
+ const holdSearchFocus = (0, react.useCallback)((el) => {
336
529
  inputRef.current = el;
337
530
  if (el !== null) el.focus();
338
- };
531
+ }, []);
532
+ /** Same mount-time focus trick for the new-branch input: the form mounts
533
+ * when the toolbar plus flips `creating`, mid-card-lifecycle, so the ref
534
+ * callback is the only reliable focus point. Stable for the same reason
535
+ * as holdSearchFocus — typing would otherwise re-focus on every render. */
536
+ const holdCreateFocus = (0, react.useCallback)((el) => {
537
+ if (el !== null) el.focus();
538
+ }, []);
339
539
  const flyRef = (0, react.useRef)(null);
340
540
  const flyConfirmRef = (0, react.useRef)(null);
341
541
  /** The row whose pick is awaiting confirmation (anchoring element). */
@@ -347,17 +547,43 @@ window.__ModuleLoader__.load({
347
547
  const [pos, setPos] = (0, react.useState)(null);
348
548
  const [flyPos, setFlyPos] = (0, react.useState)(null);
349
549
  const [query, setQuery] = (0, react.useState)("");
350
- /** Expanded folder set, keyed by node path. Re-seeded on every open so
351
- * the current branch's chain is visible without re-expanding by hand. */
550
+ /** Expanded folder set, keyed by group-prefixed node path (see groupKey).
551
+ * Re-seeded on every open so the current branch's chain is visible
552
+ * without re-expanding by hand. */
352
553
  const [expanded, setExpanded] = (0, react.useState)(/* @__PURE__ */ new Set());
554
+ /** Top-level group open flags, beside the expanded set (which owns
555
+ * folder paths only — a group header is not a path node). Re-seeded on
556
+ * every open: past TREE_MIN_ROWS the remote group starts closed so the
557
+ * list leads with the local branches. The WORKTREE group starts open
558
+ * unconditionally — it is the blank session's quick-hop entry, always
559
+ * worth its few rows. */
560
+ const [localGroupOpen, setLocalGroupOpen] = (0, react.useState)(true);
561
+ const [remoteGroupOpen, setRemoteGroupOpen] = (0, react.useState)(true);
562
+ const [worktreeGroupOpen, setWorktreeGroupOpen] = (0, react.useState)(true);
353
563
  /** IDEA-style selection: clicked row (blue). Zero or one at a time. */
354
564
  const [selected, setSelected] = (0, react.useState)(null);
565
+ /** The create flyout: open flag plus the live draft. Opening the menu
566
+ * (or closing the flyout) resets both — see the open-reset effect. */
567
+ const [creating, setCreating] = (0, react.useState)(false);
568
+ const [draft, setDraft] = (0, react.useState)("");
569
+ /** The create flyout element and its placed position (see its place
570
+ * pass below; same measure-then-place posture as the confirm flyout). */
571
+ const createFlyRef = (0, react.useRef)(null);
572
+ const [createFlyPos, setCreateFlyPos] = (0, react.useState)(null);
355
573
  const confirmRef = (0, react.useRef)(confirm);
356
574
  confirmRef.current = confirm;
357
575
  const queryRef = (0, react.useRef)(query);
358
576
  queryRef.current = query;
359
577
  const selectedRef = (0, react.useRef)(selected);
360
578
  selectedRef.current = selected;
579
+ /** Fresh creating flag for the stale-safe document keydown listener. */
580
+ const creatingRef = (0, react.useRef)(creating);
581
+ creatingRef.current = creating;
582
+ /** Latest rows for the open-reset effect: the effect must NOT re-run when
583
+ * a mid-open refresh swaps the rows (that would reset folders the user
584
+ * has toggled), but the reset itself still needs the freshest list. */
585
+ const latestRows = (0, react.useRef)(rows);
586
+ latestRows.current = rows;
361
587
  /** Always-fresh pick for the stale-safe document keydown listener. */
362
588
  const pickRef = (0, react.useRef)(() => {});
363
589
  const confirmOpen = confirm !== null;
@@ -377,40 +603,50 @@ window.__ModuleLoader__.load({
377
603
  };
378
604
  /** Stage a pick: remember the row element (the flyout anchors beside
379
605
  * it), then hand the branch to the owner. All pick paths — search Enter,
380
- * keyboard Enter on a selected row — funnel through here. */
606
+ * keyboard Enter on a selected row — funnel through here. A remote row
607
+ * carries its DISPLAY name through selection and anchors; the owner
608
+ * always receives the real `<remote>/name` action name. */
381
609
  const pick = (el, name) => {
382
610
  if (el !== null) pendingRef.current = {
383
611
  name,
384
612
  el
385
613
  };
386
614
  setPendingName(name);
387
- onSelect(name);
615
+ onSelect(remoteNameMapRef.current.get(name) ?? name);
388
616
  };
389
617
  pickRef.current = pick;
390
- /** Prefix tree when the list is big enough to need one; null (flat list)
391
- * below TREE_MIN_ROWS. Built once per rows change. */
392
- const tree = (0, react.useMemo)(() => rows.length > TREE_MIN_ROWS ? buildTree(rows) : null, [rows]);
393
- /** Every folder path that renders a header — the expand/collapse-all
394
- * button's scope. */
395
- const folderPaths = (0, react.useMemo)(() => {
396
- const out = [];
397
- const walk = (nodes) => {
398
- for (const node of nodes) {
399
- if (node.children.length > 0) out.push(node.path);
400
- walk(node.children);
401
- }
402
- };
403
- if (tree !== null) walk(tree);
404
- return out;
405
- }, [tree]);
406
- const allExpanded = folderPaths.length > 0 && folderPaths.every((p) => expanded.has(p));
618
+ /** The two-group model of the rows (see groupRows) and each group's '/'
619
+ * prefix tree — always on; TREE_MIN_ROWS only sets the default opening
620
+ * depth (see the open-reset effect). */
621
+ const grouped = (0, react.useMemo)(() => groupRows(rows), [rows]);
622
+ const localTree = (0, react.useMemo)(() => buildTree(grouped.localRows), [grouped.localRows]);
623
+ const remoteTree = (0, react.useMemo)(() => buildTree(grouped.remoteDisplayRows), [grouped.remoteDisplayRows]);
624
+ /** Fresh display→action map for the stale-safe document keydown listener
625
+ * (its Enter path funnels through pick, which reads the ref). */
626
+ const remoteNameMapRef = (0, react.useRef)(grouped.remoteNameMap);
627
+ remoteNameMapRef.current = grouped.remoteNameMap;
628
+ /** Every folder key that renders a header — the expand/collapse-all
629
+ * button's scope (group-prefixed, see groupKey). */
630
+ const folderPaths = (0, react.useMemo)(() => [...collectFolderPaths(localTree).map((p) => groupKey("local", p)), ...collectFolderPaths(remoteTree).map((p) => groupKey("remote", p))], [localTree, remoteTree]);
631
+ /** Locked row names (dimmed, pick-answered-with-hint) — a Set for the
632
+ * click gate. MUST sit before the `!open` early return: a hook after it
633
+ * would change the hook count between a closed and an open menu
634
+ * (React #310, seen live as the whole dock unmounting on first open). */
635
+ const lockedRows = (0, react.useMemo)(() => new Set(rows.filter((r) => r.locked === true).map((r) => r.name)), [rows]);
636
+ const allExpanded = folderPaths.every((p) => expanded.has(p)) && localGroupOpen && remoteGroupOpen && (!canAdopt || worktreeGroupOpen);
407
637
  const toggleAll = () => {
408
- setExpanded(allExpanded ? /* @__PURE__ */ new Set() : new Set(folderPaths));
638
+ const next = !allExpanded;
639
+ setLocalGroupOpen(next);
640
+ setRemoteGroupOpen(next);
641
+ setWorktreeGroupOpen(next);
642
+ setExpanded(next ? new Set(folderPaths) : /* @__PURE__ */ new Set());
409
643
  };
410
644
  const locateCurrent = () => {
645
+ setLocalGroupOpen(true);
646
+ if (grouped.worktreeRows.some((row) => row.name === currentBranch)) setWorktreeGroupOpen(true);
411
647
  setExpanded((prev) => {
412
648
  const next = new Set(prev);
413
- for (const p of chainExpanded(currentBranch)) next.add(p);
649
+ for (const p of chainExpanded(currentBranch)) next.add(groupKey("local", p));
414
650
  return next;
415
651
  });
416
652
  requestAnimationFrame(() => {
@@ -421,7 +657,17 @@ window.__ModuleLoader__.load({
421
657
  if (!open) return;
422
658
  setQuery("");
423
659
  setSelected(null);
424
- setExpanded(chainExpanded(currentBranch));
660
+ setCreating(false);
661
+ setDraft("");
662
+ const currentRows = latestRows.current;
663
+ const current = groupRows(currentRows);
664
+ const localPaths = collectFolderPaths(buildTree(current.localRows)).map((p) => groupKey("local", p));
665
+ const remotePaths = collectFolderPaths(buildTree(current.remoteDisplayRows)).map((p) => groupKey("remote", p));
666
+ const many = currentRows.length > TREE_MIN_ROWS;
667
+ setLocalGroupOpen(true);
668
+ setRemoteGroupOpen(!many);
669
+ setWorktreeGroupOpen(true);
670
+ setExpanded(many ? new Set([...chainExpanded(currentBranch)].map((p) => groupKey("local", p))) : /* @__PURE__ */ new Set([...localPaths, ...remotePaths]));
425
671
  }, [open, currentBranch]);
426
672
  (0, react.useEffect)(() => {
427
673
  if (selected !== null && !rows.some((r) => r.name === selected)) setSelected(null);
@@ -523,6 +769,37 @@ window.__ModuleLoader__.load({
523
769
  window.removeEventListener("scroll", place, true);
524
770
  };
525
771
  }, [confirmOpen, pendingName]);
772
+ (0, react.useLayoutEffect)(() => {
773
+ if (!creating) {
774
+ setCreateFlyPos(null);
775
+ return;
776
+ }
777
+ const place = () => {
778
+ const fly = createFlyRef.current;
779
+ const card = cardRef.current;
780
+ if (fly === null || card === null) return;
781
+ const cr = card.getBoundingClientRect();
782
+ const vw = window.innerWidth;
783
+ const vh = window.innerHeight;
784
+ const left = cr.right + GAP;
785
+ const room = Math.min(FLY_MAX_WIDTH, Math.max(200, vw - MARGIN - left));
786
+ fly.style.maxWidth = `${room}px`;
787
+ const fw = fly.offsetWidth;
788
+ const fh = fly.offsetHeight;
789
+ const top = Math.min(Math.max(cr.top + cr.height / 2 - fh / 2, MARGIN), Math.max(MARGIN, vh - fh - MARGIN));
790
+ setCreateFlyPos({
791
+ left: Math.min(left, vw - MARGIN - fw),
792
+ top
793
+ });
794
+ };
795
+ place();
796
+ window.addEventListener("resize", place);
797
+ window.addEventListener("scroll", place, true);
798
+ return () => {
799
+ window.removeEventListener("resize", place);
800
+ window.removeEventListener("scroll", place, true);
801
+ };
802
+ }, [creating]);
526
803
  (0, react.useEffect)(() => {
527
804
  if (confirmOpen && pendingName !== null) {
528
805
  const raf = requestAnimationFrame(() => {
@@ -542,6 +819,7 @@ window.__ModuleLoader__.load({
542
819
  const onPointerDown = (event) => {
543
820
  if (cardRef.current?.contains(event.target) === true) return;
544
821
  if (flyRef.current?.contains(event.target) === true) return;
822
+ if (createFlyRef.current?.contains(event.target) === true) return;
545
823
  if (anchorRef.current?.contains(event.target) === true) return;
546
824
  confirmRef.current?.onCancel();
547
825
  onClose();
@@ -553,6 +831,11 @@ window.__ModuleLoader__.load({
553
831
  confirmRef.current.onCancel();
554
832
  return;
555
833
  }
834
+ if (creatingRef.current) {
835
+ setCreating(false);
836
+ setDraft("");
837
+ return;
838
+ }
556
839
  if (queryRef.current.trim() !== "") {
557
840
  setQuery("");
558
841
  return;
@@ -567,7 +850,8 @@ window.__ModuleLoader__.load({
567
850
  const card = cardRef.current;
568
851
  const active = document.activeElement;
569
852
  if (card === null || active === null || !card.contains(active)) return;
570
- if (active === card.querySelector("input")) return;
853
+ const inputs = card.querySelectorAll("input");
854
+ if (inputs.length > 0 && [...inputs].includes(active)) return;
571
855
  const leaves = [...card.querySelectorAll("button[role=\"menuitem\"][data-branch]")];
572
856
  if (key === "ArrowDown" || key === "ArrowUp") {
573
857
  event.preventDefault();
@@ -577,6 +861,7 @@ window.__ModuleLoader__.load({
577
861
  if (key === "ArrowDown") next = idx < 0 ? 0 : Math.min(leaves.length - 1, idx + 1);
578
862
  else next = idx <= 0 ? leaves.length - 1 : idx - 1;
579
863
  const target = leaves[next];
864
+ if (target === void 0) return;
580
865
  const name = target.dataset.branch ?? null;
581
866
  if (name !== null) setSelected(name);
582
867
  target.focus();
@@ -600,30 +885,88 @@ window.__ModuleLoader__.load({
600
885
  ]);
601
886
  if (!open || pos === null) return null;
602
887
  const needle = query.trim().toLowerCase();
603
- const visible = needle === "" ? rows : rows.filter((row) => row.name.toLowerCase().includes(needle));
604
- /** Enter in the search field: commit the first enabled visible row
605
- * (its rendered button is the anchor — found by its data-branch key; the
606
- * label text alone can't identify a row inside a tree). */
888
+ const visible = needle === "" ? rows : [
889
+ ...grouped.localRows,
890
+ ...grouped.worktreeRows,
891
+ ...grouped.remoteDisplayRows
892
+ ].filter((row) => row.name.toLowerCase().includes(needle));
893
+ /** Enter in the search field: commit the first visible row (its rendered
894
+ * button is the anchor — found by its data-branch key; the label text
895
+ * alone can't identify a row inside a tree). */
607
896
  const commitFirst = () => {
608
- const first = visible.find((row) => !row.disabled);
897
+ const first = visible[0];
609
898
  if (first === void 0) return;
610
899
  const card = cardRef.current;
611
900
  if (card === null) return;
612
901
  const el = card.querySelector(`button[data-branch="${CSS.escape(first.name)}"]`);
613
902
  pick(el, first.name);
614
903
  };
615
- /** Row class composition: base + HEAD tint + selection (selection wins). */
616
- const rowClass = (name) => {
617
- let cls = BranchChip_module_default.menuRow;
904
+ /** New-branch draft validation: git ref-name rules first, then a duplicate
905
+ * check against every EXISTING local branch — local rows and worktree
906
+ * rows alike (a worktree row IS a checked-out branch, just filed under
907
+ * its own group). A remote display name is not a claim on a new local
908
+ * branch's name (its twin could not even coexist with one; the host
909
+ * hides such remote rows). */
910
+ const createIssue = branchNameIssue(draft);
911
+ const existsLocally = (name) => grouped.localRows.some((row) => row.name === name) || grouped.worktreeRows.some((row) => row.name === name);
912
+ const createDuplicate = createIssue === null && existsLocally(draft);
913
+ const createValid = createIssue === null && !createDuplicate;
914
+ /** Error line under the input, ONLY while the draft is unacceptable with
915
+ * a non-empty reason (the ask line above already names the cut point, and
916
+ * an untouched input needs no error) — the Create button disables in
917
+ * lockstep. */
918
+ const createHint = createDuplicate ? t("menuNewBranchExists") : t("menuNewBranchBad");
919
+ const showCreateHint = createIssue !== null && createIssue !== "empty" || createDuplicate;
920
+ /** Fire the create in one stroke — the flyout's whole point. Invalid
921
+ * drafts and a running create are no-ops (the Create button disables in
922
+ * lockstep); the owner closes the menu on success, toasts on failure and
923
+ * leaves the flyout open for a renamed retry. */
924
+ const commitCreate = () => {
925
+ if (!createValid || busy) return;
926
+ onCreate(draft);
927
+ };
928
+ /** Row class composition: base + HEAD tint + selection (selection wins)
929
+ * + the locked dim. (`css` is an index-signature record, so noUncheckedIndexedAccess
930
+ * types every class as possibly absent — the base falls back to ''.) */
931
+ const rowClass = (row, name) => {
932
+ let cls = BranchChip_module_default.menuRow ?? "";
618
933
  if (name === currentBranch) cls += ` ${BranchChip_module_default.menuRowSelected}`;
619
934
  if (name === selected) cls += ` ${BranchChip_module_default.menuRowPicked}`;
935
+ if (row?.locked === true) cls += ` ${BranchChip_module_default.menuRowLocked}`;
620
936
  return cls;
621
937
  };
938
+ /** Locked rows keep the click path ALIVE (the owner answers picks with
939
+ * the main-checkout toast) but stay unselected — a dimmed row wearing
940
+ * the blue selection would read as "chosen yet unusable". */
941
+ const isLocked = (name) => lockedRows.has(name);
942
+ /** The upstream divergence arrows of a local row (IDEA's ↑N/↓N) ahead of
943
+ * the trailing check: plain text marks in the secondary tone — no base
944
+ * icon pairs a direction with a count. Absent without an upstream or
945
+ * when in sync. */
946
+ const renderArrows = (row) => {
947
+ if (row === null) return null;
948
+ const marks = [];
949
+ if ((row.ahead ?? 0) > 0) marks.push(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
950
+ className: BranchChip_module_default.menuRowArrow,
951
+ title: t("aheadTitle", { n: row.ahead }),
952
+ children: ["↑", row.ahead]
953
+ }, "ahead"));
954
+ if ((row.behind ?? 0) > 0) marks.push(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
955
+ className: BranchChip_module_default.menuRowArrow,
956
+ title: t("behindTitle", { n: row.behind }),
957
+ children: ["↓", row.behind]
958
+ }, "behind"));
959
+ return marks;
960
+ };
622
961
  /** A row's click behavior: with the confirm flyout open, clicking a row
623
962
  * re-picks it (the old one-click flow — the flyout re-anchors); without
624
963
  * one it just selects (IDEA model — double-click or Enter opens the
625
- * confirm flyout for the selected row). */
964
+ * confirm flyout for the selected row). Locked rows do neither: dimmed
965
+ * rows are not selectable, the double-click is the hint's stage. `el` is
966
+ * nullable like {@link pick}'s anchor: a row whose button is already
967
+ * unmounted still selects/picks, it just re-anchors nothing. */
626
968
  const rowClick = (el, name) => {
969
+ if (isLocked(name)) return;
627
970
  if (confirmOpen) pick(el, name);
628
971
  else setSelected(name);
629
972
  };
@@ -658,12 +1001,75 @@ window.__ModuleLoader__.load({
658
1001
  }
659
1002
  return false;
660
1003
  };
661
- /** One tree group-header row: its own segment (a compressed chain's
1004
+ /** One top-level group header (local/remote branches): the folder-header
1005
+ * posture with its own open flag — toggling flips the flag, never a key
1006
+ * in the expanded path set. `menuGroupTop` lifts the tone above the
1007
+ * folder headers (see the CSS note). In the search view (onToggle
1008
+ * absent) it renders inert: the matched subtrees below are force-open
1009
+ * anyway. */
1010
+ const renderGroupHeader = (label, count, open, onToggle) => {
1011
+ const cls = `${BranchChip_module_default.menuGroup} ${BranchChip_module_default.menuGroupTop}`;
1012
+ return onToggle === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1013
+ className: cls,
1014
+ role: "presentation",
1015
+ style: { paddingLeft: 8 },
1016
+ children: [
1017
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutline14, {
1018
+ size: 12,
1019
+ className: BranchChip_module_default.menuGroupChevron
1020
+ }),
1021
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1022
+ className: BranchChip_module_default.menuGroupLabel,
1023
+ children: label
1024
+ }),
1025
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1026
+ className: BranchChip_module_default.menuGroupCount,
1027
+ children: [
1028
+ "(",
1029
+ count,
1030
+ ")"
1031
+ ]
1032
+ })
1033
+ ]
1034
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1035
+ type: "button",
1036
+ className: cls,
1037
+ "aria-expanded": open,
1038
+ onClick: () => {
1039
+ if (guardActive()) return;
1040
+ onToggle();
1041
+ armShiftGuard();
1042
+ },
1043
+ children: [
1044
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutline14, {
1045
+ size: 12,
1046
+ className: open ? `${BranchChip_module_default.menuGroupChevron} ${BranchChip_module_default.menuGroupChevronOpen}` : BranchChip_module_default.menuGroupChevron
1047
+ }),
1048
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1049
+ className: BranchChip_module_default.menuGroupLabel,
1050
+ children: label
1051
+ }),
1052
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1053
+ className: BranchChip_module_default.menuGroupCount,
1054
+ children: [
1055
+ "(",
1056
+ count,
1057
+ ")"
1058
+ ]
1059
+ })
1060
+ ]
1061
+ });
1062
+ };
1063
+ /**
1064
+ * One tree group-header row: its own segment (a compressed chain's
662
1065
  * walked segments join the label), a count badge, and a chevron that
663
1066
  * turns for expansion. Clicking toggles. One color throughout — the
664
- * folder path is not color-distinguished from the name. */
665
- const renderHeader = (node, label, depth) => {
666
- const isOpen = expanded.has(node.path);
1067
+ * folder path is not color-distinguished from the name. `prefix` scopes
1068
+ * the expanded-key space to the owning group (see groupKey) and keeps
1069
+ * React keys unique across the two trees.
1070
+ */
1071
+ const renderHeader = (node, label, depth, prefix) => {
1072
+ const isOpen = expanded.has(`${prefix}${node.path}`);
667
1073
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
668
1074
  type: "button",
669
1075
  className: BranchChip_module_default.menuGroup,
@@ -672,7 +1078,7 @@ window.__ModuleLoader__.load({
672
1078
  "aria-expanded": isOpen,
673
1079
  onClick: () => {
674
1080
  if (guardActive()) return;
675
- toggle(node.path);
1081
+ toggle(`${prefix}${node.path}`);
676
1082
  armShiftGuard();
677
1083
  },
678
1084
  children: [
@@ -693,19 +1099,24 @@ window.__ModuleLoader__.load({
693
1099
  ]
694
1100
  })
695
1101
  ]
696
- }, `group:${node.path}`);
1102
+ }, `${prefix}group:${node.path}`);
697
1103
  };
698
1104
  /** One tree leaf row: under an expanded folder it shows only its own
699
1105
  * segment (indentation carries the hierarchy — no repeated full path);
700
1106
  * a compressed linear chain keeps its walked segments in the label so
701
- * the context survives without a pointless one-entry folder. */
702
- const renderLeaf = (node, label, depth) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1107
+ * the context survives without a pointless one-entry folder. The
1108
+ * data-branch key stays the group-local DISPLAY name — unique across
1109
+ * all groups (a remote display name can never equal a local row; a
1110
+ * worktree row's branch has left the local group) — which is what the
1111
+ * buttonOf/commitFirst/center lookups rely on. */
1112
+ const renderLeaf = (node, label, depth, prefix) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
703
1113
  type: "button",
704
1114
  role: "menuitem",
705
1115
  "data-branch": node.path,
706
- className: rowClass(node.path),
707
- disabled: node.leaf?.disabled ?? false,
708
- style: { paddingLeft: 8 + depth * 12 },
1116
+ "data-kind": node.leaf?.kind,
1117
+ className: rowClass(node.leaf ?? null, node.path),
1118
+ title: node.leaf?.locked === true ? t("mainRepoOnly") : void 0,
1119
+ style: { paddingLeft: 8 + depth * 12 + LEAF_CHEVRON_SLOT },
709
1120
  onClick: () => {
710
1121
  if (guardActive()) return;
711
1122
  rowClick(buttonOf(node.path), node.path);
@@ -720,35 +1131,76 @@ window.__ModuleLoader__.load({
720
1131
  onMouseLeave: (event) => {
721
1132
  clearTooltip(event.currentTarget);
722
1133
  },
1134
+ children: [
1135
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1136
+ className: BranchChip_module_default.menuRowLabel,
1137
+ children: label
1138
+ }),
1139
+ renderArrows(node.leaf),
1140
+ node.path === currentBranch && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutline16, { size: 14 })
1141
+ ]
1142
+ }, `${prefix}${node.path}`);
1143
+ /** One flat worktree row: a direct hop target, one per linked worktree
1144
+ * — no tree (worktree names rarely fork, and the group is a launcher,
1145
+ * not a taxonomy), no confirm (the double-click IS the hop; the owner
1146
+ * picks it up through onSelect). The native title carries the worktree
1147
+ * DIRECTORY — the fact a branch row cannot show. The row the session
1148
+ * currently lives in keeps the trailing check + HEAD tint: it is the
1149
+ * "you are here" mark the local group no longer holds (its branch was
1150
+ * filed into THIS group). */
1151
+ const renderFlatLeaf = (row, prefix) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1152
+ type: "button",
1153
+ role: "menuitem",
1154
+ "data-branch": row.name,
1155
+ "data-kind": row.kind,
1156
+ className: rowClass(row, row.name),
1157
+ title: row.locked === true ? t("mainRepoOnly") : row.path,
1158
+ style: { paddingLeft: 38 },
1159
+ onClick: () => {
1160
+ if (guardActive()) return;
1161
+ rowClick(buttonOf(row.name), row.name);
1162
+ },
1163
+ onDoubleClick: (event) => {
1164
+ if (guardActive()) return;
1165
+ pick(event.currentTarget, row.name);
1166
+ },
1167
+ onMouseEnter: (event) => {
1168
+ gateTooltip(event.currentTarget, row.name);
1169
+ },
1170
+ onMouseLeave: (event) => {
1171
+ clearTooltip(event.currentTarget);
1172
+ },
723
1173
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
724
1174
  className: BranchChip_module_default.menuRowLabel,
725
- children: label
726
- }), node.path === currentBranch && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutline16, { size: 14 })]
727
- }, node.path);
1175
+ children: row.name
1176
+ }), row.name === currentBranch && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutline16, { size: 14 })]
1177
+ }, `${prefix}${row.name}`);
728
1178
  /** Recursive tree renderer. Linear chains — nodes that are neither a
729
1179
  * branch nor a real fork — compress into the next row's label, so
730
1180
  * `feature/优化` stays a single flat row instead of a pointless one-entry
731
1181
  * folder, while a real fork (`a/deep/tree` holding leaf1+leaf2) gets a
732
1182
  * header whose children show only their own segments. */
733
- const renderTree = (nodes, depth) => {
1183
+ const renderTree = (nodes, depth, prefix) => {
734
1184
  const out = [];
735
1185
  for (const node of nodes) {
736
1186
  let cur = node;
737
1187
  const parts = [];
738
1188
  while (cur.leaf === null && cur.children.length === 1) {
1189
+ const next = cur.children[0];
1190
+ if (next === void 0) break;
739
1191
  parts.push(cur.segment);
740
- cur = cur.children[0];
1192
+ cur = next;
741
1193
  }
742
1194
  const label = parts.length === 0 ? cur.segment : `${parts.join("/")}/${cur.segment}`;
743
1195
  if (cur.leaf !== null) {
744
- out.push(renderLeaf(cur, label, depth));
1196
+ out.push(renderLeaf(cur, label, depth, prefix));
745
1197
  if (cur.children.length > 0) {
746
- out.push(renderHeader(cur, label, depth));
747
- if (expanded.has(cur.path)) out.push(...renderTree(cur.children, depth + 1));
1198
+ out.push(renderHeader(cur, label, depth, prefix));
1199
+ if (expanded.has(`${prefix}${cur.path}`)) out.push(...renderTree(cur.children, depth + 1, prefix));
748
1200
  }
749
1201
  } else {
750
- out.push(renderHeader(cur, label, depth));
751
- if (expanded.has(cur.path)) out.push(...renderTree(cur.children, depth + 1));
1202
+ out.push(renderHeader(cur, label, depth, prefix));
1203
+ if (expanded.has(`${prefix}${cur.path}`)) out.push(...renderTree(cur.children, depth + 1, prefix));
752
1204
  }
753
1205
  }
754
1206
  return out;
@@ -757,7 +1209,11 @@ window.__ModuleLoader__.load({
757
1209
  * filter keeps the path), hide non-matching siblings, force every kept
758
1210
  * folder open, and highlight the hit substring. No chain compression —
759
1211
  * the full ancestor path is exactly the context the search is for. */
760
- const renderSearch = (nodes, depth) => {
1212
+ /** Needle-matching leaf count of a tree: the search-view group header
1213
+ * must count the MATCHES under it, not the whole group — a full count
1214
+ * above two filtered rows reads as a lie. */
1215
+ const searchLeafCount = (nodes) => nodes.reduce((sum, node) => sum + (node.leaf !== null && node.leaf.name.toLowerCase().includes(needle) ? 1 : 0) + searchLeafCount(node.children), 0);
1216
+ const renderSearch = (nodes, depth, prefix) => {
761
1217
  const out = [];
762
1218
  for (const node of nodes) {
763
1219
  const leafHit = node.leaf !== null && node.leaf.name.toLowerCase().includes(needle);
@@ -766,9 +1222,10 @@ window.__ModuleLoader__.load({
766
1222
  type: "button",
767
1223
  role: "menuitem",
768
1224
  "data-branch": node.path,
769
- className: rowClass(node.path),
770
- disabled: node.leaf?.disabled ?? false,
771
- style: { paddingLeft: 8 + depth * 12 },
1225
+ "data-kind": node.leaf?.kind,
1226
+ className: rowClass(node.leaf ?? null, node.path),
1227
+ title: node.leaf?.locked === true ? t("mainRepoOnly") : void 0,
1228
+ style: { paddingLeft: 8 + depth * 12 + LEAF_CHEVRON_SLOT },
772
1229
  onClick: () => {
773
1230
  if (guardActive()) return;
774
1231
  rowClick(buttonOf(node.path), node.path);
@@ -783,11 +1240,15 @@ window.__ModuleLoader__.load({
783
1240
  onMouseLeave: (event) => {
784
1241
  clearTooltip(event.currentTarget);
785
1242
  },
786
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
787
- className: BranchChip_module_default.menuRowLabel,
788
- children: renderLabel(node.segment)
789
- }), node.path === currentBranch && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutline16, { size: 14 })]
790
- }, node.path));
1243
+ children: [
1244
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1245
+ className: BranchChip_module_default.menuRowLabel,
1246
+ children: renderLabel(node.segment)
1247
+ }),
1248
+ renderArrows(node.leaf),
1249
+ node.path === currentBranch && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutline16, { size: 14 })
1250
+ ]
1251
+ }, `${prefix}${node.path}`));
791
1252
  if (childHit) {
792
1253
  out.push(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
793
1254
  role: "presentation",
@@ -812,8 +1273,8 @@ window.__ModuleLoader__.load({
812
1273
  ]
813
1274
  })
814
1275
  ]
815
- }, `search:${node.path}`));
816
- out.push(...renderSearch(node.children, depth + 1));
1276
+ }, `${prefix}search:${node.path}`));
1277
+ out.push(...renderSearch(node.children, depth + 1, prefix));
817
1278
  }
818
1279
  }
819
1280
  return out;
@@ -821,140 +1282,233 @@ window.__ModuleLoader__.load({
821
1282
  /** The rendered button for a branch name (flyout anchor on click-select
822
1283
  * paths, where the handler only has the name at hand). */
823
1284
  const buttonOf = (name) => cardRef.current?.querySelector(`button[data-branch="${CSS.escape(name)}"]`) ?? null;
824
- /** One flat row (small repos, and search results there). */
825
- const renderRow = (row, highlight) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
826
- type: "button",
827
- role: "menuitem",
828
- "data-branch": row.name,
829
- className: rowClass(row.name),
830
- disabled: row.disabled,
831
- onClick: () => {
832
- if (guardActive()) return;
833
- rowClick(buttonOf(row.name), row.name);
834
- },
835
- onDoubleClick: (event) => {
836
- if (guardActive()) return;
837
- pick(event.currentTarget, row.name);
838
- },
839
- onMouseEnter: (event) => {
840
- gateTooltip(event.currentTarget, row.name);
841
- },
842
- onMouseLeave: (event) => {
843
- clearTooltip(event.currentTarget);
844
- },
845
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
846
- className: BranchChip_module_default.menuRowLabel,
847
- children: highlight ? renderLabel(row.name) : row.name
848
- }), row.name === currentBranch && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutline16, { size: 14 })]
849
- }, row.name);
850
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
851
- ref: cardRef,
852
- className: BranchChip_module_default.menuCard,
853
- style: {
854
- left: pos.left,
855
- bottom: pos.bottom
856
- },
857
- role: "menu",
858
- "aria-label": t("menuLocalBranches"),
859
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
860
- className: BranchChip_module_default.menuToolbar,
861
- role: "toolbar",
862
- "aria-label": t("menuLocalBranches"),
863
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
864
- type: "button",
865
- className: BranchChip_module_default.menuToolButton,
866
- title: t("menuLocate"),
867
- "aria-label": t("menuLocate"),
868
- onClick: locateCurrent,
869
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconGoalOutline16, { size: 16 })
870
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
871
- type: "button",
872
- className: BranchChip_module_default.menuToolButton,
873
- title: allExpanded ? t("menuCollapseAll") : t("menuExpandAll"),
874
- "aria-label": allExpanded ? t("menuCollapseAll") : t("menuExpandAll"),
875
- disabled: tree === null || folderPaths.length === 0,
876
- onClick: toggleAll,
877
- children: allExpanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronUpOutline14, { size: 14 }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutline14, { size: 14 })
1285
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1286
+ (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1287
+ ref: cardRef,
1288
+ className: BranchChip_module_default.menuCard,
1289
+ style: {
1290
+ left: pos.left,
1291
+ bottom: pos.bottom
1292
+ },
1293
+ role: "menu",
1294
+ "aria-label": t("menuBranches"),
1295
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1296
+ className: BranchChip_module_default.menuToolbar,
1297
+ role: "toolbar",
1298
+ "aria-label": t("menuBranches"),
1299
+ children: [
1300
+ canCreate && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1301
+ type: "button",
1302
+ className: creating ? `${BranchChip_module_default.menuToolButton} ${BranchChip_module_default.menuToolButtonOn}` : BranchChip_module_default.menuToolButton,
1303
+ title: t("menuNewBranch"),
1304
+ "aria-label": t("menuNewBranch"),
1305
+ "aria-pressed": creating,
1306
+ onClick: () => {
1307
+ confirmRef.current?.onCancel();
1308
+ const next = !creating;
1309
+ setCreating(next);
1310
+ if (!next) setDraft("");
1311
+ },
1312
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlusOutline16, { size: 16 })
1313
+ }),
1314
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1315
+ type: "button",
1316
+ className: BranchChip_module_default.menuToolButton,
1317
+ title: t("menuLocate"),
1318
+ "aria-label": t("menuLocate"),
1319
+ onClick: locateCurrent,
1320
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconGoalOutline16, { size: 16 })
1321
+ }),
1322
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1323
+ type: "button",
1324
+ className: updateBusy ? `${BranchChip_module_default.menuToolButton} ${BranchChip_module_default.menuToolButtonRunning}` : BranchChip_module_default.menuToolButton,
1325
+ title: t("menuUpdate"),
1326
+ "aria-label": t("menuUpdate"),
1327
+ disabled: busy || fetchBusy,
1328
+ onClick: () => {
1329
+ confirmRef.current?.onCancel();
1330
+ onUpdate();
1331
+ },
1332
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FetchGlyph, { dashed: false })
1333
+ }),
1334
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1335
+ type: "button",
1336
+ className: fetchBusy ? `${BranchChip_module_default.menuToolButton} ${BranchChip_module_default.menuToolButtonRunning}` : BranchChip_module_default.menuToolButton,
1337
+ title: t("menuFetch"),
1338
+ "aria-label": t("menuFetch"),
1339
+ disabled: busy || updateBusy,
1340
+ onClick: () => {
1341
+ confirmRef.current?.onCancel();
1342
+ onFetch();
1343
+ },
1344
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FetchGlyph, {})
1345
+ }),
1346
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1347
+ type: "button",
1348
+ className: BranchChip_module_default.menuToolButton,
1349
+ title: allExpanded ? t("menuCollapseAll") : t("menuExpandAll"),
1350
+ "aria-label": allExpanded ? t("menuCollapseAll") : t("menuExpandAll"),
1351
+ disabled: rows.length === 0,
1352
+ onClick: toggleAll,
1353
+ children: allExpanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronUpOutline14, { size: 14 }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutline14, { size: 14 })
1354
+ })
1355
+ ]
1356
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1357
+ className: BranchChip_module_default.menuMain,
1358
+ children: [
1359
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1360
+ className: BranchChip_module_default.menuHeading,
1361
+ children: t("menuBranches")
1362
+ }),
1363
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1364
+ className: BranchChip_module_default.menuRows,
1365
+ role: "presentation",
1366
+ ref: holdRowsCenter,
1367
+ children: [needle === "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1368
+ grouped.localRows.length > 0 && renderGroupHeader(t("menuLocalBranches"), grouped.localRows.length, localGroupOpen, () => setLocalGroupOpen((value) => !value)),
1369
+ localGroupOpen && renderTree(localTree, 1, "local:"),
1370
+ canAdopt && grouped.worktreeRows.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderGroupHeader(t("menuWorktrees"), grouped.worktreeRows.length, worktreeGroupOpen, () => setWorktreeGroupOpen((value) => !value)), worktreeGroupOpen && grouped.worktreeRows.map((row) => renderFlatLeaf(row, "worktree:"))] }),
1371
+ grouped.remoteDisplayRows.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderGroupHeader(t("menuRemoteBranches"), grouped.remoteDisplayRows.length, remoteGroupOpen, () => setRemoteGroupOpen((value) => !value)), remoteGroupOpen && renderTree(remoteTree, 1, "remote:")] })
1372
+ ] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1373
+ grouped.localRows.some((row) => row.name.toLowerCase().includes(needle)) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderGroupHeader(t("menuLocalBranches"), searchLeafCount(localTree), true), renderSearch(localTree, 1, "local:")] }),
1374
+ canAdopt && grouped.worktreeRows.some((row) => row.name.toLowerCase().includes(needle)) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderGroupHeader(t("menuWorktrees"), grouped.worktreeRows.filter((row) => row.name.toLowerCase().includes(needle)).length, true), grouped.worktreeRows.filter((row) => row.name.toLowerCase().includes(needle)).map((row) => renderFlatLeaf(row, "worktree:"))] }),
1375
+ grouped.remoteDisplayRows.some((row) => row.name.toLowerCase().includes(needle)) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderGroupHeader(t("menuRemoteBranches"), searchLeafCount(remoteTree), true), renderSearch(remoteTree, 1, "remote:")] })
1376
+ ] }), visible.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1377
+ className: BranchChip_module_default.menuEmpty,
1378
+ children: rows.length === 0 ? t("menuNoBranches") : t("menuNoMatches")
1379
+ })]
1380
+ }),
1381
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1382
+ className: BranchChip_module_default.menuSearchWrap,
1383
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1384
+ ref: holdSearchFocus,
1385
+ className: BranchChip_module_default.menuSearch,
1386
+ type: "text",
1387
+ value: query,
1388
+ placeholder: t("menuSearchPlaceholder"),
1389
+ "aria-label": t("menuSearchPlaceholder"),
1390
+ spellCheck: false,
1391
+ onChange: (event) => {
1392
+ setQuery(event.target.value);
1393
+ },
1394
+ onKeyDown: (event) => {
1395
+ if (event.key === "Enter") {
1396
+ event.preventDefault();
1397
+ commitFirst();
1398
+ }
1399
+ }
1400
+ })
1401
+ })
1402
+ ]
878
1403
  })]
879
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
880
- className: BranchChip_module_default.menuMain,
1404
+ }), document.body),
1405
+ confirm !== null && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1406
+ ref: flyRef,
1407
+ className: BranchChip_module_default.popCard,
1408
+ style: flyPos ?? FLY_MEASURE,
1409
+ role: "dialog",
1410
+ "aria-label": confirm.ask,
881
1411
  children: [
882
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
883
- className: BranchChip_module_default.menuHeading,
884
- children: t("menuLocalBranches")
1412
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1413
+ className: BranchChip_module_default.popAsk,
1414
+ children: confirm.ask
1415
+ }),
1416
+ confirm.subject !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1417
+ className: BranchChip_module_default.popSubject,
1418
+ children: confirm.subject
885
1419
  }),
886
1420
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
887
- className: BranchChip_module_default.menuRows,
888
- role: "presentation",
889
- ref: holdRowsCenter,
890
- children: [tree === null ? (needle === "" ? rows : visible).map((row) => renderRow(row, needle !== "")) : needle === "" ? renderTree(tree, 0) : renderSearch(tree, 0), visible.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
891
- className: BranchChip_module_default.menuEmpty,
892
- children: t("menuNoMatches")
1421
+ className: BranchChip_module_default.popActions,
1422
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1423
+ type: "button",
1424
+ disabled: confirm.busy,
1425
+ onClick: confirm.onCancel,
1426
+ children: confirm.cancelLabel
1427
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1428
+ ref: flyConfirmRef,
1429
+ type: "button",
1430
+ disabled: confirm.busy,
1431
+ onClick: confirm.onConfirm,
1432
+ children: confirm.confirmLabel
893
1433
  })]
1434
+ })
1435
+ ]
1436
+ }), document.body),
1437
+ creating && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1438
+ ref: createFlyRef,
1439
+ className: BranchChip_module_default.popCard,
1440
+ style: createFlyPos ?? FLY_MEASURE,
1441
+ role: "dialog",
1442
+ "aria-label": t("createBranchTitle", { branch: currentBranch }),
1443
+ children: [
1444
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1445
+ className: BranchChip_module_default.popAsk,
1446
+ children: t("createBranchTitle", { branch: currentBranch })
894
1447
  }),
895
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
896
- className: BranchChip_module_default.menuSearchWrap,
897
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
898
- ref: holdSearchFocus,
899
- className: BranchChip_module_default.menuSearch,
900
- type: "text",
901
- value: query,
902
- placeholder: t("menuSearchPlaceholder"),
903
- "aria-label": t("menuSearchPlaceholder"),
904
- spellCheck: false,
905
- onChange: (event) => {
906
- setQuery(event.target.value);
907
- },
908
- onKeyDown: (event) => {
909
- if (event.key === "Enter") {
910
- event.preventDefault();
911
- commitFirst();
912
- }
1448
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1449
+ ref: holdCreateFocus,
1450
+ className: BranchChip_module_default.menuCreate,
1451
+ type: "text",
1452
+ value: draft,
1453
+ placeholder: t("menuNewBranchPlaceholder"),
1454
+ "aria-label": t("menuNewBranchPlaceholder"),
1455
+ "aria-invalid": createIssue !== null && createIssue !== "empty",
1456
+ spellCheck: false,
1457
+ disabled: busy,
1458
+ onChange: (event) => {
1459
+ setDraft(event.target.value);
1460
+ },
1461
+ onKeyDown: (event) => {
1462
+ if (event.key === "Enter") {
1463
+ event.preventDefault();
1464
+ commitCreate();
913
1465
  }
914
- })
1466
+ }
1467
+ }),
1468
+ showCreateHint && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1469
+ className: BranchChip_module_default.menuCreateHintBad,
1470
+ role: "status",
1471
+ children: createHint
1472
+ }),
1473
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1474
+ className: BranchChip_module_default.popActions,
1475
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1476
+ type: "button",
1477
+ disabled: busy,
1478
+ onClick: () => {
1479
+ setCreating(false);
1480
+ setDraft("");
1481
+ },
1482
+ children: t("actionCancel")
1483
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1484
+ type: "button",
1485
+ disabled: !createValid || busy,
1486
+ onClick: commitCreate,
1487
+ children: busy ? t("createBranchBusy") : t("actionConfirm")
1488
+ })]
915
1489
  })
916
1490
  ]
917
- })]
918
- }), document.body), confirm !== null && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
919
- ref: flyRef,
920
- className: BranchChip_module_default.popCard,
921
- style: flyPos ?? FLY_MEASURE,
922
- role: "dialog",
923
- "aria-label": confirm.ask,
924
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
925
- className: BranchChip_module_default.popAsk,
926
- children: confirm.ask
927
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
928
- className: BranchChip_module_default.popActions,
929
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
930
- type: "button",
931
- disabled: confirm.busy,
932
- onClick: confirm.onCancel,
933
- children: confirm.cancelLabel
934
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
935
- ref: flyConfirmRef,
936
- type: "button",
937
- disabled: confirm.busy,
938
- onClick: confirm.onConfirm,
939
- children: confirm.confirmLabel
940
- })]
941
- })]
942
- }), document.body)] });
1491
+ }), document.body)
1492
+ ] });
943
1493
  }
944
1494
  //#endregion
945
1495
  //#region src/client/BranchChip.tsx
946
1496
  /**
947
1497
  * BranchChipDock: the composer tool-row entry (conversation.input.left, right
948
1498
  * of the mode chips) for sessions inside a git repository. Blank sessions
949
- * get the full segmented control — branch picker plus the worktree
950
- * isolation toggle — because that is the moment to choose the environment
951
- * for the conversation. Once the session starts, the worktree toggle is
952
- * withdrawn: a started session may still switch branches in place (a
953
- * switch inside a linked worktree checks out within that worktree —
954
- * probeRepo roots at the session directory's toplevel, never the main
955
- * checkout), but its directory is fixed. Non-git directories and load
956
- * failures render nothing. The confirm dialogs and the error toast live
957
- * here too.
1499
+ * OF THE MAIN checkout get the full segmented control — branch picker plus
1500
+ * the worktree isolation toggle — because that is the moment to choose the
1501
+ * environment for the conversation, and starting a worktree is a main-repo
1502
+ * decision. Once the session starts, the worktree toggle is withdrawn (its
1503
+ * directory is fixed). A session inside a LINKED worktree scopes the whole
1504
+ * entry down: blank, the menu lists every branch for READING but every
1505
+ * pick but the current branch answers with the main-checkout hint (and
1506
+ * neither the toggle nor the in-place new-branch tool exists there);
1507
+ * started, the menu shows nothing but the session's own branch — fetch and
1508
+ * update-current stay, since neither moves the checkout (probeRepo still
1509
+ * roots at the session directory's toplevel, never the main checkout).
1510
+ * Non-git directories and load failures render nothing. The confirm
1511
+ * dialogs and the error toast live here too.
958
1512
  *
959
1513
  * Checking the worktree toggle pops the cutout confirm dialog right away:
960
1514
  * confirming it cuts a NEW branch (`<current>-wt`, suffixes past taken
@@ -966,6 +1520,25 @@ window.__ModuleLoader__.load({
966
1520
  * current branch stages the same cutout confirm. Dismissing the dialog and
967
1521
  * sending the message anyway means the user knowingly stays in the current
968
1522
  * directory — no separate notice fires on send.
1523
+ *
1524
+ * In-place branch creation (the menu toolbar's plus, worktree mode off)
1525
+ * opens the create flyout right of the branch card: type the name, press
1526
+ * Create — the new branch is cut from the session directory's current
1527
+ * checkout and checked out there in one stroke, the worktree-less sibling
1528
+ * of the cutout flow. A failure toasts and leaves the flyout open.
1529
+ *
1530
+ * Remote branches join the picker under their own menu group: picking one
1531
+ * stages the remote-twin confirm — the switch creates the local tracking
1532
+ * branch in place (git's dwim), the worktree pick creates the twin inside
1533
+ * its fresh worktree. Both rides go through the existing /switch and
1534
+ * /worktree routes, which already resolve `<remote>/name` display names.
1535
+ *
1536
+ * Branches held by linked worktrees get their own 「工作树」 group (blank
1537
+ * sessions only): they have left the local group — git refuses to check
1538
+ * them out twice, so a local-group row would be a dead end — and a
1539
+ * double-click hops the session straight into that worktree directory
1540
+ * (adoptWorktree; no git action, no confirm). A started session's
1541
+ * directory is fixed, so the group only exists while blank.
969
1542
  */
970
1543
  /**
971
1544
  * Heavier check glyph for the worktree toggle. The base's IconCheckOutline16
@@ -989,6 +1562,17 @@ window.__ModuleLoader__.load({
989
1562
  })
990
1563
  });
991
1564
  }
1565
+ /** First free `<base>-wt` name against the local branch list — the prefilled
1566
+ * draft of the cutout dialog (same shape as the host's suffix walk, minus
1567
+ * the storage-folder probe the client cannot see). */
1568
+ function firstFreeCutoutName(base, taken) {
1569
+ const stem = `${base}-wt`;
1570
+ if (!taken.includes(stem)) return stem;
1571
+ for (let i = 2;; i += 1) {
1572
+ const candidate = `${stem}${i}`;
1573
+ if (!taken.includes(candidate)) return candidate;
1574
+ }
1575
+ }
992
1576
  /**
993
1577
  * Read the repository status for a directory; refetch on demand.
994
1578
  * @param cwd - absolute session directory.
@@ -1037,30 +1621,56 @@ window.__ModuleLoader__.load({
1037
1621
  return branch.length <= BRANCH_DISPLAY_MAX ? branch : `${branch.slice(0, 24)}…`;
1038
1622
  }
1039
1623
  /**
1040
- * Build the branch rows for the picker: local branches only (remote
1041
- * branches are not offered). A branch already checked out by a live
1042
- * worktree is disabled while the worktree toggle is off (git refuses such
1043
- * a switch); with the toggle on it is the reuse path, so it stays
1044
- * selectable. The selected row's trailing check is BranchMenu's own
1045
- * affordance — no leading icon.
1624
+ * Build the branch rows for the picker in three kinds: LOCAL branches not
1625
+ * held by a linked worktree, REMOTE branches, and one WORKTREE row per
1626
+ * linked worktree. A branch held by a worktree LEAVES the local group —
1627
+ * git refuses to check it out twice, so the row would be a dead end; the
1628
+ * worktree group is the way INTO it instead (a direct session hop, see
1629
+ * the owner's onAdoptWorktree). The main worktree and detached worktrees
1630
+ * don't come along: the main checkout is home, not a hop target, and a
1631
+ * detached worktree has no branch name to offer.
1632
+ *
1633
+ * Inside a linked-worktree session every row but the current branch is
1634
+ * LOCKED (dimmed, still clickable): a pick reaches the owner, which
1635
+ * answers with the main-checkout hint — the dimming reads as "not usable
1636
+ * here" at a glance while the click keeps its explanation.
1046
1637
  */
1047
- function buildBranchRows(branches, worktrees, currentBranch, worktreeMode) {
1048
- const occupied = new Set(worktrees.flatMap((w) => w.branch === void 0 ? [] : [w.branch]));
1049
- return branches.filter((b) => b.kind === "local").map((branch) => ({
1050
- name: branch.name,
1051
- disabled: branch.name !== currentBranch && !worktreeMode && occupied.has(localBranchName(branch.name))
1052
- }));
1638
+ function buildBranchRows(branches, worktrees, currentBranch, inLinkedWorktree) {
1639
+ const held = new Set(worktrees.flatMap((w) => w.main || w.branch === void 0 ? [] : [w.branch]));
1640
+ const lock = (name) => inLinkedWorktree && name !== currentBranch;
1641
+ return [
1642
+ ...branches.filter((b) => b.kind === "local" && !held.has(b.name)).map((b) => ({
1643
+ name: b.name,
1644
+ kind: "local",
1645
+ ...b.ahead === void 0 ? {} : { ahead: b.ahead },
1646
+ ...b.behind === void 0 ? {} : { behind: b.behind },
1647
+ locked: lock(b.name)
1648
+ })),
1649
+ ...branches.filter((b) => b.kind === "remote").map((b) => ({
1650
+ name: b.name,
1651
+ kind: "remote",
1652
+ locked: lock(b.name)
1653
+ })),
1654
+ ...worktrees.flatMap((w) => w.main || w.branch === void 0 ? [] : [{
1655
+ name: w.branch,
1656
+ kind: "worktree",
1657
+ path: w.path,
1658
+ locked: lock(w.branch)
1659
+ }])
1660
+ ];
1053
1661
  }
1054
1662
  /**
1055
1663
  * The check-time confirm dialog, rendered while the branch menu is closed:
1056
1664
  * the same popCard chrome as BranchMenu's flyout, but bottom-pinned above
1057
1665
  * the chip in the menu card's posture — the flyout's right-of-card anchor
1058
1666
  * has no card to sit beside here. Outside pointerdown and Escape cancel;
1059
- * the confirm button takes focus so Enter commits.
1667
+ * the naming input (cutout flow) takes focus when present, else the
1668
+ * confirm button does so Enter commits.
1060
1669
  */
1061
- function ChipConfirm({ anchorRef, ask, confirmLabel, cancelLabel, busy, onConfirm, onCancel }) {
1670
+ function ChipConfirm({ anchorRef, ask, subject, confirmLabel, cancelLabel, busy, draft, onDraftChange, draftPlaceholder, draftInvalid, draftHint, onConfirm, onCancel }) {
1062
1671
  const popRef = (0, react.useRef)(null);
1063
1672
  const confirmRef = (0, react.useRef)(null);
1673
+ const draftInputRef = (0, react.useRef)(null);
1064
1674
  const [pos, setPos] = (0, react.useState)(null);
1065
1675
  (0, react.useLayoutEffect)(() => {
1066
1676
  const place = () => {
@@ -1086,7 +1696,7 @@ window.__ModuleLoader__.load({
1086
1696
  }, [anchorRef]);
1087
1697
  (0, react.useEffect)(() => {
1088
1698
  const raf = requestAnimationFrame(() => {
1089
- confirmRef.current?.focus();
1699
+ (draftInputRef.current ?? confirmRef.current)?.focus();
1090
1700
  });
1091
1701
  return () => {
1092
1702
  cancelAnimationFrame(raf);
@@ -1114,24 +1724,55 @@ window.__ModuleLoader__.load({
1114
1724
  style: pos ?? POP_MEASURE,
1115
1725
  role: "dialog",
1116
1726
  "aria-label": ask,
1117
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1118
- className: BranchChip_module_default.popAsk,
1119
- children: ask
1120
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1121
- className: BranchChip_module_default.popActions,
1122
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1123
- type: "button",
1727
+ children: [
1728
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1729
+ className: BranchChip_module_default.popAsk,
1730
+ children: ask
1731
+ }),
1732
+ subject !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1733
+ className: BranchChip_module_default.popSubject,
1734
+ children: subject
1735
+ }),
1736
+ onDraftChange !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1737
+ ref: draftInputRef,
1738
+ className: BranchChip_module_default.menuCreate,
1739
+ type: "text",
1740
+ value: draft,
1741
+ placeholder: draftPlaceholder,
1742
+ "aria-label": draftPlaceholder,
1743
+ "aria-invalid": draftInvalid,
1744
+ spellCheck: false,
1124
1745
  disabled: busy,
1125
- onClick: onCancel,
1126
- children: cancelLabel
1127
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1128
- ref: confirmRef,
1129
- type: "button",
1130
- disabled: busy,
1131
- onClick: onConfirm,
1132
- children: confirmLabel
1133
- })]
1134
- })]
1746
+ onChange: (event) => {
1747
+ onDraftChange(event.target.value);
1748
+ },
1749
+ onKeyDown: (event) => {
1750
+ if (event.key === "Enter" && draftInvalid !== true && !busy) {
1751
+ event.preventDefault();
1752
+ onConfirm();
1753
+ }
1754
+ }
1755
+ }), draftInvalid === true && draftHint !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1756
+ className: BranchChip_module_default.menuCreateHintBad,
1757
+ role: "status",
1758
+ children: draftHint
1759
+ })] }),
1760
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1761
+ className: BranchChip_module_default.popActions,
1762
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1763
+ type: "button",
1764
+ disabled: busy,
1765
+ onClick: onCancel,
1766
+ children: cancelLabel
1767
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1768
+ ref: confirmRef,
1769
+ type: "button",
1770
+ disabled: busy || draftInvalid === true,
1771
+ onClick: onConfirm,
1772
+ children: confirmLabel
1773
+ })]
1774
+ })
1775
+ ]
1135
1776
  }), document.body);
1136
1777
  }
1137
1778
  /** The tool-row entry registered into conversation.input.left. */
@@ -1142,6 +1783,11 @@ window.__ModuleLoader__.load({
1142
1783
  const [worktreeMode, setWorktreeMode] = (0, react.useState)(false);
1143
1784
  const [confirm, setConfirm] = (0, react.useState)(null);
1144
1785
  const [busy, setBusy] = (0, react.useState)(false);
1786
+ /** Which arrow is spinning: fetch and update are single-flight against
1787
+ * the SAME busyRef (mutually exclusive), but the spinning state must be
1788
+ * per-tool — one shared flag made both arrows rotate at once. */
1789
+ const [fetchBusy, setFetchBusy] = (0, react.useState)(false);
1790
+ const [updateBusy, setUpdateBusy] = (0, react.useState)(false);
1145
1791
  const [toast, setToast] = (0, react.useState)(null);
1146
1792
  const chipRef = (0, react.useRef)(null);
1147
1793
  const busyRef = (0, react.useRef)(false);
@@ -1203,48 +1849,177 @@ window.__ModuleLoader__.load({
1203
1849
  refresh,
1204
1850
  runGuarded
1205
1851
  ]);
1206
- /** Worktree flow: POST /worktree (create-or-reuse, or cut out a new
1207
- * branch), register the directory, hop sessions. */
1208
- const doWorktree = (0, react.useCallback)((branch, cutout) => runGuarded(async () => {
1852
+ /** Create-branch flow: POST /branch (create from the current checkout and
1853
+ * switch to it in place), then refetch the status — the menu closed by
1854
+ * then, and the chip label must name the new branch. Fired directly by
1855
+ * the menu's create flyout (no confirm kind): typing the name into the
1856
+ * flyout and pressing Create is the intent. */
1857
+ const doCreateBranch = (0, react.useCallback)((name) => runGuarded(async () => {
1209
1858
  if (cwd === void 0) return "no session directory";
1210
- const result = cutout ? await requestWorktreeCutout(cwd, branch) : await requestWorktree(cwd, branch);
1859
+ const result = await requestCreateBranch(cwd, name);
1211
1860
  if (!result.ok) return result.error;
1212
- try {
1213
- await adoptWorktree(result.path);
1214
- } catch (cause) {
1215
- return cause instanceof Error ? cause.message : String(cause);
1216
- }
1861
+ await refresh();
1217
1862
  }), [
1218
- adoptWorktree,
1219
1863
  cwd,
1864
+ refresh,
1220
1865
  runGuarded
1221
1866
  ]);
1222
- const facts = repo.facts;
1223
- const rows = (0, react.useMemo)(() => facts === null ? [] : buildBranchRows(facts.branches, facts.worktrees, facts.currentBranch, worktreeMode), [facts, worktreeMode]);
1224
- if (facts === null) return null;
1225
- const confirmLocalName = confirm === null ? "" : localBranchName(confirm.branch);
1226
- const existingWorktree = confirm === null || confirm.kind !== "worktree" ? void 0 : facts.worktrees.find((w) => w.branch === confirmLocalName);
1227
- /** One confirm bundle shared by the menu flyout and the standalone
1228
- * dialog (whichever is showing). */
1229
- const confirmBundle = confirm === null ? null : {
1230
- ask: confirm.kind === "worktree-cutout" ? t("worktreeAskCutOut", { branch: confirmLocalName }) : confirm.kind === "worktree" ? t(existingWorktree !== void 0 ? "worktreeAskReuse" : "worktreeAskNew", { branch: confirmLocalName }) : t("switchAsk", { branch: confirm.branch }),
1231
- confirmLabel: busy ? confirm.kind === "worktree" || confirm.kind === "worktree-cutout" ? t("worktreeBusy") : t("switchBusy") : t("actionConfirm"),
1232
- cancelLabel: t("actionCancel"),
1233
- busy,
1234
- onConfirm: () => {
1235
- if (confirm.kind === "worktree" || confirm.kind === "worktree-cutout") doWorktree(confirm.branch, confirm.kind === "worktree-cutout");
1236
- else doSwitch(confirm.branch);
1237
- },
1238
- onCancel: () => {
1239
- if (!busy) setConfirm(null);
1867
+ /** Remote-sync flow: POST /fetch (fetch every remote + prune), then
1868
+ * refetch the status. Deliberately NOT runGuarded: its success closes the
1869
+ * menu, while the whole point of a sync is watching the refreshed branch
1870
+ * list in place. Single-flight shares busyRef with the other actions, so
1871
+ * a sync and a confirm action can never interleave. A network fetch has
1872
+ * NO visible side effect when the remote moved not — the spinning tool
1873
+ * (menu side) and the done toast here ARE the feedback. */
1874
+ const doFetch = (0, react.useCallback)(async () => {
1875
+ if (busyRef.current) return;
1876
+ busyRef.current = true;
1877
+ setBusy(true);
1878
+ setFetchBusy(true);
1879
+ const failure = await (async () => {
1880
+ if (cwd === void 0) return "no session directory";
1881
+ const result = await requestFetch(cwd);
1882
+ if (!result.ok) return result.error;
1883
+ })();
1884
+ busyRef.current = false;
1885
+ setBusy(false);
1886
+ setFetchBusy(false);
1887
+ if (failure !== void 0) {
1888
+ showError(failure);
1889
+ return;
1240
1890
  }
1241
- };
1242
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1243
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1244
- className: BranchChip_module_default.dock,
1245
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1246
- ref: chipRef,
1247
- type: "button",
1891
+ await refresh();
1892
+ setToast({
1893
+ seq: Date.now(),
1894
+ text: t("fetchDone")
1895
+ });
1896
+ }, [
1897
+ cwd,
1898
+ refresh,
1899
+ showError,
1900
+ t
1901
+ ]);
1902
+ /** Update-current-branch flow: POST /update (fetch every remote, then
1903
+ * fast-forward the checked-out branch to its upstream), then refetch the
1904
+ * status in place — same keep-the-menu-open semantics as the fetch sync.
1905
+ * The toast tells the two apart: fast-forwarded vs already up to date. */
1906
+ const doUpdate = (0, react.useCallback)(async () => {
1907
+ if (busyRef.current) return;
1908
+ busyRef.current = true;
1909
+ setBusy(true);
1910
+ setUpdateBusy(true);
1911
+ const result = cwd === void 0 ? void 0 : await requestUpdate(cwd);
1912
+ busyRef.current = false;
1913
+ setBusy(false);
1914
+ setUpdateBusy(false);
1915
+ if (result === void 0) {
1916
+ showError("no session directory");
1917
+ return;
1918
+ }
1919
+ if (!result.ok) {
1920
+ showError(result.error);
1921
+ return;
1922
+ }
1923
+ await refresh();
1924
+ setToast({
1925
+ seq: Date.now(),
1926
+ text: result.updated ? t("updateDone", { branch: result.branch }) : t("updateUpToDate")
1927
+ });
1928
+ }, [
1929
+ cwd,
1930
+ refresh,
1931
+ showError,
1932
+ t
1933
+ ]);
1934
+ /** Worktree-group flow: hop the session into the EXISTING worktree
1935
+ * directory. No git action, no confirm — the double-click IS the hop
1936
+ * (a directory jump is reversible and touches nothing), and the owner's
1937
+ * adoptWorktree registers the folder and opens a blank session there. */
1938
+ const doAdoptWorktree = (0, react.useCallback)((path) => {
1939
+ if (busyRef.current) return;
1940
+ busyRef.current = true;
1941
+ setBusy(true);
1942
+ adoptWorktree(path).then(() => {
1943
+ setMenuOpen(false);
1944
+ }).catch((cause) => {
1945
+ showError(cause instanceof Error ? cause.message : String(cause));
1946
+ }).finally(() => {
1947
+ busyRef.current = false;
1948
+ setBusy(false);
1949
+ });
1950
+ }, [adoptWorktree, showError]);
1951
+ /** Worktree flow: POST /worktree (create-or-reuse, or cut out a new
1952
+ * branch under an explicit name), register the directory, hop sessions. */
1953
+ const doWorktree = (0, react.useCallback)((branch, cutout, name) => runGuarded(async () => {
1954
+ if (cwd === void 0) return "no session directory";
1955
+ const result = cutout ? await requestWorktreeCutout(cwd, branch, name) : await requestWorktree(cwd, branch);
1956
+ if (!result.ok) return result.error;
1957
+ try {
1958
+ await adoptWorktree(result.path);
1959
+ } catch (cause) {
1960
+ return cause instanceof Error ? cause.message : String(cause);
1961
+ }
1962
+ }), [
1963
+ adoptWorktree,
1964
+ cwd,
1965
+ runGuarded
1966
+ ]);
1967
+ const facts = repo.facts;
1968
+ const inLinkedWorktree = facts !== null && facts.worktrees.find((w) => w.main)?.path !== facts.repoRoot;
1969
+ const rows = (0, react.useMemo)(() => {
1970
+ if (facts === null) return [];
1971
+ if (inLinkedWorktree && !session.blank) {
1972
+ const current = facts.branches.find((b) => b.kind === "local" && b.name === facts.currentBranch);
1973
+ return current === void 0 ? [] : [{
1974
+ name: current.name,
1975
+ kind: "local",
1976
+ ...current.ahead === void 0 ? {} : { ahead: current.ahead },
1977
+ ...current.behind === void 0 ? {} : { behind: current.behind }
1978
+ }];
1979
+ }
1980
+ return buildBranchRows(facts.branches, facts.worktrees, facts.currentBranch, inLinkedWorktree);
1981
+ }, [
1982
+ facts,
1983
+ inLinkedWorktree,
1984
+ session.blank
1985
+ ]);
1986
+ const localNames = (0, react.useMemo)(() => rows.filter((row) => row.kind !== "remote").map((row) => row.name), [rows]);
1987
+ if (facts === null) return null;
1988
+ const confirmLocalName = confirm === null ? "" : localBranchName(confirm.branch);
1989
+ const isCutout = confirm?.kind === "worktree-cutout";
1990
+ const cutoutDraft = isCutout ? confirm.draft ?? "" : "";
1991
+ const cutoutIssue = isCutout ? branchNameIssue(cutoutDraft) : null;
1992
+ const cutoutDuplicate = isCutout && cutoutIssue === null && localNames.includes(cutoutDraft);
1993
+ const cutoutValid = cutoutIssue === null && !cutoutDuplicate;
1994
+ const cutoutHint = cutoutDuplicate ? t("menuNewBranchExists") : cutoutIssue !== null && cutoutIssue !== "empty" ? t("menuNewBranchBad") : void 0;
1995
+ const existingWorktree = confirm === null || confirm.kind !== "worktree" ? void 0 : facts.worktrees.find((w) => w.branch === confirmLocalName);
1996
+ /** One confirm bundle shared by the menu flyout and the standalone
1997
+ * dialog (whichever is showing). Remote picks keep the ask line SHORT (a
1998
+ * wrapping sentence with long branch names breaks badly) and name the
1999
+ * branch on its own weight-500 line — the dwim/worktree consequences are
2000
+ * git's default behavior, not worth a third line. */
2001
+ const confirmBundle = confirm === null ? null : {
2002
+ ask: confirm.kind === "worktree-cutout" ? t("worktreeAskCutOut", { branch: confirmLocalName }) : confirm.kind === "worktree" ? confirm.remote === true ? t("worktreeAskRemote") : t(existingWorktree !== void 0 ? "worktreeAskReuse" : "worktreeAskNew", { branch: confirmLocalName }) : confirm.remote === true ? t("switchAskRemote") : t("switchAsk", { branch: confirm.branch }),
2003
+ ...confirm.remote === true ? { subject: confirm.branch } : {},
2004
+ confirmLabel: busy ? confirm.kind === "worktree" || confirm.kind === "worktree-cutout" ? t("worktreeBusy") : t("switchBusy") : t("actionConfirm"),
2005
+ cancelLabel: t("actionCancel"),
2006
+ busy,
2007
+ onConfirm: () => {
2008
+ if (confirm.kind === "worktree" || confirm.kind === "worktree-cutout") {
2009
+ if (confirm.kind === "worktree-cutout" && !cutoutValid) return;
2010
+ doWorktree(confirm.branch, confirm.kind === "worktree-cutout", confirm.draft);
2011
+ } else doSwitch(confirm.branch);
2012
+ },
2013
+ onCancel: () => {
2014
+ if (!busy) setConfirm(null);
2015
+ }
2016
+ };
2017
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2018
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2019
+ className: BranchChip_module_default.dock,
2020
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2021
+ ref: chipRef,
2022
+ type: "button",
1248
2023
  className: BranchChip_module_default.chip,
1249
2024
  title: facts.currentBranch,
1250
2025
  onClick: () => {
@@ -1257,7 +2032,7 @@ window.__ModuleLoader__.load({
1257
2032
  className: BranchChip_module_default.branch,
1258
2033
  children: displayBranch(facts.currentBranch)
1259
2034
  })]
1260
- }), session.blank && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2035
+ }), session.blank && !inLinkedWorktree && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1261
2036
  className: BranchChip_module_default.divider,
1262
2037
  "aria-hidden": "true"
1263
2038
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
@@ -1270,7 +2045,8 @@ window.__ModuleLoader__.load({
1270
2045
  if (next) {
1271
2046
  setConfirm({
1272
2047
  kind: "worktree-cutout",
1273
- branch: facts.currentBranch
2048
+ branch: facts.currentBranch,
2049
+ draft: firstFreeCutoutName(localBranchName(facts.currentBranch), localNames)
1274
2050
  });
1275
2051
  if (!busyRef.current) refresh();
1276
2052
  } else setConfirm(null);
@@ -1291,18 +2067,47 @@ window.__ModuleLoader__.load({
1291
2067
  rows,
1292
2068
  currentBranch: facts.currentBranch,
1293
2069
  confirm: confirmBundle,
2070
+ canCreate: !worktreeMode && !inLinkedWorktree,
2071
+ canAdopt: session.blank,
2072
+ busy,
2073
+ onCreate: (name) => {
2074
+ doCreateBranch(name);
2075
+ },
2076
+ onFetch: () => {
2077
+ doFetch();
2078
+ },
2079
+ fetchBusy,
2080
+ onUpdate: () => {
2081
+ doUpdate();
2082
+ },
2083
+ updateBusy,
1294
2084
  onSelect: (branch) => {
1295
2085
  if (branch === facts.currentBranch) {
1296
2086
  if (worktreeMode) setConfirm({
1297
2087
  kind: "worktree-cutout",
1298
- branch
2088
+ branch,
2089
+ draft: firstFreeCutoutName(localBranchName(branch), localNames)
1299
2090
  });
1300
2091
  else setMenuOpen(false);
1301
2092
  return;
1302
2093
  }
2094
+ if (inLinkedWorktree) {
2095
+ setToast({
2096
+ seq: Date.now(),
2097
+ text: t("mainRepoOnly")
2098
+ });
2099
+ return;
2100
+ }
2101
+ const row = rows.find((r) => r.name === branch);
2102
+ if (row?.kind === "worktree" && row.path !== void 0) {
2103
+ doAdoptWorktree(row.path);
2104
+ return;
2105
+ }
2106
+ const remote = row?.kind === "remote";
1303
2107
  setConfirm({
1304
2108
  kind: worktreeMode ? "worktree" : "switch",
1305
- branch
2109
+ branch,
2110
+ remote
1306
2111
  });
1307
2112
  },
1308
2113
  onClose: () => {
@@ -1312,7 +2117,17 @@ window.__ModuleLoader__.load({
1312
2117
  }),
1313
2118
  confirmBundle !== null && !menuOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChipConfirm, {
1314
2119
  anchorRef: chipRef,
1315
- ...confirmBundle
2120
+ ...confirmBundle,
2121
+ ...isCutout ? { draft: cutoutDraft } : {},
2122
+ ...isCutout ? { onDraftChange: (value) => {
2123
+ setConfirm((current) => current?.kind === "worktree-cutout" ? {
2124
+ ...current,
2125
+ draft: value
2126
+ } : current);
2127
+ } } : {},
2128
+ draftPlaceholder: t("menuNewBranchPlaceholder"),
2129
+ ...isCutout && !cutoutValid ? { draftInvalid: true } : {},
2130
+ ...cutoutHint === void 0 ? {} : { draftHint: cutoutHint }
1316
2131
  }),
1317
2132
  toast !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
1318
2133
  text: toast.text,
@@ -1332,21 +2147,30 @@ window.__ModuleLoader__.load({
1332
2147
  * The form publishes through a snapshot store because the slot component
1333
2148
  * reads through a snapshot selector while both the scope and the local draft
1334
2149
  * change underneath; every projection is rebuilt from the two together. The
1335
- * field is staged only when the user touched it, so a save writes a sparse
1336
- * patch and never restates fields it did not see.
2150
+ * root field is staged only when the user touched it, so a save writes a
2151
+ * sparse patch and never restates fields it did not see. The grouping switch
2152
+ * is not staged: a set optimistic-publishes, yields a frame so the spinner
2153
+ * can paint, then writes; pending holds until the seat callback settles.
1337
2154
  */
1338
2155
  var CardForm = class {
1339
2156
  scope;
2157
+ afterGroupSidebarWrite;
1340
2158
  snapshotValue;
1341
2159
  listeners = /* @__PURE__ */ new Set();
1342
2160
  draft;
1343
2161
  saving = false;
1344
2162
  failed = false;
2163
+ groupingPending = false;
2164
+ groupingDraft;
1345
2165
  /**
1346
2166
  * @param scope - the bound settings scope for the `git-worktree` namespace.
2167
+ * @param afterGroupSidebarWrite - awaited after the setting lands, until
2168
+ * the sidebar seat has actually swapped (facts in on enable, native
2169
+ * paint on disable). Absent in unit tests that only cover the write.
1347
2170
  */
1348
- constructor(scope) {
2171
+ constructor(scope, afterGroupSidebarWrite) {
1349
2172
  this.scope = scope;
2173
+ this.afterGroupSidebarWrite = afterGroupSidebarWrite;
1350
2174
  this.snapshotValue = this.project();
1351
2175
  scope.subscribe(() => {
1352
2176
  this.publish();
@@ -1367,7 +2191,7 @@ window.__ModuleLoader__.load({
1367
2191
  }
1368
2192
  };
1369
2193
  }
1370
- /** @returns the edit, clear, save, and discard actions bound to this form. */
2194
+ /** @returns the edit, clear, save, discard, and grouping-switch actions bound to this form. */
1371
2195
  actions() {
1372
2196
  return {
1373
2197
  editRoot: (text) => {
@@ -1386,10 +2210,39 @@ window.__ModuleLoader__.load({
1386
2210
  this.draft = void 0;
1387
2211
  this.failed = false;
1388
2212
  this.publish();
1389
- }
2213
+ },
2214
+ setGroupSidebar: (value) => this.setGroupSidebar(value)
1390
2215
  };
1391
2216
  }
1392
2217
  /**
2218
+ * Flip the grouping switch immediately, then persist.
2219
+ *
2220
+ * `scope.set` only stores the document; the visible sidebar swap (inject
2221
+ * + `/group` facts, or dispose + native paint) happens after. Pending
2222
+ * stays up until that callback settles so the spinner matches what the
2223
+ * user sees, not the write round-trip.
2224
+ */
2225
+ async setGroupSidebar(value) {
2226
+ if (this.groupingPending) return;
2227
+ if (value === this.effectiveGroupSidebar()) return;
2228
+ this.groupingPending = true;
2229
+ this.groupingDraft = value;
2230
+ this.publish();
2231
+ await yieldForPaint();
2232
+ try {
2233
+ await this.scope.set("groupSidebar", value);
2234
+ if (this.afterGroupSidebarWrite !== void 0) await this.afterGroupSidebarWrite(value);
2235
+ } finally {
2236
+ this.groupingPending = false;
2237
+ this.groupingDraft = void 0;
2238
+ this.publish();
2239
+ }
2240
+ }
2241
+ /** Resolved grouping switch, preferring an in-flight optimistic draft. */
2242
+ effectiveGroupSidebar() {
2243
+ return this.groupingDraft ?? this.scope.getSnapshot().value?.groupSidebar ?? true;
2244
+ }
2245
+ /**
1393
2246
  * Write the staged edit, then re-seed from what the Host accepted.
1394
2247
  *
1395
2248
  * The Host is the only authority on acceptance — an empty draft clears the
@@ -1445,7 +2298,9 @@ window.__ModuleLoader__.load({
1445
2298
  overridden: this.draft !== void 0 ? this.draft.trim() !== "" : this.storedRoot(),
1446
2299
  dirty: this.draft !== void 0 && this.draft !== this.effectiveRoot(),
1447
2300
  saving: this.saving,
1448
- failed: this.failed
2301
+ failed: this.failed,
2302
+ groupSidebar: this.effectiveGroupSidebar(),
2303
+ groupingPending: this.groupingPending
1449
2304
  };
1450
2305
  }
1451
2306
  /** Replace the snapshot reference and notify, only when the fact moved. */
@@ -1458,15 +2313,27 @@ window.__ModuleLoader__.load({
1458
2313
  this.store(this.project());
1459
2314
  }
1460
2315
  };
2316
+ /** Yield until after the next paint (rAF), or a macrotask when rAF is absent (tests). */
2317
+ function yieldForPaint() {
2318
+ return new Promise((resolve) => {
2319
+ if (typeof requestAnimationFrame === "function") {
2320
+ requestAnimationFrame(() => {
2321
+ resolve();
2322
+ });
2323
+ return;
2324
+ }
2325
+ setTimeout(resolve, 0);
2326
+ });
2327
+ }
1461
2328
  //#endregion
1462
2329
  //#region \0git-worktree-css:D:\Code\dsh-worktree\src\client\GitWorktreeCard.module.css?inline
1463
- const css = "/* git-worktree settings card on the Plugins configuration tab. Visual\n * language mirrors the settings section's own card chrome (border radius,\n * layer fills, pending badge, footer buttons) so cards from different\n * packages sit in one list without reading as two designs; tokens only, no\n * literal colors. */\n\n.card_1712176718 {\n list-style: none;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n background: var(--dsw-alias-bg-layer-3);\n transition: border-color .16s, background .16s;\n}\n\n.card_1712176718:hover {\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n/* An open card reads as the one being worked on, not merely taller. */\n.cardOpen_1712176718 {\n background: var(--dsw-alias-bg-layer-2);\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n.header_1712176718 {\n width: 100%;\n appearance: none;\n border: 0;\n background: none;\n font: inherit;\n color: inherit;\n text-align: left;\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 14px 16px;\n border-radius: 12px;\n}\n\n.header_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: -2px;\n}\n\n/* Name over description, mirroring the section's own plugin cards: the\n * description is what tells one plugin's settings from another's. */\n.headText_1712176718 {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.name_1712176718 {\n font-size: 15px;\n font-weight: 600;\n line-height: 1.4;\n color: var(--dsw-alias-label-primary);\n}\n\n.description_1712176718 {\n font-size: 13px;\n line-height: 1.5;\n color: var(--dsw-alias-label-tertiary);\n}\n\n/* Carried on the header so a collapsed card still says it holds edits. */\n.pending_1712176718 {\n flex: none;\n border-radius: 999px;\n padding: 1px 8px;\n font-size: 11px;\n line-height: 17px;\n font-weight: 500;\n white-space: nowrap;\n background: var(--dsw-alias-bg-module-platform);\n color: var(--dsw-alias-label-secondary);\n}\n\n.chevron_1712176718 {\n flex: none;\n color: var(--dsw-alias-label-tertiary);\n transition: transform .16s;\n}\n\n.chevronOpen_1712176718 {\n transform: rotate(180deg);\n}\n\n.body_1712176718 {\n border-top: 1px solid var(--dsw-alias-border-l2);\n margin: 0 16px;\n padding: 12px 0 8px;\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.note_1712176718 {\n margin: 0;\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.field_1712176718 {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.fieldLabel_1712176718 {\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-secondary);\n}\n\n.input_1712176718 {\n box-sizing: border-box;\n width: 100%;\n padding: 4px 8px;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-primary);\n background-color: var(--dsw-alias-bg-layer-2);\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 6px;\n appearance: none;\n}\n\n.input_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: -1px;\n}\n\n.input_1712176718:disabled {\n opacity: 0.6;\n}\n\n/* The directory control and its native-dialog launcher share one row. */\n.inputRow_1712176718 {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.inputRow_1712176718 .input_1712176718 {\n flex: 1;\n min-width: 0;\n}\n\n.browse_1712176718 {\n appearance: none;\n flex: none;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 6px;\n padding: 4px 10px;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n background: none;\n cursor: pointer;\n white-space: nowrap;\n}\n\n.browse_1712176718:hover:not(:disabled) {\n color: var(--dsw-alias-label-primary);\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n.browse_1712176718:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.browse_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: 1px;\n}\n\n.hint_1712176718 {\n margin: 0;\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.footer_1712176718 {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n padding: 8px 0 4px;\n border-top: 1px solid var(--dsw-alias-border-l2);\n}\n\n.failed_1712176718 {\n flex: 1;\n min-width: 0;\n margin: 0;\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-error);\n}\n\n.discard_1712176718,\n.save_1712176718 {\n appearance: none;\n border: 1px solid transparent;\n border-radius: 8px;\n padding: 5px 14px;\n font: inherit;\n font-size: 13px;\n line-height: 1.5;\n cursor: pointer;\n}\n\n.discard_1712176718 {\n border-color: var(--dsw-alias-border-l2);\n background: none;\n color: var(--dsw-alias-label-secondary);\n}\n\n.discard_1712176718:hover:not(:disabled) {\n color: var(--dsw-alias-label-primary);\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n.save_1712176718 {\n background: var(--dsw-alias-label-primary);\n color: var(--dsw-alias-bg-layer-3);\n}\n\n.discard_1712176718:disabled,\n.save_1712176718:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.discard_1712176718:focus-visible,\n.save_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: 1px;\n}\n";
1464
- const tagId = "@laoyuehanni/dsh-git-worktree/GitWorktreeCard.module.css";
1465
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId + "\"]") === null) {
2330
+ const css$2 = "/* git-worktree settings card on the Plugins configuration tab. Visual\n * language mirrors the settings section's own card chrome (border radius,\n * layer fills, pending badge, footer buttons) so cards from different\n * packages sit in one list without reading as two designs; tokens only, no\n * literal colors. */\n\n.card_1712176718 {\n list-style: none;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 12px;\n background: var(--dsw-alias-bg-layer-3);\n transition: border-color .16s, background .16s;\n}\n\n.card_1712176718:hover {\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n/* An open card reads as the one being worked on, not merely taller. */\n.cardOpen_1712176718 {\n background: var(--dsw-alias-bg-layer-2);\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n.header_1712176718 {\n width: 100%;\n appearance: none;\n border: 0;\n background: none;\n font: inherit;\n color: inherit;\n text-align: left;\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 14px 16px;\n border-radius: 12px;\n}\n\n.header_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: -2px;\n}\n\n/* Name over description, mirroring the section's own plugin cards: the\n * description is what tells one plugin's settings from another's. */\n.headText_1712176718 {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.name_1712176718 {\n font-size: 15px;\n font-weight: 600;\n line-height: 1.4;\n color: var(--dsw-alias-label-primary);\n}\n\n.description_1712176718 {\n font-size: 13px;\n line-height: 1.5;\n color: var(--dsw-alias-label-tertiary);\n}\n\n/* Carried on the header so a collapsed card still says it holds edits. */\n.pending_1712176718 {\n flex: none;\n border-radius: 999px;\n padding: 1px 8px;\n font-size: 11px;\n line-height: 17px;\n font-weight: 500;\n white-space: nowrap;\n background: var(--dsw-alias-bg-module-platform);\n color: var(--dsw-alias-label-secondary);\n}\n\n.chevron_1712176718 {\n flex: none;\n color: var(--dsw-alias-label-tertiary);\n transition: transform .16s;\n}\n\n.chevronOpen_1712176718 {\n transform: rotate(180deg);\n}\n\n.body_1712176718 {\n border-top: 1px solid var(--dsw-alias-border-l2);\n margin: 0 16px;\n padding: 12px 0 8px;\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.note_1712176718 {\n margin: 0;\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.field_1712176718 {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.fieldLabel_1712176718 {\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-secondary);\n}\n\n.input_1712176718 {\n box-sizing: border-box;\n width: 100%;\n padding: 4px 8px;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-primary);\n background-color: var(--dsw-alias-bg-layer-2);\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 6px;\n appearance: none;\n}\n\n.input_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: -1px;\n}\n\n.input_1712176718:disabled {\n opacity: 0.6;\n}\n\n/* The directory control and its native-dialog launcher share one row. */\n.inputRow_1712176718 {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.inputRow_1712176718 .input_1712176718 {\n flex: 1;\n min-width: 0;\n}\n\n.browse_1712176718 {\n appearance: none;\n flex: none;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: 6px;\n padding: 4px 10px;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n background: none;\n cursor: pointer;\n white-space: nowrap;\n}\n\n.browse_1712176718:hover:not(:disabled) {\n color: var(--dsw-alias-label-primary);\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n.browse_1712176718:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.browse_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: 1px;\n}\n\n.hint_1712176718 {\n margin: 0;\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.footer_1712176718 {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n padding: 8px 0 4px;\n border-top: 1px solid var(--dsw-alias-border-l2);\n}\n\n.failed_1712176718 {\n flex: 1;\n min-width: 0;\n margin: 0;\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-error);\n}\n\n.discard_1712176718,\n.save_1712176718 {\n appearance: none;\n border: 1px solid transparent;\n border-radius: 8px;\n padding: 5px 14px;\n font: inherit;\n font-size: 13px;\n line-height: 1.5;\n cursor: pointer;\n}\n\n.discard_1712176718 {\n border-color: var(--dsw-alias-border-l2);\n background: none;\n color: var(--dsw-alias-label-secondary);\n}\n\n.discard_1712176718:hover:not(:disabled) {\n color: var(--dsw-alias-label-primary);\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n.save_1712176718 {\n background: var(--dsw-alias-label-primary);\n color: var(--dsw-alias-bg-layer-3);\n}\n\n.discard_1712176718:disabled,\n.save_1712176718:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.discard_1712176718:focus-visible,\n.save_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: 1px;\n}\n\n/* Sidebar-grouping switch: title + hint + caution beside a checkbox. */\n.toggleRow_1712176718 {\n margin-top: 10px;\n flex-direction: row;\n align-items: flex-start;\n gap: 10px;\n}\n\n.toggleText_1712176718 {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.toggleLabel_1712176718 {\n color: var(--dsw-alias-label-primary);\n font-weight: 500;\n}\n\n.toggleMark_1712176718 {\n margin-left: 4px;\n font-weight: 400;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.toggleHint_1712176718 {\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n\n.toggleNote_1712176718 {\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.toggleControl_1712176718 {\n display: flex;\n align-items: center;\n gap: 6px;\n flex: none;\n margin-top: 2px;\n}\n\n.spinner_1712176718 {\n display: flex;\n color: var(--dsw-alias-label-tertiary);\n animation: spin 0.7s linear infinite;\n}\n\n@keyframes spin {\n to { transform: rotate(360deg); }\n}\n\n.toggle_1712176718 {\n width: 16px;\n height: 16px;\n accent-color: var(--dsw-alias-brand-primary);\n cursor: pointer;\n}\n\n.toggle_1712176718:disabled {\n cursor: progress;\n}\n";
2331
+ const tagId$2 = "@laoyuehanni/dsh-git-worktree/GitWorktreeCard.module.css";
2332
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId$2 + "\"]") === null) {
1466
2333
  const tag = document.createElement("style");
1467
2334
  tag.dataset.plugin = "@laoyuehanni/dsh-git-worktree";
1468
- tag.dataset.pluginCss = tagId;
1469
- tag.textContent = css;
2335
+ tag.dataset.pluginCss = tagId$2;
2336
+ tag.textContent = css$2;
1470
2337
  document.head.appendChild(tag);
1471
2338
  }
1472
2339
  var GitWorktreeCard_module_default = {
@@ -1490,7 +2357,16 @@ window.__ModuleLoader__.load({
1490
2357
  "footer": "footer_1712176718",
1491
2358
  "failed": "failed_1712176718",
1492
2359
  "discard": "discard_1712176718",
1493
- "save": "save_1712176718"
2360
+ "save": "save_1712176718",
2361
+ "toggleRow": "toggleRow_1712176718",
2362
+ "toggleText": "toggleText_1712176718",
2363
+ "toggleLabel": "toggleLabel_1712176718",
2364
+ "toggleMark": "toggleMark_1712176718",
2365
+ "toggleHint": "toggleHint_1712176718",
2366
+ "toggleNote": "toggleNote_1712176718",
2367
+ "toggleControl": "toggleControl_1712176718",
2368
+ "spinner": "spinner_1712176718",
2369
+ "toggle": "toggle_1712176718"
1494
2370
  };
1495
2371
  //#endregion
1496
2372
  //#region src/client/GitWorktreeCard.tsx
@@ -1607,6 +2483,46 @@ window.__ModuleLoader__.load({
1607
2483
  className: GitWorktreeCard_module_default.hint,
1608
2484
  children: [t("cardRootDirHint"), state.overridden ? ` ${t("cardOverridden")}` : ""]
1609
2485
  }),
2486
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2487
+ className: `${GitWorktreeCard_module_default.field} ${GitWorktreeCard_module_default.toggleRow}`,
2488
+ "aria-busy": state.groupingPending,
2489
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2490
+ className: GitWorktreeCard_module_default.toggleText,
2491
+ children: [
2492
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2493
+ className: GitWorktreeCard_module_default.toggleLabel,
2494
+ children: [t("cardGroupSidebarLabel"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2495
+ className: GitWorktreeCard_module_default.toggleMark,
2496
+ children: t("cardGroupSidebarMark")
2497
+ })]
2498
+ }),
2499
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2500
+ className: GitWorktreeCard_module_default.toggleHint,
2501
+ children: t("cardGroupSidebarHint")
2502
+ }),
2503
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2504
+ className: GitWorktreeCard_module_default.toggleNote,
2505
+ children: t("cardGroupSidebarNote")
2506
+ })
2507
+ ]
2508
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2509
+ className: GitWorktreeCard_module_default.toggleControl,
2510
+ children: [state.groupingPending ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2511
+ className: GitWorktreeCard_module_default.spinner,
2512
+ role: "status",
2513
+ "aria-label": t("cardGroupSidebarBusy"),
2514
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLoadingOutline16, { size: 14 })
2515
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2516
+ className: GitWorktreeCard_module_default.toggle,
2517
+ type: "checkbox",
2518
+ disabled: lockInput || state.groupingPending,
2519
+ checked: state.groupSidebar,
2520
+ onChange: (event) => {
2521
+ props.setGroupSidebar(event.target.checked);
2522
+ }
2523
+ })]
2524
+ })]
2525
+ }),
1610
2526
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1611
2527
  className: GitWorktreeCard_module_default.footer,
1612
2528
  children: [
@@ -1636,23 +2552,1934 @@ window.__ModuleLoader__.load({
1636
2552
  });
1637
2553
  }
1638
2554
  //#endregion
2555
+ //#region src/client/sidebar-groups.ts
2556
+ /**
2557
+ * Derive the sidebar groups.
2558
+ *
2559
+ * Rules (the shipped design): git facts absent/null → plain single row;
2560
+ * same-`repoRoot` workspaces cluster into one repo group; inside a group the
2561
+ * main worktree leads and linked members keep registry order; a repo cluster
2562
+ * with exactly ONE member degrades to a plain row (zero visual intrusion for
2563
+ * repositories without worktrees); a group renders where its FIRST member
2564
+ * sits in the registry order (the main worktree's slot).
2565
+ * @param items - workspace list items in registry order.
2566
+ * @param facts - per-path git facts from the /group route (absent = unknown).
2567
+ * @returns groups in render order.
2568
+ */
2569
+ function deriveSidebarGroups(items, facts) {
2570
+ const bucketOrder = [];
2571
+ const buckets = /* @__PURE__ */ new Map();
2572
+ const singles = [];
2573
+ items.forEach((workspace, index) => {
2574
+ const pathFacts = facts?.[workspace.path];
2575
+ if (pathFacts === void 0 || pathFacts === null) {
2576
+ singles.push({
2577
+ index,
2578
+ group: singleGroup(workspace)
2579
+ });
2580
+ return;
2581
+ }
2582
+ const bucketKey = `repo:${pathFacts.repoRoot}`;
2583
+ let bucket = buckets.get(bucketKey);
2584
+ if (bucket === void 0) {
2585
+ bucket = {
2586
+ index,
2587
+ mainSeen: false,
2588
+ members: []
2589
+ };
2590
+ buckets.set(bucketKey, bucket);
2591
+ bucketOrder.push(bucketKey);
2592
+ }
2593
+ bucket.members.push({
2594
+ workspace,
2595
+ label: pathFacts.main ? {
2596
+ type: "main",
2597
+ branch: pathFacts.branch
2598
+ } : {
2599
+ type: "linked",
2600
+ branch: pathFacts.branch
2601
+ }
2602
+ });
2603
+ if (pathFacts.main) bucket.mainSeen = true;
2604
+ });
2605
+ const repoGroups = /* @__PURE__ */ new Map();
2606
+ for (const key of bucketOrder) {
2607
+ const bucket = buckets.get(key);
2608
+ if (bucket === void 0) continue;
2609
+ const ordered = bucket.mainSeen ? [...bucket.members].sort((a, b) => Number(b.label.type === "main") - Number(a.label.type === "main")) : bucket.members;
2610
+ const first = ordered[0];
2611
+ if (first === void 0) continue;
2612
+ const repoName = facts?.[first.workspace.path]?.repoName ?? first.workspace.title;
2613
+ if (ordered.length === 1) {
2614
+ singles.push({
2615
+ index: bucket.index,
2616
+ group: singleGroup(first.workspace)
2617
+ });
2618
+ continue;
2619
+ }
2620
+ repoGroups.set(key, {
2621
+ key,
2622
+ kind: "repo",
2623
+ repoName,
2624
+ members: ordered
2625
+ });
2626
+ }
2627
+ const slots = [...singles, ...[...repoGroups.values()].map((group) => {
2628
+ return {
2629
+ index: buckets.get(group.key)?.index ?? Number.MAX_SAFE_INTEGER,
2630
+ group
2631
+ };
2632
+ })];
2633
+ slots.sort((a, b) => a.index - b.index);
2634
+ return slots.map((slot) => slot.group);
2635
+ }
2636
+ /** A plain single-row group for one workspace. */
2637
+ function singleGroup(workspace) {
2638
+ return {
2639
+ key: `ws:${workspace.workspaceId}`,
2640
+ kind: "single",
2641
+ repoName: void 0,
2642
+ members: [{
2643
+ workspace,
2644
+ label: { type: "plain" }
2645
+ }]
2646
+ };
2647
+ }
2648
+ /**
2649
+ * Session ids a member row shows, in the workspace's stored order — the
2650
+ * native browser's visibility rule: archived hidden everywhere, subagent
2651
+ * rows never listed, and a blank row visible only while it IS the current
2652
+ * selection (a blank is the provisional New Session row).
2653
+ * @param workspace - the member's workspace.
2654
+ * @param sessions - session list snapshot.
2655
+ * @param archivedSessionIds - registry-global archive set.
2656
+ * @returns visible session ids in stored order.
2657
+ */
2658
+ function visibleSessionIds(workspace, sessions, archivedSessionIds) {
2659
+ const archived = new Set(archivedSessionIds);
2660
+ const visible = [];
2661
+ for (const sessionId of workspace.sessionIds) {
2662
+ const summary = sessions.byId[sessionId];
2663
+ if (summary === void 0) continue;
2664
+ if (summary.origin === "subagent") continue;
2665
+ if (archived.has(sessionId)) continue;
2666
+ if (summary.blank && sessionId !== sessions.current) continue;
2667
+ visible.push(sessionId);
2668
+ }
2669
+ return visible;
2670
+ }
2671
+ /** localStorage key of the sidebar expansion map (browser-local only). */
2672
+ const EXPAND_STORAGE_KEY = "dsh-git-worktree.sidebar.expand";
2673
+ /** Read the persisted expansion map; unreadable/absent answers {}. */
2674
+ function loadExpandState() {
2675
+ if (typeof localStorage === "undefined") return {};
2676
+ try {
2677
+ const raw = localStorage.getItem(EXPAND_STORAGE_KEY);
2678
+ if (raw === null) return {};
2679
+ const parsed = JSON.parse(raw);
2680
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return {};
2681
+ const out = {};
2682
+ for (const [key, value] of Object.entries(parsed)) if (typeof value === "boolean") out[key] = value;
2683
+ return out;
2684
+ } catch {
2685
+ return {};
2686
+ }
2687
+ }
2688
+ /** Persist the expansion map; write failures (quota, privacy mode) stay silent. */
2689
+ function saveExpandState(state) {
2690
+ if (typeof localStorage === "undefined") return;
2691
+ try {
2692
+ localStorage.setItem(EXPAND_STORAGE_KEY, JSON.stringify(state));
2693
+ } catch {}
2694
+ }
2695
+ /** localStorage key of grouping/order prefs (browser-local; P3 may graduate to store v5). */
2696
+ const VIEW_STORAGE_KEY = "dsh-git-worktree.sidebar.view";
2697
+ const DEFAULT_VIEW_PREFS = {
2698
+ groupBy: "workspace",
2699
+ orderBy: "updated"
2700
+ };
2701
+ /** Read persisted view prefs; unreadable/absent answers native defaults. */
2702
+ function loadViewPrefs() {
2703
+ if (typeof localStorage === "undefined") return DEFAULT_VIEW_PREFS;
2704
+ try {
2705
+ const raw = localStorage.getItem(VIEW_STORAGE_KEY);
2706
+ if (raw === null) return DEFAULT_VIEW_PREFS;
2707
+ const parsed = JSON.parse(raw);
2708
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return DEFAULT_VIEW_PREFS;
2709
+ const record = parsed;
2710
+ return {
2711
+ groupBy: record.groupBy === "flat" || record.groupBy === "workspace" ? record.groupBy : DEFAULT_VIEW_PREFS.groupBy,
2712
+ orderBy: record.orderBy === "manual" || record.orderBy === "updated" ? record.orderBy : DEFAULT_VIEW_PREFS.orderBy
2713
+ };
2714
+ } catch {
2715
+ return DEFAULT_VIEW_PREFS;
2716
+ }
2717
+ }
2718
+ /** Persist view prefs; write failures stay silent. */
2719
+ function saveViewPrefs(prefs) {
2720
+ if (typeof localStorage === "undefined") return;
2721
+ try {
2722
+ localStorage.setItem(VIEW_STORAGE_KEY, JSON.stringify(prefs));
2723
+ } catch {}
2724
+ }
2725
+ /** Recency comparator: newest first, id as the deterministic tiebreak. */
2726
+ function byRecency(a, b) {
2727
+ if (b.updatedAt !== a.updatedAt) return b.updatedAt - a.updatedAt;
2728
+ return a.id < b.id ? -1 : 1;
2729
+ }
2730
+ /**
2731
+ * Index running/total subagent descendants under each ancestor reached through
2732
+ * an uninterrupted subagent-origin chain (ordinary forks terminate propagation).
2733
+ * Mirrors `indexSubagentDescendants` without importing the runtime bundle.
2734
+ */
2735
+ function indexSubagentRunning(byId) {
2736
+ const out = /* @__PURE__ */ new Map();
2737
+ const bump = (id, running) => {
2738
+ const cur = out.get(id) ?? {
2739
+ count: 0,
2740
+ runningCount: 0
2741
+ };
2742
+ out.set(id, {
2743
+ count: cur.count + 1,
2744
+ runningCount: cur.runningCount + (running ? 1 : 0)
2745
+ });
2746
+ };
2747
+ for (const summary of Object.values(byId)) {
2748
+ if (summary === void 0 || summary.origin !== "subagent") continue;
2749
+ const running = summary.running === true;
2750
+ const seen = /* @__PURE__ */ new Set();
2751
+ let parentId = summary.parentId;
2752
+ while (parentId !== void 0 && parentId !== "" && !seen.has(parentId)) {
2753
+ seen.add(parentId);
2754
+ bump(parentId, running);
2755
+ const parent = byId[parentId];
2756
+ if (parent === void 0 || parent.origin !== "subagent") break;
2757
+ parentId = parent.parentId;
2758
+ }
2759
+ }
2760
+ return out;
2761
+ }
2762
+ /** A blank session's canonical title never enters search; the renderer localizes the label. */
2763
+ function sessionTitle(session) {
2764
+ return session.blank ? "New Session" : session.displayTitle;
2765
+ }
2766
+ /** Project a list-row summary into a renderable session node. */
2767
+ function sessionNode(session, descendants) {
2768
+ return {
2769
+ id: session.id,
2770
+ title: sessionTitle(session),
2771
+ blank: session.blank,
2772
+ running: session.running === true,
2773
+ runningSubagentCount: descendants.get(session.id)?.runningCount ?? 0,
2774
+ completed: session.completed === true,
2775
+ updatedAt: session.updatedAt ?? 0,
2776
+ ...session.pendingInteraction === void 0 ? {} : { pendingInteraction: session.pendingInteraction }
2777
+ };
2778
+ }
2779
+ /** Visible session ids, optionally newest-first when `orderBy` is `updated`. */
2780
+ function orderedVisibleSessionIds(workspace, sessions, archivedSessionIds, orderBy) {
2781
+ const ids = visibleSessionIds(workspace, sessions, archivedSessionIds);
2782
+ if (orderBy !== "updated") return ids;
2783
+ return [...ids].sort((a, b) => {
2784
+ const left = sessions.byId[a];
2785
+ const right = sessions.byId[b];
2786
+ return byRecency({
2787
+ id: a,
2788
+ updatedAt: left?.updatedAt ?? Number.NEGATIVE_INFINITY
2789
+ }, {
2790
+ id: b,
2791
+ updatedAt: right?.updatedAt ?? Number.NEGATIVE_INFINITY
2792
+ });
2793
+ });
2794
+ }
2795
+ /**
2796
+ * Flat session list ("In one list"): every visible session as a top-level
2797
+ * row. `updated` is newest-first; `manual` keeps the session-list stored order.
2798
+ */
2799
+ function deriveFlat(list, archivedSessionIds, orderBy = "updated") {
2800
+ const archived = new Set(archivedSessionIds);
2801
+ const descendants = indexSubagentRunning(list.byId);
2802
+ const rows = [];
2803
+ for (const id of list.ids) {
2804
+ const summary = list.byId[id];
2805
+ if (summary === void 0) continue;
2806
+ if (summary.origin === "subagent") continue;
2807
+ if (archived.has(id)) continue;
2808
+ if (summary.blank && id !== list.current) continue;
2809
+ rows.push(summary);
2810
+ }
2811
+ if (orderBy === "updated") rows.sort((a, b) => byRecency({
2812
+ id: a.id,
2813
+ updatedAt: a.updatedAt ?? 0
2814
+ }, {
2815
+ id: b.id,
2816
+ updatedAt: b.updatedAt ?? 0
2817
+ }));
2818
+ return rows.map((session) => sessionNode(session, descendants));
2819
+ }
2820
+ /** Display label for the ungrouped bucket row. */
2821
+ const UNGROUPED_LABEL = "Ungrouped";
2822
+ /**
2823
+ * Directory display label: basename of the path (both separators accepted).
2824
+ * Ungrouped-bucket fallback for surfaces without a workspace title.
2825
+ */
2826
+ function workspaceLabel(cwd) {
2827
+ if (cwd === void 0 || cwd === "") return UNGROUPED_LABEL;
2828
+ const base = cwd.replace(/[/\\]+$/, "").split(/[/\\]/).pop();
2829
+ return base !== void 0 && base !== "" ? base : cwd;
2830
+ }
2831
+ /**
2832
+ * Keep controlled input and RPC payload inside the session.search wire
2833
+ * contract: strip NULs, cap at 500 UTF-16 code units, and never split a
2834
+ * surrogate pair at the cut.
2835
+ */
2836
+ function sanitizeSearchQuery(value) {
2837
+ const withoutNul = value.replaceAll("\0", "");
2838
+ if (withoutNul.length <= 500) return withoutNul;
2839
+ let end = 500;
2840
+ const last = withoutNul.charCodeAt(end - 1);
2841
+ const next = withoutNul.charCodeAt(end);
2842
+ if (last >= 55296 && last <= 56319 && next >= 56320 && next <= 57343) end -= 1;
2843
+ return withoutNul.slice(0, end);
2844
+ }
2845
+ /**
2846
+ * Compact relative time for session rows, as a structured bucket the
2847
+ * renderer localizes ("now"/"5min"/"3h"/"2d"/"4mo"/"1y" in en).
2848
+ */
2849
+ function relativeTime(updatedAt, now) {
2850
+ const MIN = 6e4;
2851
+ const HOUR = 36e5;
2852
+ const DAY = 864e5;
2853
+ const diff = Math.max(0, now - updatedAt);
2854
+ if (diff < MIN) return {
2855
+ unit: "now",
2856
+ n: 0
2857
+ };
2858
+ if (diff < HOUR) return {
2859
+ unit: "minutes",
2860
+ n: Math.floor(diff / MIN)
2861
+ };
2862
+ if (diff < DAY) return {
2863
+ unit: "hours",
2864
+ n: Math.floor(diff / HOUR)
2865
+ };
2866
+ if (diff < 30 * DAY) return {
2867
+ unit: "days",
2868
+ n: Math.floor(diff / DAY)
2869
+ };
2870
+ if (diff < 365 * DAY) return {
2871
+ unit: "months",
2872
+ n: Math.floor(diff / (30 * DAY))
2873
+ };
2874
+ return {
2875
+ unit: "years",
2876
+ n: Math.floor(diff / (365 * DAY))
2877
+ };
2878
+ }
2879
+ /** Localized compact relative time ("刚刚"/"5分钟" in zh, "now"/"5min" in en). */
2880
+ function timeLabel(updatedAt, now, t) {
2881
+ const { unit, n } = relativeTime(updatedAt, now);
2882
+ if (unit === "now") return t("time.now");
2883
+ if (unit === "minutes") return t("time.minutes", { n });
2884
+ if (unit === "hours") return t("time.hours", { n });
2885
+ if (unit === "days") return t("time.days", { n });
2886
+ if (unit === "months") return t("time.months", { n });
2887
+ return t("time.years", { n });
2888
+ }
2889
+ /** Hover-card variant: distances wrap in the ago template; the now bucket stays bare. */
2890
+ function hoverTimeLabel(updatedAt, now, t) {
2891
+ const { unit, n } = relativeTime(updatedAt, now);
2892
+ if (unit === "now") return t("time.now");
2893
+ return t("time.ago", { t: unit === "minutes" ? t("time.minutes", { n }) : unit === "hours" ? t("time.hours", { n }) : unit === "days" ? t("time.days", { n }) : unit === "months" ? t("time.months", { n }) : t("time.years", { n }) });
2894
+ }
2895
+ /**
2896
+ * Absolute creation time through the dictionary's date template (the message
2897
+ * clock pattern): `toLocaleString` would follow the browser language, not the
2898
+ * app locale.
2899
+ */
2900
+ function createdLabel(createdAt, t) {
2901
+ const d = new Date(createdAt);
2902
+ const pad2 = (v) => String(v).padStart(2, "0");
2903
+ return t("hover.created", { time: `${t("date.ymd", {
2904
+ y: d.getFullYear(),
2905
+ m: d.getMonth() + 1,
2906
+ d: d.getDate()
2907
+ })} ${pad2(d.getHours())}:${pad2(d.getMinutes())}` });
2908
+ }
2909
+ /** Ordinary sessions are visible; among blanks, only the current one. */
2910
+ function sessionVisible(session, current, archived) {
2911
+ return session.origin !== "subagent" && !archived.has(session.id) && (!session.blank || session.id === current);
2912
+ }
2913
+ /**
2914
+ * Merge immediate title/Workspace substring matches with ranked Host content
2915
+ * matches. Local rows lead newest-first, content-only rows retain backend
2916
+ * order, and duplicate sessions receive the backend snippet in place.
2917
+ */
2918
+ function deriveSearchResults(list, workspaces, query, archivedSessionIds, content, limit) {
2919
+ const q = query.trim().toLowerCase();
2920
+ if (q === "") return {
2921
+ items: [],
2922
+ hasMore: false
2923
+ };
2924
+ const archived = new Set(archivedSessionIds);
2925
+ const descendants = indexSubagentRunning(list.byId);
2926
+ const workspaceBySession = /* @__PURE__ */ new Map();
2927
+ for (const workspace of workspaces) for (const sessionId of workspace.sessionIds) if (!workspaceBySession.has(sessionId)) workspaceBySession.set(sessionId, workspace.title);
2928
+ const labelOf = (summary) => workspaceBySession.get(summary.id) ?? workspaceLabel(summary.cwd);
2929
+ const contentBySession = /* @__PURE__ */ new Map();
2930
+ for (const item of content.items) if (!contentBySession.has(item.sessionId)) contentBySession.set(item.sessionId, item);
2931
+ const local = [];
2932
+ for (const id of list.ids) {
2933
+ const summary = list.byId[id];
2934
+ if (summary === void 0 || summary.blank || !sessionVisible(summary, list.current, archived)) continue;
2935
+ if (sessionTitle(summary).toLowerCase().includes(q) || labelOf(summary).toLowerCase().includes(q)) local.push(summary);
2936
+ }
2937
+ local.sort((a, b) => byRecency({
2938
+ id: a.id,
2939
+ updatedAt: a.updatedAt ?? 0
2940
+ }, {
2941
+ id: b.id,
2942
+ updatedAt: b.updatedAt ?? 0
2943
+ }));
2944
+ const ordered = [];
2945
+ const included = /* @__PURE__ */ new Set();
2946
+ const include = (summary) => {
2947
+ if (included.has(summary.id)) return;
2948
+ included.add(summary.id);
2949
+ ordered.push(summary);
2950
+ };
2951
+ for (const summary of local) include(summary);
2952
+ for (const item of content.items) {
2953
+ const summary = list.byId[item.sessionId];
2954
+ if (summary !== void 0 && !summary.blank && sessionVisible(summary, list.current, archived)) include(summary);
2955
+ }
2956
+ return {
2957
+ items: ordered.slice(0, limit).map((summary) => {
2958
+ const match = contentBySession.get(summary.id);
2959
+ const node = sessionNode(summary, descendants);
2960
+ return {
2961
+ id: node.id,
2962
+ title: node.title,
2963
+ workspace: labelOf(summary),
2964
+ running: node.running,
2965
+ runningSubagentCount: node.runningSubagentCount,
2966
+ completed: node.completed,
2967
+ ...summary.pendingInteraction === void 0 ? {} : { pendingInteraction: summary.pendingInteraction },
2968
+ ...match === void 0 ? {} : { snippet: match.snippet }
2969
+ };
2970
+ }),
2971
+ hasMore: content.hasMore || ordered.length > limit
2972
+ };
2973
+ }
2974
+ //#endregion
2975
+ //#region \0git-worktree-css:D:\Code\dsh-worktree\src\client\sidebar-rows.module.css?inline
2976
+ const css$1 = "/* Native Rows.module_2050697429.css_2050697429 transplanted 1:1 (DSW tokens, row-in, reduced-motion).\n * Drag marker classes (dropBefore/dropAfter) are kept for P3; unused in P2. */\n\n.projectRow_2050697429,\n.sessionRow_2050697429 {\n cursor: pointer;\n user-select: none;\n color: var(--dsw-alias-label-primary);\n border-radius: 8px;\n align-items: center;\n gap: 6px;\n padding: 0 8px;\n display: flex;\n}\n\n.projectRow_2050697429:hover,\n.sessionRow_2050697429:hover,\n.sessionRow_2050697429.selected_2050697429 {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.searchResultRow_2050697429 {\n box-sizing: border-box;\n cursor: pointer;\n text-align: left;\n width: 100%;\n min-height: 48px;\n color: var(--dsw-alias-label-primary);\n background: 0 0;\n border: none;\n border-radius: 8px;\n flex-direction: column;\n align-items: stretch;\n padding: 4px 8px;\n display: flex;\n}\n\n.searchResultRow_2050697429:hover,\n.searchResultRow_2050697429.selected_2050697429 {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.searchResultHeading_2050697429 {\n align-items: center;\n min-width: 0;\n display: flex;\n}\n\n.searchResultTitle_2050697429 {\n text-overflow: ellipsis;\n white-space: nowrap;\n min-width: 0;\n margin-left: 4px;\n font-size: 14px;\n line-height: 20px;\n overflow: hidden;\n}\n\n.searchResultMeta_2050697429 {\n align-items: center;\n gap: 6px;\n min-width: 0;\n margin-left: 20px;\n display: flex;\n}\n\n.searchResultWorkspace_2050697429,\n.searchResultSnippet_2050697429 {\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 12px;\n line-height: 17px;\n overflow: hidden;\n}\n\n.searchResultWorkspace_2050697429 {\n max-width: 40%;\n color: var(--dsw-alias-label-tertiary);\n flex: none;\n}\n\n.searchResultSnippet_2050697429 {\n min-width: 0;\n color: var(--dsw-alias-label-secondary);\n flex: 1;\n}\n\n.projectRow_2050697429 {\n box-sizing: border-box;\n align-items: center;\n height: 34px;\n}\n\n.projectRow_2050697429 .rowActions_2050697429 {\n height: 20px;\n}\n\n.sessionRow_2050697429 {\n height: 32px;\n animation: row-in 0.15s var(--ds-ease-in-out);\n gap: 0;\n}\n\n.sessionRow_2050697429 .title_2050697429 {\n margin: 0 6px 0 4px;\n}\n\n.flatSessionRowWithoutStatus_2050697429 .title_2050697429 {\n margin-left: 0;\n}\n\n@keyframes row-in {\n 0% { opacity: 0; }\n}\n\n.slot_2050697429 {\n width: 16px;\n height: 20px;\n color: var(--dsw-alias-label-tertiary);\n flex: none;\n justify-content: center;\n align-items: center;\n display: inline-flex;\n}\n\n.visuallyHidden_2050697429 {\n clip: rect(0 0 0 0);\n white-space: nowrap;\n width: 1px;\n height: 1px;\n position: absolute;\n overflow: hidden;\n}\n\n.folderActive_2050697429 {\n color: var(--dsw-alias-state-business-primary);\n}\n\n.projectRow_2050697429 .chevron_2050697429 {\n display: none;\n}\n\n.projectRow_2050697429:hover .chevron_2050697429 {\n display: inline-flex;\n}\n\n.projectRow_2050697429:hover .folder_2050697429 {\n display: none;\n}\n\n.arrow_2050697429 {\n transition: transform 0.15s var(--ds-ease-in-out);\n}\n\n.arrowOpen_2050697429 {\n transform: rotate(90deg);\n}\n\n.projectText_2050697429 {\n flex-direction: column;\n flex: 1;\n gap: 2px;\n min-width: 0;\n display: flex;\n}\n\n.title_2050697429 {\n text-overflow: ellipsis;\n white-space: nowrap;\n min-width: 0;\n font-size: 14px;\n line-height: 20px;\n overflow: hidden;\n}\n\n.renameInput_2050697429 {\n border: 1px solid var(--dsw-alias-border-l2);\n background: var(--dsw-alias-button-elevated-fill);\n min-width: 0;\n color: inherit;\n border-radius: 4px;\n outline: none;\n padding: 0 2px;\n font-size: 14px;\n line-height: 20px;\n}\n\n.sessionRow_2050697429 .title_2050697429 {\n flex: 1;\n}\n\n.meta_2050697429 {\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 20px;\n overflow: hidden;\n}\n\n.time_2050697429 {\n color: var(--dsw-alias-label-tertiary);\n flex: none;\n font-size: 12px;\n line-height: 20px;\n}\n\n.dot_2050697429 {\n flex: none;\n}\n\n.rowActions_2050697429 {\n flex: none;\n align-items: center;\n gap: 12px;\n display: none;\n}\n\n.projectRow_2050697429:hover .rowActions_2050697429,\n.sessionRow_2050697429:hover .rowActions_2050697429,\n.projectRow_2050697429.menuOpen_2050697429 .rowActions_2050697429,\n.sessionRow_2050697429.menuOpen_2050697429 .rowActions_2050697429 {\n display: inline-flex;\n}\n\n.sessionRow_2050697429:hover .time_2050697429,\n.sessionRow_2050697429.menuOpen_2050697429 .time_2050697429 {\n display: none;\n}\n\n.projectRow_2050697429.menuOpen_2050697429,\n.sessionRow_2050697429.menuOpen_2050697429 {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n/* P3: session drag insertion markers (unused in P2). */\n.sessionRow_2050697429.dropBefore_2050697429,\n.sessionRow_2050697429.dropAfter_2050697429 {\n position: relative;\n}\n\n.sessionRow_2050697429.dropBefore_2050697429:before,\n.sessionRow_2050697429.dropAfter_2050697429:after {\n content: \"\";\n z-index: 1;\n background:\n linear-gradient(55deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 5px 7px no-repeat,\n linear-gradient(125deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 5px / 5px 7px no-repeat,\n linear-gradient(var(--dsw-alias-state-business-primary) 0 0) 4px 5px / calc(100% - 4px) 2px no-repeat;\n pointer-events: none;\n height: 12px;\n position: absolute;\n left: 0;\n right: 4px;\n}\n\n.sessionRow_2050697429.dropBefore_2050697429:before {\n top: -7px;\n}\n\n.sessionRow_2050697429.dropAfter_2050697429:after {\n bottom: -7px;\n}\n\n.hoverContent_2050697429 {\n flex-direction: column;\n gap: 8px;\n display: flex;\n}\n\n.hoverTitle_2050697429 {\n color: #fff;\n overflow-wrap: break-word;\n font-size: 14px;\n line-height: 20px;\n}\n\n.hoverPath_2050697429 {\n color: #cfd3d6;\n word-break: break-all;\n font-size: 12px;\n line-height: 16px;\n}\n\n.hoverTime_2050697429 {\n color: #cfd3d6;\n font-size: 12px;\n line-height: 16px;\n}\n\n.hoverStatus_2050697429 {\n color: #adb2b8;\n align-items: center;\n gap: 8px;\n font-size: 12px;\n line-height: 20px;\n display: flex;\n}\n\n.iconButton_2050697429 {\n cursor: pointer;\n width: 16px;\n height: 16px;\n color: var(--dsw-alias-label-tertiary);\n background: 0 0;\n border: none;\n border-radius: 4px;\n flex: none;\n justify-content: center;\n align-items: center;\n padding: 0;\n display: inline-flex;\n}\n\n.iconButton_2050697429:hover {\n color: var(--dsw-alias-label-primary);\n}\n\n.chevron_2050697429 {\n color: var(--dsw-alias-label-caption);\n}\n\n.repoCount_2050697429 {\n flex: none;\n margin-left: 8px;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 20px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .sessionRow_2050697429,\n .arrow_2050697429 {\n transition: none;\n animation: none;\n }\n}\n";
2977
+ const tagId$1 = "@laoyuehanni/dsh-git-worktree/sidebar-rows.module.css";
2978
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId$1 + "\"]") === null) {
2979
+ const tag = document.createElement("style");
2980
+ tag.dataset.plugin = "@laoyuehanni/dsh-git-worktree";
2981
+ tag.dataset.pluginCss = tagId$1;
2982
+ tag.textContent = css$1;
2983
+ document.head.appendChild(tag);
2984
+ }
2985
+ var sidebar_rows_module_default = {
2986
+ "module": "module_2050697429",
2987
+ "css": "css_2050697429",
2988
+ "projectRow": "projectRow_2050697429",
2989
+ "sessionRow": "sessionRow_2050697429",
2990
+ "selected": "selected_2050697429",
2991
+ "searchResultRow": "searchResultRow_2050697429",
2992
+ "searchResultHeading": "searchResultHeading_2050697429",
2993
+ "searchResultTitle": "searchResultTitle_2050697429",
2994
+ "searchResultMeta": "searchResultMeta_2050697429",
2995
+ "searchResultWorkspace": "searchResultWorkspace_2050697429",
2996
+ "searchResultSnippet": "searchResultSnippet_2050697429",
2997
+ "rowActions": "rowActions_2050697429",
2998
+ "title": "title_2050697429",
2999
+ "flatSessionRowWithoutStatus": "flatSessionRowWithoutStatus_2050697429",
3000
+ "slot": "slot_2050697429",
3001
+ "visuallyHidden": "visuallyHidden_2050697429",
3002
+ "folderActive": "folderActive_2050697429",
3003
+ "chevron": "chevron_2050697429",
3004
+ "folder": "folder_2050697429",
3005
+ "arrow": "arrow_2050697429",
3006
+ "arrowOpen": "arrowOpen_2050697429",
3007
+ "projectText": "projectText_2050697429",
3008
+ "renameInput": "renameInput_2050697429",
3009
+ "meta": "meta_2050697429",
3010
+ "time": "time_2050697429",
3011
+ "dot": "dot_2050697429",
3012
+ "menuOpen": "menuOpen_2050697429",
3013
+ "dropBefore": "dropBefore_2050697429",
3014
+ "dropAfter": "dropAfter_2050697429",
3015
+ "hoverContent": "hoverContent_2050697429",
3016
+ "hoverTitle": "hoverTitle_2050697429",
3017
+ "hoverPath": "hoverPath_2050697429",
3018
+ "hoverTime": "hoverTime_2050697429",
3019
+ "hoverStatus": "hoverStatus_2050697429",
3020
+ "iconButton": "iconButton_2050697429",
3021
+ "repoCount": "repoCount_2050697429"
3022
+ };
3023
+ //#endregion
3024
+ //#region src/client/sidebar-rows.tsx
3025
+ /**
3026
+ * Workspace / session / search row components transplanted from the native
3027
+ * `Rows.js` (injected props, no ctx). Hover swaps (folder→chevron, time→⋯)
3028
+ * are CSS-only. Drag wiring is intentionally omitted — P3.
3029
+ *
3030
+ * @module git-worktree/client/sidebar-rows
3031
+ */
3032
+ function cx$1(...parts) {
3033
+ return parts.filter((part) => typeof part === "string" && part !== "").join(" ");
3034
+ }
3035
+ /** Row display title: blank rows show the localized New Session label. */
3036
+ function displayTitle(node, t) {
3037
+ return node.blank ? t("session.new") : node.title;
3038
+ }
3039
+ /** Hover-card body: workspace title, display directory path, absolute creation time. */
3040
+ function WorkspaceHoverContent({ label, cwd, createdAt, t }) {
3041
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3042
+ className: sidebar_rows_module_default.hoverContent,
3043
+ children: [
3044
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3045
+ className: sidebar_rows_module_default.hoverTitle,
3046
+ children: label
3047
+ }),
3048
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3049
+ className: sidebar_rows_module_default.hoverPath,
3050
+ children: cwd
3051
+ }),
3052
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3053
+ className: sidebar_rows_module_default.hoverTime,
3054
+ children: createdLabel(createdAt, t)
3055
+ })
3056
+ ]
3057
+ });
3058
+ }
3059
+ /**
3060
+ * Project (workspace) header row: folder + title; hover reveals the chevron
3061
+ * and create button. `containsCurrent` is a derivation fact (no renderer scan).
3062
+ * Drag wiring is not transplanted (P3 — `useNativeDragAcceptance` stays vacant).
3063
+ */
3064
+ function ProjectRowItem({ row, onToggle, onCreate, actions, home, t, badge }) {
3065
+ const active = row.expanded && row.containsCurrent;
3066
+ const [menuOpen, setMenuOpen] = (0, react.useState)(false);
3067
+ const workspaceMenuItems = [{
3068
+ id: "rename",
3069
+ label: t("rename"),
3070
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEditOutline16, {})
3071
+ }, {
3072
+ id: "delete",
3073
+ label: t("delete.workspace"),
3074
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTrashOutline16, {}),
3075
+ danger: true
3076
+ }];
3077
+ const ownRow = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3078
+ className: cx$1(sidebar_rows_module_default.projectRow, menuOpen && sidebar_rows_module_default.menuOpen),
3079
+ role: "treeitem",
3080
+ "aria-expanded": row.expanded,
3081
+ onClick: onToggle,
3082
+ children: [
3083
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3084
+ className: cx$1(sidebar_rows_module_default.slot, sidebar_rows_module_default.folder, active && sidebar_rows_module_default.folderActive),
3085
+ children: row.expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderOpen16, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderClose16, {})
3086
+ }),
3087
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3088
+ className: cx$1(sidebar_rows_module_default.slot, sidebar_rows_module_default.chevron),
3089
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTriangleRightFill14, { className: cx$1(sidebar_rows_module_default.arrow, row.expanded && sidebar_rows_module_default.arrowOpen) })
3090
+ }),
3091
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3092
+ className: sidebar_rows_module_default.projectText,
3093
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3094
+ className: sidebar_rows_module_default.title,
3095
+ children: row.label
3096
+ })
3097
+ }),
3098
+ badge !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3099
+ className: sidebar_rows_module_default.repoCount,
3100
+ children: badge
3101
+ }) : null,
3102
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3103
+ className: sidebar_rows_module_default.rowActions,
3104
+ children: [actions !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
3105
+ open: menuOpen,
3106
+ onClose: () => {
3107
+ setMenuOpen(false);
3108
+ },
3109
+ items: workspaceMenuItems,
3110
+ onSelect: (id) => {
3111
+ setMenuOpen(false);
3112
+ if (id !== "rename" && id !== "delete") return;
3113
+ if (id === "rename") actions.rename();
3114
+ else actions.delete();
3115
+ },
3116
+ portal: true,
3117
+ closeOnPointerLeave: true,
3118
+ anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3119
+ type: "button",
3120
+ className: sidebar_rows_module_default.iconButton,
3121
+ "aria-label": t("actions.workspace.aria", { name: row.label }),
3122
+ onClick: (e) => {
3123
+ e.stopPropagation();
3124
+ setMenuOpen((v) => !v);
3125
+ },
3126
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEllipsisOutline16, {})
3127
+ })
3128
+ }), onCreate !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3129
+ type: "button",
3130
+ className: sidebar_rows_module_default.iconButton,
3131
+ "aria-label": t("actions.newSession.aria", { name: row.label }),
3132
+ onClick: (e) => {
3133
+ e.stopPropagation();
3134
+ onCreate();
3135
+ },
3136
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlusOutline16, {})
3137
+ })]
3138
+ })
3139
+ ]
3140
+ });
3141
+ if (row.createdAt === void 0) return ownRow;
3142
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.HoverCard, {
3143
+ anchor: ownRow,
3144
+ content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkspaceHoverContent, {
3145
+ label: row.label,
3146
+ cwd: row.cwd === void 0 ? void 0 : (0, _deepseek_ai_dsh_client_runtime_client.abbreviateHomePath)(row.cwd, home),
3147
+ createdAt: row.createdAt,
3148
+ t
3149
+ }),
3150
+ disabled: menuOpen,
3151
+ copyText: row.cwd,
3152
+ copyLabel: t("copy"),
3153
+ copiedLabel: t("hover.copied")
3154
+ });
3155
+ }
3156
+ function assertNever(value) {
3157
+ throw new Error(`unknown pending interaction: ${String(value)}`);
3158
+ }
3159
+ /** Session status presentation; pending interaction is primary and live activity outranks completion. */
3160
+ function sessionStatuses(node, t) {
3161
+ const subagents = node.runningSubagentCount === 0 ? void 0 : {
3162
+ state: "ongoing",
3163
+ label: t(node.runningSubagentCount === 1 ? "status.subagentsRunning.one" : "status.subagentsRunning.other", { n: node.runningSubagentCount })
3164
+ };
3165
+ let pending;
3166
+ switch (node.pendingInteraction) {
3167
+ case "approval":
3168
+ pending = {
3169
+ state: "warning",
3170
+ label: t("status.waitingApproval")
3171
+ };
3172
+ break;
3173
+ case "plan-review":
3174
+ pending = {
3175
+ state: "warning",
3176
+ label: t("status.planReview")
3177
+ };
3178
+ break;
3179
+ case "question":
3180
+ pending = {
3181
+ state: "warning",
3182
+ label: t("status.waitingAnswer")
3183
+ };
3184
+ break;
3185
+ case void 0: break;
3186
+ default: return assertNever(node.pendingInteraction);
3187
+ }
3188
+ if (pending !== void 0) return subagents === void 0 ? [pending] : [pending, subagents];
3189
+ if (node.running) {
3190
+ const primary = {
3191
+ state: "ongoing",
3192
+ label: t("status.running")
3193
+ };
3194
+ return subagents === void 0 ? [primary] : [primary, subagents];
3195
+ }
3196
+ if (subagents !== void 0) return [subagents];
3197
+ if (node.completed) return [{
3198
+ state: "done",
3199
+ label: t("status.completed")
3200
+ }];
3201
+ return [{
3202
+ state: "done",
3203
+ label: t("status.idle")
3204
+ }];
3205
+ }
3206
+ /** Primary status dot plus every status's screen-reader label. */
3207
+ function SessionStatusDots({ statuses }) {
3208
+ const primary = statuses[0];
3209
+ if (primary === void 0) return null;
3210
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: primary.state }), statuses.map((status) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3211
+ className: sidebar_rows_module_default.visuallyHidden,
3212
+ children: status.label
3213
+ }, status.label))] });
3214
+ }
3215
+ /** Hover-card body: full title, relative time, and every relevant live status. */
3216
+ function SessionHoverContent({ node, now, t }) {
3217
+ const statuses = sessionStatuses(node, t);
3218
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3219
+ className: sidebar_rows_module_default.hoverContent,
3220
+ children: [
3221
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3222
+ className: sidebar_rows_module_default.hoverTitle,
3223
+ children: displayTitle(node, t)
3224
+ }),
3225
+ !node.blank && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3226
+ className: sidebar_rows_module_default.hoverTime,
3227
+ children: hoverTimeLabel(node.updatedAt, now, t)
3228
+ }),
3229
+ statuses.map((status) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3230
+ className: sidebar_rows_module_default.hoverStatus,
3231
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: status.state }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: status.label })]
3232
+ }, status.label))
3233
+ ]
3234
+ });
3235
+ }
3236
+ /** One flat search result: title, Workspace context, and optional content excerpt. */
3237
+ function SearchResultItem({ result, currentId, onOpen, t }) {
3238
+ const selected = result.id === currentId;
3239
+ const statuses = sessionStatuses(result, t);
3240
+ const primaryStatus = statuses[0];
3241
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
3242
+ type: "button",
3243
+ className: cx$1(sidebar_rows_module_default.searchResultRow, selected && sidebar_rows_module_default.selected),
3244
+ role: "treeitem",
3245
+ "aria-selected": selected,
3246
+ onClick: () => {
3247
+ onOpen(result.id);
3248
+ },
3249
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3250
+ className: sidebar_rows_module_default.searchResultHeading,
3251
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3252
+ className: sidebar_rows_module_default.slot,
3253
+ children: primaryStatus !== void 0 && (primaryStatus.state !== "done" || result.completed) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionStatusDots, { statuses })
3254
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3255
+ className: sidebar_rows_module_default.searchResultTitle,
3256
+ children: result.title
3257
+ })]
3258
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3259
+ className: sidebar_rows_module_default.searchResultMeta,
3260
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3261
+ className: sidebar_rows_module_default.searchResultWorkspace,
3262
+ children: result.workspace
3263
+ }), result.snippet !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3264
+ className: sidebar_rows_module_default.searchResultSnippet,
3265
+ children: result.snippet
3266
+ })]
3267
+ })]
3268
+ });
3269
+ }
3270
+ /**
3271
+ * One 32px session row: status dot, title, relative time, hover ⋯ menu.
3272
+ * Drag wiring is not transplanted (P3).
3273
+ */
3274
+ function SessionNodeItem({ node, currentId, now, onOpen, onRename, onFork, onArchive, flat = false, t }) {
3275
+ const title = displayTitle(node, t);
3276
+ const selected = node.id === currentId;
3277
+ const statuses = sessionStatuses(node, t);
3278
+ const showStatus = statuses[0]?.state !== "done" || node.completed;
3279
+ const [menuOpen, setMenuOpen] = (0, react.useState)(false);
3280
+ const sessionMenuItems = [
3281
+ {
3282
+ id: "rename",
3283
+ label: t("rename"),
3284
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEditOutline16, {})
3285
+ },
3286
+ {
3287
+ id: "fork",
3288
+ label: t("menu.fork"),
3289
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconBranchOutline16, {})
3290
+ },
3291
+ {
3292
+ id: "archive",
3293
+ label: t("menu.archiveSession"),
3294
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconArchiveOutline20, { size: 16 })
3295
+ }
3296
+ ];
3297
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.HoverCard, {
3298
+ anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3299
+ className: cx$1(sidebar_rows_module_default.sessionRow, selected && sidebar_rows_module_default.selected, menuOpen && sidebar_rows_module_default.menuOpen, flat && !showStatus && sidebar_rows_module_default.flatSessionRowWithoutStatus),
3300
+ role: "treeitem",
3301
+ "aria-selected": selected,
3302
+ onClick: () => {
3303
+ onOpen(node.id);
3304
+ },
3305
+ children: [
3306
+ (!flat || showStatus) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3307
+ className: sidebar_rows_module_default.slot,
3308
+ children: showStatus && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionStatusDots, { statuses })
3309
+ }),
3310
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3311
+ className: sidebar_rows_module_default.title,
3312
+ children: title
3313
+ }),
3314
+ !node.blank && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3315
+ className: sidebar_rows_module_default.time,
3316
+ children: timeLabel(node.updatedAt, now, t)
3317
+ }),
3318
+ !node.blank && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3319
+ className: sidebar_rows_module_default.rowActions,
3320
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
3321
+ open: menuOpen,
3322
+ onClose: () => {
3323
+ setMenuOpen(false);
3324
+ },
3325
+ items: sessionMenuItems,
3326
+ onSelect: (id) => {
3327
+ setMenuOpen(false);
3328
+ if (id === "rename") onRename(node.id, node.title);
3329
+ if (id === "fork") onFork(node.id);
3330
+ if (id === "archive") onArchive(node.id);
3331
+ },
3332
+ portal: true,
3333
+ closeOnPointerLeave: true,
3334
+ anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3335
+ type: "button",
3336
+ className: sidebar_rows_module_default.iconButton,
3337
+ "aria-label": t("actions.session.aria", { name: title }),
3338
+ onClick: (e) => {
3339
+ e.stopPropagation();
3340
+ setMenuOpen((v) => !v);
3341
+ },
3342
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEllipsisOutline16, {})
3343
+ })
3344
+ })
3345
+ })
3346
+ ]
3347
+ }),
3348
+ content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionHoverContent, {
3349
+ node,
3350
+ now,
3351
+ t
3352
+ }),
3353
+ disabled: menuOpen,
3354
+ copyText: node.blank ? void 0 : node.title,
3355
+ copyLabel: t("copy"),
3356
+ copiedLabel: t("hover.copied")
3357
+ });
3358
+ }
3359
+ //#endregion
3360
+ //#region src/client/pick-flow.ts
3361
+ /**
3362
+ * Edge-triggered controller for one add-workspace flow.
3363
+ *
3364
+ * `sync(open)` mirrors the dialog's open flag: only a RISING edge (closed →
3365
+ * open) starts a pick — re-syncing `true` while a run is live is a no-op, so
3366
+ * the parent's re-renders (fresh inline callbacks and all) can never
3367
+ * re-launch the chooser or drop a finished pick the way an effect keyed on
3368
+ * unstable function deps would. A falling edge invalidates any in-flight
3369
+ * run: its eventual result is discarded without a callback. `kill()` is the
3370
+ * permanent teardown — nothing fires after it.
3371
+ */
3372
+ var PickFlowController = class {
3373
+ hooks;
3374
+ started = false;
3375
+ epoch = 0;
3376
+ /** Refresh the callbacks to the latest render's closures; never restarts a run. */
3377
+ attach(hooks) {
3378
+ this.hooks = hooks;
3379
+ }
3380
+ /** Sync with the dialog's open flag (see the class doc for the edge semantics). */
3381
+ sync(open) {
3382
+ if (open) {
3383
+ if (this.started) return;
3384
+ this.started = true;
3385
+ this.epoch += 1;
3386
+ this.run(this.epoch);
3387
+ return;
3388
+ }
3389
+ this.epoch += 1;
3390
+ this.started = false;
3391
+ }
3392
+ /** Permanent teardown (unmount): no callback fires afterwards. */
3393
+ kill() {
3394
+ this.epoch += 1;
3395
+ this.started = false;
3396
+ }
3397
+ async run(token) {
3398
+ const hooks = this.hooks;
3399
+ if (hooks === void 0) return;
3400
+ let path;
3401
+ try {
3402
+ path = await hooks.pickDirectory();
3403
+ } catch (reason) {
3404
+ if (token === this.epoch) hooks.onFailed(messageOf(reason));
3405
+ return;
3406
+ }
3407
+ if (token !== this.epoch) return;
3408
+ if (path === null || path === "") {
3409
+ hooks.onCancelled();
3410
+ return;
3411
+ }
3412
+ let workspace;
3413
+ try {
3414
+ workspace = await hooks.createWorkspace({ path });
3415
+ } catch (reason) {
3416
+ if (token === this.epoch) hooks.onFailed(messageOf(reason));
3417
+ return;
3418
+ }
3419
+ if (token !== this.epoch) return;
3420
+ hooks.onPicked(workspace.workspaceId);
3421
+ }
3422
+ };
3423
+ /** Error text for a rejection of any shape. */
3424
+ function messageOf(reason) {
3425
+ return reason instanceof Error ? reason.message : String(reason);
3426
+ }
3427
+ //#endregion
3428
+ //#region \0git-worktree-css:D:\Code\dsh-worktree\src\client\GroupedSidebar.module.css?inline
3429
+ const css = "/* Native WorkspaceBrowser.module_1808205761.css_1808205761 + WorkspacePicker.module_1808205761.css_1808205761 transplanted\n * 1:1 (DSW tokens, search expand, reduced-motion). Drag classes\n * (workspaceDrop*, listTopDrop*) are kept for P3; unused in P2.\n * Overlay: memberIndent / sessionsIndent for the repo-grouped tree. */\n\n.root_1808205761 {\n --dsh-session-list-edge-inset: var(--dsh-sidebar-inline-padding);\n --dsh-session-list-scrollbar-width: 8px;\n --dsh-session-list-scrollbar-offset: 2px;\n box-sizing: border-box;\n min-height: 0;\n padding-right: var(--dsh-session-list-edge-inset);\n flex-direction: column;\n flex: 1;\n display: flex;\n}\n\n.root_1808205761.rail_1808205761 {\n padding-right: 0;\n}\n\n.iconButton_1808205761 {\n cursor: pointer;\n width: 28px;\n height: 28px;\n color: var(--dsw-alias-label-secondary);\n background: 0 0;\n border: none;\n border-radius: 50%;\n flex: none;\n justify-content: center;\n align-items: center;\n padding: 0;\n display: inline-flex;\n}\n\n.iconButton_1808205761:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.sectionHeader_1808205761 {\n box-sizing: border-box;\n height: 36px;\n color: var(--dsw-alias-label-tertiary);\n border-radius: 12px;\n flex: none;\n justify-content: flex-end;\n align-items: center;\n gap: 4px;\n margin-bottom: 4px;\n padding-left: 4px;\n display: flex;\n overflow: hidden;\n}\n\n.root_1808205761:not(.rail_1808205761) .sectionHeader_1808205761 {\n margin-top: 2px;\n margin-right: -4px;\n}\n\n.sectionLabel_1808205761 {\n white-space: nowrap;\n opacity: 1;\n visibility: visible;\n min-width: 0;\n max-width: 45%;\n transition: max-width 0.18s var(--ds-ease-in-out), margin-right 0.18s var(--ds-ease-in-out), opacity 0.12s var(--ds-ease-in-out), transform 0.18s var(--ds-ease-in-out), visibility 0s linear;\n flex: none;\n line-height: 20px;\n overflow: hidden;\n}\n\n.sectionLabelHidden_1808205761 {\n opacity: 0;\n visibility: hidden;\n max-width: 0;\n margin-right: -4px;\n transition-delay: 0s, 0s, 0s, 0s, 0.18s;\n transform: translate(-4px);\n}\n\n.searchSlot_1808205761 {\n box-sizing: border-box;\n min-width: 0;\n max-width: 28px;\n transition: max-width 0.18s var(--ds-ease-in-out), padding-left 0.18s var(--ds-ease-in-out);\n flex: 1;\n align-items: center;\n margin-left: auto;\n padding-left: 0;\n display: flex;\n}\n\n.searchSlotExpanded_1808205761 {\n max-width: 100%;\n padding-left: 0;\n}\n\n.headerActions_1808205761 {\n opacity: 1;\n visibility: visible;\n max-width: 60px;\n transition: max-width 0.18s var(--ds-ease-in-out), opacity 0.12s var(--ds-ease-in-out), transform 0.18s var(--ds-ease-in-out), visibility 0s linear;\n flex: none;\n align-items: center;\n gap: 4px;\n display: flex;\n overflow: hidden;\n}\n\n.headerActionsHidden_1808205761 {\n opacity: 0;\n visibility: hidden;\n pointer-events: none;\n max-width: 0;\n transition-delay: 0s, 0s, 0s, 0.18s;\n transform: translate(4px);\n}\n\n.search_1808205761 {\n box-sizing: border-box;\n cursor: text;\n width: 100%;\n height: 28px;\n color: var(--dsw-alias-label-secondary);\n transition: width 0.18s var(--ds-ease-in-out), padding 0.18s var(--ds-ease-in-out), border-color 0.18s var(--ds-ease-in-out), background-color 0.18s var(--ds-ease-in-out);\n background: 0 0;\n border: none;\n border-radius: 50%;\n flex: none;\n align-items: center;\n gap: 0;\n margin: 0;\n padding: 0;\n display: flex;\n overflow: hidden;\n}\n\n.searchExpanded_1808205761 {\n border: 1px solid var(--dsw-alias-border-l2);\n width: calc(100% + 4px);\n height: 30px;\n color: var(--dsw-alias-label-caption);\n background: 0 0;\n border-radius: 10px;\n margin-inline: -2px;\n padding: 0 4px 0 0;\n}\n\n.searchButton_1808205761 {\n cursor: pointer;\n width: 28px;\n height: 28px;\n color: inherit;\n background: 0 0;\n border: none;\n border-radius: 50%;\n flex: none;\n justify-content: center;\n align-items: center;\n padding: 0;\n display: inline-flex;\n}\n\n.searchExpanded_1808205761 .searchButton_1808205761 {\n width: 28px;\n height: 30px;\n}\n\n.searchButton_1808205761:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.searchExpanded_1808205761 .searchButton_1808205761:hover {\n background: 0 0;\n}\n\n.searchInput_1808205761 {\n opacity: 0;\n pointer-events: none;\n width: 0;\n min-width: 0;\n color: var(--dsw-alias-label-primary);\n transition: opacity 0.12s var(--ds-ease-in-out);\n background: 0 0;\n border: none;\n outline: none;\n flex: 1;\n font-size: 13px;\n line-height: 18px;\n}\n\n.searchExpanded_1808205761 .searchInput_1808205761 {\n opacity: 1;\n pointer-events: auto;\n margin-left: -2px;\n}\n\n.searchInput_1808205761::placeholder {\n color: var(--dsw-alias-label-tertiary);\n}\n\n.clearButton_1808205761 {\n cursor: pointer;\n width: 24px;\n height: 24px;\n color: var(--dsw-alias-label-secondary);\n background: 0 0;\n border: none;\n border-radius: 50%;\n flex: none;\n justify-content: center;\n align-items: center;\n padding: 0;\n display: inline-flex;\n}\n\n.clearButton_1808205761:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.rail_1808205761 .sectionHeader_1808205761 {\n justify-content: flex-start;\n gap: 0;\n margin-bottom: 12px;\n padding-left: 0;\n}\n\n.rail_1808205761 .headerActions_1808205761 {\n max-width: none;\n}\n\n.rail_1808205761 .iconButton_1808205761 {\n width: 36px;\n height: 36px;\n color: var(--dsw-alias-label-primary);\n}\n\n.rail_1808205761 .search_1808205761 {\n background: 0 0;\n border-color: #0000;\n gap: 0;\n width: 36px;\n height: 36px;\n margin: 0 0 12px;\n padding: 0;\n}\n\n.rail_1808205761 .searchButton_1808205761 {\n width: 36px;\n height: 36px;\n color: var(--dsw-alias-label-primary);\n}\n\n.rail_1808205761 .searchButton_1808205761:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.listArea_1808205761 {\n min-height: 0;\n margin-left: -4px;\n margin-right: calc(-1 * var(--dsh-session-list-edge-inset));\n flex-direction: column;\n flex: 1;\n padding-left: 4px;\n display: flex;\n overflow: visible;\n}\n\n.rail_1808205761 .listArea_1808205761 {\n margin-left: 0;\n margin-right: 0;\n padding-left: 0;\n}\n\n.treeBody_1808205761 {\n flex-direction: column;\n flex: 1;\n min-height: 0;\n display: flex;\n position: relative;\n}\n\n.fade_1808205761 {\n left: 0;\n right: var(--dsh-session-list-edge-inset);\n background: linear-gradient(to bottom, transparent, var(--dsw-specific-sidebar-fill));\n pointer-events: none;\n height: 24px;\n position: absolute;\n bottom: 0;\n}\n\n.wide_1808205761 {\n animation: wide-in 0.2s var(--ds-ease-in-out);\n}\n\n@keyframes wide-in {\n 0% { opacity: 0; }\n}\n\n.list_1808205761 {\n min-height: 0;\n margin-left: -4px;\n margin-right: var(--dsh-session-list-scrollbar-offset);\n padding-left: 4px;\n padding-right: calc(var(--dsh-session-list-edge-inset) - var(--dsh-session-list-scrollbar-width) - var(--dsh-session-list-scrollbar-offset));\n scrollbar-gutter: stable;\n flex: 1;\n padding-bottom: 16px;\n overflow-y: auto;\n}\n\n.flatList_1808205761 > * + *,\n.searchTree_1808205761 > [role=treeitem] + [role=treeitem],\n.groupSection_1808205761 > * + * {\n margin-top: 2px;\n}\n\n.searchStatus_1808205761,\n.searchWarning_1808205761 {\n color: var(--dsw-alias-label-tertiary);\n padding: 10px 12px;\n font-size: 12px;\n line-height: 18px;\n}\n\n.searchWarning_1808205761 {\n color: var(--dsw-alias-label-secondary);\n}\n\n.groupSection_1808205761 {\n position: relative;\n}\n\n.groupSection_1808205761 + .groupSection_1808205761 {\n margin-top: 4px;\n}\n\n/* P3: workspace drag insertion markers (unused in P2). */\n.listTopDropIndicator_1808205761,\n.workspaceDropBefore_1808205761:before,\n.workspaceDropAfter_1808205761:after {\n content: \"\";\n z-index: 1;\n background:\n linear-gradient(55deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 5px 7px no-repeat,\n linear-gradient(125deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 5px / 5px 7px no-repeat,\n linear-gradient(var(--dsw-alias-state-business-primary) 0 0) 4px 5px / calc(100% - 4px) 2px no-repeat;\n pointer-events: none;\n height: 12px;\n position: absolute;\n left: 0;\n right: 0;\n}\n\n.listTopDropIndicator_1808205761 {\n top: -8px;\n left: 0;\n right: var(--dsh-session-list-edge-inset);\n}\n\n.listTopDropActive_1808205761 > .workspaceDropBefore_1808205761:first-child:before {\n display: none;\n}\n\n.workspaceDropBefore_1808205761:before {\n top: -8px;\n}\n\n.workspaceDropAfter_1808205761:after {\n bottom: -8px;\n}\n\n.sessionOverflowButton_1808205761 {\n cursor: pointer;\n text-align: left;\n width: 100%;\n height: 28px;\n color: var(--dsw-alias-label-tertiary);\n background: 0 0;\n border: none;\n border-radius: 8px;\n padding: 0 12px 0 28px;\n font-size: 12px;\n}\n\n.groupSection_1808205761 > .sessionOverflowButton_1808205761 {\n margin-top: 0;\n}\n\n.sessionOverflowButton_1808205761:hover {\n color: var(--dsw-alias-label-secondary);\n background: 0 0;\n}\n\n.empty_1808205761 {\n color: var(--dsw-alias-label-tertiary);\n padding: 16px 12px;\n font-size: 13px;\n}\n\n.renameInput_1808205761 {\n box-sizing: border-box;\n border: 1px solid var(--dsw-alias-border-l2);\n width: 100%;\n height: 44px;\n color: var(--dsw-alias-label-primary);\n background: 0 0;\n border-radius: 22px;\n outline: none;\n padding: 7px 14px;\n font-size: 14px;\n font-weight: 400;\n line-height: 22px;\n}\n\n.renameInput_1808205761:disabled {\n color: var(--dsw-alias-label-dimmed);\n}\n\n.renameError_1808205761 {\n color: var(--dsw-alias-state-error-primary);\n margin-top: 8px;\n font-size: 12px;\n line-height: 18px;\n}\n\n.deleteAction_1808205761:not(:disabled) {\n color: var(--dsw-alias-state-error-primary);\n}\n\n.deleteStatus_1808205761 {\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 18px;\n}\n\n.modalAction_1808205761 {\n min-width: 72px;\n}\n\n.modalError_1808205761,\n.menuStatus_1808205761 {\n margin-top: 8px;\n font-size: 12px;\n line-height: 18px;\n}\n\n.modalError_1808205761 {\n color: var(--dsw-alias-state-error-primary);\n}\n\n.menuStatus_1808205761 {\n color: var(--dsw-alias-label-secondary);\n}\n\n/* Aggregation overlay: indent member workspaces and their sessions. */\n.memberIndent_1808205761 {\n margin-left: 16px;\n}\n\n.sessionsIndent_1808205761 {\n margin-left: 8px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .wide_1808205761 {\n animation: none;\n }\n\n .search_1808205761,\n .sectionLabel_1808205761,\n .searchSlot_1808205761,\n .searchInput_1808205761,\n .headerActions_1808205761 {\n transition: none;\n }\n}\n";
3430
+ const tagId = "@laoyuehanni/dsh-git-worktree/GroupedSidebar.module.css";
3431
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId + "\"]") === null) {
3432
+ const tag = document.createElement("style");
3433
+ tag.dataset.plugin = "@laoyuehanni/dsh-git-worktree";
3434
+ tag.dataset.pluginCss = tagId;
3435
+ tag.textContent = css;
3436
+ document.head.appendChild(tag);
3437
+ }
3438
+ var GroupedSidebar_module_default = {
3439
+ "module": "module_1808205761",
3440
+ "css": "css_1808205761",
3441
+ "root": "root_1808205761",
3442
+ "rail": "rail_1808205761",
3443
+ "iconButton": "iconButton_1808205761",
3444
+ "sectionHeader": "sectionHeader_1808205761",
3445
+ "sectionLabel": "sectionLabel_1808205761",
3446
+ "sectionLabelHidden": "sectionLabelHidden_1808205761",
3447
+ "searchSlot": "searchSlot_1808205761",
3448
+ "searchSlotExpanded": "searchSlotExpanded_1808205761",
3449
+ "headerActions": "headerActions_1808205761",
3450
+ "headerActionsHidden": "headerActionsHidden_1808205761",
3451
+ "search": "search_1808205761",
3452
+ "searchExpanded": "searchExpanded_1808205761",
3453
+ "searchButton": "searchButton_1808205761",
3454
+ "searchInput": "searchInput_1808205761",
3455
+ "clearButton": "clearButton_1808205761",
3456
+ "listArea": "listArea_1808205761",
3457
+ "treeBody": "treeBody_1808205761",
3458
+ "fade": "fade_1808205761",
3459
+ "wide": "wide_1808205761",
3460
+ "list": "list_1808205761",
3461
+ "flatList": "flatList_1808205761",
3462
+ "searchTree": "searchTree_1808205761",
3463
+ "groupSection": "groupSection_1808205761",
3464
+ "searchStatus": "searchStatus_1808205761",
3465
+ "searchWarning": "searchWarning_1808205761",
3466
+ "listTopDropIndicator": "listTopDropIndicator_1808205761",
3467
+ "workspaceDropBefore": "workspaceDropBefore_1808205761",
3468
+ "workspaceDropAfter": "workspaceDropAfter_1808205761",
3469
+ "listTopDropActive": "listTopDropActive_1808205761",
3470
+ "sessionOverflowButton": "sessionOverflowButton_1808205761",
3471
+ "empty": "empty_1808205761",
3472
+ "renameInput": "renameInput_1808205761",
3473
+ "renameError": "renameError_1808205761",
3474
+ "deleteAction": "deleteAction_1808205761",
3475
+ "deleteStatus": "deleteStatus_1808205761",
3476
+ "modalAction": "modalAction_1808205761",
3477
+ "modalError": "modalError_1808205761",
3478
+ "menuStatus": "menuStatus_1808205761",
3479
+ "memberIndent": "memberIndent_1808205761",
3480
+ "sessionsIndent": "sessionsIndent_1808205761"
3481
+ };
3482
+ //#endregion
3483
+ //#region src/client/GroupedSidebar.tsx
3484
+ /**
3485
+ * GroupedSidebar: the `sidebar.workspaces` seat occupant. P1 aggregation
3486
+ * (same-repository workspaces clustered from /group facts) plus a 1:1
3487
+ * transplant of the native workspace browser's search, menus, status dots,
3488
+ * relative time, view options, rail, and dialogs.
3489
+ *
3490
+ * Drag-reorder and the native `dsh.workspace.view.v5` store are P3. Adding a
3491
+ * workspace uses `workspaces.pickDirectory` rather than re-declaring the
3492
+ * `sidebar.workspaces.directoryFlow` child hole (native already declared it;
3493
+ * a second declarer throws).
3494
+ *
3495
+ * @module git-worktree/client/GroupedSidebar
3496
+ */
3497
+ function cx(...parts) {
3498
+ return parts.filter((part) => typeof part === "string" && part !== "").join(" ");
3499
+ }
3500
+ function ViewOptionsMenu({ groupBy, orderBy, onGroupPick, onOrderPick, t }) {
3501
+ const [open, setOpen] = (0, react.useState)(false);
3502
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
3503
+ open,
3504
+ onClose: () => {
3505
+ setOpen(false);
3506
+ },
3507
+ items: [
3508
+ {
3509
+ type: "label",
3510
+ id: "group-by",
3511
+ text: t("groupBy.label")
3512
+ },
3513
+ {
3514
+ id: "workspace",
3515
+ label: t("groupBy.workspace")
3516
+ },
3517
+ {
3518
+ id: "flat",
3519
+ label: t("groupBy.flat")
3520
+ },
3521
+ {
3522
+ type: "separator",
3523
+ id: "order-by-separator"
3524
+ },
3525
+ {
3526
+ type: "label",
3527
+ id: "order-by",
3528
+ text: t("orderBy.label")
3529
+ },
3530
+ {
3531
+ id: "manual",
3532
+ label: t("orderBy.manual")
3533
+ },
3534
+ {
3535
+ id: "updated",
3536
+ label: t("orderBy.updated")
3537
+ }
3538
+ ],
3539
+ selectedIds: [groupBy, orderBy],
3540
+ onSelect: (id) => {
3541
+ if (id === "workspace" || id === "flat") onGroupPick(id);
3542
+ else if (id === "manual" || id === "updated") onOrderPick(id);
3543
+ setOpen(false);
3544
+ },
3545
+ align: "end",
3546
+ dense: true,
3547
+ portal: true,
3548
+ anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
3549
+ label: t("viewOptions.label"),
3550
+ side: "bottom",
3551
+ delayMs: 500,
3552
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3553
+ type: "button",
3554
+ className: cx(GroupedSidebar_module_default.iconButton, GroupedSidebar_module_default.wide),
3555
+ "aria-label": t("viewOptions.label"),
3556
+ onClick: () => {
3557
+ setOpen((v) => !v);
3558
+ },
3559
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPersonalizationOutline16, {})
3560
+ })
3561
+ })
3562
+ });
3563
+ }
3564
+ /** Add-workspace flow: OS directory picker (cannot redeclare native's directoryFlow hole). */
3565
+ function WorkspacePickFlow({ open, onClose, onRetry, pickDirectory, createWorkspace, onPick, t }) {
3566
+ const [errorOpen, setErrorOpen] = (0, react.useState)(false);
3567
+ const [modalError, setModalError] = (0, react.useState)(null);
3568
+ const controllerRef = (0, react.useRef)(null);
3569
+ const controller = controllerRef.current ?? (controllerRef.current = new PickFlowController());
3570
+ controller.attach({
3571
+ pickDirectory,
3572
+ createWorkspace,
3573
+ onPicked: onPick,
3574
+ onCancelled: onClose,
3575
+ onFailed: (message) => {
3576
+ setModalError(message);
3577
+ setErrorOpen(true);
3578
+ onClose();
3579
+ }
3580
+ });
3581
+ (0, react.useEffect)(() => {
3582
+ controller.sync(open);
3583
+ }, [open, controller]);
3584
+ (0, react.useEffect)(() => () => {
3585
+ controller.kill();
3586
+ }, [controller]);
3587
+ const closeModal = () => {
3588
+ setErrorOpen(false);
3589
+ setModalError(null);
3590
+ };
3591
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
3592
+ open: errorOpen,
3593
+ onClose: closeModal,
3594
+ closeLabel: t("close"),
3595
+ title: t("folderError.title"),
3596
+ footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3597
+ variant: "outline",
3598
+ className: GroupedSidebar_module_default.modalAction,
3599
+ onClick: closeModal,
3600
+ children: t("cancel")
3601
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3602
+ variant: "primary",
3603
+ className: GroupedSidebar_module_default.modalAction,
3604
+ onClick: () => {
3605
+ closeModal();
3606
+ onRetry();
3607
+ },
3608
+ children: t("folderError.retry")
3609
+ })] }),
3610
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3611
+ className: GroupedSidebar_module_default.modalError,
3612
+ role: "alert",
3613
+ children: modalError
3614
+ })
3615
+ });
3616
+ }
3617
+ function SearchResults({ list, workspaces, archivedSessionIds, query, remote, resultLimit, currentId, onOpen, t }) {
3618
+ const currentRemote = remote.query === query ? remote : {
3619
+ query,
3620
+ status: "loading",
3621
+ items: [],
3622
+ hasMore: false
3623
+ };
3624
+ const results = (0, react.useMemo)(() => deriveSearchResults(list, workspaces, query, archivedSessionIds, currentRemote, resultLimit), [
3625
+ list,
3626
+ workspaces,
3627
+ query,
3628
+ archivedSessionIds,
3629
+ currentRemote,
3630
+ resultLimit
3631
+ ]);
3632
+ const pending = currentRemote.status === "loading";
3633
+ const failed = currentRemote.status === "error";
3634
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3635
+ className: cx(GroupedSidebar_module_default.treeBody, GroupedSidebar_module_default.wide),
3636
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3637
+ className: GroupedSidebar_module_default.list,
3638
+ children: [
3639
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3640
+ className: GroupedSidebar_module_default.searchTree,
3641
+ role: "tree",
3642
+ "aria-label": t("search.results.aria"),
3643
+ children: results.items.map((result) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SearchResultItem, {
3644
+ result,
3645
+ currentId,
3646
+ onOpen,
3647
+ t
3648
+ }, result.id))
3649
+ }),
3650
+ pending && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3651
+ className: GroupedSidebar_module_default.searchStatus,
3652
+ role: "status",
3653
+ children: t("search.pending")
3654
+ }),
3655
+ failed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3656
+ className: GroupedSidebar_module_default.searchWarning,
3657
+ role: "status",
3658
+ children: t("search.unavailable")
3659
+ }),
3660
+ !pending && results.items.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3661
+ className: GroupedSidebar_module_default.empty,
3662
+ children: t("search.noMatches")
3663
+ }),
3664
+ results.hasMore && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3665
+ className: GroupedSidebar_module_default.searchStatus,
3666
+ children: t("search.hasMore", { n: resultLimit })
3667
+ })
3668
+ ]
3669
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: GroupedSidebar_module_default.fade })]
3670
+ });
3671
+ }
3672
+ function FlatListBody({ list, archivedSessionIds, orderBy, currentId, now, onOpen, onRename, onFork, onArchive, t }) {
3673
+ const rows = (0, react.useMemo)(() => deriveFlat(list, archivedSessionIds, orderBy), [
3674
+ list,
3675
+ archivedSessionIds,
3676
+ orderBy
3677
+ ]);
3678
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3679
+ className: cx(GroupedSidebar_module_default.treeBody, GroupedSidebar_module_default.wide),
3680
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3681
+ className: cx(GroupedSidebar_module_default.list, GroupedSidebar_module_default.flatList),
3682
+ role: "tree",
3683
+ "aria-label": t("section.sessions"),
3684
+ children: [rows.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3685
+ className: GroupedSidebar_module_default.empty,
3686
+ children: t("empty.none")
3687
+ }), rows.map((node) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionNodeItem, {
3688
+ node,
3689
+ currentId,
3690
+ now,
3691
+ onOpen,
3692
+ onRename,
3693
+ onFork,
3694
+ onArchive,
3695
+ flat: true,
3696
+ t
3697
+ }, node.id))]
3698
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: GroupedSidebar_module_default.fade })]
3699
+ });
3700
+ }
3701
+ function memberLabel(member, t) {
3702
+ if (member.label.type === "main") return member.label.branch === null ? t("sidebarMain") : t("sidebarMainBranch", { branch: member.label.branch });
3703
+ if (member.label.type === "linked") return member.label.branch ?? member.workspace.title;
3704
+ return member.workspace.title;
3705
+ }
3706
+ function createdAtMs(createdAt) {
3707
+ if (createdAt === void 0 || createdAt === "") return void 0;
3708
+ const parsed = Date.parse(createdAt);
3709
+ return Number.isNaN(parsed) ? void 0 : parsed;
3710
+ }
3711
+ function GroupedTree({ groups, sessions, archived, currentSessionId, expandMap, onToggle, expandTo, orderBy, now, home, onOpen, onRename, onFork, onArchive, onWorkspaceRename, onWorkspaceDelete, startSession, t }) {
3712
+ const descendants = (0, react.useMemo)(() => indexSubagentRunning(sessions.byId), [sessions.byId]);
3713
+ const [expandedSessionGroups, setExpandedSessionGroups] = (0, react.useState)([]);
3714
+ const empty = groups.length === 0;
3715
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3716
+ className: cx(GroupedSidebar_module_default.treeBody, GroupedSidebar_module_default.wide),
3717
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3718
+ className: GroupedSidebar_module_default.list,
3719
+ role: "tree",
3720
+ "aria-label": t("section.workspaces"),
3721
+ children: [empty && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3722
+ className: GroupedSidebar_module_default.empty,
3723
+ children: t("empty.none")
3724
+ }), groups.map((group) => {
3725
+ if (group.kind === "repo") {
3726
+ const memberIds = group.members.map((member) => orderedVisibleSessionIds(member.workspace, sessions, archived, orderBy));
3727
+ const visibleCount = memberIds.reduce((sum, ids) => sum + ids.length, 0);
3728
+ const containsCurrent = group.members.some((member) => member.workspace.sessionIds.includes(currentSessionId ?? "\0"));
3729
+ const open = expandMap[group.key] ?? containsCurrent;
3730
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3731
+ className: GroupedSidebar_module_default.groupSection,
3732
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProjectRowItem, {
3733
+ row: {
3734
+ key: group.key,
3735
+ label: group.repoName ?? group.key,
3736
+ expanded: open,
3737
+ containsCurrent
3738
+ },
3739
+ onToggle: () => {
3740
+ onToggle(group.key);
3741
+ },
3742
+ home,
3743
+ t,
3744
+ badge: String(visibleCount)
3745
+ }), open && group.members.map((member, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemberBlock, {
3746
+ member,
3747
+ indent: true,
3748
+ sessionIds: memberIds[index] ?? [],
3749
+ sessions,
3750
+ currentSessionId,
3751
+ expandMap,
3752
+ onToggle,
3753
+ expandTo,
3754
+ descendants,
3755
+ expandedSessionGroups,
3756
+ setExpandedSessionGroups,
3757
+ now,
3758
+ home,
3759
+ onOpen,
3760
+ onRename,
3761
+ onFork,
3762
+ onArchive,
3763
+ onWorkspaceRename,
3764
+ onWorkspaceDelete,
3765
+ startSession,
3766
+ t
3767
+ }, member.workspace.workspaceId))]
3768
+ }, group.key);
3769
+ }
3770
+ const member = group.members[0];
3771
+ if (member === void 0) return null;
3772
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3773
+ className: GroupedSidebar_module_default.groupSection,
3774
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemberBlock, {
3775
+ member,
3776
+ indent: false,
3777
+ sessionIds: orderedVisibleSessionIds(member.workspace, sessions, archived, orderBy),
3778
+ sessions,
3779
+ currentSessionId,
3780
+ expandMap,
3781
+ onToggle,
3782
+ expandTo,
3783
+ descendants,
3784
+ expandedSessionGroups,
3785
+ setExpandedSessionGroups,
3786
+ now,
3787
+ home,
3788
+ onOpen,
3789
+ onRename,
3790
+ onFork,
3791
+ onArchive,
3792
+ onWorkspaceRename,
3793
+ onWorkspaceDelete,
3794
+ startSession,
3795
+ t
3796
+ })
3797
+ }, group.key);
3798
+ })]
3799
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: GroupedSidebar_module_default.fade })]
3800
+ });
3801
+ }
3802
+ function MemberBlock({ member, indent, sessionIds, sessions, currentSessionId, expandMap, onToggle, expandTo, descendants, expandedSessionGroups, setExpandedSessionGroups, now, home, onOpen, onRename, onFork, onArchive, onWorkspaceRename, onWorkspaceDelete, startSession, t }) {
3803
+ const key = `ws:${member.workspace.workspaceId}`;
3804
+ const containsCurrent = member.workspace.sessionIds.includes(currentSessionId ?? "\0");
3805
+ const open = expandMap[key] ?? containsCurrent;
3806
+ const label = memberLabel(member, t);
3807
+ const overflowOpen = expandedSessionGroups.includes(key);
3808
+ const visibleIds = overflowOpen ? sessionIds : sessionIds.slice(0, 5);
3809
+ const nodes = [];
3810
+ for (const sessionId of visibleIds) {
3811
+ const summary = sessions.byId[sessionId];
3812
+ if (summary !== void 0) nodes.push(sessionNode(summary, descendants));
3813
+ }
3814
+ const created = createdAtMs(member.workspace.createdAt);
3815
+ const body = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProjectRowItem, {
3816
+ row: {
3817
+ key,
3818
+ label,
3819
+ expanded: open,
3820
+ containsCurrent,
3821
+ cwd: member.workspace.path,
3822
+ ...created === void 0 ? {} : { createdAt: created }
3823
+ },
3824
+ onToggle: () => {
3825
+ onToggle(key);
3826
+ },
3827
+ onCreate: () => {
3828
+ expandTo(key);
3829
+ startSession(member.workspace.workspaceId);
3830
+ },
3831
+ actions: {
3832
+ rename: () => {
3833
+ onWorkspaceRename(member.workspace.workspaceId, member.workspace.title);
3834
+ },
3835
+ delete: () => {
3836
+ onWorkspaceDelete(member.workspace.workspaceId, member.workspace.title);
3837
+ }
3838
+ },
3839
+ home,
3840
+ t
3841
+ }), open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3842
+ className: indent ? GroupedSidebar_module_default.sessionsIndent : void 0,
3843
+ children: [nodes.map((node) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionNodeItem, {
3844
+ node,
3845
+ currentId: currentSessionId,
3846
+ now,
3847
+ onOpen,
3848
+ onRename,
3849
+ onFork,
3850
+ onArchive,
3851
+ t
3852
+ }, node.id)), sessionIds.length > 5 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3853
+ type: "button",
3854
+ className: GroupedSidebar_module_default.sessionOverflowButton,
3855
+ "aria-expanded": overflowOpen,
3856
+ onClick: () => {
3857
+ setExpandedSessionGroups((keys) => keys.includes(key) ? keys.filter((k) => k !== key) : [...keys, key]);
3858
+ },
3859
+ children: overflowOpen ? t("sessions.collapse") : t("sessions.expand", { n: sessionIds.length - 5 })
3860
+ })]
3861
+ })] });
3862
+ return indent ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3863
+ className: GroupedSidebar_module_default.memberIndent,
3864
+ children: body
3865
+ }) : body;
3866
+ }
3867
+ function GroupedSidebar(props) {
3868
+ const { t } = props;
3869
+ const workspaces = (0, react.useSyncExternalStore)(props.workspacesList.subscribe, props.workspacesList.getSnapshot);
3870
+ const sessions = (0, react.useSyncExternalStore)(props.sessionsList.subscribe, props.sessionsList.getSnapshot);
3871
+ const host = (0, react.useSyncExternalStore)(props.hostDescription.subscribe, props.hostDescription.getSnapshot);
3872
+ const directoryFlowAvailable = (0, react.useSyncExternalStore)(props.directoryFlow.subscribe, props.directoryFlow.getSnapshot);
3873
+ const items = workspaces.items;
3874
+ const home = host?.home;
3875
+ const signature = (0, react.useMemo)(() => [...items].map((item) => item.path).sort().join("\n"), [items]);
3876
+ const [factsState, setFactsState] = (0, react.useState)(null);
3877
+ const readyOnce = (0, react.useRef)(false);
3878
+ const signalReady = () => {
3879
+ if (readyOnce.current) return;
3880
+ readyOnce.current = true;
3881
+ props.onReady?.();
3882
+ };
3883
+ (0, react.useEffect)(() => {
3884
+ if (factsState?.signature === signature) {
3885
+ signalReady();
3886
+ return;
3887
+ }
3888
+ let live = true;
3889
+ props.loadFacts(items.map((item) => item.path)).then((facts) => {
3890
+ if (!live) return;
3891
+ if (facts !== void 0) setFactsState({
3892
+ signature,
3893
+ facts
3894
+ });
3895
+ signalReady();
3896
+ }, () => {
3897
+ if (live) signalReady();
3898
+ });
3899
+ return () => {
3900
+ live = false;
3901
+ };
3902
+ }, [
3903
+ signature,
3904
+ factsState?.signature,
3905
+ props.loadFacts,
3906
+ items
3907
+ ]);
3908
+ const facts = factsState?.signature === signature ? factsState.facts : void 0;
3909
+ const groups = (0, react.useMemo)(() => deriveSidebarGroups(items, facts), [items, facts]);
3910
+ const sessionList = sessions;
3911
+ const archived = workspaces.archivedSessionIds;
3912
+ const [expandMap, setExpandMap] = (0, react.useState)(() => loadExpandState());
3913
+ const toggle = (key) => {
3914
+ const next = {
3915
+ ...expandMap,
3916
+ [key]: !(expandMap[key] ?? false)
3917
+ };
3918
+ setExpandMap(next);
3919
+ saveExpandState(next);
3920
+ };
3921
+ const expandTo = (key) => {
3922
+ if (expandMap[key] === true) return;
3923
+ const next = {
3924
+ ...expandMap,
3925
+ [key]: true
3926
+ };
3927
+ setExpandMap(next);
3928
+ saveExpandState(next);
3929
+ };
3930
+ const [viewPrefs, setViewPrefs] = (0, react.useState)(() => loadViewPrefs());
3931
+ const setGroupBy = (groupBy) => {
3932
+ const next = {
3933
+ ...viewPrefs,
3934
+ groupBy
3935
+ };
3936
+ setViewPrefs(next);
3937
+ saveViewPrefs(next);
3938
+ };
3939
+ const setOrderBy = (orderBy) => {
3940
+ const next = {
3941
+ ...viewPrefs,
3942
+ orderBy
3943
+ };
3944
+ setViewPrefs(next);
3945
+ saveViewPrefs(next);
3946
+ };
3947
+ const [query, setQuery] = (0, react.useState)("");
3948
+ const [searchExpanded, setSearchExpanded] = (0, react.useState)(false);
3949
+ const normalizedQuery = sanitizeSearchQuery(query).trim();
3950
+ const [remoteSearch, setRemoteSearch] = (0, react.useState)({
3951
+ query: "",
3952
+ status: "idle",
3953
+ items: [],
3954
+ hasMore: false
3955
+ });
3956
+ const searchRoot = (0, react.useRef)(null);
3957
+ const searchInput = (0, react.useRef)(null);
3958
+ const [wsPickerOpen, setWsPickerOpen] = (0, react.useState)(false);
3959
+ const composingRef = (0, react.useRef)(false);
3960
+ const [searchOnExpand, setSearchOnExpand] = (0, react.useState)(false);
3961
+ (0, react.useEffect)(() => {
3962
+ if (props.wide && searchOnExpand) {
3963
+ const timer = window.setTimeout(() => {
3964
+ searchInput.current?.focus({ preventScroll: true });
3965
+ setSearchOnExpand(false);
3966
+ }, 300);
3967
+ return () => {
3968
+ window.clearTimeout(timer);
3969
+ };
3970
+ }
3971
+ }, [props.wide, searchOnExpand]);
3972
+ (0, react.useEffect)(() => {
3973
+ if (!props.wide || !searchExpanded || searchOnExpand) return;
3974
+ searchInput.current?.focus({ preventScroll: true });
3975
+ }, [
3976
+ props.wide,
3977
+ searchExpanded,
3978
+ searchOnExpand
3979
+ ]);
3980
+ (0, react.useEffect)(() => {
3981
+ if (!props.wide || !searchExpanded || searchOnExpand) return;
3982
+ const onClick = (event) => {
3983
+ if (!(event.target instanceof Node) || searchRoot.current?.contains(event.target) === true) return;
3984
+ searchInput.current?.blur();
3985
+ if (normalizedQuery !== "") return;
3986
+ setSearchExpanded(false);
3987
+ };
3988
+ document.addEventListener("click", onClick);
3989
+ return () => {
3990
+ document.removeEventListener("click", onClick);
3991
+ };
3992
+ }, [
3993
+ normalizedQuery,
3994
+ props.wide,
3995
+ searchExpanded,
3996
+ searchOnExpand
3997
+ ]);
3998
+ (0, react.useEffect)(() => {
3999
+ if (normalizedQuery === "") {
4000
+ setRemoteSearch({
4001
+ query: "",
4002
+ status: "idle",
4003
+ items: [],
4004
+ hasMore: false
4005
+ });
4006
+ return;
4007
+ }
4008
+ const controller = new AbortController();
4009
+ setRemoteSearch({
4010
+ query: normalizedQuery,
4011
+ status: "loading",
4012
+ items: [],
4013
+ hasMore: false
4014
+ });
4015
+ const timer = window.setTimeout(() => {
4016
+ props.searchSessions(normalizedQuery, controller.signal).then((result) => {
4017
+ if (controller.signal.aborted) return;
4018
+ setRemoteSearch({
4019
+ query: normalizedQuery,
4020
+ status: "ready",
4021
+ items: result.items,
4022
+ hasMore: result.hasMore
4023
+ });
4024
+ }).catch(() => {
4025
+ if (controller.signal.aborted) return;
4026
+ setRemoteSearch({
4027
+ query: normalizedQuery,
4028
+ status: "error",
4029
+ items: [],
4030
+ hasMore: false
4031
+ });
4032
+ });
4033
+ }, 250);
4034
+ return () => {
4035
+ window.clearTimeout(timer);
4036
+ controller.abort();
4037
+ };
4038
+ }, [normalizedQuery, props.searchSessions]);
4039
+ const [renameTarget, setRenameTarget] = (0, react.useState)(null);
4040
+ const [renameDraft, setRenameDraft] = (0, react.useState)("");
4041
+ const [renaming, setRenaming] = (0, react.useState)(false);
4042
+ const [renameError, setRenameError] = (0, react.useState)(null);
4043
+ const renameTrimmed = renameDraft.trim();
4044
+ const renameDuplicate = renameTarget !== null && renameTrimmed !== "" && renameTrimmed !== renameTarget.currentTitle && items.some((w) => w.title === renameTrimmed);
4045
+ const renameBlocked = renaming || renameTrimmed === "" || renameTarget === null || renameTrimmed === renameTarget.currentTitle || renameDuplicate;
4046
+ const closeRename = () => {
4047
+ if (renaming) return;
4048
+ setRenameTarget(null);
4049
+ setRenameError(null);
4050
+ };
4051
+ const confirmRename = () => {
4052
+ if (renameBlocked || renameTarget === null) return;
4053
+ setRenaming(true);
4054
+ setRenameError(null);
4055
+ props.renameWorkspace(renameTarget.workspaceId, renameTrimmed).then(() => {
4056
+ setRenaming(false);
4057
+ setRenameTarget(null);
4058
+ }).catch((reason) => {
4059
+ setRenaming(false);
4060
+ setRenameError(reason instanceof Error ? reason.message : String(reason));
4061
+ });
4062
+ };
4063
+ const [sessionRenameTarget, setSessionRenameTarget] = (0, react.useState)(null);
4064
+ const [sessionRenameDraft, setSessionRenameDraft] = (0, react.useState)("");
4065
+ const [sessionRenaming, setSessionRenaming] = (0, react.useState)(false);
4066
+ const [sessionRenameError, setSessionRenameError] = (0, react.useState)(null);
4067
+ const sessionRenameTrimmed = sessionRenameDraft.trim();
4068
+ const sessionRenameBlocked = sessionRenaming || sessionRenameTrimmed === "" || sessionRenameTarget === null;
4069
+ const closeSessionRename = () => {
4070
+ if (sessionRenaming) return;
4071
+ setSessionRenameTarget(null);
4072
+ setSessionRenameError(null);
4073
+ };
4074
+ const confirmSessionRename = () => {
4075
+ if (sessionRenameBlocked || sessionRenameTarget === null) return;
4076
+ setSessionRenaming(true);
4077
+ setSessionRenameError(null);
4078
+ props.renameSession(sessionRenameTarget.sessionId, sessionRenameTrimmed).then(() => {
4079
+ setSessionRenaming(false);
4080
+ setSessionRenameTarget(null);
4081
+ }).catch((reason) => {
4082
+ setSessionRenaming(false);
4083
+ setSessionRenameError(reason instanceof Error ? reason.message : String(reason));
4084
+ });
4085
+ };
4086
+ const onSessionRename = (sessionId, currentTitle) => {
4087
+ setSessionRenameTarget({
4088
+ sessionId,
4089
+ currentTitle
4090
+ });
4091
+ setSessionRenameDraft(currentTitle);
4092
+ setSessionRenameError(null);
4093
+ };
4094
+ const onSessionArchive = (sessionId) => {
4095
+ props.archiveSession(sessionId).catch((reason) => {
4096
+ console.warn("session archive rejected:", reason);
4097
+ });
4098
+ };
4099
+ const [deleteTarget, setDeleteTarget] = (0, react.useState)(null);
4100
+ const [deleting, setDeleting] = (0, react.useState)(false);
4101
+ const [deleteCommittedId, setDeleteCommittedId] = (0, react.useState)(null);
4102
+ const [deleteError, setDeleteError] = (0, react.useState)(null);
4103
+ (0, react.useEffect)(() => {
4104
+ if (deleteCommittedId === null || items.some((workspace) => workspace.workspaceId === deleteCommittedId)) return;
4105
+ setDeleting(false);
4106
+ setDeleteCommittedId(null);
4107
+ setDeleteTarget(null);
4108
+ }, [deleteCommittedId, items]);
4109
+ const closeDelete = () => {
4110
+ if (deleting) return;
4111
+ setDeleteTarget(null);
4112
+ setDeleteError(null);
4113
+ };
4114
+ const confirmDelete = () => {
4115
+ if (deleting || deleteTarget === null) return;
4116
+ setDeleting(true);
4117
+ setDeleteCommittedId(null);
4118
+ setDeleteError(null);
4119
+ props.deleteWorkspace(deleteTarget.workspaceId).then(() => {
4120
+ setDeleteCommittedId(deleteTarget.workspaceId);
4121
+ }).catch((reason) => {
4122
+ setDeleting(false);
4123
+ setDeleteError(reason instanceof Error ? reason.message : String(reason));
4124
+ });
4125
+ };
4126
+ const now = Date.now();
4127
+ const wide = props.wide;
4128
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4129
+ className: cx(GroupedSidebar_module_default.root, !wide && GroupedSidebar_module_default.rail),
4130
+ children: [
4131
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4132
+ className: GroupedSidebar_module_default.sectionHeader,
4133
+ children: [
4134
+ wide && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4135
+ className: cx(GroupedSidebar_module_default.sectionLabel, GroupedSidebar_module_default.wide, searchExpanded && GroupedSidebar_module_default.sectionLabelHidden),
4136
+ children: viewPrefs.groupBy === "flat" ? t("section.sessions") : t("section.workspaces")
4137
+ }),
4138
+ wide && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4139
+ className: cx(GroupedSidebar_module_default.searchSlot, searchExpanded && GroupedSidebar_module_default.searchSlotExpanded),
4140
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4141
+ ref: searchRoot,
4142
+ className: cx(GroupedSidebar_module_default.search, searchExpanded && GroupedSidebar_module_default.searchExpanded),
4143
+ onClick: () => {
4144
+ setWsPickerOpen(false);
4145
+ setSearchExpanded(true);
4146
+ searchInput.current?.focus();
4147
+ },
4148
+ children: [
4149
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
4150
+ label: t("search"),
4151
+ side: "bottom",
4152
+ delayMs: 500,
4153
+ disabled: searchExpanded,
4154
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4155
+ type: "button",
4156
+ className: GroupedSidebar_module_default.searchButton,
4157
+ "aria-label": t("search.sessions.aria"),
4158
+ "aria-expanded": searchExpanded,
4159
+ onClick: () => {
4160
+ setWsPickerOpen(false);
4161
+ setSearchExpanded(true);
4162
+ },
4163
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconSearchOutline16, { size: searchExpanded ? 11 : 14 })
4164
+ })
4165
+ }),
4166
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
4167
+ ref: searchInput,
4168
+ className: GroupedSidebar_module_default.searchInput,
4169
+ type: "text",
4170
+ placeholder: t("search.placeholder"),
4171
+ maxLength: 500,
4172
+ value: query,
4173
+ tabIndex: searchExpanded ? 0 : -1,
4174
+ onChange: (e) => {
4175
+ setQuery(sanitizeSearchQuery(e.target.value));
4176
+ },
4177
+ onKeyDown: (e) => {
4178
+ if (e.key !== "Escape") return;
4179
+ setQuery("");
4180
+ setSearchExpanded(false);
4181
+ }
4182
+ }),
4183
+ searchExpanded && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4184
+ type: "button",
4185
+ className: GroupedSidebar_module_default.clearButton,
4186
+ "aria-label": t("search.clear"),
4187
+ onClick: (e) => {
4188
+ e.stopPropagation();
4189
+ setQuery("");
4190
+ setSearchExpanded(false);
4191
+ },
4192
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCloseFill14, {})
4193
+ })
4194
+ ]
4195
+ })
4196
+ }),
4197
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4198
+ className: cx(GroupedSidebar_module_default.headerActions, wide && searchExpanded && GroupedSidebar_module_default.headerActionsHidden),
4199
+ children: [wide && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewOptionsMenu, {
4200
+ groupBy: viewPrefs.groupBy,
4201
+ orderBy: viewPrefs.orderBy,
4202
+ onGroupPick: setGroupBy,
4203
+ onOrderPick: setOrderBy,
4204
+ t
4205
+ }), directoryFlowAvailable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
4206
+ label: t("workspace.add"),
4207
+ side: "bottom",
4208
+ delayMs: 500,
4209
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4210
+ type: "button",
4211
+ className: GroupedSidebar_module_default.iconButton,
4212
+ "aria-label": t("workspace.add"),
4213
+ onClick: () => {
4214
+ setWsPickerOpen((v) => !v);
4215
+ },
4216
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconProjectAddOutline16, { size: wide ? 16 : 18 })
4217
+ })
4218
+ })]
4219
+ }),
4220
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkspacePickFlow, {
4221
+ t,
4222
+ open: wsPickerOpen,
4223
+ pickDirectory: props.pickDirectory,
4224
+ createWorkspace: props.createWorkspace,
4225
+ onPick: (workspaceId) => {
4226
+ setWsPickerOpen(false);
4227
+ props.startSession(workspaceId);
4228
+ },
4229
+ onClose: () => {
4230
+ setWsPickerOpen(false);
4231
+ },
4232
+ onRetry: () => {
4233
+ setWsPickerOpen(true);
4234
+ }
4235
+ })
4236
+ ]
4237
+ }),
4238
+ !wide && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4239
+ className: GroupedSidebar_module_default.search,
4240
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
4241
+ label: t("search"),
4242
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4243
+ type: "button",
4244
+ className: GroupedSidebar_module_default.searchButton,
4245
+ "aria-label": t("search.sessions.aria"),
4246
+ onClick: () => {
4247
+ setSearchExpanded(true);
4248
+ setSearchOnExpand(true);
4249
+ props.expandSidebar();
4250
+ },
4251
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconSearchOutline16, { size: 18 })
4252
+ })
4253
+ })
4254
+ }),
4255
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4256
+ className: GroupedSidebar_module_default.listArea,
4257
+ children: wide && (normalizedQuery !== "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SearchResults, {
4258
+ list: sessionList,
4259
+ workspaces: items,
4260
+ archivedSessionIds: archived,
4261
+ query: normalizedQuery,
4262
+ remote: remoteSearch,
4263
+ resultLimit: props.searchResultLimit,
4264
+ currentId: sessions.current,
4265
+ onOpen: props.openSession,
4266
+ t
4267
+ }) : viewPrefs.groupBy === "flat" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FlatListBody, {
4268
+ list: sessionList,
4269
+ archivedSessionIds: archived,
4270
+ orderBy: viewPrefs.orderBy,
4271
+ currentId: sessions.current,
4272
+ now,
4273
+ onOpen: props.openSession,
4274
+ onRename: onSessionRename,
4275
+ onFork: props.forkSession,
4276
+ onArchive: onSessionArchive,
4277
+ t
4278
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GroupedTree, {
4279
+ groups,
4280
+ sessions: sessionList,
4281
+ archived,
4282
+ currentSessionId: sessions.current,
4283
+ expandMap,
4284
+ onToggle: toggle,
4285
+ expandTo,
4286
+ orderBy: viewPrefs.orderBy,
4287
+ now,
4288
+ home,
4289
+ onOpen: props.openSession,
4290
+ onRename: onSessionRename,
4291
+ onFork: props.forkSession,
4292
+ onArchive: onSessionArchive,
4293
+ onWorkspaceRename: (workspaceId, currentTitle) => {
4294
+ setRenameTarget({
4295
+ workspaceId,
4296
+ currentTitle
4297
+ });
4298
+ setRenameDraft(currentTitle);
4299
+ setRenameError(null);
4300
+ },
4301
+ onWorkspaceDelete: (workspaceId, title) => {
4302
+ setDeleteTarget({
4303
+ workspaceId,
4304
+ title
4305
+ });
4306
+ setDeleteError(null);
4307
+ },
4308
+ startSession: props.startSession,
4309
+ t
4310
+ }))
4311
+ }),
4312
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
4313
+ open: renameTarget !== null,
4314
+ onClose: closeRename,
4315
+ closeLabel: t("close"),
4316
+ title: t("rename.workspace.title"),
4317
+ footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4318
+ variant: "outline",
4319
+ disabled: renaming,
4320
+ onClick: closeRename,
4321
+ children: t("cancel")
4322
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4323
+ variant: "primary",
4324
+ disabled: renameBlocked,
4325
+ onClick: confirmRename,
4326
+ children: t("rename")
4327
+ })] }),
4328
+ children: [
4329
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
4330
+ className: GroupedSidebar_module_default.renameInput,
4331
+ value: renameDraft,
4332
+ "aria-label": t("field.workspaceName"),
4333
+ autoFocus: true,
4334
+ disabled: renaming,
4335
+ onFocus: (e) => {
4336
+ e.target.select();
4337
+ },
4338
+ onChange: (e) => {
4339
+ setRenameDraft(e.target.value);
4340
+ setRenameError(null);
4341
+ },
4342
+ onCompositionStart: () => {
4343
+ composingRef.current = true;
4344
+ },
4345
+ onCompositionEnd: () => {
4346
+ composingRef.current = false;
4347
+ },
4348
+ onKeyDown: (e) => {
4349
+ if (e.key === "Enter" && !composingRef.current) {
4350
+ e.preventDefault();
4351
+ confirmRename();
4352
+ }
4353
+ }
4354
+ }),
4355
+ renameDuplicate && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4356
+ className: GroupedSidebar_module_default.renameError,
4357
+ role: "alert",
4358
+ children: t("conflict.named", { name: renameTrimmed })
4359
+ }),
4360
+ renameError !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4361
+ className: GroupedSidebar_module_default.renameError,
4362
+ role: "alert",
4363
+ children: renameError
4364
+ })
4365
+ ]
4366
+ }),
4367
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
4368
+ open: sessionRenameTarget !== null,
4369
+ onClose: closeSessionRename,
4370
+ closeLabel: t("close"),
4371
+ title: t("rename.session.title"),
4372
+ footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4373
+ variant: "outline",
4374
+ disabled: sessionRenaming,
4375
+ onClick: closeSessionRename,
4376
+ children: t("cancel")
4377
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4378
+ variant: "primary",
4379
+ disabled: sessionRenameBlocked,
4380
+ onClick: confirmSessionRename,
4381
+ children: t("rename")
4382
+ })] }),
4383
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
4384
+ className: GroupedSidebar_module_default.renameInput,
4385
+ value: sessionRenameDraft,
4386
+ "aria-label": t("field.sessionName"),
4387
+ autoFocus: true,
4388
+ disabled: sessionRenaming,
4389
+ onFocus: (e) => {
4390
+ e.target.select();
4391
+ },
4392
+ onChange: (e) => {
4393
+ setSessionRenameDraft(e.target.value);
4394
+ setSessionRenameError(null);
4395
+ },
4396
+ onCompositionStart: () => {
4397
+ composingRef.current = true;
4398
+ },
4399
+ onCompositionEnd: () => {
4400
+ composingRef.current = false;
4401
+ },
4402
+ onKeyDown: (e) => {
4403
+ if (e.key === "Enter" && !composingRef.current) {
4404
+ e.preventDefault();
4405
+ confirmSessionRename();
4406
+ }
4407
+ }
4408
+ }), sessionRenameError !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4409
+ className: GroupedSidebar_module_default.renameError,
4410
+ role: "alert",
4411
+ children: sessionRenameError
4412
+ })]
4413
+ }),
4414
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
4415
+ open: deleteTarget !== null,
4416
+ onClose: closeDelete,
4417
+ closeLabel: t("close"),
4418
+ title: t("delete.workspace"),
4419
+ ...deleteTarget === null ? {} : { description: t("delete.desc", { name: deleteTarget.title }) },
4420
+ footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4421
+ variant: "outline",
4422
+ disabled: deleting,
4423
+ onClick: closeDelete,
4424
+ children: t("cancel")
4425
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4426
+ variant: "outline",
4427
+ className: GroupedSidebar_module_default.deleteAction,
4428
+ disabled: deleting,
4429
+ onClick: confirmDelete,
4430
+ children: t("delete.workspace")
4431
+ })] }),
4432
+ children: [deleting && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4433
+ className: GroupedSidebar_module_default.deleteStatus,
4434
+ role: "status",
4435
+ children: t("delete.pending")
4436
+ }), deleteError !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4437
+ className: GroupedSidebar_module_default.renameError,
4438
+ role: "alert",
4439
+ children: deleteError
4440
+ })]
4441
+ })
4442
+ ]
4443
+ });
4444
+ }
4445
+ //#endregion
1639
4446
  //#region src/client/locales.ts
1640
4447
  /** English dictionary — complete by construction. */
1641
4448
  const en = {
1642
4449
  chipWorktree: "Worktree",
1643
4450
  worktreeToggle: "Create an isolated worktree",
4451
+ menuBranches: "Branches",
1644
4452
  menuLocalBranches: "Local branches",
4453
+ menuWorktrees: "Worktrees",
4454
+ menuRemoteBranches: "Remote branches",
4455
+ mainRepoOnly: "Branch operations start from the main checkout",
1645
4456
  menuSearchPlaceholder: "Search branches",
1646
4457
  menuNoMatches: "No matching branches",
4458
+ menuNoBranches: "No branches yet",
1647
4459
  menuLocate: "Locate current branch",
1648
4460
  menuExpandAll: "Expand all",
1649
4461
  menuCollapseAll: "Collapse all",
4462
+ menuNewBranch: "Create branch from current",
4463
+ menuNewBranchPlaceholder: "New branch name",
4464
+ menuNewBranchBad: "Git will not accept this name",
4465
+ menuNewBranchExists: "A branch with this name already exists",
4466
+ menuFetch: "Fetch",
4467
+ menuUpdate: "Update current branch from upstream",
4468
+ fetchDone: "Remote branches synced",
4469
+ updateDone: "{branch} fast-forwarded to its upstream",
4470
+ updateUpToDate: "Already up to date",
4471
+ aheadTitle: "{n} commits ahead of upstream",
4472
+ behindTitle: "{n} commits behind upstream",
1650
4473
  switchAsk: "Switch to {branch}?",
4474
+ switchAskRemote: "Check out this remote branch?",
1651
4475
  switchBusy: "Switching…",
1652
4476
  worktreeAskNew: "Create a worktree from {branch}?",
4477
+ worktreeAskRemote: "Create a worktree from this remote branch?",
1653
4478
  worktreeAskReuse: "Switch to the {branch} worktree?",
1654
- worktreeAskCutOut: "Cut a worktree out of the current branch {branch}?",
4479
+ worktreeAskCutOut: "Cut a new branch out of {branch} into an isolated worktree",
1655
4480
  worktreeBusy: "Creating…",
4481
+ createBranchTitle: "New branch from {branch}",
4482
+ createBranchBusy: "Creating…",
1656
4483
  actionCancel: "Cancel",
1657
4484
  actionConfirm: "Confirm",
1658
4485
  errorGeneric: "Git worktree: {message}",
@@ -1670,24 +4497,121 @@ window.__ModuleLoader__.load({
1670
4497
  cardSaveFailed: "The change did not save. Check the path is absolute and try again.",
1671
4498
  cardDiscard: "Discard",
1672
4499
  cardSave: "Save",
1673
- cardSaving: "Saving…"
4500
+ cardSaving: "Saving…",
4501
+ sidebarSectionTitle: "Workspaces",
4502
+ sidebarAddSession: "Start a new session",
4503
+ sidebarNewSession: "New Session",
4504
+ sidebarMainBranch: "Main ({branch})",
4505
+ sidebarMain: "Main",
4506
+ sidebarRailExpand: "Expand sidebar",
4507
+ cardGroupSidebarLabel: "Group workspaces",
4508
+ cardGroupSidebarHint: "DSH does not yet expose a multi-workspace grouping API, so this replaces the native sidebar 1:1 and adds same-repo worktree grouping.",
4509
+ cardGroupSidebarMark: "(experimental)",
4510
+ cardGroupSidebarNote: "Turn it off to restore the native list if anything breaks; we will switch to the official API as soon as it ships.",
4511
+ cardGroupSidebarBusy: "Switching sidebar…",
4512
+ "group.ungrouped": "Ungrouped",
4513
+ "session.new": "New Session",
4514
+ "section.workspaces": "Workspaces",
4515
+ "section.sessions": "Sessions",
4516
+ "viewOptions.label": "View options",
4517
+ "groupBy.label": "Group by",
4518
+ "groupBy.workspace": "WorkSpace",
4519
+ "groupBy.flat": "In one list",
4520
+ "orderBy.label": "Order by",
4521
+ "orderBy.manual": "Manual",
4522
+ "orderBy.updated": "Last updated",
4523
+ "sessions.expand": "Show {n} more sessions",
4524
+ "sessions.collapse": "Show less",
4525
+ "empty.none": "No sessions yet",
4526
+ "empty.noMatches": "No matches",
4527
+ "workspace.add": "Add workspace",
4528
+ search: "Search",
4529
+ "search.sessions.aria": "Search sessions",
4530
+ "search.placeholder": "Search sessions...",
4531
+ "search.clear": "Clear search",
4532
+ "search.results.aria": "Search results",
4533
+ "search.pending": "Searching session history…",
4534
+ "search.unavailable": "Content search is temporarily unavailable. Showing name matches.",
4535
+ "search.noMatches": "No matching sessions",
4536
+ "search.hasMore": "Showing the first {n} results. Narrow your search.",
4537
+ "menu.addWorkspace": "Add workspace…",
4538
+ "picker.loading": "Loading workspaces…",
4539
+ "conflict.named": "A workspace named “{name}” already exists.",
4540
+ "folderError.title": "Couldn’t open folder",
4541
+ "folderError.retry": "Choose again",
4542
+ rename: "Rename",
4543
+ "rename.workspace.title": "Rename workspace",
4544
+ "rename.session.title": "Rename session",
4545
+ "field.workspaceName": "Workspace name",
4546
+ "field.sessionName": "Session name",
4547
+ "delete.workspace": "Delete workspace",
4548
+ "delete.desc": "This removes “{name}” from the workspace list. The folder and session logs will be kept. Its sessions will appear under Ungrouped.",
4549
+ "delete.pending": "Deleting workspace…",
4550
+ "menu.fork": "Fork session",
4551
+ "menu.archiveSession": "Archive session",
4552
+ "sessions.count.one": "{n} session",
4553
+ "sessions.count.other": "{n} sessions",
4554
+ "actions.workspace.aria": "Workspace actions for {name}",
4555
+ "actions.session.aria": "Session actions for {name}",
4556
+ "actions.newSession.aria": "New session in {name}",
4557
+ "status.running": "Running",
4558
+ "status.subagentsRunning.one": "{n} subagent running",
4559
+ "status.subagentsRunning.other": "{n} subagents running",
4560
+ "status.idle": "Idle",
4561
+ "status.waitingApproval": "Waiting for approval",
4562
+ "status.planReview": "Plan awaiting review",
4563
+ "status.waitingAnswer": "Waiting for answer",
4564
+ "status.completed": "Completed",
4565
+ "hover.created": "Created {time}",
4566
+ "hover.copied": "Copied",
4567
+ "date.ymd": "{y}-{m}-{d}",
4568
+ "time.now": "now",
4569
+ "time.minutes": "{n}min",
4570
+ "time.hours": "{n}h",
4571
+ "time.days": "{n}d",
4572
+ "time.months": "{n}mo",
4573
+ "time.years": "{n}y",
4574
+ "time.ago": "{t} ago",
4575
+ copy: "Copy",
4576
+ close: "Close",
4577
+ cancel: "Cancel"
1674
4578
  };
1675
4579
  /** 中文词典。 */
1676
4580
  const zh = {
1677
4581
  chipWorktree: "工作树",
1678
4582
  worktreeToggle: "创建隔离工作树",
4583
+ menuBranches: "分支",
1679
4584
  menuLocalBranches: "本地分支",
4585
+ menuWorktrees: "工作树",
4586
+ menuRemoteBranches: "远程分支",
4587
+ mainRepoOnly: "分支操作请在主仓库发起",
1680
4588
  menuSearchPlaceholder: "搜索分支",
1681
4589
  menuNoMatches: "没有匹配的分支",
4590
+ menuNoBranches: "暂无分支",
1682
4591
  menuLocate: "定位当前分支",
1683
4592
  menuExpandAll: "全部展开",
1684
4593
  menuCollapseAll: "全部折叠",
4594
+ menuNewBranch: "从当前分支新建分支",
4595
+ menuNewBranchPlaceholder: "新分支名称",
4596
+ menuNewBranchBad: "Git 不接受该名称",
4597
+ menuNewBranchExists: "同名分支已存在",
4598
+ menuFetch: "提取",
4599
+ menuUpdate: "更新当前分支",
4600
+ fetchDone: "远程分支已同步",
4601
+ updateDone: "{branch} 已快进到远程最新",
4602
+ updateUpToDate: "已是最新",
4603
+ aheadTitle: "领先上游 {n} 个提交",
4604
+ behindTitle: "落后上游 {n} 个提交",
1685
4605
  switchAsk: "是否切到 {branch}?",
4606
+ switchAskRemote: "是否检出该远程分支?",
1686
4607
  switchBusy: "切换中…",
1687
4608
  worktreeAskNew: "是否从 {branch} 新建工作树?",
4609
+ worktreeAskRemote: "从该远程分支新建工作树?",
1688
4610
  worktreeAskReuse: "是否切到 {branch} 工作树?",
1689
- worktreeAskCutOut: "是否从当前分支 {branch} 切出工作树?",
4611
+ worktreeAskCutOut: "从当前分支 {branch} 切出新分支到隔离工作树",
1690
4612
  worktreeBusy: "创建中…",
4613
+ createBranchTitle: "从 {branch} 新建分支",
4614
+ createBranchBusy: "创建中…",
1691
4615
  actionCancel: "取消",
1692
4616
  actionConfirm: "确认",
1693
4617
  errorGeneric: "Git 工作树:{message}",
@@ -1705,7 +4629,84 @@ window.__ModuleLoader__.load({
1705
4629
  cardSaveFailed: "保存未生效,请检查路径是否为绝对路径后重试。",
1706
4630
  cardDiscard: "放弃",
1707
4631
  cardSave: "保存",
1708
- cardSaving: "保存中…"
4632
+ cardSaving: "保存中…",
4633
+ sidebarSectionTitle: "工作区",
4634
+ sidebarAddSession: "发起新会话",
4635
+ sidebarNewSession: "新会话",
4636
+ sidebarMainBranch: "主仓库({branch})",
4637
+ sidebarMain: "主仓库",
4638
+ sidebarRailExpand: "展开侧栏",
4639
+ cardGroupSidebarLabel: "聚合工作区",
4640
+ cardGroupSidebarHint: "DSH 尚未开放多工作区聚合接口,因此按原生侧边栏 1:1 替换左侧列表,并加上同仓库工作树分组。",
4641
+ cardGroupSidebarMark: "(测试功能)",
4642
+ cardGroupSidebarNote: "使用中若遇问题,关掉即可回到原生;官方接口一旦开放,会第一时间改用原生实现。",
4643
+ cardGroupSidebarBusy: "正在切换侧栏…",
4644
+ "group.ungrouped": "未分组",
4645
+ "session.new": "新会话",
4646
+ "section.workspaces": "工作区",
4647
+ "section.sessions": "会话",
4648
+ "viewOptions.label": "视图选项",
4649
+ "groupBy.label": "分组方式",
4650
+ "groupBy.workspace": "按工作区",
4651
+ "groupBy.flat": "单列表",
4652
+ "orderBy.label": "排序方式",
4653
+ "orderBy.manual": "手动排序",
4654
+ "orderBy.updated": "最近更新",
4655
+ "sessions.expand": "展开其余 {n} 个会话",
4656
+ "sessions.collapse": "收起",
4657
+ "empty.none": "暂无会话",
4658
+ "empty.noMatches": "无匹配结果",
4659
+ "workspace.add": "添加工作区",
4660
+ search: "搜索",
4661
+ "search.sessions.aria": "搜索会话",
4662
+ "search.placeholder": "搜索会话…",
4663
+ "search.clear": "清除搜索",
4664
+ "search.results.aria": "搜索结果",
4665
+ "search.pending": "正在搜索会话历史…",
4666
+ "search.unavailable": "内容搜索暂不可用,仅显示名称匹配。",
4667
+ "search.noMatches": "无匹配会话",
4668
+ "search.hasMore": "仅显示前 {n} 条结果,请缩小搜索范围。",
4669
+ "menu.addWorkspace": "添加工作区…",
4670
+ "picker.loading": "正在加载工作区…",
4671
+ "conflict.named": "已存在名为“{name}”的工作区。",
4672
+ "folderError.title": "无法打开文件夹",
4673
+ "folderError.retry": "重新选择",
4674
+ rename: "重命名",
4675
+ "rename.workspace.title": "重命名工作区",
4676
+ "rename.session.title": "重命名会话",
4677
+ "field.workspaceName": "工作区名称",
4678
+ "field.sessionName": "会话名称",
4679
+ "delete.workspace": "删除工作区",
4680
+ "delete.desc": "将把“{name}”从工作区列表中移除。文件夹与会话记录会保留,其会话将显示在“未分组”下。",
4681
+ "delete.pending": "正在删除工作区…",
4682
+ "menu.fork": "分叉会话",
4683
+ "menu.archiveSession": "归档会话",
4684
+ "sessions.count.one": "{n} 个会话",
4685
+ "sessions.count.other": "{n} 个会话",
4686
+ "actions.workspace.aria": "工作区“{name}”的操作",
4687
+ "actions.session.aria": "会话“{name}”的操作",
4688
+ "actions.newSession.aria": "在“{name}”中新建会话",
4689
+ "status.running": "进行中",
4690
+ "status.subagentsRunning.one": "{n} 个子代理运行中",
4691
+ "status.subagentsRunning.other": "{n} 个子代理运行中",
4692
+ "status.idle": "空闲",
4693
+ "status.waitingApproval": "等待审批",
4694
+ "status.planReview": "计划待审",
4695
+ "status.waitingAnswer": "等待回答",
4696
+ "status.completed": "已完成",
4697
+ "hover.created": "创建于 {time}",
4698
+ "hover.copied": "已复制",
4699
+ "date.ymd": "{y}年{m}月{d}日",
4700
+ "time.now": "刚刚",
4701
+ "time.minutes": "{n}分钟",
4702
+ "time.hours": "{n}小时",
4703
+ "time.days": "{n}天",
4704
+ "time.months": "{n}个月",
4705
+ "time.years": "{n}年",
4706
+ "time.ago": "{t}前",
4707
+ copy: "复制",
4708
+ close: "关闭",
4709
+ cancel: "取消"
1709
4710
  };
1710
4711
  //#endregion
1711
4712
  //#region src/client/index.ts
@@ -1743,11 +4744,153 @@ window.__ModuleLoader__.load({
1743
4744
  locale: NS,
1744
4745
  inject: chipInjected
1745
4746
  }, BranchChipDock));
1746
- const form = new CardForm(ctx.settingsScope.bind({ namespace: GIT_WORKTREE_NS }));
4747
+ const groupingScope = ctx.settingsScope.bind({ namespace: GIT_WORKTREE_NS });
4748
+ const SEAT_READY_TIMEOUT_MS = 2e4;
4749
+ const SNAPSHOT_WAIT_MS = 8e3;
4750
+ let groupingDisposer;
4751
+ let groupingEnabled;
4752
+ let seatEpoch = 0;
4753
+ let seatReady = Promise.resolve();
4754
+ let seatReadyResolve;
4755
+ let seatTimer;
4756
+ const finishSeat = () => {
4757
+ if (seatTimer !== void 0) {
4758
+ window.clearTimeout(seatTimer);
4759
+ seatTimer = void 0;
4760
+ }
4761
+ const resolve = seatReadyResolve;
4762
+ seatReadyResolve = void 0;
4763
+ resolve?.();
4764
+ };
4765
+ const afterPaint = () => new Promise((resolve) => {
4766
+ if (typeof requestAnimationFrame === "function") {
4767
+ requestAnimationFrame(() => {
4768
+ requestAnimationFrame(() => {
4769
+ resolve();
4770
+ });
4771
+ });
4772
+ return;
4773
+ }
4774
+ setTimeout(resolve, 0);
4775
+ });
4776
+ const groupingMatches = (enabled) => {
4777
+ const snapshot = groupingScope.getSnapshot();
4778
+ return snapshot.status === "ready" && (snapshot.value?.groupSidebar ?? true) === enabled;
4779
+ };
4780
+ const waitSnapshotMatches = async (enabled) => {
4781
+ if (groupingMatches(enabled)) return;
4782
+ await new Promise((resolve) => {
4783
+ const stop = groupingScope.subscribe(() => {
4784
+ if (!groupingMatches(enabled)) return;
4785
+ stop();
4786
+ window.clearTimeout(timer);
4787
+ resolve();
4788
+ });
4789
+ const timer = window.setTimeout(() => {
4790
+ stop();
4791
+ resolve();
4792
+ }, SNAPSHOT_WAIT_MS);
4793
+ if (groupingMatches(enabled)) {
4794
+ window.clearTimeout(timer);
4795
+ stop();
4796
+ resolve();
4797
+ }
4798
+ });
4799
+ };
4800
+ const syncGroupingSeat = () => {
4801
+ const snapshot = groupingScope.getSnapshot();
4802
+ if (snapshot.status !== "ready") return seatReady;
4803
+ const enabled = snapshot.value?.groupSidebar ?? true;
4804
+ if (enabled === groupingEnabled) return seatReady;
4805
+ groupingEnabled = enabled;
4806
+ if (groupingDisposer !== void 0) {
4807
+ groupingDisposer();
4808
+ groupingDisposer = void 0;
4809
+ }
4810
+ const epoch = ++seatEpoch;
4811
+ seatReady = new Promise((resolve) => {
4812
+ seatReadyResolve = resolve;
4813
+ });
4814
+ if (!enabled) {
4815
+ afterPaint().then(() => {
4816
+ if (epoch === seatEpoch) finishSeat();
4817
+ });
4818
+ return seatReady;
4819
+ }
4820
+ const injectFace = () => ({
4821
+ workspacesList: ctx.workspaces.list,
4822
+ sessionsList: ctx.sessions.list,
4823
+ openSession: (sessionId) => {
4824
+ ctx.sessions.open(sessionId);
4825
+ },
4826
+ startSession: (workspaceId) => {
4827
+ ctx.workspaces.startSession(workspaceId);
4828
+ },
4829
+ loadFacts: async (paths) => {
4830
+ const result = await requestGroupWorktrees(paths);
4831
+ return result.ok ? result.facts : void 0;
4832
+ },
4833
+ searchSessions: async (query, signal) => {
4834
+ const result = await ctx.sessions.search(query, signal);
4835
+ if (!result.ok) throw new Error(result.error.message);
4836
+ return result.value;
4837
+ },
4838
+ searchResultLimit: ctx.sessions.searchResultLimit,
4839
+ renameSession: async (sessionId, title) => {
4840
+ const session = ctx.sessions.binding(sessionId)?.session;
4841
+ if (session === void 0) throw new Error(`unknown session "${sessionId}"`);
4842
+ const result = await session.rename(title);
4843
+ if (!result.ok) throw new Error(result.error.message);
4844
+ },
4845
+ forkSession: (sessionId) => {
4846
+ ctx.sessions.fork({
4847
+ sessionId,
4848
+ increaseTitle: true
4849
+ }).then((childId) => {
4850
+ ctx.sessions.open(childId);
4851
+ }).catch(() => {});
4852
+ },
4853
+ renameWorkspace: async (workspaceId, title) => {
4854
+ await ctx.workspaces.rename(workspaceId, title);
4855
+ },
4856
+ deleteWorkspace: async (workspaceId) => {
4857
+ await ctx.workspaces.delete(workspaceId);
4858
+ },
4859
+ archiveSession: async (sessionId) => {
4860
+ await ctx.workspaces.archiveSession(sessionId);
4861
+ },
4862
+ createWorkspace: (input) => ctx.workspaces.create(input),
4863
+ pickDirectory: () => ctx.workspaces.pickDirectory(),
4864
+ hostDescription: ctx.get("connection").hostDescription,
4865
+ directoryFlow: {
4866
+ getSnapshot: () => ctx.slots.entries("sidebar.workspaces.directoryFlow").length > 0,
4867
+ subscribe: (listener) => ctx.slots.subscribe("sidebar.workspaces.directoryFlow", listener)
4868
+ },
4869
+ onReady: () => {
4870
+ if (epoch === seatEpoch) finishSeat();
4871
+ }
4872
+ });
4873
+ groupingDisposer = ctx.slots.inject("sidebar.workspaces", () => ctx.slots.register({
4874
+ name: "sidebar.workspaces",
4875
+ priority: -1,
4876
+ locale: NS,
4877
+ inject: injectFace
4878
+ }, GroupedSidebar));
4879
+ seatTimer = window.setTimeout(() => {
4880
+ if (epoch === seatEpoch) finishSeat();
4881
+ }, SEAT_READY_TIMEOUT_MS);
4882
+ return seatReady;
4883
+ };
4884
+ const waitForGroupingSeat = async (enabled) => {
4885
+ await waitSnapshotMatches(enabled);
4886
+ await syncGroupingSeat();
4887
+ };
4888
+ const form = new CardForm(groupingScope, waitForGroupingSeat);
1747
4889
  const store = form.bind();
1748
4890
  ctx.slots.inject("settings.plugin.item", () => ctx.slots.register({
1749
4891
  name: "settings.plugin.item",
1750
4892
  key: GIT_WORKTREE_NS,
4893
+ priority: -1,
1751
4894
  locale: NS,
1752
4895
  inject: () => ({
1753
4896
  hooks: { gitWorktreeCard: store },
@@ -1755,6 +4898,14 @@ window.__ModuleLoader__.load({
1755
4898
  pickDirectory: () => ctx.workspaces.pickDirectory()
1756
4899
  })
1757
4900
  }, GitWorktreeCard));
4901
+ syncGroupingSeat();
4902
+ const unsubscribeGrouping = groupingScope.subscribe(() => {
4903
+ syncGroupingSeat();
4904
+ });
4905
+ ctx.effect(() => () => {
4906
+ unsubscribeGrouping();
4907
+ if (groupingDisposer !== void 0) groupingDisposer();
4908
+ }, "git-worktree: sidebar grouping lifecycle");
1758
4909
  }
1759
4910
  //#endregion
1760
4911
  exports.apply = apply;