@laoyuehanni/dsh-git-worktree 0.4.1 → 0.4.2

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
@@ -69,6 +69,14 @@ window.__ModuleLoader__.load({
69
69
  const ROUTE_UPDATE = `${ROUTE_PREFIX}/update`;
70
70
  /** POST ROUTE_PREFIX/group — git belonging facts for a batch of workspace paths. */
71
71
  const ROUTE_GROUP = `${ROUTE_PREFIX}/group`;
72
+ /** POST ROUTE_PREFIX/inspect — pre-delete facts for one worktree directory. */
73
+ const ROUTE_INSPECT = `${ROUTE_PREFIX}/inspect`;
74
+ /** POST ROUTE_PREFIX/remove — delete one linked worktree (git registration + folder). */
75
+ const ROUTE_REMOVE = `${ROUTE_PREFIX}/remove`;
76
+ /** POST ROUTE_PREFIX/exists — batch directory-existence probe (fs, no git). */
77
+ const ROUTE_EXISTS = `${ROUTE_PREFIX}/exists`;
78
+ /** POST ROUTE_PREFIX/ensure-directory — mkdir -p a missing worktree storage slot. */
79
+ const ROUTE_ENSURE_DIRECTORY = `${ROUTE_PREFIX}/ensure-directory`;
72
80
  //#endregion
73
81
  //#region src/client/api.ts
74
82
  /** POST one JSON body and parse the uniform envelope. */
@@ -195,6 +203,44 @@ window.__ModuleLoader__.load({
195
203
  async function requestGroupWorktrees(paths) {
196
204
  return post(ROUTE_GROUP, { paths });
197
205
  }
206
+ /**
207
+ * Pre-delete facts for one worktree directory: the uncommitted-file count
208
+ * (lost with the folder) and the branch's ahead count (kept).
209
+ * @param path - absolute worktree directory.
210
+ */
211
+ function requestInspectWorktree(path) {
212
+ return post(ROUTE_INSPECT, { path });
213
+ }
214
+ /**
215
+ * Remove one linked worktree (git registration + folder). `force` rides
216
+ * `--force` past uncommitted changes the confirm dialog already showed.
217
+ * @param path - absolute worktree directory to delete.
218
+ * @param force - delete past uncommitted changes.
219
+ */
220
+ function requestRemoveWorktree(path, force) {
221
+ return post(ROUTE_REMOVE, {
222
+ path,
223
+ force
224
+ });
225
+ }
226
+ /**
227
+ * Batch directory-existence probe (true = exists AND is a directory). The
228
+ * sidebar gates register-as-workspace on this so a missing folder never
229
+ * reaches the DSH workspace API.
230
+ * @param paths - absolute directories to probe.
231
+ */
232
+ function requestPathExists(paths) {
233
+ return post(ROUTE_EXISTS, { paths });
234
+ }
235
+ /**
236
+ * Recreate a missing worktree storage slot (`mkdir -p`). The host gates this
237
+ * to paths directly inside the storage root; historical sessions reattach
238
+ * automatically once the directory is back.
239
+ * @param path - the missing slot directory (absolute).
240
+ */
241
+ function requestEnsureDirectory(path) {
242
+ return post(ROUTE_ENSURE_DIRECTORY, { path });
243
+ }
198
244
  //#endregion
199
245
  //#region \0git-worktree-css:D:\Code\dsh-worktree\src\client\BranchChip.module.css?inline
200
246
  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";
@@ -2817,6 +2863,57 @@ window.__ModuleLoader__.load({
2817
2863
  }));
2818
2864
  return rows.map((session) => sessionNode(session, descendants));
2819
2865
  }
2866
+ /**
2867
+ * Derive the stray-session clusters: sessions no workspace account holds
2868
+ * (a deleted-then-recreated registration's leftovers, or history that
2869
+ * appeared after first-boot grouping), clustered by their header cwd into
2870
+ * VIRTUAL directory groups. The same visibility rule as everywhere else
2871
+ * applies (archived hidden, subagent rows never listed, a blank visible
2872
+ * only while it IS the current selection — deleting the current session's
2873
+ * workspace registration must not make it vanish).
2874
+ *
2875
+ * Matching against registered workspace paths is case-insensitive
2876
+ * (NTFS): one directory must never split into two clusters because of
2877
+ * casing drift between a session header and the registry's realpath.
2878
+ * @param items - workspace list items (their `sessionIds` projection IS the
2879
+ * accounting; the registry guarantees one record per canonical path).
2880
+ * @param sessions - session list snapshot.
2881
+ * @param archivedSessionIds - registry-global archive set.
2882
+ * @returns stray groups in first-appearance order; empty when nothing is loose.
2883
+ */
2884
+ function deriveStrayGroups(items, sessions, archivedSessionIds) {
2885
+ const accounted = new Set(items.flatMap((workspace) => workspace.sessionIds));
2886
+ const registered = /* @__PURE__ */ new Map();
2887
+ for (const workspace of items) {
2888
+ const key = workspace.path.toLowerCase();
2889
+ if (!registered.has(key)) registered.set(key, workspace.title);
2890
+ }
2891
+ const archived = new Set(archivedSessionIds);
2892
+ const clusters = /* @__PURE__ */ new Map();
2893
+ for (const id of sessions.ids) {
2894
+ if (accounted.has(id)) continue;
2895
+ const summary = sessions.byId[id];
2896
+ if (summary === void 0) continue;
2897
+ if (summary.origin === "subagent") continue;
2898
+ if (archived.has(id)) continue;
2899
+ if (summary.blank && id !== sessions.current) continue;
2900
+ const path = summary.cwd ?? "";
2901
+ const key = `stray:${path === "" ? "?" : path.toLowerCase()}`;
2902
+ const existing = clusters.get(key);
2903
+ if (existing === void 0) clusters.set(key, {
2904
+ kind: "stray",
2905
+ key,
2906
+ path,
2907
+ belongsTo: path === "" ? void 0 : registered.get(path.toLowerCase()),
2908
+ sessions: [summary]
2909
+ });
2910
+ else clusters.set(key, {
2911
+ ...existing,
2912
+ sessions: [...existing.sessions, summary]
2913
+ });
2914
+ }
2915
+ return [...clusters.values()];
2916
+ }
2820
2917
  /** Display label for the ungrouped bucket row. */
2821
2918
  const UNGROUPED_LABEL = "Ungrouped";
2822
2919
  /**
@@ -2973,7 +3070,7 @@ window.__ModuleLoader__.load({
2973
3070
  }
2974
3071
  //#endregion
2975
3072
  //#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";
3073
+ 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/* Virtual (unregistered) directory rows read one weight lighter than real\n * workspace rows — together with the dashed folder glyph, the whole row is\n * distinguishable at a glance. */\n.strayRow_2050697429 .title_2050697429 {\n color: var(--dsw-alias-label-secondary);\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
3074
  const tagId$1 = "@laoyuehanni/dsh-git-worktree/sidebar-rows.module.css";
2978
3075
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId$1 + "\"]") === null) {
2979
3076
  const tag = document.createElement("style");
@@ -3005,6 +3102,7 @@ window.__ModuleLoader__.load({
3005
3102
  "arrow": "arrow_2050697429",
3006
3103
  "arrowOpen": "arrowOpen_2050697429",
3007
3104
  "projectText": "projectText_2050697429",
3105
+ "strayRow": "strayRow_2050697429",
3008
3106
  "renameInput": "renameInput_2050697429",
3009
3107
  "meta": "meta_2050697429",
3010
3108
  "time": "time_2050697429",
@@ -3064,16 +3162,25 @@ window.__ModuleLoader__.load({
3064
3162
  function ProjectRowItem({ row, onToggle, onCreate, actions, home, t, badge }) {
3065
3163
  const active = row.expanded && row.containsCurrent;
3066
3164
  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
- }];
3165
+ const workspaceMenuItems = [
3166
+ {
3167
+ id: "rename",
3168
+ label: t("rename"),
3169
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEditOutline16, {})
3170
+ },
3171
+ ...actions?.removeWorktree !== void 0 ? [{
3172
+ id: "removeWorktree",
3173
+ label: t("worktreeRemove.menu"),
3174
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTrashOutline16, {}),
3175
+ danger: true
3176
+ }] : [],
3177
+ {
3178
+ id: "delete",
3179
+ label: t("delete.workspace"),
3180
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTrashOutline16, {}),
3181
+ danger: true
3182
+ }
3183
+ ];
3077
3184
  const ownRow = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3078
3185
  className: cx$1(sidebar_rows_module_default.projectRow, menuOpen && sidebar_rows_module_default.menuOpen),
3079
3186
  role: "treeitem",
@@ -3109,9 +3216,9 @@ window.__ModuleLoader__.load({
3109
3216
  items: workspaceMenuItems,
3110
3217
  onSelect: (id) => {
3111
3218
  setMenuOpen(false);
3112
- if (id !== "rename" && id !== "delete") return;
3113
3219
  if (id === "rename") actions.rename();
3114
- else actions.delete();
3220
+ else if (id === "removeWorktree") actions.removeWorktree?.();
3221
+ else if (id === "delete") actions.delete();
3115
3222
  },
3116
3223
  portal: true,
3117
3224
  closeOnPointerLeave: true,
@@ -3156,6 +3263,146 @@ window.__ModuleLoader__.load({
3156
3263
  function assertNever(value) {
3157
3264
  throw new Error(`unknown pending interaction: ${String(value)}`);
3158
3265
  }
3266
+ /** Final path segment of an absolute directory ('' for the unknown-cwd cluster). */
3267
+ function pathBasename(path) {
3268
+ if (path === "") return "";
3269
+ const parts = path.split(/[\\/]/);
3270
+ return parts[parts.length - 1] ?? "";
3271
+ }
3272
+ /**
3273
+ * Dashed folder glyph for virtual (unregistered) directory rows. The icon set
3274
+ * ships no dashed variant, so this follows the WorktreeCheck precedent of a
3275
+ * module-local SVG: at 16px a dash pattern is a far stronger "directory-shaped
3276
+ * but not a registered workspace" mark than the outline/solid stroke contrast
3277
+ * it replaces.
3278
+ */
3279
+ function StrayFolderGlyph({ size = 16 }) {
3280
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
3281
+ width: size,
3282
+ height: size,
3283
+ viewBox: "0 0 16 16",
3284
+ fill: "none",
3285
+ "aria-hidden": "true",
3286
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
3287
+ d: "M1.75 4.4c0-.91.71-1.65 1.6-1.65h2.47c.45 0 .88.19 1.19.52l.79.86h4.85c.89 0 1.6.74 1.6 1.65v6.05c0 .91-.71 1.65-1.6 1.65H3.35c-.89 0-1.6-.74-1.6-1.65Z",
3288
+ stroke: "currentColor",
3289
+ strokeWidth: "1.15",
3290
+ strokeDasharray: "2 1.6",
3291
+ strokeLinejoin: "round",
3292
+ strokeLinecap: "round"
3293
+ })
3294
+ });
3295
+ }
3296
+ /**
3297
+ * One virtual directory row of the stray (Ungrouped) section: DASHED folder
3298
+ * (the real workspace rows' folder is solid — the dash pattern is the
3299
+ * at-a-glance "this directory is not a registered workspace" mark) +
3300
+ * directory basename + session-count badge; hover reveals the full path plus
3301
+ * one guidance line — ownership when a registered workspace holds the
3302
+ * directory, or the rebuild hint when it is a missing worktree storage slot.
3303
+ * The ⋯ menu carries exactly one action: register (directory probed real and
3304
+ * unregistered) or rebuild (missing but host-confirmed as a storage slot).
3305
+ */
3306
+ function StrayGroupRow({ path, belongsTo, count, expanded, onToggle, onRegister, registering, onRebuild, rebuilding, missingDir, worktreeSlot, home, t }) {
3307
+ const [menuOpen, setMenuOpen] = (0, react.useState)(false);
3308
+ const label = path === "" ? t("stray.unknown") : pathBasename(path);
3309
+ const items = onRegister !== void 0 ? [{
3310
+ id: "register",
3311
+ label: t("stray.register"),
3312
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderOpen16, {})
3313
+ }] : onRebuild !== void 0 ? [{
3314
+ id: "rebuild",
3315
+ label: t("stray.rebuild"),
3316
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderOpen16, {})
3317
+ }] : [];
3318
+ const row = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3319
+ className: cx$1(sidebar_rows_module_default.projectRow, sidebar_rows_module_default.strayRow, menuOpen && sidebar_rows_module_default.menuOpen),
3320
+ role: "treeitem",
3321
+ "aria-expanded": expanded,
3322
+ onClick: onToggle,
3323
+ children: [
3324
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3325
+ className: cx$1(sidebar_rows_module_default.slot, sidebar_rows_module_default.folder),
3326
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StrayFolderGlyph, {})
3327
+ }),
3328
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3329
+ className: cx$1(sidebar_rows_module_default.slot, sidebar_rows_module_default.chevron),
3330
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTriangleRightFill14, { className: cx$1(sidebar_rows_module_default.arrow, expanded && sidebar_rows_module_default.arrowOpen) })
3331
+ }),
3332
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3333
+ className: sidebar_rows_module_default.projectText,
3334
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3335
+ className: sidebar_rows_module_default.title,
3336
+ children: label
3337
+ })
3338
+ }),
3339
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3340
+ className: sidebar_rows_module_default.repoCount,
3341
+ children: String(count)
3342
+ }),
3343
+ items.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3344
+ className: sidebar_rows_module_default.rowActions,
3345
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
3346
+ open: menuOpen,
3347
+ onClose: () => {
3348
+ setMenuOpen(false);
3349
+ },
3350
+ items,
3351
+ onSelect: (id) => {
3352
+ setMenuOpen(false);
3353
+ if (id === "register") onRegister?.();
3354
+ if (id === "rebuild") onRebuild?.();
3355
+ },
3356
+ portal: true,
3357
+ closeOnPointerLeave: true,
3358
+ anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3359
+ type: "button",
3360
+ className: sidebar_rows_module_default.iconButton,
3361
+ "aria-label": onRegister !== void 0 ? t("stray.register.aria", { name: label }) : t("stray.rebuild.aria", { name: label }),
3362
+ disabled: registering === true || rebuilding === true,
3363
+ onClick: (e) => {
3364
+ e.stopPropagation();
3365
+ setMenuOpen((v) => !v);
3366
+ },
3367
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEllipsisOutline16, {})
3368
+ })
3369
+ })
3370
+ })
3371
+ ]
3372
+ });
3373
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.HoverCard, {
3374
+ anchor: row,
3375
+ content: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3376
+ className: sidebar_rows_module_default.hoverContent,
3377
+ children: [
3378
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3379
+ className: sidebar_rows_module_default.hoverTitle,
3380
+ children: label
3381
+ }),
3382
+ path !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3383
+ className: sidebar_rows_module_default.hoverPath,
3384
+ children: (0, _deepseek_ai_dsh_client_runtime_client.abbreviateHomePath)(path, home)
3385
+ }),
3386
+ belongsTo !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3387
+ className: sidebar_rows_module_default.hoverStatus,
3388
+ children: t("stray.belongsTo", { name: belongsTo })
3389
+ }),
3390
+ missingDir === true && worktreeSlot === true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3391
+ className: sidebar_rows_module_default.hoverStatus,
3392
+ children: t("stray.worktreeSlot")
3393
+ }),
3394
+ missingDir === true && worktreeSlot !== true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3395
+ className: sidebar_rows_module_default.hoverStatus,
3396
+ children: t("stray.missingDir")
3397
+ })
3398
+ ]
3399
+ }),
3400
+ disabled: menuOpen,
3401
+ copyText: path === "" ? void 0 : path,
3402
+ copyLabel: t("copy"),
3403
+ copiedLabel: t("hover.copied")
3404
+ });
3405
+ }
3159
3406
  /** Session status presentation; pending interaction is primary and live activity outranks completion. */
3160
3407
  function sessionStatuses(node, t) {
3161
3408
  const subagents = node.runningSubagentCount === 0 ? void 0 : {
@@ -3426,7 +3673,7 @@ window.__ModuleLoader__.load({
3426
3673
  }
3427
3674
  //#endregion
3428
3675
  //#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";
3676
+ 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/* Pre-delete facts of the worktree-removal dialog: one line per fact, the\n * destructive one (uncommitted files die with the folder) in error tone. */\n.removeFacts_1808205761 {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin-top: 8px;\n}\n\n.removeFact_1808205761 {\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-secondary);\n}\n\n.removeFactWarn_1808205761 {\n color: var(--dsw-alias-state-error-primary);\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
3677
  const tagId = "@laoyuehanni/dsh-git-worktree/GroupedSidebar.module.css";
3431
3678
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId + "\"]") === null) {
3432
3679
  const tag = document.createElement("style");
@@ -3473,6 +3720,9 @@ window.__ModuleLoader__.load({
3473
3720
  "renameError": "renameError_1808205761",
3474
3721
  "deleteAction": "deleteAction_1808205761",
3475
3722
  "deleteStatus": "deleteStatus_1808205761",
3723
+ "removeFacts": "removeFacts_1808205761",
3724
+ "removeFact": "removeFact_1808205761",
3725
+ "removeFactWarn": "removeFactWarn_1808205761",
3476
3726
  "modalAction": "modalAction_1808205761",
3477
3727
  "modalError": "modalError_1808205761",
3478
3728
  "menuStatus": "menuStatus_1808205761",
@@ -3708,7 +3958,7 @@ window.__ModuleLoader__.load({
3708
3958
  const parsed = Date.parse(createdAt);
3709
3959
  return Number.isNaN(parsed) ? void 0 : parsed;
3710
3960
  }
3711
- function GroupedTree({ groups, sessions, archived, currentSessionId, expandMap, onToggle, expandTo, orderBy, now, home, onOpen, onRename, onFork, onArchive, onWorkspaceRename, onWorkspaceDelete, startSession, t }) {
3961
+ function GroupedTree({ groups, footer, sessions, archived, currentSessionId, expandMap, onToggle, expandTo, orderBy, now, home, onOpen, onRename, onFork, onArchive, onWorkspaceRename, onWorkspaceDelete, onWorktreeRemove, startSession, t }) {
3712
3962
  const descendants = (0, react.useMemo)(() => indexSubagentRunning(sessions.byId), [sessions.byId]);
3713
3963
  const [expandedSessionGroups, setExpandedSessionGroups] = (0, react.useState)([]);
3714
3964
  const empty = groups.length === 0;
@@ -3718,34 +3968,66 @@ window.__ModuleLoader__.load({
3718
3968
  className: GroupedSidebar_module_default.list,
3719
3969
  role: "tree",
3720
3970
  "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", {
3971
+ children: [
3972
+ empty && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3973
+ className: GroupedSidebar_module_default.empty,
3974
+ children: t("empty.none")
3975
+ }),
3976
+ groups.map((group) => {
3977
+ if (group.kind === "repo") {
3978
+ const memberIds = group.members.map((member) => orderedVisibleSessionIds(member.workspace, sessions, archived, orderBy));
3979
+ const visibleCount = memberIds.reduce((sum, ids) => sum + ids.length, 0);
3980
+ const containsCurrent = group.members.some((member) => member.workspace.sessionIds.includes(currentSessionId ?? "\0"));
3981
+ const open = expandMap[group.key] ?? containsCurrent;
3982
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3983
+ className: GroupedSidebar_module_default.groupSection,
3984
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProjectRowItem, {
3985
+ row: {
3986
+ key: group.key,
3987
+ label: group.repoName ?? group.key,
3988
+ expanded: open,
3989
+ containsCurrent
3990
+ },
3991
+ onToggle: () => {
3992
+ onToggle(group.key);
3993
+ },
3994
+ home,
3995
+ t,
3996
+ badge: String(visibleCount)
3997
+ }), open && group.members.map((member, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemberBlock, {
3998
+ member,
3999
+ indent: true,
4000
+ sessionIds: memberIds[index] ?? [],
4001
+ sessions,
4002
+ currentSessionId,
4003
+ expandMap,
4004
+ onToggle,
4005
+ expandTo,
4006
+ descendants,
4007
+ expandedSessionGroups,
4008
+ setExpandedSessionGroups,
4009
+ now,
4010
+ home,
4011
+ onOpen,
4012
+ onRename,
4013
+ onFork,
4014
+ onArchive,
4015
+ onWorkspaceRename,
4016
+ onWorkspaceDelete,
4017
+ onWorktreeRemove,
4018
+ startSession,
4019
+ t
4020
+ }, member.workspace.workspaceId))]
4021
+ }, group.key);
4022
+ }
4023
+ const member = group.members[0];
4024
+ if (member === void 0) return null;
4025
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3731
4026
  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, {
4027
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemberBlock, {
3746
4028
  member,
3747
- indent: true,
3748
- sessionIds: memberIds[index] ?? [],
4029
+ indent: false,
4030
+ sessionIds: orderedVisibleSessionIds(member.workspace, sessions, archived, orderBy),
3749
4031
  sessions,
3750
4032
  currentSessionId,
3751
4033
  expandMap,
@@ -3762,44 +4044,18 @@ window.__ModuleLoader__.load({
3762
4044
  onArchive,
3763
4045
  onWorkspaceRename,
3764
4046
  onWorkspaceDelete,
4047
+ onWorktreeRemove,
3765
4048
  startSession,
3766
4049
  t
3767
- }, member.workspace.workspaceId))]
4050
+ })
3768
4051
  }, 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
- })]
4052
+ }),
4053
+ footer
4054
+ ]
3799
4055
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: GroupedSidebar_module_default.fade })]
3800
4056
  });
3801
4057
  }
3802
- function MemberBlock({ member, indent, sessionIds, sessions, currentSessionId, expandMap, onToggle, expandTo, descendants, expandedSessionGroups, setExpandedSessionGroups, now, home, onOpen, onRename, onFork, onArchive, onWorkspaceRename, onWorkspaceDelete, startSession, t }) {
4058
+ function MemberBlock({ member, indent, sessionIds, sessions, currentSessionId, expandMap, onToggle, expandTo, descendants, expandedSessionGroups, setExpandedSessionGroups, now, home, onOpen, onRename, onFork, onArchive, onWorkspaceRename, onWorkspaceDelete, onWorktreeRemove, startSession, t }) {
3803
4059
  const key = `ws:${member.workspace.workspaceId}`;
3804
4060
  const containsCurrent = member.workspace.sessionIds.includes(currentSessionId ?? "\0");
3805
4061
  const open = expandMap[key] ?? containsCurrent;
@@ -3812,6 +4068,9 @@ window.__ModuleLoader__.load({
3812
4068
  if (summary !== void 0) nodes.push(sessionNode(summary, descendants));
3813
4069
  }
3814
4070
  const created = createdAtMs(member.workspace.createdAt);
4071
+ const hasRunning = member.workspace.sessionIds.some((id) => sessions.byId[id]?.running === true);
4072
+ const occupied = containsCurrent || hasRunning;
4073
+ const canRemoveWorktree = member.label.type === "linked" && !occupied;
3815
4074
  const body = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProjectRowItem, {
3816
4075
  row: {
3817
4076
  key,
@@ -3834,7 +4093,10 @@ window.__ModuleLoader__.load({
3834
4093
  },
3835
4094
  delete: () => {
3836
4095
  onWorkspaceDelete(member.workspace.workspaceId, member.workspace.title);
3837
- }
4096
+ },
4097
+ ...canRemoveWorktree ? { removeWorktree: () => {
4098
+ onWorktreeRemove(member);
4099
+ } } : {}
3838
4100
  },
3839
4101
  home,
3840
4102
  t
@@ -4123,7 +4385,197 @@ window.__ModuleLoader__.load({
4123
4385
  setDeleteError(reason instanceof Error ? reason.message : String(reason));
4124
4386
  });
4125
4387
  };
4388
+ const [wtRemoveTarget, setWtRemoveTarget] = (0, react.useState)(null);
4389
+ const [wtInspect, setWtInspect] = (0, react.useState)({ status: "loading" });
4390
+ const [wtRemoving, setWtRemoving] = (0, react.useState)(false);
4391
+ const [wtRemoveError, setWtRemoveError] = (0, react.useState)(null);
4392
+ (0, react.useEffect)(() => {
4393
+ if (wtRemoveTarget === null) return;
4394
+ setWtInspect({ status: "loading" });
4395
+ let live = true;
4396
+ props.inspectWorktree(wtRemoveTarget.workspace.path).then((facts) => {
4397
+ if (live) setWtInspect({
4398
+ status: "ready",
4399
+ dirty: facts.dirty,
4400
+ ahead: facts.ahead
4401
+ });
4402
+ }, (reason) => {
4403
+ if (live) setWtInspect({
4404
+ status: "error",
4405
+ error: reason instanceof Error ? reason.message : String(reason)
4406
+ });
4407
+ });
4408
+ return () => {
4409
+ live = false;
4410
+ };
4411
+ }, [wtRemoveTarget]);
4412
+ const archivedSet = (0, react.useMemo)(() => new Set(archived), [archived]);
4413
+ const wtArchiveIds = wtRemoveTarget === null ? [] : wtRemoveTarget.workspace.sessionIds.filter((id) => {
4414
+ const summary = sessionList.byId[id];
4415
+ return summary !== void 0 && !archivedSet.has(id) && !summary.blank && summary.origin !== "subagent";
4416
+ });
4417
+ const closeWtRemove = () => {
4418
+ if (wtRemoving) return;
4419
+ setWtRemoveTarget(null);
4420
+ setWtRemoveError(null);
4421
+ };
4422
+ const confirmWtRemove = () => {
4423
+ if (wtRemoving || wtRemoveTarget === null || wtInspect.status !== "ready") return;
4424
+ const target = wtRemoveTarget;
4425
+ setWtRemoving(true);
4426
+ setWtRemoveError(null);
4427
+ (async () => {
4428
+ try {
4429
+ await props.removeWorktree(target.workspace.path, wtInspect.dirty > 0);
4430
+ for (const sessionId of wtArchiveIds) await props.archiveSession(sessionId).catch((reason) => {
4431
+ console.warn("session archive rejected during worktree removal:", reason);
4432
+ });
4433
+ await props.deleteWorkspace(target.workspace.workspaceId);
4434
+ setWtRemoving(false);
4435
+ setWtRemoveTarget(null);
4436
+ } catch (reason) {
4437
+ setWtRemoving(false);
4438
+ setWtRemoveError(reason instanceof Error ? reason.message : String(reason));
4439
+ }
4440
+ })();
4441
+ };
4126
4442
  const now = Date.now();
4443
+ const strayGroups = (0, react.useMemo)(() => deriveStrayGroups(items, sessionList, archived), [
4444
+ items,
4445
+ sessionList,
4446
+ archived
4447
+ ]);
4448
+ const strayDescendants = (0, react.useMemo)(() => indexSubagentRunning(sessionList.byId), [sessionList.byId]);
4449
+ const strayProbePaths = (0, react.useMemo)(() => [...new Set(strayGroups.filter((group) => group.belongsTo === void 0 && group.path !== "").map((group) => group.path))], [strayGroups]);
4450
+ const strayProbeSignature = strayProbePaths.join("\n");
4451
+ const [strayDirExists, setStrayDirExists] = (0, react.useState)(void 0);
4452
+ const [straySlotRebuildable, setStraySlotRebuildable] = (0, react.useState)(void 0);
4453
+ (0, react.useEffect)(() => {
4454
+ if (strayProbePaths.length === 0) return;
4455
+ let live = true;
4456
+ props.probeDirectories(strayProbePaths).then((result) => {
4457
+ if (!live) return;
4458
+ setStrayDirExists(result?.exists);
4459
+ setStraySlotRebuildable(result?.rebuildable);
4460
+ }, () => {
4461
+ if (live) {
4462
+ setStrayDirExists(void 0);
4463
+ setStraySlotRebuildable(void 0);
4464
+ }
4465
+ });
4466
+ return () => {
4467
+ live = false;
4468
+ };
4469
+ }, [strayProbeSignature]);
4470
+ const straySectionKey = "stray:section";
4471
+ const strayContainsCurrent = strayGroups.some((group) => group.sessions.some((session) => session.id === sessions.current));
4472
+ const straySectionOpen = expandMap[straySectionKey] ?? strayContainsCurrent;
4473
+ const strayTotal = strayGroups.reduce((sum, group) => sum + group.sessions.length, 0);
4474
+ const [strayRegPath, setStrayRegPath] = (0, react.useState)(null);
4475
+ const [toast, setToast] = (0, react.useState)(null);
4476
+ const registerStrayWorkspace = (path) => {
4477
+ if (strayRegPath !== null) return;
4478
+ setStrayRegPath(path);
4479
+ props.createWorkspace({ path }).then(() => {
4480
+ setStrayRegPath(null);
4481
+ }, (reason) => {
4482
+ setStrayRegPath(null);
4483
+ setToast({
4484
+ seq: Date.now(),
4485
+ text: t("stray.registerFailed", { message: reason instanceof Error ? reason.message : String(reason) })
4486
+ });
4487
+ });
4488
+ };
4489
+ const [strayRebuildPath, setStrayRebuildPath] = (0, react.useState)(null);
4490
+ const rebuildStrayDirectory = (path) => {
4491
+ if (strayRebuildPath !== null) return;
4492
+ setStrayRebuildPath(path);
4493
+ props.ensureDirectory(path).then(() => {
4494
+ setStrayRebuildPath(null);
4495
+ setToast({
4496
+ seq: Date.now(),
4497
+ text: t("stray.rebuildDone")
4498
+ });
4499
+ props.probeDirectories([path]).then((result) => {
4500
+ if (result === void 0) return;
4501
+ setStrayDirExists((current) => ({
4502
+ ...current,
4503
+ ...result.exists
4504
+ }));
4505
+ setStraySlotRebuildable((current) => ({
4506
+ ...current,
4507
+ ...result.rebuildable
4508
+ }));
4509
+ });
4510
+ }, (reason) => {
4511
+ setStrayRebuildPath(null);
4512
+ setToast({
4513
+ seq: Date.now(),
4514
+ text: t("stray.rebuildFailed", { message: reason instanceof Error ? reason.message : String(reason) })
4515
+ });
4516
+ });
4517
+ };
4518
+ const straySection = strayGroups.length === 0 ? void 0 : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4519
+ className: GroupedSidebar_module_default.groupSection,
4520
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProjectRowItem, {
4521
+ row: {
4522
+ key: straySectionKey,
4523
+ label: t("group.ungrouped"),
4524
+ expanded: straySectionOpen,
4525
+ containsCurrent: strayContainsCurrent
4526
+ },
4527
+ onToggle: () => {
4528
+ toggle(straySectionKey);
4529
+ },
4530
+ home,
4531
+ t,
4532
+ badge: String(strayTotal)
4533
+ }), straySectionOpen && strayGroups.map((group) => {
4534
+ const groupOpen = expandMap[group.key] ?? group.sessions.some((session) => session.id === sessions.current);
4535
+ const registrable = group.belongsTo === void 0 && group.path !== "" && strayDirExists?.[group.path] === true;
4536
+ const missingDir = group.belongsTo === void 0 && group.path !== "" && strayDirExists?.[group.path] === false;
4537
+ const rebuildable = missingDir && straySlotRebuildable?.[group.path] === true;
4538
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4539
+ className: cx(GroupedSidebar_module_default.groupSection, GroupedSidebar_module_default.memberIndent),
4540
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StrayGroupRow, {
4541
+ path: group.path,
4542
+ belongsTo: group.belongsTo,
4543
+ count: group.sessions.length,
4544
+ expanded: groupOpen,
4545
+ onToggle: () => {
4546
+ toggle(group.key);
4547
+ },
4548
+ missingDir,
4549
+ worktreeSlot: rebuildable,
4550
+ ...registrable ? {
4551
+ onRegister: () => {
4552
+ registerStrayWorkspace(group.path);
4553
+ },
4554
+ registering: strayRegPath === group.path
4555
+ } : rebuildable ? {
4556
+ onRebuild: () => {
4557
+ rebuildStrayDirectory(group.path);
4558
+ },
4559
+ rebuilding: strayRebuildPath === group.path
4560
+ } : {},
4561
+ home,
4562
+ t
4563
+ }), groupOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4564
+ className: GroupedSidebar_module_default.sessionsIndent,
4565
+ children: group.sessions.map((session) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionNodeItem, {
4566
+ node: sessionNode(session, strayDescendants),
4567
+ currentId: sessions.current,
4568
+ now,
4569
+ onOpen: props.openSession,
4570
+ onRename: onSessionRename,
4571
+ onFork: props.forkSession,
4572
+ onArchive: onSessionArchive,
4573
+ t
4574
+ }, session.id))
4575
+ })]
4576
+ }, group.key);
4577
+ })]
4578
+ });
4127
4579
  const wide = props.wide;
4128
4580
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4129
4581
  className: cx(GroupedSidebar_module_default.root, !wide && GroupedSidebar_module_default.rail),
@@ -4277,6 +4729,7 @@ window.__ModuleLoader__.load({
4277
4729
  t
4278
4730
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GroupedTree, {
4279
4731
  groups,
4732
+ footer: straySection,
4280
4733
  sessions: sessionList,
4281
4734
  archived,
4282
4735
  currentSessionId: sessions.current,
@@ -4305,6 +4758,10 @@ window.__ModuleLoader__.load({
4305
4758
  });
4306
4759
  setDeleteError(null);
4307
4760
  },
4761
+ onWorktreeRemove: (member) => {
4762
+ setWtRemoveTarget(member);
4763
+ setWtRemoveError(null);
4764
+ },
4308
4765
  startSession: props.startSession,
4309
4766
  t
4310
4767
  }))
@@ -4438,7 +4895,75 @@ window.__ModuleLoader__.load({
4438
4895
  role: "alert",
4439
4896
  children: deleteError
4440
4897
  })]
4441
- })
4898
+ }),
4899
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
4900
+ open: wtRemoveTarget !== null,
4901
+ onClose: closeWtRemove,
4902
+ closeLabel: t("close"),
4903
+ title: t("worktreeRemove.title"),
4904
+ ...wtRemoveTarget === null ? {} : { description: t("worktreeRemove.desc", { path: wtRemoveTarget.workspace.path }) },
4905
+ 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, {
4906
+ variant: "outline",
4907
+ disabled: wtRemoving,
4908
+ onClick: closeWtRemove,
4909
+ children: t("cancel")
4910
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4911
+ variant: "outline",
4912
+ className: GroupedSidebar_module_default.deleteAction,
4913
+ disabled: wtRemoving || wtInspect.status !== "ready",
4914
+ onClick: confirmWtRemove,
4915
+ children: t("worktreeRemove.menu")
4916
+ })] }),
4917
+ children: [
4918
+ wtRemoveTarget?.label.type === "linked" && wtRemoveTarget.label.branch !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4919
+ className: GroupedSidebar_module_default.removeFact,
4920
+ children: t("worktreeRemove.descBranch", { branch: wtRemoveTarget.label.branch })
4921
+ }),
4922
+ wtInspect.status === "loading" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4923
+ className: GroupedSidebar_module_default.deleteStatus,
4924
+ role: "status",
4925
+ children: t("worktreeRemove.inspecting")
4926
+ }),
4927
+ wtInspect.status === "error" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4928
+ className: GroupedSidebar_module_default.renameError,
4929
+ role: "alert",
4930
+ children: wtInspect.error
4931
+ }),
4932
+ wtInspect.status === "ready" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4933
+ className: GroupedSidebar_module_default.removeFacts,
4934
+ children: [
4935
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4936
+ className: cx(GroupedSidebar_module_default.removeFact, wtInspect.dirty > 0 && GroupedSidebar_module_default.removeFactWarn),
4937
+ children: wtInspect.dirty > 0 ? t(wtInspect.dirty === 1 ? "worktreeRemove.dirty.one" : "worktreeRemove.dirty.other", { n: wtInspect.dirty }) : t("worktreeRemove.clean")
4938
+ }),
4939
+ wtInspect.ahead !== void 0 && wtInspect.ahead > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4940
+ className: GroupedSidebar_module_default.removeFact,
4941
+ children: t("worktreeRemove.ahead", { n: wtInspect.ahead })
4942
+ }),
4943
+ wtArchiveIds.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4944
+ className: GroupedSidebar_module_default.removeFact,
4945
+ children: t(wtArchiveIds.length === 1 ? "worktreeRemove.sessions.one" : "worktreeRemove.sessions.other", { n: wtArchiveIds.length })
4946
+ })
4947
+ ]
4948
+ }),
4949
+ wtRemoving && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4950
+ className: GroupedSidebar_module_default.deleteStatus,
4951
+ role: "status",
4952
+ children: t("worktreeRemove.busy")
4953
+ }),
4954
+ wtRemoveError !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4955
+ className: GroupedSidebar_module_default.renameError,
4956
+ role: "alert",
4957
+ children: wtRemoveError
4958
+ })
4959
+ ]
4960
+ }),
4961
+ toast !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
4962
+ text: toast.text,
4963
+ onDone: () => {
4964
+ setToast(null);
4965
+ }
4966
+ }, toast.seq)
4442
4967
  ]
4443
4968
  });
4444
4969
  }
@@ -4547,6 +5072,29 @@ window.__ModuleLoader__.load({
4547
5072
  "delete.workspace": "Delete workspace",
4548
5073
  "delete.desc": "This removes “{name}” from the workspace list. The folder and session logs will be kept. Its sessions will appear under Ungrouped.",
4549
5074
  "delete.pending": "Deleting workspace…",
5075
+ "worktreeRemove.menu": "Remove worktree",
5076
+ "worktreeRemove.title": "Remove worktree",
5077
+ "worktreeRemove.desc": "This removes the worktree from git and deletes the folder “{path}”.",
5078
+ "worktreeRemove.descBranch": "The branch {branch} is kept.",
5079
+ "worktreeRemove.inspecting": "Inspecting worktree…",
5080
+ "worktreeRemove.dirty.one": "{n} uncommitted file will be deleted with the folder.",
5081
+ "worktreeRemove.dirty.other": "{n} uncommitted files will be deleted with the folder.",
5082
+ "worktreeRemove.clean": "No uncommitted changes.",
5083
+ "worktreeRemove.ahead": "{n} commits ahead of upstream, kept on the branch.",
5084
+ "worktreeRemove.sessions.one": "{n} session in this workspace will be archived too.",
5085
+ "worktreeRemove.sessions.other": "{n} sessions in this workspace will be archived too.",
5086
+ "worktreeRemove.busy": "Removing…",
5087
+ "stray.unknown": "(unknown directory)",
5088
+ "stray.belongsTo": "Stray sessions of “{name}”",
5089
+ "stray.missingDir": "Directory no longer exists — registering is unavailable",
5090
+ "stray.worktreeSlot": "A worktree storage slot: rebuild this directory (e.g. git worktree add) and its historical sessions reattach automatically",
5091
+ "stray.rebuild": "Rebuild empty directory",
5092
+ "stray.rebuild.aria": "Rebuild the directory “{name}”",
5093
+ "stray.rebuildDone": "Directory rebuilt; its historical sessions will reattach automatically",
5094
+ "stray.rebuildFailed": "Rebuild failed: {message}",
5095
+ "stray.register": "Register as workspace",
5096
+ "stray.register.aria": "Register “{name}” as a workspace",
5097
+ "stray.registerFailed": "Registration failed: {message}",
4550
5098
  "menu.fork": "Fork session",
4551
5099
  "menu.archiveSession": "Archive session",
4552
5100
  "sessions.count.one": "{n} session",
@@ -4679,6 +5227,29 @@ window.__ModuleLoader__.load({
4679
5227
  "delete.workspace": "删除工作区",
4680
5228
  "delete.desc": "将把“{name}”从工作区列表中移除。文件夹与会话记录会保留,其会话将显示在“未分组”下。",
4681
5229
  "delete.pending": "正在删除工作区…",
5230
+ "worktreeRemove.menu": "删除工作树",
5231
+ "worktreeRemove.title": "删除工作树",
5232
+ "worktreeRemove.desc": "将从 git 移除该工作树并删除目录“{path}”。",
5233
+ "worktreeRemove.descBranch": "分支 {branch} 将保留。",
5234
+ "worktreeRemove.inspecting": "正在检查工作树…",
5235
+ "worktreeRemove.dirty.one": "{n} 个未提交文件将随目录一并删除。",
5236
+ "worktreeRemove.dirty.other": "{n} 个未提交文件将随目录一并删除。",
5237
+ "worktreeRemove.clean": "无未提交改动。",
5238
+ "worktreeRemove.ahead": "分支领先上游 {n} 个提交,提交将保留在分支上。",
5239
+ "worktreeRemove.sessions.one": "该工作区下的 {n} 个会话将一并归档。",
5240
+ "worktreeRemove.sessions.other": "该工作区下的 {n} 个会话将一并归档。",
5241
+ "worktreeRemove.busy": "删除中…",
5242
+ "stray.unknown": "(目录未知)",
5243
+ "stray.belongsTo": "属于“{name}”的失联会话",
5244
+ "stray.missingDir": "目录已不存在,无法注册",
5245
+ "stray.worktreeSlot": "工作树存放位:重建此目录(如 git worktree add)后,其历史会话将自动归位",
5246
+ "stray.rebuild": "重建空目录",
5247
+ "stray.rebuild.aria": "重建目录“{name}”",
5248
+ "stray.rebuildDone": "目录已重建,其历史会话将自动归位",
5249
+ "stray.rebuildFailed": "重建失败:{message}",
5250
+ "stray.register": "注册为工作区",
5251
+ "stray.register.aria": "将“{name}”注册为工作区",
5252
+ "stray.registerFailed": "注册失败:{message}",
4682
5253
  "menu.fork": "分叉会话",
4683
5254
  "menu.archiveSession": "归档会话",
4684
5255
  "sessions.count.one": "{n} 个会话",
@@ -4859,6 +5430,29 @@ window.__ModuleLoader__.load({
4859
5430
  archiveSession: async (sessionId) => {
4860
5431
  await ctx.workspaces.archiveSession(sessionId);
4861
5432
  },
5433
+ inspectWorktree: async (path) => {
5434
+ const result = await requestInspectWorktree(path);
5435
+ if (!result.ok) throw new Error(result.error);
5436
+ return {
5437
+ dirty: result.dirty,
5438
+ ahead: result.ahead
5439
+ };
5440
+ },
5441
+ removeWorktree: async (path, force) => {
5442
+ const result = await requestRemoveWorktree(path, force);
5443
+ if (!result.ok) throw new Error(result.error);
5444
+ },
5445
+ probeDirectories: async (paths) => {
5446
+ const result = await requestPathExists(paths);
5447
+ return result.ok ? {
5448
+ exists: result.exists,
5449
+ ...result.rebuildable === void 0 ? {} : { rebuildable: result.rebuildable }
5450
+ } : void 0;
5451
+ },
5452
+ ensureDirectory: async (path) => {
5453
+ const result = await requestEnsureDirectory(path);
5454
+ if (!result.ok) throw new Error(result.error);
5455
+ },
4862
5456
  createWorkspace: (input) => ctx.workspaces.create(input),
4863
5457
  pickDirectory: () => ctx.workspaces.pickDirectory(),
4864
5458
  hostDescription: ctx.get("connection").hostDescription,