@aiti-ai/aiti-git-review 0.2.11 → 0.2.13

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.
@@ -1,8 +1,8 @@
1
1
  let _ctx$2 = null;
2
- function __setCtx(ctx) {
2
+ function __setCtx$1(ctx) {
3
3
  _ctx$2 = ctx;
4
4
  }
5
- function extSvc(key) {
5
+ function extSvc$1(key) {
6
6
  return _ctx$2?.getExtService?.(key);
7
7
  }
8
8
  function regSvc(key, impl) {
@@ -51,6 +51,67 @@ function t$1(key, params) {
51
51
  const fn = _ctx$2?.t;
52
52
  return typeof fn === "function" ? fn(key, params) : key;
53
53
  }
54
+ function displayCwd(cwd, home) {
55
+ return home && cwd && cwd.startsWith(home) ? "~" + cwd.slice(home.length) : cwd;
56
+ }
57
+ const UNREAD_KEY = "pi-web:unread-session-ids";
58
+ function loadUnread() {
59
+ try {
60
+ const r = localStorage.getItem(UNREAD_KEY);
61
+ const a = r ? JSON.parse(r) : [];
62
+ return new Set(Array.isArray(a) ? a : []);
63
+ } catch {
64
+ return /* @__PURE__ */ new Set();
65
+ }
66
+ }
67
+ function wkKey(s) {
68
+ return s.projectKey || s.cwd || s.id;
69
+ }
70
+ function recentProjects(sessions) {
71
+ const m = /* @__PURE__ */ new Map();
72
+ for (const s of sessions) {
73
+ const root = s.projectRoot || s.cwd;
74
+ if (!root) continue;
75
+ const k = wkKey(s);
76
+ const p = m.get(k);
77
+ if (!p || s.modified > p.modified) m.set(k, { root, modified: s.modified });
78
+ }
79
+ return [...m.values()].sort((a, b) => (b.modified || "").localeCompare(a.modified || "")).map((x) => ({ key: x.root, root: x.root }));
80
+ }
81
+ function projectActivity(sessions, running, unread) {
82
+ const m = /* @__PURE__ */ new Map();
83
+ for (const s of sessions) {
84
+ const k = wkKey(s);
85
+ if (!k) continue;
86
+ let e = m.get(k);
87
+ if (!e) {
88
+ e = { running: 0, unread: 0 };
89
+ m.set(k, e);
90
+ }
91
+ if (running.has(s.id)) e.running++;
92
+ if (unread.has(s.id)) e.unread++;
93
+ }
94
+ return m;
95
+ }
96
+ let _ctx$1 = null;
97
+ function __setCtx(ctx) {
98
+ _ctx$1 = ctx;
99
+ }
100
+ function extSvc(key) {
101
+ return _ctx$1?.getExtService?.(key);
102
+ }
103
+ function apiUrl(p) {
104
+ const fn = _ctx$1?.apiUrl;
105
+ return typeof fn === "function" ? fn(p) : p;
106
+ }
107
+ function t(key, params) {
108
+ const fn = _ctx$1?.t;
109
+ return typeof fn === "function" ? fn(key, params) : key;
110
+ }
111
+ function createPortal(children, container) {
112
+ const fn = _ctx$1?.createPortal;
113
+ return typeof fn === "function" ? fn(children, container) : children;
114
+ }
54
115
  function isFixedContainingBlock(cs) {
55
116
  const zoomValue = parseFloat(cs.zoom || "");
56
117
  if (Number.isFinite(zoomValue) && zoomValue !== 1) return true;
@@ -98,52 +159,57 @@ const P = (d) => ({ tag: "path", attrs: { d } });
98
159
  const R = (x, y, width, height, rx = 2) => ({ tag: "rect", attrs: { x, y, width, height, rx } });
99
160
  const thin = (n) => ({ ...n, attrs: { ...n.attrs, "stroke-width": 1.5 } });
100
161
  const DOCK_ICON_NODES = {
101
- /** 浮窗:圆角框 + 标题栏 + 圆点(app-window;用户 2026-09-15 定稿 C)。 */
162
+ /** Float: rounded frame + title bar + dots (app-window; user finalized C on 2026-09-15). */
102
163
  float: [
103
164
  R(2, 4, 20, 16, 2),
104
165
  P("M10 4v4"),
105
166
  P("M2 8h20"),
106
167
  P("M6 4v4")
107
168
  ],
108
- /** 新窗口打开:方框 + 右上外斜箭头(square-arrow-out-up-right;
109
- * 用户 2026-09-15 拍板:B 图形用作「新窗口打开」,且仅支持的面板(文件/文件夹)显示)。 */
169
+ /** Open in new window: box + outward diagonal arrow at top right
170
+ * (square-arrow-out-up-right;
171
+ * user ruling 2026-09-15: glyph B serves "Open in new window", shown only for capable
172
+ * panels (files/folders)). */
110
173
  "new-window": [
111
174
  P("M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6"),
112
175
  P("m21 3-9 9"),
113
176
  P("M15 3h6v6")
114
177
  ],
115
- /** 左栏:方框 + 左缘粗边。 */
178
+ /** Left panel: box + thick left edge. */
116
179
  "panel-left": [R(3, 3, 18, 18), P("M9 3v18")],
117
- /** 右栏:方框 + 右缘粗边。 */
180
+ /** Right panel: box + thick right edge. */
118
181
  "panel-right": [R(3, 3, 18, 18), P("M15 3v18")],
119
- /** 底部(预留位):方框 + 下缘粗边。 */
182
+ /** Bottom (reserved slot): box + thick bottom edge. */
120
183
  "panel-bottom": [R(3, 3, 18, 18), P("M3 15h18")],
121
184
  "chevron-up": [P("m18 15-6-6-6 6")],
122
185
  "chevron-down": [P("m6 9 6 6 6-6")],
123
186
  "chevron-left": [P("m15 18-6-6 6-6")],
124
187
  "chevron-right": [P("m9 18 6-6-6-6")],
125
188
  "arrow-up": [P("m5 12 7-7 7 7"), P("M12 19V5")],
126
- /** 钉住:图钉(lucide pin;⋮ 区块操作「钉住」,与 aiti-folder MiPin 同形)。 */
189
+ /** Pin: pushpin (lucide pin; the ⋮ block operation "Pin", same shape as aiti-folder's MiPin). */
127
190
  pin: [
128
191
  { tag: "line", attrs: { x1: 12, y1: 17, x2: 12, y2: 22 } },
129
192
  P("M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z")
130
193
  ],
131
- /** 关闭:×(lucide x;⋮ 区块操作「关闭」)。 */
194
+ /** Close: × (lucide x; the ⋮ block operation "Close"). */
132
195
  x: [P("M18 6 6 18"), P("m6 6 12 12")],
133
- /** 取消钉住态:图钉 + 斜删除线(lucide pin-off;移动行钉住钮已钉态,与 MiPin 同语义族)。 */
196
+ /** Unpin state: pushpin + diagonal strike (lucide pin-off; the move-row pin button's
197
+ * pinned state, same semantic family as MiPin). */
134
198
  "pin-off": [
135
199
  { tag: "line", attrs: { x1: 12, y1: 17, x2: 12, y2: 22 } },
136
200
  P("M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16h14v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"),
137
201
  { tag: "line", attrs: { x1: 2, y1: 2, x2: 22, y2: 22 } }
138
202
  ],
139
- /** 移除本实例:垃圾桶(lucide trash;多实例区块 ⋮「移除本实例」,与 aiti-folder MiTrash 同形)。 */
203
+ /** Remove this instance: trash can (lucide trash; multi-instance blocks' ⋮ "Remove
204
+ * this instance", same shape as aiti-folder's MiTrash). */
140
205
  trash: [
141
206
  { tag: "polyline", attrs: { points: "3 6 5 6 21 6" } },
142
207
  P("M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"),
143
208
  { tag: "line", attrs: { x1: 10, y1: 11, x2: 10, y2: 17 } },
144
209
  { tag: "line", attrs: { x1: 14, y1: 11, x2: 14, y2: 17 } }
145
210
  ],
146
- /** 移动:对角双箭头(lucide move-diagonal-2;⋮「移动」行首图标——左上 + 右下,用户 2026-09-15 指定)。 */
211
+ /** Move: diagonal double arrow (lucide move-diagonal-2; the ⋮ "Move" row's leading
212
+ * icon — top-left + bottom-right, specified by the user 2026-09-15). */
147
213
  "move-diagonal-2": [
148
214
  P("M5 11V5h6"),
149
215
  P("M19 13v6h-6"),
@@ -831,6 +897,7 @@ const DOCK_MENU_WORDS = {
831
897
  block: { "zh-CN": "区块", en: "Block" },
832
898
  position: { "zh-CN": "切换停靠位置", en: "Change dock position" },
833
899
  actions: { "zh-CN": "区块操作", en: "Block actions" },
900
+ dragReorder: { "zh-CN": "拖动排序", en: "Drag to reorder" },
834
901
  move: { "zh-CN": "移动", en: "Move" },
835
902
  pin: { "zh-CN": "钉住", en: "Pin" },
836
903
  unpin: { "zh-CN": "取消钉住", en: "Unpin" },
@@ -1160,8 +1227,9 @@ function DockBody(props) {
1160
1227
  {
1161
1228
  key: "label",
1162
1229
  "data-ext-dock-icon-row-label": "1",
1163
- // 行首图标(可选):带图标 = 动作行(正文字色,与其余 icon+text 行同款);
1164
- // 无图标 = 纯说明名(dim,位置菜单「停靠方位」标题原样)。
1230
+ // Leading row icon (optional): with an icon = an action row (body text color,
1231
+ // same style as the other icon+text rows); without = a pure caption name (dim,
1232
+ // e.g. the position menu's "Dock zones" title as-is).
1165
1233
  style: {
1166
1234
  display: "inline-flex",
1167
1235
  alignItems: "center",
@@ -1290,16 +1358,19 @@ function DockBody(props) {
1290
1358
  boxShadow: "0 8px 24px rgba(0,0,0,0.4)",
1291
1359
  minWidth: menu?.kind === "position" ? 190 : 150,
1292
1360
  maxWidth: "calc(100vw - 16px)",
1293
- // 长菜单滚动契约(v3):视口内可滚 + 防滚动穿透(内部滚动不触发「容器滚动即关」)
1361
+ // Long-menu scroll contract (v3): scrollable inside the viewport + scroll
1362
+ // containment (inner scroll does not trigger "container scroll closes")
1294
1363
  maxHeight: "min(70vh, calc(100vh - 16px))",
1295
1364
  overflowY: "auto",
1296
1365
  overscrollBehavior: "contain",
1297
- // 首帧离屏(布局期测量后落位,绘制前同步无闪烁)
1366
+ // First frame off-screen (positioned after layout measurement, synced before paint, no flicker)
1298
1367
  ...menuPos ? { left: menuPos.left, top: menuPos.top } : { left: -99999, top: -99999 }
1299
1368
  },
1300
- // hover 关闭仅限真 hover 设备(2026-11-15 小屏反馈「菜单经常自己关掉」):手机上手指
1301
- // 滑动浏览菜单项时浏览器合成 mouse 事件(touchmove 目标变化 → 合成 mouseleave),
1302
- // 无条件关闭等于「一滑就关」;触屏(hover:none)忽略 mouseleave,改由外点/滚动关闭。
1369
+ // Hover-close only on true hover devices (2026-11-15 small-screen feedback "the menu
1370
+ // keeps closing itself"): while a finger swipes through menu items on phones the
1371
+ // browser synthesizes mouse events (touchmove target change → synthetic mouseleave);
1372
+ // unconditional close equals "one swipe closes it". Touch (hover:none) ignores
1373
+ // mouseleave and closes via outside click/scroll instead.
1303
1374
  onMouseLeave: () => {
1304
1375
  try {
1305
1376
  if (!window.matchMedia("(hover: hover) and (pointer: fine)").matches) return;
@@ -1355,7 +1426,7 @@ function DockBody(props) {
1355
1426
  } };
1356
1427
  if (chrome === "section" && kind !== "reserved") {
1357
1428
  headerProps.draggable = true;
1358
- headerProps.title = props.headerHint ?? "拖动排序";
1429
+ headerProps.title = props.headerHint ?? menuWord("dragReorder");
1359
1430
  headerProps.onDragStart = onDragStart;
1360
1431
  headerProps.onDragOver = (e) => {
1361
1432
  if (isDockDrag(e) && dragKey !== blockKey) {
@@ -1393,10 +1464,11 @@ function DockBody(props) {
1393
1464
  "data-ext-float-dock-body": itemKey,
1394
1465
  "data-ext-item": itemKey,
1395
1466
  "data-ext-dock-block": blockKey,
1396
- // 根上带声明属性:TabBar ⇱ 菜单在 face 挂载时可直接读(注册表兜底优先)
1467
+ // Declaration attributes on the root: the TabBar ⇱ menu reads them directly when the
1468
+ // face is mounted (registry fallback takes precedence)
1397
1469
  "data-ext-float-dock": allZones.join(" "),
1398
1470
  ...defaultZone ? { "data-ext-float-dock-default": defaultZone } : {},
1399
- // 注册按钮数(e2e/调试断言用):当前头行可见 / 溢出
1471
+ // Registered button counts (for e2e/debug assertions): currently visible in header / overflow
1400
1472
  "data-ext-dock-actions": String(shownActions.length),
1401
1473
  "data-ext-dock-actions-overflow": String(overflowActions.length),
1402
1474
  style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0, overflow: "hidden", position: "relative" }
@@ -1522,12 +1594,12 @@ const G = {
1522
1594
  probePath: "",
1523
1595
  presetRepo: ""
1524
1596
  };
1525
- let _ctx$1 = null;
1597
+ let _ctx = null;
1526
1598
  function setGRCtx(ctx) {
1527
- _ctx$1 = ctx;
1599
+ _ctx = ctx;
1528
1600
  }
1529
1601
  function getCtx() {
1530
- return _ctx$1;
1602
+ return _ctx;
1531
1603
  }
1532
1604
  const lastSeg = (p) => {
1533
1605
  const s = String(p).split("/");
@@ -1820,7 +1892,7 @@ function buildBody(panel2, spec, finish) {
1820
1892
  head.appendChild(icon);
1821
1893
  const titleEl = document.createElement("div");
1822
1894
  titleEl.style.cssText = "flex:1;min-width:0;font-size:15px;font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;";
1823
- titleEl.textContent = o.title || (spec.kind === "confirm" ? o.danger ? "危险操作确认" : "确认操作" : spec.kind === "prompt" ? "输入" : spec.kind === "choice" ? "请选择" : "提示");
1895
+ titleEl.textContent = o.title || (spec.kind === "confirm" ? o.danger ? "Confirm dangerous operation" : "Confirm" : spec.kind === "prompt" ? "Input" : spec.kind === "choice" ? "Choose" : "Notice");
1824
1896
  head.appendChild(titleEl);
1825
1897
  panel2.appendChild(head);
1826
1898
  if (o.message) {
@@ -1876,11 +1948,11 @@ function buildBody(panel2, spec, finish) {
1876
1948
  }
1877
1949
  if (items.length === 0) finish(o.cancelId ?? null);
1878
1950
  } else if (spec.kind === "alert") {
1879
- const ok = mk(o.confirmText || "确定", true, false, () => finish(void 0));
1951
+ const ok = mk(o.confirmText || "OK", true, false, () => finish(void 0));
1880
1952
  ok.__primary = true;
1881
1953
  } else {
1882
- mk(o.cancelText || "取消", false, false, () => finish(spec.kind === "prompt" ? null : spec.kind === "choice" ? o.cancelId ?? null : false));
1883
- const ok = mk(o.confirmText || (spec.kind === "confirm" && o.danger ? "确认执行" : "确定"), true, !!(spec.kind === "confirm" && o.danger), () => finish(spec.kind === "prompt" ? input && o.required && !input.value.trim() ? void 0 : input.value : true));
1954
+ mk(o.cancelText || "Cancel", false, false, () => finish(spec.kind === "prompt" ? null : spec.kind === "choice" ? o.cancelId ?? null : false));
1955
+ const ok = mk(o.confirmText || (spec.kind === "confirm" && o.danger ? "Confirm" : "OK"), true, !!(spec.kind === "confirm" && o.danger), () => finish(spec.kind === "prompt" ? input && o.required && !input.value.trim() ? void 0 : input.value : true));
1884
1956
  ok.__primary = true;
1885
1957
  }
1886
1958
  panel2.appendChild(foot);
@@ -1970,57 +2042,6 @@ function dedupeFetch(url, options) {
1970
2042
  inflight.set(url, { promise, freshUntil: 0 });
1971
2043
  return promise.then((r) => r.clone());
1972
2044
  }
1973
- function displayCwd(cwd, home) {
1974
- return home && cwd && cwd.startsWith(home) ? "~" + cwd.slice(home.length) : cwd;
1975
- }
1976
- const UNREAD_KEY = "pi-web:unread-session-ids";
1977
- function loadUnread() {
1978
- try {
1979
- const r = localStorage.getItem(UNREAD_KEY);
1980
- const a = r ? JSON.parse(r) : [];
1981
- return new Set(Array.isArray(a) ? a : []);
1982
- } catch {
1983
- return /* @__PURE__ */ new Set();
1984
- }
1985
- }
1986
- function wkKey(s) {
1987
- return s.projectKey || s.cwd || s.id;
1988
- }
1989
- function recentProjects(sessions) {
1990
- const m = /* @__PURE__ */ new Map();
1991
- for (const s of sessions) {
1992
- const root = s.projectRoot || s.cwd;
1993
- if (!root) continue;
1994
- const k = wkKey(s);
1995
- const p = m.get(k);
1996
- if (!p || s.modified > p.modified) m.set(k, { root, modified: s.modified });
1997
- }
1998
- return [...m.values()].sort((a, b) => (b.modified || "").localeCompare(a.modified || "")).map((x) => ({ key: x.root, root: x.root }));
1999
- }
2000
- function projectActivity(sessions, running, unread) {
2001
- const m = /* @__PURE__ */ new Map();
2002
- for (const s of sessions) {
2003
- const k = wkKey(s);
2004
- if (!k) continue;
2005
- let e = m.get(k);
2006
- if (!e) {
2007
- e = { running: 0, unread: 0 };
2008
- m.set(k, e);
2009
- }
2010
- if (running.has(s.id)) e.running++;
2011
- if (unread.has(s.id)) e.unread++;
2012
- }
2013
- return m;
2014
- }
2015
- let _ctx = null;
2016
- function apiUrl(p) {
2017
- const fn = _ctx?.apiUrl;
2018
- return typeof fn === "function" ? fn(p) : p;
2019
- }
2020
- function t(key, params) {
2021
- const fn = _ctx?.t;
2022
- return typeof fn === "function" ? fn(key, params) : key;
2023
- }
2024
2045
  const COMPONENT_DICT = {
2025
2046
  en: {
2026
2047
  "files.cancel": "Cancel",
@@ -2029,7 +2050,28 @@ const COMPONENT_DICT = {
2029
2050
  "files.parentDir": "Parent directory",
2030
2051
  "files.selectFolder": "Select this folder",
2031
2052
  "i18n.close": "Close",
2053
+ "i18n.cancel": "Cancel",
2054
+ "i18n.checking": "Checking…",
2032
2055
  "sidebar.customPath": "Custom path…",
2056
+ // Shared directory picker (extensions/_shared/directory-picker.tsx)
2057
+ "directoryPicker.selectDirectory": "Select directory",
2058
+ "directoryPicker.goToParent": "Go to parent directory",
2059
+ "directoryPicker.directoryPath": "Directory path",
2060
+ "directoryPicker.editPath": "Edit path",
2061
+ "directoryPicker.pathEditHint": "Click or type to edit the path (Alt+D / Ctrl+L)",
2062
+ "directoryPicker.copyPath": "Copy path",
2063
+ "directoryPicker.copied": "Path copied",
2064
+ "directoryPicker.pathPlaceholder": "/path/to/project or ~/project",
2065
+ "directoryPicker.loadingDirectories": "Loading directories…",
2066
+ "directoryPicker.noDrives": "No drives found",
2067
+ "directoryPicker.noSubdirectories": "No subdirectories",
2068
+ "directoryPicker.selectCurrentDirectory": "Select current directory",
2069
+ "directoryPicker.selectThisFolder": "Select this folder",
2070
+ "directoryPicker.newFolder": "New folder",
2071
+ "directoryPicker.newFolderIn": "Create a new folder in {path}",
2072
+ "directoryPicker.folderName": "Folder name",
2073
+ "directoryPicker.create": "Create",
2074
+ "directoryPicker.creating": "Creating…",
2033
2075
  "files.openFolder": "Open Folder",
2034
2076
  "sidebar.filterProjects": "Filter projects…",
2035
2077
  "sidebar.noMatchingProjects": "No matching projects",
@@ -2068,9 +2110,14 @@ const COMPONENT_DICT = {
2068
2110
  "git.aiRefine": "AI refine",
2069
2111
  "git.aiRefineBusy": "AI grouping… (up to 3 min)",
2070
2112
  "git.aiMessage": "Generate",
2071
- "git.aiMessageBusy": "Generating… (up to 3 min)",
2113
+ "git.aiMessageBusy": "Generating… (usually under a minute)",
2114
+ "git.aiMessageBusyLong": "Still generating… (large changes take longer)",
2115
+ "git.aiMessagePending": "Still waiting… (the session keeps running in the background)",
2116
+ "git.aiMessageStillPending": "The session is still generating in the background — open the dialog again and press Generate to pick the result up.",
2117
+ "git.aiMessageEmpty": "The AI answered, but the text could not be cleaned into a commit message — please retry.",
2072
2118
  "git.aiMessageOverwrite": "Message already has content. Overwrite with the generated commit message?",
2073
2119
  "git.aiMessageTitle": "Generate a commit message with AI (reads AGENTS.md and the diff of selected files)",
2120
+ "git.wiPickTitle": "Insert a work-item header at the top of the message (aiti-codehub picker)",
2074
2121
  "git.stagedBucket": "Staged",
2075
2122
  "git.unstagedBucket": "Changes",
2076
2123
  "git.stageTitle": "Stage",
@@ -2081,7 +2128,14 @@ const COMPONENT_DICT = {
2081
2128
  "git.discardUntrackedConfirm": "Move the untracked file to the trash? (restorable from the trash)",
2082
2129
  "git.diffTitle": "View diff (git-review)",
2083
2130
  "git.changesToggle": "Toggle changed-files section",
2084
- "git.planRetry": "Retry remaining groups"
2131
+ "git.planRetry": "Retry remaining groups",
2132
+ "git.nestedRepoTip": "Nested git repository (click to toggle its changes)",
2133
+ "git.nestedFallbackHint": "git-ops engine unavailable — read-only view",
2134
+ "git.moreActions": "More actions",
2135
+ "git.branchPanelEntry": "Branch panel",
2136
+ "git.refreshRepo": "Refresh this repo (git status only)",
2137
+ "git.openAsFolderTab": "Open as folder tab",
2138
+ "git.collapseChanges": "Collapse changes"
2085
2139
  },
2086
2140
  "zh-CN": {
2087
2141
  "files.cancel": "取消",
@@ -2090,7 +2144,28 @@ const COMPONENT_DICT = {
2090
2144
  "files.parentDir": "上级目录",
2091
2145
  "files.selectFolder": "选择此文件夹",
2092
2146
  "i18n.close": "关闭",
2147
+ "i18n.cancel": "取消",
2148
+ "i18n.checking": "检查中…",
2093
2149
  "sidebar.customPath": "自定义路径…",
2150
+ // Shared directory picker (extensions/_shared/directory-picker.tsx)
2151
+ "directoryPicker.selectDirectory": "选择目录",
2152
+ "directoryPicker.goToParent": "转到上级目录",
2153
+ "directoryPicker.directoryPath": "目录路径",
2154
+ "directoryPicker.editPath": "编辑路径",
2155
+ "directoryPicker.pathEditHint": "点击或直接键入以编辑路径(Alt+D / Ctrl+L)",
2156
+ "directoryPicker.copyPath": "复制路径",
2157
+ "directoryPicker.copied": "已复制路径",
2158
+ "directoryPicker.pathPlaceholder": "/路径/到/项目 或 ~/项目",
2159
+ "directoryPicker.loadingDirectories": "正在加载目录…",
2160
+ "directoryPicker.noDrives": "未找到盘符",
2161
+ "directoryPicker.noSubdirectories": "没有子目录",
2162
+ "directoryPicker.selectCurrentDirectory": "选择当前目录",
2163
+ "directoryPicker.selectThisFolder": "选择此文件夹",
2164
+ "directoryPicker.newFolder": "新建文件夹",
2165
+ "directoryPicker.newFolderIn": "在 {path} 新建文件夹",
2166
+ "directoryPicker.folderName": "文件夹名",
2167
+ "directoryPicker.create": "创建",
2168
+ "directoryPicker.creating": "创建中…",
2094
2169
  "files.openFolder": "打开文件夹",
2095
2170
  "sidebar.filterProjects": "筛选项目…",
2096
2171
  "sidebar.noMatchingProjects": "没有匹配的项目",
@@ -2129,9 +2204,14 @@ const COMPONENT_DICT = {
2129
2204
  "git.aiRefine": "AI 精修",
2130
2205
  "git.aiRefineBusy": "AI 分组中…(最长 3 分钟)",
2131
2206
  "git.aiMessage": "生成",
2132
- "git.aiMessageBusy": "生成中…(最长 3 分钟)",
2207
+ "git.aiMessageBusy": "生成中…(通常 1 分钟内)",
2208
+ "git.aiMessageBusyLong": "仍在生成…(改动较大时需要更久)",
2209
+ "git.aiMessagePending": "仍在等待…(会话在后台继续生成)",
2210
+ "git.aiMessageStillPending": "会话仍在后台生成——稍后重新打开本弹窗、再点一次生成即可取回结果。",
2211
+ "git.aiMessageEmpty": "AI 已作答,但无法整理成提交信息——请重试。",
2133
2212
  "git.aiMessageOverwrite": "输入框已有内容,生成结果将覆盖,是否继续?",
2134
2213
  "git.aiMessageTitle": "AI 生成提交信息(读取 AGENTS.md 与所选文件的 diff)",
2214
+ "git.wiPickTitle": "在消息开头插入工作项头部(aiti-codehub 选择器)",
2135
2215
  "git.stagedBucket": "已暂存",
2136
2216
  "git.unstagedBucket": "工作区",
2137
2217
  "git.stageTitle": "暂存",
@@ -2142,7 +2222,14 @@ const COMPONENT_DICT = {
2142
2222
  "git.discardUntrackedConfirm": "将未跟踪文件移入回收站?(可在回收站还原)",
2143
2223
  "git.diffTitle": "查看 diff(git-review)",
2144
2224
  "git.changesToggle": "开/合变更文件区",
2145
- "git.planRetry": "重试剩余组"
2225
+ "git.planRetry": "重试剩余组",
2226
+ "git.nestedRepoTip": "嵌套 Git 仓库(点击展开/收起其变更)",
2227
+ "git.nestedFallbackHint": "git-ops 引擎未启用——只读视图",
2228
+ "git.moreActions": "更多操作",
2229
+ "git.branchPanelEntry": "分支面板",
2230
+ "git.refreshRepo": "刷新本仓(仅 git 状态)",
2231
+ "git.openAsFolderTab": "打开为独立文件夹标签页",
2232
+ "git.collapseChanges": "收起变更区"
2146
2233
  }
2147
2234
  };
2148
2235
  function currentLocale() {
@@ -2160,10 +2247,10 @@ function ct(key, params) {
2160
2247
  }
2161
2248
  return hit;
2162
2249
  }
2163
- function FolderIcon({ open, size }) {
2250
+ function FolderIcon$1({ open, size }) {
2164
2251
  return /* @__PURE__ */ jsx("svg", { width: size ?? 14, height: size ?? 14, viewBox: "0 0 24 24", fill: "none", stroke: "var(--text-dim)", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx("path", { d: open ? "m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" : "M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z" }) });
2165
2252
  }
2166
- function CheckIcon() {
2253
+ function CheckIcon$1() {
2167
2254
  return /* @__PURE__ */ jsx("svg", { width: 10, height: 10, viewBox: "0 0 10 10", fill: "none", stroke: "var(--accent)", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx("polyline", { points: "1.5 5 4 7.5 8.5 2.5" }) });
2168
2255
  }
2169
2256
  function PathLabel({ text, style }) {
@@ -2185,66 +2272,691 @@ function ActivityBadges({ act, t: t2 }) {
2185
2272
  ] }) : null
2186
2273
  ] });
2187
2274
  }
2188
- const rowStyle = { display: "flex", alignItems: "center", gap: 8, width: "100%", padding: "0 12px", height: 26, border: "none", background: "transparent", color: "var(--text)", cursor: "pointer", textAlign: "left" };
2189
- function DirectoryBrowser({ initialPath, onSelect, onCancel }) {
2190
- const [path, setPath] = useState(initialPath || "");
2191
- const [data, setData] = useState(null);
2192
- const [loading, setLoading] = useState(false);
2193
- const [error, setError] = useState(null);
2194
- const load = useCallback((target) => {
2195
- if (loading) return;
2196
- setLoading(true);
2197
- setError(null);
2198
- const p = target ? { path: target } : {};
2199
- fetch(apiUrl("/api/cwd/browse"), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(p) }).then(async (r) => {
2200
- const d = await r.json();
2201
- if (!r.ok || d.error) throw new Error(d.error || "HTTP " + r.status);
2202
- setData(d);
2203
- setPath(d.path);
2204
- }).catch((e) => setError(e && e.message ? e.message : String(e))).finally(() => setLoading(false));
2205
- }, [loading]);
2206
- useEffect(() => {
2207
- load(initialPath || "");
2275
+ const OVERLAY_BACK_MOBILE_QUERY = "(max-width: 640px)";
2276
+ function dismissOnBack(getService, close) {
2277
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return () => {
2278
+ };
2279
+ const mq = window.matchMedia(OVERLAY_BACK_MOBILE_QUERY);
2280
+ let handle = null;
2281
+ let released = false;
2282
+ const sync = () => {
2283
+ if (released) return;
2284
+ let service;
2285
+ try {
2286
+ service = getService();
2287
+ } catch {
2288
+ service = null;
2289
+ }
2290
+ const should = mq.matches && !!service && typeof service.acquire === "function";
2291
+ if (should && !handle) {
2292
+ try {
2293
+ handle = service.acquire(close);
2294
+ } catch {
2295
+ handle = null;
2296
+ }
2297
+ } else if (!should && handle) {
2298
+ const prev = handle;
2299
+ handle = null;
2300
+ try {
2301
+ prev.release();
2302
+ } catch {
2303
+ }
2304
+ }
2305
+ };
2306
+ sync();
2307
+ const onChange = () => sync();
2308
+ if (typeof mq.addEventListener === "function") mq.addEventListener("change", onChange);
2309
+ else mq.addListener(onChange);
2310
+ return () => {
2311
+ if (released) return;
2312
+ released = true;
2313
+ if (typeof mq.removeEventListener === "function") mq.removeEventListener("change", onChange);
2314
+ else mq.removeListener(onChange);
2315
+ const prev = handle;
2316
+ handle = null;
2317
+ if (prev) {
2318
+ try {
2319
+ prev.release();
2320
+ } catch {
2321
+ }
2322
+ }
2323
+ };
2324
+ }
2325
+ const DIRECTORY_PICKER_ATTR = "data-aiti-directory-picker";
2326
+ function isDirectoryPickerTarget(target) {
2327
+ const el = target;
2328
+ try {
2329
+ return typeof el?.closest === "function" && !!el.closest(`[${DIRECTORY_PICKER_ATTR}]`);
2330
+ } catch {
2331
+ return false;
2332
+ }
2333
+ }
2334
+ const DRIVE_RE = /^[a-zA-Z]:/;
2335
+ function isWindowsPath(value) {
2336
+ if (value.startsWith("\\\\")) return true;
2337
+ if (DRIVE_RE.test(value)) return true;
2338
+ return !value.startsWith("/") && value.includes("\\") && !value.includes("/");
2339
+ }
2340
+ function splitPosix(value) {
2341
+ const absolute = value.startsWith("/");
2342
+ const parts = value.split("/").filter(Boolean);
2343
+ let acc = "";
2344
+ const segments = [];
2345
+ for (const part of parts) {
2346
+ acc = acc ? `${acc}/${part}` : absolute ? `/${part}` : part;
2347
+ segments.push({ label: part, path: acc });
2348
+ }
2349
+ return { sep: "/", root: absolute ? { label: "/", path: "/" } : null, segments };
2350
+ }
2351
+ function splitWindows(value) {
2352
+ const unc = value.startsWith("\\\\");
2353
+ const normalized = unc ? "\\\\" + value.slice(2).replace(/[\\/]+/g, "\\") : value.replace(/[\\/]+/g, "\\");
2354
+ let root = null;
2355
+ let acc = "";
2356
+ let rest = normalized;
2357
+ if (unc) {
2358
+ const parts2 = normalized.slice(2).split("\\").filter(Boolean);
2359
+ const server = parts2.shift() ?? "";
2360
+ const share = parts2.shift() ?? "";
2361
+ const rootPath = share ? `\\\\${server}\\${share}` : server ? `\\\\${server}` : "\\\\";
2362
+ root = { label: rootPath, path: rootPath };
2363
+ acc = rootPath;
2364
+ rest = parts2.length > 0 ? "\\" + parts2.join("\\") : "";
2365
+ } else {
2366
+ const drive = DRIVE_RE.exec(normalized)?.[0] ?? null;
2367
+ if (drive) {
2368
+ const rootPath = `${drive}\\`;
2369
+ root = { label: drive, path: rootPath };
2370
+ acc = drive;
2371
+ rest = normalized.slice(drive.length);
2372
+ }
2373
+ }
2374
+ const parts = rest.split("\\").filter(Boolean);
2375
+ const segments = [];
2376
+ for (const part of parts) {
2377
+ acc = acc ? `${acc}\\${part}` : part;
2378
+ segments.push({ label: part, path: acc });
2379
+ }
2380
+ return { sep: "\\", root, segments };
2381
+ }
2382
+ function splitPathSegments(input) {
2383
+ const value = typeof input === "string" ? input : "";
2384
+ if (!value) return { sep: "/", root: null, segments: [] };
2385
+ return isWindowsPath(value) ? splitWindows(value) : splitPosix(value);
2386
+ }
2387
+ const BOX = {
2388
+ display: "flex",
2389
+ alignItems: "center",
2390
+ gap: 1,
2391
+ minWidth: 0,
2392
+ height: 36,
2393
+ padding: "0 4px 0 6px",
2394
+ border: "1px solid var(--border)",
2395
+ borderRadius: 6,
2396
+ background: "var(--bg-panel)",
2397
+ color: "var(--text)",
2398
+ fontFamily: "var(--font-mono)",
2399
+ fontSize: 12,
2400
+ boxSizing: "border-box"
2401
+ };
2402
+ const SEGMENT = {
2403
+ minWidth: 22,
2404
+ maxWidth: 240,
2405
+ height: 24,
2406
+ padding: "0 4px",
2407
+ border: 0,
2408
+ borderRadius: 4,
2409
+ background: "none",
2410
+ color: "var(--text-muted)",
2411
+ font: "inherit",
2412
+ cursor: "pointer",
2413
+ overflow: "hidden",
2414
+ textOverflow: "ellipsis",
2415
+ whiteSpace: "nowrap"
2416
+ };
2417
+ const ICON_BUTTON = {
2418
+ flexShrink: 0,
2419
+ width: 24,
2420
+ height: 24,
2421
+ padding: 0,
2422
+ display: "flex",
2423
+ alignItems: "center",
2424
+ justifyContent: "center",
2425
+ border: 0,
2426
+ borderRadius: 4,
2427
+ background: "none",
2428
+ color: "var(--text-dim)",
2429
+ cursor: "pointer"
2430
+ };
2431
+ function CopyIcon() {
2432
+ return /* @__PURE__ */ jsxs("svg", { width: "12", height: "12", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.3", "aria-hidden": "true", children: [
2433
+ /* @__PURE__ */ jsx("rect", { x: "5.5", y: "5.5", width: "8", height: "8", rx: "1.2" }),
2434
+ /* @__PURE__ */ jsx("path", { d: "M10.5 5.5v-1a1 1 0 0 0-1-1h-7a1 1 0 0 0-1 1v7a1 1 0 0 0 1 1h1" })
2435
+ ] });
2436
+ }
2437
+ function CheckIcon() {
2438
+ return /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 16 16", fill: "none", stroke: "var(--accent)", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("polyline", { points: "2.5 8.5 6 12 13.5 4" }) });
2439
+ }
2440
+ async function writeClipboard(text) {
2441
+ try {
2442
+ if (navigator.clipboard?.writeText) {
2443
+ await navigator.clipboard.writeText(text);
2444
+ return true;
2445
+ }
2446
+ } catch {
2447
+ }
2448
+ const area = document.createElement("textarea");
2449
+ area.value = text;
2450
+ area.setAttribute("readonly", "");
2451
+ area.style.position = "fixed";
2452
+ area.style.top = "-1000px";
2453
+ area.style.opacity = "0";
2454
+ document.body.appendChild(area);
2455
+ try {
2456
+ area.select();
2457
+ return document.execCommand("copy");
2458
+ } catch {
2459
+ return false;
2460
+ } finally {
2461
+ area.remove();
2462
+ }
2463
+ }
2464
+ function PathBreadcrumb(props) {
2465
+ const { value, disabled = false, onNavigate } = props;
2466
+ const [editing, setEditingState] = useState(false);
2467
+ const [draft, setDraft] = useState("");
2468
+ const [copied, setCopied] = useState(false);
2469
+ const inputRef = useRef(null);
2470
+ const hotRef = useRef(null);
2471
+ const editingRef = useRef(false);
2472
+ const draftRef = useRef("");
2473
+ const copyTimerRef = useRef(null);
2474
+ const mountedRef = useRef(true);
2475
+ const propsRef = useRef(props);
2476
+ propsRef.current = props;
2477
+ const setEditing = useCallback((on) => {
2478
+ editingRef.current = on;
2479
+ setEditingState(on);
2480
+ propsRef.current.onEditingChange?.(on);
2208
2481
  }, []);
2482
+ const enterEdit = useCallback((seed) => {
2483
+ if (propsRef.current.disabled) return;
2484
+ const next = seed !== void 0 ? seed : propsRef.current.value;
2485
+ draftRef.current = next;
2486
+ setDraft(next);
2487
+ setEditing(true);
2488
+ }, [setEditing]);
2489
+ const commitEdit = useCallback(() => {
2490
+ if (!editingRef.current) return;
2491
+ const next = draftRef.current.trim();
2492
+ setEditing(false);
2493
+ if (next && next !== propsRef.current.value) propsRef.current.onNavigate(next);
2494
+ }, [setEditing]);
2495
+ const cancelEdit = useCallback(() => {
2496
+ if (!editingRef.current) return;
2497
+ setEditing(false);
2498
+ }, [setEditing]);
2499
+ useEffect(() => {
2500
+ if (!editing) return;
2501
+ const field = inputRef.current;
2502
+ if (!field) return;
2503
+ field.focus();
2504
+ field.select();
2505
+ }, [editing]);
2506
+ useEffect(() => {
2507
+ if (!editing && props.autoFocus) hotRef.current?.focus({ preventScroll: true });
2508
+ }, [editing, props.autoFocus]);
2209
2509
  useEffect(() => {
2210
- const k = (e) => {
2211
- if (e.key === "Escape") onCancel();
2510
+ mountedRef.current = true;
2511
+ return () => {
2512
+ mountedRef.current = false;
2513
+ if (copyTimerRef.current !== null) window.clearTimeout(copyTimerRef.current);
2212
2514
  };
2213
- document.addEventListener("keydown", k, true);
2214
- return () => document.removeEventListener("keydown", k, true);
2515
+ }, []);
2516
+ const copyPath = useCallback(() => {
2517
+ if (!propsRef.current.value) return;
2518
+ void writeClipboard(propsRef.current.value).then((ok) => {
2519
+ if (!mountedRef.current) return;
2520
+ if (!ok) {
2521
+ enterEdit();
2522
+ return;
2523
+ }
2524
+ setCopied(true);
2525
+ if (copyTimerRef.current !== null) window.clearTimeout(copyTimerRef.current);
2526
+ copyTimerRef.current = window.setTimeout(() => {
2527
+ if (mountedRef.current) setCopied(false);
2528
+ }, 1200);
2529
+ });
2530
+ }, [enterEdit]);
2531
+ const handleBarKeyDown = (event) => {
2532
+ if (editingRef.current || propsRef.current.disabled) return;
2533
+ if (event.altKey && (event.key === "d" || event.key === "D")) {
2534
+ event.preventDefault();
2535
+ enterEdit();
2536
+ return;
2537
+ }
2538
+ if ((event.ctrlKey || event.metaKey) && (event.key === "l" || event.key === "L")) {
2539
+ event.preventDefault();
2540
+ enterEdit();
2541
+ return;
2542
+ }
2543
+ if (event.key === "Enter" || event.key === "F2") {
2544
+ event.preventDefault();
2545
+ enterEdit();
2546
+ return;
2547
+ }
2548
+ if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
2549
+ event.preventDefault();
2550
+ enterEdit(event.key);
2551
+ }
2552
+ };
2553
+ const split = splitPathSegments(value);
2554
+ const copyTitle = copied ? props.copiedLabel : props.copyLabel;
2555
+ return /* @__PURE__ */ jsxs(
2556
+ "div",
2557
+ {
2558
+ className: "path-breadcrumb",
2559
+ role: "group",
2560
+ "aria-label": props.label,
2561
+ onKeyDown: handleBarKeyDown,
2562
+ style: { ...BOX, ...props.style },
2563
+ "data-editing": editing ? "1" : void 0,
2564
+ children: [
2565
+ editing ? /* @__PURE__ */ jsx(
2566
+ "input",
2567
+ {
2568
+ ref: inputRef,
2569
+ className: "path-breadcrumb-input",
2570
+ type: "text",
2571
+ value: draft,
2572
+ placeholder: props.placeholder,
2573
+ autoComplete: "off",
2574
+ spellCheck: false,
2575
+ "aria-label": props.label,
2576
+ onChange: (event) => {
2577
+ draftRef.current = event.target.value;
2578
+ setDraft(event.target.value);
2579
+ },
2580
+ onKeyDown: (event) => {
2581
+ if (event.nativeEvent.isComposing || event.keyCode === 229) return;
2582
+ if (event.key === "Enter") {
2583
+ event.preventDefault();
2584
+ event.stopPropagation();
2585
+ commitEdit();
2586
+ return;
2587
+ }
2588
+ if (event.key === "Escape") {
2589
+ event.preventDefault();
2590
+ event.stopPropagation();
2591
+ cancelEdit();
2592
+ }
2593
+ },
2594
+ onBlur: commitEdit,
2595
+ style: { minWidth: 0, flex: 1, height: 28, padding: "0 8px", border: 0, outline: "none", background: "transparent", color: "var(--text)", fontFamily: "var(--font-mono)", fontSize: 12 }
2596
+ }
2597
+ ) : value ? /* @__PURE__ */ jsxs(Fragment, { children: [
2598
+ split.root && /* @__PURE__ */ jsx(
2599
+ "button",
2600
+ {
2601
+ type: "button",
2602
+ className: "path-breadcrumb-segment is-root",
2603
+ title: split.root.path,
2604
+ disabled,
2605
+ onClick: () => {
2606
+ if (split.root && split.root.path !== value) onNavigate(split.root.path);
2607
+ },
2608
+ style: { ...SEGMENT, flexShrink: 0, color: "var(--text-muted)" },
2609
+ children: split.root.label
2610
+ }
2611
+ ),
2612
+ split.segments.map((segment, index) => {
2613
+ const last = index === split.segments.length - 1;
2614
+ const showSep = split.root ? !(index === 0 && split.root.path.endsWith(split.sep)) : false;
2615
+ return /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", minWidth: 0, flexShrink: last ? 1 : 100 }, children: [
2616
+ showSep ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: { flexShrink: 0, color: "var(--text-dim)" }, children: split.sep }) : null,
2617
+ /* @__PURE__ */ jsx(
2618
+ "button",
2619
+ {
2620
+ type: "button",
2621
+ className: `path-breadcrumb-segment${last ? " is-current" : ""}`,
2622
+ title: segment.path,
2623
+ disabled,
2624
+ onClick: () => {
2625
+ if (segment.path !== value) onNavigate(segment.path);
2626
+ },
2627
+ style: { ...SEGMENT, color: last ? "var(--text)" : "var(--text-muted)", fontWeight: last ? 600 : 400, maxWidth: last ? void 0 : 180 },
2628
+ children: segment.label
2629
+ }
2630
+ )
2631
+ ] }, segment.path);
2632
+ }),
2633
+ /* @__PURE__ */ jsx(
2634
+ "button",
2635
+ {
2636
+ type: "button",
2637
+ ref: hotRef,
2638
+ className: "path-breadcrumb-edit-hot",
2639
+ "aria-label": props.editLabel,
2640
+ title: props.editHint ?? props.editLabel,
2641
+ autoFocus: props.autoFocus,
2642
+ onClick: () => enterEdit(),
2643
+ style: { flex: 1, minWidth: 18, height: "100%", padding: 0, border: 0, background: "none", cursor: "text" }
2644
+ }
2645
+ )
2646
+ ] }) : /* @__PURE__ */ jsx(
2647
+ "button",
2648
+ {
2649
+ type: "button",
2650
+ ref: hotRef,
2651
+ className: "path-breadcrumb-edit-hot",
2652
+ "aria-label": props.editLabel,
2653
+ title: props.editHint ?? props.editLabel,
2654
+ autoFocus: props.autoFocus,
2655
+ onClick: () => enterEdit(),
2656
+ style: { flex: 1, minWidth: 18, height: "100%", padding: "0 8px", border: 0, background: "none", color: "var(--text-dim)", font: "inherit", textAlign: "left", cursor: "text" },
2657
+ children: props.placeholder
2658
+ }
2659
+ ),
2660
+ /* @__PURE__ */ jsx(
2661
+ "button",
2662
+ {
2663
+ type: "button",
2664
+ className: "path-breadcrumb-copy",
2665
+ "aria-label": copyTitle,
2666
+ title: copyTitle,
2667
+ disabled: disabled || !value || editing,
2668
+ onClick: copyPath,
2669
+ style: { ...ICON_BUTTON, cursor: disabled || !value || editing ? "default" : "pointer", opacity: disabled || !value ? 0.5 : 1 },
2670
+ children: copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {})
2671
+ }
2672
+ )
2673
+ ]
2674
+ }
2675
+ );
2676
+ }
2677
+ const DEFAULT_CREATE_FOLDER_URL = "/api/extensions/aiti-folder/create-folder";
2678
+ async function loadDirectories(host, directory) {
2679
+ const response = await fetch(host.apiUrl("/api/cwd/browse"), {
2680
+ method: "POST",
2681
+ headers: { "content-type": "application/json" },
2682
+ body: JSON.stringify({ path: directory ?? void 0 })
2683
+ });
2684
+ const data = await response.json();
2685
+ if (!response.ok || data.error) throw new Error(data.error ?? `HTTP ${response.status}`);
2686
+ return data;
2687
+ }
2688
+ async function createFolder(host, directory, name) {
2689
+ const response = await fetch(host.apiUrl(host.createFolderUrl ?? DEFAULT_CREATE_FOLDER_URL), {
2690
+ method: "POST",
2691
+ headers: { "content-type": "application/json" },
2692
+ body: JSON.stringify({ dir: directory, name })
2693
+ });
2694
+ const data = await response.json().catch(() => ({}));
2695
+ if (!response.ok || !data.ok || !data.path) throw new Error(data.error ?? `HTTP ${response.status}`);
2696
+ return data.path;
2697
+ }
2698
+ function FolderIcon() {
2699
+ return /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.3", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M1.5 3h4l1.5 2h7.5v7.5h-13z" }) });
2700
+ }
2701
+ function FolderPlusIcon() {
2702
+ return /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round", "aria-hidden": "true", children: [
2703
+ /* @__PURE__ */ jsx("path", { d: "M1.5 3h4l1.5 2h7.5v7.5h-13z" }),
2704
+ /* @__PURE__ */ jsx("path", { d: "M8 7v3.5M6.25 8.75h3.5" })
2705
+ ] });
2706
+ }
2707
+ function DriveIcon() {
2708
+ return /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
2709
+ /* @__PURE__ */ jsx("rect", { x: "2", y: "3", width: "12", height: "10", rx: "1.5" }),
2710
+ /* @__PURE__ */ jsx("path", { d: "M2 9h12" }),
2711
+ /* @__PURE__ */ jsx("circle", { cx: "11.5", cy: "11", r: "0.6", fill: "currentColor", stroke: "none" })
2712
+ ] });
2713
+ }
2714
+ function isWindowsDriveRoot(directory) {
2715
+ return /^[a-zA-Z]:[\\/]?$/.test(directory);
2716
+ }
2717
+ function DirectoryPicker$1(props) {
2718
+ const { host, onCancel, onSelect, initialPath, busy = false, error } = props;
2719
+ const t2 = host.t;
2720
+ const [portalTarget, setPortalTarget] = useState(null);
2721
+ const [currentPath, setCurrentPath] = useState("");
2722
+ const [parentDirectory, setParentDirectory] = useState(null);
2723
+ const [pathEditing, setPathEditing] = useState(false);
2724
+ const [directories, setDirectories] = useState([]);
2725
+ const [drives, setDrives] = useState(null);
2726
+ const [loadError, setLoadError] = useState(null);
2727
+ const [loading, setLoading] = useState(true);
2728
+ const [newFolderOpen, setNewFolderOpen] = useState(false);
2729
+ const [newFolderName, setNewFolderName] = useState("");
2730
+ const [newFolderBusy, setNewFolderBusy] = useState(false);
2731
+ const [newFolderError, setNewFolderError] = useState(null);
2732
+ const navigateTo = useCallback(async (directory) => {
2733
+ setLoading(true);
2734
+ setLoadError(null);
2735
+ setNewFolderOpen(false);
2736
+ setNewFolderError(null);
2737
+ try {
2738
+ const data = await loadDirectories(host, directory);
2739
+ const nextPath = data.path ?? directory ?? "/";
2740
+ setCurrentPath(nextPath);
2741
+ setParentDirectory(data.parentPath ?? null);
2742
+ setDirectories(data.directories ?? []);
2743
+ setDrives(data.drives ?? null);
2744
+ } catch (cause) {
2745
+ setLoadError(cause instanceof Error ? cause.message : String(cause));
2746
+ } finally {
2747
+ setLoading(false);
2748
+ }
2749
+ }, [host]);
2750
+ useEffect(() => {
2751
+ setPortalTarget(document.body);
2752
+ void navigateTo(initialPath || void 0);
2753
+ }, [initialPath, navigateTo]);
2754
+ const canSelect = Boolean(currentPath) && !busy && !loading && !pathEditing;
2755
+ const canNavigateUp = Boolean(parentDirectory) || isWindowsDriveRoot(currentPath);
2756
+ const canCreateFolder = Boolean(currentPath) && drives === null && !loading && !busy && !pathEditing;
2757
+ const canSubmitNewFolder = canCreateFolder && !newFolderBusy && Boolean(newFolderName.trim());
2758
+ const submitNewFolder = useCallback(async () => {
2759
+ const name = newFolderName.trim();
2760
+ if (!name || newFolderBusy || !canCreateFolder) return;
2761
+ setNewFolderBusy(true);
2762
+ setNewFolderError(null);
2763
+ try {
2764
+ const created = await createFolder(host, currentPath, name);
2765
+ setNewFolderName("");
2766
+ await navigateTo(created);
2767
+ } catch (cause) {
2768
+ setNewFolderError(cause instanceof Error ? cause.message : String(cause));
2769
+ } finally {
2770
+ setNewFolderBusy(false);
2771
+ }
2772
+ }, [canCreateFolder, currentPath, host, navigateTo, newFolderBusy, newFolderName]);
2773
+ const handleNewFolderSubmit = (event) => {
2774
+ event.preventDefault();
2775
+ void submitNewFolder();
2776
+ };
2777
+ const busyRef = useRef(busy);
2778
+ useEffect(() => {
2779
+ busyRef.current = busy;
2780
+ }, [busy]);
2781
+ const cancelRef = useRef(onCancel);
2782
+ useEffect(() => {
2783
+ cancelRef.current = onCancel;
2215
2784
  }, [onCancel]);
2216
- const dirs = data && data.directories || [];
2217
- const drives = data && data.drives;
2218
- return /* @__PURE__ */ jsx("div", { onClick: (e) => {
2219
- if (e.target === e.currentTarget) onCancel();
2220
- }, style: { position: "fixed", inset: 0, zIndex: 400, background: "rgba(0,0,0,0.35)", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsxs("div", { style: { width: "min(560px,92vw)", maxHeight: "80vh", display: "flex", flexDirection: "column", background: "var(--bg-panel)", border: "1px solid var(--border)", borderRadius: 8, boxShadow: "0 8px 32px rgba(0,0,0,0.3)", overflow: "hidden" }, children: [
2221
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "8px 12px", borderBottom: "1px solid var(--border)", background: "var(--bg)", flexShrink: 0 }, children: [
2222
- /* @__PURE__ */ jsx("span", { style: { fontSize: 13, fontWeight: 600, color: "var(--text)", flex: 1 }, children: ct("sidebar.customPath") }),
2223
- /* @__PURE__ */ jsx("button", { onClick: onCancel, title: ct("i18n.close"), style: { height: 28, padding: "0 10px", border: "1px solid var(--border)", borderRadius: 5, background: "var(--bg-panel)", color: "var(--text)", cursor: "pointer", fontSize: 12 }, children: "✕" })
2224
- ] }),
2225
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6, padding: "6px 12px", borderBottom: "1px solid var(--border)", flexShrink: 0, fontSize: 12, color: "var(--text-muted)", fontFamily: "var(--font-mono)", overflowX: "auto", whiteSpace: "nowrap" }, children: [
2226
- data && data.parentPath != null ? /* @__PURE__ */ jsx("button", { onClick: () => load(data.parentPath), title: ct("files.parentDir"), style: { height: 22, padding: "0 6px", border: "1px solid var(--border)", borderRadius: 4, background: "var(--bg-panel)", color: "var(--text-muted)", cursor: "pointer", fontSize: 12, flexShrink: 0 }, children: "↑" }) : null,
2227
- /* @__PURE__ */ jsx("span", { title: path, style: { overflow: "hidden", textOverflow: "ellipsis" }, children: path || "/" })
2228
- ] }),
2229
- /* @__PURE__ */ jsxs("div", { style: { flex: 1, overflowY: "auto", padding: "4px 0" }, children: [
2230
- loading ? /* @__PURE__ */ jsx("div", { style: { padding: "12px", fontSize: 12, color: "var(--text-dim)" }, children: ct("files.loading") }) : null,
2231
- error ? /* @__PURE__ */ jsx("div", { style: { padding: "12px", fontSize: 12, color: "var(--danger, #f87171)" }, children: error }) : null,
2232
- !loading && !error && drives && drives.length > 0 ? drives.map((d) => /* @__PURE__ */ jsxs("button", { onClick: () => load(d.path), style: rowStyle, children: [
2233
- /* @__PURE__ */ jsx(FolderIcon, { open: false }),
2234
- /* @__PURE__ */ jsx("span", { style: { fontSize: 12 }, children: d.name })
2235
- ] }, d.path)) : null,
2236
- !loading && !error && dirs.length === 0 && (!drives || drives.length === 0) ? /* @__PURE__ */ jsx("div", { style: { padding: "12px", fontSize: 12, color: "var(--text-dim)" }, children: ct("files.noSubdirs") }) : null,
2237
- !loading && !error ? dirs.map((d) => /* @__PURE__ */ jsxs("button", { onClick: () => load(d.path), onDoubleClick: () => onSelect(d.path), style: rowStyle, children: [
2238
- /* @__PURE__ */ jsx(FolderIcon, { open: false }),
2239
- /* @__PURE__ */ jsx("span", { style: { flex: 1, fontSize: 12, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: d.name }),
2240
- /* @__PURE__ */ jsx("span", { style: { fontSize: 10, color: "var(--text-dim)" }, children: "→" })
2241
- ] }, d.path)) : null
2242
- ] }),
2243
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 8, padding: "8px 12px", borderTop: "1px solid var(--border)", flexShrink: 0, background: "var(--bg)" }, children: [
2244
- /* @__PURE__ */ jsx("button", { onClick: () => path && onSelect(path), disabled: !path, style: { height: 28, padding: "0 12px", border: "none", borderRadius: 5, background: "var(--accent)", color: "#fff", cursor: path ? "pointer" : "not-allowed", fontSize: 12, fontWeight: 600, opacity: path ? 1 : 0.5 }, children: ct("files.selectFolder") }),
2245
- /* @__PURE__ */ jsx("button", { onClick: onCancel, style: { height: 28, padding: "0 10px", border: "1px solid var(--border)", borderRadius: 5, background: "var(--bg-panel)", color: "var(--text)", cursor: "pointer", fontSize: 12 }, children: ct("files.cancel") })
2246
- ] })
2247
- ] }) });
2785
+ useEffect(() => dismissOnBack(
2786
+ () => host.getExtService?.("pi-web.overlayBack"),
2787
+ () => {
2788
+ if (!busyRef.current) cancelRef.current();
2789
+ }
2790
+ ), [host]);
2791
+ if (!portalTarget) return null;
2792
+ const overlay2 = /* @__PURE__ */ jsx(
2793
+ "div",
2794
+ {
2795
+ className: "directory-picker-backdrop",
2796
+ ...{ [DIRECTORY_PICKER_ATTR]: "1" },
2797
+ role: "dialog",
2798
+ "aria-modal": "true",
2799
+ "aria-label": t2("directoryPicker.selectDirectory"),
2800
+ onClick: (event) => {
2801
+ if (event.target === event.currentTarget && !busy) onCancel();
2802
+ },
2803
+ onKeyDown: (event) => {
2804
+ if (event.key === "Escape" && !busy) onCancel();
2805
+ },
2806
+ style: { position: "fixed", inset: 0, zIndex: 2147483e3, display: "flex", alignItems: "center", justifyContent: "center", background: "rgba(0,0,0,0.35)" },
2807
+ children: /* @__PURE__ */ jsxs("div", { className: "directory-picker-panel", style: { width: 520, maxWidth: "calc(100vw - 16px)", height: "min(620px, calc(100dvh - 16px))", maxHeight: "calc(100dvh - 16px)", display: "flex", flexDirection: "column", overflow: "hidden", background: "var(--bg)", border: "1px solid var(--border)", borderRadius: 10, boxShadow: "0 8px 32px rgba(0,0,0,0.18)" }, children: [
2808
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", flexShrink: 0, padding: "12px 18px", borderBottom: "1px solid var(--border)" }, children: [
2809
+ /* @__PURE__ */ jsx("div", { style: { minWidth: 0, flex: 1 }, children: /* @__PURE__ */ jsx("div", { style: { color: "var(--text)", fontWeight: 700, fontSize: 15 }, children: t2("directoryPicker.selectDirectory") }) }),
2810
+ /* @__PURE__ */ jsx(
2811
+ "button",
2812
+ {
2813
+ type: "button",
2814
+ onClick: onCancel,
2815
+ disabled: busy,
2816
+ title: t2("i18n.close"),
2817
+ "aria-label": t2("i18n.close"),
2818
+ style: { padding: "2px 6px", border: 0, background: "none", color: "var(--text-muted)", fontSize: 20, lineHeight: 1, cursor: busy ? "default" : "pointer", opacity: busy ? 0.5 : 1 },
2819
+ children: "×"
2820
+ }
2821
+ )
2822
+ ] }),
2823
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8, flexShrink: 0, padding: "10px 14px", borderBottom: "1px solid var(--border)" }, children: [
2824
+ /* @__PURE__ */ jsx("button", { className: "directory-picker-back", type: "button", onClick: () => void navigateTo(parentDirectory ?? void 0), disabled: loading || !canNavigateUp, title: t2("directoryPicker.goToParent"), "aria-label": t2("directoryPicker.goToParent"), style: { width: 36, height: 36, padding: 0, display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0, border: "1px solid var(--border)", borderRadius: 6, background: "var(--bg-hover)", color: "var(--text-muted)", cursor: canNavigateUp ? "pointer" : "default", opacity: canNavigateUp ? 1 : 0.45 }, children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "m18 15-6-6-6 6" }) }) }),
2825
+ /* @__PURE__ */ jsx(
2826
+ PathBreadcrumb,
2827
+ {
2828
+ value: currentPath,
2829
+ label: t2("directoryPicker.directoryPath"),
2830
+ editLabel: t2("directoryPicker.editPath"),
2831
+ editHint: t2("directoryPicker.pathEditHint"),
2832
+ copyLabel: t2("directoryPicker.copyPath"),
2833
+ copiedLabel: t2("directoryPicker.copied"),
2834
+ placeholder: t2("directoryPicker.pathPlaceholder"),
2835
+ disabled: loading || busy,
2836
+ autoFocus: true,
2837
+ onNavigate: (path) => void navigateTo(path),
2838
+ onEditingChange: setPathEditing,
2839
+ style: { flex: 1 }
2840
+ }
2841
+ )
2842
+ ] }),
2843
+ /* @__PURE__ */ jsxs("div", { className: "directory-picker-list", style: { flex: 1, minHeight: 0, overflow: "auto", padding: "8px 10px" }, children: [
2844
+ loading ? /* @__PURE__ */ jsx("div", { style: { padding: 8, color: "var(--text-dim)", fontSize: 11 }, children: t2("directoryPicker.loadingDirectories") }) : drives !== null ? /* @__PURE__ */ jsx(Fragment, { children: drives.length > 0 ? drives.map((drive) => /* @__PURE__ */ jsxs(
2845
+ "button",
2846
+ {
2847
+ className: "directory-picker-entry",
2848
+ type: "button",
2849
+ onClick: () => void navigateTo(drive.path),
2850
+ title: drive.path,
2851
+ style: { width: "100%", minHeight: 34, display: "flex", alignItems: "center", gap: 7, padding: "6px 8px", border: 0, borderRadius: 5, background: "none", color: "var(--text-muted)", cursor: "pointer", textAlign: "left", fontFamily: "var(--font-mono)", fontSize: 11 },
2852
+ children: [
2853
+ /* @__PURE__ */ jsx(DriveIcon, {}),
2854
+ /* @__PURE__ */ jsx("span", { children: drive.name })
2855
+ ]
2856
+ },
2857
+ drive.path
2858
+ )) : /* @__PURE__ */ jsx("div", { style: { padding: 8, color: "var(--text-dim)", fontSize: 11 }, children: t2("directoryPicker.noDrives") }) }) : directories.length > 0 ? directories.map((entry) => /* @__PURE__ */ jsxs(
2859
+ "button",
2860
+ {
2861
+ className: "directory-picker-entry",
2862
+ type: "button",
2863
+ onClick: () => void navigateTo(entry.path),
2864
+ title: entry.path,
2865
+ style: { width: "100%", minHeight: 30, display: "flex", alignItems: "center", gap: 7, padding: "5px 8px", border: 0, borderRadius: 5, background: "none", color: "var(--text-muted)", cursor: "pointer", textAlign: "left", fontFamily: "var(--font-mono)", fontSize: 11 },
2866
+ children: [
2867
+ /* @__PURE__ */ jsx(FolderIcon, {}),
2868
+ /* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: entry.name })
2869
+ ]
2870
+ },
2871
+ entry.path
2872
+ )) : /* @__PURE__ */ jsx("div", { style: { padding: 8, color: "var(--text-dim)", fontSize: 11 }, children: t2("directoryPicker.noSubdirectories") }),
2873
+ (loadError || error) && /* @__PURE__ */ jsx("div", { style: { padding: "8px", color: "var(--danger, #dc2626)", fontSize: 11 }, children: loadError ?? error })
2874
+ ] }),
2875
+ newFolderOpen && /* @__PURE__ */ jsxs("form", { onSubmit: handleNewFolderSubmit, style: { flexShrink: 0, padding: "10px 14px", borderTop: "1px solid var(--border)" }, children: [
2876
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
2877
+ /* @__PURE__ */ jsx("label", { htmlFor: "aiti-directory-new-folder", style: { position: "absolute", width: 1, height: 1, padding: 0, margin: -1, overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", border: 0 }, children: t2("directoryPicker.folderName") }),
2878
+ /* @__PURE__ */ jsx(
2879
+ "input",
2880
+ {
2881
+ className: "directory-picker-new-folder-name",
2882
+ id: "aiti-directory-new-folder",
2883
+ type: "text",
2884
+ value: newFolderName,
2885
+ placeholder: t2("directoryPicker.folderName"),
2886
+ autoFocus: true,
2887
+ autoComplete: "off",
2888
+ spellCheck: false,
2889
+ onChange: (event) => {
2890
+ setNewFolderName(event.target.value);
2891
+ setNewFolderError(null);
2892
+ },
2893
+ onKeyDown: (event) => {
2894
+ if (event.key === "Escape") {
2895
+ event.stopPropagation();
2896
+ setNewFolderOpen(false);
2897
+ setNewFolderError(null);
2898
+ }
2899
+ },
2900
+ style: { minWidth: 0, flex: 1, height: 32, padding: "0 10px", border: "1px solid var(--border)", borderRadius: 6, outline: "none", background: "var(--bg-panel)", color: "var(--text)", fontSize: 12 }
2901
+ }
2902
+ ),
2903
+ /* @__PURE__ */ jsx(
2904
+ "button",
2905
+ {
2906
+ className: "directory-picker-action",
2907
+ type: "submit",
2908
+ disabled: !canSubmitNewFolder,
2909
+ style: { minWidth: 58, height: 32, padding: "0 12px", border: 0, borderRadius: 6, background: "var(--accent)", color: "#fff", fontSize: 13, fontWeight: 600, opacity: canSubmitNewFolder ? 1 : 0.6, cursor: canSubmitNewFolder ? "pointer" : "default" },
2910
+ children: newFolderBusy ? t2("directoryPicker.creating") : t2("directoryPicker.create")
2911
+ }
2912
+ )
2913
+ ] }),
2914
+ newFolderError && /* @__PURE__ */ jsx("div", { style: { paddingTop: 6, color: "var(--danger, #dc2626)", fontSize: 11 }, children: newFolderError })
2915
+ ] }),
2916
+ /* @__PURE__ */ jsxs("div", { className: "directory-picker-footer", style: { display: "flex", alignItems: "center", gap: 10, flexShrink: 0, padding: "10px 18px", borderTop: "1px solid var(--border)" }, children: [
2917
+ /* @__PURE__ */ jsxs(
2918
+ "button",
2919
+ {
2920
+ className: "directory-picker-new-folder",
2921
+ type: "button",
2922
+ onClick: () => {
2923
+ setNewFolderOpen(true);
2924
+ setNewFolderError(null);
2925
+ },
2926
+ disabled: !canCreateFolder,
2927
+ title: t2("directoryPicker.newFolderIn", { path: currentPath }),
2928
+ style: { display: "flex", alignItems: "center", gap: 6, padding: "6px 10px", border: "1px solid var(--border)", borderRadius: 6, background: "none", color: "var(--text-muted)", fontSize: 13, opacity: canCreateFolder ? 1 : 0.45, cursor: canCreateFolder ? "pointer" : "default" },
2929
+ children: [
2930
+ /* @__PURE__ */ jsx(FolderPlusIcon, {}),
2931
+ t2("directoryPicker.newFolder")
2932
+ ]
2933
+ }
2934
+ ),
2935
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 10, marginLeft: "auto" }, children: [
2936
+ /* @__PURE__ */ jsx("button", { className: "directory-picker-action", type: "button", onClick: onCancel, disabled: busy, style: { padding: "6px 14px", border: "1px solid var(--border)", borderRadius: 6, background: "none", color: "var(--text-muted)", cursor: busy ? "default" : "pointer", fontSize: 13 }, children: t2("i18n.cancel") }),
2937
+ /* @__PURE__ */ jsx(
2938
+ "button",
2939
+ {
2940
+ className: "directory-picker-action",
2941
+ type: "button",
2942
+ onClick: () => onSelect(currentPath),
2943
+ disabled: !canSelect,
2944
+ title: t2("directoryPicker.selectCurrentDirectory"),
2945
+ style: { padding: "6px 16px", border: 0, borderRadius: 6, background: "var(--accent)", color: "#fff", fontSize: 13, fontWeight: 600, opacity: canSelect ? 1 : 0.6, cursor: canSelect ? "pointer" : "default" },
2946
+ children: busy ? t2("i18n.checking") : t2("directoryPicker.selectThisFolder")
2947
+ }
2948
+ )
2949
+ ] })
2950
+ ] })
2951
+ ] })
2952
+ }
2953
+ );
2954
+ const portaled = host.createPortal ? host.createPortal(overlay2, portalTarget) : null;
2955
+ return portaled ?? overlay2;
2956
+ }
2957
+ const HOST = { apiUrl, t: ct, getExtService: extSvc, createPortal };
2958
+ function DirectoryPicker(props) {
2959
+ return /* @__PURE__ */ jsx(DirectoryPicker$1, { ...props, host: HOST });
2248
2960
  }
2249
2961
  function WorkspaceDropdown({ selected, onSelect, onClose, align = "left", showUseDefault = true, allOption, width, extraTopItem }) {
2250
2962
  const selectedStr = selected || "";
@@ -2286,14 +2998,16 @@ function WorkspaceDropdown({ selected, onSelect, onClose, align = "left", showUs
2286
2998
  useEffect(() => {
2287
2999
  const onScroll = (e) => {
2288
3000
  if (ddRef.current && e.target instanceof Node && ddRef.current.contains(e.target)) return;
3001
+ if (pickerOpen || isDirectoryPickerTarget(e.target)) return;
2289
3002
  onClose();
2290
3003
  };
2291
3004
  window.addEventListener("scroll", onScroll, true);
2292
3005
  return () => window.removeEventListener("scroll", onScroll, true);
2293
- }, [onClose]);
3006
+ }, [onClose, pickerOpen]);
2294
3007
  useEffect(() => {
2295
3008
  let alive = true;
2296
- const p = dedupeFetch(apiUrl("/api/home")).then((r) => r.json()).then((d) => d?.home ?? null).catch(() => null);
3009
+ const svc = extSvc("pi-web.home");
3010
+ const p = svc?.ensure ? svc.ensure() : dedupeFetch(apiUrl("/api/home")).then((r) => r.json()).then((d) => d?.home ?? null).catch(() => null);
2297
3011
  void p.then((dir) => {
2298
3012
  if (alive && dir) setHome(dir);
2299
3013
  });
@@ -2381,8 +3095,8 @@ function WorkspaceDropdown({ selected, onSelect, onClose, align = "left", showUs
2381
3095
  },
2382
3096
  style: { display: "flex", alignItems: "center", gap: 7, width: "100%", padding: "8px 10px", background: "var(--bg)", borderLeft: "none", borderRight: "none", borderTop: "none", borderBottom: "1px solid var(--border)", color: !selectedStr ? "var(--text)" : "var(--text-muted)", cursor: "pointer", textAlign: "left", fontSize: 11 },
2383
3097
  children: [
2384
- !selectedStr ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx("span", { style: { width: 10, flexShrink: 0 } }),
2385
- /* @__PURE__ */ jsx(FolderIcon, { open: false }),
3098
+ !selectedStr ? /* @__PURE__ */ jsx(CheckIcon$1, {}) : /* @__PURE__ */ jsx("span", { style: { width: 10, flexShrink: 0 } }),
3099
+ /* @__PURE__ */ jsx(FolderIcon$1, { open: false }),
2386
3100
  /* @__PURE__ */ jsx(PathLabel, { text: allOption.label, style: { flex: 1 } })
2387
3101
  ]
2388
3102
  },
@@ -2402,7 +3116,7 @@ function WorkspaceDropdown({ selected, onSelect, onClose, align = "left", showUs
2402
3116
  title: p.root,
2403
3117
  style: { display: "flex", alignItems: "center", gap: 7, width: "100%", padding: "8px 10px", background: "var(--bg)", borderLeft: "none", borderRight: "none", borderTop: "none", borderBottom: "1px solid var(--border)", color: cur ? "var(--text)" : "var(--text-muted)", cursor: "pointer", textAlign: "left", fontSize: 11, fontFamily: "var(--font-mono)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
2404
3118
  children: [
2405
- cur ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx("span", { style: { width: 10, flexShrink: 0 } }),
3119
+ cur ? /* @__PURE__ */ jsx(CheckIcon$1, {}) : /* @__PURE__ */ jsx("span", { style: { width: 10, flexShrink: 0 } }),
2406
3120
  /* @__PURE__ */ jsx(PathLabel, { text: displayCwd(p.root, home), style: { flex: 1 } }),
2407
3121
  /* @__PURE__ */ jsx(ActivityBadges, { act: activity.get(p.key), t: ct })
2408
3122
  ]
@@ -2446,7 +3160,7 @@ function WorkspaceDropdown({ selected, onSelect, onClose, align = "left", showUs
2446
3160
  ]
2447
3161
  }
2448
3162
  ),
2449
- pickerOpen ? /* @__PURE__ */ jsx(DirectoryBrowser, { initialPath: selectedStr, onSelect: (p) => {
3163
+ pickerOpen ? /* @__PURE__ */ jsx(DirectoryPicker, { initialPath: selectedStr, onSelect: (p) => {
2450
3164
  setPickerOpen(false);
2451
3165
  onClose();
2452
3166
  onSelect(p);
@@ -2709,7 +3423,7 @@ function TaskPicker({ onClose, onOpenTask, presetRepo, fallbackRepo, onDock }) {
2709
3423
  useEffect(() => {
2710
3424
  if (!wsOpen) return;
2711
3425
  const h = (e) => {
2712
- if (wsBoxRef.current && !wsBoxRef.current.contains(e.target)) setWsOpen(false);
3426
+ if (wsBoxRef.current && !wsBoxRef.current.contains(e.target) && !isDirectoryPickerTarget(e.target)) setWsOpen(false);
2713
3427
  };
2714
3428
  document.addEventListener("mousedown", h);
2715
3429
  return () => document.removeEventListener("mousedown", h);
@@ -3652,7 +4366,7 @@ function ReviewApp({ onClose, init, onExitToList }) {
3652
4366
  });
3653
4367
  };
3654
4368
  void pull();
3655
- const topicsSvc = extSvc("aiti-event-bus.subscribe-topics");
4369
+ const topicsSvc = extSvc$1("aiti-event-bus.subscribe-topics");
3656
4370
  if (topicsSvc) {
3657
4371
  const off = topicsSvc((f) => {
3658
4372
  if (f && f.type === "gr:task" && f.taskId === task.id) void pull();
@@ -5099,6 +5813,7 @@ function DockReviewWork() {
5099
5813
  }
5100
5814
  function register(ctx) {
5101
5815
  seedDockDefault("aiti-git-review:workspace", "right-panel");
5816
+ __setCtx$1(ctx);
5102
5817
  __setCtx(ctx);
5103
5818
  setGRCtx(ctx);
5104
5819
  ctx.registerItems?.("toolbar", [{