@aiti-ai/ext-shared 0.1.13 → 0.1.16
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 +22 -12
- package/README.zh-CN.md +1 -1
- package/agent-spawn-env.test.mjs +92 -0
- package/agent-spawn-env.ts +92 -1
- package/dev-pack.mjs +16 -3
- package/dock-icons.ts +145 -13
- package/ext-display-names.ts +108 -78
- package/ext-entry-contracts.test.mjs +8 -10
- package/ext-float-dock-core.ts +66 -9
- package/ext-float-dock.test.mjs +1 -0
- package/ext-float-dock.ts +181 -32
- package/ext-protocol.mjs +1 -1
- package/git-ops-client/api.mjs +3 -1
- package/git-ops-client/branch-panel.tsx +115 -20
- package/git-ops-client/graph-lanes.mjs +118 -0
- package/git-ops-client/graph-lanes.test.mjs +132 -0
- package/git-ops-client/i18n.mjs +9 -0
- package/icons/box.svg +1 -0
- package/icons/discussion.svg +1 -0
- package/icons/film.svg +1 -0
- package/icons/flag.svg +1 -0
- package/icons/message-square-text.svg +1 -0
- package/icons/qr-code.svg +1 -0
- package/icons/star.svg +1 -0
- package/menu-row.tsx +92 -0
- package/new-session-cwd.test.mjs +4 -4
- package/package.json +3 -3
- package/path-breadcrumb.tsx +363 -0
- package/path-crumbs.test.mjs +91 -0
- package/path-crumbs.ts +102 -0
- package/pi-fork-rpc/wire.test.mjs +4 -3
- package/pi-fork-rpc/wire.ts +39 -2
- package/popup-anchor.ts +27 -2
- package/soffice-panel.ts +39 -30
- package/typo-search.mjs +79 -0
- package/typo-search.test.mjs +57 -0
- package/ui-dialogs.test.mjs +59 -4
- package/ui-dialogs.ts +95 -9
- package/sync-gate.test.mjs +0 -93
- package/sync-mirror.test.mjs +0 -85
package/ext-float-dock.ts
CHANGED
|
@@ -11,14 +11,89 @@
|
|
|
11
11
|
* 控制浮窗/嵌入两 face 的显隐。
|
|
12
12
|
*/
|
|
13
13
|
import { useEffect, useState, createElement as h } from "react";
|
|
14
|
-
import { clampToViewport, fixedOrigin } from "./popup-anchor";
|
|
15
|
-
|
|
14
|
+
import { clampToViewport, fixedOrigin, zoomFactorOf } from "./popup-anchor";
|
|
15
|
+
// ── header/menu words: local bilingual table below (menuWord); core float/zone words live in ext-float-dock-core (dockWord) ──
|
|
16
|
+
const DOCK_MENU_WORDS: Record<string, { "zh-CN": string; en: string }> = {
|
|
17
|
+
expand: { "zh-CN": "展开", en: "Expand" },
|
|
18
|
+
collapse: { "zh-CN": "折叠", en: "Collapse" },
|
|
19
|
+
block: { "zh-CN": "区块", en: "Block" },
|
|
20
|
+
position: { "zh-CN": "切换停靠位置", en: "Change dock position" },
|
|
21
|
+
actions: { "zh-CN": "区块操作", en: "Block actions" },
|
|
22
|
+
move: { "zh-CN": "移动", en: "Move" },
|
|
23
|
+
pin: { "zh-CN": "钉住", en: "Pin" },
|
|
24
|
+
unpin: { "zh-CN": "取消钉住", en: "Unpin" },
|
|
25
|
+
moveUp: { "zh-CN": "上移", en: "Move up" },
|
|
26
|
+
moveDown: { "zh-CN": "下移", en: "Move down" },
|
|
27
|
+
tools: { "zh-CN": "工具", en: "Tools" },
|
|
28
|
+
removeInstance: { "zh-CN": "移除本实例", en: "Remove this instance" },
|
|
29
|
+
close: { "zh-CN": "关闭", en: "Close" },
|
|
30
|
+
zones: { "zh-CN": "停靠方位", en: "Dock zones" },
|
|
31
|
+
defaultSuffix: { "zh-CN": "(默认)", en: " (default)" },
|
|
32
|
+
};
|
|
33
|
+
function menuWord(key: keyof typeof DOCK_MENU_WORDS): string {
|
|
34
|
+
let loc = "en";
|
|
35
|
+
try { loc = window.localStorage.getItem("pi-locale") || "en"; } catch { /* storage unavailable */ }
|
|
36
|
+
const w = DOCK_MENU_WORDS[key];
|
|
37
|
+
return (w as any)[loc === "zh-CN" ? "zh-CN" : "en"] ?? w.en;
|
|
38
|
+
}
|
|
39
|
+
import { DOCK_ICON_NODES, DOCK_ICON_SVG_ROOT_PROPS, dockIconReactAttrs, type DockIconName } from "./dock-icons";
|
|
16
40
|
|
|
17
41
|
/** 图标元素(React/h 版;dock-icons 单一数据源):stroke=2 线稿、currentColor。
|
|
18
42
|
* 与 DOM 版 createDockIconSvg(core appendDockIconRow 内)同图形同尺寸。 */
|
|
19
43
|
export function dockIconEl(name: DockIconName, size = 16): unknown {
|
|
20
44
|
return h("svg", { width: size, height: size, ...DOCK_ICON_SVG_ROOT_PROPS, "aria-hidden": "true" },
|
|
21
|
-
|
|
45
|
+
// kebab-case SVG attrs (stroke-width from thin()) must be camelized for React JSX
|
|
46
|
+
...DOCK_ICON_NODES[name].map((n, i) => h(n.tag, { key: i, ...dockIconReactAttrs(n.attrs) })));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** CSS-mask span: icon asset URL tinted with currentColor (same rendering as the
|
|
50
|
+
* host's renderExtItemIcon). */
|
|
51
|
+
function maskedIconSpan(url: string, size: number): unknown {
|
|
52
|
+
return h("span", { "aria-hidden": "true", style: {
|
|
53
|
+
display: "inline-block", width: size, height: size, flexShrink: 0,
|
|
54
|
+
background: "currentColor",
|
|
55
|
+
WebkitMaskImage: `url("${url}")`, maskImage: `url("${url}")`,
|
|
56
|
+
WebkitMaskRepeat: "no-repeat", maskRepeat: "no-repeat",
|
|
57
|
+
WebkitMaskPosition: "center", maskPosition: "center",
|
|
58
|
+
WebkitMaskSize: "contain", maskSize: "contain",
|
|
59
|
+
} });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Block-header icon declaration → React element (the DockBody icon prop contract).
|
|
63
|
+
* Five forms, aligned with the host's renderExtItemIcon (ExtUiItem.icon) contract so
|
|
64
|
+
* third-party extensions (npm-installed, not importing this module's name table) can
|
|
65
|
+
* fully self-host their icons, on both the static shell and the real face:
|
|
66
|
+
* 1. React element (h()-built) → rendered as-is (fully self-held; the third-party main path);
|
|
67
|
+
* 2. { svg: "<path …/>" } → inline SVG markup (24×24, stroke=currentColor; same shape
|
|
68
|
+
* as the host's {svg} form);
|
|
69
|
+
* 3. { url: "https://…/icon.svg" } → CSS-mask span tinted with currentColor (expects a
|
|
70
|
+
* complete URL: the host-derived static-entry meta.iconUrl, or a value the extension
|
|
71
|
+
* resolved itself via its own ctx.apiUrl);
|
|
72
|
+
* 4. a DOCK_ICON_NODES name-table hit → dockIconEl (built-in extensions' shortcut;
|
|
73
|
+
* also available to third parties via the @aiti-ai/ext-shared npm package);
|
|
74
|
+
* 5. any other string → emoji/text glyph (host-identical fallback).
|
|
75
|
+
* A bare relative path "icons/x.svg" (the host manifest form) is NOT resolved here — it
|
|
76
|
+
* needs extId + the basePath-aware apiUrl and this module is ctx-free. On the static-shell
|
|
77
|
+
* path the host derives meta.iconUrl and the shell passes form ③; on the real-face path
|
|
78
|
+
* the owning extension resolves it itself (it has ctx.apiUrl). With an old host that lacks
|
|
79
|
+
* the derivation, the static shell simply renders no icon (graceful, no emoji-text fallback). */
|
|
80
|
+
export function dockIconFromDecl(icon: unknown, size = 13): unknown {
|
|
81
|
+
if (icon == null) return null;
|
|
82
|
+
if (typeof icon === "object") {
|
|
83
|
+
const o = icon as Record<string, unknown>;
|
|
84
|
+
if (typeof o.svg === "string") {
|
|
85
|
+
return h("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor",
|
|
86
|
+
strokeWidth: 2, strokeLinecap: "round" as const, strokeLinejoin: "round" as const, "aria-hidden": "true",
|
|
87
|
+
dangerouslySetInnerHTML: { __html: o.svg } });
|
|
88
|
+
}
|
|
89
|
+
if (typeof o.url === "string") return maskedIconSpan(o.url, size);
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
if (typeof icon !== "string" || !icon) return null;
|
|
93
|
+
if (/^https?:\/\//.test(icon)) return maskedIconSpan(icon, size);
|
|
94
|
+
if ((DOCK_ICON_NODES as Record<string, unknown>)[icon]) return dockIconEl(icon as DockIconName, size);
|
|
95
|
+
if (icon.endsWith(".svg")) return null; // relative asset path: see doc above (host derives meta.iconUrl)
|
|
96
|
+
return h("span", { style: { fontSize: size, lineHeight: 1 } }, icon); // emoji/text glyph
|
|
22
97
|
}
|
|
23
98
|
|
|
24
99
|
/* ── 左栏区块 zone 泛化(sidebar 统一 dock 方案 §3.8)──
|
|
@@ -35,6 +110,7 @@ export {
|
|
|
35
110
|
SIDEBAR_COLLAPSE_PREFIX, SIDEBAR_ORDER_KEY,
|
|
36
111
|
SIDEBAR_COLLAPSE_EVENT, SIDEBAR_ORDER_EVENT, SIDEBAR_MOVE_EVENT, FLOAT_INSTALLED_EVENT,
|
|
37
112
|
readBlockCollapsed, writeBlockCollapsed, seedBlockCollapsedDefault,
|
|
113
|
+
SIDEBAR_DISMISS_PREFIX, readBlockDismissed, writeBlockDismissed,
|
|
38
114
|
readDockOrder, writeDockOrder,
|
|
39
115
|
effectiveBlockOrder, moveBlockKey, migrateLegacyCollapseKeys,
|
|
40
116
|
createDockHeaderStore, localDockHeaderStore, DOCK_HEADER_PENDING_TTL,
|
|
@@ -54,7 +130,7 @@ import {
|
|
|
54
130
|
floatApi, closePanel, positionMenuModel, seedDockDefault, declareDockZones, DOCK_ZONE_LABELS,
|
|
55
131
|
} from "./ext-float-dock-core";
|
|
56
132
|
import { usePresent, useGate } from "./ext-float-dock-lite";
|
|
57
|
-
import type { DockHeaderAction, DockHeaderCommands, DockHeaderState, DockHeaderStore, DockMenuItem, DockIconRowItem } from "./ext-float-dock-core";
|
|
133
|
+
import type { DockHeaderAction, DockHeaderCommands, DockHeaderState, DockHeaderStore, DockMenuItem, DockIconRowItem, MenuIconRowItem } from "./ext-float-dock-core";
|
|
58
134
|
|
|
59
135
|
|
|
60
136
|
/* ── 左栏区块栈:折叠/排序/迁移的 React 绑定见文件尾(useBlockCollapsed/useDockOrder);
|
|
@@ -175,7 +251,7 @@ type DockMenuRow =
|
|
|
175
251
|
| { type: "head"; label: string }
|
|
176
252
|
| { type: "sep" }
|
|
177
253
|
| { type: "item"; label: string; icon?: unknown; badge?: number | string; hint?: string; active?: boolean; alwaysRun?: boolean; disabled?: boolean; run: () => void }
|
|
178
|
-
| { type: "icons"; label?: string; icon?: unknown; items: DockIconRowItem
|
|
254
|
+
| { type: "icons"; label?: string; icon?: unknown; items: Array<DockIconRowItem | MenuIconRowItem> };
|
|
179
255
|
|
|
180
256
|
/** 停靠面板头行(chrome="section",左栏区块统一头行 v3):展开箭头 + 标题位 +
|
|
181
257
|
* **声明式业务按钮**(自适应宽度;放不下自动进 ⋮「工具」组)+ **常驻 detach**(位置菜单)+
|
|
@@ -187,6 +263,16 @@ export function DockBody(props: {
|
|
|
187
263
|
itemKey: string;
|
|
188
264
|
zone?: DockZone;
|
|
189
265
|
title?: string;
|
|
266
|
+
/** Collapsed-header icon left of the title (chrome="section" only). Five forms
|
|
267
|
+
* (see dockIconFromDecl): React element / {svg} markup / {url} asset URL /
|
|
268
|
+
* dock-icons name string / emoji-text — third-party extensions carry their own
|
|
269
|
+
* icons without depending on the built-in name table. */
|
|
270
|
+
icon?: unknown;
|
|
271
|
+
/** Collapsed-header hover tooltip override. chrome="section" headers default to the
|
|
272
|
+
* functional hint (drag-handle text for dockable; none for reserved). Provide
|
|
273
|
+
* headerHint for a semantic description instead — typically on reserved blocks whose
|
|
274
|
+
* header would otherwise be mute. */
|
|
275
|
+
headerHint?: string;
|
|
190
276
|
/** "section":统一 ⋮ 头行(左栏区块);"tab":无头行(控件在宿主 TabBar 页签上) */
|
|
191
277
|
chrome?: "section" | "tab";
|
|
192
278
|
/** 可停靠位置全集(detach 位置菜单;缺省 [zone]——单 zone 面板无需传) */
|
|
@@ -211,6 +297,11 @@ export function DockBody(props: {
|
|
|
211
297
|
onNewWindow?: () => void;
|
|
212
298
|
/** 扩展附加菜单项(钉住等多实例专属动作;插在区块操作段) */
|
|
213
299
|
extraMenuItems?: Array<{ label: string; icon?: unknown; hint?: string; active?: boolean; alwaysRun?: boolean; run: () => void }>;
|
|
300
|
+
/** 移动行钉住钮(2026-11-24 菜单单行化:钉住并入「移动」图标排首位)——提供即渲染
|
|
301
|
+
* (pin/pin-off 图标随钉住态切换);不传则移动行只有上移/下移。 */
|
|
302
|
+
moveRowPin?: { isPinned: () => boolean; toggle: () => void } | null;
|
|
303
|
+
/** 隐藏区块段「关闭」item(关闭已并入内容 ⋯ 菜单「窗口」图标排时置 true,防重复入口)。 */
|
|
304
|
+
hideCloseItem?: boolean;
|
|
214
305
|
/** 标题位自定义(如文件夹的目录切换器);提供时替换标题文本(title 仍用于 aria/兜底) */
|
|
215
306
|
renderTitle?: () => unknown;
|
|
216
307
|
/** 声明式头行按钮(face 本地声明;与服务/本地 store 注册的 buttons 合并,prop 优先按 id 去重) */
|
|
@@ -256,7 +347,12 @@ export function DockBody(props: {
|
|
|
256
347
|
if (m.height > below && above > below) top = b.top - gap - m.height; // 上翻
|
|
257
348
|
const c = clampToViewport(b.right - m.width, top, m.width, m.height, pad);
|
|
258
349
|
const o = fixedOrigin(menuEl);
|
|
259
|
-
|
|
350
|
+
// Panel UI scale (CSS zoom on the sidebar / right-panel containers): b/m/o are all
|
|
351
|
+
// viewport-space, but the menu's written inset is rendered scaled by the ancestor
|
|
352
|
+
// zoom chain — divide back so the rendered position lands on the expected viewport
|
|
353
|
+
// coordinates (zoom does not create a containing block; orthogonal to fixedOrigin).
|
|
354
|
+
const z = zoomFactorOf(menuEl);
|
|
355
|
+
const next = { left: (c.left - o.x) / z, top: (c.top - o.y) / z };
|
|
260
356
|
setMenuPos((cur) => (cur && cur.left === next.left && cur.top === next.top) ? cur : next);
|
|
261
357
|
}, [menu, menuEl]);
|
|
262
358
|
useEffect(() => {
|
|
@@ -267,9 +363,20 @@ export function DockBody(props: {
|
|
|
267
363
|
if (t && menu.anchor?.contains(t)) return;
|
|
268
364
|
setMenu(null);
|
|
269
365
|
};
|
|
366
|
+
// 锚点打开时位置快照(scroll 关闭的位移阈值判据)
|
|
367
|
+
let anchorTop: number | null = null;
|
|
368
|
+
let anchorLeft: number | null = null;
|
|
369
|
+
try { const a = menu.anchor?.getBoundingClientRect?.(); if (a) { anchorTop = a.top; anchorLeft = a.left; } } catch { /* ignore */ }
|
|
270
370
|
const onScroll = (e: any) => {
|
|
271
|
-
//
|
|
371
|
+
// 菜单内部滚动豁免(长菜单必须可滚);菜单外滚动在锚点真被滚走时才关(fixed 弹层滞留旧位=错位)。
|
|
372
|
+
// 位移阈值容错(2026-11-15 小屏反馈「菜单经常自己关掉」):手机地址栏收缩/橡皮筋/惯性
|
|
373
|
+
// 假 scroll 时锚点没挪(fixed 侧栏 overlay 不随 body 滚)→ 不关;错位超阈值才关。
|
|
272
374
|
if (menuEl && e.target instanceof Node && menuEl.contains(e.target)) return;
|
|
375
|
+
try {
|
|
376
|
+
const a = menu.anchor?.getBoundingClientRect?.();
|
|
377
|
+
if (a && anchorTop !== null && anchorLeft !== null
|
|
378
|
+
&& Math.abs(a.top - anchorTop) < 4 && Math.abs(a.left - anchorLeft) < 4) return;
|
|
379
|
+
} catch { /* ignore */ }
|
|
273
380
|
setMenu(null);
|
|
274
381
|
};
|
|
275
382
|
document.addEventListener("mousedown", onDown);
|
|
@@ -327,46 +434,67 @@ export function DockBody(props: {
|
|
|
327
434
|
// ── ⋮ 主菜单(三段:工具溢出 / 内容注册菜单项 / 区块操作)──
|
|
328
435
|
const buildMainMenu = (): DockMenuRow[] => {
|
|
329
436
|
const out: DockMenuRow[] = [];
|
|
437
|
+
// 「移动」图标行构建(含可选钉住钮首位):menuItems 有 moveRow 占位时在占位处插入
|
|
438
|
+
//(前移),否则回落区块段默认位。内容未挂载(折叠未展开过)时 menuItems 缺席,
|
|
439
|
+
// 区块段默认移动排同样走此构建——钉住钮不再只随挂载态出现(2026-11-15)。
|
|
440
|
+
// Sorting is dockable-only: reserved blocks (fixed resident blocks like projects) get
|
|
441
|
+
// no drag handle and no "move" row in the ⋮ menu.
|
|
442
|
+
const sortable = kind !== "reserved";
|
|
443
|
+
const buildMoveRow = (): DockMenuRow => ({
|
|
444
|
+
type: "icons", label: menuWord("move"), icon: dockIconEl("move-diagonal-2", 13), items: [
|
|
445
|
+
...(props.moveRowPin ? [{
|
|
446
|
+
key: "pin",
|
|
447
|
+
icon: (props.moveRowPin.isPinned() ? "pin-off" : "pin") as any,
|
|
448
|
+
label: props.moveRowPin.isPinned() ? menuWord("unpin") : menuWord("pin"),
|
|
449
|
+
run: () => props.moveRowPin!.toggle(),
|
|
450
|
+
}] : []),
|
|
451
|
+
{ key: "move-up", icon: "chevron-up", label: menuWord("moveUp"), run: () => requestBlockMove(blockKey, -1) },
|
|
452
|
+
{ key: "move-down", icon: "chevron-down", label: menuWord("moveDown"), run: () => requestBlockMove(blockKey, 1) },
|
|
453
|
+
],
|
|
454
|
+
});
|
|
330
455
|
if (overflowActions.length > 0) {
|
|
331
|
-
out.push({ type: "head", label: "
|
|
456
|
+
out.push({ type: "head", label: menuWord("tools") });
|
|
332
457
|
for (const a of overflowActions) out.push({ type: "item", label: a.title, icon: a.icon, badge: a.badge, active: a.active, alwaysRun: true, disabled: a.disabled, run: a.onClick });
|
|
333
458
|
}
|
|
334
459
|
if (storeData.menuItems && storeData.menuItems.length > 0) {
|
|
335
460
|
if (out.length > 0) out.push({ type: "sep" });
|
|
461
|
+
let moveRowInserted = false;
|
|
336
462
|
for (const m of storeData.menuItems) {
|
|
463
|
+
if (m.kind === "moveRow" && sortable && !moveRowInserted) { moveRowInserted = true; out.push(buildMoveRow()); continue; }
|
|
337
464
|
if (m.kind === "head") out.push({ type: "head", label: m.label });
|
|
338
465
|
else if (m.kind === "sep") out.push({ type: "sep" });
|
|
466
|
+
else if (m.kind === "iconsRow") out.push({ type: "icons", label: m.label, items: m.items });
|
|
339
467
|
else out.push({ type: "item", label: m.label, icon: m.icon, hint: m.hint, active: m.active, alwaysRun: m.alwaysRun, disabled: m.disabled, run: m.run });
|
|
340
468
|
}
|
|
469
|
+
if (chrome === "section" && sortable && !moveRowInserted) out.push(buildMoveRow());
|
|
341
470
|
}
|
|
342
471
|
const ops: DockMenuRow[] = [];
|
|
343
|
-
if (chrome === "section") {
|
|
472
|
+
if (chrome === "section" && sortable && !(storeData.menuItems || []).some((m) => m.kind === "moveRow")) {
|
|
344
473
|
// 单行「移动」(2026-09-15 用户拍板回归 §3.5 图标排形态):行首对角双箭头图标(move-diagonal-2,
|
|
345
474
|
// 左上+右下)+ 行名呈 icon+text,与区块段其余行呼应;右侧 chevron-up/down 即时上移/下移。
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
] });
|
|
475
|
+
// menuItems 含 moveRow 占位时移动行已前移插入(不在此重复)。与挂载态 buildMoveRow
|
|
476
|
+
// 同源:钉住钮(moveRowPin 提供时)在未挂载折叠态同样可见可用。
|
|
477
|
+
ops.push(buildMoveRow());
|
|
350
478
|
}
|
|
351
479
|
if (kind === "reserved" && typeof props.onRemove === "function") {
|
|
352
|
-
ops.push({ type: "item", label: "
|
|
480
|
+
ops.push({ type: "item", label: menuWord("removeInstance"), icon: dockIconEl("trash", 13), run: () => props.onRemove!() });
|
|
353
481
|
}
|
|
354
482
|
if (Array.isArray(props.extraMenuItems)) {
|
|
355
483
|
for (const m of props.extraMenuItems) ops.push({ type: "item", label: m.label, icon: m.icon, hint: m.hint, active: m.active, alwaysRun: m.alwaysRun, run: m.run });
|
|
356
484
|
}
|
|
357
|
-
if (kind === "dockable" && chrome === "section") {
|
|
358
|
-
ops.push({ type: "item", label: "
|
|
485
|
+
if (kind === "dockable" && chrome === "section" && props.hideCloseItem !== true) {
|
|
486
|
+
ops.push({ type: "item", label: menuWord("close"), icon: dockIconEl("x", 13), run: () => (props.onClose ? props.onClose() : closePanel(itemKey)) });
|
|
359
487
|
}
|
|
360
488
|
if (ops.length > 0) {
|
|
361
489
|
if (out.length > 0) out.push({ type: "sep" });
|
|
362
|
-
out.push({ type: "head", label: "
|
|
490
|
+
out.push({ type: "head", label: menuWord("block") });
|
|
363
491
|
out.push(...ops);
|
|
364
492
|
}
|
|
365
493
|
return out;
|
|
366
494
|
};
|
|
367
495
|
const positionRows: DockMenuRow[] = menu?.kind === "position"
|
|
368
496
|
// v5 图标排(方案 §3.4):统一模型(浮窗 → 各停靠位)+ 一行无歧义方位图标
|
|
369
|
-
? [{ type: "icons" as const, label: "
|
|
497
|
+
? [{ type: "icons" as const, label: menuWord("zones"), items: positionMenuModel(itemKey, allZones, defaultZone, state, { onNewWindow: props.onNewWindow }) }]
|
|
370
498
|
: [];
|
|
371
499
|
const menuRows: DockMenuRow[] = menu?.kind === "position" ? positionRows : (menu?.kind === "main" ? buildMainMenu() : []);
|
|
372
500
|
const renderMenuRow = (it: DockMenuRow, i: number) => {
|
|
@@ -389,7 +517,7 @@ export function DockBody(props: {
|
|
|
389
517
|
style: { display: "flex", gap: 6, marginLeft: "auto", flexShrink: 0 } },
|
|
390
518
|
...it.items.map((x, j) => {
|
|
391
519
|
const isRadio = x.active === true || x.active === false;
|
|
392
|
-
const tip = x.isDefault ? `${x.label}
|
|
520
|
+
const tip = x.isDefault ? `${x.label}${menuWord("defaultSuffix")}` : x.label;
|
|
393
521
|
return h("button", {
|
|
394
522
|
key: `icon-${j}`, type: "button",
|
|
395
523
|
role: isRadio ? "menuitemradio" : "menuitem",
|
|
@@ -406,7 +534,7 @@ export function DockBody(props: {
|
|
|
406
534
|
onMouseEnter: (e: any) => { if (!x.active) { e.currentTarget.style.background = "var(--bg-hover, #262626)"; e.currentTarget.style.color = "var(--text, #ddd)"; } },
|
|
407
535
|
onMouseLeave: (e: any) => { if (!x.active) { e.currentTarget.style.background = "none"; e.currentTarget.style.color = "var(--text-muted, #888)"; } },
|
|
408
536
|
},
|
|
409
|
-
dockIconEl(x.icon, 16),
|
|
537
|
+
typeof x.icon === "string" ? dockIconEl(x.icon as any, 16) : x.icon,
|
|
410
538
|
x.isDefault ? h("span", { key: "dot", "data-ext-dock-icon-default": "1", style: { position: "absolute" as const, top: 3, right: 3, width: 4, height: 4, borderRadius: "50%", background: "var(--accent, #2563eb)", pointerEvents: "none" as const } }) : null,
|
|
411
539
|
);
|
|
412
540
|
})),
|
|
@@ -442,7 +570,10 @@ export function DockBody(props: {
|
|
|
442
570
|
// 首帧离屏(布局期测量后落位,绘制前同步无闪烁)
|
|
443
571
|
...(menuPos ? { left: menuPos.left, top: menuPos.top } : { left: -99999, top: -99999 }),
|
|
444
572
|
},
|
|
445
|
-
|
|
573
|
+
// hover 关闭仅限真 hover 设备(2026-11-15 小屏反馈「菜单经常自己关掉」):手机上手指
|
|
574
|
+
// 滑动浏览菜单项时浏览器合成 mouse 事件(touchmove 目标变化 → 合成 mouseleave),
|
|
575
|
+
// 无条件关闭等于「一滑就关」;触屏(hover:none)忽略 mouseleave,改由外点/滚动关闭。
|
|
576
|
+
onMouseLeave: () => { try { if (!window.matchMedia("(hover: hover) and (pointer: fine)").matches) return; } catch { /* 判定缺席按桌面处理 */ } setMenu(null); },
|
|
446
577
|
}, menuRows.map(renderMenuRow)) : null;
|
|
447
578
|
const toggleCollapsed = () => setCollapsed(!collapsed);
|
|
448
579
|
// 排序 v2:头行 = HTML5 拖拽把手。dragged key 双通道传递:dataTransfer(跨 bundle,
|
|
@@ -477,9 +608,11 @@ export function DockBody(props: {
|
|
|
477
608
|
requestBlockDrop(dragged, blockKey, (e.clientY - r.top) < r.height / 2);
|
|
478
609
|
};
|
|
479
610
|
const headerProps: any = { ref: setHeaderEl, style: { display: "flex", alignItems: "center", gap: 4, padding: "4px 8px", borderBottom: "1px solid var(--border, #333)", flexShrink: 0, minWidth: 0 }, onClick: (e: any) => { if (e.target && typeof e.target.closest === "function" && e.target.closest("button")) return; toggleCollapsed(); } };
|
|
480
|
-
if (chrome === "section") {
|
|
611
|
+
if (chrome === "section" && kind !== "reserved") {
|
|
612
|
+
// Drag handle only for dockable blocks (reserved = fixed-order resident blocks, e.g.
|
|
613
|
+
// projects: no "drag to reorder" tooltip, not a drag handle; click-to-collapse unaffected).
|
|
481
614
|
headerProps.draggable = true;
|
|
482
|
-
headerProps.title = "拖动排序";
|
|
615
|
+
headerProps.title = props.headerHint ?? "拖动排序";
|
|
483
616
|
headerProps.onDragStart = onDragStart;
|
|
484
617
|
headerProps.onDragOver = (e: any) => { if (isDockDrag(e) && dragKey !== blockKey) { e.preventDefault(); e.dataTransfer.dropEffect = "move"; dropMark(e, true); } };
|
|
485
618
|
headerProps.onDragLeave = (e: any) => { try { if (e.relatedTarget && e.currentTarget.contains(e.relatedTarget)) return; } catch { /* ignore */ } dropMark(e, false); };
|
|
@@ -488,10 +621,19 @@ export function DockBody(props: {
|
|
|
488
621
|
dragKey = null;
|
|
489
622
|
document.querySelectorAll(".pi-dock-drop-before, .pi-dock-drop-after").forEach((el) => el.classList.remove("pi-dock-drop-before", "pi-dock-drop-after"));
|
|
490
623
|
};
|
|
624
|
+
} else if (chrome === "section" && props.headerHint) {
|
|
625
|
+
// Reserved header: mute by default; a semantic headerHint gives it a hover description.
|
|
626
|
+
headerProps.title = props.headerHint;
|
|
491
627
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
628
|
+
// Collapsed-header icon (five-form declaration contract; see dockIconFromDecl)
|
|
629
|
+
const iconNode = dockIconFromDecl(props.icon, 13);
|
|
630
|
+
const titleNode = h("span", { style: { minWidth: 0, flex: "0 1 auto", display: "inline-flex", alignItems: "center", gap: 5 } },
|
|
631
|
+
iconNode,
|
|
632
|
+
props.renderTitle
|
|
633
|
+
? props.renderTitle()
|
|
634
|
+
// 13px/500 body-color matches custom renderTitle headers (e.g. folder title
|
|
635
|
+
// switcher) so every section header reads as the same tier; icon prop is 13 too.
|
|
636
|
+
: h("span", { style: { fontSize: 13, fontWeight: 500, color: "var(--text, #222)", flex: "0 1 auto", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" as const, minWidth: 0 } }, title ?? ""));
|
|
495
637
|
// 折叠保挂(v3):内容注册过命令(曾挂载)→ 折叠保留 children(隐藏),按钮状态与命令即时可用
|
|
496
638
|
const keepAlive = collapsed && storeData.hasCommands;
|
|
497
639
|
return h("div", {
|
|
@@ -508,7 +650,7 @@ export function DockBody(props: {
|
|
|
508
650
|
},
|
|
509
651
|
chrome === "section" && h("div", headerProps,
|
|
510
652
|
h("button", {
|
|
511
|
-
type: "button", title: collapsed ? "
|
|
653
|
+
type: "button", title: collapsed ? menuWord("expand") : menuWord("collapse"), "aria-label": (title ?? menuWord("block")) + (collapsed ? " " + menuWord("expand") : " " + menuWord("collapse")),
|
|
512
654
|
"aria-expanded": collapsed ? "false" : "true", style: { ...btnBase, display: "flex", alignItems: "center" },
|
|
513
655
|
onClick: toggleCollapsed,
|
|
514
656
|
},
|
|
@@ -522,7 +664,7 @@ export function DockBody(props: {
|
|
|
522
664
|
...shownActions.map(actionBtn),
|
|
523
665
|
showDetach ? h("span", { style: { position: "relative", display: "inline-flex", flexShrink: 0 } },
|
|
524
666
|
h("button", {
|
|
525
|
-
ref: setPosBtnEl, type: "button", title: "
|
|
667
|
+
ref: setPosBtnEl, type: "button", title: menuWord("position"), "aria-label": menuWord("position"), "aria-haspopup": "menu",
|
|
526
668
|
"aria-expanded": menu?.kind === "position" ? "true" : "false",
|
|
527
669
|
style: { ...btnBase, fontSize: 12 },
|
|
528
670
|
onClick: () => { if (menu?.kind === "position") setMenu(null); else { setMenuPos(null); setMenu({ kind: "position", anchor: posBtnEl ?? menuBtnEl! }); } },
|
|
@@ -530,7 +672,7 @@ export function DockBody(props: {
|
|
|
530
672
|
menu?.kind === "position" ? menuNode : null,
|
|
531
673
|
) : null,
|
|
532
674
|
h("span", { style: { position: "relative", display: "inline-flex", flexShrink: 0 } },
|
|
533
|
-
h("button", { ref: setMenuBtnEl, type: "button", title: "
|
|
675
|
+
h("button", { ref: setMenuBtnEl, type: "button", title: menuWord("actions"), "aria-label": menuWord("actions"), "aria-haspopup": "menu", "aria-expanded": menu?.kind === "main" ? "true" : "false",
|
|
534
676
|
style: { ...btnBase, fontSize: 12, fontWeight: 700 },
|
|
535
677
|
onClick: () => { if (menu?.kind === "main") { setMenu(null); } else { setMenuPos(null); setMenu({ kind: "main", anchor: menuBtnEl! }); } },
|
|
536
678
|
onKeyDown: (e: any) => { if (e.key === "Escape" && menu?.kind === "main") setMenu(null); } }, "⋮"),
|
|
@@ -606,6 +748,9 @@ export function useGateSidebar(itemKey: string): string | null {
|
|
|
606
748
|
export function sidebarBlockItem(opts: {
|
|
607
749
|
key: string; // 完整 itemKey "extId:itemId"(= 注册复合 id 约定)
|
|
608
750
|
title: string;
|
|
751
|
+
/** Collapsed-header icon: five-form declaration (element / {svg} / {url} /
|
|
752
|
+
* dock-icons name / emoji-text; see dockIconFromDecl). */
|
|
753
|
+
icon?: unknown;
|
|
609
754
|
priority?: number; // 默认序(项目0→任务1→文件2→停靠3+)
|
|
610
755
|
zones?: DockZone[]; // 位置全集(sidebar 族自动并入;右栏显式声明)
|
|
611
756
|
defaultZone?: DockZone;
|
|
@@ -621,6 +766,7 @@ export function sidebarBlockItem(opts: {
|
|
|
621
766
|
if (!dockedZone) return null;
|
|
622
767
|
return h(DockBody, {
|
|
623
768
|
itemKey: opts.key, title: opts.title, chrome: "section" as const,
|
|
769
|
+
icon: opts.icon,
|
|
624
770
|
zones, defaultZone: opts.defaultZone, kind: "dockable" as const,
|
|
625
771
|
}, opts.renderContent());
|
|
626
772
|
};
|
|
@@ -641,6 +787,9 @@ export function sidebarBlockItem(opts: {
|
|
|
641
787
|
export function createDockFaces(opts: {
|
|
642
788
|
key: string; // 完整 itemKey "extId:itemId"(= 注册 id 约定,防 dock tab 链断裂)
|
|
643
789
|
title: string;
|
|
790
|
+
/** Collapsed-header icon: five-form declaration (element / {svg} / {url} /
|
|
791
|
+
* dock-icons name / emoji-text; see dockIconFromDecl). */
|
|
792
|
+
icon?: unknown;
|
|
644
793
|
zones: DockZone[];
|
|
645
794
|
defaultZone?: DockZone;
|
|
646
795
|
renderContent: () => any; // 两面共用内容(ReactNode 工厂)
|
|
@@ -689,7 +838,7 @@ export function createDockFaces(opts: {
|
|
|
689
838
|
},
|
|
690
839
|
opts.chrome !== false && h("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "10px 14px 6px", flexShrink: 0 } },
|
|
691
840
|
h("h3", { style: { margin: 0, fontSize: 14, fontWeight: 600, flex: 1 } }, title),
|
|
692
|
-
h("button", { type: "button", "aria-label": "
|
|
841
|
+
h("button", { type: "button", "aria-label": menuWord("close"), title: menuWord("close"), onClick: () => closePanel(key),
|
|
693
842
|
style: { background: "none", border: "none", color: "var(--text-muted, #888)", cursor: "pointer", fontSize: 14, padding: "2px 8px", fontFamily: "inherit" } }, "✕"),
|
|
694
843
|
),
|
|
695
844
|
h("div", { style: { flex: 1, minHeight: 0, overflow: "auto", display: "flex", flexDirection: "column" } }, renderContent()),
|
|
@@ -703,11 +852,11 @@ export function createDockFaces(opts: {
|
|
|
703
852
|
if (zone === "sidebar-explorer") {
|
|
704
853
|
const dockedZone = useGateSidebar(key);
|
|
705
854
|
if (!dockedZone) return null;
|
|
706
|
-
return h(DockBody, { itemKey: key, zone, title, chrome, zones, defaultZone }, renderContent());
|
|
855
|
+
return h(DockBody, { itemKey: key, zone, title, icon: opts.icon, chrome, zones, defaultZone }, renderContent());
|
|
707
856
|
}
|
|
708
857
|
const docked = useGate(key, { dock: zone });
|
|
709
858
|
if (!docked) return null;
|
|
710
|
-
return h(DockBody, { itemKey: key, zone, title, chrome, zones, defaultZone }, renderContent());
|
|
859
|
+
return h(DockBody, { itemKey: key, zone, title, icon: opts.icon, chrome, zones, defaultZone }, renderContent());
|
|
711
860
|
};
|
|
712
861
|
|
|
713
862
|
const hasSidebarZone = zones.some((z) => z === "sidebar-explorer" || z.startsWith("sidebar:"));
|
package/ext-protocol.mjs
CHANGED
package/git-ops-client/api.mjs
CHANGED
|
@@ -23,7 +23,8 @@ export function createGitOpsApi({ apiUrl = (p) => p, fetchImpl = (...a) => fetch
|
|
|
23
23
|
};
|
|
24
24
|
return {
|
|
25
25
|
refs: (cwd) => call("/refs", { cwd }),
|
|
26
|
-
log: (cwd, cursor) => call("/log", { cwd, cursor: cursor || 0 }),
|
|
26
|
+
log: (cwd, cursor, opts) => call("/log", { cwd, cursor: cursor || 0, ...(opts && typeof opts === "object" ? opts : {}) }),
|
|
27
|
+
tags: (cwd) => call("/tags", { cwd }),
|
|
27
28
|
checkout: (cwd, ref, mode) => call("/checkout", { cwd, ref, mode }),
|
|
28
29
|
branchCreate: (cwd, name, from, checkout = true) => call("/branch-create", { cwd, name, from, checkout }),
|
|
29
30
|
branchDelete: (cwd, name) => call("/branch-delete", { cwd, name }),
|
|
@@ -34,6 +35,7 @@ export function createGitOpsApi({ apiUrl = (p) => p, fetchImpl = (...a) => fetch
|
|
|
34
35
|
stage: (cwd, paths) => call("/stage", { cwd, paths }),
|
|
35
36
|
unstage: (cwd, paths) => call("/unstage", { cwd, paths }),
|
|
36
37
|
discard: (cwd, paths) => call("/discard", { cwd, paths }),
|
|
38
|
+
ignoreAdd: (cwd, paths) => call("/ignore-add", { cwd, paths }),
|
|
37
39
|
commit: (cwd, message, amend) => call("/commit", { cwd, message, amend }),
|
|
38
40
|
planExecute: (cwd, groups) => call("/plan/execute", { cwd, groups }),
|
|
39
41
|
planRollback: (cwd, baseHEAD) => call("/plan/rollback", { cwd, baseHEAD }),
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
* worktree 分区数据与操作由消费方注入(宿主 /api/worktrees* 例外不进引擎,§2)。
|
|
13
13
|
*/
|
|
14
14
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
15
|
-
import { clampToViewport, fixedOrigin } from "../popup-anchor";
|
|
15
|
+
import { clampToViewport, fixedOrigin, zoomFactorOf } from "../popup-anchor";
|
|
16
16
|
import { buildAtText, openNewSessionWithExtSvc } from "../new-session-cwd";
|
|
17
17
|
import { createGitOpsApi } from "./api.mjs";
|
|
18
|
+
import { assignLanes, laneColor, parseGraphRows } from "./graph-lanes.mjs";
|
|
18
19
|
import { makeT } from "./i18n.mjs";
|
|
19
20
|
|
|
20
21
|
/* ── chip 徽标(折叠头右端;非 git / 引擎缺席由消费方门控不渲染)── */
|
|
@@ -102,6 +103,8 @@ export function BranchPanel(p: BranchPanelProps) {
|
|
|
102
103
|
const [remotesOpen, setRemotesOpen] = useState(false);
|
|
103
104
|
const [log, setLog] = useState<{ lines: string[]; nextCursor: number | null }>({ lines: [], nextCursor: null });
|
|
104
105
|
const [logCursor, setLogCursor] = useState(0);
|
|
106
|
+
// graph view branch filter ("" = HEAD; dsh-better-sidebar borrow plan §2.1)
|
|
107
|
+
const [logRef, setLogRef] = useState("");
|
|
105
108
|
const [stash, setStash] = useState<any[]>([]);
|
|
106
109
|
const [stashFiles, setStashFiles] = useState<Record<number, { tracked: string[]; untracked: string[] }>>({});
|
|
107
110
|
const [expandedStash, setExpandedStash] = useState<number | null>(null);
|
|
@@ -143,7 +146,7 @@ export function BranchPanel(p: BranchPanelProps) {
|
|
|
143
146
|
setLoadError(null);
|
|
144
147
|
const [r, g, s] = await Promise.all([
|
|
145
148
|
api.refs(p.cwd),
|
|
146
|
-
api.log(p.cwd, 0),
|
|
149
|
+
api.log(p.cwd, 0, { ref: logRef }),
|
|
147
150
|
api.stashList(p.cwd),
|
|
148
151
|
]);
|
|
149
152
|
if (r.status === 404 || r.status === 0) { setLoadError(r.data?.error || "HTTP " + r.status); return; }
|
|
@@ -152,7 +155,7 @@ export function BranchPanel(p: BranchPanelProps) {
|
|
|
152
155
|
setLog({ lines: g.data?.lines ?? [], nextCursor: g.data?.nextCursor ?? null });
|
|
153
156
|
setLogCursor(0);
|
|
154
157
|
setStash(s.data?.items ?? []);
|
|
155
|
-
}, [api, p.cwd]);
|
|
158
|
+
}, [api, p.cwd, logRef]);
|
|
156
159
|
|
|
157
160
|
// 打开拉一次(cwd 变了重拉)
|
|
158
161
|
useEffect(() => {
|
|
@@ -162,12 +165,20 @@ export function BranchPanel(p: BranchPanelProps) {
|
|
|
162
165
|
|
|
163
166
|
const loadMoreLog = useCallback(async () => {
|
|
164
167
|
if (!p.cwd || log.nextCursor == null) return;
|
|
165
|
-
const g = await api.log(p.cwd, log.nextCursor);
|
|
168
|
+
const g = await api.log(p.cwd, log.nextCursor, { ref: logRef });
|
|
166
169
|
if (g.status === 200) {
|
|
167
170
|
setLog((prev) => ({ lines: [...prev.lines, ...(g.data?.lines ?? [])], nextCursor: g.data?.nextCursor ?? null }));
|
|
168
171
|
setLogCursor(log.nextCursor);
|
|
169
172
|
}
|
|
170
|
-
}, [api, p.cwd, log.nextCursor]);
|
|
173
|
+
}, [api, p.cwd, log.nextCursor, logRef]);
|
|
174
|
+
|
|
175
|
+
// graph branch filter switch: clearing lines + bumping refreshData identity reloads page 0 with the ref
|
|
176
|
+
const switchGraphRef = useCallback((ref: string) => {
|
|
177
|
+
setLogRef(ref);
|
|
178
|
+
setLog({ lines: [], nextCursor: null });
|
|
179
|
+
}, []);
|
|
180
|
+
|
|
181
|
+
const graphRows = useMemo(() => assignLanes(parseGraphRows(log.lines)), [log.lines]);
|
|
171
182
|
|
|
172
183
|
// 定位:右对齐 chip、展开其下;下方装不下则压缩高度(面板内滚,不上翻——mockup 形态)
|
|
173
184
|
useLayoutEffect(() => {
|
|
@@ -182,7 +193,8 @@ export function BranchPanel(p: BranchPanelProps) {
|
|
|
182
193
|
left = c.left; top = c.top;
|
|
183
194
|
}
|
|
184
195
|
const o = fixedOrigin(el);
|
|
185
|
-
|
|
196
|
+
const z = zoomFactorOf(el);
|
|
197
|
+
setPos((cur) => (cur && cur.left === (left - o.x) / z && cur.top === (top - o.y) / z ? cur : { left: (left - o.x) / z, top: (top - o.y) / z }));
|
|
186
198
|
});
|
|
187
199
|
|
|
188
200
|
// 点外关闭(chip 本体除外——由 chip onClick 单一开关)+ Escape
|
|
@@ -766,24 +778,35 @@ export function BranchPanel(p: BranchPanelProps) {
|
|
|
766
778
|
</div>
|
|
767
779
|
)}
|
|
768
780
|
|
|
769
|
-
{/*
|
|
781
|
+
{/* graph (borrow plan §2.1: lane-rendered --graph + ref badges + branch filter) */}
|
|
770
782
|
{sectionHead("graph", t("graph"))}
|
|
771
783
|
{!collapsed.has("graph") && (
|
|
772
784
|
<div style={{ paddingBottom: 2 }}>
|
|
785
|
+
<div style={{ display: "flex", alignItems: "center", padding: "0 12px 4px" }}>
|
|
786
|
+
<select value={logRef} title={t("graphBranch")} onChange={(e) => switchGraphRef(e.target.value)}
|
|
787
|
+
style={{ height: 20, maxWidth: "100%", boxSizing: "border-box" as const, fontSize: 10,
|
|
788
|
+
fontFamily: "var(--font-mono)", color: "var(--text-muted)", background: "var(--bg-hover)",
|
|
789
|
+
border: "1px solid var(--border)", borderRadius: 5, padding: "0 4px", outline: "none", cursor: "pointer" }}>
|
|
790
|
+
<option value="">{t("graphBranchHead")}</option>
|
|
791
|
+
{(refsData?.branches ?? []).map((b: string) => <option key={b} value={b}>{b}</option>)}
|
|
792
|
+
</select>
|
|
793
|
+
</div>
|
|
773
794
|
{log.lines.length === 0 && <div style={{ padding: "2px 12px 4px", fontSize: 11, color: "var(--text-dim)" }}>{t("graphEmpty")}</div>}
|
|
774
|
-
{
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
795
|
+
{graphRows.map((row, i) => row.raw !== undefined ? (
|
|
796
|
+
<div key={i} style={{ ...graphLineStyle, opacity: 0.7 }}>{row.raw}</div>
|
|
797
|
+
) : (
|
|
798
|
+
<div key={i} className="gitops-row" onClick={row.sha ? () => void openCommit(row.sha.slice(0, 7)) : undefined}
|
|
799
|
+
title={row.sha ? t("commitView") : undefined}
|
|
800
|
+
style={{ ...graphLineStyle, cursor: row.sha ? "pointer" : "default", alignItems: "center" }}>
|
|
801
|
+
<GraphLaneArt graph={row.graph} lanes={row.lanes} prevLanes={row.prevLanes}
|
|
802
|
+
nodeCol={row.nodeCol} nodeLane={row.nodeLane} isHead={row.refs.some((r) => r.startsWith("HEAD"))} />
|
|
803
|
+
{row.sha ? <span style={{ color: "var(--accent)", flexShrink: 0 }}>{row.sha.slice(0, 7)}</span> : null}
|
|
804
|
+
{row.refs.map((r, ri) => <GraphRefChip key={ri} text={r} headLabel={t("graphRefHead")} />)}
|
|
805
|
+
{row.subject ? (
|
|
806
|
+
<span style={{ overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" as const, color: "var(--text-muted)" }}>{row.subject}</span>
|
|
807
|
+
) : null}
|
|
808
|
+
</div>
|
|
809
|
+
))}
|
|
787
810
|
{log.nextCursor != null && (
|
|
788
811
|
<button type="button" disabled={busy} onClick={() => void loadMoreLog()} style={{ display: "block", width: "100%", textAlign: "center" as const, padding: "5px 0", fontSize: 10, color: "var(--text-dim)", background: "none", border: "none", cursor: "pointer" }}>
|
|
789
812
|
{t("graphMore")}
|
|
@@ -985,3 +1008,75 @@ const graphLineStyle = {
|
|
|
985
1008
|
display: "flex", gap: 7, padding: "2.5px 12px", fontFamily: "var(--font-mono)", fontSize: 10.5,
|
|
986
1009
|
color: "var(--text-muted)", overflow: "hidden",
|
|
987
1010
|
} as const;
|
|
1011
|
+
|
|
1012
|
+
/* ── graph lane rendering (§2.1): one SVG per row, geometry decoded from git's own ASCII art ── */
|
|
1013
|
+
|
|
1014
|
+
const LANE_W = 8;
|
|
1015
|
+
const ROW_H = 15;
|
|
1016
|
+
|
|
1017
|
+
function GraphRefChip({ text, headLabel }: { text: string; headLabel: string }) {
|
|
1018
|
+
const isHead = text === "HEAD" || text.startsWith("HEAD ->");
|
|
1019
|
+
const isTag = text.startsWith("tag:");
|
|
1020
|
+
const label = text === "HEAD" ? headLabel
|
|
1021
|
+
: isHead && text.startsWith("HEAD -> ") ? text.slice("HEAD -> ".length)
|
|
1022
|
+
: isTag ? text.slice(4).trim()
|
|
1023
|
+
: text;
|
|
1024
|
+
return (
|
|
1025
|
+
<span style={{
|
|
1026
|
+
fontFamily: "var(--font-mono)", fontSize: 9.5, lineHeight: 1, padding: "2.5px 5px", borderRadius: 4,
|
|
1027
|
+
flexShrink: 0, whiteSpace: "nowrap" as const,
|
|
1028
|
+
color: isHead ? "var(--accent)" : isTag ? "var(--text)" : "var(--text-muted)",
|
|
1029
|
+
background: isHead ? "color-mix(in srgb, var(--accent) 14%, transparent)" : "var(--bg-hover)",
|
|
1030
|
+
border: "1px solid " + (isHead ? "color-mix(in srgb, var(--accent) 45%, transparent)" : "var(--border)"),
|
|
1031
|
+
}}>{label}</span>
|
|
1032
|
+
);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
function GraphLaneArt(p: {
|
|
1036
|
+
graph: string;
|
|
1037
|
+
lanes: [number, number][];
|
|
1038
|
+
prevLanes: [number, number][];
|
|
1039
|
+
nodeCol: number;
|
|
1040
|
+
nodeLane: number;
|
|
1041
|
+
isHead: boolean;
|
|
1042
|
+
}) {
|
|
1043
|
+
const laneMap = new Map(p.lanes);
|
|
1044
|
+
const prevMap = new Map(p.prevLanes);
|
|
1045
|
+
const w = Math.max(p.graph.length, 1) * LANE_W;
|
|
1046
|
+
const x = (i: number) => (i + 0.5) * LANE_W;
|
|
1047
|
+
const segs: { x1: number; y1: number; x2: number; y2: number; c: string }[] = [];
|
|
1048
|
+
let node: { x: number; c: string } | null = null;
|
|
1049
|
+
for (let i = 0; i < p.graph.length; i++) {
|
|
1050
|
+
const ch = p.graph[i];
|
|
1051
|
+
if (ch === "|" || ch === "*") {
|
|
1052
|
+
const c = laneColor(laneMap.get(i) ?? 0);
|
|
1053
|
+
segs.push({ x1: x(i), y1: 0, x2: x(i), y2: ROW_H, c });
|
|
1054
|
+
if (ch === "*") node = { x: x(i), c };
|
|
1055
|
+
} else if (ch === "\\") {
|
|
1056
|
+
// branch-out edge: colored by the new branch lane below (i+1)
|
|
1057
|
+
const c = laneColor(laneMap.get(i + 1) ?? 0);
|
|
1058
|
+
segs.push({ x1: x(i - 1), y1: 0, x2: x(i + 1), y2: ROW_H, c });
|
|
1059
|
+
} else if (ch === "/") {
|
|
1060
|
+
// merge-in edge: colored by the collapsing lane above (i+1)
|
|
1061
|
+
const c = laneColor(prevMap.get(i + 1) ?? laneMap.get(i + 1) ?? 0);
|
|
1062
|
+
segs.push({ x1: x(i + 1), y1: 0, x2: x(i - 1), y2: ROW_H, c });
|
|
1063
|
+
} else if (ch === "-" || ch === "_") {
|
|
1064
|
+
const c = laneColor(laneMap.get(i) ?? 0);
|
|
1065
|
+
segs.push({ x1: x(i) - LANE_W / 2, y1: ROW_H / 2, x2: x(i) + LANE_W / 2, y2: ROW_H / 2, c });
|
|
1066
|
+
} else if (ch === ".") {
|
|
1067
|
+
const c = laneColor(laneMap.get(i) ?? 0);
|
|
1068
|
+
segs.push({ x1: x(i), y1: ROW_H / 2, x2: x(i) + 0.01, y2: ROW_H / 2, c });
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return (
|
|
1072
|
+
<svg width={w} height={ROW_H} viewBox={`0 0 ${w} ${ROW_H}`} style={{ flexShrink: 0 }}>
|
|
1073
|
+
{segs.map((s, si) => <line key={si} x1={s.x1} y1={s.y1} x2={s.x2} y2={s.y2} stroke={s.c} strokeWidth={1.3} />)}
|
|
1074
|
+
{node ? (
|
|
1075
|
+
<>
|
|
1076
|
+
<circle cx={node.x} cy={ROW_H / 2} r={p.isHead ? 3.4 : 2.6} fill="var(--bg)" stroke={node.c} strokeWidth={p.isHead ? 1.6 : 1} />
|
|
1077
|
+
{p.isHead ? <circle cx={node.x} cy={ROW_H / 2} r={1.4} fill={node.c} /> : null}
|
|
1078
|
+
</>
|
|
1079
|
+
) : null}
|
|
1080
|
+
</svg>
|
|
1081
|
+
);
|
|
1082
|
+
}
|