@laoyuehanni/dsh-git-worktree 0.4.4 → 0.4.5
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/README.md +6 -5
- package/README.zh.md +6 -5
- package/lib/client.js +2565 -889
- package/lib/git.d.ts +66 -8
- package/lib/git.js +83 -12
- package/lib/index.d.ts +28 -2
- package/lib/index.js +51 -6
- package/lib/routes.d.ts +70 -5
- package/lib/routes.js +241 -12
- package/lib/wire.d.ts +97 -4
- package/lib/wire.js +14 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -60,8 +60,15 @@ window.__ModuleLoader__.load({
|
|
|
60
60
|
const ROUTE_WORKTREE = `${ROUTE_PREFIX}/worktree`;
|
|
61
61
|
/** POST ROUTE_PREFIX/switch — in-place branch switch of the main checkout. */
|
|
62
62
|
const ROUTE_SWITCH = `${ROUTE_PREFIX}/switch`;
|
|
63
|
-
/** POST ROUTE_PREFIX/branch — create a NEW branch
|
|
63
|
+
/** POST ROUTE_PREFIX/branch — create a NEW branch (at the current checkout
|
|
64
|
+
* or an explicit start point, with or without checking it out). */
|
|
64
65
|
const ROUTE_BRANCH = `${ROUTE_PREFIX}/branch`;
|
|
66
|
+
/** POST ROUTE_PREFIX/branch-rename — rename a LOCAL branch (refs are
|
|
67
|
+
* repository-wide; worktree HEADs pointing at it follow). */
|
|
68
|
+
const ROUTE_BRANCH_RENAME = `${ROUTE_PREFIX}/branch-rename`;
|
|
69
|
+
/** POST ROUTE_PREFIX/branch-delete — delete a LOCAL branch (`-d`, merged
|
|
70
|
+
* only; git refuses the rest). */
|
|
71
|
+
const ROUTE_BRANCH_DELETE = `${ROUTE_PREFIX}/branch-delete`;
|
|
65
72
|
/** POST ROUTE_PREFIX/fetch — sync remote-tracking refs (fetch every remote + prune). */
|
|
66
73
|
const ROUTE_FETCH = `${ROUTE_PREFIX}/fetch`;
|
|
67
74
|
/** POST ROUTE_PREFIX/update — fast-forward the current branch to its upstream. */
|
|
@@ -76,6 +83,12 @@ window.__ModuleLoader__.load({
|
|
|
76
83
|
const ROUTE_EXISTS = `${ROUTE_PREFIX}/exists`;
|
|
77
84
|
/** POST ROUTE_PREFIX/ensure-directory — mkdir -p a missing worktree storage slot. */
|
|
78
85
|
const ROUTE_ENSURE_DIRECTORY = `${ROUTE_PREFIX}/ensure-directory`;
|
|
86
|
+
/** POST ROUTE_PREFIX/worktrees-all — scan the storage root: git facts for
|
|
87
|
+
* every direct child directory (the plugin-planned worktree slots). */
|
|
88
|
+
const ROUTE_WORKTREES_ALL = `${ROUTE_PREFIX}/worktrees-all`;
|
|
89
|
+
/** POST ROUTE_PREFIX/purge — delete a NON-git directory sitting DIRECTLY in
|
|
90
|
+
* the storage root (an orphaned leftover whose .git is already gone). */
|
|
91
|
+
const ROUTE_PURGE = `${ROUTE_PREFIX}/purge`;
|
|
79
92
|
//#endregion
|
|
80
93
|
//#region src/client/api.ts
|
|
81
94
|
/** POST one JSON body and parse the uniform envelope. */
|
|
@@ -90,7 +103,15 @@ window.__ModuleLoader__.load({
|
|
|
90
103
|
headers: { "content-type": "application/json" },
|
|
91
104
|
body: JSON.stringify(body)
|
|
92
105
|
});
|
|
93
|
-
|
|
106
|
+
let payload;
|
|
107
|
+
try {
|
|
108
|
+
payload = await response.json();
|
|
109
|
+
} catch {
|
|
110
|
+
return {
|
|
111
|
+
ok: false,
|
|
112
|
+
error: `HTTP ${String(response.status)}`
|
|
113
|
+
};
|
|
114
|
+
}
|
|
94
115
|
if (!response.ok) return {
|
|
95
116
|
ok: false,
|
|
96
117
|
error: payload.error ?? `HTTP ${String(response.status)}`
|
|
@@ -167,13 +188,50 @@ window.__ModuleLoader__.load({
|
|
|
167
188
|
});
|
|
168
189
|
}
|
|
169
190
|
/**
|
|
170
|
-
* Create a NEW branch from the directory's current
|
|
171
|
-
* in place.
|
|
172
|
-
*
|
|
191
|
+
* Create a NEW branch. Without `from`: cut from the directory's current
|
|
192
|
+
* checkout and switch to it in place (the original in-place shape). With
|
|
193
|
+
* `from` (a local branch or remote-tracking ref): created AT that start
|
|
194
|
+
* point — left unchecked-out by default (the row menu's 新建), or checked
|
|
195
|
+
* out here too with `checkout` (the row menu's 新建并检出).
|
|
196
|
+
* @param repoPath - absolute directory inside the repository.
|
|
173
197
|
* @param name - user-typed new branch name (validated client-side already).
|
|
198
|
+
* @param from - optional start point; absent keeps the in-place semantics.
|
|
199
|
+
* @param checkout - with `from`, also check the new branch out here.
|
|
174
200
|
*/
|
|
175
|
-
function requestCreateBranch(repoPath, name) {
|
|
201
|
+
function requestCreateBranch(repoPath, name, from, checkout) {
|
|
202
|
+
if (from === void 0) return post(ROUTE_BRANCH, {
|
|
203
|
+
repoPath,
|
|
204
|
+
name
|
|
205
|
+
});
|
|
176
206
|
return post(ROUTE_BRANCH, {
|
|
207
|
+
repoPath,
|
|
208
|
+
name,
|
|
209
|
+
from,
|
|
210
|
+
...checkout === true ? { checkout: true } : {}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Rename a LOCAL branch (`git branch -m`); repository-wide, worktree HEADs
|
|
215
|
+
* follow.
|
|
216
|
+
* @param repoPath - absolute directory inside the repository.
|
|
217
|
+
* @param name - branch to rename.
|
|
218
|
+
* @param newName - user-typed new name (validated client-side already).
|
|
219
|
+
*/
|
|
220
|
+
function requestRenameBranch(repoPath, name, newName) {
|
|
221
|
+
return post(ROUTE_BRANCH_RENAME, {
|
|
222
|
+
repoPath,
|
|
223
|
+
name,
|
|
224
|
+
newName
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Delete a LOCAL branch with the safe form (`git branch -d`); git refuses
|
|
229
|
+
* unmerged commits and branches checked out in any worktree.
|
|
230
|
+
* @param repoPath - absolute directory inside the repository.
|
|
231
|
+
* @param name - branch to delete.
|
|
232
|
+
*/
|
|
233
|
+
function requestDeleteBranch(repoPath, name) {
|
|
234
|
+
return post(ROUTE_BRANCH_DELETE, {
|
|
177
235
|
repoPath,
|
|
178
236
|
name
|
|
179
237
|
});
|
|
@@ -240,15 +298,152 @@ window.__ModuleLoader__.load({
|
|
|
240
298
|
function requestEnsureDirectory(path) {
|
|
241
299
|
return post(ROUTE_ENSURE_DIRECTORY, { path });
|
|
242
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Scan the worktree storage root: git facts for every direct child directory
|
|
303
|
+
* (the slots this plugin plans). Orphan/foreign folders answer null facts —
|
|
304
|
+
* the manager dialog shows them as unrecognized.
|
|
305
|
+
*/
|
|
306
|
+
function requestWorktreesAll() {
|
|
307
|
+
return post(ROUTE_WORKTREES_ALL, {});
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Delete a NON-git directory sitting directly inside the storage root (an
|
|
311
|
+
* orphaned leftover whose .git is already gone). The host triple-gates this:
|
|
312
|
+
* slot boundary, real directory, no git identity — anything git still
|
|
313
|
+
* recognizes must go through requestRemoveWorktree instead.
|
|
314
|
+
* @param path - the leftover directory (absolute).
|
|
315
|
+
*/
|
|
316
|
+
function requestPurgeDirectory(path) {
|
|
317
|
+
return post(ROUTE_PURGE, { path });
|
|
318
|
+
}
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/client/branch-tree.ts
|
|
321
|
+
/** Segment order: natural (so `v2` precedes `v10`) and case-blind. */
|
|
322
|
+
const segCmp = (a, b) => a.localeCompare(b, void 0, {
|
|
323
|
+
numeric: true,
|
|
324
|
+
sensitivity: "base"
|
|
325
|
+
});
|
|
326
|
+
/** Expanded-key space: folder paths carry their group prefix so a local
|
|
327
|
+
* folder can never share a toggle state with a same-named remote display
|
|
328
|
+
* folder (`feat/x` on both sides). Group OPEN flags stay booleans beside
|
|
329
|
+
* this set — they are not part of the path namespace at all. */
|
|
330
|
+
const groupKey = (group, path) => `${group}:${path}`;
|
|
331
|
+
/**
|
|
332
|
+
* Split rows into the three groups and derive the remote display names.
|
|
333
|
+
* @param rows - the flat row list, in host order.
|
|
334
|
+
* @returns the three groups plus the display→action map for remotes.
|
|
335
|
+
*/
|
|
336
|
+
function groupRows(rows) {
|
|
337
|
+
const localRows = [];
|
|
338
|
+
const remoteRows = [];
|
|
339
|
+
const worktreeRows = [];
|
|
340
|
+
for (const row of rows) if (row.kind === "remote") remoteRows.push(row);
|
|
341
|
+
else if (row.kind === "worktree") worktreeRows.push(row);
|
|
342
|
+
else localRows.push(row);
|
|
343
|
+
const first = remoteRows[0]?.name ?? "";
|
|
344
|
+
const slash = first.indexOf("/");
|
|
345
|
+
const soleRemote = slash > 0 && remoteRows.every((row) => row.name.startsWith(first.slice(0, slash + 1))) ? first.slice(0, slash) : void 0;
|
|
346
|
+
const display = (name) => soleRemote === void 0 ? name : name.slice(soleRemote.length + 1);
|
|
347
|
+
return {
|
|
348
|
+
localRows,
|
|
349
|
+
remoteDisplayRows: remoteRows.map((row) => ({
|
|
350
|
+
...row,
|
|
351
|
+
name: display(row.name)
|
|
352
|
+
})),
|
|
353
|
+
worktreeRows,
|
|
354
|
+
remoteNameMap: new Map(remoteRows.map((row) => [display(row.name), row.name]))
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Build the prefix tree of the rows (see TreeNode).
|
|
359
|
+
* @param rows - the rows of ONE group, named as they display.
|
|
360
|
+
* @returns the root level, sorted folders-first and totalled.
|
|
361
|
+
*/
|
|
362
|
+
function buildTree(rows) {
|
|
363
|
+
const root = [];
|
|
364
|
+
const find = (level, segment) => level.find((n) => n.segment === segment);
|
|
365
|
+
for (const row of rows) {
|
|
366
|
+
const segs = row.name.split("/").filter((s) => s !== "");
|
|
367
|
+
let level = root;
|
|
368
|
+
let path = "";
|
|
369
|
+
for (let i = 0; i < segs.length; i += 1) {
|
|
370
|
+
const seg = segs[i];
|
|
371
|
+
if (seg === void 0) break;
|
|
372
|
+
path = path === "" ? seg : `${path}/${seg}`;
|
|
373
|
+
let node = find(level, seg);
|
|
374
|
+
if (node === void 0) {
|
|
375
|
+
node = {
|
|
376
|
+
segment: seg,
|
|
377
|
+
path,
|
|
378
|
+
depth: i,
|
|
379
|
+
leaf: null,
|
|
380
|
+
children: [],
|
|
381
|
+
total: 0
|
|
382
|
+
};
|
|
383
|
+
level.push(node);
|
|
384
|
+
}
|
|
385
|
+
if (i === segs.length - 1) node.leaf = row;
|
|
386
|
+
level = node.children;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
const finish = (nodes) => {
|
|
390
|
+
for (const node of nodes) finish(node.children);
|
|
391
|
+
nodes.sort((a, b) => {
|
|
392
|
+
const af = a.children.length > 0 ? 0 : 1;
|
|
393
|
+
const bf = b.children.length > 0 ? 0 : 1;
|
|
394
|
+
return af !== bf ? af - bf : segCmp(a.segment, b.segment);
|
|
395
|
+
});
|
|
396
|
+
};
|
|
397
|
+
finish(root);
|
|
398
|
+
const count = (nodes) => {
|
|
399
|
+
for (const node of nodes) {
|
|
400
|
+
count(node.children);
|
|
401
|
+
node.total = (node.leaf === null ? 0 : 1) + node.children.reduce((sum, c) => sum + c.total, 0);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
count(root);
|
|
405
|
+
return root;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Every folder path that renders a header, walking the tree depth-first.
|
|
409
|
+
* @param nodes - a tree level (the root list at the top call).
|
|
410
|
+
* @param out - accumulator, for the recursion.
|
|
411
|
+
* @returns the folder paths in render order.
|
|
412
|
+
*/
|
|
413
|
+
function collectFolderPaths(nodes, out = []) {
|
|
414
|
+
for (const node of nodes) if (node.children.length > 0) {
|
|
415
|
+
out.push(node.path);
|
|
416
|
+
collectFolderPaths(node.children, out);
|
|
417
|
+
}
|
|
418
|
+
return out;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* The folders that must start expanded so the checked-out branch is
|
|
422
|
+
* immediately visible in the tree: every proper ancestor of its path.
|
|
423
|
+
* @param branch - the branch name (a bare name has no ancestors).
|
|
424
|
+
* @returns the ancestor folder paths, unprefixed.
|
|
425
|
+
*/
|
|
426
|
+
function chainExpanded(branch) {
|
|
427
|
+
const segs = branch.split("/").filter((s) => s !== "");
|
|
428
|
+
const set = /* @__PURE__ */ new Set();
|
|
429
|
+
let path = "";
|
|
430
|
+
for (let i = 0; i < segs.length - 1; i += 1) {
|
|
431
|
+
const seg = segs[i];
|
|
432
|
+
if (seg === void 0) break;
|
|
433
|
+
path = path === "" ? seg : `${path}/${seg}`;
|
|
434
|
+
set.add(path);
|
|
435
|
+
}
|
|
436
|
+
return set;
|
|
437
|
+
}
|
|
243
438
|
//#endregion
|
|
244
439
|
//#region \0git-worktree-css:D:\Code\dsh-worktree\src\client\BranchChip.module.css?inline
|
|
245
|
-
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: r20, elevation-prominent\n * hairline, --dsw-specific-menu — host 0.1.2 Menu card; hosts without\n * the token fall back to the old r12-era shadow-lv3). 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: 0;\n border-radius: 20px;\n background: var(--dsw-specific-menu, var(--dsw-alias-surface-raised, #ffffff));\n /* Elevation-prominent carries the hairline stroke; the lv3 fallback\n * keeps a shadow where the token does not exist. */\n box-shadow: var(--dsw-elevation-prominent, 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: 0;\n border-radius: 20px;\n background: var(--dsw-specific-menu, var(--dsw-alias-surface-raised, #ffffff));\n /* Same elevation card as .popCard_2006230319 (host 0.1.2 Menu); lv3 fallback\n * for hosts without the token. */\n box-shadow: var(--dsw-elevation-prominent, 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: 0.5px 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: 0.5px 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";
|
|
246
|
-
const tagId$
|
|
247
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId$
|
|
440
|
+
const css$4 = "/* Branch chip row inside the composer tool row (conversation.input_2006230319.left_2006230319,\n * right of the mode chips). A single chip button: the branch picker (the\n * worktree toggle that used to share this dock is gone — worktree actions\n * live in the branch menu's right-click).\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). */\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.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.branch_2006230319 {\n max-width: 16em;\n overflow: hidden;\n text-overflow: ellipsis;\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: r20, elevation-prominent\n * hairline, --dsw-specific-menu — host 0.1.2 Menu card; hosts without\n * the token fall back to the old r12-era shadow-lv3). 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: 0;\n border-radius: 20px;\n background: var(--dsw-specific-menu, var(--dsw-alias-surface-raised, #ffffff));\n /* Elevation-prominent carries the hairline stroke; the lv3 fallback\n * keeps a shadow where the token does not exist. */\n box-shadow: var(--dsw-elevation-prominent, 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: 0;\n border-radius: 20px;\n background: var(--dsw-specific-menu, var(--dsw-alias-surface-raised, #ffffff));\n /* Same elevation card as .popCard_2006230319 (host 0.1.2 Menu); lv3 fallback\n * for hosts without the token. */\n box-shadow: var(--dsw-elevation-prominent, 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: 0.5px 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/* 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: 0.5px 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/* ── Create/rename flyouts (BranchMenu row context menu) ────────────\n * Open IN PLACE of the row menu (at its point, clamped) and hold the whole\n * flow in one panel: ask line, input, live hint, and the Cancel/confirm\n * pair — typing the name and pressing the button fires in one stroke, no\n * second confirm step. */\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\n/* ── Row context menu (BranchMenu right-click) ─────────────────────\n * Cursor-anchored transient over the branch card: the same card chrome\n * family as .popCard_2006230319 (--dsw-specific-menu, elevation-prominent hairline,\n * lv3 fallback) at a smaller radius — r20 would round a launcher this\n * short into a pill, r12 keeps the corners proportionate to a handful of\n * rows (two on a worktree row, up to six plus a header on a branch row).\n * Width hugs the widest item\n * (shrink-to-fit, no design width) with a generous cap for safety —\n * a launcher reads better snug than stretched. Positioned once at open\n * and dismissed rather than re-placed when the page moves (see\n * BranchMenu's ctx placement pass); z-index one step above the popCard so\n * it never slides under the confirm flyout. */\n.ctxCard_2006230319 {\n box-sizing: border-box;\n position: fixed;\n z-index: 1001;\n width: max-content;\n max-width: 280px;\n padding: 4px;\n border: 0;\n border-radius: 12px;\n background: var(--dsw-specific-menu, var(--dsw-alias-surface-raised, #ffffff));\n box-shadow: var(--dsw-elevation-prominent, var(--dsw-shadow-lv3));\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n/* The target row's name, above the verbs. Unlike the items this one holds\n * a branch name, so it is the one line allowed to hit the 280px cap and\n * ellipsize (the full name rides in a title). Secondary tone and no hover\n * affordance: it is a label, not a seventh item. */\n.ctxHeader_2006230319 {\n padding: 4px 8px 2px;\n font-size: 12px;\n line-height: 16px;\n color: var(--dsw-alias-label-secondary);\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n\n/* Menu-item rows: the .menuRow_2006230319 geometry at a hair lighter weight — a\n * launcher's labels read as commands, not data. nowrap: the labels are\n * fixed copy (no branch names), the 280px cap is unreachable by design. */\n.ctxItem_2006230319 {\n display: inline-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 line-height: 20px;\n text-align: left;\n white-space: nowrap;\n cursor: pointer;\n}\n\n.ctxItem_2006230319:hover,\n.ctxItem_2006230319:focus-visible {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* The arrow-key walk lands here, so the focused item must read as strongly\n * as a hovered one — the tint above carries it, the default ring would sit\n * outside the 8px radius. */\n.ctxItem_2006230319:focus-visible {\n outline: none;\n}\n\n/* Leading glyph rides the label tone, a step quieter. */\n.ctxItem_2006230319 svg {\n flex-shrink: 0;\n opacity: 0.75;\n}\n\n.ctxItemLabel_2006230319 {\n flex: 1 1 0;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n";
|
|
441
|
+
const tagId$4 = "@laoyuehanni/dsh-git-worktree/BranchChip.module.css";
|
|
442
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId$4 + "\"]") === null) {
|
|
248
443
|
const tag = document.createElement("style");
|
|
249
444
|
tag.dataset.plugin = "@laoyuehanni/dsh-git-worktree";
|
|
250
|
-
tag.dataset.pluginCss = tagId$
|
|
251
|
-
tag.textContent = css$
|
|
445
|
+
tag.dataset.pluginCss = tagId$4;
|
|
446
|
+
tag.textContent = css$4;
|
|
252
447
|
document.head.appendChild(tag);
|
|
253
448
|
}
|
|
254
449
|
var BranchChip_module_default = {
|
|
@@ -256,13 +451,8 @@ window.__ModuleLoader__.load({
|
|
|
256
451
|
"left": "left_2006230319",
|
|
257
452
|
"trigger": "trigger_2006230319",
|
|
258
453
|
"dock": "dock_2006230319",
|
|
259
|
-
"divider": "divider_2006230319",
|
|
260
454
|
"chip": "chip_2006230319",
|
|
261
455
|
"branch": "branch_2006230319",
|
|
262
|
-
"check": "check_2006230319",
|
|
263
|
-
"checkOn": "checkOn_2006230319",
|
|
264
|
-
"box": "box_2006230319",
|
|
265
|
-
"checkLabel": "checkLabel_2006230319",
|
|
266
456
|
"popCard": "popCard_2006230319",
|
|
267
457
|
"popAsk": "popAsk_2006230319",
|
|
268
458
|
"popSubject": "popSubject_2006230319",
|
|
@@ -276,7 +466,6 @@ window.__ModuleLoader__.load({
|
|
|
276
466
|
"menuMain": "menuMain_2006230319",
|
|
277
467
|
"menuHeading": "menuHeading_2006230319",
|
|
278
468
|
"menuRow": "menuRow_2006230319",
|
|
279
|
-
"menuRowLocked": "menuRowLocked_2006230319",
|
|
280
469
|
"menuRowSelected": "menuRowSelected_2006230319",
|
|
281
470
|
"menuRowPicked": "menuRowPicked_2006230319",
|
|
282
471
|
"menuRowLabel": "menuRowLabel_2006230319",
|
|
@@ -291,9 +480,12 @@ window.__ModuleLoader__.load({
|
|
|
291
480
|
"menuEmpty": "menuEmpty_2006230319",
|
|
292
481
|
"menuSearchWrap": "menuSearchWrap_2006230319",
|
|
293
482
|
"menuSearch": "menuSearch_2006230319",
|
|
294
|
-
"menuToolButtonOn": "menuToolButtonOn_2006230319",
|
|
295
483
|
"menuCreate": "menuCreate_2006230319",
|
|
296
|
-
"menuCreateHintBad": "menuCreateHintBad_2006230319"
|
|
484
|
+
"menuCreateHintBad": "menuCreateHintBad_2006230319",
|
|
485
|
+
"ctxCard": "ctxCard_2006230319",
|
|
486
|
+
"ctxHeader": "ctxHeader_2006230319",
|
|
487
|
+
"ctxItem": "ctxItem_2006230319",
|
|
488
|
+
"ctxItemLabel": "ctxItemLabel_2006230319"
|
|
297
489
|
};
|
|
298
490
|
//#endregion
|
|
299
491
|
//#region src/client/BranchMenu.tsx
|
|
@@ -326,37 +518,57 @@ window.__ModuleLoader__.load({
|
|
|
326
518
|
* local row because the host hides remote branches that have a local
|
|
327
519
|
* twin), with SEVERAL remotes the full names stay so `origin`/`upstream`
|
|
328
520
|
* become the folder layer beneath the header. Picking a remote row hands
|
|
329
|
-
* the owner the real `<remote>/name` (see pick) —
|
|
330
|
-
* the
|
|
331
|
-
* Selection model
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
* pick flow).
|
|
521
|
+
* the owner the real `<remote>/name` (see pick) — 签出 dwims the tracking
|
|
522
|
+
* twin in place, and the worktree verbs spell the twin-in-worktree ask.
|
|
523
|
+
* Selection model: a single click SELECTS a row (blue); Enter or the row's
|
|
524
|
+
* RIGHT-CLICK menu executes — 签出 and the worktree hop run DIRECTLY (no
|
|
525
|
+
* confirmation step; the switch is keep-open, the hop moves the session),
|
|
526
|
+
* while the consequential verbs keep their dialogs (delete's confirm, the
|
|
527
|
+
* create/rename inputs). While a dialog is open, clicking another row
|
|
528
|
+
* re-anchors it (the old one-click pick flow).
|
|
337
529
|
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
* (
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
* The flyout is a separate portal (not clipped by the card's
|
|
352
|
-
* overflow:hidden), horizontally anchored to the card's right edge — it
|
|
353
|
-
* can never overlap the branch list — and vertically centered on the
|
|
354
|
-
* picked row. Its width is content-driven, capped in CSS, wrapping.
|
|
530
|
+
* Rows also speak right-click: a cursor-anchored context menu (the browser's
|
|
531
|
+
* native one is suppressed over rows only). A branch row gets the six-verb
|
|
532
|
+
* set — 签出 (through `pick`, executed DIRECTLY — no confirmation step),
|
|
533
|
+
* 新建 and 新建并检出
|
|
534
|
+
* (the create flyout with the row as the `from` start point, the latter
|
|
535
|
+
* adding `checkout` so `git switch -c <name> <from>`), 重命名分支 and
|
|
536
|
+
* 删除分支 (local rows; a rename flyout prefilled with the current name /
|
|
537
|
+
* the safe-delete confirm), 复制分支 — with each verb degenerating where it
|
|
538
|
+
* has no object (current branch: no 签出, no 删除; canCreate gates the
|
|
539
|
+
* write trio; remote rows: no rename, no delete). A worktree row keeps its
|
|
540
|
+
* two-item launcher (hop + copy path). The menu is a second surface, never
|
|
541
|
+
* a second semantics — it IS the execution channel (the double-click it
|
|
542
|
+
* replaced is gone), alongside Enter for the keyboard.
|
|
355
543
|
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
544
|
+
* The create and rename flyouts open IN PLACE of the row menu — at the
|
|
545
|
+
* very point it stood (staged-from-menu posture; the cursor never leaves
|
|
546
|
+
* the conversation), clamped into the viewport. Each holds its input —
|
|
547
|
+
* validated as you type (git ref-name rules plus a duplicate check against
|
|
548
|
+
* the rows; the rename pre-fills the current name and disables an
|
|
549
|
+
* unchanged draft) — and the Cancel/confirm pair. Confirming fires in ONE
|
|
550
|
+
* stroke (no second confirm step — typing into the flyout and pressing the
|
|
551
|
+
* button IS the intent). While the action runs the flyout freezes (busy
|
|
552
|
+
* disables input and buttons); a failure toasts and leaves the flyout open
|
|
553
|
+
* for a corrected retry, a success closes the flyout but KEEPS THE MENU
|
|
554
|
+
* OPEN (the row-menu keep-open rule: 原地动作 — checkout, create, rename,
|
|
555
|
+
* delete — leave the picker up for more rows; only session-hopping actions
|
|
556
|
+
* close it). A confirm flyout staged WITHOUT the row menu (worktree picks
|
|
557
|
+
* from Enter or a re-click) anchors to the card's right edge as before.
|
|
558
|
+
* The flyouts are separate portals (not clipped by the card's
|
|
559
|
+
* overflow:hidden); their width is content-driven, capped in CSS, wrapping.
|
|
560
|
+
*
|
|
561
|
+
* Every row is actionable, by construction: the owner never sends a branch
|
|
562
|
+
* this directory cannot act on (a linked-worktree session gets its own
|
|
563
|
+
* branch plus the OTHER worktrees — never another branch, see the chip's
|
|
564
|
+
* `rows`), so there is no dimmed/locked state, no verb withheld per-row for
|
|
565
|
+
* that reason, and nothing for the search field's Enter commit to skip.
|
|
566
|
+
*
|
|
567
|
+
* Close semantics: outside pointerdown (card, flyouts, row menu, and chip
|
|
568
|
+
* excluded) cancels the confirm and closes the menu; Escape unwinds tier
|
|
569
|
+
* by tier — row menu, confirm, create flyout, rename flyout, search text,
|
|
570
|
+
* selection, the menu; Enter in the search field commits the first enabled
|
|
571
|
+
* visible row.
|
|
360
572
|
*
|
|
361
573
|
* Long names and many branches: a clipped label shows the full name on
|
|
362
574
|
* hover via the native title (gated to actually-clipped rows only). The
|
|
@@ -409,7 +621,7 @@ window.__ModuleLoader__.load({
|
|
|
409
621
|
/** Design flyout width cap — matches .popCard's max-width arm. */
|
|
410
622
|
const FLY_MAX_WIDTH = 400;
|
|
411
623
|
/** After a folder toggle, clicks arriving within this window are swallowed
|
|
412
|
-
* (
|
|
624
|
+
* (layout-shift guard — see shiftGuardUntil in the component). */
|
|
413
625
|
const CLICK_GUARD_MS = 250;
|
|
414
626
|
/** Unplaced flyout: hidden but laid out at a fixed origin so offsetWidth/
|
|
415
627
|
* offsetHeight are real for the measure-then-place pass (base Menu trick). */
|
|
@@ -431,135 +643,99 @@ window.__ModuleLoader__.load({
|
|
|
431
643
|
* posture: a chevron column marks foldable rows, a text column carries
|
|
432
644
|
* content), so leaf padding is 8 + 12×depth + 18. */
|
|
433
645
|
const LEAF_CHEVRON_SLOT = 18;
|
|
434
|
-
/** Every folder path that renders a header, walking the tree depth-first. */
|
|
435
|
-
function collectFolderPaths(nodes, out = []) {
|
|
436
|
-
for (const node of nodes) if (node.children.length > 0) {
|
|
437
|
-
out.push(node.path);
|
|
438
|
-
collectFolderPaths(node.children, out);
|
|
439
|
-
}
|
|
440
|
-
return out;
|
|
441
|
-
}
|
|
442
|
-
const segCmp = (a, b) => a.localeCompare(b, void 0, {
|
|
443
|
-
numeric: true,
|
|
444
|
-
sensitivity: "base"
|
|
445
|
-
});
|
|
446
|
-
/** Split rows into the three groups and derive the remote display names. */
|
|
447
|
-
function groupRows(rows) {
|
|
448
|
-
const localRows = [];
|
|
449
|
-
const remoteRows = [];
|
|
450
|
-
const worktreeRows = [];
|
|
451
|
-
for (const row of rows) if (row.kind === "remote") remoteRows.push(row);
|
|
452
|
-
else if (row.kind === "worktree") worktreeRows.push(row);
|
|
453
|
-
else localRows.push(row);
|
|
454
|
-
const first = remoteRows[0]?.name ?? "";
|
|
455
|
-
const slash = first.indexOf("/");
|
|
456
|
-
const soleRemote = slash > 0 && remoteRows.every((row) => row.name.startsWith(first.slice(0, slash + 1))) ? first.slice(0, slash) : void 0;
|
|
457
|
-
const display = (name) => soleRemote === void 0 ? name : name.slice(soleRemote.length + 1);
|
|
458
|
-
return {
|
|
459
|
-
localRows,
|
|
460
|
-
remoteDisplayRows: remoteRows.map((row) => ({
|
|
461
|
-
...row,
|
|
462
|
-
name: display(row.name)
|
|
463
|
-
})),
|
|
464
|
-
worktreeRows,
|
|
465
|
-
remoteNameMap: new Map(remoteRows.map((row) => [display(row.name), row.name]))
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
/** Expanded-key space: folder paths carry their group prefix so a local
|
|
469
|
-
* folder can never share a toggle state with a same-named remote display
|
|
470
|
-
* folder (`feat/x` on both sides). Group OPEN flags stay booleans beside
|
|
471
|
-
* this set — they are not part of the path namespace at all. */
|
|
472
|
-
const groupKey = (group, path) => `${group}:${path}`;
|
|
473
|
-
/** Build the prefix tree of the rows (see TreeNode). */
|
|
474
|
-
function buildTree(rows) {
|
|
475
|
-
const root = [];
|
|
476
|
-
const find = (level, segment) => level.find((n) => n.segment === segment);
|
|
477
|
-
for (const row of rows) {
|
|
478
|
-
const segs = row.name.split("/").filter((s) => s !== "");
|
|
479
|
-
let level = root;
|
|
480
|
-
let path = "";
|
|
481
|
-
for (let i = 0; i < segs.length; i += 1) {
|
|
482
|
-
const seg = segs[i];
|
|
483
|
-
if (seg === void 0) break;
|
|
484
|
-
path = path === "" ? seg : `${path}/${seg}`;
|
|
485
|
-
let node = find(level, seg);
|
|
486
|
-
if (node === void 0) {
|
|
487
|
-
node = {
|
|
488
|
-
segment: seg,
|
|
489
|
-
path,
|
|
490
|
-
depth: i,
|
|
491
|
-
leaf: null,
|
|
492
|
-
children: [],
|
|
493
|
-
total: 0
|
|
494
|
-
};
|
|
495
|
-
level.push(node);
|
|
496
|
-
}
|
|
497
|
-
if (i === segs.length - 1) node.leaf = row;
|
|
498
|
-
level = node.children;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
const finish = (nodes) => {
|
|
502
|
-
for (const node of nodes) finish(node.children);
|
|
503
|
-
nodes.sort((a, b) => {
|
|
504
|
-
const af = a.children.length > 0 ? 0 : 1;
|
|
505
|
-
const bf = b.children.length > 0 ? 0 : 1;
|
|
506
|
-
return af !== bf ? af - bf : segCmp(a.segment, b.segment);
|
|
507
|
-
});
|
|
508
|
-
};
|
|
509
|
-
finish(root);
|
|
510
|
-
const count = (nodes) => {
|
|
511
|
-
for (const node of nodes) {
|
|
512
|
-
count(node.children);
|
|
513
|
-
node.total = (node.leaf === null ? 0 : 1) + node.children.reduce((sum, c) => sum + c.total, 0);
|
|
514
|
-
}
|
|
515
|
-
};
|
|
516
|
-
count(root);
|
|
517
|
-
return root;
|
|
518
|
-
}
|
|
519
|
-
/** The folders that must start expanded so the checked-out branch is
|
|
520
|
-
* immediately visible in the tree: every proper ancestor of its path. */
|
|
521
|
-
function chainExpanded(branch) {
|
|
522
|
-
const segs = branch.split("/").filter((s) => s !== "");
|
|
523
|
-
const set = /* @__PURE__ */ new Set();
|
|
524
|
-
let path = "";
|
|
525
|
-
for (let i = 0; i < segs.length - 1; i += 1) {
|
|
526
|
-
const seg = segs[i];
|
|
527
|
-
if (seg === void 0) break;
|
|
528
|
-
path = path === "" ? seg : `${path}/${seg}`;
|
|
529
|
-
set.add(path);
|
|
530
|
-
}
|
|
531
|
-
return set;
|
|
532
|
-
}
|
|
533
|
-
/** Hover tooltip: set the native `title` ONLY when the label is actually
|
|
534
|
-
* clipped (scrollWidth > clientWidth) — fitted names show no tooltip, and
|
|
535
|
-
* long ones expose their full path without a custom bubble. The target is
|
|
536
|
-
* the label span (first span child), the clipped element. */
|
|
537
|
-
const gateTooltip = (button, name) => {
|
|
538
|
-
const label = button.querySelector(":scope > span");
|
|
539
|
-
if (label !== null) label.title = label.scrollWidth > label.clientWidth ? name : "";
|
|
540
|
-
};
|
|
541
|
-
/** Leaving a row drops its tooltip so a recycled DOM node (search refilter)
|
|
542
|
-
* can never show a stale title for another branch. */
|
|
543
|
-
const clearTooltip = (button) => {
|
|
544
|
-
const label = button.querySelector(":scope > span");
|
|
545
|
-
if (label !== null) label.title = "";
|
|
546
|
-
};
|
|
547
646
|
/**
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
647
|
+
* Place one flyout of the picker's family (confirm / create / rename).
|
|
648
|
+
*
|
|
649
|
+
* All three share one posture, and it used to be written out three times:
|
|
650
|
+
* **row-menu-staged** flyouts replace the menu AT its cursor point (the
|
|
651
|
+
* pointer never leaves the conversation), everything else anchors to the
|
|
652
|
+
* card's right edge — never over the branch list — vertically centered on
|
|
653
|
+
* its own anchor and clamped into the viewport. The width is
|
|
654
|
+
* content-driven through a measure-then-place pass: the flyout first lays
|
|
655
|
+
* out hidden at FLY_MEASURE (real offsets, no flash), place() clamps its
|
|
656
|
+
* inline max-width to the room right of the card, then pins the box.
|
|
657
|
+
*
|
|
658
|
+
* @param active - whether the flyout is showing; false clears the position.
|
|
659
|
+
* @param flyRef - the flyout element being placed.
|
|
660
|
+
* @param cardRef - the picker card it hangs off.
|
|
661
|
+
* @param pointRef - the staged row-menu point, or null-valued for the card-side posture.
|
|
662
|
+
* @param verticalAnchor - the box whose center the flyout rides; null centers on the card.
|
|
663
|
+
* @param deps - extra re-place triggers (a re-pick moves the anchor row).
|
|
664
|
+
* @returns the placed position, or null while unmeasured.
|
|
551
665
|
*/
|
|
552
|
-
function
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
666
|
+
function useFlyoutPlacement(active, flyRef, cardRef, pointRef, verticalAnchor, deps) {
|
|
667
|
+
const [pos, setPos] = (0, react.useState)(null);
|
|
668
|
+
(0, react.useLayoutEffect)(() => {
|
|
669
|
+
if (!active) {
|
|
670
|
+
setPos(null);
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
const place = () => {
|
|
674
|
+
const fly = flyRef.current;
|
|
675
|
+
if (fly === null) return;
|
|
676
|
+
const vw = window.innerWidth;
|
|
677
|
+
const vh = window.innerHeight;
|
|
678
|
+
const fw = fly.offsetWidth;
|
|
679
|
+
const fh = fly.offsetHeight;
|
|
680
|
+
const point = pointRef.current;
|
|
681
|
+
if (point !== null) {
|
|
682
|
+
setPos({
|
|
683
|
+
left: Math.min(Math.max(point.x, MARGIN), Math.max(MARGIN, vw - MARGIN - fw)),
|
|
684
|
+
top: Math.min(Math.max(point.y, MARGIN), Math.max(MARGIN, vh - MARGIN - fh))
|
|
685
|
+
});
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
const card = cardRef.current;
|
|
689
|
+
if (card === null) return;
|
|
690
|
+
const cr = card.getBoundingClientRect();
|
|
691
|
+
const anchor = verticalAnchor === null ? cr : verticalAnchor();
|
|
692
|
+
if (anchor === null) return;
|
|
693
|
+
const left = cr.right + GAP;
|
|
694
|
+
const room = Math.min(FLY_MAX_WIDTH, Math.max(200, vw - MARGIN - left));
|
|
695
|
+
fly.style.maxWidth = `${room}px`;
|
|
696
|
+
const top = Math.min(Math.max(anchor.top + anchor.height / 2 - fh / 2, MARGIN), Math.max(MARGIN, vh - fh - MARGIN));
|
|
697
|
+
setPos({
|
|
698
|
+
left: Math.min(left, vw - MARGIN - fw),
|
|
699
|
+
top
|
|
700
|
+
});
|
|
701
|
+
};
|
|
702
|
+
place();
|
|
703
|
+
window.addEventListener("resize", place);
|
|
704
|
+
window.addEventListener("scroll", place, true);
|
|
705
|
+
return () => {
|
|
706
|
+
window.removeEventListener("resize", place);
|
|
707
|
+
window.removeEventListener("scroll", place, true);
|
|
708
|
+
};
|
|
709
|
+
}, [
|
|
710
|
+
active,
|
|
711
|
+
verticalAnchor,
|
|
712
|
+
...deps
|
|
713
|
+
]);
|
|
714
|
+
return pos;
|
|
715
|
+
}
|
|
716
|
+
/** Hover tooltip: set the native `title` ONLY when the label is actually
|
|
717
|
+
* clipped (scrollWidth > clientWidth) — fitted names show no tooltip, and
|
|
718
|
+
* long ones expose their full path without a custom bubble. The target is
|
|
719
|
+
* the label span (first span child), the clipped element. */
|
|
720
|
+
const gateTooltip = (button, name) => {
|
|
721
|
+
const label = button.querySelector(":scope > span");
|
|
722
|
+
if (label !== null) label.title = label.scrollWidth > label.clientWidth ? name : "";
|
|
723
|
+
};
|
|
724
|
+
/** Leaving a row drops its tooltip so a recycled DOM node (search refilter)
|
|
725
|
+
* can never show a stale title for another branch. */
|
|
726
|
+
const clearTooltip = (button) => {
|
|
727
|
+
const label = button.querySelector(":scope > span");
|
|
728
|
+
if (label !== null) label.title = "";
|
|
729
|
+
};
|
|
730
|
+
/**
|
|
731
|
+
* Render the upward branch picker with its right-side confirm flyout.
|
|
732
|
+
* @param props - anchor, rows, confirm bundle, callbacks, and the class sheet.
|
|
733
|
+
* @returns null while closed or unplaced; otherwise the portaled card (+flyout).
|
|
734
|
+
*/
|
|
735
|
+
function BranchMenu({ open, anchorRef, rows, currentBranch, confirm, onSelect, canCreate, canAdopt, canWorktree, onWorktree, onCutWorktree, onCreate, onRename, onDelete, busy, onFetch, fetchBusy, onUpdate, updateBusy, onClose, t }) {
|
|
736
|
+
const cardRef = (0, react.useRef)(null);
|
|
737
|
+
const inputRef = (0, react.useRef)(null);
|
|
738
|
+
/**
|
|
563
739
|
* Search-field ref callback: focus the field the moment it mounts. The
|
|
564
740
|
* card mounts in two stages (open flips, then pos resolves a render
|
|
565
741
|
* later), so an [open]-keyed passive effect fires while the input is
|
|
@@ -575,15 +751,19 @@ window.__ModuleLoader__.load({
|
|
|
575
751
|
inputRef.current = el;
|
|
576
752
|
if (el !== null) el.focus();
|
|
577
753
|
}, []);
|
|
578
|
-
/**
|
|
579
|
-
*
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
754
|
+
/** The create/rename flyout inputs. Focus does NOT ride the ref callback:
|
|
755
|
+
* the flyout's first frame lays out in the hidden measure-then-place
|
|
756
|
+
* posture, and focus() on a visibility:hidden element is a no-op (the
|
|
757
|
+
* confirm button hit the same wall — see its rAF effect) — so the refs
|
|
758
|
+
* are plain holders and the focus effect below lands one frame later,
|
|
759
|
+
* once the placed flyout is visible. */
|
|
760
|
+
const createInputRef = (0, react.useRef)(null);
|
|
761
|
+
const renameInputRef = (0, react.useRef)(null);
|
|
585
762
|
const flyRef = (0, react.useRef)(null);
|
|
586
763
|
const flyConfirmRef = (0, react.useRef)(null);
|
|
764
|
+
/** The cutout draft input inside the confirm flyout (present only when
|
|
765
|
+
* the owner staged a draft — see BranchConfirmFly). */
|
|
766
|
+
const flyInputRef = (0, react.useRef)(null);
|
|
587
767
|
/** The row whose pick is awaiting confirmation (anchoring element). */
|
|
588
768
|
const pendingRef = (0, react.useRef)(null);
|
|
589
769
|
/** Pending row's name — the placement-effect trigger: picking another
|
|
@@ -591,7 +771,6 @@ window.__ModuleLoader__.load({
|
|
|
591
771
|
* stays true, so a ref mutation re-renders nothing). */
|
|
592
772
|
const [pendingName, setPendingName] = (0, react.useState)(null);
|
|
593
773
|
const [pos, setPos] = (0, react.useState)(null);
|
|
594
|
-
const [flyPos, setFlyPos] = (0, react.useState)(null);
|
|
595
774
|
const [query, setQuery] = (0, react.useState)("");
|
|
596
775
|
/** Expanded folder set, keyed by group-prefixed node path (see groupKey).
|
|
597
776
|
* Re-seeded on every open so the current branch's chain is visible
|
|
@@ -612,10 +791,40 @@ window.__ModuleLoader__.load({
|
|
|
612
791
|
* (or closing the flyout) resets both — see the open-reset effect. */
|
|
613
792
|
const [creating, setCreating] = (0, react.useState)(false);
|
|
614
793
|
const [draft, setDraft] = (0, react.useState)("");
|
|
615
|
-
/** The create
|
|
616
|
-
*
|
|
794
|
+
/** The create's start point: the row context menu's cut base (新建/新建
|
|
795
|
+
* 并检出 always stage it with the row's branch — the toolbar plus that
|
|
796
|
+
* used to leave it undefined is gone, the undefined shape survives only
|
|
797
|
+
* in the owner API). `createCheckout` splits the two from-shapes: with
|
|
798
|
+
* the base AND checked out here (新建并检出), or at the base with no
|
|
799
|
+
* checkout touched (新建). Reset on every open. */
|
|
800
|
+
const [createBase, setCreateBase] = (0, react.useState)(void 0);
|
|
801
|
+
const [createCheckout, setCreateCheckout] = (0, react.useState)(false);
|
|
802
|
+
/** The rename flyout: the LOCAL branch being renamed plus the live draft
|
|
803
|
+
* (pre-filled with the current name — an unchanged draft disables the
|
|
804
|
+
* confirm). Opened only from a row context menu; reset on menu open. */
|
|
805
|
+
const [renaming, setRenaming] = (0, react.useState)(null);
|
|
806
|
+
const renameFlyRef = (0, react.useRef)(null);
|
|
807
|
+
/** The create flyout element (placed by useFlyoutPlacement below, the
|
|
808
|
+
* same measure-then-place posture as the confirm and rename flyouts). */
|
|
617
809
|
const createFlyRef = (0, react.useRef)(null);
|
|
618
|
-
|
|
810
|
+
/** The row context menu (right-click): the target row plus the cursor
|
|
811
|
+
* point in viewport coordinates; null while closed. Placement is
|
|
812
|
+
* computed once at open — a cursor-anchored transient does not track
|
|
813
|
+
* scroll/resize (the next pointerdown, scrollbar drags included,
|
|
814
|
+
* dismisses it). */
|
|
815
|
+
const [ctx, setCtx] = (0, react.useState)(null);
|
|
816
|
+
const ctxCardRef = (0, react.useRef)(null);
|
|
817
|
+
const [ctxPos, setCtxPos] = (0, react.useState)(null);
|
|
818
|
+
/** Where the row menu stood when one of its items staged a second-level
|
|
819
|
+
* flyout (create/rename/delete confirm, a worktree-mode pick): the flyout
|
|
820
|
+
* replaces the menu AT this point — the cursor is already here, so the
|
|
821
|
+
* second click/keystroke should be too. Any non-ctx staging path (Enter,
|
|
822
|
+
* click re-pick) clears it and the flyout falls back to the card-right
|
|
823
|
+
* posture. Read by the three flyout placement passes. */
|
|
824
|
+
const ctxPointRef = (0, react.useRef)(null);
|
|
825
|
+
/** Copy feedback: a seq-keyed Toast (the shared copied label) fired by a
|
|
826
|
+
* successful context-menu copy write. */
|
|
827
|
+
const [copiedSeq, setCopiedSeq] = (0, react.useState)(null);
|
|
619
828
|
const confirmRef = (0, react.useRef)(confirm);
|
|
620
829
|
confirmRef.current = confirm;
|
|
621
830
|
const queryRef = (0, react.useRef)(query);
|
|
@@ -625,39 +834,64 @@ window.__ModuleLoader__.load({
|
|
|
625
834
|
/** Fresh creating flag for the stale-safe document keydown listener. */
|
|
626
835
|
const creatingRef = (0, react.useRef)(creating);
|
|
627
836
|
creatingRef.current = creating;
|
|
837
|
+
/** Fresh rename flyout state for the same stale-safe listeners. */
|
|
838
|
+
const renamingRef = (0, react.useRef)(renaming);
|
|
839
|
+
renamingRef.current = renaming;
|
|
840
|
+
/** Fresh row-menu state for the same stale-safe listeners (Escape tier
|
|
841
|
+
* and the outside-pointerdown dismissal). */
|
|
842
|
+
const ctxStateRef = (0, react.useRef)(ctx);
|
|
843
|
+
ctxStateRef.current = ctx;
|
|
628
844
|
/** Latest rows for the open-reset effect: the effect must NOT re-run when
|
|
629
845
|
* a mid-open refresh swaps the rows (that would reset folders the user
|
|
630
846
|
* has toggled), but the reset itself still needs the freshest list. */
|
|
631
847
|
const latestRows = (0, react.useRef)(rows);
|
|
632
848
|
latestRows.current = rows;
|
|
849
|
+
/** Latest checked-out branch for the open-reset effect. The reset must
|
|
850
|
+
* fire on OPEN only: 签出 is keep-open, so the owner's refresh moves
|
|
851
|
+
* `currentBranch` while the menu stands — keying the effect on it would
|
|
852
|
+
* wipe the search text, the folder state, and any half-typed flyout
|
|
853
|
+
* right after the switch the user meant to follow up on. The seeding
|
|
854
|
+
* still needs the fresh value, hence the ref. */
|
|
855
|
+
const currentBranchRef = (0, react.useRef)(currentBranch);
|
|
856
|
+
currentBranchRef.current = currentBranch;
|
|
633
857
|
/** Always-fresh pick for the stale-safe document keydown listener. */
|
|
634
858
|
const pickRef = (0, react.useRef)(() => {});
|
|
635
859
|
const confirmOpen = confirm !== null;
|
|
636
860
|
/**
|
|
637
|
-
*
|
|
638
|
-
* second click
|
|
639
|
-
*
|
|
640
|
-
*
|
|
861
|
+
* Layout-shift guard: toggling a folder shifts the layout — a rapid
|
|
862
|
+
* second click can land on a row that slid under the cursor (a
|
|
863
|
+
* branch!), which would select it or pop the switch flyout. After a
|
|
864
|
+
* folder toggle, every click swallowed for CLICK_GUARD_MS, so a rushed
|
|
641
865
|
* double-click on a folder expands it exactly once and never bleeds into
|
|
642
866
|
* a branch click. Branch-row clicks do not arm the guard (selecting does
|
|
643
|
-
* not move anything), so row
|
|
867
|
+
* not move anything), so follow-up row clicks keep working instantly.
|
|
644
868
|
*/
|
|
645
869
|
const shiftGuardUntil = (0, react.useRef)(0);
|
|
646
870
|
const guardActive = () => Date.now() < shiftGuardUntil.current;
|
|
647
871
|
const armShiftGuard = () => {
|
|
648
872
|
shiftGuardUntil.current = Date.now() + CLICK_GUARD_MS;
|
|
649
873
|
};
|
|
650
|
-
/**
|
|
651
|
-
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
|
|
655
|
-
const pick = (el, name) => {
|
|
874
|
+
/** Anchor a second-level flyout to a row: remember the row element (the
|
|
875
|
+
* flyout anchors beside it) and mark it pending. Shared by every
|
|
876
|
+
* right-side flyout stage path — pick (confirm) and the row menu's
|
|
877
|
+
* delete (its own confirm). */
|
|
878
|
+
const stagePending = (el, name) => {
|
|
656
879
|
if (el !== null) pendingRef.current = {
|
|
657
880
|
name,
|
|
658
881
|
el
|
|
659
882
|
};
|
|
660
883
|
setPendingName(name);
|
|
884
|
+
};
|
|
885
|
+
/** Stage a pick: anchor the confirm flyout beside the row (or, when the
|
|
886
|
+
* row menu staged it, AT the menu's point — see ctxPointRef), then hand
|
|
887
|
+
* the branch to the owner. All pick paths — search Enter, keyboard Enter
|
|
888
|
+
* on a selected row, the row menu's 签出 — funnel through here; only the
|
|
889
|
+
* row menu's calls carry `fromCtx`. A remote row carries its DISPLAY name
|
|
890
|
+
* through selection and anchors; the owner always receives the real
|
|
891
|
+
* `<remote>/name` action name. */
|
|
892
|
+
const pick = (el, name, fromCtx = false) => {
|
|
893
|
+
if (!fromCtx) ctxPointRef.current = null;
|
|
894
|
+
stagePending(el, name);
|
|
661
895
|
onSelect(remoteNameMapRef.current.get(name) ?? name);
|
|
662
896
|
};
|
|
663
897
|
pickRef.current = pick;
|
|
@@ -671,14 +905,17 @@ window.__ModuleLoader__.load({
|
|
|
671
905
|
* (its Enter path funnels through pick, which reads the ref). */
|
|
672
906
|
const remoteNameMapRef = (0, react.useRef)(grouped.remoteNameMap);
|
|
673
907
|
remoteNameMapRef.current = grouped.remoteNameMap;
|
|
908
|
+
/** The inverse map, action→display: state that holds an ACTION name (the
|
|
909
|
+
* create flyout's base) has to read back as what the row showed, or a
|
|
910
|
+
* single-remote setup would suddenly quote `origin/feat/x` at a user who
|
|
911
|
+
* only ever saw `feat/x`. */
|
|
912
|
+
const displayNameOf = (0, react.useMemo)(() => {
|
|
913
|
+
const inverse = new Map([...grouped.remoteNameMap].map(([display, action]) => [action, display]));
|
|
914
|
+
return (action) => inverse.get(action) ?? action;
|
|
915
|
+
}, [grouped.remoteNameMap]);
|
|
674
916
|
/** Every folder key that renders a header — the expand/collapse-all
|
|
675
917
|
* button's scope (group-prefixed, see groupKey). */
|
|
676
918
|
const folderPaths = (0, react.useMemo)(() => [...collectFolderPaths(localTree).map((p) => groupKey("local", p)), ...collectFolderPaths(remoteTree).map((p) => groupKey("remote", p))], [localTree, remoteTree]);
|
|
677
|
-
/** Locked row names (dimmed, pick-answered-with-hint) — a Set for the
|
|
678
|
-
* click gate. MUST sit before the `!open` early return: a hook after it
|
|
679
|
-
* would change the hook count between a closed and an open menu
|
|
680
|
-
* (React #310, seen live as the whole dock unmounting on first open). */
|
|
681
|
-
const lockedRows = (0, react.useMemo)(() => new Set(rows.filter((r) => r.locked === true).map((r) => r.name)), [rows]);
|
|
682
919
|
const allExpanded = folderPaths.every((p) => expanded.has(p)) && localGroupOpen && remoteGroupOpen && (!canAdopt || worktreeGroupOpen);
|
|
683
920
|
const toggleAll = () => {
|
|
684
921
|
const next = !allExpanded;
|
|
@@ -689,7 +926,6 @@ window.__ModuleLoader__.load({
|
|
|
689
926
|
};
|
|
690
927
|
const locateCurrent = () => {
|
|
691
928
|
setLocalGroupOpen(true);
|
|
692
|
-
if (grouped.worktreeRows.some((row) => row.name === currentBranch)) setWorktreeGroupOpen(true);
|
|
693
929
|
setExpanded((prev) => {
|
|
694
930
|
const next = new Set(prev);
|
|
695
931
|
for (const p of chainExpanded(currentBranch)) next.add(groupKey("local", p));
|
|
@@ -705,6 +941,10 @@ window.__ModuleLoader__.load({
|
|
|
705
941
|
setSelected(null);
|
|
706
942
|
setCreating(false);
|
|
707
943
|
setDraft("");
|
|
944
|
+
setCreateBase(void 0);
|
|
945
|
+
setCreateCheckout(false);
|
|
946
|
+
setRenaming(null);
|
|
947
|
+
setCtx(null);
|
|
708
948
|
const currentRows = latestRows.current;
|
|
709
949
|
const current = groupRows(currentRows);
|
|
710
950
|
const localPaths = collectFolderPaths(buildTree(current.localRows)).map((p) => groupKey("local", p));
|
|
@@ -713,8 +953,8 @@ window.__ModuleLoader__.load({
|
|
|
713
953
|
setLocalGroupOpen(true);
|
|
714
954
|
setRemoteGroupOpen(!many);
|
|
715
955
|
setWorktreeGroupOpen(true);
|
|
716
|
-
setExpanded(many ? new Set([...chainExpanded(
|
|
717
|
-
}, [open
|
|
956
|
+
setExpanded(many ? new Set([...chainExpanded(currentBranchRef.current)].map((p) => groupKey("local", p))) : /* @__PURE__ */ new Set([...localPaths, ...remotePaths]));
|
|
957
|
+
}, [open]);
|
|
718
958
|
(0, react.useEffect)(() => {
|
|
719
959
|
if (selected !== null && !rows.some((r) => r.name === selected)) setSelected(null);
|
|
720
960
|
}, [rows, selected]);
|
|
@@ -730,6 +970,7 @@ window.__ModuleLoader__.load({
|
|
|
730
970
|
(0, react.useLayoutEffect)(() => {
|
|
731
971
|
if (!open) {
|
|
732
972
|
setPos(null);
|
|
973
|
+
setCtx(null);
|
|
733
974
|
return;
|
|
734
975
|
}
|
|
735
976
|
const place = () => {
|
|
@@ -782,74 +1023,45 @@ window.__ModuleLoader__.load({
|
|
|
782
1023
|
cancelAnimationFrame(raf);
|
|
783
1024
|
};
|
|
784
1025
|
}, [open, centerCurrentRow]);
|
|
1026
|
+
const flyPos = useFlyoutPlacement(confirmOpen && pendingName !== null, flyRef, cardRef, ctxPointRef, (0, react.useCallback)(() => pendingRef.current?.el.getBoundingClientRect() ?? null, []), [pendingName]);
|
|
1027
|
+
const createFlyPos = useFlyoutPlacement(creating, createFlyRef, cardRef, ctxPointRef, null, []);
|
|
1028
|
+
const renameFlyPos = useFlyoutPlacement(renaming !== null, renameFlyRef, cardRef, ctxPointRef, null, [renaming]);
|
|
785
1029
|
(0, react.useLayoutEffect)(() => {
|
|
786
|
-
if (
|
|
787
|
-
|
|
1030
|
+
if (ctx === null) {
|
|
1031
|
+
setCtxPos(null);
|
|
788
1032
|
return;
|
|
789
1033
|
}
|
|
790
|
-
const
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
const room = Math.min(FLY_MAX_WIDTH, Math.max(200, vw - MARGIN - left));
|
|
801
|
-
fly.style.maxWidth = `${room}px`;
|
|
802
|
-
const fw = fly.offsetWidth;
|
|
803
|
-
const fh = fly.offsetHeight;
|
|
804
|
-
const top = Math.min(Math.max(row.top + row.height / 2 - fh / 2, MARGIN), Math.max(MARGIN, vh - fh - MARGIN));
|
|
805
|
-
setFlyPos({
|
|
806
|
-
left: Math.min(left, vw - MARGIN - fw),
|
|
807
|
-
top
|
|
808
|
-
});
|
|
1034
|
+
const el = ctxCardRef.current;
|
|
1035
|
+
if (el === null) return;
|
|
1036
|
+
const vw = window.innerWidth;
|
|
1037
|
+
const vh = window.innerHeight;
|
|
1038
|
+
setCtxPos({
|
|
1039
|
+
left: Math.min(Math.max(ctx.x, MARGIN), Math.max(MARGIN, vw - MARGIN - el.offsetWidth)),
|
|
1040
|
+
top: Math.min(Math.max(ctx.y, MARGIN), Math.max(MARGIN, vh - MARGIN - el.offsetHeight))
|
|
1041
|
+
});
|
|
1042
|
+
const dismiss = () => {
|
|
1043
|
+
setCtx(null);
|
|
809
1044
|
};
|
|
810
|
-
|
|
811
|
-
window.addEventListener("
|
|
812
|
-
window.addEventListener("scroll", place, true);
|
|
1045
|
+
window.addEventListener("resize", dismiss);
|
|
1046
|
+
window.addEventListener("scroll", dismiss, true);
|
|
813
1047
|
return () => {
|
|
814
|
-
window.removeEventListener("resize",
|
|
815
|
-
window.removeEventListener("scroll",
|
|
816
|
-
};
|
|
817
|
-
}, [confirmOpen, pendingName]);
|
|
818
|
-
(0, react.useLayoutEffect)(() => {
|
|
819
|
-
if (!creating) {
|
|
820
|
-
setCreateFlyPos(null);
|
|
821
|
-
return;
|
|
822
|
-
}
|
|
823
|
-
const place = () => {
|
|
824
|
-
const fly = createFlyRef.current;
|
|
825
|
-
const card = cardRef.current;
|
|
826
|
-
if (fly === null || card === null) return;
|
|
827
|
-
const cr = card.getBoundingClientRect();
|
|
828
|
-
const vw = window.innerWidth;
|
|
829
|
-
const vh = window.innerHeight;
|
|
830
|
-
const left = cr.right + GAP;
|
|
831
|
-
const room = Math.min(FLY_MAX_WIDTH, Math.max(200, vw - MARGIN - left));
|
|
832
|
-
fly.style.maxWidth = `${room}px`;
|
|
833
|
-
const fw = fly.offsetWidth;
|
|
834
|
-
const fh = fly.offsetHeight;
|
|
835
|
-
const top = Math.min(Math.max(cr.top + cr.height / 2 - fh / 2, MARGIN), Math.max(MARGIN, vh - fh - MARGIN));
|
|
836
|
-
setCreateFlyPos({
|
|
837
|
-
left: Math.min(left, vw - MARGIN - fw),
|
|
838
|
-
top
|
|
839
|
-
});
|
|
1048
|
+
window.removeEventListener("resize", dismiss);
|
|
1049
|
+
window.removeEventListener("scroll", dismiss, true);
|
|
840
1050
|
};
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
1051
|
+
}, [ctx]);
|
|
1052
|
+
(0, react.useEffect)(() => {
|
|
1053
|
+
if (ctx === null) return;
|
|
1054
|
+
const raf = requestAnimationFrame(() => {
|
|
1055
|
+
ctxCardRef.current?.querySelector("button[role=\"menuitem\"]")?.focus();
|
|
1056
|
+
});
|
|
844
1057
|
return () => {
|
|
845
|
-
|
|
846
|
-
window.removeEventListener("scroll", place, true);
|
|
1058
|
+
cancelAnimationFrame(raf);
|
|
847
1059
|
};
|
|
848
|
-
}, [
|
|
1060
|
+
}, [ctx]);
|
|
849
1061
|
(0, react.useEffect)(() => {
|
|
850
1062
|
if (confirmOpen && pendingName !== null) {
|
|
851
1063
|
const raf = requestAnimationFrame(() => {
|
|
852
|
-
flyConfirmRef.current?.focus();
|
|
1064
|
+
(flyInputRef.current ?? flyConfirmRef.current)?.focus();
|
|
853
1065
|
});
|
|
854
1066
|
return () => {
|
|
855
1067
|
cancelAnimationFrame(raf);
|
|
@@ -860,9 +1072,25 @@ window.__ModuleLoader__.load({
|
|
|
860
1072
|
setPendingName(null);
|
|
861
1073
|
}
|
|
862
1074
|
}, [confirmOpen, pendingName]);
|
|
1075
|
+
const renamingOpen = renaming !== null;
|
|
1076
|
+
(0, react.useEffect)(() => {
|
|
1077
|
+
if (!creating && !renamingOpen) return;
|
|
1078
|
+
const raf = requestAnimationFrame(() => {
|
|
1079
|
+
(creating ? createInputRef.current : renameInputRef.current)?.focus();
|
|
1080
|
+
});
|
|
1081
|
+
return () => {
|
|
1082
|
+
cancelAnimationFrame(raf);
|
|
1083
|
+
};
|
|
1084
|
+
}, [creating, renamingOpen]);
|
|
863
1085
|
(0, react.useEffect)(() => {
|
|
864
1086
|
if (!open) return;
|
|
865
1087
|
const onPointerDown = (event) => {
|
|
1088
|
+
if (ctxStateRef.current !== null && ctxCardRef.current?.contains(event.target) !== true) {
|
|
1089
|
+
setCtx(null);
|
|
1090
|
+
if (cardRef.current?.contains(event.target) === true) return;
|
|
1091
|
+
}
|
|
1092
|
+
if (ctxCardRef.current?.contains(event.target) === true) return;
|
|
1093
|
+
if (renameFlyRef.current?.contains(event.target) === true) return;
|
|
866
1094
|
if (cardRef.current?.contains(event.target) === true) return;
|
|
867
1095
|
if (flyRef.current?.contains(event.target) === true) return;
|
|
868
1096
|
if (createFlyRef.current?.contains(event.target) === true) return;
|
|
@@ -873,6 +1101,10 @@ window.__ModuleLoader__.load({
|
|
|
873
1101
|
const onKeyDown = (event) => {
|
|
874
1102
|
const key = event.key;
|
|
875
1103
|
if (key === "Escape") {
|
|
1104
|
+
if (ctxStateRef.current !== null) {
|
|
1105
|
+
setCtx(null);
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
876
1108
|
if (confirmRef.current !== null) {
|
|
877
1109
|
confirmRef.current.onCancel();
|
|
878
1110
|
return;
|
|
@@ -882,6 +1114,10 @@ window.__ModuleLoader__.load({
|
|
|
882
1114
|
setDraft("");
|
|
883
1115
|
return;
|
|
884
1116
|
}
|
|
1117
|
+
if (renamingRef.current !== null) {
|
|
1118
|
+
setRenaming(null);
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
885
1121
|
if (queryRef.current.trim() !== "") {
|
|
886
1122
|
setQuery("");
|
|
887
1123
|
return;
|
|
@@ -931,9 +1167,18 @@ window.__ModuleLoader__.load({
|
|
|
931
1167
|
]);
|
|
932
1168
|
if (!open || pos === null) return null;
|
|
933
1169
|
const needle = query.trim().toLowerCase();
|
|
934
|
-
|
|
1170
|
+
/** The worktree rows that are actually OFFERED. Without `canAdopt` the
|
|
1171
|
+
* group is not rendered at all (a STARTED main-checkout session, see the
|
|
1172
|
+
* prop), so those rows must leave every derived set too — `visible` feeds
|
|
1173
|
+
* the search-Enter commit and the empty-state test, and a row that
|
|
1174
|
+
* reaches neither the eye nor the pointer must not be reachable by
|
|
1175
|
+
* keyboard either (an unrendered hit used to hop the session into a
|
|
1176
|
+
* worktree the gate had just withheld) nor count as "something matched"
|
|
1177
|
+
* under an empty list. */
|
|
1178
|
+
const pickableWorktreeRows = canAdopt ? grouped.worktreeRows : [];
|
|
1179
|
+
const visible = needle === "" ? canAdopt ? rows : rows.filter((row) => row.kind !== "worktree") : [
|
|
935
1180
|
...grouped.localRows,
|
|
936
|
-
...
|
|
1181
|
+
...pickableWorktreeRows,
|
|
937
1182
|
...grouped.remoteDisplayRows
|
|
938
1183
|
].filter((row) => row.name.toLowerCase().includes(needle));
|
|
939
1184
|
/** Enter in the search field: commit the first visible row (its rendered
|
|
@@ -965,26 +1210,50 @@ window.__ModuleLoader__.load({
|
|
|
965
1210
|
const showCreateHint = createIssue !== null && createIssue !== "empty" || createDuplicate;
|
|
966
1211
|
/** Fire the create in one stroke — the flyout's whole point. Invalid
|
|
967
1212
|
* drafts and a running create are no-ops (the Create button disables in
|
|
968
|
-
* lockstep);
|
|
969
|
-
*
|
|
1213
|
+
* lockstep); a failure toasts and leaves the flyout open for a renamed
|
|
1214
|
+
* retry, a success runs `onSettled` (flyout closes, the MENU stays —
|
|
1215
|
+
* the keep-open rule) via the owner. The start point rides along:
|
|
1216
|
+
* the row's branch as `from`, `checkout` splitting 新建 (at-base,
|
|
1217
|
+
* untouched checkouts) from 新建并检出 (at-base AND checked out here). */
|
|
970
1218
|
const commitCreate = () => {
|
|
971
1219
|
if (!createValid || busy) return;
|
|
972
|
-
onCreate(draft)
|
|
1220
|
+
onCreate(draft, createBase, createCheckout, () => {
|
|
1221
|
+
setCreating(false);
|
|
1222
|
+
setDraft("");
|
|
1223
|
+
setCreateBase(void 0);
|
|
1224
|
+
setCreateCheckout(false);
|
|
1225
|
+
});
|
|
1226
|
+
};
|
|
1227
|
+
/** Rename-draft validation: git ref-name rules first, then a duplicate
|
|
1228
|
+
* check against every EXISTING local name — the branch's own current name
|
|
1229
|
+
* excluded (a rename onto itself is the no-op the confirm disables via
|
|
1230
|
+
* `renameChanged`). Same namespace as the create: worktree-held names are
|
|
1231
|
+
* taken (their branches exist), remote names are no claim. */
|
|
1232
|
+
const renameIssue = renaming === null ? null : branchNameIssue(renaming.draft);
|
|
1233
|
+
const renameDuplicate = renaming !== null && renameIssue === null && renaming.draft !== renaming.name && existsLocally(renaming.draft);
|
|
1234
|
+
const renameChanged = renaming !== null && renaming.draft !== renaming.name;
|
|
1235
|
+
const renameValid = renameIssue === null && !renameDuplicate && renameChanged;
|
|
1236
|
+
const showRenameHint = renameIssue !== null && renameIssue !== "empty" || renameDuplicate;
|
|
1237
|
+
/** Fire the rename in one stroke — the create flyout's one-stroke intent
|
|
1238
|
+
* on a prefilled input: editing the name and pressing confirm IS the
|
|
1239
|
+
* intent. Git stays the authority (an occupied target toasts 400 and the
|
|
1240
|
+
* flyout stays open for a corrected retry); success runs `onSettled` —
|
|
1241
|
+
* the flyout closes, the menu stays. */
|
|
1242
|
+
const commitRename = () => {
|
|
1243
|
+
if (renaming === null || !renameValid || busy) return;
|
|
1244
|
+
onRename(renaming.name, renaming.draft, () => {
|
|
1245
|
+
setRenaming(null);
|
|
1246
|
+
});
|
|
973
1247
|
};
|
|
974
|
-
/** Row class composition: base + HEAD tint + selection (selection wins)
|
|
975
|
-
*
|
|
976
|
-
*
|
|
977
|
-
const rowClass = (
|
|
1248
|
+
/** Row class composition: base + HEAD tint + selection (selection wins).
|
|
1249
|
+
* (`css` is an index-signature record, so noUncheckedIndexedAccess types
|
|
1250
|
+
* every class as possibly absent — the base falls back to ''.) */
|
|
1251
|
+
const rowClass = (name) => {
|
|
978
1252
|
let cls = BranchChip_module_default.menuRow ?? "";
|
|
979
1253
|
if (name === currentBranch) cls += ` ${BranchChip_module_default.menuRowSelected}`;
|
|
980
1254
|
if (name === selected) cls += ` ${BranchChip_module_default.menuRowPicked}`;
|
|
981
|
-
if (row?.locked === true) cls += ` ${BranchChip_module_default.menuRowLocked}`;
|
|
982
1255
|
return cls;
|
|
983
1256
|
};
|
|
984
|
-
/** Locked rows keep the click path ALIVE (the owner answers picks with
|
|
985
|
-
* the main-checkout toast) but stay unselected — a dimmed row wearing
|
|
986
|
-
* the blue selection would read as "chosen yet unusable". */
|
|
987
|
-
const isLocked = (name) => lockedRows.has(name);
|
|
988
1257
|
/** The upstream divergence arrows of a local row (IDEA's ↑N/↓N) ahead of
|
|
989
1258
|
* the trailing check: plain text marks in the secondary tone — no base
|
|
990
1259
|
* icon pairs a direction with a count. Absent without an upstream or
|
|
@@ -1004,18 +1273,47 @@ window.__ModuleLoader__.load({
|
|
|
1004
1273
|
}, "behind"));
|
|
1005
1274
|
return marks;
|
|
1006
1275
|
};
|
|
1007
|
-
/** A row's click behavior: with
|
|
1008
|
-
* re-picks it (the
|
|
1009
|
-
* one it just selects (
|
|
1010
|
-
*
|
|
1011
|
-
*
|
|
1012
|
-
*
|
|
1013
|
-
* unmounted still selects/picks, it just re-anchors nothing. */
|
|
1276
|
+
/** A row's click behavior: with a dialog open (delete confirm or a
|
|
1277
|
+
* worktree pick), clicking a row re-picks it (the flyout re-anchors);
|
|
1278
|
+
* without one it just selects (Enter or the row menu executes the
|
|
1279
|
+
* selected row — 签出 directly, no dialog).
|
|
1280
|
+
* `el` is nullable like {@link pick}'s anchor: a row whose button is
|
|
1281
|
+
* already unmounted still selects/picks, it just re-anchors nothing. */
|
|
1014
1282
|
const rowClick = (el, name) => {
|
|
1015
|
-
if (isLocked(name)) return;
|
|
1016
1283
|
if (confirmOpen) pick(el, name);
|
|
1017
1284
|
else setSelected(name);
|
|
1018
1285
|
};
|
|
1286
|
+
/** Shared row pointer wiring — the three render shapes (tree leaf, flat
|
|
1287
|
+
* worktree row, search hit) bind ONE behavior set: hover tooltip gating,
|
|
1288
|
+
* click-select (with confirm-flyout re-anchor while it is open), and the
|
|
1289
|
+
* RIGHT-CLICK row menu. Execution lives on two channels: Enter (the
|
|
1290
|
+
* keyboard path, see the document keydown handler) and the context menu
|
|
1291
|
+
* (the mouse path — 签出/跳转 funnel through the same `pick` the removed
|
|
1292
|
+
* double-click used). The context menu only replaces the browser's native
|
|
1293
|
+
* one over rows (headers, toolbar, and the search field keep it) and
|
|
1294
|
+
* neither selects nor picks on open, so it adds a surface, never a second
|
|
1295
|
+
* semantics. No shift-guard arming: the menu moves nothing. */
|
|
1296
|
+
const rowEvents = (row, name) => ({
|
|
1297
|
+
onClick: () => {
|
|
1298
|
+
if (guardActive()) return;
|
|
1299
|
+
rowClick(buttonOf(name), name);
|
|
1300
|
+
},
|
|
1301
|
+
onMouseEnter: (event) => {
|
|
1302
|
+
gateTooltip(event.currentTarget, name);
|
|
1303
|
+
},
|
|
1304
|
+
onMouseLeave: (event) => {
|
|
1305
|
+
clearTooltip(event.currentTarget);
|
|
1306
|
+
},
|
|
1307
|
+
onContextMenu: (event) => {
|
|
1308
|
+
event.preventDefault();
|
|
1309
|
+
setCtx({
|
|
1310
|
+
row,
|
|
1311
|
+
name,
|
|
1312
|
+
x: event.clientX,
|
|
1313
|
+
y: event.clientY
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1019
1317
|
/** Wrap every case-insensitive occurrence of `needle` in `text` with the
|
|
1020
1318
|
* search-mark span (IDEA-style hit highlight). */
|
|
1021
1319
|
const renderLabel = (text) => {
|
|
@@ -1160,23 +1458,9 @@ window.__ModuleLoader__.load({
|
|
|
1160
1458
|
role: "menuitem",
|
|
1161
1459
|
"data-branch": node.path,
|
|
1162
1460
|
"data-kind": node.leaf?.kind,
|
|
1163
|
-
className: rowClass(node.
|
|
1164
|
-
title: node.leaf?.locked === true ? t("mainRepoOnly") : void 0,
|
|
1461
|
+
className: rowClass(node.path),
|
|
1165
1462
|
style: { paddingLeft: 8 + depth * 12 + LEAF_CHEVRON_SLOT },
|
|
1166
|
-
|
|
1167
|
-
if (guardActive()) return;
|
|
1168
|
-
rowClick(buttonOf(node.path), node.path);
|
|
1169
|
-
},
|
|
1170
|
-
onDoubleClick: (event) => {
|
|
1171
|
-
if (guardActive()) return;
|
|
1172
|
-
pick(event.currentTarget, node.path);
|
|
1173
|
-
},
|
|
1174
|
-
onMouseEnter: (event) => {
|
|
1175
|
-
gateTooltip(event.currentTarget, node.path);
|
|
1176
|
-
},
|
|
1177
|
-
onMouseLeave: (event) => {
|
|
1178
|
-
clearTooltip(event.currentTarget);
|
|
1179
|
-
},
|
|
1463
|
+
...rowEvents(node.leaf, node.path),
|
|
1180
1464
|
children: [
|
|
1181
1465
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1182
1466
|
className: BranchChip_module_default.menuRowLabel,
|
|
@@ -1188,34 +1472,21 @@ window.__ModuleLoader__.load({
|
|
|
1188
1472
|
}, `${prefix}${node.path}`);
|
|
1189
1473
|
/** One flat worktree row: a direct hop target, one per linked worktree
|
|
1190
1474
|
* — no tree (worktree names rarely fork, and the group is a launcher,
|
|
1191
|
-
* not a taxonomy), no confirm (the
|
|
1192
|
-
* picks it up through onSelect). The native title carries the
|
|
1193
|
-
* DIRECTORY — the fact a branch row cannot show. The row the
|
|
1194
|
-
* currently lives in keeps the trailing check + HEAD tint: it is
|
|
1195
|
-
* "you are here" mark the local group no longer holds (its branch
|
|
1196
|
-
* filed into THIS group). */
|
|
1475
|
+
* not a taxonomy), no confirm (the row menu's 跳到此工作树 IS the hop;
|
|
1476
|
+
* the owner picks it up through onSelect). The native title carries the
|
|
1477
|
+
* worktree DIRECTORY — the fact a branch row cannot show. The row the
|
|
1478
|
+
* session currently lives in keeps the trailing check + HEAD tint: it is
|
|
1479
|
+
* the "you are here" mark the local group no longer holds (its branch
|
|
1480
|
+
* was filed into THIS group). */
|
|
1197
1481
|
const renderFlatLeaf = (row, prefix) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1198
1482
|
type: "button",
|
|
1199
1483
|
role: "menuitem",
|
|
1200
1484
|
"data-branch": row.name,
|
|
1201
1485
|
"data-kind": row.kind,
|
|
1202
|
-
className: rowClass(row
|
|
1203
|
-
title: row.
|
|
1486
|
+
className: rowClass(row.name),
|
|
1487
|
+
title: row.path,
|
|
1204
1488
|
style: { paddingLeft: 38 },
|
|
1205
|
-
|
|
1206
|
-
if (guardActive()) return;
|
|
1207
|
-
rowClick(buttonOf(row.name), row.name);
|
|
1208
|
-
},
|
|
1209
|
-
onDoubleClick: (event) => {
|
|
1210
|
-
if (guardActive()) return;
|
|
1211
|
-
pick(event.currentTarget, row.name);
|
|
1212
|
-
},
|
|
1213
|
-
onMouseEnter: (event) => {
|
|
1214
|
-
gateTooltip(event.currentTarget, row.name);
|
|
1215
|
-
},
|
|
1216
|
-
onMouseLeave: (event) => {
|
|
1217
|
-
clearTooltip(event.currentTarget);
|
|
1218
|
-
},
|
|
1489
|
+
...rowEvents(row, row.name),
|
|
1219
1490
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1220
1491
|
className: BranchChip_module_default.menuRowLabel,
|
|
1221
1492
|
children: row.name
|
|
@@ -1269,23 +1540,9 @@ window.__ModuleLoader__.load({
|
|
|
1269
1540
|
role: "menuitem",
|
|
1270
1541
|
"data-branch": node.path,
|
|
1271
1542
|
"data-kind": node.leaf?.kind,
|
|
1272
|
-
className: rowClass(node.
|
|
1273
|
-
title: node.leaf?.locked === true ? t("mainRepoOnly") : void 0,
|
|
1543
|
+
className: rowClass(node.path),
|
|
1274
1544
|
style: { paddingLeft: 8 + depth * 12 + LEAF_CHEVRON_SLOT },
|
|
1275
|
-
|
|
1276
|
-
if (guardActive()) return;
|
|
1277
|
-
rowClick(buttonOf(node.path), node.path);
|
|
1278
|
-
},
|
|
1279
|
-
onDoubleClick: (event) => {
|
|
1280
|
-
if (guardActive()) return;
|
|
1281
|
-
pick(event.currentTarget, node.path);
|
|
1282
|
-
},
|
|
1283
|
-
onMouseEnter: (event) => {
|
|
1284
|
-
gateTooltip(event.currentTarget, node.path);
|
|
1285
|
-
},
|
|
1286
|
-
onMouseLeave: (event) => {
|
|
1287
|
-
clearTooltip(event.currentTarget);
|
|
1288
|
-
},
|
|
1545
|
+
...rowEvents(node.leaf, node.path),
|
|
1289
1546
|
children: [
|
|
1290
1547
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1291
1548
|
className: BranchChip_module_default.menuRowLabel,
|
|
@@ -1328,6 +1585,205 @@ window.__ModuleLoader__.load({
|
|
|
1328
1585
|
/** The rendered button for a branch name (flyout anchor on click-select
|
|
1329
1586
|
* paths, where the handler only has the name at hand). */
|
|
1330
1587
|
const buttonOf = (name) => cardRef.current?.querySelector(`button[data-branch="${CSS.escape(name)}"]`) ?? null;
|
|
1588
|
+
/** The row menu's items — for a BRANCH row, the six-verb set (签出 /
|
|
1589
|
+
* 新建 / 新建并检出 / 重命名分支 / 删除分支 / 复制分支), each degenerating
|
|
1590
|
+
* where it has no object: the current branch drops 签出 AND 删除 (git
|
|
1591
|
+
* refuses a delete of the checked-out branch anyway), worktree mode and
|
|
1592
|
+
* linked-worktree sessions drop the write trio + delete (canCreate — the
|
|
1593
|
+
* gate the removed toolbar plus lived under), remote rows drop 重命名
|
|
1594
|
+
* and 删除 (a remote branch is not ours to rename or delete), and a
|
|
1595
|
+
* LOCKED row drops 签出 and the hop — the owner answers those picks
|
|
1596
|
+
* with the main-checkout toast, so the verb leaves with the refusal.
|
|
1597
|
+
* 签出 and the hop go through `pick` DIRECTLY — no confirmation step (the owner
|
|
1598
|
+
* executes the switch in place, keep-open; a worktree-mode pick stages
|
|
1599
|
+
* the owner's worktree dialog instead). 新建 / 新建并检出 open the
|
|
1600
|
+
* create flyout with the row as the start point (`from`; 新建并检出 adds
|
|
1601
|
+
* `checkout` — `git switch -c <name> <from>` — while 新建 leaves every
|
|
1602
|
+
* checkout untouched), 重命名 the rename flyout, 删除 the owner's
|
|
1603
|
+
* confirm flyout (the safe `git branch -d`). A WORKTREE row keeps its
|
|
1604
|
+
* two-item launcher (hop + copy path): its job is hopping, and its
|
|
1605
|
+
* branch is by definition checked out elsewhere. While the session is
|
|
1606
|
+
* BLANK (canWorktree) the two worktree verbs join the set BELOW 新建并
|
|
1607
|
+
* 检出 (isolation reads as the heavier variant of branching) — 创建工作
|
|
1608
|
+
* 树 (the owner stages the reuse/new/remote-twin ask via `onWorktree`;
|
|
1609
|
+
* routing it through `pick` would land on the plain in-place 签出) and
|
|
1610
|
+
* 新建分支并创建工作树 (the owner's cutout dialog, name typed by hand,
|
|
1611
|
+
* cut from THIS row); a started session drops them — its directory is
|
|
1612
|
+
* fixed. Copy is client-only (WYSIWYG display names; a successful write
|
|
1613
|
+
* toasts the shared copied label). The menu opens NEITHER select NOR
|
|
1614
|
+
* pick — it launches, never re-semantics. */
|
|
1615
|
+
const ctxItems = [];
|
|
1616
|
+
if (ctx !== null) {
|
|
1617
|
+
const { row, name, x, y } = ctx;
|
|
1618
|
+
const isWorktree = row?.kind === "worktree";
|
|
1619
|
+
const executable = name !== currentBranch;
|
|
1620
|
+
const markPoint = () => {
|
|
1621
|
+
ctxPointRef.current = {
|
|
1622
|
+
x,
|
|
1623
|
+
y
|
|
1624
|
+
};
|
|
1625
|
+
};
|
|
1626
|
+
const openCreate = (checkout) => {
|
|
1627
|
+
confirmRef.current?.onCancel();
|
|
1628
|
+
setRenaming(null);
|
|
1629
|
+
markPoint();
|
|
1630
|
+
setCtx(null);
|
|
1631
|
+
setDraft("");
|
|
1632
|
+
setCreateBase(remoteNameMapRef.current.get(name) ?? name);
|
|
1633
|
+
setCreateCheckout(checkout);
|
|
1634
|
+
setCreating(true);
|
|
1635
|
+
};
|
|
1636
|
+
if (isWorktree) {
|
|
1637
|
+
if (executable) ctxItems.push({
|
|
1638
|
+
id: "hop",
|
|
1639
|
+
label: t("ctxHop"),
|
|
1640
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRightUpOutline16, { size: 14 }),
|
|
1641
|
+
run: () => {
|
|
1642
|
+
markPoint();
|
|
1643
|
+
setCtx(null);
|
|
1644
|
+
setSelected(name);
|
|
1645
|
+
pick(buttonOf(name), name, true);
|
|
1646
|
+
}
|
|
1647
|
+
});
|
|
1648
|
+
ctxItems.push({
|
|
1649
|
+
id: "copy",
|
|
1650
|
+
label: t("ctxCopyPath"),
|
|
1651
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCopyOutline16, { size: 14 }),
|
|
1652
|
+
run: () => {
|
|
1653
|
+
setCtx(null);
|
|
1654
|
+
const text = row?.path !== void 0 ? row.path : name;
|
|
1655
|
+
(0, _deepseek_ai_dsh_client_ui_primitives.writeClipboard)(text).then((ok) => {
|
|
1656
|
+
if (ok) setCopiedSeq(Date.now());
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
});
|
|
1660
|
+
} else {
|
|
1661
|
+
if (executable) ctxItems.push({
|
|
1662
|
+
id: "checkout",
|
|
1663
|
+
label: t("ctxCheckout"),
|
|
1664
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconBranchOutline16, { size: 14 }),
|
|
1665
|
+
run: () => {
|
|
1666
|
+
markPoint();
|
|
1667
|
+
setCtx(null);
|
|
1668
|
+
setSelected(name);
|
|
1669
|
+
pick(buttonOf(name), name, true);
|
|
1670
|
+
}
|
|
1671
|
+
});
|
|
1672
|
+
if (canCreate) {
|
|
1673
|
+
ctxItems.push({
|
|
1674
|
+
id: "create",
|
|
1675
|
+
label: t("ctxCreate"),
|
|
1676
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlusOutline16, { size: 14 }),
|
|
1677
|
+
run: () => {
|
|
1678
|
+
openCreate(false);
|
|
1679
|
+
}
|
|
1680
|
+
});
|
|
1681
|
+
ctxItems.push({
|
|
1682
|
+
id: "create-checkout",
|
|
1683
|
+
label: t("ctxCreateCheckout"),
|
|
1684
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconBranchOutline16, { size: 14 }),
|
|
1685
|
+
run: () => {
|
|
1686
|
+
openCreate(true);
|
|
1687
|
+
}
|
|
1688
|
+
});
|
|
1689
|
+
}
|
|
1690
|
+
if (canWorktree) {
|
|
1691
|
+
if (name !== currentBranch) ctxItems.push({
|
|
1692
|
+
id: "worktree",
|
|
1693
|
+
label: t("ctxWorktree"),
|
|
1694
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconProjectAddOutline16, { size: 14 }),
|
|
1695
|
+
run: () => {
|
|
1696
|
+
markPoint();
|
|
1697
|
+
setCtx(null);
|
|
1698
|
+
setSelected(name);
|
|
1699
|
+
stagePending(buttonOf(name), name);
|
|
1700
|
+
onWorktree(name);
|
|
1701
|
+
}
|
|
1702
|
+
});
|
|
1703
|
+
ctxItems.push({
|
|
1704
|
+
id: "worktree-cut",
|
|
1705
|
+
label: t("ctxWorktreeCut"),
|
|
1706
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconBranchOutline16, { size: 14 }),
|
|
1707
|
+
run: () => {
|
|
1708
|
+
markPoint();
|
|
1709
|
+
setCtx(null);
|
|
1710
|
+
stagePending(buttonOf(name), name);
|
|
1711
|
+
onCutWorktree(name);
|
|
1712
|
+
}
|
|
1713
|
+
});
|
|
1714
|
+
}
|
|
1715
|
+
if (canCreate) {
|
|
1716
|
+
if (row?.kind !== "remote") {
|
|
1717
|
+
ctxItems.push({
|
|
1718
|
+
id: "rename",
|
|
1719
|
+
label: t("ctxRename"),
|
|
1720
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEditOutline16, { size: 14 }),
|
|
1721
|
+
run: () => {
|
|
1722
|
+
confirmRef.current?.onCancel();
|
|
1723
|
+
markPoint();
|
|
1724
|
+
setCtx(null);
|
|
1725
|
+
setCreating(false);
|
|
1726
|
+
setDraft("");
|
|
1727
|
+
setCreateBase(void 0);
|
|
1728
|
+
setCreateCheckout(false);
|
|
1729
|
+
setRenaming({
|
|
1730
|
+
name,
|
|
1731
|
+
draft: name
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
});
|
|
1735
|
+
if (name !== currentBranch) ctxItems.push({
|
|
1736
|
+
id: "delete",
|
|
1737
|
+
label: t("ctxDelete"),
|
|
1738
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTrashOutline16, { size: 14 }),
|
|
1739
|
+
run: () => {
|
|
1740
|
+
confirmRef.current?.onCancel();
|
|
1741
|
+
markPoint();
|
|
1742
|
+
setCtx(null);
|
|
1743
|
+
stagePending(buttonOf(name), name);
|
|
1744
|
+
onDelete(name);
|
|
1745
|
+
}
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
ctxItems.push({
|
|
1750
|
+
id: "copy",
|
|
1751
|
+
label: t("ctxCopyName"),
|
|
1752
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCopyOutline16, { size: 14 }),
|
|
1753
|
+
run: () => {
|
|
1754
|
+
setCtx(null);
|
|
1755
|
+
(0, _deepseek_ai_dsh_client_ui_primitives.writeClipboard)(name).then((ok) => {
|
|
1756
|
+
if (ok) setCopiedSeq(Date.now());
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
/** The create flyout's ask line. The base branch is the whole difference
|
|
1763
|
+
* between "new branch" and "new branch from THAT row" — the row that was
|
|
1764
|
+
* right-clicked is no longer visible once the menu is replaced by this
|
|
1765
|
+
* flyout (and near a viewport edge the menu had already detached from
|
|
1766
|
+
* it), so the ask has to carry it. No base = the toolbar-era in-place
|
|
1767
|
+
* create, which has nothing to name. */
|
|
1768
|
+
const createAsk = createBase === void 0 ? t("createFlyAsk") : t("createFlyAskFrom", { branch: displayNameOf(createBase) });
|
|
1769
|
+
/**
|
|
1770
|
+
* Arrow/Enter/Home/End inside the row menu. Items are read from the DOM
|
|
1771
|
+
* rather than from `ctxItems` so the focused item IS the source of truth
|
|
1772
|
+
* (no index state to drift). Wrapping at both ends: a six-item transient
|
|
1773
|
+
* is faster to cycle than to aim at. Escape is NOT handled here — the
|
|
1774
|
+
* document listener already unwinds the menu first, and its ordering
|
|
1775
|
+
* against the flyouts belongs in one place.
|
|
1776
|
+
*/
|
|
1777
|
+
const ctxKeyDown = (event) => {
|
|
1778
|
+
const key = event.key;
|
|
1779
|
+
if (key !== "ArrowDown" && key !== "ArrowUp" && key !== "Home" && key !== "End" && key !== "Enter") return;
|
|
1780
|
+
const items = [...ctxCardRef.current?.querySelectorAll("button[role=\"menuitem\"]") ?? []];
|
|
1781
|
+
if (items.length === 0) return;
|
|
1782
|
+
if (key === "Enter") return;
|
|
1783
|
+
event.preventDefault();
|
|
1784
|
+
const at = items.indexOf(document.activeElement);
|
|
1785
|
+
items[key === "Home" ? 0 : key === "End" ? items.length - 1 : key === "ArrowDown" ? (at + 1) % items.length : at <= 0 ? items.length - 1 : at - 1]?.focus();
|
|
1786
|
+
};
|
|
1331
1787
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1332
1788
|
(0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1333
1789
|
ref: cardRef,
|
|
@@ -1343,20 +1799,6 @@ window.__ModuleLoader__.load({
|
|
|
1343
1799
|
role: "toolbar",
|
|
1344
1800
|
"aria-label": t("menuBranches"),
|
|
1345
1801
|
children: [
|
|
1346
|
-
canCreate && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1347
|
-
type: "button",
|
|
1348
|
-
className: creating ? `${BranchChip_module_default.menuToolButton} ${BranchChip_module_default.menuToolButtonOn}` : BranchChip_module_default.menuToolButton,
|
|
1349
|
-
title: t("menuNewBranch"),
|
|
1350
|
-
"aria-label": t("menuNewBranch"),
|
|
1351
|
-
"aria-pressed": creating,
|
|
1352
|
-
onClick: () => {
|
|
1353
|
-
confirmRef.current?.onCancel();
|
|
1354
|
-
const next = !creating;
|
|
1355
|
-
setCreating(next);
|
|
1356
|
-
if (!next) setDraft("");
|
|
1357
|
-
},
|
|
1358
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlusOutline16, { size: 16 })
|
|
1359
|
-
}),
|
|
1360
1802
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1361
1803
|
type: "button",
|
|
1362
1804
|
className: BranchChip_module_default.menuToolButton,
|
|
@@ -1394,7 +1836,7 @@ window.__ModuleLoader__.load({
|
|
|
1394
1836
|
className: BranchChip_module_default.menuToolButton,
|
|
1395
1837
|
title: allExpanded ? t("menuCollapseAll") : t("menuExpandAll"),
|
|
1396
1838
|
"aria-label": allExpanded ? t("menuCollapseAll") : t("menuExpandAll"),
|
|
1397
|
-
disabled: rows.length === 0,
|
|
1839
|
+
disabled: rows.length === 0 || needle !== "",
|
|
1398
1840
|
onClick: toggleAll,
|
|
1399
1841
|
children: allExpanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronUpOutline14, { size: 14 }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutline14, { size: 14 })
|
|
1400
1842
|
})
|
|
@@ -1413,11 +1855,11 @@ window.__ModuleLoader__.load({
|
|
|
1413
1855
|
children: [needle === "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1414
1856
|
grouped.localRows.length > 0 && renderGroupHeader(t("menuLocalBranches"), grouped.localRows.length, localGroupOpen, () => setLocalGroupOpen((value) => !value)),
|
|
1415
1857
|
localGroupOpen && renderTree(localTree, 1, "local:"),
|
|
1416
|
-
|
|
1858
|
+
pickableWorktreeRows.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderGroupHeader(t("menuWorktrees"), pickableWorktreeRows.length, worktreeGroupOpen, () => setWorktreeGroupOpen((value) => !value)), worktreeGroupOpen && pickableWorktreeRows.map((row) => renderFlatLeaf(row, "worktree:"))] }),
|
|
1417
1859
|
grouped.remoteDisplayRows.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderGroupHeader(t("menuRemoteBranches"), grouped.remoteDisplayRows.length, remoteGroupOpen, () => setRemoteGroupOpen((value) => !value)), remoteGroupOpen && renderTree(remoteTree, 1, "remote:")] })
|
|
1418
1860
|
] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1419
1861
|
grouped.localRows.some((row) => row.name.toLowerCase().includes(needle)) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderGroupHeader(t("menuLocalBranches"), searchLeafCount(localTree), true), renderSearch(localTree, 1, "local:")] }),
|
|
1420
|
-
|
|
1862
|
+
pickableWorktreeRows.some((row) => row.name.toLowerCase().includes(needle)) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderGroupHeader(t("menuWorktrees"), pickableWorktreeRows.filter((row) => row.name.toLowerCase().includes(needle)).length, true), pickableWorktreeRows.filter((row) => row.name.toLowerCase().includes(needle)).map((row) => renderFlatLeaf(row, "worktree:"))] }),
|
|
1421
1863
|
grouped.remoteDisplayRows.some((row) => row.name.toLowerCase().includes(needle)) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderGroupHeader(t("menuRemoteBranches"), searchLeafCount(remoteTree), true), renderSearch(remoteTree, 1, "remote:")] })
|
|
1422
1864
|
] }), visible.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1423
1865
|
className: BranchChip_module_default.menuEmpty,
|
|
@@ -1463,6 +1905,30 @@ window.__ModuleLoader__.load({
|
|
|
1463
1905
|
className: BranchChip_module_default.popSubject,
|
|
1464
1906
|
children: confirm.subject
|
|
1465
1907
|
}),
|
|
1908
|
+
confirm.onDraftChange !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1909
|
+
ref: flyInputRef,
|
|
1910
|
+
className: BranchChip_module_default.menuCreate,
|
|
1911
|
+
type: "text",
|
|
1912
|
+
value: confirm.draft ?? "",
|
|
1913
|
+
placeholder: confirm.draftPlaceholder,
|
|
1914
|
+
"aria-label": confirm.draftPlaceholder,
|
|
1915
|
+
"aria-invalid": confirm.draftInvalid === true,
|
|
1916
|
+
spellCheck: false,
|
|
1917
|
+
disabled: confirm.busy,
|
|
1918
|
+
onChange: (event) => {
|
|
1919
|
+
confirm.onDraftChange?.(event.target.value);
|
|
1920
|
+
},
|
|
1921
|
+
onKeyDown: (event) => {
|
|
1922
|
+
if (event.key === "Enter") {
|
|
1923
|
+
event.preventDefault();
|
|
1924
|
+
if (confirm.draftInvalid !== true && !confirm.busy) confirm.onConfirm();
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
}), confirm.draftInvalid === true && confirm.draftHint !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1928
|
+
className: BranchChip_module_default.menuCreateHintBad,
|
|
1929
|
+
role: "status",
|
|
1930
|
+
children: confirm.draftHint
|
|
1931
|
+
})] }),
|
|
1466
1932
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1467
1933
|
className: BranchChip_module_default.popActions,
|
|
1468
1934
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
@@ -1473,7 +1939,7 @@ window.__ModuleLoader__.load({
|
|
|
1473
1939
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1474
1940
|
ref: flyConfirmRef,
|
|
1475
1941
|
type: "button",
|
|
1476
|
-
disabled: confirm.busy,
|
|
1942
|
+
disabled: confirm.busy || confirm.draftInvalid === true,
|
|
1477
1943
|
onClick: confirm.onConfirm,
|
|
1478
1944
|
children: confirm.confirmLabel
|
|
1479
1945
|
})]
|
|
@@ -1485,14 +1951,14 @@ window.__ModuleLoader__.load({
|
|
|
1485
1951
|
className: BranchChip_module_default.popCard,
|
|
1486
1952
|
style: createFlyPos ?? FLY_MEASURE,
|
|
1487
1953
|
role: "dialog",
|
|
1488
|
-
"aria-label":
|
|
1954
|
+
"aria-label": createAsk,
|
|
1489
1955
|
children: [
|
|
1490
1956
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1491
1957
|
className: BranchChip_module_default.popAsk,
|
|
1492
|
-
children:
|
|
1958
|
+
children: createAsk
|
|
1493
1959
|
}),
|
|
1494
1960
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1495
|
-
ref:
|
|
1961
|
+
ref: createInputRef,
|
|
1496
1962
|
className: BranchChip_module_default.menuCreate,
|
|
1497
1963
|
type: "text",
|
|
1498
1964
|
value: draft,
|
|
@@ -1530,95 +1996,157 @@ window.__ModuleLoader__.load({
|
|
|
1530
1996
|
type: "button",
|
|
1531
1997
|
disabled: !createValid || busy,
|
|
1532
1998
|
onClick: commitCreate,
|
|
1533
|
-
children: busy ? t("createBranchBusy") : t("actionConfirm")
|
|
1999
|
+
children: busy ? t("createBranchBusy") : createCheckout ? t("createCheckoutConfirm") : t("actionConfirm")
|
|
1534
2000
|
})]
|
|
1535
2001
|
})
|
|
1536
2002
|
]
|
|
1537
|
-
}), document.body)
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
2003
|
+
}), document.body),
|
|
2004
|
+
renaming !== null && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2005
|
+
ref: renameFlyRef,
|
|
2006
|
+
className: BranchChip_module_default.popCard,
|
|
2007
|
+
style: renameFlyPos ?? FLY_MEASURE,
|
|
2008
|
+
role: "dialog",
|
|
2009
|
+
"aria-label": t("renameBranchTitle", { branch: renaming.name }),
|
|
2010
|
+
children: [
|
|
2011
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2012
|
+
className: BranchChip_module_default.popAsk,
|
|
2013
|
+
children: t("renameBranchTitle", { branch: renaming.name })
|
|
2014
|
+
}),
|
|
2015
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2016
|
+
ref: renameInputRef,
|
|
2017
|
+
className: BranchChip_module_default.menuCreate,
|
|
2018
|
+
type: "text",
|
|
2019
|
+
value: renaming.draft,
|
|
2020
|
+
placeholder: t("menuNewBranchPlaceholder"),
|
|
2021
|
+
"aria-label": t("menuNewBranchPlaceholder"),
|
|
2022
|
+
"aria-invalid": renameIssue !== null && renameIssue !== "empty",
|
|
2023
|
+
spellCheck: false,
|
|
2024
|
+
disabled: busy,
|
|
2025
|
+
onChange: (event) => {
|
|
2026
|
+
setRenaming((current) => current === null ? current : {
|
|
2027
|
+
...current,
|
|
2028
|
+
draft: event.target.value
|
|
2029
|
+
});
|
|
2030
|
+
},
|
|
2031
|
+
onKeyDown: (event) => {
|
|
2032
|
+
if (event.key === "Enter") {
|
|
2033
|
+
event.preventDefault();
|
|
2034
|
+
commitRename();
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
}),
|
|
2038
|
+
showRenameHint && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2039
|
+
className: BranchChip_module_default.menuCreateHintBad,
|
|
2040
|
+
role: "status",
|
|
2041
|
+
children: renameDuplicate ? t("menuNewBranchExists") : t("menuNewBranchBad")
|
|
2042
|
+
}),
|
|
2043
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2044
|
+
className: BranchChip_module_default.popActions,
|
|
2045
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2046
|
+
type: "button",
|
|
2047
|
+
disabled: busy,
|
|
2048
|
+
onClick: () => {
|
|
2049
|
+
setRenaming(null);
|
|
2050
|
+
},
|
|
2051
|
+
children: t("actionCancel")
|
|
2052
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2053
|
+
type: "button",
|
|
2054
|
+
disabled: !renameValid || busy,
|
|
2055
|
+
onClick: commitRename,
|
|
2056
|
+
children: busy ? t("renameBranchBusy") : t("actionConfirm")
|
|
2057
|
+
})]
|
|
2058
|
+
})
|
|
2059
|
+
]
|
|
2060
|
+
}), document.body),
|
|
2061
|
+
ctx !== null && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2062
|
+
ref: ctxCardRef,
|
|
2063
|
+
className: BranchChip_module_default.ctxCard,
|
|
2064
|
+
style: ctxPos ?? FLY_MEASURE,
|
|
2065
|
+
role: "menu",
|
|
2066
|
+
"aria-label": ctx.name,
|
|
2067
|
+
onKeyDown: ctxKeyDown,
|
|
2068
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2069
|
+
className: BranchChip_module_default.ctxHeader,
|
|
2070
|
+
title: ctx.name,
|
|
2071
|
+
children: ctx.name
|
|
2072
|
+
}), ctxItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2073
|
+
type: "button",
|
|
2074
|
+
role: "menuitem",
|
|
2075
|
+
className: BranchChip_module_default.ctxItem,
|
|
2076
|
+
onClick: item.run,
|
|
2077
|
+
children: [item.icon, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2078
|
+
className: BranchChip_module_default.ctxItemLabel,
|
|
2079
|
+
children: item.label
|
|
2080
|
+
})]
|
|
2081
|
+
}, item.id))]
|
|
2082
|
+
}), document.body),
|
|
2083
|
+
copiedSeq !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
|
|
2084
|
+
text: t("hover.copied"),
|
|
2085
|
+
onDone: () => {
|
|
2086
|
+
setCopiedSeq(null);
|
|
2087
|
+
}
|
|
2088
|
+
}, copiedSeq)
|
|
2089
|
+
] });
|
|
1621
2090
|
}
|
|
2091
|
+
//#endregion
|
|
2092
|
+
//#region src/client/BranchChip.tsx
|
|
2093
|
+
/**
|
|
2094
|
+
* BranchChipDock: the composer tool-row entry (conversation.input.left, right
|
|
2095
|
+
* of the mode chips) for sessions inside a git repository. Blank sessions
|
|
2096
|
+
* OF THE MAIN checkout get the full segmented control — branch picker plus
|
|
2097
|
+
* the worktree isolation toggle — because that is the moment to choose the
|
|
2098
|
+
* environment for the conversation, and starting a worktree is a main-repo
|
|
2099
|
+
* decision. Once the session starts, the worktree toggle is withdrawn (its
|
|
2100
|
+
* directory is fixed). A session inside a LINKED worktree scopes the entry
|
|
2101
|
+
* down to TWO things, blank or started alike: the branch this worktree
|
|
2102
|
+
* holds (the position marker, trailing check included) and the 「工作树」
|
|
2103
|
+
* group of every OTHER worktree — the main checkout included, since from
|
|
2104
|
+
* in here that is another place to go — whose rows carry the hop. The
|
|
2105
|
+
* directory's identity IS its branch, so every other BRANCH would be a row
|
|
2106
|
+
* the owner must refuse — a menu of refusals is not a menu (the same
|
|
2107
|
+
* judgement that removed the toggle and the in-place new-branch tool here).
|
|
2108
|
+
* A worktree row is different in kind: hopping there registers that folder
|
|
2109
|
+
* and opens a fresh session, touching no checkout, so it stays legal here —
|
|
2110
|
+
* and it is the one action a linked-worktree session most needs, since
|
|
2111
|
+
* moving between worktrees is the point of having them. What also stays is
|
|
2112
|
+
* the two tools that never move a checkout: fetch, and update-current — the
|
|
2113
|
+
* update fast-forwards the session's OWN worktree, the fetch is
|
|
2114
|
+
* repository-wide metadata. Non-git directories and load failures render
|
|
2115
|
+
* nothing. The confirm dialogs and the error toast live here too.
|
|
2116
|
+
*
|
|
2117
|
+
* Checking the worktree toggle pops the cutout confirm dialog right away:
|
|
2118
|
+
* confirming it cuts a NEW branch (`<current>-wt`, suffixes past taken
|
|
2119
|
+
* names) out of the current checkout into a fresh isolated worktree — the
|
|
2120
|
+
* current branch itself is occupied by the main worktree, so git refuses a
|
|
2121
|
+
* second worktree on it. The dialog stands alone above the chip (the
|
|
2122
|
+
* branch menu stays closed); the chip still opens the menu, where picking
|
|
2123
|
+
* another branch keeps the plain create-or-reuse flow and re-picking the
|
|
2124
|
+
* current branch stages the same cutout confirm. Dismissing the dialog and
|
|
2125
|
+
* sending the message anyway means the user knowingly stays in the current
|
|
2126
|
+
* directory — no separate notice fires on send.
|
|
2127
|
+
*
|
|
2128
|
+
* In-place branch creation (the menu toolbar's plus, worktree mode off)
|
|
2129
|
+
* opens the create flyout right of the branch card: type the name, press
|
|
2130
|
+
* Create — the new branch is cut from the session directory's current
|
|
2131
|
+
* checkout and checked out there in one stroke, the worktree-less sibling
|
|
2132
|
+
* of the cutout flow. A failure toasts and leaves the flyout open.
|
|
2133
|
+
*
|
|
2134
|
+
* Remote branches join the picker under their own menu group: picking one
|
|
2135
|
+
* stages the remote-twin confirm — the switch creates the local tracking
|
|
2136
|
+
* branch in place (git's dwim), the worktree pick creates the twin inside
|
|
2137
|
+
* its fresh worktree. Both rides go through the existing /switch and
|
|
2138
|
+
* /worktree routes, which already resolve `<remote>/name` display names.
|
|
2139
|
+
*
|
|
2140
|
+
* Worktrees get their own 「工作树」 group, listing every worktree but the
|
|
2141
|
+
* one the session sits in: the row menu's 「跳到此工作树」 registers that
|
|
2142
|
+
* directory and opens a blank session in it (adoptWorktree; no git action,
|
|
2143
|
+
* no confirm). On the main checkout's BLANK session the group doubles as
|
|
2144
|
+
* the only way to reach a branch held by a worktree — those have left the
|
|
2145
|
+
* local group (git refuses to check them out twice, so a local-group row
|
|
2146
|
+
* would be a dead end). A linked-worktree session keeps that group and
|
|
2147
|
+
* gains the main checkout row (see {@link buildLinkedWorktreeRows}); a
|
|
2148
|
+
* started MAIN-checkout session drops the group — its directory is fixed.
|
|
2149
|
+
*/
|
|
1622
2150
|
/**
|
|
1623
2151
|
* Read the repository status for a directory; refetch on demand.
|
|
1624
2152
|
* @param cwd - absolute session directory.
|
|
@@ -1667,45 +2195,84 @@ window.__ModuleLoader__.load({
|
|
|
1667
2195
|
return branch.length <= BRANCH_DISPLAY_MAX ? branch : `${branch.slice(0, 24)}…`;
|
|
1668
2196
|
}
|
|
1669
2197
|
/**
|
|
1670
|
-
* Build the branch rows for the picker
|
|
1671
|
-
* held by a linked worktree, REMOTE branches,
|
|
1672
|
-
* linked worktree. A branch held by a worktree
|
|
1673
|
-
* git refuses to check it out twice, so the row
|
|
1674
|
-
* worktree group is the way INTO it instead (a
|
|
1675
|
-
* the owner's onAdoptWorktree).
|
|
1676
|
-
* don't come along: the main checkout is home, not a hop target, and a
|
|
1677
|
-
* detached worktree has no branch name to offer.
|
|
2198
|
+
* Build the branch rows for the picker on the MAIN checkout, in three
|
|
2199
|
+
* kinds: LOCAL branches not held by a linked worktree, REMOTE branches,
|
|
2200
|
+
* and one WORKTREE row per linked worktree. A branch held by a worktree
|
|
2201
|
+
* LEAVES the local group — git refuses to check it out twice, so the row
|
|
2202
|
+
* would be a dead end; the worktree group is the way INTO it instead (a
|
|
2203
|
+
* direct session hop, see the owner's onAdoptWorktree).
|
|
1678
2204
|
*
|
|
1679
|
-
*
|
|
1680
|
-
*
|
|
1681
|
-
*
|
|
1682
|
-
*
|
|
2205
|
+
* The worktree group is "every worktree EXCEPT the one this session sits
|
|
2206
|
+
* in" — here that is the main checkout itself (the session IS the main
|
|
2207
|
+
* checkout), so `w.main` drops out: hopping home is not a hop. A detached
|
|
2208
|
+
* worktree drops out too — it has no branch name to show or hop by.
|
|
2209
|
+
* (Linked-worktree sessions express the same rule from the other side, and
|
|
2210
|
+
* therefore DO list the main checkout: see
|
|
2211
|
+
* {@link buildLinkedWorktreeRows}.)
|
|
2212
|
+
*
|
|
2213
|
+
* Only the MAIN checkout's sessions call this: a linked-worktree session
|
|
2214
|
+
* renders its own pair of rows instead (see
|
|
2215
|
+
* {@link buildLinkedWorktreeRows}), so nothing here ever has to express
|
|
2216
|
+
* "not usable in this directory".
|
|
1683
2217
|
*/
|
|
1684
|
-
function buildBranchRows(branches, worktrees
|
|
2218
|
+
function buildBranchRows(branches, worktrees) {
|
|
1685
2219
|
const held = new Set(worktrees.flatMap((w) => w.main || w.branch === void 0 ? [] : [w.branch]));
|
|
1686
|
-
const lock = (name) => inLinkedWorktree && name !== currentBranch;
|
|
1687
2220
|
return [
|
|
1688
2221
|
...branches.filter((b) => b.kind === "local" && !held.has(b.name)).map((b) => ({
|
|
1689
2222
|
name: b.name,
|
|
1690
2223
|
kind: "local",
|
|
1691
2224
|
...b.ahead === void 0 ? {} : { ahead: b.ahead },
|
|
1692
|
-
...b.behind === void 0 ? {} : { behind: b.behind }
|
|
1693
|
-
locked: lock(b.name)
|
|
2225
|
+
...b.behind === void 0 ? {} : { behind: b.behind }
|
|
1694
2226
|
})),
|
|
1695
2227
|
...branches.filter((b) => b.kind === "remote").map((b) => ({
|
|
1696
2228
|
name: b.name,
|
|
1697
|
-
kind: "remote"
|
|
1698
|
-
locked: lock(b.name)
|
|
2229
|
+
kind: "remote"
|
|
1699
2230
|
})),
|
|
1700
2231
|
...worktrees.flatMap((w) => w.main || w.branch === void 0 ? [] : [{
|
|
1701
2232
|
name: w.branch,
|
|
1702
2233
|
kind: "worktree",
|
|
1703
|
-
path: w.path
|
|
1704
|
-
locked: lock(w.branch)
|
|
2234
|
+
path: w.path
|
|
1705
2235
|
}])
|
|
1706
2236
|
];
|
|
1707
2237
|
}
|
|
1708
2238
|
/**
|
|
2239
|
+
* Build the rows for a LINKED-worktree session: the branch this worktree
|
|
2240
|
+
* holds, plus one row per OTHER worktree of the repository.
|
|
2241
|
+
*
|
|
2242
|
+
* The worktree rows are here for the HOP: 「跳到此工作树」 registers that
|
|
2243
|
+
* directory and opens a blank session in it (`adoptWorktree`) — a
|
|
2244
|
+
* session-level jump that never touches a checkout, so a linked-worktree
|
|
2245
|
+
* session can offer it on the same terms the main checkout's blank session
|
|
2246
|
+
* does. Hopping between worktrees is the whole point of having them.
|
|
2247
|
+
*
|
|
2248
|
+
* The exclusion is the SAME rule as {@link buildBranchRows} states from the
|
|
2249
|
+
* main checkout's side — "every worktree except the one you are in" — which
|
|
2250
|
+
* here means excluding by BRANCH (`w.branch === currentBranch`) rather than
|
|
2251
|
+
* by `w.main`. The main checkout therefore STAYS in the list: from inside a
|
|
2252
|
+
* linked worktree it is exactly the other place you want to go, and unlike
|
|
2253
|
+
* the worktree you are sitting in, its row is not a hop to where you
|
|
2254
|
+
* already are. Detached worktrees still drop out (no branch name to show),
|
|
2255
|
+
* as does this session's own worktree (it already owns the local row above,
|
|
2256
|
+
* which carries the trailing check as the "you are here" mark).
|
|
2257
|
+
*
|
|
2258
|
+
* What stays absent is every OTHER branch, local or remote: the directory's
|
|
2259
|
+
* identity is its branch, so those rows could only ever be offered as
|
|
2260
|
+
* refusals (see the component doc).
|
|
2261
|
+
*/
|
|
2262
|
+
function buildLinkedWorktreeRows(branches, worktrees, currentBranch) {
|
|
2263
|
+
const current = branches.find((b) => b.kind === "local" && b.name === currentBranch);
|
|
2264
|
+
return [...current === void 0 ? [] : [{
|
|
2265
|
+
name: current.name,
|
|
2266
|
+
kind: "local",
|
|
2267
|
+
...current.ahead === void 0 ? {} : { ahead: current.ahead },
|
|
2268
|
+
...current.behind === void 0 ? {} : { behind: current.behind }
|
|
2269
|
+
}], ...worktrees.flatMap((w) => w.branch === void 0 || w.branch === currentBranch ? [] : [{
|
|
2270
|
+
name: w.branch,
|
|
2271
|
+
kind: "worktree",
|
|
2272
|
+
path: w.path
|
|
2273
|
+
}])];
|
|
2274
|
+
}
|
|
2275
|
+
/**
|
|
1709
2276
|
* The check-time confirm dialog, rendered while the branch menu is closed:
|
|
1710
2277
|
* the same popCard chrome as BranchMenu's flyout, but bottom-pinned above
|
|
1711
2278
|
* the chip in the menu card's posture — the flyout's right-of-card anchor
|
|
@@ -1822,13 +2389,12 @@ window.__ModuleLoader__.load({
|
|
|
1822
2389
|
}), document.body);
|
|
1823
2390
|
}
|
|
1824
2391
|
/** The tool-row entry registered into conversation.input.left. */
|
|
1825
|
-
function BranchChipDock({ sessionId, useSessions, useSession, adoptWorktree, t }) {
|
|
2392
|
+
function BranchChipDock({ sessionId, useSessions, useSession, adoptWorktree, pruneWorktrees, t }) {
|
|
1826
2393
|
const summary = useSessions((state) => state.byId[sessionId]);
|
|
1827
2394
|
const session = useSession((s) => s);
|
|
1828
2395
|
const cwd = summary?.cwd;
|
|
1829
2396
|
const [repo, refresh] = useRepoStatus(cwd);
|
|
1830
2397
|
const [menuOpen, setMenuOpen] = (0, react.useState)(false);
|
|
1831
|
-
const [worktreeMode, setWorktreeMode] = (0, react.useState)(false);
|
|
1832
2398
|
const [confirm, setConfirm] = (0, react.useState)(null);
|
|
1833
2399
|
const [busy, setBusy] = (0, react.useState)(false);
|
|
1834
2400
|
/** Which arrow is spinning: fetch and update are single-flight against
|
|
@@ -1836,19 +2402,29 @@ window.__ModuleLoader__.load({
|
|
|
1836
2402
|
* per-tool — one shared flag made both arrows rotate at once. */
|
|
1837
2403
|
const [fetchBusy, setFetchBusy] = (0, react.useState)(false);
|
|
1838
2404
|
const [updateBusy, setUpdateBusy] = (0, react.useState)(false);
|
|
1839
|
-
|
|
2405
|
+
/** Toasts wait their turn instead of overwriting each other. One flow
|
|
2406
|
+
* can raise two in a row — a worktree creation whose fetch warned, then
|
|
2407
|
+
* the auto-prune's report — and a single-slot state made the second
|
|
2408
|
+
* silently erase the first before anyone read it. Head renders, `onDone`
|
|
2409
|
+
* shifts. */
|
|
2410
|
+
const [toasts, setToasts] = (0, react.useState)([]);
|
|
2411
|
+
const toastSeq = (0, react.useRef)(0);
|
|
2412
|
+
const pushToast = (0, react.useCallback)((text) => {
|
|
2413
|
+
toastSeq.current += 1;
|
|
2414
|
+
const seq = toastSeq.current;
|
|
2415
|
+
setToasts((queue) => [...queue, {
|
|
2416
|
+
seq,
|
|
2417
|
+
text
|
|
2418
|
+
}]);
|
|
2419
|
+
}, []);
|
|
1840
2420
|
const chipRef = (0, react.useRef)(null);
|
|
1841
2421
|
const busyRef = (0, react.useRef)(false);
|
|
1842
2422
|
(0, react.useEffect)(() => {
|
|
1843
|
-
setWorktreeMode(false);
|
|
1844
2423
|
setConfirm(null);
|
|
1845
2424
|
setMenuOpen(false);
|
|
1846
2425
|
}, [cwd]);
|
|
1847
2426
|
(0, react.useEffect)(() => {
|
|
1848
|
-
if (!session.blank)
|
|
1849
|
-
setWorktreeMode(false);
|
|
1850
|
-
setConfirm((current) => current !== null && current.kind !== "switch" ? null : current);
|
|
1851
|
-
}
|
|
2427
|
+
if (!session.blank) setConfirm(null);
|
|
1852
2428
|
}, [session.blank]);
|
|
1853
2429
|
(0, react.useEffect)(() => {
|
|
1854
2430
|
const refreshIfIdle = () => {
|
|
@@ -1866,13 +2442,13 @@ window.__ModuleLoader__.load({
|
|
|
1866
2442
|
};
|
|
1867
2443
|
}, [refresh]);
|
|
1868
2444
|
const showError = (0, react.useCallback)((message) => {
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
const runGuarded = (0, react.useCallback)(async (action) => {
|
|
2445
|
+
pushToast(t("errorGeneric", { message }));
|
|
2446
|
+
}, [pushToast, t]);
|
|
2447
|
+
/** Run one guarded confirm action: single-flight, toast on failure. On
|
|
2448
|
+
* success the confirm clears; the MENU closes unless `keepOpen` (the row
|
|
2449
|
+
* menu's rule: 原地动作 leave the picker up), and `onSettled` — the
|
|
2450
|
+
* flyout's success-only close hook — fires after both. */
|
|
2451
|
+
const runGuarded = (0, react.useCallback)(async (action, keepOpen = false, onSettled) => {
|
|
1876
2452
|
if (busyRef.current) return;
|
|
1877
2453
|
busyRef.current = true;
|
|
1878
2454
|
setBusy(true);
|
|
@@ -1884,30 +2460,57 @@ window.__ModuleLoader__.load({
|
|
|
1884
2460
|
return;
|
|
1885
2461
|
}
|
|
1886
2462
|
setConfirm(null);
|
|
1887
|
-
setMenuOpen(false);
|
|
2463
|
+
if (!keepOpen) setMenuOpen(false);
|
|
2464
|
+
onSettled?.();
|
|
1888
2465
|
}, [showError]);
|
|
1889
2466
|
/** In-place switch flow: POST /switch, then refetch the status. */
|
|
1890
|
-
const doSwitch = (0, react.useCallback)((branch) => runGuarded(async () => {
|
|
2467
|
+
const doSwitch = (0, react.useCallback)((branch, keepOpen = false) => runGuarded(async () => {
|
|
1891
2468
|
if (cwd === void 0) return "no session directory";
|
|
1892
2469
|
const result = await requestSwitch(cwd, branch);
|
|
1893
2470
|
if (!result.ok) return result.error;
|
|
1894
2471
|
await refresh();
|
|
1895
|
-
}), [
|
|
2472
|
+
}, keepOpen), [
|
|
1896
2473
|
cwd,
|
|
1897
2474
|
refresh,
|
|
1898
2475
|
runGuarded
|
|
1899
2476
|
]);
|
|
1900
|
-
/** Create-branch flow: POST /branch (
|
|
1901
|
-
*
|
|
1902
|
-
*
|
|
1903
|
-
*
|
|
1904
|
-
*
|
|
1905
|
-
const doCreateBranch = (0, react.useCallback)((name) => runGuarded(async () => {
|
|
2477
|
+
/** Create-branch flow: POST /branch (`from` + `checkout` split the three
|
|
2478
|
+
* shapes — see the wire docs), then refetch the status. ALWAYS keep-open:
|
|
2479
|
+
* the row menu is the only entry now, and the whole point of the menu is
|
|
2480
|
+
* acting on more rows afterwards; `onSettled` closes the create flyout
|
|
2481
|
+
* on success only. */
|
|
2482
|
+
const doCreateBranch = (0, react.useCallback)((name, from, checkout, onSettled) => runGuarded(async () => {
|
|
1906
2483
|
if (cwd === void 0) return "no session directory";
|
|
1907
|
-
const result = await requestCreateBranch(cwd, name);
|
|
2484
|
+
const result = await requestCreateBranch(cwd, name, from, checkout);
|
|
1908
2485
|
if (!result.ok) return result.error;
|
|
1909
2486
|
await refresh();
|
|
1910
|
-
}), [
|
|
2487
|
+
}, true, onSettled), [
|
|
2488
|
+
cwd,
|
|
2489
|
+
refresh,
|
|
2490
|
+
runGuarded
|
|
2491
|
+
]);
|
|
2492
|
+
/** Rename-branch flow: POST /branch-rename (`git branch -m`, repository-
|
|
2493
|
+
* wide), then refetch the status — the chip label and the row follow the
|
|
2494
|
+
* new name. Keep-open + success-only `onSettled`, like the create. */
|
|
2495
|
+
const doRenameBranch = (0, react.useCallback)((name, newName, onSettled) => runGuarded(async () => {
|
|
2496
|
+
if (cwd === void 0) return "no session directory";
|
|
2497
|
+
const result = await requestRenameBranch(cwd, name, newName);
|
|
2498
|
+
if (!result.ok) return result.error;
|
|
2499
|
+
await refresh();
|
|
2500
|
+
}, true, onSettled), [
|
|
2501
|
+
cwd,
|
|
2502
|
+
refresh,
|
|
2503
|
+
runGuarded
|
|
2504
|
+
]);
|
|
2505
|
+
/** Delete-branch flow: POST /branch-delete (the SAFE `-d`; git refuses
|
|
2506
|
+
* unmerged commits and occupied branches with a 400 toast), then refetch
|
|
2507
|
+
* the status — the refreshed rows drop the row, the menu stays. */
|
|
2508
|
+
const doDeleteBranch = (0, react.useCallback)((name) => runGuarded(async () => {
|
|
2509
|
+
if (cwd === void 0) return "no session directory";
|
|
2510
|
+
const result = await requestDeleteBranch(cwd, name);
|
|
2511
|
+
if (!result.ok) return result.error;
|
|
2512
|
+
await refresh();
|
|
2513
|
+
}, true), [
|
|
1911
2514
|
cwd,
|
|
1912
2515
|
refresh,
|
|
1913
2516
|
runGuarded
|
|
@@ -1937,12 +2540,10 @@ window.__ModuleLoader__.load({
|
|
|
1937
2540
|
return;
|
|
1938
2541
|
}
|
|
1939
2542
|
await refresh();
|
|
1940
|
-
|
|
1941
|
-
seq: Date.now(),
|
|
1942
|
-
text: t("fetchDone")
|
|
1943
|
-
});
|
|
2543
|
+
pushToast(t("fetchDone"));
|
|
1944
2544
|
}, [
|
|
1945
2545
|
cwd,
|
|
2546
|
+
pushToast,
|
|
1946
2547
|
refresh,
|
|
1947
2548
|
showError,
|
|
1948
2549
|
t
|
|
@@ -1969,18 +2570,16 @@ window.__ModuleLoader__.load({
|
|
|
1969
2570
|
return;
|
|
1970
2571
|
}
|
|
1971
2572
|
await refresh();
|
|
1972
|
-
|
|
1973
|
-
seq: Date.now(),
|
|
1974
|
-
text: result.updated ? t("updateDone", { branch: result.branch }) : t("updateUpToDate")
|
|
1975
|
-
});
|
|
2573
|
+
pushToast(result.updated ? t("updateDone", { branch: result.branch }) : t("updateUpToDate"));
|
|
1976
2574
|
}, [
|
|
1977
2575
|
cwd,
|
|
2576
|
+
pushToast,
|
|
1978
2577
|
refresh,
|
|
1979
2578
|
showError,
|
|
1980
2579
|
t
|
|
1981
2580
|
]);
|
|
1982
2581
|
/** Worktree-group flow: hop the session into the EXISTING worktree
|
|
1983
|
-
* directory. No git action, no confirm — the
|
|
2582
|
+
* directory. No git action, no confirm — the row menu's hop IS the jump
|
|
1984
2583
|
* (a directory jump is reversible and touches nothing), and the owner's
|
|
1985
2584
|
* adoptWorktree registers the folder and opens a blank session there. */
|
|
1986
2585
|
const doAdoptWorktree = (0, react.useCallback)((path) => {
|
|
@@ -1997,7 +2596,10 @@ window.__ModuleLoader__.load({
|
|
|
1997
2596
|
});
|
|
1998
2597
|
}, [adoptWorktree, showError]);
|
|
1999
2598
|
/** Worktree flow: POST /worktree (create-or-reuse, or cut out a new
|
|
2000
|
-
* branch under an explicit name), register the directory, hop sessions.
|
|
2599
|
+
* branch under an explicit name), register the directory, hop sessions.
|
|
2600
|
+
* After the hop the lazy auto-prune fires (fire-and-forget — a slow
|
|
2601
|
+
* removal must not hold the confirm dialog open), and a failed
|
|
2602
|
+
* pre-create fetch surfaces as a toast without undoing the creation. */
|
|
2001
2603
|
const doWorktree = (0, react.useCallback)((branch, cutout, name) => runGuarded(async () => {
|
|
2002
2604
|
if (cwd === void 0) return "no session directory";
|
|
2003
2605
|
const result = cutout ? await requestWorktreeCutout(cwd, branch, name) : await requestWorktree(cwd, branch);
|
|
@@ -2007,30 +2609,27 @@ window.__ModuleLoader__.load({
|
|
|
2007
2609
|
} catch (cause) {
|
|
2008
2610
|
return cause instanceof Error ? cause.message : String(cause);
|
|
2009
2611
|
}
|
|
2612
|
+
if (result.fetchWarning !== void 0) pushToast(t("fetchWarning", { message: result.fetchWarning }));
|
|
2613
|
+
pruneWorktrees?.(result.path).then((report) => {
|
|
2614
|
+
if (report === void 0) return;
|
|
2615
|
+
if (report.removed.length > 0) pushToast(report.failed.length > 0 ? `${t("pruneDone", { n: report.removed.length })} ${t("pruneFailed", { n: report.failed.length })}` : t("pruneDone", { n: report.removed.length }));
|
|
2616
|
+
else if (report.failed.length > 0) pushToast(t("pruneFailed", { n: report.failed.length }));
|
|
2617
|
+
}).catch(() => {});
|
|
2010
2618
|
}), [
|
|
2011
2619
|
adoptWorktree,
|
|
2620
|
+
pruneWorktrees,
|
|
2012
2621
|
cwd,
|
|
2013
|
-
|
|
2622
|
+
pushToast,
|
|
2623
|
+
runGuarded,
|
|
2624
|
+
t
|
|
2014
2625
|
]);
|
|
2015
2626
|
const facts = repo.facts;
|
|
2016
|
-
const inLinkedWorktree = facts !== null && facts.
|
|
2627
|
+
const inLinkedWorktree = facts !== null && !facts.main;
|
|
2017
2628
|
const rows = (0, react.useMemo)(() => {
|
|
2018
2629
|
if (facts === null) return [];
|
|
2019
|
-
if (inLinkedWorktree
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
name: current.name,
|
|
2023
|
-
kind: "local",
|
|
2024
|
-
...current.ahead === void 0 ? {} : { ahead: current.ahead },
|
|
2025
|
-
...current.behind === void 0 ? {} : { behind: current.behind }
|
|
2026
|
-
}];
|
|
2027
|
-
}
|
|
2028
|
-
return buildBranchRows(facts.branches, facts.worktrees, facts.currentBranch, inLinkedWorktree);
|
|
2029
|
-
}, [
|
|
2030
|
-
facts,
|
|
2031
|
-
inLinkedWorktree,
|
|
2032
|
-
session.blank
|
|
2033
|
-
]);
|
|
2630
|
+
if (inLinkedWorktree) return buildLinkedWorktreeRows(facts.branches, facts.worktrees, facts.currentBranch);
|
|
2631
|
+
return buildBranchRows(facts.branches, facts.worktrees);
|
|
2632
|
+
}, [facts, inLinkedWorktree]);
|
|
2034
2633
|
const localNames = (0, react.useMemo)(() => rows.filter((row) => row.kind !== "remote").map((row) => row.name), [rows]);
|
|
2035
2634
|
if (facts === null) return null;
|
|
2036
2635
|
const confirmLocalName = confirm === null ? "" : localBranchName(confirm.branch);
|
|
@@ -2042,30 +2641,42 @@ window.__ModuleLoader__.load({
|
|
|
2042
2641
|
const cutoutHint = cutoutDuplicate ? t("menuNewBranchExists") : cutoutIssue !== null && cutoutIssue !== "empty" ? t("menuNewBranchBad") : void 0;
|
|
2043
2642
|
const existingWorktree = confirm === null || confirm.kind !== "worktree" ? void 0 : facts.worktrees.find((w) => w.branch === confirmLocalName);
|
|
2044
2643
|
/** One confirm bundle shared by the menu flyout and the standalone
|
|
2045
|
-
* dialog (whichever is showing).
|
|
2046
|
-
*
|
|
2047
|
-
*
|
|
2048
|
-
*
|
|
2644
|
+
* dialog (whichever is showing). Switches stage NO dialog — 签出 runs
|
|
2645
|
+
* directly (keep-open); what remains is the destructive delete and the
|
|
2646
|
+
* worktree/cutout dialogs, the latter carrying the editable new-branch
|
|
2647
|
+
* name. Remote worktree picks keep the ask line SHORT and name the
|
|
2648
|
+
* branch on its own weight-500 line. */
|
|
2049
2649
|
const confirmBundle = confirm === null ? null : {
|
|
2050
|
-
ask: confirm.kind === "worktree-cutout" ? t("
|
|
2650
|
+
ask: confirm.kind === "worktree-cutout" ? t("cutoutFlyAsk", { branch: confirm.branch }) : confirm.kind === "delete" ? t("deleteBranchAsk", { branch: confirm.branch }) : confirm.remote === true ? t("worktreeAskRemote") : t(existingWorktree !== void 0 ? "worktreeAskReuse" : "worktreeAskNew", { branch: confirmLocalName }),
|
|
2051
2651
|
...confirm.remote === true ? { subject: confirm.branch } : {},
|
|
2052
|
-
confirmLabel: busy ? confirm.kind === "
|
|
2652
|
+
confirmLabel: busy ? confirm.kind === "delete" ? t("deleteBranchBusy") : t("worktreeBusy") : t("actionConfirm"),
|
|
2053
2653
|
cancelLabel: t("actionCancel"),
|
|
2054
2654
|
busy,
|
|
2655
|
+
...confirm.kind === "worktree-cutout" ? {
|
|
2656
|
+
draft: cutoutDraft,
|
|
2657
|
+
onDraftChange: (value) => {
|
|
2658
|
+
setConfirm((current) => current?.kind === "worktree-cutout" ? {
|
|
2659
|
+
...current,
|
|
2660
|
+
draft: value
|
|
2661
|
+
} : current);
|
|
2662
|
+
},
|
|
2663
|
+
draftPlaceholder: t("menuNewBranchPlaceholder"),
|
|
2664
|
+
...cutoutValid ? {} : { draftInvalid: true },
|
|
2665
|
+
...cutoutHint === void 0 ? {} : { draftHint: cutoutHint }
|
|
2666
|
+
} : {},
|
|
2055
2667
|
onConfirm: () => {
|
|
2056
|
-
if (confirm.kind === "
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
} else doSwitch(confirm.branch);
|
|
2668
|
+
if (confirm.kind === "delete") doDeleteBranch(confirm.branch);
|
|
2669
|
+
else if (confirm.kind === "worktree-cutout" && !cutoutValid) return;
|
|
2670
|
+
else doWorktree(confirm.branch, confirm.kind === "worktree-cutout", confirm.draft);
|
|
2060
2671
|
},
|
|
2061
2672
|
onCancel: () => {
|
|
2062
2673
|
if (!busy) setConfirm(null);
|
|
2063
2674
|
}
|
|
2064
2675
|
};
|
|
2065
2676
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
2066
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
2677
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2067
2678
|
className: BranchChip_module_default.dock,
|
|
2068
|
-
children:
|
|
2679
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2069
2680
|
ref: chipRef,
|
|
2070
2681
|
type: "button",
|
|
2071
2682
|
className: BranchChip_module_default.chip,
|
|
@@ -2080,34 +2691,7 @@ window.__ModuleLoader__.load({
|
|
|
2080
2691
|
className: BranchChip_module_default.branch,
|
|
2081
2692
|
children: displayBranch(facts.currentBranch)
|
|
2082
2693
|
})]
|
|
2083
|
-
})
|
|
2084
|
-
className: BranchChip_module_default.divider,
|
|
2085
|
-
"aria-hidden": "true"
|
|
2086
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2087
|
-
type: "button",
|
|
2088
|
-
className: worktreeMode ? BranchChip_module_default.checkOn : BranchChip_module_default.check,
|
|
2089
|
-
onClick: () => {
|
|
2090
|
-
const next = !worktreeMode;
|
|
2091
|
-
setWorktreeMode(next);
|
|
2092
|
-
setMenuOpen(false);
|
|
2093
|
-
if (next) {
|
|
2094
|
-
setConfirm({
|
|
2095
|
-
kind: "worktree-cutout",
|
|
2096
|
-
branch: facts.currentBranch,
|
|
2097
|
-
draft: firstFreeCutoutName(localBranchName(facts.currentBranch), localNames)
|
|
2098
|
-
});
|
|
2099
|
-
if (!busyRef.current) refresh();
|
|
2100
|
-
} else setConfirm(null);
|
|
2101
|
-
},
|
|
2102
|
-
title: t("worktreeToggle"),
|
|
2103
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2104
|
-
className: BranchChip_module_default.box,
|
|
2105
|
-
children: worktreeMode ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorktreeCheck, { size: 10 }) : null
|
|
2106
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2107
|
-
className: BranchChip_module_default.checkLabel,
|
|
2108
|
-
children: t("chipWorktree")
|
|
2109
|
-
})]
|
|
2110
|
-
})] })]
|
|
2694
|
+
})
|
|
2111
2695
|
}),
|
|
2112
2696
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BranchMenu, {
|
|
2113
2697
|
open: menuOpen,
|
|
@@ -2115,11 +2699,35 @@ window.__ModuleLoader__.load({
|
|
|
2115
2699
|
rows,
|
|
2116
2700
|
currentBranch: facts.currentBranch,
|
|
2117
2701
|
confirm: confirmBundle,
|
|
2118
|
-
canCreate: !
|
|
2119
|
-
canAdopt: session.blank,
|
|
2702
|
+
canCreate: !inLinkedWorktree,
|
|
2703
|
+
canAdopt: session.blank || inLinkedWorktree,
|
|
2704
|
+
canWorktree: session.blank && !inLinkedWorktree,
|
|
2705
|
+
onWorktree: (branch) => {
|
|
2706
|
+
const row = rows.find((r) => r.name === branch);
|
|
2707
|
+
setConfirm({
|
|
2708
|
+
kind: "worktree",
|
|
2709
|
+
branch,
|
|
2710
|
+
remote: row?.kind === "remote"
|
|
2711
|
+
});
|
|
2712
|
+
},
|
|
2713
|
+
onCutWorktree: (base) => {
|
|
2714
|
+
setConfirm({
|
|
2715
|
+
kind: "worktree-cutout",
|
|
2716
|
+
branch: base
|
|
2717
|
+
});
|
|
2718
|
+
},
|
|
2120
2719
|
busy,
|
|
2121
|
-
onCreate: (name) => {
|
|
2122
|
-
doCreateBranch(name);
|
|
2720
|
+
onCreate: (name, from, checkout, onSettled) => {
|
|
2721
|
+
doCreateBranch(name, from, checkout, onSettled);
|
|
2722
|
+
},
|
|
2723
|
+
onRename: (name, newName, onSettled) => {
|
|
2724
|
+
doRenameBranch(name, newName, onSettled);
|
|
2725
|
+
},
|
|
2726
|
+
onDelete: (branch) => {
|
|
2727
|
+
setConfirm({
|
|
2728
|
+
kind: "delete",
|
|
2729
|
+
branch
|
|
2730
|
+
});
|
|
2123
2731
|
},
|
|
2124
2732
|
onFetch: () => {
|
|
2125
2733
|
doFetch();
|
|
@@ -2131,19 +2739,7 @@ window.__ModuleLoader__.load({
|
|
|
2131
2739
|
updateBusy,
|
|
2132
2740
|
onSelect: (branch) => {
|
|
2133
2741
|
if (branch === facts.currentBranch) {
|
|
2134
|
-
|
|
2135
|
-
kind: "worktree-cutout",
|
|
2136
|
-
branch,
|
|
2137
|
-
draft: firstFreeCutoutName(localBranchName(branch), localNames)
|
|
2138
|
-
});
|
|
2139
|
-
else setMenuOpen(false);
|
|
2140
|
-
return;
|
|
2141
|
-
}
|
|
2142
|
-
if (inLinkedWorktree) {
|
|
2143
|
-
setToast({
|
|
2144
|
-
seq: Date.now(),
|
|
2145
|
-
text: t("mainRepoOnly")
|
|
2146
|
-
});
|
|
2742
|
+
setMenuOpen(false);
|
|
2147
2743
|
return;
|
|
2148
2744
|
}
|
|
2149
2745
|
const row = rows.find((r) => r.name === branch);
|
|
@@ -2151,12 +2747,7 @@ window.__ModuleLoader__.load({
|
|
|
2151
2747
|
doAdoptWorktree(row.path);
|
|
2152
2748
|
return;
|
|
2153
2749
|
}
|
|
2154
|
-
|
|
2155
|
-
setConfirm({
|
|
2156
|
-
kind: worktreeMode ? "worktree" : "switch",
|
|
2157
|
-
branch,
|
|
2158
|
-
remote
|
|
2159
|
-
});
|
|
2750
|
+
doSwitch(branch, true);
|
|
2160
2751
|
},
|
|
2161
2752
|
onClose: () => {
|
|
2162
2753
|
setMenuOpen(false);
|
|
@@ -2177,18 +2768,19 @@ window.__ModuleLoader__.load({
|
|
|
2177
2768
|
...isCutout && !cutoutValid ? { draftInvalid: true } : {},
|
|
2178
2769
|
...cutoutHint === void 0 ? {} : { draftHint: cutoutHint }
|
|
2179
2770
|
}),
|
|
2180
|
-
|
|
2181
|
-
text:
|
|
2771
|
+
toasts[0] !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
|
|
2772
|
+
text: toasts[0].text,
|
|
2182
2773
|
onDone: () => {
|
|
2183
|
-
|
|
2774
|
+
setToasts((queue) => queue.slice(1));
|
|
2184
2775
|
}
|
|
2185
|
-
},
|
|
2776
|
+
}, toasts[0].seq)
|
|
2186
2777
|
] });
|
|
2187
2778
|
}
|
|
2188
2779
|
//#endregion
|
|
2189
2780
|
//#region src/client/card-form.ts
|
|
2190
|
-
/** The
|
|
2781
|
+
/** The fields this card edits. */
|
|
2191
2782
|
const ROOT_FIELD = "rootDir";
|
|
2783
|
+
const KEEP_FIELD = "keepWorktrees";
|
|
2192
2784
|
/**
|
|
2193
2785
|
* Stages the settings edit over the `git-worktree` scope.
|
|
2194
2786
|
*
|
|
@@ -2206,10 +2798,12 @@ window.__ModuleLoader__.load({
|
|
|
2206
2798
|
snapshotValue;
|
|
2207
2799
|
listeners = /* @__PURE__ */ new Set();
|
|
2208
2800
|
draft;
|
|
2801
|
+
keepDraft;
|
|
2209
2802
|
saving = false;
|
|
2210
2803
|
failed = false;
|
|
2211
2804
|
groupingPending = false;
|
|
2212
2805
|
groupingDraft;
|
|
2806
|
+
switchFailed = null;
|
|
2213
2807
|
/**
|
|
2214
2808
|
* @param scope - the bound settings scope for the `git-worktree` namespace.
|
|
2215
2809
|
* @param afterGroupSidebarWrite - awaited after the setting lands, until
|
|
@@ -2239,7 +2833,7 @@ window.__ModuleLoader__.load({
|
|
|
2239
2833
|
}
|
|
2240
2834
|
};
|
|
2241
2835
|
}
|
|
2242
|
-
/** @returns the edit, clear, save, discard, and
|
|
2836
|
+
/** @returns the edit, clear, save, discard, and switch actions bound to this form. */
|
|
2243
2837
|
actions() {
|
|
2244
2838
|
return {
|
|
2245
2839
|
editRoot: (text) => {
|
|
@@ -2254,14 +2848,53 @@ window.__ModuleLoader__.load({
|
|
|
2254
2848
|
},
|
|
2255
2849
|
save: () => this.save(),
|
|
2256
2850
|
discard: () => {
|
|
2257
|
-
if (this.draft === void 0 && !this.failed) return;
|
|
2851
|
+
if (this.draft === void 0 && this.keepDraft === void 0 && !this.failed) return;
|
|
2258
2852
|
this.draft = void 0;
|
|
2853
|
+
this.keepDraft = void 0;
|
|
2259
2854
|
this.failed = false;
|
|
2260
2855
|
this.publish();
|
|
2261
2856
|
},
|
|
2262
|
-
setGroupSidebar: (value) => this.setGroupSidebar(value)
|
|
2857
|
+
setGroupSidebar: (value) => this.setGroupSidebar(value),
|
|
2858
|
+
setFetchBeforeCreate: (value) => this.setSimpleFlag("fetchBeforeCreate", value),
|
|
2859
|
+
setAutoPruneWorktrees: (value) => this.setSimpleFlag("autoPruneWorktrees", value),
|
|
2860
|
+
editKeepWorktrees: (text) => {
|
|
2861
|
+
this.keepDraft = text;
|
|
2862
|
+
this.failed = false;
|
|
2863
|
+
this.publish();
|
|
2864
|
+
}
|
|
2263
2865
|
};
|
|
2264
2866
|
}
|
|
2867
|
+
/** Strict integer parse for the staged keep cap; anything else is unusable. */
|
|
2868
|
+
parseKeep(text) {
|
|
2869
|
+
if (!/^-?\d+$/.test(text.trim())) return void 0;
|
|
2870
|
+
return Number(text.trim());
|
|
2871
|
+
}
|
|
2872
|
+
/** The keep cap as the user sees it: the live draft, else the stored value
|
|
2873
|
+
* over the shipped default. */
|
|
2874
|
+
effectiveKeepText() {
|
|
2875
|
+
const value = this.scope.getSnapshot().value?.[KEEP_FIELD];
|
|
2876
|
+
return this.keepDraft ?? String(value ?? 30);
|
|
2877
|
+
}
|
|
2878
|
+
/**
|
|
2879
|
+
* Flip a write-through switch with no seat swap to wait for (unlike the
|
|
2880
|
+
* grouping switch): optimistic publish, persist, done.
|
|
2881
|
+
*
|
|
2882
|
+
* A rejected write is CAUGHT, not propagated: the card invokes these from
|
|
2883
|
+
* a checkbox `onChange` that discards the promise, so an escaping
|
|
2884
|
+
* rejection would be an unhandled one AND would leave the control
|
|
2885
|
+
* snapping back with no explanation. The failure is recorded instead and
|
|
2886
|
+
* the card renders a retry note beside the switch.
|
|
2887
|
+
*/
|
|
2888
|
+
async setSimpleFlag(field, value) {
|
|
2889
|
+
if (value === (this.scope.getSnapshot().value?.[field] ?? false)) return;
|
|
2890
|
+
try {
|
|
2891
|
+
await this.scope.set(field, value);
|
|
2892
|
+
if (this.switchFailed === field) this.switchFailed = null;
|
|
2893
|
+
} catch (_switchWriteFailure) {
|
|
2894
|
+
this.switchFailed = field;
|
|
2895
|
+
}
|
|
2896
|
+
this.publish();
|
|
2897
|
+
}
|
|
2265
2898
|
/**
|
|
2266
2899
|
* Flip the grouping switch immediately, then persist.
|
|
2267
2900
|
*
|
|
@@ -2280,6 +2913,9 @@ window.__ModuleLoader__.load({
|
|
|
2280
2913
|
try {
|
|
2281
2914
|
await this.scope.set("groupSidebar", value);
|
|
2282
2915
|
if (this.afterGroupSidebarWrite !== void 0) await this.afterGroupSidebarWrite(value);
|
|
2916
|
+
if (this.switchFailed === "groupSidebar") this.switchFailed = null;
|
|
2917
|
+
} catch (_switchWriteFailure) {
|
|
2918
|
+
this.switchFailed = "groupSidebar";
|
|
2283
2919
|
} finally {
|
|
2284
2920
|
this.groupingPending = false;
|
|
2285
2921
|
this.groupingDraft = void 0;
|
|
@@ -2291,28 +2927,38 @@ window.__ModuleLoader__.load({
|
|
|
2291
2927
|
return this.groupingDraft ?? this.scope.getSnapshot().value?.groupSidebar ?? true;
|
|
2292
2928
|
}
|
|
2293
2929
|
/**
|
|
2294
|
-
* Write the staged
|
|
2930
|
+
* Write the staged edits (root text and/or keep cap), then re-seed from
|
|
2931
|
+
* what the Host accepted.
|
|
2295
2932
|
*
|
|
2296
|
-
* The Host is the only authority on acceptance — an empty draft
|
|
2297
|
-
* field, anything else stores the trimmed text (so blanking the
|
|
2298
|
-
* saving is the same gesture as clearing it)
|
|
2299
|
-
*
|
|
2933
|
+
* The Host is the only authority on acceptance — an empty root draft
|
|
2934
|
+
* clears the field, anything else stores the trimmed text (so blanking the
|
|
2935
|
+
* control and saving is the same gesture as clearing it); the keep draft
|
|
2936
|
+
* must parse to an integer >= 1 before the save may run. A save that did
|
|
2937
|
+
* not land keeps its drafts so the user can correct them instead of
|
|
2938
|
+
* retyping.
|
|
2300
2939
|
*/
|
|
2301
2940
|
async save() {
|
|
2302
|
-
if (this.draft === void 0 || this.saving) return;
|
|
2303
|
-
const
|
|
2941
|
+
if (this.draft === void 0 && this.keepDraft === void 0 || this.saving) return;
|
|
2942
|
+
const intendedRoot = this.draft?.trim();
|
|
2943
|
+
const intendedKeep = this.keepDraft !== void 0 ? this.parseKeep(this.keepDraft) : void 0;
|
|
2944
|
+
if (this.keepDraft !== void 0 && (intendedKeep === void 0 || intendedKeep < 1)) return;
|
|
2304
2945
|
this.saving = true;
|
|
2305
2946
|
this.failed = false;
|
|
2306
2947
|
this.publish();
|
|
2307
2948
|
let landed = true;
|
|
2308
2949
|
try {
|
|
2309
|
-
if (
|
|
2310
|
-
else await this.scope.set(ROOT_FIELD,
|
|
2311
|
-
if (
|
|
2950
|
+
if (intendedRoot === "") await this.scope.unset(ROOT_FIELD);
|
|
2951
|
+
else if (intendedRoot !== void 0) await this.scope.set(ROOT_FIELD, intendedRoot);
|
|
2952
|
+
if (intendedKeep !== void 0) await this.scope.set(KEEP_FIELD, intendedKeep);
|
|
2953
|
+
if (intendedRoot !== void 0 && (intendedRoot === "" ? this.storedRoot() : this.storedRootValue() !== intendedRoot)) landed = false;
|
|
2954
|
+
if (intendedKeep !== void 0 && this.userLayer()?.["keepWorktrees"] !== intendedKeep) landed = false;
|
|
2312
2955
|
} catch (_settingsWriteFailure) {
|
|
2313
2956
|
landed = false;
|
|
2314
2957
|
}
|
|
2315
|
-
if (landed)
|
|
2958
|
+
if (landed) {
|
|
2959
|
+
if (intendedRoot !== void 0) this.draft = void 0;
|
|
2960
|
+
if (intendedKeep !== void 0) this.keepDraft = void 0;
|
|
2961
|
+
}
|
|
2316
2962
|
this.saving = false;
|
|
2317
2963
|
this.failed = !landed;
|
|
2318
2964
|
this.publish();
|
|
@@ -2339,16 +2985,23 @@ window.__ModuleLoader__.load({
|
|
|
2339
2985
|
project() {
|
|
2340
2986
|
const snapshot = this.scope.getSnapshot();
|
|
2341
2987
|
const draft = this.draft ?? this.effectiveRoot();
|
|
2988
|
+
const keepText = this.effectiveKeepText();
|
|
2989
|
+
const keepParsed = this.parseKeep(keepText);
|
|
2342
2990
|
return {
|
|
2343
2991
|
available: snapshot.status === "ready",
|
|
2344
2992
|
writable: snapshot.writable,
|
|
2345
2993
|
rootDir: draft,
|
|
2346
2994
|
overridden: this.draft !== void 0 ? this.draft.trim() !== "" : this.storedRoot(),
|
|
2347
|
-
dirty: this.draft !== void 0 && this.draft !== this.effectiveRoot(),
|
|
2995
|
+
dirty: this.draft !== void 0 && this.draft !== this.effectiveRoot() || this.keepDraft !== void 0 && this.keepDraft !== String(this.scope.getSnapshot().value?.["keepWorktrees"] ?? 30),
|
|
2348
2996
|
saving: this.saving,
|
|
2349
2997
|
failed: this.failed,
|
|
2350
2998
|
groupSidebar: this.effectiveGroupSidebar(),
|
|
2351
|
-
groupingPending: this.groupingPending
|
|
2999
|
+
groupingPending: this.groupingPending,
|
|
3000
|
+
fetchBeforeCreate: this.scope.getSnapshot().value?.fetchBeforeCreate ?? false,
|
|
3001
|
+
autoPruneWorktrees: this.scope.getSnapshot().value?.autoPruneWorktrees ?? false,
|
|
3002
|
+
keepWorktreesText: keepText,
|
|
3003
|
+
keepWorktreesValid: keepParsed !== void 0 && keepParsed >= 1,
|
|
3004
|
+
switchFailed: this.switchFailed
|
|
2352
3005
|
};
|
|
2353
3006
|
}
|
|
2354
3007
|
/** Replace the snapshot reference and notify, only when the fact moved. */
|
|
@@ -2359,247 +3012,61 @@ window.__ModuleLoader__.load({
|
|
|
2359
3012
|
}
|
|
2360
3013
|
publish() {
|
|
2361
3014
|
this.store(this.project());
|
|
2362
|
-
}
|
|
2363
|
-
};
|
|
2364
|
-
/** Yield until after the next paint (rAF), or a macrotask when rAF is absent (tests). */
|
|
2365
|
-
function yieldForPaint() {
|
|
2366
|
-
return new Promise((resolve) => {
|
|
2367
|
-
if (typeof requestAnimationFrame === "function") {
|
|
2368
|
-
requestAnimationFrame(() => {
|
|
2369
|
-
resolve();
|
|
2370
|
-
});
|
|
2371
|
-
return;
|
|
2372
|
-
}
|
|
2373
|
-
setTimeout(resolve, 0);
|
|
2374
|
-
});
|
|
2375
|
-
}
|
|
2376
|
-
//#endregion
|
|
2377
|
-
//#region \0git-worktree-css:D:\Code\dsh-worktree\src\client\GitWorktreeCard.module.css?inline
|
|
2378
|
-
const css$2 = "/* git-worktree settings card on the Plugins configuration tab. Visual\n * language mirrors the settings section's own card chrome (border radius,\n * layer fills, pending badge, footer buttons) so cards from different\n * packages sit in one list without reading as two designs; tokens only, no\n * literal colors. */\n\n.card_1712176718 {\n list-style: none;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: 16px;\n background: var(--dsw-alias-bg-layer-3);\n transition: border-color .16s, background .16s;\n}\n\n.card_1712176718:hover {\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n/* An open card reads as the one being worked on, not merely taller. */\n.cardOpen_1712176718 {\n background: var(--dsw-alias-bg-layer-2);\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n.header_1712176718 {\n width: 100%;\n appearance: none;\n border: 0;\n background: none;\n font: inherit;\n color: inherit;\n text-align: left;\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 14px 16px;\n border-radius: 12px;\n}\n\n.header_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: -2px;\n}\n\n/* Name over description, mirroring the section's own plugin cards: the\n * description is what tells one plugin's settings from another's. */\n.headText_1712176718 {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.name_1712176718 {\n font-size: 15px;\n font-weight: 600;\n line-height: 1.4;\n color: var(--dsw-alias-label-primary);\n}\n\n.description_1712176718 {\n font-size: 13px;\n line-height: 1.5;\n color: var(--dsw-alias-label-tertiary);\n}\n\n/* Carried on the header so a collapsed card still says it holds edits. */\n.pending_1712176718 {\n flex: none;\n border-radius: 999px;\n corner-shape: round;\n padding: 1px 8px;\n font-size: 11px;\n line-height: 17px;\n font-weight: 500;\n white-space: nowrap;\n background: var(--dsw-alias-bg-module-platform);\n color: var(--dsw-alias-label-secondary);\n}\n\n.chevron_1712176718 {\n flex: none;\n color: var(--dsw-alias-label-tertiary);\n transition: transform .16s;\n}\n\n.chevronOpen_1712176718 {\n transform: rotate(180deg);\n}\n\n.body_1712176718 {\n border-top: 0.5px solid var(--dsw-alias-border-l2);\n margin: 0 16px;\n padding: 12px 0 8px;\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.note_1712176718 {\n margin: 0;\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.field_1712176718 {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.fieldLabel_1712176718 {\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-secondary);\n}\n\n.input_1712176718 {\n box-sizing: border-box;\n width: 100%;\n padding: 4px 8px;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-primary);\n background-color: var(--dsw-alias-bg-layer-2);\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: 6px;\n appearance: none;\n}\n\n.input_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: -1px;\n}\n\n.input_1712176718:disabled {\n opacity: 0.6;\n}\n\n/* The directory control and its native-dialog launcher share one row. */\n.inputRow_1712176718 {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.inputRow_1712176718 .input_1712176718 {\n flex: 1;\n min-width: 0;\n}\n\n.browse_1712176718 {\n appearance: none;\n flex: none;\n border: 0.5px solid var(--dsw-alias-border-l3);\n border-radius: 6px;\n padding: 4px 10px;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n background: none;\n cursor: pointer;\n white-space: nowrap;\n}\n\n.browse_1712176718:hover:not(:disabled) {\n color: var(--dsw-alias-label-primary);\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n.browse_1712176718:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.browse_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: 1px;\n}\n\n.hint_1712176718 {\n margin: 0;\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.footer_1712176718 {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n padding: 8px 0 4px;\n border-top: 0.5px solid var(--dsw-alias-border-l2);\n}\n\n.failed_1712176718 {\n flex: 1;\n min-width: 0;\n margin: 0;\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-error);\n}\n\n.discard_1712176718,\n.save_1712176718 {\n appearance: none;\n border: 0.5px solid transparent;\n border-radius: 8px;\n padding: 5px 14px;\n font: inherit;\n font-size: 13px;\n line-height: 1.5;\n cursor: pointer;\n}\n\n.discard_1712176718 {\n border-color: var(--dsw-alias-border-l2);\n background: none;\n color: var(--dsw-alias-label-secondary);\n}\n\n.discard_1712176718:hover:not(:disabled) {\n color: var(--dsw-alias-label-primary);\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n.save_1712176718 {\n background: var(--dsw-alias-label-primary);\n color: var(--dsw-alias-bg-layer-3);\n}\n\n.discard_1712176718:disabled,\n.save_1712176718:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.discard_1712176718:focus-visible,\n.save_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: 1px;\n}\n\n/* Sidebar-grouping switch: title + hint + caution beside a checkbox. */\n.toggleRow_1712176718 {\n margin-top: 10px;\n flex-direction: row;\n align-items: flex-start;\n gap: 10px;\n}\n\n.toggleText_1712176718 {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.toggleLabel_1712176718 {\n color: var(--dsw-alias-label-primary);\n font-weight: 500;\n}\n\n.toggleMark_1712176718 {\n margin-left: 4px;\n font-weight: 400;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.toggleHint_1712176718 {\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n\n.toggleNote_1712176718 {\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.toggleControl_1712176718 {\n display: flex;\n align-items: center;\n gap: 6px;\n flex: none;\n margin-top: 2px;\n}\n\n.spinner_1712176718 {\n display: flex;\n color: var(--dsw-alias-label-tertiary);\n animation: spin 0.7s linear infinite;\n}\n\n@keyframes spin {\n to { transform: rotate(360deg); }\n}\n\n.toggle_1712176718 {\n width: 16px;\n height: 16px;\n accent-color: var(--dsw-alias-brand-primary);\n cursor: pointer;\n}\n\n.toggle_1712176718:disabled {\n cursor: progress;\n}\n";
|
|
2379
|
-
const tagId$2 = "@laoyuehanni/dsh-git-worktree/GitWorktreeCard.module.css";
|
|
2380
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId$2 + "\"]") === null) {
|
|
2381
|
-
const tag = document.createElement("style");
|
|
2382
|
-
tag.dataset.plugin = "@laoyuehanni/dsh-git-worktree";
|
|
2383
|
-
tag.dataset.pluginCss = tagId$2;
|
|
2384
|
-
tag.textContent = css$2;
|
|
2385
|
-
document.head.appendChild(tag);
|
|
2386
|
-
}
|
|
2387
|
-
var GitWorktreeCard_module_default = {
|
|
2388
|
-
"card": "card_1712176718",
|
|
2389
|
-
"cardOpen": "cardOpen_1712176718",
|
|
2390
|
-
"header": "header_1712176718",
|
|
2391
|
-
"headText": "headText_1712176718",
|
|
2392
|
-
"name": "name_1712176718",
|
|
2393
|
-
"description": "description_1712176718",
|
|
2394
|
-
"pending": "pending_1712176718",
|
|
2395
|
-
"chevron": "chevron_1712176718",
|
|
2396
|
-
"chevronOpen": "chevronOpen_1712176718",
|
|
2397
|
-
"body": "body_1712176718",
|
|
2398
|
-
"note": "note_1712176718",
|
|
2399
|
-
"field": "field_1712176718",
|
|
2400
|
-
"fieldLabel": "fieldLabel_1712176718",
|
|
2401
|
-
"input": "input_1712176718",
|
|
2402
|
-
"inputRow": "inputRow_1712176718",
|
|
2403
|
-
"browse": "browse_1712176718",
|
|
2404
|
-
"hint": "hint_1712176718",
|
|
2405
|
-
"footer": "footer_1712176718",
|
|
2406
|
-
"failed": "failed_1712176718",
|
|
2407
|
-
"discard": "discard_1712176718",
|
|
2408
|
-
"save": "save_1712176718",
|
|
2409
|
-
"toggleRow": "toggleRow_1712176718",
|
|
2410
|
-
"toggleText": "toggleText_1712176718",
|
|
2411
|
-
"toggleLabel": "toggleLabel_1712176718",
|
|
2412
|
-
"toggleMark": "toggleMark_1712176718",
|
|
2413
|
-
"toggleHint": "toggleHint_1712176718",
|
|
2414
|
-
"toggleNote": "toggleNote_1712176718",
|
|
2415
|
-
"toggleControl": "toggleControl_1712176718",
|
|
2416
|
-
"spinner": "spinner_1712176718",
|
|
2417
|
-
"toggle": "toggle_1712176718"
|
|
2418
|
-
};
|
|
2419
|
-
//#endregion
|
|
2420
|
-
//#region src/client/GitWorktreeCard.tsx
|
|
2421
|
-
/**
|
|
2422
|
-
* The git-worktree card on the Plugins configuration tab: a collapsible row
|
|
2423
|
-
* whose header names the plugin over a one-line description of what its
|
|
2424
|
-
* settings govern, disclosing the storage-root control when open. The card
|
|
2425
|
-
* owns everything inside it — chrome, controls, and copy — per the keyed-slot
|
|
2426
|
-
* contract; the tab only dispatches it under the `git-worktree` namespace
|
|
2427
|
-
* key.
|
|
2428
|
-
*
|
|
2429
|
-
* Renders nothing while the namespace is unavailable: a deployment that did
|
|
2430
|
-
* not compose the host half shows no trace of the card. A stored root edit
|
|
2431
|
-
* takes effect live (the Host routes read the section source per request);
|
|
2432
|
-
* no data moves — worktrees already created stay where they are, and git
|
|
2433
|
-
* itself still lists and reuses them.
|
|
2434
|
-
*
|
|
2435
|
-
* @module git-worktree/client/GitWorktreeCard
|
|
2436
|
-
*/
|
|
2437
|
-
/**
|
|
2438
|
-
* Render the git-worktree settings card.
|
|
2439
|
-
* @param props - locale copy, the card snapshot, and its form actions.
|
|
2440
|
-
* @returns the card, or nothing when the namespace is unavailable.
|
|
2441
|
-
*/
|
|
2442
|
-
function GitWorktreeCard(props) {
|
|
2443
|
-
const [open, setOpen] = (0, react.useState)(false);
|
|
2444
|
-
const [picking, setPicking] = (0, react.useState)(false);
|
|
2445
|
-
const { t } = props;
|
|
2446
|
-
const state = props.useGitWorktreeCard((snapshot) => snapshot);
|
|
2447
|
-
if (!state.available) return null;
|
|
2448
|
-
const lockInput = !state.writable;
|
|
2449
|
-
const lockActions = !state.dirty || state.saving;
|
|
2450
|
-
/**
|
|
2451
|
-
* Open the shell's native folder dialog and stage the chosen path — the
|
|
2452
|
-
* same picker the workspace flows use, driven through the injected
|
|
2453
|
-
* workspace service. A dismissal leaves the staged draft exactly as it
|
|
2454
|
-
* was; the text input stays the fallback either way.
|
|
2455
|
-
*/
|
|
2456
|
-
const browse = async () => {
|
|
2457
|
-
if (picking || lockInput) return;
|
|
2458
|
-
setPicking(true);
|
|
2459
|
-
try {
|
|
2460
|
-
const picked = await props.pickDirectory();
|
|
2461
|
-
if (picked !== null && picked !== "") props.editRoot(picked);
|
|
2462
|
-
} catch (_pickFailure) {} finally {
|
|
2463
|
-
setPicking(false);
|
|
2464
|
-
}
|
|
2465
|
-
};
|
|
2466
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
2467
|
-
className: open ? `${GitWorktreeCard_module_default.card} ${GitWorktreeCard_module_default.cardOpen}` : GitWorktreeCard_module_default.card,
|
|
2468
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2469
|
-
type: "button",
|
|
2470
|
-
className: GitWorktreeCard_module_default.header,
|
|
2471
|
-
"aria-expanded": open,
|
|
2472
|
-
"aria-label": `${t(open ? "cardCollapse" : "cardExpand")}: ${t("cardTitle")}`,
|
|
2473
|
-
onClick: () => {
|
|
2474
|
-
setOpen(!open);
|
|
2475
|
-
},
|
|
2476
|
-
children: [
|
|
2477
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2478
|
-
className: GitWorktreeCard_module_default.headText,
|
|
2479
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2480
|
-
className: GitWorktreeCard_module_default.name,
|
|
2481
|
-
children: t("cardTitle")
|
|
2482
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2483
|
-
className: GitWorktreeCard_module_default.description,
|
|
2484
|
-
children: t("cardDescription")
|
|
2485
|
-
})]
|
|
2486
|
-
}),
|
|
2487
|
-
state.dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2488
|
-
className: GitWorktreeCard_module_default.pending,
|
|
2489
|
-
children: t("cardUnsaved")
|
|
2490
|
-
}) : null,
|
|
2491
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutline14, { className: open ? `${GitWorktreeCard_module_default.chevron} ${GitWorktreeCard_module_default.chevronOpen}` : GitWorktreeCard_module_default.chevron })
|
|
2492
|
-
]
|
|
2493
|
-
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2494
|
-
className: GitWorktreeCard_module_default.body,
|
|
2495
|
-
children: [
|
|
2496
|
-
!state.writable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2497
|
-
className: GitWorktreeCard_module_default.note,
|
|
2498
|
-
role: "status",
|
|
2499
|
-
children: t("cardReadOnly")
|
|
2500
|
-
}) : null,
|
|
2501
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2502
|
-
className: GitWorktreeCard_module_default.field,
|
|
2503
|
-
htmlFor: "git-worktree-card-root-dir",
|
|
2504
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2505
|
-
className: GitWorktreeCard_module_default.fieldLabel,
|
|
2506
|
-
children: t("cardRootDirLabel")
|
|
2507
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2508
|
-
className: GitWorktreeCard_module_default.inputRow,
|
|
2509
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2510
|
-
id: "git-worktree-card-root-dir",
|
|
2511
|
-
className: GitWorktreeCard_module_default.input,
|
|
2512
|
-
type: "text",
|
|
2513
|
-
spellCheck: false,
|
|
2514
|
-
value: state.rootDir,
|
|
2515
|
-
disabled: lockInput,
|
|
2516
|
-
onChange: (event) => {
|
|
2517
|
-
props.editRoot(event.target.value);
|
|
2518
|
-
}
|
|
2519
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2520
|
-
type: "button",
|
|
2521
|
-
className: GitWorktreeCard_module_default.browse,
|
|
2522
|
-
disabled: lockInput || picking,
|
|
2523
|
-
onClick: () => {
|
|
2524
|
-
browse();
|
|
2525
|
-
},
|
|
2526
|
-
children: t(picking ? "cardPicking" : "cardBrowse")
|
|
2527
|
-
})]
|
|
2528
|
-
})]
|
|
2529
|
-
}),
|
|
2530
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
2531
|
-
className: GitWorktreeCard_module_default.hint,
|
|
2532
|
-
children: [t("cardRootDirHint"), state.overridden ? ` ${t("cardOverridden")}` : ""]
|
|
2533
|
-
}),
|
|
2534
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2535
|
-
className: `${GitWorktreeCard_module_default.field} ${GitWorktreeCard_module_default.toggleRow}`,
|
|
2536
|
-
"aria-busy": state.groupingPending,
|
|
2537
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2538
|
-
className: GitWorktreeCard_module_default.toggleText,
|
|
2539
|
-
children: [
|
|
2540
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2541
|
-
className: GitWorktreeCard_module_default.toggleLabel,
|
|
2542
|
-
children: [t("cardGroupSidebarLabel"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2543
|
-
className: GitWorktreeCard_module_default.toggleMark,
|
|
2544
|
-
children: t("cardGroupSidebarMark")
|
|
2545
|
-
})]
|
|
2546
|
-
}),
|
|
2547
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2548
|
-
className: GitWorktreeCard_module_default.toggleHint,
|
|
2549
|
-
children: t("cardGroupSidebarHint")
|
|
2550
|
-
}),
|
|
2551
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2552
|
-
className: GitWorktreeCard_module_default.toggleNote,
|
|
2553
|
-
children: t("cardGroupSidebarNote")
|
|
2554
|
-
})
|
|
2555
|
-
]
|
|
2556
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2557
|
-
className: GitWorktreeCard_module_default.toggleControl,
|
|
2558
|
-
children: [state.groupingPending ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2559
|
-
className: GitWorktreeCard_module_default.spinner,
|
|
2560
|
-
role: "status",
|
|
2561
|
-
"aria-label": t("cardGroupSidebarBusy"),
|
|
2562
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLoadingOutline16, { size: 14 })
|
|
2563
|
-
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2564
|
-
className: GitWorktreeCard_module_default.toggle,
|
|
2565
|
-
type: "checkbox",
|
|
2566
|
-
disabled: lockInput || state.groupingPending,
|
|
2567
|
-
checked: state.groupSidebar,
|
|
2568
|
-
onChange: (event) => {
|
|
2569
|
-
props.setGroupSidebar(event.target.checked);
|
|
2570
|
-
}
|
|
2571
|
-
})]
|
|
2572
|
-
})]
|
|
2573
|
-
}),
|
|
2574
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2575
|
-
className: GitWorktreeCard_module_default.footer,
|
|
2576
|
-
children: [
|
|
2577
|
-
state.failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2578
|
-
className: GitWorktreeCard_module_default.failed,
|
|
2579
|
-
role: "status",
|
|
2580
|
-
children: t("cardSaveFailed")
|
|
2581
|
-
}) : null,
|
|
2582
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2583
|
-
type: "button",
|
|
2584
|
-
className: GitWorktreeCard_module_default.discard,
|
|
2585
|
-
disabled: lockActions,
|
|
2586
|
-
onClick: props.discard,
|
|
2587
|
-
children: t("cardDiscard")
|
|
2588
|
-
}),
|
|
2589
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2590
|
-
type: "button",
|
|
2591
|
-
className: GitWorktreeCard_module_default.save,
|
|
2592
|
-
disabled: lockActions,
|
|
2593
|
-
onClick: props.save,
|
|
2594
|
-
children: t(state.saving ? "cardSaving" : "cardSave")
|
|
2595
|
-
})
|
|
2596
|
-
]
|
|
2597
|
-
})
|
|
2598
|
-
]
|
|
2599
|
-
}) : null]
|
|
3015
|
+
}
|
|
3016
|
+
};
|
|
3017
|
+
/** Yield until after the next paint (rAF), or a macrotask when rAF is absent (tests). */
|
|
3018
|
+
function yieldForPaint() {
|
|
3019
|
+
return new Promise((resolve) => {
|
|
3020
|
+
if (typeof requestAnimationFrame === "function") {
|
|
3021
|
+
requestAnimationFrame(() => {
|
|
3022
|
+
resolve();
|
|
3023
|
+
});
|
|
3024
|
+
return;
|
|
3025
|
+
}
|
|
3026
|
+
setTimeout(resolve, 0);
|
|
2600
3027
|
});
|
|
2601
3028
|
}
|
|
2602
3029
|
//#endregion
|
|
3030
|
+
//#region src/client/prune-history.ts
|
|
3031
|
+
const KEY = "git-worktree:prune-history";
|
|
3032
|
+
/** The log is a recent-activity trail, not an archive: the oldest runs fall
|
|
3033
|
+
* off once this many are kept. */
|
|
3034
|
+
const MAX_RUNS = 20;
|
|
3035
|
+
/** Append one finished run (newest first), trimming the tail past
|
|
3036
|
+
* {@link MAX_RUNS}. Best-effort: a storage write that throws (private mode,
|
|
3037
|
+
* quota) swallows — the toast already told the user what happened. */
|
|
3038
|
+
function recordPruneRun(entry) {
|
|
3039
|
+
try {
|
|
3040
|
+
const next = [entry, ...readPruneHistory()].slice(0, MAX_RUNS);
|
|
3041
|
+
localStorage.setItem(KEY, JSON.stringify(next));
|
|
3042
|
+
} catch {}
|
|
3043
|
+
}
|
|
3044
|
+
/** Structural check of ONE stored run. The payload is browser-local JSON an
|
|
3045
|
+
* older build (or anything else holding this key) may have written in a
|
|
3046
|
+
* different shape, and the settings card reads `run.removed.length` straight
|
|
3047
|
+
* into its render — a top-level `Array.isArray` alone would let `[1, 2]`
|
|
3048
|
+
* through and take the whole card down with a TypeError. Only the fields the
|
|
3049
|
+
* card actually touches are checked; their element shapes stay trusted (a
|
|
3050
|
+
* malformed member degrades one line, not the page). */
|
|
3051
|
+
function isPruneRunEntry(value) {
|
|
3052
|
+
if (typeof value !== "object" || value === null) return false;
|
|
3053
|
+
const entry = value;
|
|
3054
|
+
return typeof entry.at === "number" && Array.isArray(entry.removed) && Array.isArray(entry.skippedDirty) && Array.isArray(entry.failed);
|
|
3055
|
+
}
|
|
3056
|
+
/** The recorded runs, newest first; an unreadable/foreign payload reads as
|
|
3057
|
+
* "no history" rather than throwing into the settings render — entry by
|
|
3058
|
+
* entry, so one bad record costs its own line and nothing else. */
|
|
3059
|
+
function readPruneHistory() {
|
|
3060
|
+
try {
|
|
3061
|
+
const raw = localStorage.getItem(KEY);
|
|
3062
|
+
if (raw === null) return [];
|
|
3063
|
+
const parsed = JSON.parse(raw);
|
|
3064
|
+
return Array.isArray(parsed) ? parsed.filter(isPruneRunEntry) : [];
|
|
3065
|
+
} catch {
|
|
3066
|
+
return [];
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
//#endregion
|
|
2603
3070
|
//#region src/client/sidebar-groups.ts
|
|
2604
3071
|
/**
|
|
2605
3072
|
* Derive the sidebar groups.
|
|
@@ -3217,6 +3684,991 @@ window.__ModuleLoader__.load({
|
|
|
3217
3684
|
};
|
|
3218
3685
|
}
|
|
3219
3686
|
//#endregion
|
|
3687
|
+
//#region src/client/concurrency.ts
|
|
3688
|
+
/**
|
|
3689
|
+
* Bounded-concurrency map for the browser half's fan-out calls.
|
|
3690
|
+
*
|
|
3691
|
+
* Every plugin route that answers a batch is a git process per item on the
|
|
3692
|
+
* host side, and on Windows a process spawn is the expensive part — the
|
|
3693
|
+
* `/group` route already caps its own fan-out for exactly this reason. The
|
|
3694
|
+
* browser side has the same duty for the calls it makes ONE PER ITEM
|
|
3695
|
+
* (the manager dialog inspects every scanned worktree): a bare
|
|
3696
|
+
* `Promise.all(items.map(...))` hands the host as many concurrent spawns as
|
|
3697
|
+
* the user happens to have directories.
|
|
3698
|
+
*
|
|
3699
|
+
* @module git-worktree/client/concurrency
|
|
3700
|
+
*/
|
|
3701
|
+
/**
|
|
3702
|
+
* Map over `items` with at most `limit` calls in flight, preserving INPUT
|
|
3703
|
+
* ORDER in the result (the caller zips results back onto its rows, so
|
|
3704
|
+
* completion order must not leak). Rejections propagate like `Promise.all`:
|
|
3705
|
+
* callers that want per-item tolerance catch inside `fn`.
|
|
3706
|
+
*
|
|
3707
|
+
* @param items - the inputs, mapped in order.
|
|
3708
|
+
* @param limit - maximum concurrent calls; values under 1 are clamped to 1.
|
|
3709
|
+
* @param fn - the per-item async work, given the item and its index.
|
|
3710
|
+
* @returns the results, index-aligned with `items`.
|
|
3711
|
+
*/
|
|
3712
|
+
async function mapLimit(items, limit, fn) {
|
|
3713
|
+
const queue = items.map((item, index) => [item, index]);
|
|
3714
|
+
const results = [];
|
|
3715
|
+
const width = Math.max(1, Math.floor(limit));
|
|
3716
|
+
let cursor = 0;
|
|
3717
|
+
const worker = async () => {
|
|
3718
|
+
for (;;) {
|
|
3719
|
+
const entry = queue[cursor];
|
|
3720
|
+
cursor += 1;
|
|
3721
|
+
if (entry === void 0) return;
|
|
3722
|
+
const [item, index] = entry;
|
|
3723
|
+
results[index] = await fn(item, index);
|
|
3724
|
+
}
|
|
3725
|
+
};
|
|
3726
|
+
await Promise.all(Array.from({ length: Math.min(width, queue.length) }, worker));
|
|
3727
|
+
return results;
|
|
3728
|
+
}
|
|
3729
|
+
//#endregion
|
|
3730
|
+
//#region src/client/scan-groups.ts
|
|
3731
|
+
/** Group the scan for display: repositories alphabetical, rows within a
|
|
3732
|
+
* group by branch name, both numeric-aware so `feat/v2` sorts past
|
|
3733
|
+
* `feat/v10`. Grouping is display-order only — the removal flows address
|
|
3734
|
+
* rows by path. */
|
|
3735
|
+
function groupScanEntries(entries) {
|
|
3736
|
+
const byRepo = /* @__PURE__ */ new Map();
|
|
3737
|
+
const orphans = [];
|
|
3738
|
+
for (const entry of entries) {
|
|
3739
|
+
if (entry.repoName === null) {
|
|
3740
|
+
orphans.push(entry);
|
|
3741
|
+
continue;
|
|
3742
|
+
}
|
|
3743
|
+
const list = byRepo.get(entry.repoName);
|
|
3744
|
+
if (list === void 0) byRepo.set(entry.repoName, [entry]);
|
|
3745
|
+
else list.push(entry);
|
|
3746
|
+
}
|
|
3747
|
+
const cmp = (a, b) => a.localeCompare(b, void 0, { numeric: true });
|
|
3748
|
+
const groups = [...byRepo.entries()].sort((a, b) => cmp(a[0], b[0])).map(([repoName, groupEntries]) => ({
|
|
3749
|
+
repoName,
|
|
3750
|
+
entries: groupEntries.slice().sort((a, b) => cmp(a.branch ?? "", b.branch ?? ""))
|
|
3751
|
+
}));
|
|
3752
|
+
return orphans.length > 0 ? [...groups, {
|
|
3753
|
+
repoName: null,
|
|
3754
|
+
entries: orphans
|
|
3755
|
+
}] : groups;
|
|
3756
|
+
}
|
|
3757
|
+
//#endregion
|
|
3758
|
+
//#region src/client/worktree-remove-flow.ts
|
|
3759
|
+
/**
|
|
3760
|
+
* Remove one worktree completely. A refused git removal rethrows UNLESS the
|
|
3761
|
+
* directory is actually gone (the Windows half-removal shape: git already
|
|
3762
|
+
* unregistered and emptied the tree, then failed the final rmdir — the git
|
|
3763
|
+
* half is done, so the flow continues with the DSH half). Session archives
|
|
3764
|
+
* never abort the flow (a rejected archive is logged and skipped); a failed
|
|
3765
|
+
* workspace unregistration DOES reject — the caller's UI owns the retry.
|
|
3766
|
+
*/
|
|
3767
|
+
async function removeWorktreeFully(deps, target) {
|
|
3768
|
+
try {
|
|
3769
|
+
await deps.removeWorktree(target.path, target.force);
|
|
3770
|
+
} catch (reason) {
|
|
3771
|
+
if ((await deps.probeDirectories([target.path]).catch(() => void 0))?.exists[target.path] !== false) throw reason;
|
|
3772
|
+
}
|
|
3773
|
+
for (const sessionId of target.archiveSessionIds ?? []) await deps.archiveSession(sessionId).catch((reason) => {
|
|
3774
|
+
console.warn("session archive rejected during worktree removal:", reason);
|
|
3775
|
+
});
|
|
3776
|
+
if (target.workspaceId !== void 0) await deps.deleteWorkspace(target.workspaceId);
|
|
3777
|
+
}
|
|
3778
|
+
//#endregion
|
|
3779
|
+
//#region src/client/worktree-prune.ts
|
|
3780
|
+
/** Canonical-ish key for cross-source path comparison: both sides come from
|
|
3781
|
+
* the same host, but the scan assembles `<rootDir>/<child>` while the
|
|
3782
|
+
* workspace model stores its own canonical spelling — separators are the
|
|
3783
|
+
* only drift worth papering over. */
|
|
3784
|
+
function pathKey(path) {
|
|
3785
|
+
return path.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
3786
|
+
}
|
|
3787
|
+
/** Freshest `updatedAt` across QUALIFYING sessions (non-blank, non-subagent
|
|
3788
|
+
* — the same qualification the archive set uses); 0 when nothing qualifies,
|
|
3789
|
+
* which reads as "least active in the room". Shared by the lazy prune's
|
|
3790
|
+
* plan input and the manager dialog's last-use column so the two activity
|
|
3791
|
+
* figures can never drift apart. */
|
|
3792
|
+
function freshestUpdatedAt(summaries) {
|
|
3793
|
+
let latest = 0;
|
|
3794
|
+
for (const summary of summaries) {
|
|
3795
|
+
if (summary === void 0 || summary.blank || summary.origin === "subagent") continue;
|
|
3796
|
+
if (summary.updatedAt > latest) latest = summary.updatedAt;
|
|
3797
|
+
}
|
|
3798
|
+
return latest;
|
|
3799
|
+
}
|
|
3800
|
+
/**
|
|
3801
|
+
* Which worktrees the lazy prune removes, least-recently-active first.
|
|
3802
|
+
* The cap counts every valid worktree INCLUDING the excluded ones (the
|
|
3803
|
+
* fresh creation counts against the cap it may have just overfilled), but
|
|
3804
|
+
* excluded directories are never candidates: the plan deletes the
|
|
3805
|
+
* overflow's worth of the least-active non-excluded paths, so a cap
|
|
3806
|
+
* tighter than the exclusion set simply deletes nothing this round.
|
|
3807
|
+
* Ties (two never-used directories) break alphabetically for a stable,
|
|
3808
|
+
* testable order.
|
|
3809
|
+
*/
|
|
3810
|
+
function planPrune(input) {
|
|
3811
|
+
const keep = Math.max(1, Math.floor(input.keep));
|
|
3812
|
+
const overflow = Math.max(0, input.paths.length - keep);
|
|
3813
|
+
if (overflow === 0) return [];
|
|
3814
|
+
const excluded = new Set([...input.exclude].map(pathKey));
|
|
3815
|
+
return input.paths.filter((path) => !excluded.has(pathKey(path))).slice().sort((a, b) => (input.activity[pathKey(a)] ?? 0) - (input.activity[pathKey(b)] ?? 0) || pathKey(a).localeCompare(pathKey(b))).slice(0, overflow);
|
|
3816
|
+
}
|
|
3817
|
+
/**
|
|
3818
|
+
* Walk the plan sequentially: a candidate with uncommitted changes is
|
|
3819
|
+
* SKIPPED, never forced (the manager dialog is where those get a human
|
|
3820
|
+
* decision); a removal that throws is recorded and the walk continues, so
|
|
3821
|
+
* one locked directory cannot strand the rest. Every removal rides the
|
|
3822
|
+
* shared flow with `force: false`, always.
|
|
3823
|
+
*/
|
|
3824
|
+
async function runAutoPrune(deps, targets) {
|
|
3825
|
+
const report = {
|
|
3826
|
+
removed: [],
|
|
3827
|
+
skippedDirty: [],
|
|
3828
|
+
failed: []
|
|
3829
|
+
};
|
|
3830
|
+
for (const target of targets) try {
|
|
3831
|
+
if ((await deps.inspectWorktree(target.path)).dirty > 0) {
|
|
3832
|
+
report.skippedDirty.push(target.path);
|
|
3833
|
+
continue;
|
|
3834
|
+
}
|
|
3835
|
+
await removeWorktreeFully(deps, {
|
|
3836
|
+
...target,
|
|
3837
|
+
force: false
|
|
3838
|
+
});
|
|
3839
|
+
report.removed.push(target.path);
|
|
3840
|
+
} catch (reason) {
|
|
3841
|
+
report.failed.push({
|
|
3842
|
+
path: target.path,
|
|
3843
|
+
message: reason instanceof Error ? reason.message : String(reason)
|
|
3844
|
+
});
|
|
3845
|
+
}
|
|
3846
|
+
return report;
|
|
3847
|
+
}
|
|
3848
|
+
//#endregion
|
|
3849
|
+
//#region \0git-worktree-css:D:\Code\dsh-worktree\src\client\WorktreeManagerModal.module.css?inline
|
|
3850
|
+
const css$3 = "/* The worktree manager dialog opened from the git-worktree settings card.\n * Tokens only, mirroring the card chrome and the sidebar's removal dialog\n * (a list body, a warn tint on dirty facts, the delete-tinted confirm). */\n\n/* The dialog CARD is widened here — the primitive pins its own .dialog_1867324016 to\n * min(380px, 100%), and the width lives on the card, not the content region\n * (this class rides Modal's className prop, which lands on the card; the\n * doubled class out-specifies the primitive regardless of bundle order). */\n.dialog_1867324016.dialog_1867324016 {\n width: min(680px, 100%);\n}\n\n.body_1867324016 {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.count_1867324016 {\n font-size: 12px;\n color: var(--dsw-alias-label-secondary);\n}\n\n.status_1867324016 {\n font-size: 13px;\n color: var(--dsw-alias-label-secondary);\n padding: 8px 0;\n}\n\n.error_1867324016 {\n font-size: 13px;\n color: var(--dsw-alias-label-danger, #d64545);\n white-space: pre-wrap;\n word-break: break-all;\n}\n\n.empty_1867324016 {\n font-size: 13px;\n color: var(--dsw-alias-label-dimmed);\n padding: 12px 0;\n}\n\n/* The scan-cap notice. Not .error_1867324016: the list below it is real and usable,\n * the sentence only says it is a first slice — and unlike .error_1867324016 it carries\n * prose, so no break-all. */\n.warn_1867324016 {\n font-size: 12px;\n color: var(--dsw-alias-label-warning, #b07000);\n}\n\n/* The scroll region: worktree counts grow without bound, the dialog must\n * not (BranchMenu's cap posture, dialog-scaled). No frame of its own —\n * each repository group is a card below, and a border around cards would\n * read as one flat list again. */\n.list_1867324016 {\n display: flex;\n flex-direction: column;\n gap: 10px;\n max-height: min(420px, 50vh);\n overflow-y: auto;\n padding: 1px;\n}\n\n/* One repository = one card: the outline plus the tinted header bar make\n * the group read as a container that OWNS its rows, not as one more row\n * in a flat list (the previous bare-text header sat at nearly the same\n * size and weight as the branch rows, and the belonging was invisible). */\n.group_1867324016 {\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: 10px;\n /* Clip the header background to the card's rounded corners. */\n overflow: hidden;\n}\n\n/* The per-repository header bar (and the trailing unrecognized-directory\n * group): the tinted fill separates projects at a glance, the folder icon\n * names what the header IS (a project, not a branch), and the trailing\n * count answers \"how many of my worktrees live here\" without counting. */\n.groupHead_1867324016 {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 7px 10px;\n background: var(--dsw-alias-bg-layer-2, rgba(127, 127, 127, 0.12));\n font-size: 12px;\n font-weight: 600;\n color: var(--dsw-alias-label-primary);\n}\n\n.groupIcon_1867324016 {\n display: inline-flex;\n flex-shrink: 0;\n color: var(--dsw-alias-label-secondary);\n}\n\n.groupName_1867324016 {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.groupCount_1867324016 {\n margin-left: auto;\n flex-shrink: 0;\n font-size: 11px;\n font-weight: 400;\n color: var(--dsw-alias-label-secondary);\n}\n\n.row_1867324016 {\n display: flex;\n align-items: center;\n gap: 10px;\n /* The 29px left step = the header's 10px pad + 13px icon + 6px gap:\n * row content starts level with the header TEXT, so every row visibly\n * sits INSIDE its project instead of beside it. */\n padding: 8px 10px 8px 29px;\n border-bottom: 0.5px solid var(--dsw-alias-border-l4);\n}\n\n.row_1867324016:last-child {\n border-bottom: 0;\n}\n\n.rowMain_1867324016 {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n/* Head line: branch, dirty mark, then the activity time pushed to the\n * row's right edge (the repository lives in the card's header bar). */\n.rowHead_1867324016 {\n display: flex;\n align-items: baseline;\n gap: 8px;\n min-width: 0;\n}\n\n.rowBranch_1867324016 {\n font-size: 13px;\n font-weight: 500;\n color: inherit;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.rowDirty_1867324016 {\n font-size: 11px;\n color: var(--dsw-alias-label-danger, #d64545);\n flex-shrink: 0;\n}\n\n.rowActivity_1867324016 {\n margin-left: auto;\n flex-shrink: 0;\n font-size: 11px;\n color: var(--dsw-alias-label-secondary);\n}\n\n/* The tail of the path is the identity (the <repo>-<branch> folder name), so\n * the ellipsis trims the head. */\n.rowPath_1867324016 {\n font-size: 11px;\n color: var(--dsw-alias-label-secondary);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n direction: rtl;\n text-align: left;\n}\n\n.remove_1867324016 {\n appearance: none;\n flex-shrink: 0;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: 8px;\n background: none;\n font: inherit;\n font-size: 12px;\n color: var(--dsw-alias-label-danger, #d64545);\n padding: 5px 10px;\n cursor: pointer;\n}\n\n.remove_1867324016:hover:not(:disabled) {\n border-color: var(--dsw-alias-label-danger, #d64545);\n}\n\n.remove_1867324016:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: -2px;\n}\n\n.remove_1867324016:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n\n.removeConfirm_1867324016 {\n color: var(--dsw-alias-label-danger, #d64545);\n}\n\n.removeFacts_1867324016 {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.removeFact_1867324016 {\n font-size: 13px;\n color: var(--dsw-alias-label-secondary);\n}\n\n.removeFactWarn_1867324016 {\n color: var(--dsw-alias-label-danger, #d64545);\n}\n";
|
|
3851
|
+
const tagId$3 = "@laoyuehanni/dsh-git-worktree/WorktreeManagerModal.module.css";
|
|
3852
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId$3 + "\"]") === null) {
|
|
3853
|
+
const tag = document.createElement("style");
|
|
3854
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-git-worktree";
|
|
3855
|
+
tag.dataset.pluginCss = tagId$3;
|
|
3856
|
+
tag.textContent = css$3;
|
|
3857
|
+
document.head.appendChild(tag);
|
|
3858
|
+
}
|
|
3859
|
+
var WorktreeManagerModal_module_default = {
|
|
3860
|
+
"dialog": "dialog_1867324016",
|
|
3861
|
+
"body": "body_1867324016",
|
|
3862
|
+
"count": "count_1867324016",
|
|
3863
|
+
"status": "status_1867324016",
|
|
3864
|
+
"error": "error_1867324016",
|
|
3865
|
+
"empty": "empty_1867324016",
|
|
3866
|
+
"warn": "warn_1867324016",
|
|
3867
|
+
"list": "list_1867324016",
|
|
3868
|
+
"group": "group_1867324016",
|
|
3869
|
+
"groupHead": "groupHead_1867324016",
|
|
3870
|
+
"groupIcon": "groupIcon_1867324016",
|
|
3871
|
+
"groupName": "groupName_1867324016",
|
|
3872
|
+
"groupCount": "groupCount_1867324016",
|
|
3873
|
+
"row": "row_1867324016",
|
|
3874
|
+
"rowMain": "rowMain_1867324016",
|
|
3875
|
+
"rowHead": "rowHead_1867324016",
|
|
3876
|
+
"rowBranch": "rowBranch_1867324016",
|
|
3877
|
+
"rowDirty": "rowDirty_1867324016",
|
|
3878
|
+
"rowActivity": "rowActivity_1867324016",
|
|
3879
|
+
"rowPath": "rowPath_1867324016",
|
|
3880
|
+
"remove": "remove_1867324016",
|
|
3881
|
+
"removeConfirm": "removeConfirm_1867324016",
|
|
3882
|
+
"removeFacts": "removeFacts_1867324016",
|
|
3883
|
+
"removeFact": "removeFact_1867324016",
|
|
3884
|
+
"removeFactWarn": "removeFactWarn_1867324016"
|
|
3885
|
+
};
|
|
3886
|
+
//#endregion
|
|
3887
|
+
//#region src/client/WorktreeManagerModal.tsx
|
|
3888
|
+
/**
|
|
3889
|
+
* WorktreeManagerModal: the settings card's second-level dialog listing EVERY
|
|
3890
|
+
* direct child of the worktree storage root — across repositories, orphan
|
|
3891
|
+
* directories included. Belonging is structural: each repository renders as
|
|
3892
|
+
* a card whose tinted header bar carries the folder icon, the repo name and
|
|
3893
|
+
* its worktree count, and every row steps in under that header — the
|
|
3894
|
+
* project→worktree ownership is readable from the layout alone. A row
|
|
3895
|
+
* spells the checked-out branch and the last-use time (the freshest
|
|
3896
|
+
* qualifying session's updatedAt, the same activity the lazy prune orders
|
|
3897
|
+
* by); the delete button rides the shared removal flow, so a removal here
|
|
3898
|
+
* is behaviorally the sidebar's removal: confirm with dirty/ahead facts,
|
|
3899
|
+
* git first, archives and unregistration after. Unrecognized directories
|
|
3900
|
+
* (probe finds no git repository) render read-only — deleting someone
|
|
3901
|
+
* else's folder is outside "worktree management" — and directories with a
|
|
3902
|
+
* running session withhold their delete button.
|
|
3903
|
+
*
|
|
3904
|
+
* @module git-worktree/client/WorktreeManagerModal
|
|
3905
|
+
*/
|
|
3906
|
+
/** Concurrent inspects while the dialog loads. One inspect is one git
|
|
3907
|
+
* process on the host, so this is the browser-side twin of the /group
|
|
3908
|
+
* route's batch cap. */
|
|
3909
|
+
const INSPECT_CONCURRENCY = 8;
|
|
3910
|
+
/**
|
|
3911
|
+
* The sessions of `workspace.sessionIds` the removal flow will archive:
|
|
3912
|
+
* everything visible — not archived, not blank, not a subagent row (the
|
|
3913
|
+
* same qualification every removal entry shares).
|
|
3914
|
+
*/
|
|
3915
|
+
function archiveIdsFor(face, sessionIds) {
|
|
3916
|
+
const archived = new Set(face.archivedSessionIds());
|
|
3917
|
+
const ids = [];
|
|
3918
|
+
for (const sessionId of sessionIds) {
|
|
3919
|
+
const summary = face.sessionById(sessionId);
|
|
3920
|
+
if (summary === void 0) continue;
|
|
3921
|
+
if (summary.blank || summary.origin === "subagent") continue;
|
|
3922
|
+
if (!archived.has(sessionId)) ids.push(sessionId);
|
|
3923
|
+
}
|
|
3924
|
+
return ids;
|
|
3925
|
+
}
|
|
3926
|
+
function WorktreeManagerModal({ open, onClose, face, t }) {
|
|
3927
|
+
const [scan, setScan] = (0, react.useState)({ status: "loading" });
|
|
3928
|
+
const [inspects, setInspects] = (0, react.useState)({});
|
|
3929
|
+
/** Paths known to hold a running session — their delete buttons withhold. */
|
|
3930
|
+
const [runningPaths, setRunningPaths] = (0, react.useState)(/* @__PURE__ */ new Set());
|
|
3931
|
+
const [removeTarget, setRemoveTarget] = (0, react.useState)(null);
|
|
3932
|
+
const [removing, setRemoving] = (0, react.useState)(false);
|
|
3933
|
+
const [removeError, setRemoveError] = (0, react.useState)(null);
|
|
3934
|
+
/** The "last used" column's reference point. Re-read on every OPEN: this
|
|
3935
|
+
* component is mounted for as long as the settings card is expanded (the
|
|
3936
|
+
* `open` prop only drives the Modal), so a value frozen at mount would
|
|
3937
|
+
* have the dialog quoting hour-old distances. */
|
|
3938
|
+
const [now, setNow] = (0, react.useState)(() => Date.now());
|
|
3939
|
+
/** Workspaces indexed by their normalized path. Every row's "last used"
|
|
3940
|
+
* cell needs one, and the removal flow needs two more — as linear finds
|
|
3941
|
+
* that is rows × workspaces per render, on a list whose whole point is
|
|
3942
|
+
* holding every worktree of every repository. */
|
|
3943
|
+
const workspaceAt = (0, react.useMemo)(() => {
|
|
3944
|
+
const byPath = new Map(face.workspaces().map((ws) => [pathKey(ws.path), ws]));
|
|
3945
|
+
return (path) => byPath.get(pathKey(path));
|
|
3946
|
+
}, [face]);
|
|
3947
|
+
(0, react.useEffect)(() => {
|
|
3948
|
+
if (!open) return;
|
|
3949
|
+
let live = true;
|
|
3950
|
+
setScan({ status: "loading" });
|
|
3951
|
+
setInspects({});
|
|
3952
|
+
setRemoveTarget(null);
|
|
3953
|
+
setRemoveError(null);
|
|
3954
|
+
setNow(Date.now());
|
|
3955
|
+
face.listWorktrees().then(async ({ worktrees: entries, truncated }) => {
|
|
3956
|
+
if (!live) return;
|
|
3957
|
+
setScan({
|
|
3958
|
+
status: "ready",
|
|
3959
|
+
entries,
|
|
3960
|
+
truncated: truncated === true
|
|
3961
|
+
});
|
|
3962
|
+
const valid = entries.filter((entry) => entry.repoName !== null);
|
|
3963
|
+
const workspaces = face.workspaces();
|
|
3964
|
+
const running = /* @__PURE__ */ new Set();
|
|
3965
|
+
for (const workspace of workspaces) for (const sessionId of workspace.sessionIds) if (face.sessionById(sessionId)?.running === true) running.add(pathKey(workspace.path));
|
|
3966
|
+
setRunningPaths(running);
|
|
3967
|
+
const facts = await mapLimit(valid, INSPECT_CONCURRENCY, async (entry) => {
|
|
3968
|
+
try {
|
|
3969
|
+
return [entry.path, await face.inspectWorktree(entry.path)];
|
|
3970
|
+
} catch {
|
|
3971
|
+
return [entry.path, void 0];
|
|
3972
|
+
}
|
|
3973
|
+
});
|
|
3974
|
+
if (!live) return;
|
|
3975
|
+
setInspects(Object.fromEntries(facts.filter(([, value]) => value !== void 0)));
|
|
3976
|
+
}, (reason) => {
|
|
3977
|
+
if (live) setScan({
|
|
3978
|
+
status: "error",
|
|
3979
|
+
error: reason instanceof Error ? reason.message : String(reason)
|
|
3980
|
+
});
|
|
3981
|
+
});
|
|
3982
|
+
return () => {
|
|
3983
|
+
live = false;
|
|
3984
|
+
};
|
|
3985
|
+
}, [open, face]);
|
|
3986
|
+
const closeRemove = () => {
|
|
3987
|
+
if (removing) return;
|
|
3988
|
+
setRemoveTarget(null);
|
|
3989
|
+
setRemoveError(null);
|
|
3990
|
+
};
|
|
3991
|
+
const confirmRemove = () => {
|
|
3992
|
+
if (removing || removeTarget === null) return;
|
|
3993
|
+
const target = removeTarget;
|
|
3994
|
+
setRemoving(true);
|
|
3995
|
+
setRemoveError(null);
|
|
3996
|
+
const workspace = workspaceAt(target.path);
|
|
3997
|
+
(target.kind === "orphan" ? (async () => {
|
|
3998
|
+
await face.purgeDirectory(target.path);
|
|
3999
|
+
if (workspace !== void 0) {
|
|
4000
|
+
for (const sessionId of archiveIdsFor(face, workspace.sessionIds)) await face.archiveSession(sessionId).catch((reason) => {
|
|
4001
|
+
console.warn("session archive rejected during folder purge:", reason);
|
|
4002
|
+
});
|
|
4003
|
+
await face.deleteWorkspace(workspace.workspaceId);
|
|
4004
|
+
}
|
|
4005
|
+
})() : removeWorktreeFully({
|
|
4006
|
+
removeWorktree: face.removeWorktree,
|
|
4007
|
+
probeDirectories: face.probeDirectories,
|
|
4008
|
+
archiveSession: face.archiveSession,
|
|
4009
|
+
deleteWorkspace: face.deleteWorkspace
|
|
4010
|
+
}, {
|
|
4011
|
+
path: target.path,
|
|
4012
|
+
force: (inspects[target.path]?.dirty ?? 0) > 0,
|
|
4013
|
+
...workspace === void 0 ? {} : { workspaceId: workspace.workspaceId },
|
|
4014
|
+
archiveSessionIds: workspace === void 0 ? [] : archiveIdsFor(face, workspace.sessionIds)
|
|
4015
|
+
})).then(() => {
|
|
4016
|
+
setRemoving(false);
|
|
4017
|
+
setRemoveTarget(null);
|
|
4018
|
+
face.listWorktrees().then(({ worktrees: entries, truncated }) => {
|
|
4019
|
+
setScan({
|
|
4020
|
+
status: "ready",
|
|
4021
|
+
entries,
|
|
4022
|
+
truncated: truncated === true
|
|
4023
|
+
});
|
|
4024
|
+
});
|
|
4025
|
+
}, (reason) => {
|
|
4026
|
+
setRemoving(false);
|
|
4027
|
+
setRemoveError(reason instanceof Error ? reason.message : String(reason));
|
|
4028
|
+
});
|
|
4029
|
+
};
|
|
4030
|
+
const activityOf = (path) => {
|
|
4031
|
+
const workspace = workspaceAt(path);
|
|
4032
|
+
if (workspace === void 0) return 0;
|
|
4033
|
+
return freshestUpdatedAt(workspace.sessionIds.map((id) => face.sessionById(id)));
|
|
4034
|
+
};
|
|
4035
|
+
const validCount = scan.status === "ready" ? scan.entries.filter((entry) => entry.repoName !== null).length : 0;
|
|
4036
|
+
/** Directories the scan could not read as a worktree. They sit in their
|
|
4037
|
+
* own trailing group, so the headline count must say they exist — a bare
|
|
4038
|
+
* "3 worktrees" over four groups reads as a miscount. */
|
|
4039
|
+
const orphanCount = scan.status === "ready" ? scan.entries.length - validCount : 0;
|
|
4040
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
4041
|
+
open,
|
|
4042
|
+
onClose,
|
|
4043
|
+
closeLabel: t("close"),
|
|
4044
|
+
title: t("manager.title"),
|
|
4045
|
+
className: WorktreeManagerModal_module_default.dialog ?? "",
|
|
4046
|
+
children: [
|
|
4047
|
+
scan.status === "loading" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4048
|
+
className: WorktreeManagerModal_module_default.status,
|
|
4049
|
+
role: "status",
|
|
4050
|
+
children: t("manager.loading")
|
|
4051
|
+
}),
|
|
4052
|
+
scan.status === "error" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4053
|
+
className: WorktreeManagerModal_module_default.error,
|
|
4054
|
+
role: "alert",
|
|
4055
|
+
children: t("manager.loadFailed", { message: scan.error })
|
|
4056
|
+
}),
|
|
4057
|
+
scan.status === "ready" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4058
|
+
className: WorktreeManagerModal_module_default.body,
|
|
4059
|
+
children: [
|
|
4060
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4061
|
+
className: WorktreeManagerModal_module_default.count,
|
|
4062
|
+
role: "status",
|
|
4063
|
+
children: [t("manager.count", { n: validCount }), orphanCount > 0 && t("manager.countOrphans", { n: orphanCount })]
|
|
4064
|
+
}),
|
|
4065
|
+
scan.truncated && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4066
|
+
className: WorktreeManagerModal_module_default.warn,
|
|
4067
|
+
role: "status",
|
|
4068
|
+
children: t("manager.truncated")
|
|
4069
|
+
}),
|
|
4070
|
+
scan.entries.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4071
|
+
className: WorktreeManagerModal_module_default.empty,
|
|
4072
|
+
children: t("manager.empty")
|
|
4073
|
+
}),
|
|
4074
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4075
|
+
className: WorktreeManagerModal_module_default.list,
|
|
4076
|
+
children: groupScanEntries(scan.entries).map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4077
|
+
className: WorktreeManagerModal_module_default.group,
|
|
4078
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4079
|
+
className: WorktreeManagerModal_module_default.groupHead,
|
|
4080
|
+
role: "presentation",
|
|
4081
|
+
children: [
|
|
4082
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4083
|
+
className: WorktreeManagerModal_module_default.groupIcon,
|
|
4084
|
+
"aria-hidden": "true",
|
|
4085
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderClose16, { size: 13 })
|
|
4086
|
+
}),
|
|
4087
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4088
|
+
className: WorktreeManagerModal_module_default.groupName,
|
|
4089
|
+
children: group.repoName ?? t("manager.orphans")
|
|
4090
|
+
}),
|
|
4091
|
+
group.repoName !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4092
|
+
className: WorktreeManagerModal_module_default.groupCount,
|
|
4093
|
+
children: t("manager.count", { n: group.entries.length })
|
|
4094
|
+
})
|
|
4095
|
+
]
|
|
4096
|
+
}), group.entries.map((entry) => {
|
|
4097
|
+
const unknown = entry.repoName === null;
|
|
4098
|
+
const activity = unknown ? 0 : activityOf(entry.path);
|
|
4099
|
+
const running = !unknown && runningPaths.has(pathKey(entry.path));
|
|
4100
|
+
const dirty = inspects[entry.path]?.dirty ?? 0;
|
|
4101
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4102
|
+
className: WorktreeManagerModal_module_default.row,
|
|
4103
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4104
|
+
className: WorktreeManagerModal_module_default.rowMain,
|
|
4105
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4106
|
+
className: WorktreeManagerModal_module_default.rowHead,
|
|
4107
|
+
children: [
|
|
4108
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4109
|
+
className: WorktreeManagerModal_module_default.rowBranch,
|
|
4110
|
+
children: entry.branch ?? "—"
|
|
4111
|
+
}),
|
|
4112
|
+
!unknown && dirty > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4113
|
+
className: WorktreeManagerModal_module_default.rowDirty,
|
|
4114
|
+
role: "status",
|
|
4115
|
+
children: t(dirty === 1 ? "manager.dirty.one" : "manager.dirty.other", { n: dirty })
|
|
4116
|
+
}),
|
|
4117
|
+
!unknown && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4118
|
+
className: WorktreeManagerModal_module_default.rowActivity,
|
|
4119
|
+
children: activity > 0 ? timeLabel(activity, now, t) : t("manager.activityNever")
|
|
4120
|
+
})
|
|
4121
|
+
]
|
|
4122
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4123
|
+
className: WorktreeManagerModal_module_default.rowPath,
|
|
4124
|
+
title: entry.path,
|
|
4125
|
+
children: entry.path
|
|
4126
|
+
})]
|
|
4127
|
+
}), !unknown ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4128
|
+
type: "button",
|
|
4129
|
+
className: WorktreeManagerModal_module_default.remove,
|
|
4130
|
+
disabled: running,
|
|
4131
|
+
title: running ? t("manager.running") : t("manager.removeAria", { path: entry.path }),
|
|
4132
|
+
"aria-label": t("manager.removeAria", { path: entry.path }),
|
|
4133
|
+
onClick: () => {
|
|
4134
|
+
setRemoveTarget({
|
|
4135
|
+
path: entry.path,
|
|
4136
|
+
branch: entry.branch,
|
|
4137
|
+
kind: "git"
|
|
4138
|
+
});
|
|
4139
|
+
setRemoveError(null);
|
|
4140
|
+
},
|
|
4141
|
+
children: t("worktreeRemove.menu")
|
|
4142
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4143
|
+
type: "button",
|
|
4144
|
+
className: WorktreeManagerModal_module_default.remove,
|
|
4145
|
+
disabled: running,
|
|
4146
|
+
title: running ? t("manager.running") : t("manager.purgeAria", { path: entry.path }),
|
|
4147
|
+
"aria-label": t("manager.purgeAria", { path: entry.path }),
|
|
4148
|
+
onClick: () => {
|
|
4149
|
+
setRemoveTarget({
|
|
4150
|
+
path: entry.path,
|
|
4151
|
+
branch: null,
|
|
4152
|
+
kind: "orphan"
|
|
4153
|
+
});
|
|
4154
|
+
setRemoveError(null);
|
|
4155
|
+
},
|
|
4156
|
+
children: t("manager.purgeMenu")
|
|
4157
|
+
})]
|
|
4158
|
+
}, entry.path);
|
|
4159
|
+
})]
|
|
4160
|
+
}, group.repoName ?? "<orphans>"))
|
|
4161
|
+
})
|
|
4162
|
+
]
|
|
4163
|
+
})
|
|
4164
|
+
]
|
|
4165
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
4166
|
+
open: removeTarget !== null,
|
|
4167
|
+
onClose: closeRemove,
|
|
4168
|
+
closeLabel: t("close"),
|
|
4169
|
+
title: removeTarget?.kind === "orphan" ? t("worktreePurge.title") : t("worktreeRemove.title"),
|
|
4170
|
+
...removeTarget === null ? {} : { description: t(removeTarget.kind === "orphan" ? "worktreePurge.desc" : "worktreeRemove.desc", { path: removeTarget.path }) },
|
|
4171
|
+
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, {
|
|
4172
|
+
variant: "outline",
|
|
4173
|
+
disabled: removing,
|
|
4174
|
+
onClick: closeRemove,
|
|
4175
|
+
children: t("cancel")
|
|
4176
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
4177
|
+
variant: "outline",
|
|
4178
|
+
className: WorktreeManagerModal_module_default.removeConfirm,
|
|
4179
|
+
disabled: removing,
|
|
4180
|
+
onClick: confirmRemove,
|
|
4181
|
+
children: removeTarget?.kind === "orphan" ? t("manager.purgeMenu") : t("worktreeRemove.menu")
|
|
4182
|
+
})] }),
|
|
4183
|
+
children: [
|
|
4184
|
+
removeTarget?.kind === "git" && removeTarget.branch !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4185
|
+
className: WorktreeManagerModal_module_default.removeFact,
|
|
4186
|
+
children: t("worktreeRemove.descBranch", { branch: removeTarget.branch })
|
|
4187
|
+
}),
|
|
4188
|
+
removeTarget?.kind === "git" && inspects[removeTarget.path] === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4189
|
+
className: WorktreeManagerModal_module_default.status,
|
|
4190
|
+
role: "status",
|
|
4191
|
+
children: t("worktreeRemove.inspecting")
|
|
4192
|
+
}),
|
|
4193
|
+
removeTarget?.kind === "git" && inspects[removeTarget.path] !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4194
|
+
className: WorktreeManagerModal_module_default.removeFacts,
|
|
4195
|
+
children: [
|
|
4196
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4197
|
+
className: (inspects[removeTarget.path]?.dirty ?? 0) > 0 ? `${WorktreeManagerModal_module_default.removeFact} ${WorktreeManagerModal_module_default.removeFactWarn}` : WorktreeManagerModal_module_default.removeFact,
|
|
4198
|
+
children: (inspects[removeTarget.path]?.dirty ?? 0) > 0 ? t((inspects[removeTarget.path]?.dirty ?? 0) === 1 ? "worktreeRemove.dirty.one" : "worktreeRemove.dirty.other", { n: inspects[removeTarget.path]?.dirty ?? 0 }) : t("worktreeRemove.clean")
|
|
4199
|
+
}),
|
|
4200
|
+
removeTarget !== null && inspects[removeTarget.path]?.ahead !== void 0 && (inspects[removeTarget.path]?.ahead ?? 0) > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4201
|
+
className: WorktreeManagerModal_module_default.removeFact,
|
|
4202
|
+
children: t("worktreeRemove.ahead", { n: inspects[removeTarget.path]?.ahead ?? 0 })
|
|
4203
|
+
}),
|
|
4204
|
+
removeTarget !== null && (() => {
|
|
4205
|
+
const workspace = workspaceAt(removeTarget.path);
|
|
4206
|
+
if (workspace === void 0) return null;
|
|
4207
|
+
const ids = archiveIdsFor(face, workspace.sessionIds);
|
|
4208
|
+
if (ids.length === 0) return null;
|
|
4209
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4210
|
+
className: WorktreeManagerModal_module_default.removeFact,
|
|
4211
|
+
children: t(ids.length === 1 ? "worktreeRemove.sessions.one" : "worktreeRemove.sessions.other", { n: ids.length })
|
|
4212
|
+
});
|
|
4213
|
+
})()
|
|
4214
|
+
]
|
|
4215
|
+
}),
|
|
4216
|
+
removing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4217
|
+
className: WorktreeManagerModal_module_default.status,
|
|
4218
|
+
role: "status",
|
|
4219
|
+
children: removeTarget?.kind === "orphan" ? t("worktreePurge.busy") : t("worktreeRemove.busy")
|
|
4220
|
+
}),
|
|
4221
|
+
removeError !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4222
|
+
className: WorktreeManagerModal_module_default.error,
|
|
4223
|
+
role: "alert",
|
|
4224
|
+
children: removeError
|
|
4225
|
+
})
|
|
4226
|
+
]
|
|
4227
|
+
})] });
|
|
4228
|
+
}
|
|
4229
|
+
//#endregion
|
|
4230
|
+
//#region \0git-worktree-css:D:\Code\dsh-worktree\src\client\GitWorktreeCard.module.css?inline
|
|
4231
|
+
const css$2 = "/* git-worktree settings card on the Plugins configuration tab. Visual\n * language mirrors the settings section's own card chrome (border radius,\n * layer fills, pending badge, footer buttons) so cards from different\n * packages sit in one list without reading as two designs; tokens only, no\n * literal colors. */\n\n.card_1712176718 {\n list-style: none;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: 16px;\n background: var(--dsw-alias-bg-layer-3);\n transition: border-color .16s, background .16s;\n}\n\n.card_1712176718:hover {\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n/* An open card reads as the one being worked on, not merely taller. */\n.cardOpen_1712176718 {\n background: var(--dsw-alias-bg-layer-2);\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n.header_1712176718 {\n width: 100%;\n appearance: none;\n border: 0;\n background: none;\n font: inherit;\n color: inherit;\n text-align: left;\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 14px 16px;\n border-radius: 12px;\n}\n\n.header_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: -2px;\n}\n\n/* Name over description, mirroring the section's own plugin cards: the\n * description is what tells one plugin's settings from another's. */\n.headText_1712176718 {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.name_1712176718 {\n font-size: 15px;\n font-weight: 600;\n line-height: 1.4;\n color: var(--dsw-alias-label-primary);\n}\n\n.description_1712176718 {\n font-size: 13px;\n line-height: 1.5;\n color: var(--dsw-alias-label-tertiary);\n}\n\n/* Carried on the header so a collapsed card still says it holds edits. */\n.pending_1712176718 {\n flex: none;\n border-radius: 999px;\n corner-shape: round;\n padding: 1px 8px;\n font-size: 11px;\n line-height: 17px;\n font-weight: 500;\n white-space: nowrap;\n background: var(--dsw-alias-bg-module-platform);\n color: var(--dsw-alias-label-secondary);\n}\n\n.chevron_1712176718 {\n flex: none;\n color: var(--dsw-alias-label-tertiary);\n transition: transform .16s;\n}\n\n.chevronOpen_1712176718 {\n transform: rotate(180deg);\n}\n\n.body_1712176718 {\n border-top: 0.5px solid var(--dsw-alias-border-l2);\n margin: 0 16px;\n padding: 12px 0 8px;\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.note_1712176718 {\n margin: 0;\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.field_1712176718 {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.fieldLabel_1712176718 {\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-secondary);\n}\n\n.input_1712176718 {\n box-sizing: border-box;\n width: 100%;\n padding: 4px 8px;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-primary);\n background-color: var(--dsw-alias-bg-layer-2);\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: 6px;\n appearance: none;\n}\n\n.input_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: -1px;\n}\n\n.input_1712176718:disabled {\n opacity: 0.6;\n}\n\n/* The directory control and its native-dialog launcher share one row. */\n.inputRow_1712176718 {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.inputRow_1712176718 .input_1712176718 {\n flex: 1;\n min-width: 0;\n}\n\n.browse_1712176718 {\n appearance: none;\n flex: none;\n border: 0.5px solid var(--dsw-alias-border-l3);\n border-radius: 6px;\n padding: 4px 10px;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n background: none;\n cursor: pointer;\n white-space: nowrap;\n}\n\n.browse_1712176718:hover:not(:disabled) {\n color: var(--dsw-alias-label-primary);\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n.browse_1712176718:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.browse_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: 1px;\n}\n\n.hint_1712176718 {\n margin: 0;\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.footer_1712176718 {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n padding: 8px 0 4px;\n border-top: 0.5px solid var(--dsw-alias-border-l2);\n}\n\n.failed_1712176718 {\n flex: 1;\n min-width: 0;\n margin: 0;\n font-size: 12px;\n line-height: 1.5;\n color: var(--dsw-alias-label-error);\n}\n\n.discard_1712176718,\n.save_1712176718 {\n appearance: none;\n border: 0.5px solid transparent;\n border-radius: 8px;\n padding: 5px 14px;\n font: inherit;\n font-size: 13px;\n line-height: 1.5;\n cursor: pointer;\n}\n\n.discard_1712176718 {\n border-color: var(--dsw-alias-border-l2);\n background: none;\n color: var(--dsw-alias-label-secondary);\n}\n\n.discard_1712176718:hover:not(:disabled) {\n color: var(--dsw-alias-label-primary);\n border-color: var(--dsw-alias-label-dimmed);\n}\n\n.save_1712176718 {\n background: var(--dsw-alias-label-primary);\n color: var(--dsw-alias-bg-layer-3);\n}\n\n.discard_1712176718:disabled,\n.save_1712176718:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.discard_1712176718:focus-visible,\n.save_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: 1px;\n}\n\n/* Sidebar-grouping switch: title + hint + caution beside a checkbox. */\n.toggleRow_1712176718 {\n margin-top: 10px;\n flex-direction: row;\n align-items: flex-start;\n gap: 10px;\n}\n\n.toggleText_1712176718 {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.toggleLabel_1712176718 {\n color: var(--dsw-alias-label-primary);\n font-weight: 500;\n}\n\n.toggleMark_1712176718 {\n margin-left: 4px;\n font-weight: 400;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.toggleHint_1712176718 {\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n\n.toggleControl_1712176718 {\n display: flex;\n align-items: center;\n gap: 6px;\n flex: none;\n margin-top: 2px;\n}\n\n.spinner_1712176718 {\n display: flex;\n color: var(--dsw-alias-label-tertiary);\n animation: spin 0.7s linear infinite;\n}\n\n@keyframes spin {\n to { transform: rotate(360deg); }\n}\n\n.toggle_1712176718 {\n width: 16px;\n height: 16px;\n accent-color: var(--dsw-alias-brand-primary);\n cursor: pointer;\n}\n\n.toggle_1712176718:disabled {\n cursor: progress;\n}\n\n/* Manager entry row: title + hint on the left (the toggle rows' text\n * column), the launcher button on the right — the same posture as the\n * grouping switch, minus the checkbox. (.field_1712176718 is columnar; the row\n * direction is restated here.) */\n.manageRow_1712176718 {\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n\n.manage_1712176718 {\n appearance: none;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: 8px;\n background: none;\n font: inherit;\n font-size: 13px;\n color: var(--dsw-alias-label-primary);\n padding: 6px 12px;\n cursor: pointer;\n}\n\n.manage_1712176718:hover {\n border-color: var(--dsw-alias-brand-primary);\n}\n\n.manage_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: -2px;\n}\n\n/* Keep-cap row: the number input rides the toggle row's title column, and\n * stays disabled while the auto-prune switch is off (the cap means nothing\n * without the prune that enforces it). */\n.keepRow_1712176718 {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.keepControl_1712176718 {\n display: flex;\n justify-content: flex-start;\n}\n\n.keepInput_1712176718 {\n width: 96px;\n appearance: none;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: 8px;\n background: var(--dsw-alias-bg-layer-2);\n font: inherit;\n font-size: 13px;\n color: var(--dsw-alias-label-primary);\n padding: 6px 10px;\n}\n\n.keepInput_1712176718:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary);\n outline-offset: -2px;\n}\n\n.keepInput_1712176718:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n\n.keepBad_1712176718 {\n font-size: 12px;\n color: var(--dsw-alias-label-danger, #d64545);\n}\n\n/* Write-through switches flip optimistically, so a rejected write shows up\n * as the control snapping back. This note sits in the switch's own text\n * column and says which one did not take. */\n.switchBad_1712176718 {\n font-size: 12px;\n line-height: 16px;\n color: var(--dsw-alias-label-danger, #d64545);\n}\n\n/* The auto-prune audit trail (清理记录): newest first, one run per line —\n * relative time, the removed directories with their belonging, then the\n * run's exceptions in the secondary tone. */\n.historyRow_1712176718 {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.history_1712176718 {\n margin: 0;\n padding: 0;\n list-style: none;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.historyRun_1712176718 {\n display: flex;\n flex-direction: column;\n gap: 2px;\n padding: 4px 8px;\n border: 0.5px solid color-mix(in srgb, currentColor 12%, transparent);\n border-radius: 6px;\n}\n\n.historyTime_1712176718 {\n font-size: 12px;\n font-weight: 600;\n color: var(--dsw-alias-label-primary);\n}\n\n.historyLine_1712176718 {\n font-size: 12px;\n line-height: 16px;\n color: var(--dsw-alias-label-secondary);\n overflow-wrap: anywhere;\n}\n\n/* The fold toggle. A link, not a button chrome: it reveals rows in place,\n * it does not act on anything. */\n.historyMore_1712176718 {\n align-self: flex-start;\n padding: 0;\n border: none;\n background: none;\n font: inherit;\n font-size: 12px;\n line-height: 16px;\n color: var(--dsw-alias-label-link, var(--dsw-alias-label-secondary));\n cursor: pointer;\n}\n\n.historyMore_1712176718:hover {\n text-decoration: underline;\n}\n";
|
|
4232
|
+
const tagId$2 = "@laoyuehanni/dsh-git-worktree/GitWorktreeCard.module.css";
|
|
4233
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId$2 + "\"]") === null) {
|
|
4234
|
+
const tag = document.createElement("style");
|
|
4235
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-git-worktree";
|
|
4236
|
+
tag.dataset.pluginCss = tagId$2;
|
|
4237
|
+
tag.textContent = css$2;
|
|
4238
|
+
document.head.appendChild(tag);
|
|
4239
|
+
}
|
|
4240
|
+
var GitWorktreeCard_module_default = {
|
|
4241
|
+
"card": "card_1712176718",
|
|
4242
|
+
"cardOpen": "cardOpen_1712176718",
|
|
4243
|
+
"header": "header_1712176718",
|
|
4244
|
+
"headText": "headText_1712176718",
|
|
4245
|
+
"name": "name_1712176718",
|
|
4246
|
+
"description": "description_1712176718",
|
|
4247
|
+
"pending": "pending_1712176718",
|
|
4248
|
+
"chevron": "chevron_1712176718",
|
|
4249
|
+
"chevronOpen": "chevronOpen_1712176718",
|
|
4250
|
+
"body": "body_1712176718",
|
|
4251
|
+
"note": "note_1712176718",
|
|
4252
|
+
"field": "field_1712176718",
|
|
4253
|
+
"fieldLabel": "fieldLabel_1712176718",
|
|
4254
|
+
"input": "input_1712176718",
|
|
4255
|
+
"inputRow": "inputRow_1712176718",
|
|
4256
|
+
"browse": "browse_1712176718",
|
|
4257
|
+
"hint": "hint_1712176718",
|
|
4258
|
+
"footer": "footer_1712176718",
|
|
4259
|
+
"failed": "failed_1712176718",
|
|
4260
|
+
"discard": "discard_1712176718",
|
|
4261
|
+
"save": "save_1712176718",
|
|
4262
|
+
"toggleRow": "toggleRow_1712176718",
|
|
4263
|
+
"toggleText": "toggleText_1712176718",
|
|
4264
|
+
"toggleLabel": "toggleLabel_1712176718",
|
|
4265
|
+
"toggleMark": "toggleMark_1712176718",
|
|
4266
|
+
"toggleHint": "toggleHint_1712176718",
|
|
4267
|
+
"toggleControl": "toggleControl_1712176718",
|
|
4268
|
+
"spinner": "spinner_1712176718",
|
|
4269
|
+
"toggle": "toggle_1712176718",
|
|
4270
|
+
"manageRow": "manageRow_1712176718",
|
|
4271
|
+
"manage": "manage_1712176718",
|
|
4272
|
+
"keepRow": "keepRow_1712176718",
|
|
4273
|
+
"keepControl": "keepControl_1712176718",
|
|
4274
|
+
"keepInput": "keepInput_1712176718",
|
|
4275
|
+
"keepBad": "keepBad_1712176718",
|
|
4276
|
+
"switchBad": "switchBad_1712176718",
|
|
4277
|
+
"historyRow": "historyRow_1712176718",
|
|
4278
|
+
"history": "history_1712176718",
|
|
4279
|
+
"historyRun": "historyRun_1712176718",
|
|
4280
|
+
"historyTime": "historyTime_1712176718",
|
|
4281
|
+
"historyLine": "historyLine_1712176718",
|
|
4282
|
+
"historyMore": "historyMore_1712176718"
|
|
4283
|
+
};
|
|
4284
|
+
//#endregion
|
|
4285
|
+
//#region src/client/GitWorktreeCard.tsx
|
|
4286
|
+
/**
|
|
4287
|
+
* The git-worktree card on the Plugins configuration tab: a collapsible row
|
|
4288
|
+
* whose header names the plugin over a one-line description of what its
|
|
4289
|
+
* settings govern, disclosing the storage-root control when open. The card
|
|
4290
|
+
* owns everything inside it — chrome, controls, and copy — per the keyed-slot
|
|
4291
|
+
* contract; the tab only dispatches it under the `git-worktree` namespace
|
|
4292
|
+
* key.
|
|
4293
|
+
*
|
|
4294
|
+
* Renders nothing while the namespace is unavailable: a deployment that did
|
|
4295
|
+
* not compose the host half shows no trace of the card. A stored root edit
|
|
4296
|
+
* takes effect live (the Host routes read the section source per request);
|
|
4297
|
+
* no data moves — worktrees already created stay where they are, and git
|
|
4298
|
+
* itself still lists and reuses them.
|
|
4299
|
+
*
|
|
4300
|
+
* @module git-worktree/client/GitWorktreeCard
|
|
4301
|
+
*/
|
|
4302
|
+
/** Prune runs shown before the log folds behind "show all". */
|
|
4303
|
+
const HISTORY_PREVIEW = 3;
|
|
4304
|
+
/** One removed worktree as "repo/branch" — or whichever half the scan
|
|
4305
|
+
* knew. The belonging is a snapshot taken at prune time and either field
|
|
4306
|
+
* can be missing; joining them unconditionally printed a bare " /". */
|
|
4307
|
+
function labelOfRemoved(item) {
|
|
4308
|
+
const parts = [item.repoName, item.branch].filter((part) => typeof part === "string" && part !== "");
|
|
4309
|
+
return parts.length === 0 ? "?" : parts.join("/");
|
|
4310
|
+
}
|
|
4311
|
+
/**
|
|
4312
|
+
* Render the git-worktree settings card.
|
|
4313
|
+
* @param props - locale copy, the card snapshot, and its form actions.
|
|
4314
|
+
* @returns the card, or nothing when the namespace is unavailable.
|
|
4315
|
+
*/
|
|
4316
|
+
function GitWorktreeCard(props) {
|
|
4317
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
4318
|
+
const [picking, setPicking] = (0, react.useState)(false);
|
|
4319
|
+
const [managerOpen, setManagerOpen] = (0, react.useState)(false);
|
|
4320
|
+
/** The prune log and the clock it is measured against, both read ONCE per
|
|
4321
|
+
* card expansion. Reading localStorage (and Date.now) from the render body
|
|
4322
|
+
* made every unrelated re-render re-parse the log and shift the relative
|
|
4323
|
+
* times underneath the user. */
|
|
4324
|
+
const [history, setHistory] = (0, react.useState)([]);
|
|
4325
|
+
const [historyNow, setHistoryNow] = (0, react.useState)(() => Date.now());
|
|
4326
|
+
/** Whether the log is showing past its preview. Collapses again on every
|
|
4327
|
+
* expansion: the log can hold 20 runs, and a settings card is not where
|
|
4328
|
+
* a wall of them belongs by default. */
|
|
4329
|
+
const [historyAll, setHistoryAll] = (0, react.useState)(false);
|
|
4330
|
+
(0, react.useEffect)(() => {
|
|
4331
|
+
if (!open) return;
|
|
4332
|
+
setHistory(readPruneHistory());
|
|
4333
|
+
setHistoryNow(Date.now());
|
|
4334
|
+
setHistoryAll(false);
|
|
4335
|
+
}, [open]);
|
|
4336
|
+
const shownHistory = historyAll ? history : history.slice(0, HISTORY_PREVIEW);
|
|
4337
|
+
const { t } = props;
|
|
4338
|
+
const state = props.useGitWorktreeCard((snapshot) => snapshot);
|
|
4339
|
+
if (!state.available) return null;
|
|
4340
|
+
const lockInput = !state.writable;
|
|
4341
|
+
const lockActions = !state.dirty || state.saving || !state.keepWorktreesValid;
|
|
4342
|
+
/**
|
|
4343
|
+
* Open the shell's native folder dialog and stage the chosen path — the
|
|
4344
|
+
* same picker the workspace flows use, driven through the injected
|
|
4345
|
+
* workspace service. A dismissal leaves the staged draft exactly as it
|
|
4346
|
+
* was; the text input stays the fallback either way.
|
|
4347
|
+
*/
|
|
4348
|
+
const browse = async () => {
|
|
4349
|
+
if (picking || lockInput) return;
|
|
4350
|
+
setPicking(true);
|
|
4351
|
+
try {
|
|
4352
|
+
const picked = await props.pickDirectory();
|
|
4353
|
+
if (picked !== null && picked !== "") props.editRoot(picked);
|
|
4354
|
+
} catch (_pickFailure) {} finally {
|
|
4355
|
+
setPicking(false);
|
|
4356
|
+
}
|
|
4357
|
+
};
|
|
4358
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
4359
|
+
className: open ? `${GitWorktreeCard_module_default.card} ${GitWorktreeCard_module_default.cardOpen}` : GitWorktreeCard_module_default.card,
|
|
4360
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
4361
|
+
type: "button",
|
|
4362
|
+
className: GitWorktreeCard_module_default.header,
|
|
4363
|
+
"aria-expanded": open,
|
|
4364
|
+
"aria-label": `${t(open ? "cardCollapse" : "cardExpand")}: ${t("cardTitle")}`,
|
|
4365
|
+
onClick: () => {
|
|
4366
|
+
setOpen(!open);
|
|
4367
|
+
},
|
|
4368
|
+
children: [
|
|
4369
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4370
|
+
className: GitWorktreeCard_module_default.headText,
|
|
4371
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4372
|
+
className: GitWorktreeCard_module_default.name,
|
|
4373
|
+
children: t("cardTitle")
|
|
4374
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4375
|
+
className: GitWorktreeCard_module_default.description,
|
|
4376
|
+
children: t("cardDescription")
|
|
4377
|
+
})]
|
|
4378
|
+
}),
|
|
4379
|
+
state.dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4380
|
+
className: GitWorktreeCard_module_default.pending,
|
|
4381
|
+
children: t("cardUnsaved")
|
|
4382
|
+
}) : null,
|
|
4383
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutline14, { className: open ? `${GitWorktreeCard_module_default.chevron} ${GitWorktreeCard_module_default.chevronOpen}` : GitWorktreeCard_module_default.chevron })
|
|
4384
|
+
]
|
|
4385
|
+
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4386
|
+
className: GitWorktreeCard_module_default.body,
|
|
4387
|
+
children: [
|
|
4388
|
+
!state.writable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4389
|
+
className: GitWorktreeCard_module_default.note,
|
|
4390
|
+
role: "status",
|
|
4391
|
+
children: t("cardReadOnly")
|
|
4392
|
+
}) : null,
|
|
4393
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
4394
|
+
className: GitWorktreeCard_module_default.field,
|
|
4395
|
+
htmlFor: "git-worktree-card-root-dir",
|
|
4396
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4397
|
+
className: GitWorktreeCard_module_default.fieldLabel,
|
|
4398
|
+
children: t("cardRootDirLabel")
|
|
4399
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4400
|
+
className: GitWorktreeCard_module_default.inputRow,
|
|
4401
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
4402
|
+
id: "git-worktree-card-root-dir",
|
|
4403
|
+
className: GitWorktreeCard_module_default.input,
|
|
4404
|
+
type: "text",
|
|
4405
|
+
spellCheck: false,
|
|
4406
|
+
value: state.rootDir,
|
|
4407
|
+
disabled: lockInput,
|
|
4408
|
+
onChange: (event) => {
|
|
4409
|
+
props.editRoot(event.target.value);
|
|
4410
|
+
}
|
|
4411
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4412
|
+
type: "button",
|
|
4413
|
+
className: GitWorktreeCard_module_default.browse,
|
|
4414
|
+
disabled: lockInput || picking,
|
|
4415
|
+
onClick: () => {
|
|
4416
|
+
browse();
|
|
4417
|
+
},
|
|
4418
|
+
children: t(picking ? "cardPicking" : "cardBrowse")
|
|
4419
|
+
})]
|
|
4420
|
+
})]
|
|
4421
|
+
}),
|
|
4422
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
4423
|
+
className: GitWorktreeCard_module_default.hint,
|
|
4424
|
+
children: [t("cardRootDirHint"), state.overridden ? ` ${t("cardOverridden")}` : ""]
|
|
4425
|
+
}),
|
|
4426
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
4427
|
+
className: `${GitWorktreeCard_module_default.field} ${GitWorktreeCard_module_default.toggleRow}`,
|
|
4428
|
+
"aria-busy": state.groupingPending,
|
|
4429
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4430
|
+
className: GitWorktreeCard_module_default.toggleText,
|
|
4431
|
+
children: [
|
|
4432
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4433
|
+
className: GitWorktreeCard_module_default.toggleLabel,
|
|
4434
|
+
children: [t("cardGroupSidebarLabel"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4435
|
+
className: GitWorktreeCard_module_default.toggleMark,
|
|
4436
|
+
children: t("cardGroupSidebarMark")
|
|
4437
|
+
})]
|
|
4438
|
+
}),
|
|
4439
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4440
|
+
className: GitWorktreeCard_module_default.toggleHint,
|
|
4441
|
+
children: t("cardGroupSidebarHint")
|
|
4442
|
+
}),
|
|
4443
|
+
state.switchFailed === "groupSidebar" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4444
|
+
className: GitWorktreeCard_module_default.switchBad,
|
|
4445
|
+
role: "alert",
|
|
4446
|
+
children: t("cardSwitchFailed")
|
|
4447
|
+
})
|
|
4448
|
+
]
|
|
4449
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4450
|
+
className: GitWorktreeCard_module_default.toggleControl,
|
|
4451
|
+
children: [state.groupingPending ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4452
|
+
className: GitWorktreeCard_module_default.spinner,
|
|
4453
|
+
role: "status",
|
|
4454
|
+
"aria-label": t("cardGroupSidebarBusy"),
|
|
4455
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLoadingOutline16, { size: 14 })
|
|
4456
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
4457
|
+
className: GitWorktreeCard_module_default.toggle,
|
|
4458
|
+
type: "checkbox",
|
|
4459
|
+
disabled: lockInput || state.groupingPending,
|
|
4460
|
+
checked: state.groupSidebar,
|
|
4461
|
+
onChange: (event) => {
|
|
4462
|
+
props.setGroupSidebar(event.target.checked);
|
|
4463
|
+
}
|
|
4464
|
+
})]
|
|
4465
|
+
})]
|
|
4466
|
+
}),
|
|
4467
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4468
|
+
className: `${GitWorktreeCard_module_default.field} ${GitWorktreeCard_module_default.manageRow}`,
|
|
4469
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4470
|
+
className: GitWorktreeCard_module_default.toggleText,
|
|
4471
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4472
|
+
className: GitWorktreeCard_module_default.toggleLabel,
|
|
4473
|
+
children: t("cardManageWorktrees")
|
|
4474
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4475
|
+
className: GitWorktreeCard_module_default.toggleHint,
|
|
4476
|
+
children: t("cardManageHint")
|
|
4477
|
+
})]
|
|
4478
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4479
|
+
type: "button",
|
|
4480
|
+
className: GitWorktreeCard_module_default.manage,
|
|
4481
|
+
onClick: () => {
|
|
4482
|
+
setManagerOpen(true);
|
|
4483
|
+
},
|
|
4484
|
+
children: t("cardManageWorktrees")
|
|
4485
|
+
})]
|
|
4486
|
+
}),
|
|
4487
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
4488
|
+
className: `${GitWorktreeCard_module_default.field} ${GitWorktreeCard_module_default.toggleRow}`,
|
|
4489
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4490
|
+
className: GitWorktreeCard_module_default.toggleText,
|
|
4491
|
+
children: [
|
|
4492
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4493
|
+
className: GitWorktreeCard_module_default.toggleLabel,
|
|
4494
|
+
children: t("cardFetchBeforeCreateLabel")
|
|
4495
|
+
}),
|
|
4496
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4497
|
+
className: GitWorktreeCard_module_default.toggleHint,
|
|
4498
|
+
children: t("cardFetchBeforeCreateHint")
|
|
4499
|
+
}),
|
|
4500
|
+
state.switchFailed === "fetchBeforeCreate" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4501
|
+
className: GitWorktreeCard_module_default.switchBad,
|
|
4502
|
+
role: "alert",
|
|
4503
|
+
children: t("cardSwitchFailed")
|
|
4504
|
+
})
|
|
4505
|
+
]
|
|
4506
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4507
|
+
className: GitWorktreeCard_module_default.toggleControl,
|
|
4508
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
4509
|
+
className: GitWorktreeCard_module_default.toggle,
|
|
4510
|
+
type: "checkbox",
|
|
4511
|
+
disabled: lockInput,
|
|
4512
|
+
checked: state.fetchBeforeCreate,
|
|
4513
|
+
onChange: (event) => {
|
|
4514
|
+
props.setFetchBeforeCreate(event.target.checked);
|
|
4515
|
+
}
|
|
4516
|
+
})
|
|
4517
|
+
})]
|
|
4518
|
+
}),
|
|
4519
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
4520
|
+
className: `${GitWorktreeCard_module_default.field} ${GitWorktreeCard_module_default.toggleRow}`,
|
|
4521
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4522
|
+
className: GitWorktreeCard_module_default.toggleText,
|
|
4523
|
+
children: [
|
|
4524
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4525
|
+
className: GitWorktreeCard_module_default.toggleLabel,
|
|
4526
|
+
children: t("cardAutoPruneLabel")
|
|
4527
|
+
}),
|
|
4528
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4529
|
+
className: GitWorktreeCard_module_default.toggleHint,
|
|
4530
|
+
children: t("cardAutoPruneHint")
|
|
4531
|
+
}),
|
|
4532
|
+
state.switchFailed === "autoPruneWorktrees" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4533
|
+
className: GitWorktreeCard_module_default.switchBad,
|
|
4534
|
+
role: "alert",
|
|
4535
|
+
children: t("cardSwitchFailed")
|
|
4536
|
+
})
|
|
4537
|
+
]
|
|
4538
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4539
|
+
className: GitWorktreeCard_module_default.toggleControl,
|
|
4540
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
4541
|
+
className: GitWorktreeCard_module_default.toggle,
|
|
4542
|
+
type: "checkbox",
|
|
4543
|
+
disabled: lockInput,
|
|
4544
|
+
checked: state.autoPruneWorktrees,
|
|
4545
|
+
onChange: (event) => {
|
|
4546
|
+
props.setAutoPruneWorktrees(event.target.checked);
|
|
4547
|
+
}
|
|
4548
|
+
})
|
|
4549
|
+
})]
|
|
4550
|
+
}),
|
|
4551
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
4552
|
+
className: `${GitWorktreeCard_module_default.field} ${GitWorktreeCard_module_default.keepRow}`,
|
|
4553
|
+
htmlFor: "git-worktree-card-keep",
|
|
4554
|
+
children: [
|
|
4555
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4556
|
+
className: GitWorktreeCard_module_default.fieldLabel,
|
|
4557
|
+
children: t("cardKeepWorktreesLabel")
|
|
4558
|
+
}),
|
|
4559
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4560
|
+
className: GitWorktreeCard_module_default.keepControl,
|
|
4561
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
4562
|
+
id: "git-worktree-card-keep",
|
|
4563
|
+
className: GitWorktreeCard_module_default.keepInput,
|
|
4564
|
+
type: "number",
|
|
4565
|
+
min: 1,
|
|
4566
|
+
step: 1,
|
|
4567
|
+
disabled: lockInput || !state.autoPruneWorktrees,
|
|
4568
|
+
value: state.keepWorktreesText,
|
|
4569
|
+
onChange: (event) => {
|
|
4570
|
+
props.editKeepWorktrees(event.target.value);
|
|
4571
|
+
}
|
|
4572
|
+
})
|
|
4573
|
+
}),
|
|
4574
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4575
|
+
className: GitWorktreeCard_module_default.toggleHint,
|
|
4576
|
+
children: t("cardKeepWorktreesHint")
|
|
4577
|
+
}),
|
|
4578
|
+
!state.keepWorktreesValid && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4579
|
+
className: GitWorktreeCard_module_default.keepBad,
|
|
4580
|
+
role: "alert",
|
|
4581
|
+
children: t("cardKeepWorktreesBad")
|
|
4582
|
+
})
|
|
4583
|
+
]
|
|
4584
|
+
}),
|
|
4585
|
+
history.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4586
|
+
className: `${GitWorktreeCard_module_default.field} ${GitWorktreeCard_module_default.historyRow}`,
|
|
4587
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4588
|
+
className: GitWorktreeCard_module_default.fieldLabel,
|
|
4589
|
+
children: t("cardPruneHistoryLabel")
|
|
4590
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("ul", {
|
|
4591
|
+
className: GitWorktreeCard_module_default.history,
|
|
4592
|
+
children: [shownHistory.map((run) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
4593
|
+
className: GitWorktreeCard_module_default.historyRun,
|
|
4594
|
+
children: [
|
|
4595
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4596
|
+
className: GitWorktreeCard_module_default.historyTime,
|
|
4597
|
+
children: timeLabel(run.at, historyNow, t)
|
|
4598
|
+
}),
|
|
4599
|
+
run.removed.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4600
|
+
className: GitWorktreeCard_module_default.historyLine,
|
|
4601
|
+
children: [t("cardPruneHistoryRun", { n: run.removed.length }), run.removed.map((item) => ` ${labelOfRemoved(item)}`).join(" ·")]
|
|
4602
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4603
|
+
className: GitWorktreeCard_module_default.historyLine,
|
|
4604
|
+
children: t("cardPruneHistoryNone")
|
|
4605
|
+
}),
|
|
4606
|
+
run.skippedDirty.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4607
|
+
className: GitWorktreeCard_module_default.historyLine,
|
|
4608
|
+
children: t("cardPruneHistorySkipped", { n: run.skippedDirty.length })
|
|
4609
|
+
}),
|
|
4610
|
+
run.failed.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4611
|
+
className: GitWorktreeCard_module_default.historyLine,
|
|
4612
|
+
children: t("cardPruneHistoryFailed", { n: run.failed.length })
|
|
4613
|
+
})
|
|
4614
|
+
]
|
|
4615
|
+
}, run.at)), history.length > HISTORY_PREVIEW && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4616
|
+
type: "button",
|
|
4617
|
+
className: GitWorktreeCard_module_default.historyMore,
|
|
4618
|
+
onClick: () => {
|
|
4619
|
+
setHistoryAll((value) => !value);
|
|
4620
|
+
},
|
|
4621
|
+
children: historyAll ? t("cardPruneHistoryLess") : t("cardPruneHistoryMore", { n: history.length })
|
|
4622
|
+
}) })]
|
|
4623
|
+
})]
|
|
4624
|
+
}),
|
|
4625
|
+
history.length === 0 && state.autoPruneWorktrees && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4626
|
+
className: `${GitWorktreeCard_module_default.field} ${GitWorktreeCard_module_default.historyRow}`,
|
|
4627
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4628
|
+
className: GitWorktreeCard_module_default.fieldLabel,
|
|
4629
|
+
children: t("cardPruneHistoryLabel")
|
|
4630
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4631
|
+
className: GitWorktreeCard_module_default.toggleHint,
|
|
4632
|
+
children: t("cardPruneHistoryEmpty")
|
|
4633
|
+
})]
|
|
4634
|
+
}),
|
|
4635
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorktreeManagerModal, {
|
|
4636
|
+
open: managerOpen,
|
|
4637
|
+
onClose: () => {
|
|
4638
|
+
setManagerOpen(false);
|
|
4639
|
+
},
|
|
4640
|
+
face: props.manager,
|
|
4641
|
+
t
|
|
4642
|
+
}),
|
|
4643
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4644
|
+
className: GitWorktreeCard_module_default.footer,
|
|
4645
|
+
children: [
|
|
4646
|
+
state.failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4647
|
+
className: GitWorktreeCard_module_default.failed,
|
|
4648
|
+
role: "status",
|
|
4649
|
+
children: t("cardSaveFailed")
|
|
4650
|
+
}) : null,
|
|
4651
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4652
|
+
type: "button",
|
|
4653
|
+
className: GitWorktreeCard_module_default.discard,
|
|
4654
|
+
disabled: lockActions,
|
|
4655
|
+
onClick: props.discard,
|
|
4656
|
+
children: t("cardDiscard")
|
|
4657
|
+
}),
|
|
4658
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4659
|
+
type: "button",
|
|
4660
|
+
className: GitWorktreeCard_module_default.save,
|
|
4661
|
+
disabled: lockActions,
|
|
4662
|
+
onClick: props.save,
|
|
4663
|
+
children: t(state.saving ? "cardSaving" : "cardSave")
|
|
4664
|
+
})
|
|
4665
|
+
]
|
|
4666
|
+
})
|
|
4667
|
+
]
|
|
4668
|
+
}) : null]
|
|
4669
|
+
});
|
|
4670
|
+
}
|
|
4671
|
+
//#endregion
|
|
3220
4672
|
//#region node_modules/.pnpm/@deepseek-ai+dsh-util-works_407d2a08572222b71cf59f5f9298b01a/node_modules/@deepseek-ai/dsh-util-workspace-path/lib/index.js
|
|
3221
4673
|
/**
|
|
3222
4674
|
* Browser-safe Workspace path and display helpers.
|
|
@@ -3444,10 +4896,10 @@ window.__ModuleLoader__.load({
|
|
|
3444
4896
|
}
|
|
3445
4897
|
/**
|
|
3446
4898
|
* Dashed folder glyph for virtual (unregistered) directory rows. The icon set
|
|
3447
|
-
* ships no dashed variant, so this
|
|
3448
|
-
*
|
|
3449
|
-
* but not a registered workspace" mark than the
|
|
3450
|
-
* it replaces.
|
|
4899
|
+
* ships no dashed variant, so this is a module-local SVG (the same posture
|
|
4900
|
+
* the composer's local glyphs take): at 16px a dash pattern is a far stronger
|
|
4901
|
+
* "directory-shaped but not a registered workspace" mark than the
|
|
4902
|
+
* outline/solid stroke contrast it replaces.
|
|
3451
4903
|
*/
|
|
3452
4904
|
function StrayFolderGlyph({ size = 16 }) {
|
|
3453
4905
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
@@ -4619,24 +6071,23 @@ window.__ModuleLoader__.load({
|
|
|
4619
6071
|
const target = wtRemoveTarget;
|
|
4620
6072
|
setWtRemoving(true);
|
|
4621
6073
|
setWtRemoveError(null);
|
|
4622
|
-
(
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
})();
|
|
6074
|
+
removeWorktreeFully({
|
|
6075
|
+
removeWorktree: props.removeWorktree,
|
|
6076
|
+
probeDirectories: props.probeDirectories,
|
|
6077
|
+
archiveSession: props.archiveSession,
|
|
6078
|
+
deleteWorkspace: props.deleteWorkspace
|
|
6079
|
+
}, {
|
|
6080
|
+
path: target.workspace.path,
|
|
6081
|
+
force: wtInspect.dirty > 0,
|
|
6082
|
+
workspaceId: target.workspace.workspaceId,
|
|
6083
|
+
archiveSessionIds: wtArchiveIds
|
|
6084
|
+
}).then(() => {
|
|
6085
|
+
setWtRemoving(false);
|
|
6086
|
+
setWtRemoveTarget(null);
|
|
6087
|
+
}, (reason) => {
|
|
6088
|
+
setWtRemoving(false);
|
|
6089
|
+
setWtRemoveError(reason instanceof Error ? reason.message : String(reason));
|
|
6090
|
+
});
|
|
4640
6091
|
};
|
|
4641
6092
|
const now = Date.now();
|
|
4642
6093
|
const strayGroups = (0, react.useMemo)(() => deriveStrayGroups(items, sessionList, archived), [
|
|
@@ -5170,39 +6621,48 @@ window.__ModuleLoader__.load({
|
|
|
5170
6621
|
//#region src/client/locales.ts
|
|
5171
6622
|
/** English dictionary — complete by construction. */
|
|
5172
6623
|
const en = {
|
|
5173
|
-
chipWorktree: "Worktree",
|
|
5174
|
-
worktreeToggle: "Create an isolated worktree",
|
|
5175
6624
|
menuBranches: "Branches",
|
|
5176
6625
|
menuLocalBranches: "Local branches",
|
|
5177
6626
|
menuWorktrees: "Worktrees",
|
|
5178
6627
|
menuRemoteBranches: "Remote branches",
|
|
5179
|
-
mainRepoOnly: "Branch operations start from the main checkout",
|
|
5180
6628
|
menuSearchPlaceholder: "Search branches",
|
|
5181
6629
|
menuNoMatches: "No matching branches",
|
|
5182
6630
|
menuNoBranches: "No branches yet",
|
|
5183
6631
|
menuLocate: "Locate current branch",
|
|
5184
6632
|
menuExpandAll: "Expand all",
|
|
5185
6633
|
menuCollapseAll: "Collapse all",
|
|
5186
|
-
menuNewBranch: "Create branch from current",
|
|
5187
6634
|
menuNewBranchPlaceholder: "New branch name",
|
|
5188
6635
|
menuNewBranchBad: "Git will not accept this name",
|
|
5189
6636
|
menuNewBranchExists: "A branch with this name already exists",
|
|
5190
6637
|
menuFetch: "Fetch",
|
|
5191
6638
|
menuUpdate: "Update current branch from upstream",
|
|
6639
|
+
ctxCheckout: "Check out",
|
|
6640
|
+
ctxHop: "Go to this worktree",
|
|
6641
|
+
ctxWorktree: "Create worktree",
|
|
6642
|
+
ctxWorktreeCut: "New branch and worktree",
|
|
6643
|
+
ctxCreate: "New branch",
|
|
6644
|
+
ctxCreateCheckout: "New branch and check out",
|
|
6645
|
+
ctxRename: "Rename branch",
|
|
6646
|
+
ctxDelete: "Delete branch",
|
|
6647
|
+
ctxCopyName: "Copy branch",
|
|
6648
|
+
ctxCopyPath: "Copy path",
|
|
6649
|
+
renameBranchTitle: "Rename {branch}",
|
|
6650
|
+
renameBranchBusy: "Renaming…",
|
|
6651
|
+
createFlyAsk: "Enter a new branch name",
|
|
6652
|
+
createFlyAskFrom: "New branch from {branch}",
|
|
6653
|
+
cutoutFlyAsk: "Cut a new branch from {branch} into a worktree",
|
|
6654
|
+
createCheckoutConfirm: "Create and check out",
|
|
6655
|
+
deleteBranchAsk: "Delete branch {branch}? Unmerged branches are refused.",
|
|
6656
|
+
deleteBranchBusy: "Deleting…",
|
|
5192
6657
|
fetchDone: "Remote branches synced",
|
|
5193
6658
|
updateDone: "{branch} fast-forwarded to its upstream",
|
|
5194
6659
|
updateUpToDate: "Already up to date",
|
|
5195
6660
|
aheadTitle: "{n} commits ahead of upstream",
|
|
5196
6661
|
behindTitle: "{n} commits behind upstream",
|
|
5197
|
-
switchAsk: "Switch to {branch}?",
|
|
5198
|
-
switchAskRemote: "Check out this remote branch?",
|
|
5199
|
-
switchBusy: "Switching…",
|
|
5200
6662
|
worktreeAskNew: "Create a worktree from {branch}?",
|
|
5201
6663
|
worktreeAskRemote: "Create a worktree from this remote branch?",
|
|
5202
6664
|
worktreeAskReuse: "Switch to the {branch} worktree?",
|
|
5203
|
-
worktreeAskCutOut: "Cut a new branch out of {branch} into an isolated worktree",
|
|
5204
6665
|
worktreeBusy: "Creating…",
|
|
5205
|
-
createBranchTitle: "New branch from {branch}",
|
|
5206
6666
|
createBranchBusy: "Creating…",
|
|
5207
6667
|
actionCancel: "Cancel",
|
|
5208
6668
|
actionConfirm: "Confirm",
|
|
@@ -5229,10 +6689,48 @@ window.__ModuleLoader__.load({
|
|
|
5229
6689
|
sidebarMain: "Main",
|
|
5230
6690
|
sidebarRailExpand: "Expand sidebar",
|
|
5231
6691
|
cardGroupSidebarLabel: "Group workspaces",
|
|
5232
|
-
cardGroupSidebarHint: "
|
|
6692
|
+
cardGroupSidebarHint: "Collect same-repo workspaces into one tree. Turn it off at any time to get the native list back.",
|
|
5233
6693
|
cardGroupSidebarMark: "(experimental)",
|
|
5234
|
-
cardGroupSidebarNote: "Turn it off to restore the native list if anything breaks; we will switch to the official API as soon as it ships.",
|
|
5235
6694
|
cardGroupSidebarBusy: "Switching sidebar…",
|
|
6695
|
+
cardSwitchFailed: "This switch did not save. Try again.",
|
|
6696
|
+
cardManageWorktrees: "Manage worktrees…",
|
|
6697
|
+
cardManageHint: "Browse and remove worktrees across repositories — including directories never registered as workspaces.",
|
|
6698
|
+
cardFetchBeforeCreateLabel: "Fetch upstream before creating",
|
|
6699
|
+
cardFetchBeforeCreateHint: "Runs fetch --all --prune before each worktree creation. A failed sync never blocks the creation.",
|
|
6700
|
+
cardAutoPruneLabel: "Auto-remove stale worktrees",
|
|
6701
|
+
cardAutoPruneHint: "Over the cap, creating a worktree removes the least recently used ones (folders only — branches are kept). Uncommitted changes or a running session are never removed.",
|
|
6702
|
+
cardKeepWorktreesLabel: "Worktrees to keep",
|
|
6703
|
+
cardKeepWorktreesHint: "Global cap across all repositories, minimum 1.",
|
|
6704
|
+
cardKeepWorktreesBad: "Enter an integer of at least 1",
|
|
6705
|
+
cardPruneHistoryLabel: "Prune history",
|
|
6706
|
+
cardPruneHistoryEmpty: "No prune runs yet",
|
|
6707
|
+
cardPruneHistoryRun: "Removed {n}:",
|
|
6708
|
+
cardPruneHistoryNone: "Nothing to remove this round",
|
|
6709
|
+
cardPruneHistorySkipped: "{n} skipped (uncommitted changes)",
|
|
6710
|
+
cardPruneHistoryFailed: "{n} failed",
|
|
6711
|
+
cardPruneHistoryMore: "Show all {n}",
|
|
6712
|
+
cardPruneHistoryLess: "Show less",
|
|
6713
|
+
"manager.title": "Manage worktrees",
|
|
6714
|
+
"manager.loading": "Scanning worktrees…",
|
|
6715
|
+
"manager.loadFailed": "Scan failed: {message}",
|
|
6716
|
+
"manager.empty": "The worktree storage root is empty.",
|
|
6717
|
+
"manager.count": "{n} worktree(s)",
|
|
6718
|
+
"manager.truncated": "Too many directories to scan; showing the first batch. Check that the storage folder is set correctly.",
|
|
6719
|
+
"manager.countOrphans": ", {n} unrecognized",
|
|
6720
|
+
"manager.orphans": "Unrecognized directories",
|
|
6721
|
+
"manager.activityNever": "no sessions",
|
|
6722
|
+
"manager.dirty.one": "{n} uncommitted file",
|
|
6723
|
+
"manager.dirty.other": "{n} uncommitted files",
|
|
6724
|
+
"manager.running": "A session is running here; removal is unavailable",
|
|
6725
|
+
"manager.purgeMenu": "Delete folder",
|
|
6726
|
+
"manager.purgeAria": "Delete the leftover folder “{path}”",
|
|
6727
|
+
"worktreePurge.title": "Delete leftover folder",
|
|
6728
|
+
"worktreePurge.desc": "This directory has no git record anymore. It will be deleted along with everything in it. This cannot be undone.",
|
|
6729
|
+
"worktreePurge.busy": "Deleting folder…",
|
|
6730
|
+
"manager.removeAria": "Remove the worktree “{path}”",
|
|
6731
|
+
fetchWarning: "Upstream sync failed; created from the local state: {message}",
|
|
6732
|
+
pruneDone: "Auto-removed {n} stale worktree(s)",
|
|
6733
|
+
pruneFailed: "{n} worktree(s) could not be auto-removed",
|
|
5236
6734
|
"group.ungrouped": "Ungrouped",
|
|
5237
6735
|
"session.new": "New Session",
|
|
5238
6736
|
"section.workspaces": "Workspaces",
|
|
@@ -5325,39 +6823,48 @@ window.__ModuleLoader__.load({
|
|
|
5325
6823
|
};
|
|
5326
6824
|
/** 中文词典。 */
|
|
5327
6825
|
const zh = {
|
|
5328
|
-
chipWorktree: "工作树",
|
|
5329
|
-
worktreeToggle: "创建隔离工作树",
|
|
5330
6826
|
menuBranches: "分支",
|
|
5331
6827
|
menuLocalBranches: "本地分支",
|
|
5332
6828
|
menuWorktrees: "工作树",
|
|
5333
6829
|
menuRemoteBranches: "远程分支",
|
|
5334
|
-
mainRepoOnly: "分支操作请在主仓库发起",
|
|
5335
6830
|
menuSearchPlaceholder: "搜索分支",
|
|
5336
6831
|
menuNoMatches: "没有匹配的分支",
|
|
5337
6832
|
menuNoBranches: "暂无分支",
|
|
5338
6833
|
menuLocate: "定位当前分支",
|
|
5339
6834
|
menuExpandAll: "全部展开",
|
|
5340
6835
|
menuCollapseAll: "全部折叠",
|
|
5341
|
-
menuNewBranch: "从当前分支新建分支",
|
|
5342
6836
|
menuNewBranchPlaceholder: "新分支名称",
|
|
5343
6837
|
menuNewBranchBad: "Git 不接受该名称",
|
|
5344
6838
|
menuNewBranchExists: "同名分支已存在",
|
|
5345
6839
|
menuFetch: "提取",
|
|
5346
6840
|
menuUpdate: "更新当前分支",
|
|
6841
|
+
ctxCheckout: "签出",
|
|
6842
|
+
ctxHop: "跳到此工作树",
|
|
6843
|
+
ctxWorktree: "创建工作树",
|
|
6844
|
+
ctxWorktreeCut: "新建分支并创建工作树",
|
|
6845
|
+
ctxCreate: "新建",
|
|
6846
|
+
ctxCreateCheckout: "新建并检出",
|
|
6847
|
+
ctxRename: "重命名分支",
|
|
6848
|
+
ctxDelete: "删除分支",
|
|
6849
|
+
ctxCopyName: "复制分支",
|
|
6850
|
+
ctxCopyPath: "复制路径",
|
|
6851
|
+
renameBranchTitle: "重命名 {branch}",
|
|
6852
|
+
renameBranchBusy: "重命名中…",
|
|
6853
|
+
createFlyAsk: "输入新分支名称",
|
|
6854
|
+
createFlyAskFrom: "从 {branch} 新建分支",
|
|
6855
|
+
cutoutFlyAsk: "从 {branch} 切出新分支并创建工作树",
|
|
6856
|
+
createCheckoutConfirm: "新建并检出",
|
|
6857
|
+
deleteBranchAsk: "是否删除分支 {branch}?未合并的分支会被拒绝。",
|
|
6858
|
+
deleteBranchBusy: "删除中…",
|
|
5347
6859
|
fetchDone: "远程分支已同步",
|
|
5348
6860
|
updateDone: "{branch} 已快进到远程最新",
|
|
5349
6861
|
updateUpToDate: "已是最新",
|
|
5350
6862
|
aheadTitle: "领先上游 {n} 个提交",
|
|
5351
6863
|
behindTitle: "落后上游 {n} 个提交",
|
|
5352
|
-
switchAsk: "是否切到 {branch}?",
|
|
5353
|
-
switchAskRemote: "是否检出该远程分支?",
|
|
5354
|
-
switchBusy: "切换中…",
|
|
5355
6864
|
worktreeAskNew: "是否从 {branch} 新建工作树?",
|
|
5356
6865
|
worktreeAskRemote: "从该远程分支新建工作树?",
|
|
5357
6866
|
worktreeAskReuse: "是否切到 {branch} 工作树?",
|
|
5358
|
-
worktreeAskCutOut: "从当前分支 {branch} 切出新分支到隔离工作树",
|
|
5359
6867
|
worktreeBusy: "创建中…",
|
|
5360
|
-
createBranchTitle: "从 {branch} 新建分支",
|
|
5361
6868
|
createBranchBusy: "创建中…",
|
|
5362
6869
|
actionCancel: "取消",
|
|
5363
6870
|
actionConfirm: "确认",
|
|
@@ -5384,10 +6891,48 @@ window.__ModuleLoader__.load({
|
|
|
5384
6891
|
sidebarMain: "主仓库",
|
|
5385
6892
|
sidebarRailExpand: "展开侧栏",
|
|
5386
6893
|
cardGroupSidebarLabel: "聚合工作区",
|
|
5387
|
-
cardGroupSidebarHint: "
|
|
6894
|
+
cardGroupSidebarHint: "把同仓库的工作区收成一棵树。出问题可随时关掉,回到原生列表。",
|
|
5388
6895
|
cardGroupSidebarMark: "(测试功能)",
|
|
5389
|
-
cardGroupSidebarNote: "使用中若遇问题,关掉即可回到原生;官方接口一旦开放,会第一时间改用原生实现。",
|
|
5390
6896
|
cardGroupSidebarBusy: "正在切换侧栏…",
|
|
6897
|
+
cardSwitchFailed: "该开关未保存,请重试。",
|
|
6898
|
+
cardManageWorktrees: "管理工作树…",
|
|
6899
|
+
cardManageHint: "跨仓库查看并删除全部工作树,包含从未注册为工作区的目录。",
|
|
6900
|
+
cardFetchBeforeCreateLabel: "创建工作树前同步上游",
|
|
6901
|
+
cardFetchBeforeCreateHint: "每次创建工作树前先执行 fetch --all --prune 同步远程引用;同步失败不会阻断创建。",
|
|
6902
|
+
cardAutoPruneLabel: "自动删除旧工作树",
|
|
6903
|
+
cardAutoPruneHint: "超出保留数量时,新建工作树后自动删除最久未用的(只删目录,保留分支)。有未提交改动或进行中会话的不会被删。",
|
|
6904
|
+
cardKeepWorktreesLabel: "保留工作树数量",
|
|
6905
|
+
cardKeepWorktreesHint: "所有仓库合计的全局上限,最小为 1。",
|
|
6906
|
+
cardKeepWorktreesBad: "请输入不小于 1 的整数",
|
|
6907
|
+
cardPruneHistoryLabel: "清理记录",
|
|
6908
|
+
cardPruneHistoryEmpty: "暂无清理记录",
|
|
6909
|
+
cardPruneHistoryRun: "清理了 {n} 个:",
|
|
6910
|
+
cardPruneHistoryNone: "本轮无需清理",
|
|
6911
|
+
cardPruneHistorySkipped: "{n} 个因未提交改动跳过",
|
|
6912
|
+
cardPruneHistoryFailed: "{n} 个失败",
|
|
6913
|
+
cardPruneHistoryMore: "展开全部 {n} 条",
|
|
6914
|
+
cardPruneHistoryLess: "收起",
|
|
6915
|
+
"manager.title": "管理工作树",
|
|
6916
|
+
"manager.loading": "正在扫描工作树…",
|
|
6917
|
+
"manager.loadFailed": "扫描失败:{message}",
|
|
6918
|
+
"manager.empty": "工作树存放目录暂无内容。",
|
|
6919
|
+
"manager.count": "{n} 个工作树",
|
|
6920
|
+
"manager.truncated": "目录过多,仅显示前一批。请检查存放目录是否设置正确。",
|
|
6921
|
+
"manager.countOrphans": ",{n} 个无法识别",
|
|
6922
|
+
"manager.orphans": "无法识别的目录",
|
|
6923
|
+
"manager.activityNever": "无会话",
|
|
6924
|
+
"manager.dirty.one": "{n} 个未提交文件",
|
|
6925
|
+
"manager.dirty.other": "{n} 个未提交文件",
|
|
6926
|
+
"manager.running": "有进行中的会话,暂不能删除",
|
|
6927
|
+
"manager.purgeMenu": "删除文件夹",
|
|
6928
|
+
"manager.purgeAria": "删除残留文件夹“{path}”",
|
|
6929
|
+
"worktreePurge.title": "删除残留文件夹",
|
|
6930
|
+
"worktreePurge.desc": "该目录已无 git 记录,将连同全部内容一并删除,此操作不可恢复。",
|
|
6931
|
+
"worktreePurge.busy": "正在删除文件夹…",
|
|
6932
|
+
"manager.removeAria": "删除工作树“{path}”",
|
|
6933
|
+
fetchWarning: "上游同步失败,已按本地状态创建:{message}",
|
|
6934
|
+
pruneDone: "已自动清理 {n} 个旧工作树",
|
|
6935
|
+
pruneFailed: "{n} 个工作树自动清理失败",
|
|
5391
6936
|
"group.ungrouped": "未分组",
|
|
5392
6937
|
"session.new": "新会话",
|
|
5393
6938
|
"section.workspaces": "工作区",
|
|
@@ -5505,10 +7050,92 @@ window.__ModuleLoader__.load({
|
|
|
5505
7050
|
zh,
|
|
5506
7051
|
en
|
|
5507
7052
|
}), "git-worktree: dictionaries");
|
|
5508
|
-
const chipInjected = () => ({
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
7053
|
+
const chipInjected = () => ({
|
|
7054
|
+
adoptWorktree: async (path) => {
|
|
7055
|
+
const workspace = await ctx.workspaces.create({ path });
|
|
7056
|
+
ctx.uiWorkspace.startSession(workspace.workspaceId);
|
|
7057
|
+
},
|
|
7058
|
+
pruneWorktrees: async (createdPath) => {
|
|
7059
|
+
const section = groupingScope.getSnapshot();
|
|
7060
|
+
if (section.status !== "ready") return void 0;
|
|
7061
|
+
if ((section.value?.autoPruneWorktrees ?? false) !== true) return void 0;
|
|
7062
|
+
const keep = section.value?.keepWorktrees ?? 30;
|
|
7063
|
+
const scan = await requestWorktreesAll();
|
|
7064
|
+
if (!scan.ok) return void 0;
|
|
7065
|
+
const workspaces = ctx.workspaces.list.getSnapshot();
|
|
7066
|
+
const sessions = ctx.sessions.list.getSnapshot();
|
|
7067
|
+
const archived = new Set(workspaces.archivedSessionIds);
|
|
7068
|
+
const activity = {};
|
|
7069
|
+
const workspaceIdByPath = /* @__PURE__ */ new Map();
|
|
7070
|
+
const archiveIdsByPath = /* @__PURE__ */ new Map();
|
|
7071
|
+
const exclude = /* @__PURE__ */ new Set([pathKey(createdPath)]);
|
|
7072
|
+
for (const workspace of workspaces.items) {
|
|
7073
|
+
const key = pathKey(workspace.path);
|
|
7074
|
+
workspaceIdByPath.set(key, workspace.workspaceId);
|
|
7075
|
+
const archiveIds = [];
|
|
7076
|
+
for (const sessionId of workspace.sessionIds) {
|
|
7077
|
+
const summary = sessions.byId[sessionId];
|
|
7078
|
+
if (summary === void 0) continue;
|
|
7079
|
+
if (summary.running === true) exclude.add(key);
|
|
7080
|
+
if (summary.blank || summary.origin === "subagent") continue;
|
|
7081
|
+
if (!archived.has(sessionId)) archiveIds.push(sessionId);
|
|
7082
|
+
}
|
|
7083
|
+
activity[key] = freshestUpdatedAt(workspace.sessionIds.map((id) => sessions.byId[id]));
|
|
7084
|
+
archiveIdsByPath.set(key, archiveIds);
|
|
7085
|
+
}
|
|
7086
|
+
const currentId = sessions.current;
|
|
7087
|
+
const currentCwd = currentId === void 0 ? void 0 : sessions.byId[currentId]?.cwd;
|
|
7088
|
+
if (currentCwd !== void 0) exclude.add(pathKey(currentCwd));
|
|
7089
|
+
const report = await runAutoPrune({
|
|
7090
|
+
inspectWorktree: async (path) => {
|
|
7091
|
+
const result = await requestInspectWorktree(path);
|
|
7092
|
+
if (!result.ok) throw new Error(result.error);
|
|
7093
|
+
return { dirty: result.dirty };
|
|
7094
|
+
},
|
|
7095
|
+
removeWorktree: async (path, force) => {
|
|
7096
|
+
const result = await requestRemoveWorktree(path, force);
|
|
7097
|
+
if (!result.ok) throw new Error(result.error);
|
|
7098
|
+
},
|
|
7099
|
+
probeDirectories: async (paths) => {
|
|
7100
|
+
const result = await requestPathExists(paths);
|
|
7101
|
+
return result.ok ? { exists: result.exists } : void 0;
|
|
7102
|
+
},
|
|
7103
|
+
archiveSession: (sessionId) => ctx.workspaces.archiveSession(sessionId),
|
|
7104
|
+
deleteWorkspace: (workspaceId) => ctx.workspaces.delete(workspaceId)
|
|
7105
|
+
}, planPrune({
|
|
7106
|
+
paths: scan.worktrees.filter((entry) => entry.repoName !== null).map((entry) => entry.path),
|
|
7107
|
+
activity,
|
|
7108
|
+
keep,
|
|
7109
|
+
exclude
|
|
7110
|
+
}).map((path) => {
|
|
7111
|
+
const key = pathKey(path);
|
|
7112
|
+
const workspaceId = workspaceIdByPath.get(key);
|
|
7113
|
+
return {
|
|
7114
|
+
path,
|
|
7115
|
+
force: false,
|
|
7116
|
+
...workspaceId === void 0 ? {} : { workspaceId },
|
|
7117
|
+
archiveSessionIds: archiveIdsByPath.get(key) ?? []
|
|
7118
|
+
};
|
|
7119
|
+
}));
|
|
7120
|
+
if (report.removed.length + report.skippedDirty.length + report.failed.length > 0) {
|
|
7121
|
+
const detail = new Map(scan.worktrees.map((entry) => [pathKey(entry.path), entry]));
|
|
7122
|
+
recordPruneRun({
|
|
7123
|
+
at: Date.now(),
|
|
7124
|
+
removed: report.removed.map((path) => {
|
|
7125
|
+
const entry = detail.get(pathKey(path));
|
|
7126
|
+
return {
|
|
7127
|
+
path,
|
|
7128
|
+
repoName: entry?.repoName ?? "",
|
|
7129
|
+
branch: entry?.branch ?? ""
|
|
7130
|
+
};
|
|
7131
|
+
}),
|
|
7132
|
+
skippedDirty: report.skippedDirty,
|
|
7133
|
+
failed: report.failed
|
|
7134
|
+
});
|
|
7135
|
+
}
|
|
7136
|
+
return report;
|
|
7137
|
+
}
|
|
7138
|
+
});
|
|
5512
7139
|
ctx.slots.inject("conversation.input.left", () => ctx.slots.register({
|
|
5513
7140
|
name: "conversation.input.left",
|
|
5514
7141
|
id: "git-worktree",
|
|
@@ -5702,6 +7329,54 @@ window.__ModuleLoader__.load({
|
|
|
5702
7329
|
await waitSnapshotMatches(enabled);
|
|
5703
7330
|
await syncGroupingSeat();
|
|
5704
7331
|
};
|
|
7332
|
+
const managerFace = () => ({
|
|
7333
|
+
listWorktrees: async () => {
|
|
7334
|
+
const result = await requestWorktreesAll();
|
|
7335
|
+
if (!result.ok) throw new Error(result.error);
|
|
7336
|
+
return {
|
|
7337
|
+
worktrees: result.worktrees,
|
|
7338
|
+
...result.truncated === void 0 ? {} : { truncated: result.truncated }
|
|
7339
|
+
};
|
|
7340
|
+
},
|
|
7341
|
+
inspectWorktree: async (path) => {
|
|
7342
|
+
const result = await requestInspectWorktree(path);
|
|
7343
|
+
if (!result.ok) throw new Error(result.error);
|
|
7344
|
+
return {
|
|
7345
|
+
dirty: result.dirty,
|
|
7346
|
+
ahead: result.ahead
|
|
7347
|
+
};
|
|
7348
|
+
},
|
|
7349
|
+
workspaces: () => ctx.workspaces.list.getSnapshot().items.map((workspace) => ({
|
|
7350
|
+
workspaceId: workspace.workspaceId,
|
|
7351
|
+
path: workspace.path,
|
|
7352
|
+
sessionIds: workspace.sessionIds
|
|
7353
|
+
})),
|
|
7354
|
+
sessionById: (sessionId) => {
|
|
7355
|
+
const summary = ctx.sessions.list.getSnapshot().byId[sessionId];
|
|
7356
|
+
if (summary === void 0) return void 0;
|
|
7357
|
+
return {
|
|
7358
|
+
running: summary.running,
|
|
7359
|
+
blank: summary.blank,
|
|
7360
|
+
...summary.origin === "subagent" ? { origin: "subagent" } : {},
|
|
7361
|
+
updatedAt: summary.updatedAt
|
|
7362
|
+
};
|
|
7363
|
+
},
|
|
7364
|
+
archivedSessionIds: () => ctx.workspaces.list.getSnapshot().archivedSessionIds,
|
|
7365
|
+
removeWorktree: async (path, force) => {
|
|
7366
|
+
const result = await requestRemoveWorktree(path, force);
|
|
7367
|
+
if (!result.ok) throw new Error(result.error);
|
|
7368
|
+
},
|
|
7369
|
+
probeDirectories: async (paths) => {
|
|
7370
|
+
const result = await requestPathExists(paths);
|
|
7371
|
+
return result.ok ? { exists: result.exists } : void 0;
|
|
7372
|
+
},
|
|
7373
|
+
purgeDirectory: async (path) => {
|
|
7374
|
+
const result = await requestPurgeDirectory(path);
|
|
7375
|
+
if (!result.ok) throw new Error(result.error);
|
|
7376
|
+
},
|
|
7377
|
+
archiveSession: (sessionId) => ctx.workspaces.archiveSession(sessionId),
|
|
7378
|
+
deleteWorkspace: (workspaceId) => ctx.workspaces.delete(workspaceId)
|
|
7379
|
+
});
|
|
5705
7380
|
const form = new CardForm(groupingScope, waitForGroupingSeat);
|
|
5706
7381
|
const store = form.bind();
|
|
5707
7382
|
ctx.slots.inject("settings.plugin.item", () => ctx.slots.register({
|
|
@@ -5712,7 +7387,8 @@ window.__ModuleLoader__.load({
|
|
|
5712
7387
|
inject: () => ({
|
|
5713
7388
|
hooks: { gitWorktreeCard: store },
|
|
5714
7389
|
...form.actions(),
|
|
5715
|
-
pickDirectory: () => ctx.uiWorkspace.pickDirectory()
|
|
7390
|
+
pickDirectory: () => ctx.uiWorkspace.pickDirectory(),
|
|
7391
|
+
manager: managerFace()
|
|
5716
7392
|
})
|
|
5717
7393
|
}, GitWorktreeCard));
|
|
5718
7394
|
syncGroupingSeat();
|