@laoyuehanni/dsh-git-worktree 0.4.3 → 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 +25 -41
- package/README.zh.md +25 -41
- package/lib/client.js +2735 -982
- package/lib/git.d.ts +81 -10
- package/lib/git.js +149 -18
- package/lib/index.d.ts +41 -5
- package/lib/index.js +111 -103
- 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 +30 -16
- package/lib/client.js.map +0 -1
package/lib/client.js
CHANGED
|
@@ -8,7 +8,6 @@ window.__ModuleLoader__.load({
|
|
|
8
8
|
let react_dom = require("react-dom");
|
|
9
9
|
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
10
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
|
-
let _deepseek_ai_dsh_client_runtime_client = require("@deepseek-ai/dsh-client-runtime/client");
|
|
12
11
|
//#region src/normalize.ts
|
|
13
12
|
/**
|
|
14
13
|
* Local branch name for a display name: strip the leading `<remote>/` segment
|
|
@@ -61,8 +60,15 @@ window.__ModuleLoader__.load({
|
|
|
61
60
|
const ROUTE_WORKTREE = `${ROUTE_PREFIX}/worktree`;
|
|
62
61
|
/** POST ROUTE_PREFIX/switch — in-place branch switch of the main checkout. */
|
|
63
62
|
const ROUTE_SWITCH = `${ROUTE_PREFIX}/switch`;
|
|
64
|
-
/** 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). */
|
|
65
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`;
|
|
66
72
|
/** POST ROUTE_PREFIX/fetch — sync remote-tracking refs (fetch every remote + prune). */
|
|
67
73
|
const ROUTE_FETCH = `${ROUTE_PREFIX}/fetch`;
|
|
68
74
|
/** POST ROUTE_PREFIX/update — fast-forward the current branch to its upstream. */
|
|
@@ -77,6 +83,12 @@ window.__ModuleLoader__.load({
|
|
|
77
83
|
const ROUTE_EXISTS = `${ROUTE_PREFIX}/exists`;
|
|
78
84
|
/** POST ROUTE_PREFIX/ensure-directory — mkdir -p a missing worktree storage slot. */
|
|
79
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`;
|
|
80
92
|
//#endregion
|
|
81
93
|
//#region src/client/api.ts
|
|
82
94
|
/** POST one JSON body and parse the uniform envelope. */
|
|
@@ -91,7 +103,15 @@ window.__ModuleLoader__.load({
|
|
|
91
103
|
headers: { "content-type": "application/json" },
|
|
92
104
|
body: JSON.stringify(body)
|
|
93
105
|
});
|
|
94
|
-
|
|
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
|
+
}
|
|
95
115
|
if (!response.ok) return {
|
|
96
116
|
ok: false,
|
|
97
117
|
error: payload.error ?? `HTTP ${String(response.status)}`
|
|
@@ -168,13 +188,50 @@ window.__ModuleLoader__.load({
|
|
|
168
188
|
});
|
|
169
189
|
}
|
|
170
190
|
/**
|
|
171
|
-
* Create a NEW branch from the directory's current
|
|
172
|
-
* in place.
|
|
173
|
-
*
|
|
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.
|
|
174
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.
|
|
175
200
|
*/
|
|
176
|
-
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
|
+
});
|
|
177
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, {
|
|
178
235
|
repoPath,
|
|
179
236
|
name
|
|
180
237
|
});
|
|
@@ -241,15 +298,152 @@ window.__ModuleLoader__.load({
|
|
|
241
298
|
function requestEnsureDirectory(path) {
|
|
242
299
|
return post(ROUTE_ENSURE_DIRECTORY, { path });
|
|
243
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
|
+
}
|
|
244
438
|
//#endregion
|
|
245
439
|
//#region \0git-worktree-css:D:\Code\dsh-worktree\src\client\BranchChip.module.css?inline
|
|
246
|
-
const css$3 = "/* Branch chip row inside the composer tool row (conversation.input_2006230319.left_2006230319,\n * right of the mode chips). Modeled as a single rounded-rectangle\n * segmented control: the branch picker and the worktree toggle share one\n * container with a thin divider between them, so they read as one\n * affordance instead of two loose buttons.\n *\n * Geometry mirrors the composer trigger chips in the DSH base (see\n * PermissionSelect / ModelSelect): 28px height, 13/20 medium-secondary\n * label, transparent fill, no outline 鈥?the dock stays at the same\n * visual weight as the surrounding chips (dsh-worktree select, standard\n * mode select, Workspace Write, MiniMax-M3 High). The corners stop short\n * of the base's full pill (24px) so the silhouette stays a chip rather\n * than a capsule, per the design brief. */\n\n/* Shared trigger geometry 鈥?copied 1:1 from the base composer triggers\n * (PermissionSelect .trigger_2006230319 / ModelSelect .trigger_2006230319). Centralizing here\n * keeps the two segments visually fused so the divider reads as part of\n * one component, not two loose buttons. */\n.dock_2006230319 {\n display: inline-flex;\n align-items: stretch;\n height: 28px;\n border-radius: 6px;\n background: transparent;\n color: var(--dsw-alias-label-secondary, #81858c);\n font-size: 13px;\n line-height: 20px;\n font-weight: 500;\n min-height: 28px;\n overflow: hidden;\n}\n\n/* Vertical separator between the two segments. Uses the secondary label\n * color so it stays in the same tonal family as the surrounding trigger\n * outlines and chevrons. */\n.divider_2006230319 {\n width: 1px;\n margin: 6px 0;\n background: color-mix(in srgb, currentColor 22%, transparent);\n flex-shrink: 0;\n}\n\n.chip_2006230319 {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 100%;\n padding: 0 8px 0 8px;\n border: none;\n border-radius: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n font-weight: 500;\n cursor: pointer;\n}\n\n.chip_2006230319:hover {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* The leftmost segment rounds only its left corners so it tucks into the dock. */\n.chip_2006230319:first-child {\n border-top-left-radius: 6px;\n border-bottom-left-radius: 6px;\n}\n\n/* Started sessions drop the worktree segment: the lone chip rounds all\n * corners and reads as a plain button, not a broken-off half control. */\n.chip_2006230319:only-child {\n border-radius: 6px;\n}\n\n.branch_2006230319 {\n max-width: 16em;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.check_2006230319,\n.checkOn_2006230319 {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 100%;\n padding: 0 4px 0 8px;\n border: none;\n border-radius: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n line-height: 20px;\n font-weight: 500;\n cursor: pointer;\n}\n\n.check_2006230319:hover,\n.checkOn_2006230319:hover {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* The rightmost segment rounds only its right corners. */\n.check_2006230319:last-child,\n.checkOn_2006230319:last-child {\n border-top-right-radius: 6px;\n border-bottom-right-radius: 6px;\n}\n\n.box_2006230319 {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n border: 1px solid color-mix(in srgb, currentColor 45%, transparent);\n border-radius: 4px;\n}\n\n/* Selected worktree: only the checkbox itself turns bluish and fills 鈥?the\n * surrounding button stays transparent so the label keeps the same\n * secondary tone. Mirrors the Claude Code toggle treatment. The inner\n * check rides the bluish fill with an inverted foreground token so the\n * glyph stays legible. */\n.checkOn_2006230319 .box_2006230319 {\n border-color: var(--dsw-alias-label-primary-bluish, #4186f0);\n background: var(--dsw-alias-label-primary-bluish, #4186f0);\n color: var(--dsw-alias-label-primary-foreground, #ffffff);\n}\n\n.checkLabel_2006230319 {\n white-space: nowrap;\n}\n\n/* Confirm flyout: the second-level panel opening right of the branch\n * card (the base Menu's submenu posture: r12, inverted hairline,\n * shadow-lv3, --dsw-specific-menu). Width is content-driven — it follows\n * the longest line (for remote picks that is the subject line's branch\n * name) — floored at 168px (the Cancel/Confirm pair plus padding: short\n * branch names must not squeeze the buttons into wrapping \"切换中…\"\n * mid-word) and capped at 400px; BranchMenu also clamps it inline to the\n * room right of the card. Beyond the cap the lines wrap. border-box so\n * every width arm includes the card chrome. */\n.popCard_2006230319 {\n box-sizing: border-box;\n position: fixed;\n z-index: 1000;\n width: max-content;\n min-width: 168px;\n max-width: min(400px, 80vw);\n padding: 4px;\n border: 1px solid var(--dsw-alias-border-inverted);\n border-radius: 12px;\n background: var(--dsw-specific-menu, var(--dsw-alias-surface-raised, #ffffff));\n box-shadow: var(--dsw-shadow-lv3);\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.popAsk_2006230319 {\n margin: 0;\n padding: 6px 8px;\n font-size: 13px;\n line-height: 20px;\n color: inherit;\n /* Branch names are long unbroken tokens — plain wrapping would let them\n * overflow the capped card instead of breaking. */\n overflow-wrap: anywhere;\n}\n\n/* Remote confirm's name line: the branch itself, weight 500 like the leaf\n * rows — the subject the ask line refers to (\"该远程分支\"). A dedicated\n * line keeps the long unbroken token away from the sentence, so wraps\n * happen inside the name instead of shredding the Chinese around it. */\n.popSubject_2006230319 {\n margin: 0;\n padding: 0 8px 2px;\n font-size: 13px;\n line-height: 20px;\n font-weight: 500;\n color: inherit;\n overflow-wrap: anywhere;\n}\n\n.popActions_2006230319 {\n display: flex;\n gap: 2px;\n padding: 2px;\n}\n\n/* Menu-row-like buttons: transparent fill, hover tint, same 13px type.\n * nowrap keeps labels like 切换中… from splitting mid-word when the flyout\n * is pinned to its minimum width by a short branch name. */\n.popActions_2006230319 button {\n flex: 1 1 0;\n height: 28px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n white-space: nowrap;\n cursor: pointer;\n}\n\n.popActions_2006230319 button:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.popActions_2006230319 button:disabled {\n opacity: 0.5;\n cursor: default;\n}\n\n.popActions_2006230319 button:last-child {\n color: var(--dsw-alias-label-primary-bluish, #4186f0);\n font-weight: 500;\n}\n\n/* ── Branch picker popup (BranchMenu) ──────────────────────────────\n * Upward-opening card pinned above the chip, in the Menu's card chrome\n * (r12, inverted hairline, shadow-lv3, --dsw-specific-menu — same family\n * as .popCard_2006230319). Three owner requirements shape the geometry:\n *\n * 1. height cap: min(420px, 60vh) on the card, only the rows area\n * scrolls (.menuRows_2006230319) — heading and search stay pinned;\n * 2. the search field sits pinned at the card's bottom edge, directly\n * above the chip, with the scrolling rows above it;\n * 3. the card is CSS-`bottom`-pinned ~6px above the chip's top and so\n * grows entirely upward — it can never cover the composer or fill\n * the viewport, whatever the branch count.\n *\n * The inline `left`/`bottom` come from BranchMenu's placement pass; the\n * width is fixed here (design 360px — 320 tree + 40 tool strip — and\n * viewport-capped) so horizontal clamping stays deterministic without\n * measuring the card. */\n\n/* The portal lands directly under document.body_2006230319, outside the shell's\n * box-sizing reset — content-box default would add padding/border on top\n * of the declared width (360 became 370, and the width:100% children\n * padded 16px past the card's right clip, shearing off their rounded\n * corners). Every width-declared box in this popup opts back into\n * border-box: the card, the toolbar, the rows, and the search input. */\n.menuCard_2006230319 {\n box-sizing: border-box;\n position: fixed;\n z-index: 1000;\n display: flex;\n flex-direction: row;\n width: min(360px, calc(100vw - 24px));\n max-height: min(420px, 60vh);\n overflow: hidden;\n padding: 4px;\n border: 1px solid var(--dsw-alias-border-inverted);\n border-radius: 12px;\n background: var(--dsw-specific-menu, var(--dsw-alias-surface-raised, #ffffff));\n box-shadow: var(--dsw-shadow-lv3);\n}\n\n/* Left tool strip (IDEA branch-panel posture at popup scale): a narrow\n * column of icon-only buttons for actions that do not belong in the tree\n * — locate the checked-out branch, expand/collapse the whole tree.\n * Buttons stack from the BOTTOM up: the card's height shrinks when the\n * repo has few branches, so a top-anchored strip would drift around and\n * the buttons would sit far from the search bar; anchoring to the bottom\n * pins them at a stable spot (beside the search row) whatever the height. */\n.menuToolbar_2006230319 {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n gap: 2px;\n flex-shrink: 0;\n width: 32px;\n padding: 0 2px;\n margin-right: 4px;\n border-right: 1px solid color-mix(in srgb, currentColor 12%, transparent);\n}\n\n.menuToolButton_2006230319 {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n margin: 0 auto;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n cursor: pointer;\n}\n\n.menuToolButton_2006230319:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n.menuToolButton_2006230319:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n/* The sync tools while their action runs: a soft opacity pulse. The glyph\n * is a directional arrow, so the circular-refresh spin read as garbled\n * rotation — pulsing keeps the arrow legible while clearly \"live\", and the\n * button keeps full opacity (the usual disabled dim would read as broken\n * for an in-flight network operation). */\n.menuToolButtonRunning_2006230319 svg {\n animation: menuToolPulse 700ms ease-in-out infinite alternate;\n}\n\n.menuToolButtonRunning_2006230319:disabled {\n opacity: 1;\n cursor: progress;\n}\n\n@keyframes menuToolPulse {\n from { opacity: 1; }\n to { opacity: 0.25; }\n}\n\n/* The main column: heading + scrollable rows + pinned search. */\n.menuMain_2006230319 {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n min-width: 0;\n}\n\n/* Non-interactive group heading — the Menu label row's posture. */\n.menuHeading_2006230319 {\n padding: 6px 8px 4px;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary, #81858c);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n flex-shrink: 0;\n}\n\n/* The only scrollable region: shrinks within the capped card so the\n * heading above and the search below stay visible while rows scroll. */\n.menuRows_2006230319 {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n}\n\n/* Menu-row-like buttons: transparent fill, hover tint, same 13px type.\n * Weight 500 mirrors the chip's branch label (the portal escapes the\n * composer's font context, so the match must be explicit — the inherited\n * body weight is 400 and reads visibly lighter than the chip beside it). */\n.menuRow_2006230319 {\n box-sizing: border-box; /* width:100% + padding must stay inside .menuRows_2006230319 */\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n min-height: 28px;\n padding: 4px 8px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n font-weight: 500;\n line-height: 20px;\n text-align: left;\n cursor: pointer;\n}\n\n.menuRow_2006230319:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* Locked rows (a linked-worktree session answers every non-current pick\n * with the main-checkout toast): dimmed with a default cursor, but KEEP\n * the click path alive — no disabled attribute, the double-click is the\n * toast's stage. Hover stays quiet: nothing is on offer here. */\n.menuRowLocked_2006230319 {\n opacity: 0.45;\n cursor: default;\n}\n\n.menuRowLocked_2006230319:hover {\n background: transparent;\n}\n\n/* The checked-out branch: a persistent tint a step above the resting rows\n * so it reads as \"you are here\" the moment the list scrolls it into view\n * (BranchMenu centers it on open) — the trailing check alone is easy to\n * miss from a distance. */\n.menuRowSelected_2006230319,\n.menuRowSelected_2006230319:hover:not(:disabled) {\n background: color-mix(in srgb, currentColor 10%, transparent);\n}\n\n/* IDEA-style selection: the clicked row gets a bluish fill, layering over\n * the HEAD tint when the same row is both — selection communicates intent,\n * the HEAD tint communicates position, and they coexist (IDEA 4.4). */\n.menuRowPicked_2006230319,\n.menuRowPicked_2006230319:hover:not(:disabled) {\n background: color-mix(in srgb, var(--dsw-alias-label-primary-bluish, #4186f0) 18%, transparent);\n}\n\n.menuRowLabel_2006230319 {\n flex: 1 1 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* Upstream divergence arrows (↑N/↓N) trailing a local branch row, before\n * the HEAD check: the count badge tone at a smaller size so a busy list\n * still reads the name first. Plain text arrows — no base-set icon pairs\n * a direction with a count. tabular-nums keeps ↑10 from nudging neighbors\n * as the digits tick. */\n.menuRowArrow_2006230319 {\n flex-shrink: 0;\n font-size: 11px;\n line-height: 20px;\n font-weight: 400;\n font-variant-numeric: tabular-nums;\n color: color-mix(in srgb, currentColor 55%, transparent);\n}\n\n/* Search hit highlight (IDEA): the matched substring gets a warm tint\n * behind it — theme-agnostic, legible in both light and dark cards. */\n.menuSearchMark_2006230319 {\n background: color-mix(in srgb, #b58900 38%, transparent);\n border-radius: 2px;\n}\n\n/* Tree group rows (folder headers) — BranchMenu's '/' prefix tree: the\n * same row geometry as .menuRow_2006230319, but labeled in the secondary tone so the\n * leaf rows pop, with a count badge and a chevron that turns on expand. */\n.menuGroup_2006230319 {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: 6px;\n width: 100%;\n min-height: 28px;\n padding: 4px 8px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: var(--dsw-alias-label-secondary, #81858c);\n font: inherit;\n font-size: 13px;\n font-weight: 500;\n line-height: 20px;\n text-align: left;\n cursor: pointer;\n}\n\n.menuGroup_2006230319:hover {\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* The two top-level section headers (local/remote branches) step ABOVE the\n * folder headers they contain: primary label tone like the leaf rows plus\n * a heavier weight, so the nav hierarchy reads group > row > folder — the\n * folder headers keep the secondary tone that alone would leave the\n * sections as the faintest (and most important) rows on the list. */\n.menuGroupTop_2006230319 {\n color: inherit;\n font-weight: 600;\n}\n\n.menuGroupLabel_2006230319 {\n flex: 1 1 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.menuGroupChevron_2006230319 {\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 12px;\n height: 12px;\n transition: transform 120ms ease;\n}\n\n.menuGroupChevronOpen_2006230319 {\n transform: rotate(90deg);\n}\n\n.menuGroupCount_2006230319 {\n flex-shrink: 0;\n font-size: 12px;\n line-height: 20px;\n font-weight: 400;\n color: color-mix(in srgb, currentColor 55%, transparent);\n}\n\n/* Zero-search-hit state: centered secondary line inside the rows area. */\n.menuEmpty_2006230319 {\n padding: 10px 8px;\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary, #81858c);\n text-align: center;\n}\n\n/* Bottom-pinned search field, separated from the rows by a hairline.\n * Borderless so it reads as part of the card, focus shown as the\n * standard hover tint rather than an outline. */\n.menuSearchWrap_2006230319 {\n flex-shrink: 0;\n margin-top: 2px;\n padding-top: 4px;\n border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent);\n}\n\n.menuSearch_2006230319 {\n box-sizing: border-box; /* width:100% + padding must stay inside the wrap */\n width: 100%;\n height: 30px;\n padding: 0 8px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n /* Weight 500 mirrors the chip's branch label (see .menuRow_2006230319) — the portal\n * escapes the composer's font context and would inherit body's 400. */\n font-weight: 500;\n line-height: 20px;\n}\n\n.menuSearch_2006230319::placeholder {\n color: var(--dsw-alias-label-secondary, #81858c);\n}\n\n.menuSearch_2006230319:focus {\n outline: none;\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n/* ── New-branch create flyout (BranchMenu toolbar plus) ─────────────\n * Opens to the RIGHT of the card (the confirm flyout's posture) and holds\n * the whole flow in one panel: ask line, naming input, live hint, and the\n * Cancel/Create pair — typing the name and pressing Create fires the\n * create in one stroke, no second confirm step. */\n\n/* The toolbar plus in its active (flyout open) state: a bluish tint\n * layering the same way the picked row does, so the toggled state reads at\n * a glance. */\n.menuToolButtonOn_2006230319,\n.menuToolButtonOn_2006230319:hover:not(:disabled) {\n background: color-mix(in srgb, var(--dsw-alias-label-primary-bluish, #4186f0) 18%, transparent);\n color: var(--dsw-alias-label-primary-bluish, #4186f0);\n}\n\n/* The naming input inside the flyout: borderless, part of the card, focus\n * shown as the standard hover tint. Fixed width — the popCard is\n * max-content, so a percentage width would chase the input's own default\n * size instead of the design width. */\n.menuCreate_2006230319 {\n box-sizing: border-box;\n width: 248px;\n height: 30px;\n padding: 0 8px;\n border: none;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n font: inherit;\n font-size: 13px;\n /* Weight 500 mirrors the chip's branch label (see .menuSearch_2006230319). */\n font-weight: 500;\n line-height: 20px;\n}\n\n.menuCreate_2006230319::placeholder {\n color: var(--dsw-alias-label-secondary, #81858c);\n}\n\n.menuCreate_2006230319:focus {\n outline: none;\n background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 8%, transparent));\n}\n\n.menuCreate_2006230319:disabled {\n opacity: 0.5;\n}\n\n/* The error line under the input — only rendered while the draft is\n * unacceptable with a non-empty reason; the input itself stays neutral,\n * the line carries the state. */\n.menuCreateHintBad_2006230319 {\n margin: 0;\n padding: 0 8px;\n font-size: 12px;\n line-height: 16px;\n color: var(--dsw-alias-label-error);\n}\n";
|
|
247
|
-
const tagId$
|
|
248
|
-
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) {
|
|
249
443
|
const tag = document.createElement("style");
|
|
250
444
|
tag.dataset.plugin = "@laoyuehanni/dsh-git-worktree";
|
|
251
|
-
tag.dataset.pluginCss = tagId$
|
|
252
|
-
tag.textContent = css$
|
|
445
|
+
tag.dataset.pluginCss = tagId$4;
|
|
446
|
+
tag.textContent = css$4;
|
|
253
447
|
document.head.appendChild(tag);
|
|
254
448
|
}
|
|
255
449
|
var BranchChip_module_default = {
|
|
@@ -257,13 +451,8 @@ window.__ModuleLoader__.load({
|
|
|
257
451
|
"left": "left_2006230319",
|
|
258
452
|
"trigger": "trigger_2006230319",
|
|
259
453
|
"dock": "dock_2006230319",
|
|
260
|
-
"divider": "divider_2006230319",
|
|
261
454
|
"chip": "chip_2006230319",
|
|
262
455
|
"branch": "branch_2006230319",
|
|
263
|
-
"check": "check_2006230319",
|
|
264
|
-
"checkOn": "checkOn_2006230319",
|
|
265
|
-
"box": "box_2006230319",
|
|
266
|
-
"checkLabel": "checkLabel_2006230319",
|
|
267
456
|
"popCard": "popCard_2006230319",
|
|
268
457
|
"popAsk": "popAsk_2006230319",
|
|
269
458
|
"popSubject": "popSubject_2006230319",
|
|
@@ -277,7 +466,6 @@ window.__ModuleLoader__.load({
|
|
|
277
466
|
"menuMain": "menuMain_2006230319",
|
|
278
467
|
"menuHeading": "menuHeading_2006230319",
|
|
279
468
|
"menuRow": "menuRow_2006230319",
|
|
280
|
-
"menuRowLocked": "menuRowLocked_2006230319",
|
|
281
469
|
"menuRowSelected": "menuRowSelected_2006230319",
|
|
282
470
|
"menuRowPicked": "menuRowPicked_2006230319",
|
|
283
471
|
"menuRowLabel": "menuRowLabel_2006230319",
|
|
@@ -292,9 +480,12 @@ window.__ModuleLoader__.load({
|
|
|
292
480
|
"menuEmpty": "menuEmpty_2006230319",
|
|
293
481
|
"menuSearchWrap": "menuSearchWrap_2006230319",
|
|
294
482
|
"menuSearch": "menuSearch_2006230319",
|
|
295
|
-
"menuToolButtonOn": "menuToolButtonOn_2006230319",
|
|
296
483
|
"menuCreate": "menuCreate_2006230319",
|
|
297
|
-
"menuCreateHintBad": "menuCreateHintBad_2006230319"
|
|
484
|
+
"menuCreateHintBad": "menuCreateHintBad_2006230319",
|
|
485
|
+
"ctxCard": "ctxCard_2006230319",
|
|
486
|
+
"ctxHeader": "ctxHeader_2006230319",
|
|
487
|
+
"ctxItem": "ctxItem_2006230319",
|
|
488
|
+
"ctxItemLabel": "ctxItemLabel_2006230319"
|
|
298
489
|
};
|
|
299
490
|
//#endregion
|
|
300
491
|
//#region src/client/BranchMenu.tsx
|
|
@@ -302,8 +493,9 @@ window.__ModuleLoader__.load({
|
|
|
302
493
|
* BranchMenu: the branch picker popup anchored to the composer branch chip.
|
|
303
494
|
* The base Menu primitive exposes neither a height cap nor a search field,
|
|
304
495
|
* so with many branches its portal list fills the viewport — this popup
|
|
305
|
-
* replaces it with an owner-styled card: Menu's card chrome (
|
|
306
|
-
* hairline,
|
|
496
|
+
* replaces it with an owner-styled card: Menu's card chrome (r20,
|
|
497
|
+
* elevation-prominent hairline, --dsw-specific-menu, see .menuCard;
|
|
498
|
+
* hosts without the token fall back to shadow-lv3) on a
|
|
307
499
|
* portal-fixed posture, with owner requirements baked in:
|
|
308
500
|
*
|
|
309
501
|
* 1. the card is capped at min(420px, 60vh) and only the branch rows
|
|
@@ -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
|
-
*
|
|
1677
|
-
*
|
|
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).
|
|
2204
|
+
*
|
|
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}.)
|
|
1678
2212
|
*
|
|
1679
|
-
*
|
|
1680
|
-
*
|
|
1681
|
-
*
|
|
1682
|
-
*
|
|
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,11 +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({
|
|
1826
|
-
const
|
|
2392
|
+
function BranchChipDock({ sessionId, useSessions, useSession, adoptWorktree, pruneWorktrees, t }) {
|
|
2393
|
+
const summary = useSessions((state) => state.byId[sessionId]);
|
|
2394
|
+
const session = useSession((s) => s);
|
|
2395
|
+
const cwd = summary?.cwd;
|
|
1827
2396
|
const [repo, refresh] = useRepoStatus(cwd);
|
|
1828
2397
|
const [menuOpen, setMenuOpen] = (0, react.useState)(false);
|
|
1829
|
-
const [worktreeMode, setWorktreeMode] = (0, react.useState)(false);
|
|
1830
2398
|
const [confirm, setConfirm] = (0, react.useState)(null);
|
|
1831
2399
|
const [busy, setBusy] = (0, react.useState)(false);
|
|
1832
2400
|
/** Which arrow is spinning: fetch and update are single-flight against
|
|
@@ -1834,19 +2402,29 @@ window.__ModuleLoader__.load({
|
|
|
1834
2402
|
* per-tool — one shared flag made both arrows rotate at once. */
|
|
1835
2403
|
const [fetchBusy, setFetchBusy] = (0, react.useState)(false);
|
|
1836
2404
|
const [updateBusy, setUpdateBusy] = (0, react.useState)(false);
|
|
1837
|
-
|
|
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
|
+
}, []);
|
|
1838
2420
|
const chipRef = (0, react.useRef)(null);
|
|
1839
2421
|
const busyRef = (0, react.useRef)(false);
|
|
1840
2422
|
(0, react.useEffect)(() => {
|
|
1841
|
-
setWorktreeMode(false);
|
|
1842
2423
|
setConfirm(null);
|
|
1843
2424
|
setMenuOpen(false);
|
|
1844
2425
|
}, [cwd]);
|
|
1845
2426
|
(0, react.useEffect)(() => {
|
|
1846
|
-
if (!session.blank)
|
|
1847
|
-
setWorktreeMode(false);
|
|
1848
|
-
setConfirm((current) => current !== null && current.kind !== "switch" ? null : current);
|
|
1849
|
-
}
|
|
2427
|
+
if (!session.blank) setConfirm(null);
|
|
1850
2428
|
}, [session.blank]);
|
|
1851
2429
|
(0, react.useEffect)(() => {
|
|
1852
2430
|
const refreshIfIdle = () => {
|
|
@@ -1864,13 +2442,13 @@ window.__ModuleLoader__.load({
|
|
|
1864
2442
|
};
|
|
1865
2443
|
}, [refresh]);
|
|
1866
2444
|
const showError = (0, react.useCallback)((message) => {
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
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) => {
|
|
1874
2452
|
if (busyRef.current) return;
|
|
1875
2453
|
busyRef.current = true;
|
|
1876
2454
|
setBusy(true);
|
|
@@ -1882,30 +2460,57 @@ window.__ModuleLoader__.load({
|
|
|
1882
2460
|
return;
|
|
1883
2461
|
}
|
|
1884
2462
|
setConfirm(null);
|
|
1885
|
-
setMenuOpen(false);
|
|
2463
|
+
if (!keepOpen) setMenuOpen(false);
|
|
2464
|
+
onSettled?.();
|
|
1886
2465
|
}, [showError]);
|
|
1887
2466
|
/** In-place switch flow: POST /switch, then refetch the status. */
|
|
1888
|
-
const doSwitch = (0, react.useCallback)((branch) => runGuarded(async () => {
|
|
2467
|
+
const doSwitch = (0, react.useCallback)((branch, keepOpen = false) => runGuarded(async () => {
|
|
1889
2468
|
if (cwd === void 0) return "no session directory";
|
|
1890
2469
|
const result = await requestSwitch(cwd, branch);
|
|
1891
2470
|
if (!result.ok) return result.error;
|
|
1892
2471
|
await refresh();
|
|
1893
|
-
}), [
|
|
2472
|
+
}, keepOpen), [
|
|
1894
2473
|
cwd,
|
|
1895
2474
|
refresh,
|
|
1896
2475
|
runGuarded
|
|
1897
2476
|
]);
|
|
1898
|
-
/** Create-branch flow: POST /branch (
|
|
1899
|
-
*
|
|
1900
|
-
*
|
|
1901
|
-
*
|
|
1902
|
-
*
|
|
1903
|
-
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 () => {
|
|
1904
2483
|
if (cwd === void 0) return "no session directory";
|
|
1905
|
-
const result = await requestCreateBranch(cwd, name);
|
|
2484
|
+
const result = await requestCreateBranch(cwd, name, from, checkout);
|
|
1906
2485
|
if (!result.ok) return result.error;
|
|
1907
2486
|
await refresh();
|
|
1908
|
-
}), [
|
|
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), [
|
|
1909
2514
|
cwd,
|
|
1910
2515
|
refresh,
|
|
1911
2516
|
runGuarded
|
|
@@ -1935,12 +2540,10 @@ window.__ModuleLoader__.load({
|
|
|
1935
2540
|
return;
|
|
1936
2541
|
}
|
|
1937
2542
|
await refresh();
|
|
1938
|
-
|
|
1939
|
-
seq: Date.now(),
|
|
1940
|
-
text: t("fetchDone")
|
|
1941
|
-
});
|
|
2543
|
+
pushToast(t("fetchDone"));
|
|
1942
2544
|
}, [
|
|
1943
2545
|
cwd,
|
|
2546
|
+
pushToast,
|
|
1944
2547
|
refresh,
|
|
1945
2548
|
showError,
|
|
1946
2549
|
t
|
|
@@ -1967,18 +2570,16 @@ window.__ModuleLoader__.load({
|
|
|
1967
2570
|
return;
|
|
1968
2571
|
}
|
|
1969
2572
|
await refresh();
|
|
1970
|
-
|
|
1971
|
-
seq: Date.now(),
|
|
1972
|
-
text: result.updated ? t("updateDone", { branch: result.branch }) : t("updateUpToDate")
|
|
1973
|
-
});
|
|
2573
|
+
pushToast(result.updated ? t("updateDone", { branch: result.branch }) : t("updateUpToDate"));
|
|
1974
2574
|
}, [
|
|
1975
2575
|
cwd,
|
|
2576
|
+
pushToast,
|
|
1976
2577
|
refresh,
|
|
1977
2578
|
showError,
|
|
1978
2579
|
t
|
|
1979
2580
|
]);
|
|
1980
2581
|
/** Worktree-group flow: hop the session into the EXISTING worktree
|
|
1981
|
-
* directory. No git action, no confirm — the
|
|
2582
|
+
* directory. No git action, no confirm — the row menu's hop IS the jump
|
|
1982
2583
|
* (a directory jump is reversible and touches nothing), and the owner's
|
|
1983
2584
|
* adoptWorktree registers the folder and opens a blank session there. */
|
|
1984
2585
|
const doAdoptWorktree = (0, react.useCallback)((path) => {
|
|
@@ -1995,7 +2596,10 @@ window.__ModuleLoader__.load({
|
|
|
1995
2596
|
});
|
|
1996
2597
|
}, [adoptWorktree, showError]);
|
|
1997
2598
|
/** Worktree flow: POST /worktree (create-or-reuse, or cut out a new
|
|
1998
|
-
* 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. */
|
|
1999
2603
|
const doWorktree = (0, react.useCallback)((branch, cutout, name) => runGuarded(async () => {
|
|
2000
2604
|
if (cwd === void 0) return "no session directory";
|
|
2001
2605
|
const result = cutout ? await requestWorktreeCutout(cwd, branch, name) : await requestWorktree(cwd, branch);
|
|
@@ -2005,30 +2609,27 @@ window.__ModuleLoader__.load({
|
|
|
2005
2609
|
} catch (cause) {
|
|
2006
2610
|
return cause instanceof Error ? cause.message : String(cause);
|
|
2007
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(() => {});
|
|
2008
2618
|
}), [
|
|
2009
2619
|
adoptWorktree,
|
|
2620
|
+
pruneWorktrees,
|
|
2010
2621
|
cwd,
|
|
2011
|
-
|
|
2622
|
+
pushToast,
|
|
2623
|
+
runGuarded,
|
|
2624
|
+
t
|
|
2012
2625
|
]);
|
|
2013
2626
|
const facts = repo.facts;
|
|
2014
|
-
const inLinkedWorktree = facts !== null && facts.
|
|
2627
|
+
const inLinkedWorktree = facts !== null && !facts.main;
|
|
2015
2628
|
const rows = (0, react.useMemo)(() => {
|
|
2016
2629
|
if (facts === null) return [];
|
|
2017
|
-
if (inLinkedWorktree
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
name: current.name,
|
|
2021
|
-
kind: "local",
|
|
2022
|
-
...current.ahead === void 0 ? {} : { ahead: current.ahead },
|
|
2023
|
-
...current.behind === void 0 ? {} : { behind: current.behind }
|
|
2024
|
-
}];
|
|
2025
|
-
}
|
|
2026
|
-
return buildBranchRows(facts.branches, facts.worktrees, facts.currentBranch, inLinkedWorktree);
|
|
2027
|
-
}, [
|
|
2028
|
-
facts,
|
|
2029
|
-
inLinkedWorktree,
|
|
2030
|
-
session.blank
|
|
2031
|
-
]);
|
|
2630
|
+
if (inLinkedWorktree) return buildLinkedWorktreeRows(facts.branches, facts.worktrees, facts.currentBranch);
|
|
2631
|
+
return buildBranchRows(facts.branches, facts.worktrees);
|
|
2632
|
+
}, [facts, inLinkedWorktree]);
|
|
2032
2633
|
const localNames = (0, react.useMemo)(() => rows.filter((row) => row.kind !== "remote").map((row) => row.name), [rows]);
|
|
2033
2634
|
if (facts === null) return null;
|
|
2034
2635
|
const confirmLocalName = confirm === null ? "" : localBranchName(confirm.branch);
|
|
@@ -2040,30 +2641,42 @@ window.__ModuleLoader__.load({
|
|
|
2040
2641
|
const cutoutHint = cutoutDuplicate ? t("menuNewBranchExists") : cutoutIssue !== null && cutoutIssue !== "empty" ? t("menuNewBranchBad") : void 0;
|
|
2041
2642
|
const existingWorktree = confirm === null || confirm.kind !== "worktree" ? void 0 : facts.worktrees.find((w) => w.branch === confirmLocalName);
|
|
2042
2643
|
/** One confirm bundle shared by the menu flyout and the standalone
|
|
2043
|
-
* dialog (whichever is showing).
|
|
2044
|
-
*
|
|
2045
|
-
*
|
|
2046
|
-
*
|
|
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. */
|
|
2047
2649
|
const confirmBundle = confirm === null ? null : {
|
|
2048
|
-
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 }),
|
|
2049
2651
|
...confirm.remote === true ? { subject: confirm.branch } : {},
|
|
2050
|
-
confirmLabel: busy ? confirm.kind === "
|
|
2652
|
+
confirmLabel: busy ? confirm.kind === "delete" ? t("deleteBranchBusy") : t("worktreeBusy") : t("actionConfirm"),
|
|
2051
2653
|
cancelLabel: t("actionCancel"),
|
|
2052
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
|
+
} : {},
|
|
2053
2667
|
onConfirm: () => {
|
|
2054
|
-
if (confirm.kind === "
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
} 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);
|
|
2058
2671
|
},
|
|
2059
2672
|
onCancel: () => {
|
|
2060
2673
|
if (!busy) setConfirm(null);
|
|
2061
2674
|
}
|
|
2062
2675
|
};
|
|
2063
2676
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
2064
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
2677
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2065
2678
|
className: BranchChip_module_default.dock,
|
|
2066
|
-
children:
|
|
2679
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2067
2680
|
ref: chipRef,
|
|
2068
2681
|
type: "button",
|
|
2069
2682
|
className: BranchChip_module_default.chip,
|
|
@@ -2078,34 +2691,7 @@ window.__ModuleLoader__.load({
|
|
|
2078
2691
|
className: BranchChip_module_default.branch,
|
|
2079
2692
|
children: displayBranch(facts.currentBranch)
|
|
2080
2693
|
})]
|
|
2081
|
-
})
|
|
2082
|
-
className: BranchChip_module_default.divider,
|
|
2083
|
-
"aria-hidden": "true"
|
|
2084
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2085
|
-
type: "button",
|
|
2086
|
-
className: worktreeMode ? BranchChip_module_default.checkOn : BranchChip_module_default.check,
|
|
2087
|
-
onClick: () => {
|
|
2088
|
-
const next = !worktreeMode;
|
|
2089
|
-
setWorktreeMode(next);
|
|
2090
|
-
setMenuOpen(false);
|
|
2091
|
-
if (next) {
|
|
2092
|
-
setConfirm({
|
|
2093
|
-
kind: "worktree-cutout",
|
|
2094
|
-
branch: facts.currentBranch,
|
|
2095
|
-
draft: firstFreeCutoutName(localBranchName(facts.currentBranch), localNames)
|
|
2096
|
-
});
|
|
2097
|
-
if (!busyRef.current) refresh();
|
|
2098
|
-
} else setConfirm(null);
|
|
2099
|
-
},
|
|
2100
|
-
title: t("worktreeToggle"),
|
|
2101
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2102
|
-
className: BranchChip_module_default.box,
|
|
2103
|
-
children: worktreeMode ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorktreeCheck, { size: 10 }) : null
|
|
2104
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2105
|
-
className: BranchChip_module_default.checkLabel,
|
|
2106
|
-
children: t("chipWorktree")
|
|
2107
|
-
})]
|
|
2108
|
-
})] })]
|
|
2694
|
+
})
|
|
2109
2695
|
}),
|
|
2110
2696
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BranchMenu, {
|
|
2111
2697
|
open: menuOpen,
|
|
@@ -2113,11 +2699,35 @@ window.__ModuleLoader__.load({
|
|
|
2113
2699
|
rows,
|
|
2114
2700
|
currentBranch: facts.currentBranch,
|
|
2115
2701
|
confirm: confirmBundle,
|
|
2116
|
-
canCreate: !
|
|
2117
|
-
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
|
+
},
|
|
2118
2719
|
busy,
|
|
2119
|
-
onCreate: (name) => {
|
|
2120
|
-
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
|
+
});
|
|
2121
2731
|
},
|
|
2122
2732
|
onFetch: () => {
|
|
2123
2733
|
doFetch();
|
|
@@ -2129,19 +2739,7 @@ window.__ModuleLoader__.load({
|
|
|
2129
2739
|
updateBusy,
|
|
2130
2740
|
onSelect: (branch) => {
|
|
2131
2741
|
if (branch === facts.currentBranch) {
|
|
2132
|
-
|
|
2133
|
-
kind: "worktree-cutout",
|
|
2134
|
-
branch,
|
|
2135
|
-
draft: firstFreeCutoutName(localBranchName(branch), localNames)
|
|
2136
|
-
});
|
|
2137
|
-
else setMenuOpen(false);
|
|
2138
|
-
return;
|
|
2139
|
-
}
|
|
2140
|
-
if (inLinkedWorktree) {
|
|
2141
|
-
setToast({
|
|
2142
|
-
seq: Date.now(),
|
|
2143
|
-
text: t("mainRepoOnly")
|
|
2144
|
-
});
|
|
2742
|
+
setMenuOpen(false);
|
|
2145
2743
|
return;
|
|
2146
2744
|
}
|
|
2147
2745
|
const row = rows.find((r) => r.name === branch);
|
|
@@ -2149,12 +2747,7 @@ window.__ModuleLoader__.load({
|
|
|
2149
2747
|
doAdoptWorktree(row.path);
|
|
2150
2748
|
return;
|
|
2151
2749
|
}
|
|
2152
|
-
|
|
2153
|
-
setConfirm({
|
|
2154
|
-
kind: worktreeMode ? "worktree" : "switch",
|
|
2155
|
-
branch,
|
|
2156
|
-
remote
|
|
2157
|
-
});
|
|
2750
|
+
doSwitch(branch, true);
|
|
2158
2751
|
},
|
|
2159
2752
|
onClose: () => {
|
|
2160
2753
|
setMenuOpen(false);
|
|
@@ -2175,18 +2768,19 @@ window.__ModuleLoader__.load({
|
|
|
2175
2768
|
...isCutout && !cutoutValid ? { draftInvalid: true } : {},
|
|
2176
2769
|
...cutoutHint === void 0 ? {} : { draftHint: cutoutHint }
|
|
2177
2770
|
}),
|
|
2178
|
-
|
|
2179
|
-
text:
|
|
2771
|
+
toasts[0] !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
|
|
2772
|
+
text: toasts[0].text,
|
|
2180
2773
|
onDone: () => {
|
|
2181
|
-
|
|
2774
|
+
setToasts((queue) => queue.slice(1));
|
|
2182
2775
|
}
|
|
2183
|
-
},
|
|
2776
|
+
}, toasts[0].seq)
|
|
2184
2777
|
] });
|
|
2185
2778
|
}
|
|
2186
2779
|
//#endregion
|
|
2187
2780
|
//#region src/client/card-form.ts
|
|
2188
|
-
/** The
|
|
2781
|
+
/** The fields this card edits. */
|
|
2189
2782
|
const ROOT_FIELD = "rootDir";
|
|
2783
|
+
const KEEP_FIELD = "keepWorktrees";
|
|
2190
2784
|
/**
|
|
2191
2785
|
* Stages the settings edit over the `git-worktree` scope.
|
|
2192
2786
|
*
|
|
@@ -2204,10 +2798,12 @@ window.__ModuleLoader__.load({
|
|
|
2204
2798
|
snapshotValue;
|
|
2205
2799
|
listeners = /* @__PURE__ */ new Set();
|
|
2206
2800
|
draft;
|
|
2801
|
+
keepDraft;
|
|
2207
2802
|
saving = false;
|
|
2208
2803
|
failed = false;
|
|
2209
2804
|
groupingPending = false;
|
|
2210
2805
|
groupingDraft;
|
|
2806
|
+
switchFailed = null;
|
|
2211
2807
|
/**
|
|
2212
2808
|
* @param scope - the bound settings scope for the `git-worktree` namespace.
|
|
2213
2809
|
* @param afterGroupSidebarWrite - awaited after the setting lands, until
|
|
@@ -2237,7 +2833,7 @@ window.__ModuleLoader__.load({
|
|
|
2237
2833
|
}
|
|
2238
2834
|
};
|
|
2239
2835
|
}
|
|
2240
|
-
/** @returns the edit, clear, save, discard, and
|
|
2836
|
+
/** @returns the edit, clear, save, discard, and switch actions bound to this form. */
|
|
2241
2837
|
actions() {
|
|
2242
2838
|
return {
|
|
2243
2839
|
editRoot: (text) => {
|
|
@@ -2252,14 +2848,53 @@ window.__ModuleLoader__.load({
|
|
|
2252
2848
|
},
|
|
2253
2849
|
save: () => this.save(),
|
|
2254
2850
|
discard: () => {
|
|
2255
|
-
if (this.draft === void 0 && !this.failed) return;
|
|
2851
|
+
if (this.draft === void 0 && this.keepDraft === void 0 && !this.failed) return;
|
|
2256
2852
|
this.draft = void 0;
|
|
2853
|
+
this.keepDraft = void 0;
|
|
2257
2854
|
this.failed = false;
|
|
2258
2855
|
this.publish();
|
|
2259
2856
|
},
|
|
2260
|
-
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
|
+
}
|
|
2261
2865
|
};
|
|
2262
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
|
+
}
|
|
2263
2898
|
/**
|
|
2264
2899
|
* Flip the grouping switch immediately, then persist.
|
|
2265
2900
|
*
|
|
@@ -2278,6 +2913,9 @@ window.__ModuleLoader__.load({
|
|
|
2278
2913
|
try {
|
|
2279
2914
|
await this.scope.set("groupSidebar", value);
|
|
2280
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";
|
|
2281
2919
|
} finally {
|
|
2282
2920
|
this.groupingPending = false;
|
|
2283
2921
|
this.groupingDraft = void 0;
|
|
@@ -2289,28 +2927,38 @@ window.__ModuleLoader__.load({
|
|
|
2289
2927
|
return this.groupingDraft ?? this.scope.getSnapshot().value?.groupSidebar ?? true;
|
|
2290
2928
|
}
|
|
2291
2929
|
/**
|
|
2292
|
-
* Write the staged
|
|
2930
|
+
* Write the staged edits (root text and/or keep cap), then re-seed from
|
|
2931
|
+
* what the Host accepted.
|
|
2293
2932
|
*
|
|
2294
|
-
* The Host is the only authority on acceptance — an empty draft
|
|
2295
|
-
* field, anything else stores the trimmed text (so blanking the
|
|
2296
|
-
* saving is the same gesture as clearing it)
|
|
2297
|
-
*
|
|
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.
|
|
2298
2939
|
*/
|
|
2299
2940
|
async save() {
|
|
2300
|
-
if (this.draft === void 0 || this.saving) return;
|
|
2301
|
-
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;
|
|
2302
2945
|
this.saving = true;
|
|
2303
2946
|
this.failed = false;
|
|
2304
2947
|
this.publish();
|
|
2305
2948
|
let landed = true;
|
|
2306
2949
|
try {
|
|
2307
|
-
if (
|
|
2308
|
-
else await this.scope.set(ROOT_FIELD,
|
|
2309
|
-
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;
|
|
2310
2955
|
} catch (_settingsWriteFailure) {
|
|
2311
2956
|
landed = false;
|
|
2312
2957
|
}
|
|
2313
|
-
if (landed)
|
|
2958
|
+
if (landed) {
|
|
2959
|
+
if (intendedRoot !== void 0) this.draft = void 0;
|
|
2960
|
+
if (intendedKeep !== void 0) this.keepDraft = void 0;
|
|
2961
|
+
}
|
|
2314
2962
|
this.saving = false;
|
|
2315
2963
|
this.failed = !landed;
|
|
2316
2964
|
this.publish();
|
|
@@ -2337,16 +2985,23 @@ window.__ModuleLoader__.load({
|
|
|
2337
2985
|
project() {
|
|
2338
2986
|
const snapshot = this.scope.getSnapshot();
|
|
2339
2987
|
const draft = this.draft ?? this.effectiveRoot();
|
|
2988
|
+
const keepText = this.effectiveKeepText();
|
|
2989
|
+
const keepParsed = this.parseKeep(keepText);
|
|
2340
2990
|
return {
|
|
2341
2991
|
available: snapshot.status === "ready",
|
|
2342
2992
|
writable: snapshot.writable,
|
|
2343
2993
|
rootDir: draft,
|
|
2344
2994
|
overridden: this.draft !== void 0 ? this.draft.trim() !== "" : this.storedRoot(),
|
|
2345
|
-
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),
|
|
2346
2996
|
saving: this.saving,
|
|
2347
2997
|
failed: this.failed,
|
|
2348
2998
|
groupSidebar: this.effectiveGroupSidebar(),
|
|
2349
|
-
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
|
|
2350
3005
|
};
|
|
2351
3006
|
}
|
|
2352
3007
|
/** Replace the snapshot reference and notify, only when the fact moved. */
|
|
@@ -2372,245 +3027,59 @@ window.__ModuleLoader__.load({
|
|
|
2372
3027
|
});
|
|
2373
3028
|
}
|
|
2374
3029
|
//#endregion
|
|
2375
|
-
//#region
|
|
2376
|
-
const
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
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
|
+
}
|
|
2384
3068
|
}
|
|
2385
|
-
var GitWorktreeCard_module_default = {
|
|
2386
|
-
"card": "card_1712176718",
|
|
2387
|
-
"cardOpen": "cardOpen_1712176718",
|
|
2388
|
-
"header": "header_1712176718",
|
|
2389
|
-
"headText": "headText_1712176718",
|
|
2390
|
-
"name": "name_1712176718",
|
|
2391
|
-
"description": "description_1712176718",
|
|
2392
|
-
"pending": "pending_1712176718",
|
|
2393
|
-
"chevron": "chevron_1712176718",
|
|
2394
|
-
"chevronOpen": "chevronOpen_1712176718",
|
|
2395
|
-
"body": "body_1712176718",
|
|
2396
|
-
"note": "note_1712176718",
|
|
2397
|
-
"field": "field_1712176718",
|
|
2398
|
-
"fieldLabel": "fieldLabel_1712176718",
|
|
2399
|
-
"input": "input_1712176718",
|
|
2400
|
-
"inputRow": "inputRow_1712176718",
|
|
2401
|
-
"browse": "browse_1712176718",
|
|
2402
|
-
"hint": "hint_1712176718",
|
|
2403
|
-
"footer": "footer_1712176718",
|
|
2404
|
-
"failed": "failed_1712176718",
|
|
2405
|
-
"discard": "discard_1712176718",
|
|
2406
|
-
"save": "save_1712176718",
|
|
2407
|
-
"toggleRow": "toggleRow_1712176718",
|
|
2408
|
-
"toggleText": "toggleText_1712176718",
|
|
2409
|
-
"toggleLabel": "toggleLabel_1712176718",
|
|
2410
|
-
"toggleMark": "toggleMark_1712176718",
|
|
2411
|
-
"toggleHint": "toggleHint_1712176718",
|
|
2412
|
-
"toggleNote": "toggleNote_1712176718",
|
|
2413
|
-
"toggleControl": "toggleControl_1712176718",
|
|
2414
|
-
"spinner": "spinner_1712176718",
|
|
2415
|
-
"toggle": "toggle_1712176718"
|
|
2416
|
-
};
|
|
2417
3069
|
//#endregion
|
|
2418
|
-
//#region src/client/
|
|
3070
|
+
//#region src/client/sidebar-groups.ts
|
|
2419
3071
|
/**
|
|
2420
|
-
*
|
|
2421
|
-
* whose header names the plugin over a one-line description of what its
|
|
2422
|
-
* settings govern, disclosing the storage-root control when open. The card
|
|
2423
|
-
* owns everything inside it — chrome, controls, and copy — per the keyed-slot
|
|
2424
|
-
* contract; the tab only dispatches it under the `git-worktree` namespace
|
|
2425
|
-
* key.
|
|
2426
|
-
*
|
|
2427
|
-
* Renders nothing while the namespace is unavailable: a deployment that did
|
|
2428
|
-
* not compose the host half shows no trace of the card. A stored root edit
|
|
2429
|
-
* takes effect live (the Host routes read the section source per request);
|
|
2430
|
-
* no data moves — worktrees already created stay where they are, and git
|
|
2431
|
-
* itself still lists and reuses them.
|
|
3072
|
+
* Derive the sidebar groups.
|
|
2432
3073
|
*
|
|
2433
|
-
*
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
*
|
|
2437
|
-
*
|
|
2438
|
-
*
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
const [picking, setPicking] = (0, react.useState)(false);
|
|
2443
|
-
const { t } = props;
|
|
2444
|
-
const state = props.useGitWorktreeCard((snapshot) => snapshot);
|
|
2445
|
-
if (!state.available) return null;
|
|
2446
|
-
const lockInput = !state.writable;
|
|
2447
|
-
const lockActions = !state.dirty || state.saving;
|
|
2448
|
-
/**
|
|
2449
|
-
* Open the shell's native folder dialog and stage the chosen path — the
|
|
2450
|
-
* same picker the workspace flows use, driven through the injected
|
|
2451
|
-
* workspace service. A dismissal leaves the staged draft exactly as it
|
|
2452
|
-
* was; the text input stays the fallback either way.
|
|
2453
|
-
*/
|
|
2454
|
-
const browse = async () => {
|
|
2455
|
-
if (picking || lockInput) return;
|
|
2456
|
-
setPicking(true);
|
|
2457
|
-
try {
|
|
2458
|
-
const picked = await props.pickDirectory();
|
|
2459
|
-
if (picked !== null && picked !== "") props.editRoot(picked);
|
|
2460
|
-
} catch (_pickFailure) {} finally {
|
|
2461
|
-
setPicking(false);
|
|
2462
|
-
}
|
|
2463
|
-
};
|
|
2464
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
2465
|
-
className: open ? `${GitWorktreeCard_module_default.card} ${GitWorktreeCard_module_default.cardOpen}` : GitWorktreeCard_module_default.card,
|
|
2466
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2467
|
-
type: "button",
|
|
2468
|
-
className: GitWorktreeCard_module_default.header,
|
|
2469
|
-
"aria-expanded": open,
|
|
2470
|
-
"aria-label": `${t(open ? "cardCollapse" : "cardExpand")}: ${t("cardTitle")}`,
|
|
2471
|
-
onClick: () => {
|
|
2472
|
-
setOpen(!open);
|
|
2473
|
-
},
|
|
2474
|
-
children: [
|
|
2475
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2476
|
-
className: GitWorktreeCard_module_default.headText,
|
|
2477
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2478
|
-
className: GitWorktreeCard_module_default.name,
|
|
2479
|
-
children: t("cardTitle")
|
|
2480
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2481
|
-
className: GitWorktreeCard_module_default.description,
|
|
2482
|
-
children: t("cardDescription")
|
|
2483
|
-
})]
|
|
2484
|
-
}),
|
|
2485
|
-
state.dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2486
|
-
className: GitWorktreeCard_module_default.pending,
|
|
2487
|
-
children: t("cardUnsaved")
|
|
2488
|
-
}) : null,
|
|
2489
|
-
/* @__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 })
|
|
2490
|
-
]
|
|
2491
|
-
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2492
|
-
className: GitWorktreeCard_module_default.body,
|
|
2493
|
-
children: [
|
|
2494
|
-
!state.writable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2495
|
-
className: GitWorktreeCard_module_default.note,
|
|
2496
|
-
role: "status",
|
|
2497
|
-
children: t("cardReadOnly")
|
|
2498
|
-
}) : null,
|
|
2499
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2500
|
-
className: GitWorktreeCard_module_default.field,
|
|
2501
|
-
htmlFor: "git-worktree-card-root-dir",
|
|
2502
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2503
|
-
className: GitWorktreeCard_module_default.fieldLabel,
|
|
2504
|
-
children: t("cardRootDirLabel")
|
|
2505
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2506
|
-
className: GitWorktreeCard_module_default.inputRow,
|
|
2507
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2508
|
-
id: "git-worktree-card-root-dir",
|
|
2509
|
-
className: GitWorktreeCard_module_default.input,
|
|
2510
|
-
type: "text",
|
|
2511
|
-
spellCheck: false,
|
|
2512
|
-
value: state.rootDir,
|
|
2513
|
-
disabled: lockInput,
|
|
2514
|
-
onChange: (event) => {
|
|
2515
|
-
props.editRoot(event.target.value);
|
|
2516
|
-
}
|
|
2517
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2518
|
-
type: "button",
|
|
2519
|
-
className: GitWorktreeCard_module_default.browse,
|
|
2520
|
-
disabled: lockInput || picking,
|
|
2521
|
-
onClick: () => {
|
|
2522
|
-
browse();
|
|
2523
|
-
},
|
|
2524
|
-
children: t(picking ? "cardPicking" : "cardBrowse")
|
|
2525
|
-
})]
|
|
2526
|
-
})]
|
|
2527
|
-
}),
|
|
2528
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
2529
|
-
className: GitWorktreeCard_module_default.hint,
|
|
2530
|
-
children: [t("cardRootDirHint"), state.overridden ? ` ${t("cardOverridden")}` : ""]
|
|
2531
|
-
}),
|
|
2532
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
2533
|
-
className: `${GitWorktreeCard_module_default.field} ${GitWorktreeCard_module_default.toggleRow}`,
|
|
2534
|
-
"aria-busy": state.groupingPending,
|
|
2535
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2536
|
-
className: GitWorktreeCard_module_default.toggleText,
|
|
2537
|
-
children: [
|
|
2538
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2539
|
-
className: GitWorktreeCard_module_default.toggleLabel,
|
|
2540
|
-
children: [t("cardGroupSidebarLabel"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2541
|
-
className: GitWorktreeCard_module_default.toggleMark,
|
|
2542
|
-
children: t("cardGroupSidebarMark")
|
|
2543
|
-
})]
|
|
2544
|
-
}),
|
|
2545
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2546
|
-
className: GitWorktreeCard_module_default.toggleHint,
|
|
2547
|
-
children: t("cardGroupSidebarHint")
|
|
2548
|
-
}),
|
|
2549
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2550
|
-
className: GitWorktreeCard_module_default.toggleNote,
|
|
2551
|
-
children: t("cardGroupSidebarNote")
|
|
2552
|
-
})
|
|
2553
|
-
]
|
|
2554
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2555
|
-
className: GitWorktreeCard_module_default.toggleControl,
|
|
2556
|
-
children: [state.groupingPending ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2557
|
-
className: GitWorktreeCard_module_default.spinner,
|
|
2558
|
-
role: "status",
|
|
2559
|
-
"aria-label": t("cardGroupSidebarBusy"),
|
|
2560
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLoadingOutline16, { size: 14 })
|
|
2561
|
-
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2562
|
-
className: GitWorktreeCard_module_default.toggle,
|
|
2563
|
-
type: "checkbox",
|
|
2564
|
-
disabled: lockInput || state.groupingPending,
|
|
2565
|
-
checked: state.groupSidebar,
|
|
2566
|
-
onChange: (event) => {
|
|
2567
|
-
props.setGroupSidebar(event.target.checked);
|
|
2568
|
-
}
|
|
2569
|
-
})]
|
|
2570
|
-
})]
|
|
2571
|
-
}),
|
|
2572
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2573
|
-
className: GitWorktreeCard_module_default.footer,
|
|
2574
|
-
children: [
|
|
2575
|
-
state.failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2576
|
-
className: GitWorktreeCard_module_default.failed,
|
|
2577
|
-
role: "status",
|
|
2578
|
-
children: t("cardSaveFailed")
|
|
2579
|
-
}) : null,
|
|
2580
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2581
|
-
type: "button",
|
|
2582
|
-
className: GitWorktreeCard_module_default.discard,
|
|
2583
|
-
disabled: lockActions,
|
|
2584
|
-
onClick: props.discard,
|
|
2585
|
-
children: t("cardDiscard")
|
|
2586
|
-
}),
|
|
2587
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2588
|
-
type: "button",
|
|
2589
|
-
className: GitWorktreeCard_module_default.save,
|
|
2590
|
-
disabled: lockActions,
|
|
2591
|
-
onClick: props.save,
|
|
2592
|
-
children: t(state.saving ? "cardSaving" : "cardSave")
|
|
2593
|
-
})
|
|
2594
|
-
]
|
|
2595
|
-
})
|
|
2596
|
-
]
|
|
2597
|
-
}) : null]
|
|
2598
|
-
});
|
|
2599
|
-
}
|
|
2600
|
-
//#endregion
|
|
2601
|
-
//#region src/client/sidebar-groups.ts
|
|
2602
|
-
/**
|
|
2603
|
-
* Derive the sidebar groups.
|
|
2604
|
-
*
|
|
2605
|
-
* Rules (the shipped design): git facts absent/null → plain single row;
|
|
2606
|
-
* same-`repoRoot` workspaces cluster into one repo group; inside a group the
|
|
2607
|
-
* main worktree leads and linked members keep registry order; a repo cluster
|
|
2608
|
-
* with exactly ONE member degrades to a plain row (zero visual intrusion for
|
|
2609
|
-
* repositories without worktrees); a group renders where its FIRST member
|
|
2610
|
-
* sits in the registry order (the main worktree's slot).
|
|
2611
|
-
* @param items - workspace list items in registry order.
|
|
2612
|
-
* @param facts - per-path git facts from the /group route (absent = unknown).
|
|
2613
|
-
* @returns groups in render order.
|
|
3074
|
+
* Rules (the shipped design): git facts absent/null → plain single row;
|
|
3075
|
+
* same-`repoRoot` workspaces cluster into one repo group; inside a group the
|
|
3076
|
+
* main worktree leads and linked members keep registry order; a repo cluster
|
|
3077
|
+
* with exactly ONE member degrades to a plain row (zero visual intrusion for
|
|
3078
|
+
* repositories without worktrees); a group renders where its FIRST member
|
|
3079
|
+
* sits in the registry order (the main worktree's slot).
|
|
3080
|
+
* @param items - workspace list items in registry order.
|
|
3081
|
+
* @param facts - per-path git facts from the /group route (absent = unknown).
|
|
3082
|
+
* @returns groups in render order.
|
|
2614
3083
|
*/
|
|
2615
3084
|
function deriveSidebarGroups(items, facts) {
|
|
2616
3085
|
const bucketOrder = [];
|
|
@@ -2657,7 +3126,16 @@ window.__ModuleLoader__.load({
|
|
|
2657
3126
|
if (first === void 0) continue;
|
|
2658
3127
|
const repoName = facts?.[first.workspace.path]?.repoName ?? first.workspace.title;
|
|
2659
3128
|
if (ordered.length === 1) {
|
|
2660
|
-
singles.push({
|
|
3129
|
+
if (first.label.type === "linked") singles.push({
|
|
3130
|
+
index: bucket.index,
|
|
3131
|
+
group: {
|
|
3132
|
+
key: `ws:${first.workspace.workspaceId}`,
|
|
3133
|
+
kind: "single",
|
|
3134
|
+
repoName: void 0,
|
|
3135
|
+
members: [first]
|
|
3136
|
+
}
|
|
3137
|
+
});
|
|
3138
|
+
else singles.push({
|
|
2661
3139
|
index: bucket.index,
|
|
2662
3140
|
group: singleGroup(first.workspace)
|
|
2663
3141
|
});
|
|
@@ -2859,12 +3337,45 @@ window.__ModuleLoader__.load({
|
|
|
2859
3337
|
* win; otherwise a matching cache batch. The grouped tree must paint the
|
|
2860
3338
|
* moment the workspace path set is known — not only at `useState` init,
|
|
2861
3339
|
* when the list is still the pending empty snapshot (signature `""`).
|
|
3340
|
+
*
|
|
3341
|
+
* A newly added workspace changes the signature. Exact-match-only would
|
|
3342
|
+
* drop every cached fact until `/group` returns, flattening the tree and
|
|
3343
|
+
* hiding “删除工作树” on the new linked row. Overlapping batches reuse
|
|
3344
|
+
* facts for paths still present; unknown new paths stay absent (plain)
|
|
3345
|
+
* until the probe lands.
|
|
2862
3346
|
*/
|
|
2863
3347
|
function factsForSignature(signature, live, cached) {
|
|
2864
3348
|
if (live !== null && live.signature === signature) return live;
|
|
2865
3349
|
if (cached !== null && cached.signature === signature) return cached;
|
|
3350
|
+
if (live !== null) {
|
|
3351
|
+
const facts = projectFacts(live.facts, signature);
|
|
3352
|
+
if (facts !== void 0) return {
|
|
3353
|
+
signature,
|
|
3354
|
+
facts
|
|
3355
|
+
};
|
|
3356
|
+
}
|
|
3357
|
+
if (cached !== null) {
|
|
3358
|
+
const facts = projectFacts(cached.facts, signature);
|
|
3359
|
+
if (facts !== void 0) return {
|
|
3360
|
+
signature,
|
|
3361
|
+
facts
|
|
3362
|
+
};
|
|
3363
|
+
}
|
|
2866
3364
|
return null;
|
|
2867
3365
|
}
|
|
3366
|
+
/** Facts for paths that exist in both the batch and the current signature. */
|
|
3367
|
+
function projectFacts(facts, signature) {
|
|
3368
|
+
const paths = signature.split("\n").filter((path) => path !== "");
|
|
3369
|
+
if (paths.length === 0) return void 0;
|
|
3370
|
+
const out = {};
|
|
3371
|
+
let hit = 0;
|
|
3372
|
+
for (const path of paths) {
|
|
3373
|
+
if (!Object.hasOwn(facts, path)) continue;
|
|
3374
|
+
out[path] = facts[path] ?? null;
|
|
3375
|
+
hit += 1;
|
|
3376
|
+
}
|
|
3377
|
+
return hit === 0 ? void 0 : out;
|
|
3378
|
+
}
|
|
2868
3379
|
/** Persist one /group facts batch; write failures (quota, privacy mode) stay silent. */
|
|
2869
3380
|
function saveFactsCache(entry) {
|
|
2870
3381
|
if (typeof localStorage === "undefined") return;
|
|
@@ -3094,87 +3605,1097 @@ window.__ModuleLoader__.load({
|
|
|
3094
3605
|
return t("time.ago", { t: unit === "minutes" ? t("time.minutes", { n }) : unit === "hours" ? t("time.hours", { n }) : unit === "days" ? t("time.days", { n }) : unit === "months" ? t("time.months", { n }) : t("time.years", { n }) });
|
|
3095
3606
|
}
|
|
3096
3607
|
/**
|
|
3097
|
-
* Absolute creation time through the dictionary's date template (the message
|
|
3098
|
-
* clock pattern): `toLocaleString` would follow the browser language, not the
|
|
3099
|
-
* app locale.
|
|
3608
|
+
* Absolute creation time through the dictionary's date template (the message
|
|
3609
|
+
* clock pattern): `toLocaleString` would follow the browser language, not the
|
|
3610
|
+
* app locale.
|
|
3611
|
+
*/
|
|
3612
|
+
function createdLabel(createdAt, t) {
|
|
3613
|
+
const d = new Date(createdAt);
|
|
3614
|
+
const pad2 = (v) => String(v).padStart(2, "0");
|
|
3615
|
+
return t("hover.created", { time: `${t("date.ymd", {
|
|
3616
|
+
y: d.getFullYear(),
|
|
3617
|
+
m: d.getMonth() + 1,
|
|
3618
|
+
d: d.getDate()
|
|
3619
|
+
})} ${pad2(d.getHours())}:${pad2(d.getMinutes())}` });
|
|
3620
|
+
}
|
|
3621
|
+
/** Ordinary sessions are visible; among blanks, only the current one. */
|
|
3622
|
+
function sessionVisible(session, current, archived) {
|
|
3623
|
+
return session.origin !== "subagent" && !archived.has(session.id) && (!session.blank || session.id === current);
|
|
3624
|
+
}
|
|
3625
|
+
/**
|
|
3626
|
+
* Merge immediate title/Workspace substring matches with ranked Host content
|
|
3627
|
+
* matches. Local rows lead newest-first, content-only rows retain backend
|
|
3628
|
+
* order, and duplicate sessions receive the backend snippet in place.
|
|
3629
|
+
*/
|
|
3630
|
+
function deriveSearchResults(list, workspaces, query, archivedSessionIds, content, limit) {
|
|
3631
|
+
const q = query.trim().toLowerCase();
|
|
3632
|
+
if (q === "") return {
|
|
3633
|
+
items: [],
|
|
3634
|
+
hasMore: false
|
|
3635
|
+
};
|
|
3636
|
+
const archived = new Set(archivedSessionIds);
|
|
3637
|
+
const descendants = indexSubagentRunning(list.byId);
|
|
3638
|
+
const workspaceBySession = /* @__PURE__ */ new Map();
|
|
3639
|
+
for (const workspace of workspaces) for (const sessionId of workspace.sessionIds) if (!workspaceBySession.has(sessionId)) workspaceBySession.set(sessionId, workspace.title);
|
|
3640
|
+
const labelOf = (summary) => workspaceBySession.get(summary.id) ?? workspaceLabel(summary.cwd);
|
|
3641
|
+
const contentBySession = /* @__PURE__ */ new Map();
|
|
3642
|
+
for (const item of content.items) if (!contentBySession.has(item.sessionId)) contentBySession.set(item.sessionId, item);
|
|
3643
|
+
const local = [];
|
|
3644
|
+
for (const id of list.ids) {
|
|
3645
|
+
const summary = list.byId[id];
|
|
3646
|
+
if (summary === void 0 || summary.blank || !sessionVisible(summary, list.current, archived)) continue;
|
|
3647
|
+
if (sessionTitle(summary).toLowerCase().includes(q) || labelOf(summary).toLowerCase().includes(q)) local.push(summary);
|
|
3648
|
+
}
|
|
3649
|
+
local.sort((a, b) => byRecency({
|
|
3650
|
+
id: a.id,
|
|
3651
|
+
updatedAt: a.updatedAt ?? 0
|
|
3652
|
+
}, {
|
|
3653
|
+
id: b.id,
|
|
3654
|
+
updatedAt: b.updatedAt ?? 0
|
|
3655
|
+
}));
|
|
3656
|
+
const ordered = [];
|
|
3657
|
+
const included = /* @__PURE__ */ new Set();
|
|
3658
|
+
const include = (summary) => {
|
|
3659
|
+
if (included.has(summary.id)) return;
|
|
3660
|
+
included.add(summary.id);
|
|
3661
|
+
ordered.push(summary);
|
|
3662
|
+
};
|
|
3663
|
+
for (const summary of local) include(summary);
|
|
3664
|
+
for (const item of content.items) {
|
|
3665
|
+
const summary = list.byId[item.sessionId];
|
|
3666
|
+
if (summary !== void 0 && !summary.blank && sessionVisible(summary, list.current, archived)) include(summary);
|
|
3667
|
+
}
|
|
3668
|
+
return {
|
|
3669
|
+
items: ordered.slice(0, limit).map((summary) => {
|
|
3670
|
+
const match = contentBySession.get(summary.id);
|
|
3671
|
+
const node = sessionNode(summary, descendants);
|
|
3672
|
+
return {
|
|
3673
|
+
id: node.id,
|
|
3674
|
+
title: node.title,
|
|
3675
|
+
workspace: labelOf(summary),
|
|
3676
|
+
running: node.running,
|
|
3677
|
+
runningSubagentCount: node.runningSubagentCount,
|
|
3678
|
+
completed: node.completed,
|
|
3679
|
+
...summary.pendingInteraction === void 0 ? {} : { pendingInteraction: summary.pendingInteraction },
|
|
3680
|
+
...match === void 0 ? {} : { snippet: match.snippet }
|
|
3681
|
+
};
|
|
3682
|
+
}),
|
|
3683
|
+
hasMore: content.hasMore || ordered.length > limit
|
|
3684
|
+
};
|
|
3685
|
+
}
|
|
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
|
|
4672
|
+
//#region node_modules/.pnpm/@deepseek-ai+dsh-util-works_407d2a08572222b71cf59f5f9298b01a/node_modules/@deepseek-ai/dsh-util-workspace-path/lib/index.js
|
|
4673
|
+
/**
|
|
4674
|
+
* Browser-safe Workspace path and display helpers.
|
|
4675
|
+
* @module @deepseek-ai/dsh-util-workspace-path
|
|
3100
4676
|
*/
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
return t("hover.created", { time: `${t("date.ymd", {
|
|
3105
|
-
y: d.getFullYear(),
|
|
3106
|
-
m: d.getMonth() + 1,
|
|
3107
|
-
d: d.getDate()
|
|
3108
|
-
})} ${pad2(d.getHours())}:${pad2(d.getMinutes())}` });
|
|
3109
|
-
}
|
|
3110
|
-
/** Ordinary sessions are visible; among blanks, only the current one. */
|
|
3111
|
-
function sessionVisible(session, current, archived) {
|
|
3112
|
-
return session.origin !== "subagent" && !archived.has(session.id) && (!session.blank || session.id === current);
|
|
4677
|
+
/** Whether a path uses a Windows drive or UNC prefix. */
|
|
4678
|
+
function isWindowsStylePath(value) {
|
|
4679
|
+
return /^[A-Za-z]:[/\\]/.test(value) || value.startsWith("\\\\");
|
|
3113
4680
|
}
|
|
3114
4681
|
/**
|
|
3115
|
-
*
|
|
3116
|
-
*
|
|
3117
|
-
*
|
|
4682
|
+
* Abbreviate a POSIX home directory for display.
|
|
4683
|
+
* @param path - Absolute or already-short display path.
|
|
4684
|
+
* @param home - Host account home; absent skips abbreviation.
|
|
4685
|
+
* @returns `~` or `~/…` for the POSIX home and its descendants, otherwise `path`.
|
|
3118
4686
|
*/
|
|
3119
|
-
function
|
|
3120
|
-
|
|
3121
|
-
if (
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
const workspaceBySession = /* @__PURE__ */ new Map();
|
|
3128
|
-
for (const workspace of workspaces) for (const sessionId of workspace.sessionIds) if (!workspaceBySession.has(sessionId)) workspaceBySession.set(sessionId, workspace.title);
|
|
3129
|
-
const labelOf = (summary) => workspaceBySession.get(summary.id) ?? workspaceLabel(summary.cwd);
|
|
3130
|
-
const contentBySession = /* @__PURE__ */ new Map();
|
|
3131
|
-
for (const item of content.items) if (!contentBySession.has(item.sessionId)) contentBySession.set(item.sessionId, item);
|
|
3132
|
-
const local = [];
|
|
3133
|
-
for (const id of list.ids) {
|
|
3134
|
-
const summary = list.byId[id];
|
|
3135
|
-
if (summary === void 0 || summary.blank || !sessionVisible(summary, list.current, archived)) continue;
|
|
3136
|
-
if (sessionTitle(summary).toLowerCase().includes(q) || labelOf(summary).toLowerCase().includes(q)) local.push(summary);
|
|
3137
|
-
}
|
|
3138
|
-
local.sort((a, b) => byRecency({
|
|
3139
|
-
id: a.id,
|
|
3140
|
-
updatedAt: a.updatedAt ?? 0
|
|
3141
|
-
}, {
|
|
3142
|
-
id: b.id,
|
|
3143
|
-
updatedAt: b.updatedAt ?? 0
|
|
3144
|
-
}));
|
|
3145
|
-
const ordered = [];
|
|
3146
|
-
const included = /* @__PURE__ */ new Set();
|
|
3147
|
-
const include = (summary) => {
|
|
3148
|
-
if (included.has(summary.id)) return;
|
|
3149
|
-
included.add(summary.id);
|
|
3150
|
-
ordered.push(summary);
|
|
3151
|
-
};
|
|
3152
|
-
for (const summary of local) include(summary);
|
|
3153
|
-
for (const item of content.items) {
|
|
3154
|
-
const summary = list.byId[item.sessionId];
|
|
3155
|
-
if (summary !== void 0 && !summary.blank && sessionVisible(summary, list.current, archived)) include(summary);
|
|
3156
|
-
}
|
|
3157
|
-
return {
|
|
3158
|
-
items: ordered.slice(0, limit).map((summary) => {
|
|
3159
|
-
const match = contentBySession.get(summary.id);
|
|
3160
|
-
const node = sessionNode(summary, descendants);
|
|
3161
|
-
return {
|
|
3162
|
-
id: node.id,
|
|
3163
|
-
title: node.title,
|
|
3164
|
-
workspace: labelOf(summary),
|
|
3165
|
-
running: node.running,
|
|
3166
|
-
runningSubagentCount: node.runningSubagentCount,
|
|
3167
|
-
completed: node.completed,
|
|
3168
|
-
...summary.pendingInteraction === void 0 ? {} : { pendingInteraction: summary.pendingInteraction },
|
|
3169
|
-
...match === void 0 ? {} : { snippet: match.snippet }
|
|
3170
|
-
};
|
|
3171
|
-
}),
|
|
3172
|
-
hasMore: content.hasMore || ordered.length > limit
|
|
3173
|
-
};
|
|
4687
|
+
function abbreviateHomePath(path, home) {
|
|
4688
|
+
if (home === void 0 || home === "") return path;
|
|
4689
|
+
if (isWindowsStylePath(path) || isWindowsStylePath(home)) return path;
|
|
4690
|
+
const root = home.replace(/\/+$/, "");
|
|
4691
|
+
if (root === "" || root === "/") return path;
|
|
4692
|
+
if (path.replace(/\/+$/, "") === root) return "~";
|
|
4693
|
+
if (path.startsWith(`${root}/`)) return `~${path.slice(root.length)}`;
|
|
4694
|
+
return path;
|
|
3174
4695
|
}
|
|
3175
4696
|
//#endregion
|
|
3176
4697
|
//#region \0git-worktree-css:D:\Code\dsh-worktree\src\client\sidebar-rows.module.css?inline
|
|
3177
|
-
const css$1 = "/* Native Rows.module_2050697429.css_2050697429 transplanted 1:1 (DSW tokens, row-in, reduced-motion).\n * Drag marker classes (dropBefore/dropAfter) are kept for P3; unused in P2. */\n\n.projectRow_2050697429,\n.sessionRow_2050697429 {\n cursor: pointer;\n user-select: none;\n color: var(--dsw-alias-label-primary);\n border-radius: 8px;\n align-items: center;\n gap: 6px;\n padding: 0 8px;\n display: flex;\n}\n\n.projectRow_2050697429:hover,\n.sessionRow_2050697429:hover,\n.sessionRow_2050697429.selected_2050697429 {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.searchResultRow_2050697429 {\n box-sizing: border-box;\n cursor: pointer;\n text-align: left;\n width: 100%;\n min-height: 48px;\n color: var(--dsw-alias-label-primary);\n background: 0 0;\n border: none;\n border-radius: 8px;\n flex-direction: column;\n align-items: stretch;\n padding: 4px 8px;\n display: flex;\n}\n\n.searchResultRow_2050697429:hover,\n.searchResultRow_2050697429.selected_2050697429 {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.searchResultHeading_2050697429 {\n align-items: center;\n min-width: 0;\n display: flex;\n}\n\n.searchResultTitle_2050697429 {\n text-overflow: ellipsis;\n white-space: nowrap;\n min-width: 0;\n margin-left: 4px;\n font-size: 14px;\n line-height: 20px;\n overflow: hidden;\n}\n\n.searchResultMeta_2050697429 {\n align-items: center;\n gap: 6px;\n min-width: 0;\n margin-left: 20px;\n display: flex;\n}\n\n.searchResultWorkspace_2050697429,\n.searchResultSnippet_2050697429 {\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 12px;\n line-height: 17px;\n overflow: hidden;\n}\n\n.searchResultWorkspace_2050697429 {\n max-width: 40%;\n color: var(--dsw-alias-label-tertiary);\n flex: none;\n}\n\n.searchResultSnippet_2050697429 {\n min-width: 0;\n color: var(--dsw-alias-label-secondary);\n flex: 1;\n}\n\n.projectRow_2050697429 {\n box-sizing: border-box;\n align-items: center;\n height: 34px;\n}\n\n.projectRow_2050697429 .rowActions_2050697429 {\n height: 20px;\n}\n\n.sessionRow_2050697429 {\n height: 32px;\n animation: row-in 0.15s var(--ds-ease-in-out);\n gap: 0;\n}\n\n.sessionRow_2050697429 .title_2050697429 {\n margin: 0 6px 0 4px;\n}\n\n.flatSessionRowWithoutStatus_2050697429 .title_2050697429 {\n margin-left: 0;\n}\n\n@keyframes row-in {\n 0% { opacity: 0; }\n}\n\n.slot_2050697429 {\n width: 16px;\n height: 20px;\n color: var(--dsw-alias-label-tertiary);\n flex: none;\n justify-content: center;\n align-items: center;\n display: inline-flex;\n}\n\n.visuallyHidden_2050697429 {\n clip: rect(0 0 0 0);\n white-space: nowrap;\n width: 1px;\n height: 1px;\n position: absolute;\n overflow: hidden;\n}\n\n.folderActive_2050697429 {\n color: var(--dsw-alias-state-business-primary);\n}\n\n.projectRow_2050697429 .chevron_2050697429 {\n display: none;\n}\n\n.projectRow_2050697429:hover .chevron_2050697429 {\n display: inline-flex;\n}\n\n.projectRow_2050697429:hover .folder_2050697429 {\n display: none;\n}\n\n.arrow_2050697429 {\n transition: transform 0.15s var(--ds-ease-in-out);\n}\n\n.arrowOpen_2050697429 {\n transform: rotate(90deg);\n}\n\n.projectText_2050697429 {\n flex-direction: column;\n flex: 1;\n gap: 2px;\n min-width: 0;\n display: flex;\n}\n\n.title_2050697429 {\n text-overflow: ellipsis;\n white-space: nowrap;\n min-width: 0;\n font-size: 14px;\n line-height: 20px;\n overflow: hidden;\n}\n\n/* Virtual (unregistered) directory rows read one weight lighter than real\n * workspace rows — together with the dashed folder glyph, the whole row is\n * distinguishable at a glance. */\n.strayRow_2050697429 .title_2050697429 {\n color: var(--dsw-alias-label-secondary);\n}\n\n.renameInput_2050697429 {\n border:
|
|
4698
|
+
const css$1 = "/* Native Rows.module_2050697429.css_2050697429 transplanted 1:1 (DSW tokens, row-in, reduced-motion).\n * Drag marker classes (dropBefore/dropAfter) are kept for P3; unused in P2. */\n\n.projectRow_2050697429,\n.sessionRow_2050697429 {\n cursor: pointer;\n user-select: none;\n color: var(--dsw-alias-label-primary);\n border-radius: 8px;\n align-items: center;\n gap: 6px;\n padding: 0 8px;\n display: flex;\n}\n\n.projectRow_2050697429:hover,\n.sessionRow_2050697429:hover,\n.sessionRow_2050697429.selected_2050697429 {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.searchResultRow_2050697429 {\n box-sizing: border-box;\n cursor: pointer;\n text-align: left;\n width: 100%;\n min-height: 48px;\n color: var(--dsw-alias-label-primary);\n background: 0 0;\n border: none;\n border-radius: 8px;\n flex-direction: column;\n align-items: stretch;\n padding: 4px 8px;\n display: flex;\n}\n\n.searchResultRow_2050697429:hover,\n.searchResultRow_2050697429.selected_2050697429 {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.searchResultHeading_2050697429 {\n align-items: center;\n min-width: 0;\n display: flex;\n}\n\n.searchResultTitle_2050697429 {\n text-overflow: ellipsis;\n white-space: nowrap;\n min-width: 0;\n margin-left: 4px;\n font-size: 14px;\n line-height: 20px;\n overflow: hidden;\n}\n\n.searchResultMeta_2050697429 {\n align-items: center;\n gap: 6px;\n min-width: 0;\n margin-left: 20px;\n display: flex;\n}\n\n.searchResultWorkspace_2050697429,\n.searchResultSnippet_2050697429 {\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 12px;\n line-height: 17px;\n overflow: hidden;\n}\n\n.searchResultWorkspace_2050697429 {\n max-width: 40%;\n color: var(--dsw-alias-label-tertiary);\n flex: none;\n}\n\n.searchResultSnippet_2050697429 {\n min-width: 0;\n color: var(--dsw-alias-label-secondary);\n flex: 1;\n}\n\n.projectRow_2050697429 {\n box-sizing: border-box;\n align-items: center;\n height: 34px;\n}\n\n.projectRow_2050697429 .rowActions_2050697429 {\n height: 20px;\n}\n\n.sessionRow_2050697429 {\n height: 32px;\n animation: row-in 0.15s var(--ds-ease-in-out);\n gap: 0;\n}\n\n.sessionRow_2050697429 .title_2050697429 {\n margin: 0 6px 0 4px;\n}\n\n.flatSessionRowWithoutStatus_2050697429 .title_2050697429 {\n margin-left: 0;\n}\n\n@keyframes row-in {\n 0% { opacity: 0; }\n}\n\n.slot_2050697429 {\n width: 16px;\n height: 20px;\n color: var(--dsw-alias-label-tertiary);\n flex: none;\n justify-content: center;\n align-items: center;\n display: inline-flex;\n}\n\n.visuallyHidden_2050697429 {\n clip: rect(0 0 0 0);\n white-space: nowrap;\n width: 1px;\n height: 1px;\n position: absolute;\n overflow: hidden;\n}\n\n.folderActive_2050697429 {\n color: var(--dsw-alias-state-business-primary);\n}\n\n.projectRow_2050697429 .chevron_2050697429 {\n display: none;\n}\n\n.projectRow_2050697429:hover .chevron_2050697429 {\n display: inline-flex;\n}\n\n.projectRow_2050697429:hover .folder_2050697429 {\n display: none;\n}\n\n.arrow_2050697429 {\n transition: transform 0.15s var(--ds-ease-in-out);\n}\n\n.arrowOpen_2050697429 {\n transform: rotate(90deg);\n}\n\n.projectText_2050697429 {\n flex-direction: column;\n flex: 1;\n gap: 2px;\n min-width: 0;\n display: flex;\n}\n\n.title_2050697429 {\n text-overflow: ellipsis;\n white-space: nowrap;\n min-width: 0;\n font-size: 14px;\n line-height: 20px;\n overflow: hidden;\n}\n\n/* Virtual (unregistered) directory rows read one weight lighter than real\n * workspace rows — together with the dashed folder glyph, the whole row is\n * distinguishable at a glance. */\n.strayRow_2050697429 .title_2050697429 {\n color: var(--dsw-alias-label-secondary);\n}\n\n.renameInput_2050697429 {\n border: 0.5px solid var(--dsw-alias-border-l4);\n background: var(--dsw-alias-button-elevated-fill);\n min-width: 0;\n color: inherit;\n border-radius: 4px;\n outline: none;\n padding: 0 2px;\n font-size: 14px;\n line-height: 20px;\n}\n\n.sessionRow_2050697429 .title_2050697429 {\n flex: 1;\n}\n\n.meta_2050697429 {\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 20px;\n overflow: hidden;\n}\n\n.time_2050697429 {\n color: var(--dsw-alias-label-tertiary);\n flex: none;\n font-size: 12px;\n line-height: 20px;\n}\n\n.dot_2050697429 {\n flex: none;\n}\n\n.rowActions_2050697429 {\n flex: none;\n align-items: center;\n gap: 12px;\n display: none;\n}\n\n.projectRow_2050697429:hover .rowActions_2050697429,\n.sessionRow_2050697429:hover .rowActions_2050697429,\n.projectRow_2050697429.menuOpen_2050697429 .rowActions_2050697429,\n.sessionRow_2050697429.menuOpen_2050697429 .rowActions_2050697429 {\n display: inline-flex;\n}\n\n.sessionRow_2050697429:hover .time_2050697429,\n.sessionRow_2050697429.menuOpen_2050697429 .time_2050697429 {\n display: none;\n}\n\n.projectRow_2050697429.menuOpen_2050697429,\n.sessionRow_2050697429.menuOpen_2050697429 {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n/* P3: session drag insertion markers (unused in P2). */\n.sessionRow_2050697429.dropBefore_2050697429,\n.sessionRow_2050697429.dropAfter_2050697429 {\n position: relative;\n}\n\n.sessionRow_2050697429.dropBefore_2050697429:before,\n.sessionRow_2050697429.dropAfter_2050697429:after {\n content: \"\";\n z-index: 1;\n background:\n linear-gradient(55deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 5px 7px no-repeat,\n linear-gradient(125deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 5px / 5px 7px no-repeat,\n linear-gradient(var(--dsw-alias-state-business-primary) 0 0) 4px 5px / calc(100% - 4px) 2px no-repeat;\n pointer-events: none;\n height: 12px;\n position: absolute;\n left: 0;\n right: 4px;\n}\n\n.sessionRow_2050697429.dropBefore_2050697429:before {\n top: -7px;\n}\n\n.sessionRow_2050697429.dropAfter_2050697429:after {\n bottom: -7px;\n}\n\n.hoverContent_2050697429 {\n flex-direction: column;\n gap: 8px;\n display: flex;\n}\n\n.hoverTitle_2050697429 {\n color: #fff;\n overflow-wrap: break-word;\n font-size: 14px;\n line-height: 20px;\n}\n\n.hoverPath_2050697429 {\n color: #cfd3d6;\n word-break: break-all;\n font-size: 12px;\n line-height: 16px;\n}\n\n.hoverTime_2050697429 {\n color: #cfd3d6;\n font-size: 12px;\n line-height: 16px;\n}\n\n.hoverStatus_2050697429 {\n color: #adb2b8;\n align-items: center;\n gap: 8px;\n font-size: 12px;\n line-height: 20px;\n display: flex;\n}\n\n.iconButton_2050697429 {\n cursor: pointer;\n width: 16px;\n height: 16px;\n color: var(--dsw-alias-label-tertiary);\n background: 0 0;\n border: none;\n border-radius: 4px;\n flex: none;\n justify-content: center;\n align-items: center;\n padding: 0;\n display: inline-flex;\n}\n\n.iconButton_2050697429:hover {\n color: var(--dsw-alias-label-primary);\n}\n\n.chevron_2050697429 {\n color: var(--dsw-alias-label-caption);\n}\n\n.repoCount_2050697429 {\n flex: none;\n margin-left: 8px;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 20px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .sessionRow_2050697429,\n .arrow_2050697429 {\n transition: none;\n animation: none;\n }\n}\n";
|
|
3178
4699
|
const tagId$1 = "@laoyuehanni/dsh-git-worktree/sidebar-rows.module.css";
|
|
3179
4700
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId$1 + "\"]") === null) {
|
|
3180
4701
|
const tag = document.createElement("style");
|
|
@@ -3354,7 +4875,7 @@ window.__ModuleLoader__.load({
|
|
|
3354
4875
|
anchor: ownRow,
|
|
3355
4876
|
content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WorkspaceHoverContent, {
|
|
3356
4877
|
label: row.label,
|
|
3357
|
-
cwd: row.cwd === void 0 ? void 0 :
|
|
4878
|
+
cwd: row.cwd === void 0 ? void 0 : abbreviateHomePath(row.cwd, home),
|
|
3358
4879
|
createdAt: row.createdAt,
|
|
3359
4880
|
t
|
|
3360
4881
|
}),
|
|
@@ -3375,10 +4896,10 @@ window.__ModuleLoader__.load({
|
|
|
3375
4896
|
}
|
|
3376
4897
|
/**
|
|
3377
4898
|
* Dashed folder glyph for virtual (unregistered) directory rows. The icon set
|
|
3378
|
-
* ships no dashed variant, so this
|
|
3379
|
-
*
|
|
3380
|
-
* but not a registered workspace" mark than the
|
|
3381
|
-
* 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.
|
|
3382
4903
|
*/
|
|
3383
4904
|
function StrayFolderGlyph({ size = 16 }) {
|
|
3384
4905
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
@@ -3485,7 +5006,7 @@ window.__ModuleLoader__.load({
|
|
|
3485
5006
|
}),
|
|
3486
5007
|
path !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3487
5008
|
className: sidebar_rows_module_default.hoverPath,
|
|
3488
|
-
children:
|
|
5009
|
+
children: abbreviateHomePath(path, home)
|
|
3489
5010
|
}),
|
|
3490
5011
|
belongsTo !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3491
5012
|
className: sidebar_rows_module_default.hoverStatus,
|
|
@@ -3777,7 +5298,7 @@ window.__ModuleLoader__.load({
|
|
|
3777
5298
|
}
|
|
3778
5299
|
//#endregion
|
|
3779
5300
|
//#region \0git-worktree-css:D:\Code\dsh-worktree\src\client\GroupedSidebar.module.css?inline
|
|
3780
|
-
const css = "/* Native WorkspaceBrowser.module_1808205761.css_1808205761 + WorkspacePicker.module_1808205761.css_1808205761 transplanted\n * 1:1 (DSW tokens, search expand, reduced-motion). Drag classes\n * (workspaceDrop*, listTopDrop*) are kept for P3; unused in P2.\n * Overlay: memberIndent / sessionsIndent for the repo-grouped tree. */\n\n.root_1808205761 {\n --dsh-session-list-edge-inset: var(--dsh-sidebar-inline-padding);\n --dsh-session-list-scrollbar-width: 8px;\n --dsh-session-list-scrollbar-offset: 2px;\n box-sizing: border-box;\n min-height: 0;\n padding-right: var(--dsh-session-list-edge-inset);\n flex-direction: column;\n flex: 1;\n display: flex;\n}\n\n.root_1808205761.rail_1808205761 {\n padding-right: 0;\n}\n\n.iconButton_1808205761 {\n cursor: pointer;\n width: 28px;\n height: 28px;\n color: var(--dsw-alias-label-secondary);\n background: 0 0;\n border: none;\n border-radius: 50%;\n flex: none;\n justify-content: center;\n align-items: center;\n padding: 0;\n display: inline-flex;\n}\n\n.iconButton_1808205761:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.sectionHeader_1808205761 {\n box-sizing: border-box;\n height: 36px;\n color: var(--dsw-alias-label-tertiary);\n border-radius: 12px;\n flex: none;\n justify-content: flex-end;\n align-items: center;\n gap: 4px;\n margin-bottom: 4px;\n padding-left: 4px;\n display: flex;\n overflow: hidden;\n}\n\n.root_1808205761:not(.rail_1808205761) .sectionHeader_1808205761 {\n margin-top: 2px;\n margin-right: -4px;\n}\n\n.sectionLabel_1808205761 {\n white-space: nowrap;\n opacity: 1;\n visibility: visible;\n min-width: 0;\n max-width: 45%;\n transition: max-width 0.18s var(--ds-ease-in-out), margin-right 0.18s var(--ds-ease-in-out), opacity 0.12s var(--ds-ease-in-out), transform 0.18s var(--ds-ease-in-out), visibility 0s linear;\n flex: none;\n line-height: 20px;\n overflow: hidden;\n}\n\n.sectionLabelHidden_1808205761 {\n opacity: 0;\n visibility: hidden;\n max-width: 0;\n margin-right: -4px;\n transition-delay: 0s, 0s, 0s, 0s, 0.18s;\n transform: translate(-4px);\n}\n\n.searchSlot_1808205761 {\n box-sizing: border-box;\n min-width: 0;\n max-width: 28px;\n transition: max-width 0.18s var(--ds-ease-in-out), padding-left 0.18s var(--ds-ease-in-out);\n flex: 1;\n align-items: center;\n margin-left: auto;\n padding-left: 0;\n display: flex;\n}\n\n.searchSlotExpanded_1808205761 {\n max-width: 100%;\n padding-left: 0;\n}\n\n.headerActions_1808205761 {\n opacity: 1;\n visibility: visible;\n max-width: 60px;\n transition: max-width 0.18s var(--ds-ease-in-out), opacity 0.12s var(--ds-ease-in-out), transform 0.18s var(--ds-ease-in-out), visibility 0s linear;\n flex: none;\n align-items: center;\n gap: 4px;\n display: flex;\n overflow: hidden;\n}\n\n.headerActionsHidden_1808205761 {\n opacity: 0;\n visibility: hidden;\n pointer-events: none;\n max-width: 0;\n transition-delay: 0s, 0s, 0s, 0.18s;\n transform: translate(4px);\n}\n\n.search_1808205761 {\n box-sizing: border-box;\n cursor: text;\n width: 100%;\n height: 28px;\n color: var(--dsw-alias-label-secondary);\n transition: width 0.18s var(--ds-ease-in-out), padding 0.18s var(--ds-ease-in-out), border-color 0.18s var(--ds-ease-in-out), background-color 0.18s var(--ds-ease-in-out);\n background: 0 0;\n border: none;\n border-radius: 50%;\n flex: none;\n align-items: center;\n gap: 0;\n margin: 0;\n padding: 0;\n display: flex;\n overflow: hidden;\n}\n\n.searchExpanded_1808205761 {\n border: 1px solid var(--dsw-alias-border-l2);\n width: calc(100% + 4px);\n height: 30px;\n color: var(--dsw-alias-label-caption);\n background: 0 0;\n border-radius: 10px;\n margin-inline: -2px;\n padding: 0 4px 0 0;\n}\n\n.searchButton_1808205761 {\n cursor: pointer;\n width: 28px;\n height: 28px;\n color: inherit;\n background: 0 0;\n border: none;\n border-radius: 50%;\n flex: none;\n justify-content: center;\n align-items: center;\n padding: 0;\n display: inline-flex;\n}\n\n.searchExpanded_1808205761 .searchButton_1808205761 {\n width: 28px;\n height: 30px;\n}\n\n.searchButton_1808205761:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.searchExpanded_1808205761 .searchButton_1808205761:hover {\n background: 0 0;\n}\n\n.searchInput_1808205761 {\n opacity: 0;\n pointer-events: none;\n width: 0;\n min-width: 0;\n color: var(--dsw-alias-label-primary);\n transition: opacity 0.12s var(--ds-ease-in-out);\n background: 0 0;\n border: none;\n outline: none;\n flex: 1;\n font-size: 13px;\n line-height: 18px;\n}\n\n.searchExpanded_1808205761 .searchInput_1808205761 {\n opacity: 1;\n pointer-events: auto;\n margin-left: -2px;\n}\n\n.searchInput_1808205761::placeholder {\n color: var(--dsw-alias-label-tertiary);\n}\n\n.clearButton_1808205761 {\n cursor: pointer;\n width: 24px;\n height: 24px;\n color: var(--dsw-alias-label-secondary);\n background: 0 0;\n border: none;\n border-radius: 50%;\n flex: none;\n justify-content: center;\n align-items: center;\n padding: 0;\n display: inline-flex;\n}\n\n.clearButton_1808205761:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.rail_1808205761 .sectionHeader_1808205761 {\n justify-content: flex-start;\n gap: 0;\n margin-bottom: 12px;\n padding-left: 0;\n}\n\n.rail_1808205761 .headerActions_1808205761 {\n max-width: none;\n}\n\n.rail_1808205761 .iconButton_1808205761 {\n width: 36px;\n height: 36px;\n color: var(--dsw-alias-label-primary);\n}\n\n.rail_1808205761 .search_1808205761 {\n background: 0 0;\n border-color: #0000;\n gap: 0;\n width: 36px;\n height: 36px;\n margin: 0 0 12px;\n padding: 0;\n}\n\n.rail_1808205761 .searchButton_1808205761 {\n width: 36px;\n height: 36px;\n color: var(--dsw-alias-label-primary);\n}\n\n.rail_1808205761 .searchButton_1808205761:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.listArea_1808205761 {\n min-height: 0;\n margin-left: -4px;\n margin-right: calc(-1 * var(--dsh-session-list-edge-inset));\n flex-direction: column;\n flex: 1;\n padding-left: 4px;\n display: flex;\n overflow: visible;\n}\n\n.rail_1808205761 .listArea_1808205761 {\n margin-left: 0;\n margin-right: 0;\n padding-left: 0;\n}\n\n.treeBody_1808205761 {\n flex-direction: column;\n flex: 1;\n min-height: 0;\n display: flex;\n position: relative;\n}\n\n.fade_1808205761 {\n left: 0;\n right: var(--dsh-session-list-edge-inset);\n background: linear-gradient(to bottom, transparent, var(--dsw-specific-sidebar-fill));\n pointer-events: none;\n height: 24px;\n position: absolute;\n bottom: 0;\n}\n\n.wide_1808205761 {\n animation: wide-in 0.2s var(--ds-ease-in-out);\n}\n\n@keyframes wide-in {\n 0% { opacity: 0; }\n}\n\n.list_1808205761 {\n min-height: 0;\n margin-left: -4px;\n margin-right: var(--dsh-session-list-scrollbar-offset);\n padding-left: 4px;\n padding-right: calc(var(--dsh-session-list-edge-inset) - var(--dsh-session-list-scrollbar-width) - var(--dsh-session-list-scrollbar-offset));\n scrollbar-gutter: stable;\n flex: 1;\n padding-bottom: 16px;\n overflow-y: auto;\n}\n\n.flatList_1808205761 > * + *,\n.searchTree_1808205761 > [role=treeitem] + [role=treeitem],\n.groupSection_1808205761 > * + * {\n margin-top: 2px;\n}\n\n.searchStatus_1808205761,\n.searchWarning_1808205761 {\n color: var(--dsw-alias-label-tertiary);\n padding: 10px 12px;\n font-size: 12px;\n line-height: 18px;\n}\n\n.searchWarning_1808205761 {\n color: var(--dsw-alias-label-secondary);\n}\n\n.groupSection_1808205761 {\n position: relative;\n}\n\n.groupSection_1808205761 + .groupSection_1808205761 {\n margin-top: 4px;\n}\n\n/* P3: workspace drag insertion markers (unused in P2). */\n.listTopDropIndicator_1808205761,\n.workspaceDropBefore_1808205761:before,\n.workspaceDropAfter_1808205761:after {\n content: \"\";\n z-index: 1;\n background:\n linear-gradient(55deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 5px 7px no-repeat,\n linear-gradient(125deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 5px / 5px 7px no-repeat,\n linear-gradient(var(--dsw-alias-state-business-primary) 0 0) 4px 5px / calc(100% - 4px) 2px no-repeat;\n pointer-events: none;\n height: 12px;\n position: absolute;\n left: 0;\n right: 0;\n}\n\n.listTopDropIndicator_1808205761 {\n top: -8px;\n left: 0;\n right: var(--dsh-session-list-edge-inset);\n}\n\n.listTopDropActive_1808205761 > .workspaceDropBefore_1808205761:first-child:before {\n display: none;\n}\n\n.workspaceDropBefore_1808205761:before {\n top: -8px;\n}\n\n.workspaceDropAfter_1808205761:after {\n bottom: -8px;\n}\n\n.sessionOverflowButton_1808205761 {\n cursor: pointer;\n text-align: left;\n width: 100%;\n height: 28px;\n color: var(--dsw-alias-label-tertiary);\n background: 0 0;\n border: none;\n border-radius: 8px;\n padding: 0 12px 0 28px;\n font-size: 12px;\n}\n\n.groupSection_1808205761 > .sessionOverflowButton_1808205761 {\n margin-top: 0;\n}\n\n.sessionOverflowButton_1808205761:hover {\n color: var(--dsw-alias-label-secondary);\n background: 0 0;\n}\n\n.empty_1808205761 {\n color: var(--dsw-alias-label-tertiary);\n padding: 16px 12px;\n font-size: 13px;\n}\n\n.renameInput_1808205761 {\n box-sizing: border-box;\n border: 1px solid var(--dsw-alias-border-l2);\n width: 100%;\n height: 44px;\n color: var(--dsw-alias-label-primary);\n background: 0 0;\n border-radius: 22px;\n outline: none;\n padding: 7px 14px;\n font-size: 14px;\n font-weight: 400;\n line-height: 22px;\n}\n\n.renameInput_1808205761:disabled {\n color: var(--dsw-alias-label-dimmed);\n}\n\n.renameError_1808205761 {\n color: var(--dsw-alias-state-error-primary);\n margin-top: 8px;\n font-size: 12px;\n line-height: 18px;\n}\n\n.deleteAction_1808205761:not(:disabled) {\n color: var(--dsw-alias-state-error-primary);\n}\n\n.deleteStatus_1808205761 {\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 18px;\n}\n\n/* Pre-delete facts of the worktree-removal dialog: one line per fact, the\n * destructive one (uncommitted files die with the folder) in error tone. */\n.removeFacts_1808205761 {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin-top: 8px;\n}\n\n.removeFact_1808205761 {\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-secondary);\n}\n\n.removeFactWarn_1808205761 {\n color: var(--dsw-alias-state-error-primary);\n}\n\n.modalAction_1808205761 {\n min-width: 72px;\n}\n\n.modalError_1808205761,\n.menuStatus_1808205761 {\n margin-top: 8px;\n font-size: 12px;\n line-height: 18px;\n}\n\n.modalError_1808205761 {\n color: var(--dsw-alias-state-error-primary);\n}\n\n.menuStatus_1808205761 {\n color: var(--dsw-alias-label-secondary);\n}\n\n/* Aggregation overlay: indent member workspaces and their sessions. */\n.memberIndent_1808205761 {\n margin-left: 16px;\n}\n\n.sessionsIndent_1808205761 {\n margin-left: 8px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .wide_1808205761 {\n animation: none;\n }\n\n .search_1808205761,\n .sectionLabel_1808205761,\n .searchSlot_1808205761,\n .searchInput_1808205761,\n .headerActions_1808205761 {\n transition: none;\n }\n}\n";
|
|
5301
|
+
const css = "/* Native WorkspaceBrowser.module_1808205761.css_1808205761 + WorkspacePicker.module_1808205761.css_1808205761 transplanted\n * 1:1 (DSW tokens, search expand, reduced-motion). Drag classes\n * (workspaceDrop*, listTopDrop*) are kept for P3; unused in P2.\n * Overlay: memberIndent / sessionsIndent for the repo-grouped tree. */\n\n.root_1808205761 {\n --dsh-session-list-edge-inset: var(--dsh-sidebar-inline-padding);\n --dsh-session-list-scrollbar-width: 8px;\n --dsh-session-list-scrollbar-offset: 2px;\n box-sizing: border-box;\n min-height: 0;\n padding-right: var(--dsh-session-list-edge-inset);\n flex-direction: column;\n flex: 1;\n display: flex;\n}\n\n.root_1808205761.rail_1808205761 {\n padding-right: 0;\n}\n\n.iconButton_1808205761 {\n cursor: pointer;\n width: 28px;\n height: 28px;\n color: var(--dsw-alias-label-secondary);\n background: 0 0;\n border: none;\n border-radius: 50%;\n corner-shape: round;\n flex: none;\n justify-content: center;\n align-items: center;\n padding: 0;\n display: inline-flex;\n}\n\n.iconButton_1808205761:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.sectionHeader_1808205761 {\n box-sizing: border-box;\n height: 36px;\n color: var(--dsw-alias-label-tertiary);\n border-radius: 12px;\n flex: none;\n justify-content: flex-end;\n align-items: center;\n gap: 4px;\n margin-bottom: 4px;\n padding-left: 4px;\n display: flex;\n overflow: hidden;\n}\n\n.root_1808205761:not(.rail_1808205761) .sectionHeader_1808205761 {\n margin-top: 2px;\n margin-right: -4px;\n}\n\n.sectionLabel_1808205761 {\n white-space: nowrap;\n opacity: 1;\n visibility: visible;\n min-width: 0;\n max-width: 45%;\n transition: max-width 0.18s var(--ds-ease-in-out), margin-right 0.18s var(--ds-ease-in-out), opacity 0.12s var(--ds-ease-in-out), transform 0.18s var(--ds-ease-in-out), visibility 0s linear;\n flex: none;\n line-height: 20px;\n overflow: hidden;\n}\n\n.sectionLabelHidden_1808205761 {\n opacity: 0;\n visibility: hidden;\n max-width: 0;\n margin-right: -4px;\n transition-delay: 0s, 0s, 0s, 0s, 0.18s;\n transform: translate(-4px);\n}\n\n.searchSlot_1808205761 {\n box-sizing: border-box;\n min-width: 0;\n max-width: 28px;\n transition: max-width 0.18s var(--ds-ease-in-out), padding-left 0.18s var(--ds-ease-in-out);\n flex: 1;\n align-items: center;\n margin-left: auto;\n padding-left: 0;\n display: flex;\n}\n\n.searchSlotExpanded_1808205761 {\n max-width: 100%;\n padding-left: 0;\n}\n\n.headerActions_1808205761 {\n opacity: 1;\n visibility: visible;\n max-width: 60px;\n transition: max-width 0.18s var(--ds-ease-in-out), opacity 0.12s var(--ds-ease-in-out), transform 0.18s var(--ds-ease-in-out), visibility 0s linear;\n flex: none;\n align-items: center;\n gap: 4px;\n display: flex;\n overflow: hidden;\n}\n\n.headerActionsHidden_1808205761 {\n opacity: 0;\n visibility: hidden;\n pointer-events: none;\n max-width: 0;\n transition-delay: 0s, 0s, 0s, 0.18s;\n transform: translate(4px);\n}\n\n.search_1808205761 {\n box-sizing: border-box;\n cursor: text;\n width: 100%;\n height: 28px;\n color: var(--dsw-alias-label-secondary);\n transition: width 0.18s var(--ds-ease-in-out), padding 0.18s var(--ds-ease-in-out), border-color 0.18s var(--ds-ease-in-out), background-color 0.18s var(--ds-ease-in-out);\n background: 0 0;\n border: none;\n border-radius: 50%;\n corner-shape: round;\n flex: none;\n align-items: center;\n gap: 0;\n margin: 0;\n padding: 0;\n display: flex;\n overflow: hidden;\n}\n\n.searchExpanded_1808205761 {\n border: 0.5px solid var(--dsw-alias-border-l4);\n width: calc(100% + 4px);\n height: 30px;\n color: var(--dsw-alias-label-caption);\n background: 0 0;\n border-radius: 10px;\n margin-inline: -2px;\n padding: 0 4px 0 0;\n}\n\n.searchButton_1808205761 {\n cursor: pointer;\n width: 28px;\n height: 28px;\n color: inherit;\n background: 0 0;\n border: none;\n border-radius: 50%;\n corner-shape: round;\n flex: none;\n justify-content: center;\n align-items: center;\n padding: 0;\n display: inline-flex;\n}\n\n.searchExpanded_1808205761 .searchButton_1808205761 {\n width: 28px;\n height: 30px;\n}\n\n.searchButton_1808205761:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.searchExpanded_1808205761 .searchButton_1808205761:hover {\n background: 0 0;\n}\n\n.searchInput_1808205761 {\n opacity: 0;\n pointer-events: none;\n width: 0;\n min-width: 0;\n color: var(--dsw-alias-label-primary);\n transition: opacity 0.12s var(--ds-ease-in-out);\n background: 0 0;\n border: none;\n outline: none;\n flex: 1;\n font-size: 13px;\n line-height: 18px;\n}\n\n.searchExpanded_1808205761 .searchInput_1808205761 {\n opacity: 1;\n pointer-events: auto;\n margin-left: -2px;\n}\n\n.searchInput_1808205761::placeholder {\n color: var(--dsw-alias-label-tertiary);\n}\n\n.clearButton_1808205761 {\n cursor: pointer;\n width: 24px;\n height: 24px;\n color: var(--dsw-alias-label-secondary);\n background: 0 0;\n border: none;\n border-radius: 50%;\n corner-shape: round;\n flex: none;\n justify-content: center;\n align-items: center;\n padding: 0;\n display: inline-flex;\n}\n\n.clearButton_1808205761:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.rail_1808205761 .sectionHeader_1808205761 {\n justify-content: flex-start;\n gap: 0;\n margin-bottom: 12px;\n padding-left: 0;\n}\n\n.rail_1808205761 .headerActions_1808205761 {\n max-width: none;\n}\n\n.rail_1808205761 .iconButton_1808205761 {\n width: 36px;\n height: 36px;\n color: var(--dsw-alias-label-primary);\n}\n\n.rail_1808205761 .search_1808205761 {\n background: 0 0;\n border-color: #0000;\n gap: 0;\n width: 36px;\n height: 36px;\n margin: 0 0 12px;\n padding: 0;\n}\n\n.rail_1808205761 .searchButton_1808205761 {\n width: 36px;\n height: 36px;\n color: var(--dsw-alias-label-primary);\n}\n\n.rail_1808205761 .searchButton_1808205761:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.listArea_1808205761 {\n min-height: 0;\n margin-left: -4px;\n margin-right: calc(-1 * var(--dsh-session-list-edge-inset));\n flex-direction: column;\n flex: 1;\n padding-left: 4px;\n display: flex;\n overflow: visible;\n}\n\n.rail_1808205761 .listArea_1808205761 {\n margin-left: 0;\n margin-right: 0;\n padding-left: 0;\n}\n\n.treeBody_1808205761 {\n flex-direction: column;\n flex: 1;\n min-height: 0;\n display: flex;\n position: relative;\n}\n\n.fade_1808205761 {\n left: 0;\n right: var(--dsh-session-list-edge-inset);\n background: linear-gradient(to bottom, transparent, var(--dsw-specific-sidebar-fill));\n pointer-events: none;\n height: 24px;\n position: absolute;\n bottom: 0;\n}\n\n.wide_1808205761 {\n animation: wide-in 0.2s var(--ds-ease-in-out);\n}\n\n@keyframes wide-in {\n 0% { opacity: 0; }\n}\n\n.list_1808205761 {\n min-height: 0;\n margin-left: -4px;\n margin-right: var(--dsh-session-list-scrollbar-offset);\n padding-left: 4px;\n padding-right: calc(var(--dsh-session-list-edge-inset) - var(--dsh-session-list-scrollbar-width) - var(--dsh-session-list-scrollbar-offset));\n scrollbar-gutter: stable;\n flex: 1;\n padding-bottom: 16px;\n overflow-y: auto;\n}\n\n.flatList_1808205761 > * + *,\n.searchTree_1808205761 > [role=treeitem] + [role=treeitem],\n.groupSection_1808205761 > * + * {\n margin-top: 2px;\n}\n\n.searchStatus_1808205761,\n.searchWarning_1808205761 {\n color: var(--dsw-alias-label-tertiary);\n padding: 10px 12px;\n font-size: 12px;\n line-height: 18px;\n}\n\n.searchWarning_1808205761 {\n color: var(--dsw-alias-label-secondary);\n}\n\n.groupSection_1808205761 {\n position: relative;\n}\n\n.groupSection_1808205761 + .groupSection_1808205761 {\n margin-top: 4px;\n}\n\n/* P3: workspace drag insertion markers (unused in P2). */\n.listTopDropIndicator_1808205761,\n.workspaceDropBefore_1808205761:before,\n.workspaceDropAfter_1808205761:after {\n content: \"\";\n z-index: 1;\n background:\n linear-gradient(55deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 5px 7px no-repeat,\n linear-gradient(125deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 5px / 5px 7px no-repeat,\n linear-gradient(var(--dsw-alias-state-business-primary) 0 0) 4px 5px / calc(100% - 4px) 2px no-repeat;\n pointer-events: none;\n height: 12px;\n position: absolute;\n left: 0;\n right: 0;\n}\n\n.listTopDropIndicator_1808205761 {\n top: -8px;\n left: 0;\n right: var(--dsh-session-list-edge-inset);\n}\n\n.listTopDropActive_1808205761 > .workspaceDropBefore_1808205761:first-child:before {\n display: none;\n}\n\n.workspaceDropBefore_1808205761:before {\n top: -8px;\n}\n\n.workspaceDropAfter_1808205761:after {\n bottom: -8px;\n}\n\n.sessionOverflowButton_1808205761 {\n cursor: pointer;\n text-align: left;\n width: 100%;\n height: 28px;\n color: var(--dsw-alias-label-tertiary);\n background: 0 0;\n border: none;\n border-radius: 8px;\n padding: 0 12px 0 28px;\n font-size: 12px;\n}\n\n.groupSection_1808205761 > .sessionOverflowButton_1808205761 {\n margin-top: 0;\n}\n\n.sessionOverflowButton_1808205761:hover {\n color: var(--dsw-alias-label-secondary);\n background: 0 0;\n}\n\n.empty_1808205761 {\n color: var(--dsw-alias-label-tertiary);\n padding: 16px 12px;\n font-size: 13px;\n}\n\n.renameInput_1808205761 {\n box-sizing: border-box;\n border: 0.5px solid var(--dsw-alias-border-l4);\n width: 100%;\n height: 44px;\n color: var(--dsw-alias-label-primary);\n background: 0 0;\n border-radius: 22px;\n outline: none;\n padding: 7px 14px;\n font-size: 14px;\n font-weight: 400;\n line-height: 22px;\n}\n\n.renameInput_1808205761:disabled {\n color: var(--dsw-alias-label-dimmed);\n}\n\n.renameError_1808205761 {\n color: var(--dsw-alias-state-error-primary);\n margin-top: 8px;\n font-size: 12px;\n line-height: 18px;\n}\n\n.deleteAction_1808205761:not(:disabled) {\n color: var(--dsw-alias-state-error-primary);\n}\n\n.deleteStatus_1808205761 {\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 18px;\n}\n\n/* Pre-delete facts of the worktree-removal dialog: one line per fact, the\n * destructive one (uncommitted files die with the folder) in error tone. */\n.removeFacts_1808205761 {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin-top: 8px;\n}\n\n.removeFact_1808205761 {\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-secondary);\n}\n\n.removeFactWarn_1808205761 {\n color: var(--dsw-alias-state-error-primary);\n}\n\n.modalAction_1808205761 {\n min-width: 72px;\n}\n\n.modalError_1808205761,\n.menuStatus_1808205761 {\n margin-top: 8px;\n font-size: 12px;\n line-height: 18px;\n}\n\n.modalError_1808205761 {\n color: var(--dsw-alias-state-error-primary);\n}\n\n.menuStatus_1808205761 {\n color: var(--dsw-alias-label-secondary);\n}\n\n/* Aggregation overlay: indent member workspaces and their sessions. */\n.memberIndent_1808205761 {\n margin-left: 16px;\n}\n\n.sessionsIndent_1808205761 {\n margin-left: 8px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .wide_1808205761 {\n animation: none;\n }\n\n .search_1808205761,\n .sectionLabel_1808205761,\n .searchSlot_1808205761,\n .searchInput_1808205761,\n .headerActions_1808205761 {\n transition: none;\n }\n}\n";
|
|
3781
5302
|
const tagId = "@laoyuehanni/dsh-git-worktree/GroupedSidebar.module.css";
|
|
3782
5303
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId + "\"]") === null) {
|
|
3783
5304
|
const tag = document.createElement("style");
|
|
@@ -3842,7 +5363,7 @@ window.__ModuleLoader__.load({
|
|
|
3842
5363
|
* relative time, view options, rail, and dialogs.
|
|
3843
5364
|
*
|
|
3844
5365
|
* Drag-reorder and the native `dsh.workspace.view.v5` store are P3. Adding a
|
|
3845
|
-
* workspace uses `
|
|
5366
|
+
* workspace uses `uiWorkspace.pickDirectory` rather than re-declaring the
|
|
3846
5367
|
* `sidebar.workspaces.directoryFlow` child hole (native already declared it;
|
|
3847
5368
|
* a second declarer throws).
|
|
3848
5369
|
*
|
|
@@ -4173,8 +5694,7 @@ window.__ModuleLoader__.load({
|
|
|
4173
5694
|
}
|
|
4174
5695
|
const created = createdAtMs(member.workspace.createdAt);
|
|
4175
5696
|
const hasRunning = member.workspace.sessionIds.some((id) => sessions.byId[id]?.running === true);
|
|
4176
|
-
const
|
|
4177
|
-
const canRemoveWorktree = member.label.type === "linked" && !occupied;
|
|
5697
|
+
const canRemoveWorktree = member.label.type === "linked" && !hasRunning;
|
|
4178
5698
|
const body = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProjectRowItem, {
|
|
4179
5699
|
row: {
|
|
4180
5700
|
key,
|
|
@@ -4231,11 +5751,11 @@ window.__ModuleLoader__.load({
|
|
|
4231
5751
|
}) : body;
|
|
4232
5752
|
}
|
|
4233
5753
|
function GroupedSidebar(props) {
|
|
4234
|
-
const { t } = props;
|
|
4235
|
-
const workspaces = (
|
|
4236
|
-
const sessions = (
|
|
4237
|
-
const host = (
|
|
4238
|
-
const directoryFlowAvailable = (
|
|
5754
|
+
const { t, useWorkspaces, useSessions, useHostInfo, useDirectoryFlow } = props;
|
|
5755
|
+
const workspaces = useWorkspaces((state) => state);
|
|
5756
|
+
const sessions = useSessions((state) => state);
|
|
5757
|
+
const host = useHostInfo((state) => state);
|
|
5758
|
+
const directoryFlowAvailable = useDirectoryFlow((occupied) => occupied);
|
|
4239
5759
|
const items = workspaces.items;
|
|
4240
5760
|
const home = host?.home;
|
|
4241
5761
|
const signature = (0, react.useMemo)(() => [...items].map((item) => item.path).sort().join("\n"), [items]);
|
|
@@ -4551,20 +6071,23 @@ window.__ModuleLoader__.load({
|
|
|
4551
6071
|
const target = wtRemoveTarget;
|
|
4552
6072
|
setWtRemoving(true);
|
|
4553
6073
|
setWtRemoveError(null);
|
|
4554
|
-
(
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
}
|
|
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
|
+
});
|
|
4568
6091
|
};
|
|
4569
6092
|
const now = Date.now();
|
|
4570
6093
|
const strayGroups = (0, react.useMemo)(() => deriveStrayGroups(items, sessionList, archived), [
|
|
@@ -5098,39 +6621,48 @@ window.__ModuleLoader__.load({
|
|
|
5098
6621
|
//#region src/client/locales.ts
|
|
5099
6622
|
/** English dictionary — complete by construction. */
|
|
5100
6623
|
const en = {
|
|
5101
|
-
chipWorktree: "Worktree",
|
|
5102
|
-
worktreeToggle: "Create an isolated worktree",
|
|
5103
6624
|
menuBranches: "Branches",
|
|
5104
6625
|
menuLocalBranches: "Local branches",
|
|
5105
6626
|
menuWorktrees: "Worktrees",
|
|
5106
6627
|
menuRemoteBranches: "Remote branches",
|
|
5107
|
-
mainRepoOnly: "Branch operations start from the main checkout",
|
|
5108
6628
|
menuSearchPlaceholder: "Search branches",
|
|
5109
6629
|
menuNoMatches: "No matching branches",
|
|
5110
6630
|
menuNoBranches: "No branches yet",
|
|
5111
6631
|
menuLocate: "Locate current branch",
|
|
5112
6632
|
menuExpandAll: "Expand all",
|
|
5113
6633
|
menuCollapseAll: "Collapse all",
|
|
5114
|
-
menuNewBranch: "Create branch from current",
|
|
5115
6634
|
menuNewBranchPlaceholder: "New branch name",
|
|
5116
6635
|
menuNewBranchBad: "Git will not accept this name",
|
|
5117
6636
|
menuNewBranchExists: "A branch with this name already exists",
|
|
5118
6637
|
menuFetch: "Fetch",
|
|
5119
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…",
|
|
5120
6657
|
fetchDone: "Remote branches synced",
|
|
5121
6658
|
updateDone: "{branch} fast-forwarded to its upstream",
|
|
5122
6659
|
updateUpToDate: "Already up to date",
|
|
5123
6660
|
aheadTitle: "{n} commits ahead of upstream",
|
|
5124
6661
|
behindTitle: "{n} commits behind upstream",
|
|
5125
|
-
switchAsk: "Switch to {branch}?",
|
|
5126
|
-
switchAskRemote: "Check out this remote branch?",
|
|
5127
|
-
switchBusy: "Switching…",
|
|
5128
6662
|
worktreeAskNew: "Create a worktree from {branch}?",
|
|
5129
6663
|
worktreeAskRemote: "Create a worktree from this remote branch?",
|
|
5130
6664
|
worktreeAskReuse: "Switch to the {branch} worktree?",
|
|
5131
|
-
worktreeAskCutOut: "Cut a new branch out of {branch} into an isolated worktree",
|
|
5132
6665
|
worktreeBusy: "Creating…",
|
|
5133
|
-
createBranchTitle: "New branch from {branch}",
|
|
5134
6666
|
createBranchBusy: "Creating…",
|
|
5135
6667
|
actionCancel: "Cancel",
|
|
5136
6668
|
actionConfirm: "Confirm",
|
|
@@ -5157,10 +6689,48 @@ window.__ModuleLoader__.load({
|
|
|
5157
6689
|
sidebarMain: "Main",
|
|
5158
6690
|
sidebarRailExpand: "Expand sidebar",
|
|
5159
6691
|
cardGroupSidebarLabel: "Group workspaces",
|
|
5160
|
-
cardGroupSidebarHint: "
|
|
6692
|
+
cardGroupSidebarHint: "Collect same-repo workspaces into one tree. Turn it off at any time to get the native list back.",
|
|
5161
6693
|
cardGroupSidebarMark: "(experimental)",
|
|
5162
|
-
cardGroupSidebarNote: "Turn it off to restore the native list if anything breaks; we will switch to the official API as soon as it ships.",
|
|
5163
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",
|
|
5164
6734
|
"group.ungrouped": "Ungrouped",
|
|
5165
6735
|
"session.new": "New Session",
|
|
5166
6736
|
"section.workspaces": "Workspaces",
|
|
@@ -5253,39 +6823,48 @@ window.__ModuleLoader__.load({
|
|
|
5253
6823
|
};
|
|
5254
6824
|
/** 中文词典。 */
|
|
5255
6825
|
const zh = {
|
|
5256
|
-
chipWorktree: "工作树",
|
|
5257
|
-
worktreeToggle: "创建隔离工作树",
|
|
5258
6826
|
menuBranches: "分支",
|
|
5259
6827
|
menuLocalBranches: "本地分支",
|
|
5260
6828
|
menuWorktrees: "工作树",
|
|
5261
6829
|
menuRemoteBranches: "远程分支",
|
|
5262
|
-
mainRepoOnly: "分支操作请在主仓库发起",
|
|
5263
6830
|
menuSearchPlaceholder: "搜索分支",
|
|
5264
6831
|
menuNoMatches: "没有匹配的分支",
|
|
5265
6832
|
menuNoBranches: "暂无分支",
|
|
5266
6833
|
menuLocate: "定位当前分支",
|
|
5267
6834
|
menuExpandAll: "全部展开",
|
|
5268
6835
|
menuCollapseAll: "全部折叠",
|
|
5269
|
-
menuNewBranch: "从当前分支新建分支",
|
|
5270
6836
|
menuNewBranchPlaceholder: "新分支名称",
|
|
5271
6837
|
menuNewBranchBad: "Git 不接受该名称",
|
|
5272
6838
|
menuNewBranchExists: "同名分支已存在",
|
|
5273
6839
|
menuFetch: "提取",
|
|
5274
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: "删除中…",
|
|
5275
6859
|
fetchDone: "远程分支已同步",
|
|
5276
6860
|
updateDone: "{branch} 已快进到远程最新",
|
|
5277
6861
|
updateUpToDate: "已是最新",
|
|
5278
6862
|
aheadTitle: "领先上游 {n} 个提交",
|
|
5279
6863
|
behindTitle: "落后上游 {n} 个提交",
|
|
5280
|
-
switchAsk: "是否切到 {branch}?",
|
|
5281
|
-
switchAskRemote: "是否检出该远程分支?",
|
|
5282
|
-
switchBusy: "切换中…",
|
|
5283
6864
|
worktreeAskNew: "是否从 {branch} 新建工作树?",
|
|
5284
6865
|
worktreeAskRemote: "从该远程分支新建工作树?",
|
|
5285
6866
|
worktreeAskReuse: "是否切到 {branch} 工作树?",
|
|
5286
|
-
worktreeAskCutOut: "从当前分支 {branch} 切出新分支到隔离工作树",
|
|
5287
6867
|
worktreeBusy: "创建中…",
|
|
5288
|
-
createBranchTitle: "从 {branch} 新建分支",
|
|
5289
6868
|
createBranchBusy: "创建中…",
|
|
5290
6869
|
actionCancel: "取消",
|
|
5291
6870
|
actionConfirm: "确认",
|
|
@@ -5312,10 +6891,48 @@ window.__ModuleLoader__.load({
|
|
|
5312
6891
|
sidebarMain: "主仓库",
|
|
5313
6892
|
sidebarRailExpand: "展开侧栏",
|
|
5314
6893
|
cardGroupSidebarLabel: "聚合工作区",
|
|
5315
|
-
cardGroupSidebarHint: "
|
|
6894
|
+
cardGroupSidebarHint: "把同仓库的工作区收成一棵树。出问题可随时关掉,回到原生列表。",
|
|
5316
6895
|
cardGroupSidebarMark: "(测试功能)",
|
|
5317
|
-
cardGroupSidebarNote: "使用中若遇问题,关掉即可回到原生;官方接口一旦开放,会第一时间改用原生实现。",
|
|
5318
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} 个工作树自动清理失败",
|
|
5319
6936
|
"group.ungrouped": "未分组",
|
|
5320
6937
|
"session.new": "新会话",
|
|
5321
6938
|
"section.workspaces": "工作区",
|
|
@@ -5415,12 +7032,14 @@ window.__ModuleLoader__.load({
|
|
|
5415
7032
|
* imported: a client package must not depend on a Host package.
|
|
5416
7033
|
*/
|
|
5417
7034
|
const GIT_WORKTREE_NS = "git-worktree";
|
|
5418
|
-
/** Required services: the slot ledger, session/workspace
|
|
5419
|
-
*
|
|
7035
|
+
/** Required services: the slot ledger, session/workspace runtimes, the
|
|
7036
|
+
* workspace navigation/directory face, copy, and the settings scope backing
|
|
7037
|
+
* the plugin configuration card. */
|
|
5420
7038
|
const inject = [
|
|
5421
7039
|
"slots",
|
|
5422
7040
|
"sessions",
|
|
5423
7041
|
"workspaces",
|
|
7042
|
+
"uiWorkspace",
|
|
5424
7043
|
"locale",
|
|
5425
7044
|
"connection",
|
|
5426
7045
|
"remote",
|
|
@@ -5431,10 +7050,92 @@ window.__ModuleLoader__.load({
|
|
|
5431
7050
|
zh,
|
|
5432
7051
|
en
|
|
5433
7052
|
}), "git-worktree: dictionaries");
|
|
5434
|
-
const chipInjected = () => ({
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
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
|
+
});
|
|
5438
7139
|
ctx.slots.inject("conversation.input.left", () => ctx.slots.register({
|
|
5439
7140
|
name: "conversation.input.left",
|
|
5440
7141
|
id: "git-worktree",
|
|
@@ -5503,13 +7204,11 @@ window.__ModuleLoader__.load({
|
|
|
5503
7204
|
seatReadyResolve = resolve;
|
|
5504
7205
|
});
|
|
5505
7206
|
const injectFace = () => ({
|
|
5506
|
-
workspacesList: ctx.workspaces.list,
|
|
5507
|
-
sessionsList: ctx.sessions.list,
|
|
5508
7207
|
openSession: (sessionId) => {
|
|
5509
7208
|
ctx.sessions.open(sessionId);
|
|
5510
7209
|
},
|
|
5511
7210
|
startSession: (workspaceId) => {
|
|
5512
|
-
ctx.
|
|
7211
|
+
ctx.uiWorkspace.startSession(workspaceId);
|
|
5513
7212
|
},
|
|
5514
7213
|
loadFacts: async (paths) => {
|
|
5515
7214
|
const result = await requestGroupWorktrees(paths);
|
|
@@ -5568,11 +7267,16 @@ window.__ModuleLoader__.load({
|
|
|
5568
7267
|
if (!result.ok) throw new Error(result.error);
|
|
5569
7268
|
},
|
|
5570
7269
|
createWorkspace: (input) => ctx.workspaces.create(input),
|
|
5571
|
-
pickDirectory: () => ctx.
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
7270
|
+
pickDirectory: () => ctx.uiWorkspace.pickDirectory(),
|
|
7271
|
+
hooks: {
|
|
7272
|
+
hostInfo: {
|
|
7273
|
+
getSnapshot: () => ctx.remote.$host,
|
|
7274
|
+
subscribe: (listener) => ctx.on("connection/reset", listener)
|
|
7275
|
+
},
|
|
7276
|
+
directoryFlow: {
|
|
7277
|
+
getSnapshot: () => ctx.slots.entries("sidebar.workspaces.directoryFlow").length > 0,
|
|
7278
|
+
subscribe: (listener) => ctx.slots.subscribe("sidebar.workspaces.directoryFlow", listener)
|
|
7279
|
+
}
|
|
5576
7280
|
},
|
|
5577
7281
|
onReady: () => {
|
|
5578
7282
|
if (epoch === seatEpoch) finishSeat();
|
|
@@ -5625,6 +7329,54 @@ window.__ModuleLoader__.load({
|
|
|
5625
7329
|
await waitSnapshotMatches(enabled);
|
|
5626
7330
|
await syncGroupingSeat();
|
|
5627
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
|
+
});
|
|
5628
7380
|
const form = new CardForm(groupingScope, waitForGroupingSeat);
|
|
5629
7381
|
const store = form.bind();
|
|
5630
7382
|
ctx.slots.inject("settings.plugin.item", () => ctx.slots.register({
|
|
@@ -5635,7 +7387,8 @@ window.__ModuleLoader__.load({
|
|
|
5635
7387
|
inject: () => ({
|
|
5636
7388
|
hooks: { gitWorktreeCard: store },
|
|
5637
7389
|
...form.actions(),
|
|
5638
|
-
pickDirectory: () => ctx.
|
|
7390
|
+
pickDirectory: () => ctx.uiWorkspace.pickDirectory(),
|
|
7391
|
+
manager: managerFace()
|
|
5639
7392
|
})
|
|
5640
7393
|
}, GitWorktreeCard));
|
|
5641
7394
|
syncGroupingSeat();
|