@agimon-ai/po-git 0.0.0-alpha.19 → 0.0.0-alpha.190

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,7 +1,7 @@
1
- import { createApiClient, defineActivityGroup, defineChannelFile, defineFill, defineGlobalStore, defineLeaderBinding, defineRepositorySettingsPanel, defineSessionStore, defineToolRenderer, defineWebLifecycle, defineWebPlugin, sessionApiAddress } from "@agimon-ai/po-core/web";
2
- import { AlertIcon, ArrowRightIcon, BranchIcon, Button, CheckIcon, ChevronDownIcon, ChevronRightIcon, CloseIcon, Dialog, DialogBody, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DiffView, Dot, DropdownMenuItem, EmptyState, Input, MessageIcon, MessageItem, MessageItemBody, MessageItemHeader, OptionRow, RadioGroup, RadioGroupCard, ReviewCommentDraft, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, SettingsActions, SettingsCard, SettingsField, SettingsNote, SettingsRow, SettingsRowDescription, SettingsRowText, SettingsRowTitle, SettingsSection, SettingsSectionDescription, SettingsSectionHeader, SettingsSectionTitle, ShieldIcon, Spinner, StatusBadge, buildReviewPrompt, reviewCommentAnchor, toolTone } from "@agimon-ai/po-web-components";
3
- import { createElement, useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
4
- import { sealedTransport } from "@agimon-ai/po-web-security/browser";
1
+ import { createApiClient, defineActivityGroup, defineChannelFile, defineFill, defineHostStore, defineLeaderBinding, defineRepositorySettingsPanel, defineSessionStore, defineToolRenderer, defineWebLifecycle, defineWebPlugin, sessionApiAddress } from "@agimon-ai/po-core/web";
2
+ import { ArrowRightIcon, BranchIcon, Button, CheckIcon, ChevronDownIcon, ChevronUpIcon, CodeBlock, Dialog, DialogContent, DialogTitle, DiffView, Dot, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, EmptyState, FolderIcon, Input, KebabIcon, MessageIcon, MessageItem, MessageItemBody, ProfilePicker, ReviewCommentDraft, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, SettingsActions, SettingsCard, SettingsNote, SettingsRow, SettingsRowDescription, SettingsRowText, SettingsRowTitle, SettingsSection, SettingsSectionDescription, SettingsSectionHeader, SettingsSectionTitle, ShieldIcon, Spinner, StatusBadge, Tabs, TabsContent, TabsList, TabsTrigger, TrashIcon, buildReviewPrompt, useProfileCatalog } from "@agimon-ai/po-web-components";
3
+ import { createElement, useCallback, useEffect, useEffectEvent, useId, useRef, useState } from "react";
4
+ import { browserTransport } from "@agimon-ai/po-web-security/browser";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { useStore } from "@tanstack/react-store";
7
7
  const api = createApiClient({
@@ -11,6 +11,16 @@ const api = createApiClient({
11
11
  path: "/branches",
12
12
  response: void 0
13
13
  },
14
+ deleteBranch: {
15
+ method: "DELETE",
16
+ path: "/branches",
17
+ response: void 0
18
+ },
19
+ openBranchFolder: {
20
+ method: "POST",
21
+ path: "/branches/open",
22
+ response: void 0
23
+ },
14
24
  /** Workspace: a top-level worktree session on an existing or new branch. */
15
25
  createSession: {
16
26
  method: "POST",
@@ -46,18 +56,33 @@ const api = createApiClient({
46
56
  }
47
57
  }, {
48
58
  scopes: [
49
- "global",
59
+ "host",
50
60
  "workspace",
51
61
  "session"
52
62
  ],
53
63
  basePath: "git",
54
- transport: (input, init) => sealedTransport.fetch(input, init),
64
+ transport: (input, init) => browserTransport.fetch(input, init),
55
65
  sessionAddress: sessionApiAddress
56
66
  });
57
67
  //#endregion
68
+ //#region src/constants/git.ts
69
+ /** Installs the rift CLI. Shown to the person to copy, and named in the error an agent reads. */
70
+ const RIFT_INSTALL_COMMAND = "npm install -g rift-snapshot";
71
+ //#endregion
58
72
  //#region src/extensions/workspaces/(frontend)/_lib/newSessionForm.ts
59
73
  const MAX_LISTED = 200;
60
- /** Local branches first, then remote-only ones, filtered by a case-insensitive substring. */
74
+ /** The last segment of a path: enough to name a checkout without spelling out where it lives. */
75
+ function folderName(path) {
76
+ return path.split(/[\\/]/).filter((part) => part !== "").pop() ?? path;
77
+ }
78
+ /** Where a busy branch is checked out, short enough for one line. */
79
+ function busyNote(busyAt, workspaceRoot) {
80
+ return busyAt === workspaceRoot ? "Checked out here" : `Checked out in ${folderName(busyAt)}`;
81
+ }
82
+ /**
83
+ * Local branches a session can take, then the checked-out ones, then remote-only ones, filtered by a
84
+ * case-insensitive substring.
85
+ */
61
86
  function branchOptions(branches, query) {
62
87
  const needle = query.trim().toLowerCase();
63
88
  const matches = (text) => needle === "" || text.toLowerCase().includes(needle);
@@ -66,7 +91,7 @@ function branchOptions(branches, query) {
66
91
  name: branch.name,
67
92
  current: branch.name === branches.current,
68
93
  ...branch.checkedOutAt === void 0 ? {} : { busyAt: branch.checkedOutAt }
69
- }));
94
+ })).sort((a, b) => Number(a.busyAt !== void 0) - Number(b.busyAt !== void 0));
70
95
  const remote = branches.remote.filter((branch) => matches(`${branch.remote}/${branch.name}`)).map((branch) => ({
71
96
  key: `remote:${branch.remote}/${branch.name}`,
72
97
  name: branch.name,
@@ -91,10 +116,18 @@ function formProblem$1(state) {
91
116
  }
92
117
  if (state.mode === "new" && state.newBranch.trim() === "") return "Name the new branch.";
93
118
  }
119
+ /** The launch profile choice for any session kind, or undefined when none was made. */
120
+ function launchSelection(state) {
121
+ return state.profile === void 0 ? void 0 : { profile: state.profile };
122
+ }
94
123
  /** The worktree create request for the form, or undefined in plain mode. */
95
124
  function createRequest(state) {
96
125
  const name = state.name.trim();
97
- const named = name === "" ? {} : { name };
126
+ const chosen = launchSelection(state);
127
+ const named = {
128
+ ...name === "" ? {} : { name },
129
+ ...chosen === void 0 ? {} : { selection: chosen }
130
+ };
98
131
  if (state.mode === "existing" && state.selected !== void 0) return {
99
132
  mode: "existing-branch",
100
133
  branch: state.selected.name,
@@ -113,20 +146,320 @@ function createRequest(state) {
113
146
  }
114
147
  //#endregion
115
148
  //#region src/extensions/workspaces/(frontend)/fill/_components/GitNewSessionDialog.tsx
116
- const MODES = [
117
- {
149
+ function Field$1({ label, children }) {
150
+ return /* @__PURE__ */ jsxs("label", {
151
+ className: "flex flex-col gap-2 text-base text-po-text",
152
+ children: [/* @__PURE__ */ jsx("span", { children: label }), children]
153
+ });
154
+ }
155
+ /** Inline presentation also lets story capture inspect content, rather than a portal-only root. */
156
+ function GitNewSessionDialogView({ workspaceRoot, branches, loadError = "", initialForm, busy = false, error = "", riftMissing = false, profileCatalog, onClose, onCreate, onDeleteBranch, onOpenBranchFolder }) {
157
+ const [form, setForm] = useState({
118
158
  mode: "existing",
119
- label: "existing branch"
120
- },
121
- {
122
- mode: "new",
123
- label: "new branch"
124
- },
125
- {
126
- mode: "plain",
127
- label: "no branch"
128
- }
129
- ];
159
+ newBranch: "",
160
+ baseRef: branches?.defaultBase ?? "",
161
+ name: "",
162
+ ...initialForm
163
+ });
164
+ const [query, setQuery] = useState("");
165
+ const [deleting, setDeleting] = useState();
166
+ const ready = branches?.repository === true && loadError === "";
167
+ const loading = branches === null && loadError === "";
168
+ const mode = ready || loading ? form.mode : "plain";
169
+ const state = {
170
+ ...form,
171
+ mode,
172
+ baseRef: form.baseRef || branches?.defaultBase || ""
173
+ };
174
+ const problem = formProblem$1(state);
175
+ const update = (patch) => setForm((current) => ({
176
+ ...current,
177
+ ...patch
178
+ }));
179
+ const options = branches === null ? [] : branchOptions(branches, query);
180
+ const bases = branches === null ? [] : baseOptions(branches);
181
+ const submit = () => {
182
+ if (!busy && !loading && deleting === void 0 && problem === void 0) onCreate(state);
183
+ };
184
+ return /* @__PURE__ */ jsxs("section", {
185
+ "data-testid": "new-session-dialog",
186
+ "aria-label": "New session",
187
+ className: "shrink-0 overflow-hidden rounded-lg border border-po-border bg-po-panel shadow-sm",
188
+ children: [
189
+ /* @__PURE__ */ jsxs("header", {
190
+ className: "border-b border-po-border-soft px-6 py-4",
191
+ children: [/* @__PURE__ */ jsx("h3", {
192
+ className: "text-xl font-semibold text-po-hi",
193
+ children: "New session"
194
+ }), /* @__PURE__ */ jsx("p", {
195
+ className: "mt-1 font-mono text-sm text-po-dim",
196
+ title: workspaceRoot,
197
+ children: folderName(workspaceRoot)
198
+ })]
199
+ }),
200
+ /* @__PURE__ */ jsxs("div", {
201
+ className: "flex flex-col gap-5 p-6",
202
+ children: [
203
+ !ready ? /* @__PURE__ */ jsx("p", {
204
+ "data-testid": "git-new-session-plain-note",
205
+ className: "text-base text-po-dim",
206
+ children: loading ? "Reading branches..." : loadError || "This workspace is not a git checkout. Start a plain session in this folder."
207
+ }) : /* @__PURE__ */ jsxs(Tabs, {
208
+ value: mode,
209
+ onValueChange: (value) => update({ mode: value }),
210
+ className: "flex flex-col gap-5",
211
+ children: [
212
+ /* @__PURE__ */ jsxs(TabsList, {
213
+ "aria-label": "Session kind",
214
+ className: "rounded-md border border-po-border-soft bg-po-bg p-1",
215
+ children: [
216
+ /* @__PURE__ */ jsx(TabsTrigger, {
217
+ "data-testid": "git-new-session-mode-existing",
218
+ value: "existing",
219
+ disabled: busy,
220
+ className: "flex-1 justify-center",
221
+ children: "Existing branch"
222
+ }),
223
+ /* @__PURE__ */ jsx(TabsTrigger, {
224
+ "data-testid": "git-new-session-mode-new",
225
+ value: "new",
226
+ disabled: busy,
227
+ className: "flex-1 justify-center",
228
+ children: "New branch"
229
+ }),
230
+ /* @__PURE__ */ jsx(TabsTrigger, {
231
+ "data-testid": "git-new-session-mode-plain",
232
+ value: "plain",
233
+ disabled: busy,
234
+ className: "flex-1 justify-center",
235
+ children: "No branch"
236
+ })
237
+ ]
238
+ }),
239
+ /* @__PURE__ */ jsxs(TabsContent, {
240
+ value: "existing",
241
+ className: "flex flex-col gap-2",
242
+ children: [
243
+ /* @__PURE__ */ jsx("p", {
244
+ className: "text-base font-medium",
245
+ children: "Branch"
246
+ }),
247
+ /* @__PURE__ */ jsx(Input, {
248
+ "data-testid": "git-new-session-branch-search",
249
+ "aria-label": "Find a branch",
250
+ placeholder: "Find a branch",
251
+ value: query,
252
+ onChange: (event) => setQuery(event.target.value),
253
+ disabled: busy
254
+ }),
255
+ /* @__PURE__ */ jsxs("fieldset", {
256
+ "aria-label": "Branches",
257
+ className: "max-h-64 min-w-0 overflow-y-auto rounded-md border border-po-border-soft bg-po-bg p-1",
258
+ children: [options.length === 0 ? /* @__PURE__ */ jsx("p", {
259
+ className: "px-3 py-2 text-sm text-po-dim",
260
+ children: "No matching branches"
261
+ }) : null, options.map((branch, index) => /* @__PURE__ */ jsxs("div", { children: [branch.remote !== void 0 && (index === 0 || options[index - 1]?.remote === void 0) ? /* @__PURE__ */ jsx("p", {
262
+ className: "mt-1 border-t border-po-border-soft px-3 pt-2 text-sm text-po-dim",
263
+ children: "Remote branches"
264
+ }) : null, /* @__PURE__ */ jsxs("div", {
265
+ className: "flex min-w-0 items-start gap-1",
266
+ children: [/* @__PURE__ */ jsxs("button", {
267
+ "data-testid": "git-new-session-branch-option",
268
+ "data-branch": branch.name,
269
+ "data-remote": branch.remote,
270
+ "aria-pressed": form.selected?.key === branch.key,
271
+ disabled: branch.busyAt !== void 0 || busy,
272
+ onClick: () => update({ selected: branch }),
273
+ className: `flex min-w-0 flex-1 flex-col gap-1 rounded px-3 py-2 text-left text-base ${form.selected?.key === branch.key ? "bg-po-tint-green text-po-green" : "text-po-text"}`,
274
+ children: [/* @__PURE__ */ jsxs("span", {
275
+ className: "flex items-center justify-between gap-2",
276
+ children: [/* @__PURE__ */ jsx("span", {
277
+ className: "font-mono break-all",
278
+ children: branch.remote === void 0 ? branch.name : `${branch.remote}/${branch.name}`
279
+ }), form.selected?.key === branch.key ? /* @__PURE__ */ jsx(CheckIcon, { className: "size-4 shrink-0" }) : null]
280
+ }), branch.busyAt !== void 0 ? /* @__PURE__ */ jsx("span", {
281
+ className: "truncate text-sm text-po-dim",
282
+ title: branch.busyAt,
283
+ children: busyNote(branch.busyAt, workspaceRoot)
284
+ }) : branch.current ? /* @__PURE__ */ jsx("span", {
285
+ className: "text-sm text-po-dim",
286
+ children: "Current"
287
+ }) : null]
288
+ }), /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
289
+ asChild: true,
290
+ children: /* @__PURE__ */ jsx(Button, {
291
+ variant: "ghost",
292
+ size: "icon-md",
293
+ className: "mt-1",
294
+ "aria-label": `Actions for ${branch.remote === void 0 ? branch.name : `${branch.remote}/${branch.name}`}`,
295
+ disabled: busy,
296
+ children: /* @__PURE__ */ jsx(KebabIcon, { className: "size-4" })
297
+ })
298
+ }), /* @__PURE__ */ jsxs(DropdownMenuContent, { children: [
299
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
300
+ disabled: branch.busyAt === void 0 || onOpenBranchFolder === void 0,
301
+ title: branch.busyAt === void 0 ? "This branch has no checked-out folder." : branch.busyAt,
302
+ onSelect: () => onOpenBranchFolder?.(branch.name),
303
+ children: [/* @__PURE__ */ jsx(FolderIcon, { className: "size-4" }), "Open in Finder"]
304
+ }),
305
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
306
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
307
+ variant: "destructive",
308
+ disabled: branch.remote !== void 0 || branch.busyAt !== void 0 || branch.current || onDeleteBranch === void 0,
309
+ title: branch.remote !== void 0 ? "Only local branches can be deleted here." : branch.busyAt !== void 0 || branch.current ? "Close this branch’s worktree before deleting it." : void 0,
310
+ onSelect: () => setDeleting(branch),
311
+ children: [/* @__PURE__ */ jsx(TrashIcon, { className: "size-4" }), "Delete branch"]
312
+ })
313
+ ] })] })]
314
+ })] }, branch.key))]
315
+ }),
316
+ deleting !== void 0 ? /* @__PURE__ */ jsxs("fieldset", {
317
+ "aria-label": "Confirm branch deletion",
318
+ className: "flex flex-col gap-3 rounded-md border border-po-edge-red bg-po-tint-red p-3",
319
+ children: [/* @__PURE__ */ jsxs("p", {
320
+ className: "text-sm text-po-text",
321
+ children: [
322
+ "Delete local branch ",
323
+ /* @__PURE__ */ jsx("span", {
324
+ className: "font-mono break-all",
325
+ children: deleting.name
326
+ }),
327
+ "? Git will refuse if it contains unmerged commits. No worktree or remote branch will be removed."
328
+ ]
329
+ }), /* @__PURE__ */ jsxs("div", {
330
+ className: "flex justify-end gap-2",
331
+ children: [/* @__PURE__ */ jsx(Button, {
332
+ variant: "ghost",
333
+ disabled: busy,
334
+ onClick: () => setDeleting(void 0),
335
+ children: "Cancel deletion"
336
+ }), /* @__PURE__ */ jsx(Button, {
337
+ variant: "danger-outline",
338
+ disabled: busy,
339
+ onClick: async () => {
340
+ if (busy || onDeleteBranch === void 0) return;
341
+ if (await onDeleteBranch(deleting.name)) {
342
+ if (form.selected?.key === deleting.key) update({ selected: void 0 });
343
+ setDeleting(void 0);
344
+ }
345
+ },
346
+ children: "Delete branch"
347
+ })]
348
+ })]
349
+ }) : null
350
+ ]
351
+ }),
352
+ /* @__PURE__ */ jsxs(TabsContent, {
353
+ value: "new",
354
+ className: "flex flex-col gap-4",
355
+ children: [/* @__PURE__ */ jsx(Field$1, {
356
+ label: "Branch name",
357
+ children: /* @__PURE__ */ jsx(Input, {
358
+ "data-testid": "git-new-session-new-branch",
359
+ "aria-label": "Branch name",
360
+ placeholder: "feature/my-change",
361
+ className: "font-mono",
362
+ value: form.newBranch,
363
+ onChange: (event) => update({ newBranch: event.target.value }),
364
+ disabled: busy
365
+ })
366
+ }), /* @__PURE__ */ jsx(Field$1, {
367
+ label: "From",
368
+ children: /* @__PURE__ */ jsxs(Select, {
369
+ value: form.baseRef || branches?.defaultBase || "",
370
+ onValueChange: (baseRef) => update({ baseRef }),
371
+ disabled: busy,
372
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
373
+ "data-testid": "git-new-session-base",
374
+ "aria-label": "From",
375
+ className: "font-mono",
376
+ children: /* @__PURE__ */ jsx(SelectValue, {})
377
+ }), /* @__PURE__ */ jsx(SelectContent, { children: bases.map((base) => /* @__PURE__ */ jsx(SelectItem, {
378
+ value: base,
379
+ children: base
380
+ }, base)) })]
381
+ })
382
+ })]
383
+ }),
384
+ /* @__PURE__ */ jsx(TabsContent, {
385
+ value: "plain",
386
+ children: /* @__PURE__ */ jsx("p", {
387
+ className: "text-base text-po-dim",
388
+ children: "Start in this workspace folder, without creating a worktree."
389
+ })
390
+ })
391
+ ]
392
+ }),
393
+ /* @__PURE__ */ jsx(Field$1, {
394
+ label: /* @__PURE__ */ jsxs(Fragment, { children: [
395
+ "Name",
396
+ " ",
397
+ /* @__PURE__ */ jsx("span", {
398
+ className: "text-sm text-po-dim",
399
+ children: mode === "plain" ? "(optional)" : "(optional, defaults to the branch)"
400
+ })
401
+ ] }),
402
+ children: /* @__PURE__ */ jsx(Input, {
403
+ "data-testid": "new-session-name",
404
+ "aria-label": "Session name",
405
+ placeholder: "Session name",
406
+ value: form.name,
407
+ onChange: (event) => update({ name: event.target.value }),
408
+ onKeyDown: (event) => {
409
+ if (event.key === "Enter") submit();
410
+ },
411
+ disabled: busy
412
+ })
413
+ }),
414
+ profileCatalog === void 0 ? null : /* @__PURE__ */ jsx(ProfilePicker, {
415
+ profiles: profileCatalog.profiles,
416
+ status: profileCatalog.status,
417
+ value: form.profile,
418
+ onChange: (profile) => update({ profile }),
419
+ disabled: busy
420
+ }),
421
+ mode !== "plain" ? /* @__PURE__ */ jsx("p", {
422
+ "data-testid": "new-session-hint",
423
+ className: "text-sm leading-relaxed text-po-dim",
424
+ children: (loading ? void 0 : problem) ?? "Runs in its own worktree, so this checkout stays as it is."
425
+ }) : null,
426
+ riftMissing ? /* @__PURE__ */ jsxs("div", {
427
+ "data-testid": "rift-install-notice",
428
+ role: "alert",
429
+ className: "flex flex-col gap-2 rounded-md border border-po-edge-magenta bg-po-tint-magenta px-3 py-3 text-sm text-po-hi",
430
+ children: [/* @__PURE__ */ jsx("p", { children: "This repository uses Rift, and its CLI is not installed here. Run these in the repository root, then try again." }), /* @__PURE__ */ jsx(CodeBlock, {
431
+ text: `${RIFT_INSTALL_COMMAND}
432
+ rift init`,
433
+ className: "language-bash"
434
+ })]
435
+ }) : error ? /* @__PURE__ */ jsx("p", {
436
+ "data-testid": "new-session-error",
437
+ role: "alert",
438
+ className: "rounded-md border border-po-edge-red bg-po-tint-red p-3 text-sm text-po-red",
439
+ children: error
440
+ }) : null
441
+ ]
442
+ }),
443
+ /* @__PURE__ */ jsxs("footer", {
444
+ className: "flex items-center justify-between border-t border-po-border-soft px-6 py-4",
445
+ children: [/* @__PURE__ */ jsx(Button, {
446
+ "data-testid": "new-session-cancel",
447
+ variant: "ghost",
448
+ disabled: busy,
449
+ onClick: onClose,
450
+ children: "Cancel"
451
+ }), /* @__PURE__ */ jsx(Button, {
452
+ "data-testid": "new-session-create",
453
+ variant: "primary",
454
+ title: problem,
455
+ disabled: busy || loading || deleting !== void 0 || problem !== void 0,
456
+ onClick: submit,
457
+ children: busy ? mode === "plain" ? "Creating session..." : "Creating worktree..." : riftMissing ? "Try again" : "Create session"
458
+ })]
459
+ })
460
+ ]
461
+ });
462
+ }
130
463
  function errorOf$1(body, status) {
131
464
  return typeof body === "object" && body !== null && typeof body.error === "string" ? body.error : `The cockpit answered ${String(status)}.`;
132
465
  }
@@ -138,70 +471,51 @@ function errorOf$1(body, status) {
138
471
  function GitNewSessionDialog({ newSession }) {
139
472
  const [branches, setBranches] = useState(null);
140
473
  const [loadError, setLoadError] = useState("");
141
- const [form, setForm] = useState({
142
- mode: "existing",
143
- newBranch: "",
144
- baseRef: "",
145
- name: ""
146
- });
147
- const [query, setQuery] = useState("");
148
474
  const [error, setError] = useState("");
475
+ const [riftMissing, setRiftMissing] = useState(false);
149
476
  const [busy, setBusy] = useState(false);
150
477
  const workspaceId = newSession?.workspaceId;
151
- const request = newSession?.requestWithStepUp;
478
+ const request = useEffectEvent((input) => newSession?.requestWithStepUp(input));
479
+ const profileCatalog = useProfileCatalog(workspaceId ?? "", newSession?.loadProfiles);
152
480
  useEffect(() => {
153
- if (workspaceId === void 0 || request === void 0) return;
481
+ if (workspaceId === void 0) return;
154
482
  let stale = false;
155
483
  const url = api.workspace(workspaceId).branches.url();
156
- request(url).then(async (response) => {
484
+ request(url)?.then(async (response) => {
157
485
  const body = await response.json().catch(() => void 0);
158
486
  if (stale) return;
159
487
  if (!response.ok) {
160
488
  setLoadError(errorOf$1(body, response.status));
161
489
  return;
162
490
  }
163
- const loaded = body;
164
- setBranches(loaded);
165
- setForm((current) => ({
166
- ...current,
167
- baseRef: loaded.defaultBase ?? ""
168
- }));
491
+ setBranches(body);
169
492
  }).catch(() => {
170
493
  if (!stale) setLoadError("The branches could not be loaded.");
171
494
  });
172
495
  return () => {
173
496
  stale = true;
174
497
  };
175
- }, [workspaceId, request]);
498
+ }, [workspaceId]);
176
499
  if (newSession === void 0) return null;
177
- const gitReady = branches?.repository === true && loadError === "";
178
- const mode = gitReady || branches === null ? form.mode : "plain";
179
- const state = {
180
- ...form,
181
- mode
182
- };
183
- const problem = formProblem$1(state);
184
- const options = branches === null ? [] : branchOptions(branches, query);
185
- const bases = branches === null ? [] : baseOptions(branches);
186
- const update = (patch) => setForm((current) => ({
187
- ...current,
188
- ...patch
189
- }));
190
- const submit = async () => {
191
- if (busy || problem !== void 0) return;
500
+ const submit = async (state) => {
501
+ if (busy || formProblem$1(state) !== void 0) return;
192
502
  setBusy(true);
193
503
  setError("");
504
+ setRiftMissing(false);
194
505
  const body = createRequest(state);
195
506
  let failure;
196
- if (body === void 0) failure = await newSession.createPlain(state.name);
197
- else try {
198
- const response = await newSession.requestWithStepUp(api.workspace(newSession.workspaceId).createSession.url(), {
199
- method: "POST",
200
- headers: { "Content-Type": "application/json" },
201
- body: JSON.stringify(body)
202
- });
203
- const answer = await response.json().catch(() => void 0);
204
- failure = response.ok ? await newSession.openCreated(answer.sessionId) : errorOf$1(answer, response.status);
507
+ try {
508
+ if (body === void 0) failure = await newSession.createPlain(state.name, launchSelection(state));
509
+ else {
510
+ const response = await newSession.requestWithStepUp(api.workspace(newSession.workspaceId).createSession.url(), {
511
+ method: "POST",
512
+ headers: { "Content-Type": "application/json" },
513
+ body: JSON.stringify(body)
514
+ });
515
+ const answer = await response.json().catch(() => void 0);
516
+ failure = response.ok ? await newSession.openCreated(answer.sessionId) : errorOf$1(answer, response.status);
517
+ setRiftMissing(!response.ok && answer?.code === "rift_missing");
518
+ }
205
519
  } catch {
206
520
  failure = "The cockpit is unreachable.";
207
521
  }
@@ -209,161 +523,60 @@ function GitNewSessionDialog({ newSession }) {
209
523
  setError(failure);
210
524
  setBusy(false);
211
525
  };
526
+ const branchAction = async (branch, action) => {
527
+ if (busy) return false;
528
+ setBusy(true);
529
+ setError("");
530
+ setRiftMissing(false);
531
+ try {
532
+ const workspace = api.workspace(newSession.workspaceId);
533
+ const response = await newSession.requestWithStepUp(action === "delete" ? workspace.deleteBranch.url() : workspace.openBranchFolder.url(), {
534
+ method: action === "delete" ? "DELETE" : "POST",
535
+ headers: { "Content-Type": "application/json" },
536
+ body: JSON.stringify({ branch })
537
+ });
538
+ const body = await response.json().catch(() => void 0);
539
+ if (!response.ok) {
540
+ setError(errorOf$1(body, response.status));
541
+ return false;
542
+ }
543
+ if (action === "delete") setBranches((current) => current === null ? null : {
544
+ ...current,
545
+ local: current.local.filter((item) => item.name !== branch)
546
+ });
547
+ return true;
548
+ } catch {
549
+ setError("The cockpit is unreachable.");
550
+ return false;
551
+ } finally {
552
+ setBusy(false);
553
+ }
554
+ };
212
555
  return /* @__PURE__ */ jsx(Dialog, {
213
556
  open: true,
214
- onOpenChange: (next) => !next && !busy && newSession.close(),
557
+ onOpenChange: (next) => {
558
+ if (!next && !busy) newSession.close();
559
+ },
215
560
  children: /* @__PURE__ */ jsxs(DialogContent, {
216
561
  width: "md",
217
- "data-testid": "new-session-dialog",
562
+ className: "overflow-y-auto p-0",
218
563
  "aria-describedby": void 0,
219
- children: [/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "new session" }) }), /* @__PURE__ */ jsxs(DialogBody, { children: [
220
- /* @__PURE__ */ jsx("p", {
221
- className: "truncate text-sm text-po-dim",
222
- title: newSession.workspaceRoot,
223
- children: newSession.workspaceRoot
224
- }),
225
- gitReady ? /* @__PURE__ */ jsx("div", {
226
- role: "radiogroup",
227
- "aria-label": "session kind",
228
- className: "flex gap-1",
229
- children: MODES.map((entry) => /* @__PURE__ */ jsx(Button, {
230
- role: "radio",
231
- "aria-checked": mode === entry.mode,
232
- variant: mode === entry.mode ? "outline" : "ghost",
233
- size: "sm",
234
- "data-testid": `git-new-session-mode-${entry.mode}`,
235
- disabled: busy,
236
- className: mode === entry.mode ? "border-po-blue/60 text-po-hi" : void 0,
237
- onClick: () => update({ mode: entry.mode }),
238
- children: entry.label
239
- }, entry.mode))
240
- }) : branches === null && loadError === "" ? /* @__PURE__ */ jsx("p", {
241
- className: "text-sm text-po-dim",
242
- children: "reading branches…"
243
- }) : /* @__PURE__ */ jsx("p", {
244
- "data-testid": "git-new-session-plain-note",
245
- className: "text-sm text-po-dim",
246
- children: loadError || "This workspace is not a git checkout, so the session starts in its folder."
247
- }),
248
- mode === "existing" && gitReady ? /* @__PURE__ */ jsxs("div", {
249
- className: "flex flex-col gap-1",
250
- children: [/* @__PURE__ */ jsx(Input, {
251
- "data-testid": "git-new-session-branch-search",
252
- "aria-label": "find a branch",
253
- value: query,
254
- autoFocus: true,
255
- disabled: busy,
256
- onChange: (event) => setQuery(event.target.value),
257
- placeholder: "find a branch"
258
- }), /* @__PURE__ */ jsxs("div", {
259
- role: "listbox",
260
- "aria-label": "branches",
261
- className: "max-h-48 overflow-y-auto rounded border border-po-border bg-po-deep p-1",
262
- children: [options.length === 0 ? /* @__PURE__ */ jsx("p", {
263
- className: "px-2 py-1 text-sm text-po-dim",
264
- children: "no matching branches"
265
- }) : null, options.map((option) => /* @__PURE__ */ jsxs(OptionRow, {
266
- density: "compact",
267
- active: form.selected?.key === option.key,
268
- disabled: option.busyAt !== void 0 || busy,
269
- "data-testid": "git-new-session-branch-option",
270
- "data-branch": option.name,
271
- "data-remote": option.remote,
272
- onClick: () => update({ selected: option }),
273
- className: `w-full px-2.5 py-1 text-base ${option.busyAt !== void 0 ? "opacity-50" : ""}`,
274
- children: [/* @__PURE__ */ jsx("span", {
275
- className: "min-w-0 flex-1 truncate",
276
- children: option.remote === void 0 ? option.name : `${option.remote}/${option.name}`
277
- }), /* @__PURE__ */ jsx("span", {
278
- className: "shrink-0 text-sm text-po-dim",
279
- children: option.current && option.busyAt !== void 0 ? "current · checked out" : option.current ? "current" : option.busyAt !== void 0 ? "checked out" : option.remote !== void 0 ? "remote" : ""
280
- })]
281
- }, option.key))]
282
- })]
283
- }) : null,
284
- mode === "new" && gitReady ? /* @__PURE__ */ jsxs("div", {
285
- className: "flex flex-col gap-2",
286
- children: [/* @__PURE__ */ jsxs("label", {
287
- htmlFor: "git-new-session-new-branch",
288
- className: "flex flex-col gap-1",
289
- children: [/* @__PURE__ */ jsx("span", {
290
- className: "text-sm text-po-dim",
291
- children: "new branch"
292
- }), /* @__PURE__ */ jsx(Input, {
293
- id: "git-new-session-new-branch",
294
- "data-testid": "git-new-session-new-branch",
295
- value: form.newBranch,
296
- autoFocus: true,
297
- disabled: busy,
298
- onChange: (event) => update({ newBranch: event.target.value }),
299
- placeholder: "feature/my-change"
300
- })]
301
- }), /* @__PURE__ */ jsxs("span", {
302
- className: "flex flex-col gap-1",
303
- children: [/* @__PURE__ */ jsx("span", {
304
- className: "text-sm text-po-dim",
305
- children: "from"
306
- }), /* @__PURE__ */ jsxs(Select, {
307
- value: form.baseRef,
308
- onValueChange: (baseRef) => update({ baseRef }),
309
- disabled: busy,
310
- children: [/* @__PURE__ */ jsx(SelectTrigger, {
311
- "data-testid": "git-new-session-base",
312
- "aria-label": "base branch",
313
- children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "base branch" })
314
- }), /* @__PURE__ */ jsx(SelectContent, { children: bases.map((base) => /* @__PURE__ */ jsx(SelectItem, {
315
- value: base,
316
- children: base === branches?.current ? `${base} (current)` : base
317
- }, base)) })]
318
- })]
319
- })]
320
- }) : null,
321
- /* @__PURE__ */ jsxs("label", {
322
- htmlFor: "new-session-name",
323
- className: "flex flex-col gap-1",
324
- children: [/* @__PURE__ */ jsxs("span", {
325
- className: "text-sm text-po-dim",
326
- children: ["name ", /* @__PURE__ */ jsxs("span", {
327
- className: "text-po-dim",
328
- children: [
329
- "(optional",
330
- mode === "plain" ? "" : "; defaults to the branch",
331
- ")"
332
- ]
333
- })]
334
- }), /* @__PURE__ */ jsx(Input, {
335
- id: "new-session-name",
336
- "data-testid": "new-session-name",
337
- value: form.name,
338
- autoFocus: mode === "plain",
339
- disabled: busy,
340
- onChange: (event) => update({ name: event.target.value }),
341
- onKeyDown: (event) => {
342
- if (event.key === "Enter") submit();
343
- },
344
- placeholder: "session name"
345
- })]
346
- }),
347
- error ? /* @__PURE__ */ jsx("pre", {
348
- "data-testid": "new-session-error",
349
- className: "max-h-28 overflow-y-auto rounded border border-po-edge-red bg-po-tint-red/40 px-2.5 py-2 text-sm whitespace-pre-wrap text-po-red",
350
- children: error
351
- }) : null,
352
- /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
353
- variant: "outline",
354
- "data-testid": "new-session-cancel",
355
- disabled: busy,
356
- onClick: () => newSession.close(),
357
- children: "cancel"
358
- }), /* @__PURE__ */ jsx(Button, {
359
- variant: "primary",
360
- "data-testid": "new-session-create",
361
- title: problem,
362
- disabled: busy || problem !== void 0,
363
- onClick: () => void submit(),
364
- children: busy ? mode === "plain" ? "creating…" : "creating worktree…" : "create"
365
- })] })
366
- ] })]
564
+ children: [/* @__PURE__ */ jsx(DialogTitle, {
565
+ className: "sr-only",
566
+ children: "New session"
567
+ }), /* @__PURE__ */ jsx(GitNewSessionDialogView, {
568
+ workspaceRoot: newSession.workspaceRoot,
569
+ branches,
570
+ loadError,
571
+ busy,
572
+ error,
573
+ riftMissing,
574
+ profileCatalog,
575
+ onClose: newSession.close,
576
+ onCreate: (state) => void submit(state),
577
+ onDeleteBranch: (branch) => branchAction(branch, "delete"),
578
+ onOpenBranchFolder: (branch) => void branchAction(branch, "open")
579
+ }, newSession.workspaceId)]
367
580
  })
368
581
  });
369
582
  }
@@ -446,11 +659,17 @@ function saveRequestOf(form) {
446
659
  * AVOID:
447
660
  * - Echoing a token back. The view the server sends has none to echo.
448
661
  */
662
+ function Field({ label, children }) {
663
+ return /* @__PURE__ */ jsxs("label", {
664
+ className: "flex flex-col gap-2 text-base text-po-text",
665
+ children: [/* @__PURE__ */ jsx("span", { children: label }), children]
666
+ });
667
+ }
449
668
  const METHODS = [
450
669
  {
451
670
  method: "none",
452
671
  title: "This machine's git",
453
- detail: "Whatever git here already does: your credential helper, SSH config and agent."
672
+ detail: "Your credential helper, SSH config and agent, as they are."
454
673
  },
455
674
  {
456
675
  method: "ssh",
@@ -465,10 +684,14 @@ const METHODS = [
465
684
  ];
466
685
  function GitAuthForm({ saved, saving, saveError, savedNotice = false, onSave }) {
467
686
  const [form, setForm] = useState(() => formFromView(saved));
468
- const update = (patch) => setForm((current) => ({
469
- ...current,
470
- ...patch
471
- }));
687
+ const [edited, setEdited] = useState(false);
688
+ const update = (patch) => {
689
+ setEdited(true);
690
+ setForm((current) => ({
691
+ ...current,
692
+ ...patch
693
+ }));
694
+ };
472
695
  const problem = formProblem(form, saved);
473
696
  const tokenSaved = saved.https?.hasToken === true && saved.https.host === form.host.trim().toLowerCase();
474
697
  const host = form.host.trim() === "" ? "this host" : form.host.trim();
@@ -476,133 +699,156 @@ function GitAuthForm({ saved, saving, saveError, savedNotice = false, onSave })
476
699
  "data-testid": "git-auth-form",
477
700
  children: [
478
701
  /* @__PURE__ */ jsxs(SettingsSectionHeader, { children: [/* @__PURE__ */ jsx(SettingsSectionTitle, { children: "Connection" }), /* @__PURE__ */ jsx(SettingsSectionDescription, { children: "Worktree sessions use the setup of the workspace they belong to." })] }),
479
- /* @__PURE__ */ jsx(RadioGroup, {
702
+ /* @__PURE__ */ jsx("div", {
480
703
  "aria-label": "How git reaches your remote",
481
- value: form.method,
482
- onValueChange: (value) => update({ method: value }),
483
- className: "grid grid-cols-1 gap-3",
484
- children: METHODS.map((choice) => /* @__PURE__ */ jsxs(RadioGroupCard, {
485
- value: choice.method,
486
- "data-testid": `git-auth-method-${choice.method}`,
487
- className: "flex items-start gap-2 rounded-lg p-4",
488
- children: [/* @__PURE__ */ jsxs("span", {
489
- className: "flex min-w-0 flex-1 flex-col gap-1",
490
- children: [/* @__PURE__ */ jsx("span", {
491
- className: "text-base font-medium text-po-hi",
492
- children: choice.title
493
- }), /* @__PURE__ */ jsx("span", {
494
- className: "text-sm leading-relaxed text-po-dim",
495
- children: choice.detail
496
- })]
497
- }), form.method === choice.method ? /* @__PURE__ */ jsx(CheckIcon, { className: "size-4 shrink-0 text-po-green" }) : null]
704
+ className: "flex flex-col gap-3",
705
+ children: METHODS.map((choice) => /* @__PURE__ */ jsxs("div", {
706
+ className: `overflow-hidden rounded-lg border ${form.method === choice.method ? "border-po-green" : "border-po-border-soft"}`,
707
+ children: [
708
+ /* @__PURE__ */ jsxs("button", {
709
+ type: "button",
710
+ "aria-pressed": form.method === choice.method,
711
+ disabled: saving,
712
+ "data-testid": `git-auth-method-${choice.method}`,
713
+ onClick: () => update({ method: choice.method }),
714
+ className: `flex w-full items-start gap-3 p-4 text-left ${form.method === choice.method ? "bg-po-tint-green" : "bg-po-bg"}`,
715
+ children: [/* @__PURE__ */ jsxs("span", {
716
+ className: "flex flex-1 flex-col gap-1",
717
+ children: [/* @__PURE__ */ jsx("span", {
718
+ className: "text-base font-semibold text-po-hi",
719
+ children: choice.title
720
+ }), /* @__PURE__ */ jsx("span", {
721
+ className: "text-sm leading-relaxed text-po-dim",
722
+ children: choice.detail
723
+ })]
724
+ }), form.method === choice.method ? /* @__PURE__ */ jsx(CheckIcon, { className: "mt-0.5 size-4 shrink-0 text-po-green" }) : null]
725
+ }),
726
+ form.method === choice.method && form.method === "ssh" ? /* @__PURE__ */ jsxs("div", {
727
+ className: "flex flex-col gap-3 border-t border-po-border-soft p-4",
728
+ children: [/* @__PURE__ */ jsx(Field, {
729
+ label: "Key path",
730
+ children: /* @__PURE__ */ jsx(Input, {
731
+ "data-testid": "git-auth-key-path",
732
+ value: form.keyPath,
733
+ placeholder: "~/.ssh/id_ed25519",
734
+ spellCheck: false,
735
+ disabled: saving,
736
+ onChange: (event) => update({ keyPath: event.target.value }),
737
+ className: "font-mono"
738
+ })
739
+ }), /* @__PURE__ */ jsx("p", {
740
+ className: "text-sm leading-relaxed text-po-dim",
741
+ children: "Leave blank to use SSH config and ssh-agent. Passphrases need ssh-agent. Trust an unknown host in a terminal first."
742
+ })]
743
+ }) : null,
744
+ form.method === choice.method && form.method === "https" ? /* @__PURE__ */ jsxs("div", {
745
+ className: "flex flex-col gap-4 border-t border-po-border-soft p-4",
746
+ children: [
747
+ /* @__PURE__ */ jsxs("div", {
748
+ className: "grid grid-cols-2 gap-3",
749
+ children: [/* @__PURE__ */ jsx(Field, {
750
+ label: "Host",
751
+ children: /* @__PURE__ */ jsx(Input, {
752
+ "data-testid": "git-auth-host",
753
+ value: form.host,
754
+ spellCheck: false,
755
+ disabled: saving,
756
+ onChange: (event) => update({ host: event.target.value }),
757
+ className: "font-mono"
758
+ })
759
+ }), /* @__PURE__ */ jsx(Field, {
760
+ label: "Username",
761
+ children: /* @__PURE__ */ jsx(Input, {
762
+ "data-testid": "git-auth-username",
763
+ value: form.username,
764
+ autoComplete: "username",
765
+ spellCheck: false,
766
+ disabled: saving,
767
+ onChange: (event) => update({ username: event.target.value })
768
+ })
769
+ })]
770
+ }),
771
+ /* @__PURE__ */ jsx(Field, {
772
+ label: /* @__PURE__ */ jsxs(Fragment, { children: [
773
+ "Token",
774
+ " ",
775
+ tokenSaved ? /* @__PURE__ */ jsx("span", {
776
+ "data-testid": "git-auth-token-saved",
777
+ className: "ml-2 text-sm text-po-green",
778
+ children: "A token is saved"
779
+ }) : null
780
+ ] }),
781
+ children: /* @__PURE__ */ jsx(Input, {
782
+ "data-testid": "git-auth-token",
783
+ type: "password",
784
+ value: form.token,
785
+ autoComplete: "new-password",
786
+ placeholder: tokenSaved ? "Leave blank to keep it" : "Personal access token",
787
+ disabled: saving,
788
+ onChange: (event) => update({ token: event.target.value })
789
+ })
790
+ }),
791
+ /* @__PURE__ */ jsxs("p", {
792
+ className: "text-sm text-po-dim",
793
+ children: [
794
+ "Sent only to ",
795
+ /* @__PURE__ */ jsx("span", {
796
+ className: "font-mono",
797
+ children: host
798
+ }),
799
+ ". Other hosts use this machine's git."
800
+ ]
801
+ })
802
+ ]
803
+ }) : null
804
+ ]
498
805
  }, choice.method))
499
806
  }),
500
- form.method === "ssh" ? /* @__PURE__ */ jsx(SettingsCard, { children: /* @__PURE__ */ jsx(SettingsField, {
501
- id: "git-auth-key-path",
502
- label: "Key path",
503
- description: /* @__PURE__ */ jsxs(Fragment, { children: [
504
- "Leave it blank to use your SSH config and ssh-agent. A key with a passphrase works only through ssh-agent. An unknown host is refused: run ",
505
- /* @__PURE__ */ jsx("code", {
807
+ /* @__PURE__ */ jsxs(SettingsNote, {
808
+ className: "flex items-start gap-2 leading-relaxed",
809
+ children: [/* @__PURE__ */ jsx(ShieldIcon, {
810
+ "aria-hidden": true,
811
+ className: "mt-0.5 size-4 shrink-0"
812
+ }), /* @__PURE__ */ jsxs("span", { children: [
813
+ "Only cockpit pull, push and rebase use these credentials, not the agent.",
814
+ /* @__PURE__ */ jsx("br", {}),
815
+ "Stored in ",
816
+ /* @__PURE__ */ jsx("span", {
506
817
  className: "font-mono",
507
- children: "ssh -T git@github.com"
818
+ children: "~/.po/git/credentials.json"
508
819
  }),
509
- " once in a terminal to trust it."
510
- ] }),
511
- children: /* @__PURE__ */ jsx(Input, {
512
- id: "git-auth-key-path",
513
- "data-testid": "git-auth-key-path",
514
- value: form.keyPath,
515
- placeholder: "~/.ssh/id_ed25519",
516
- spellCheck: false,
517
- onChange: (event) => update({ keyPath: event.target.value }),
518
- className: "font-mono text-sm"
519
- })
520
- }) }) : null,
521
- form.method === "https" ? /* @__PURE__ */ jsxs(SettingsCard, { children: [
522
- /* @__PURE__ */ jsx(SettingsField, {
523
- id: "git-auth-host",
524
- label: "Host",
525
- description: "The one host this token is sent to.",
526
- children: /* @__PURE__ */ jsx(Input, {
527
- id: "git-auth-host",
528
- "data-testid": "git-auth-host",
529
- value: form.host,
530
- spellCheck: false,
531
- onChange: (event) => update({ host: event.target.value }),
532
- className: "font-mono text-sm"
533
- })
534
- }),
535
- /* @__PURE__ */ jsx(SettingsField, {
536
- id: "git-auth-username",
537
- label: "Username",
538
- children: /* @__PURE__ */ jsx(Input, {
539
- id: "git-auth-username",
540
- "data-testid": "git-auth-username",
541
- value: form.username,
542
- autoComplete: "username",
543
- spellCheck: false,
544
- onChange: (event) => update({ username: event.target.value }),
545
- className: "text-base"
546
- })
547
- }),
548
- /* @__PURE__ */ jsx(SettingsField, {
549
- id: "git-auth-token",
550
- label: "Token",
551
- description: /* @__PURE__ */ jsxs(Fragment, { children: [
552
- tokenSaved ? /* @__PURE__ */ jsxs("span", {
553
- "data-testid": "git-auth-token-saved",
554
- className: "text-po-green",
555
- children: ["A token is saved.", " "]
556
- }) : null,
557
- "Sent only to ",
558
- host,
559
- ". A remote on any other host keeps using this machine's own git credentials."
560
- ] }),
561
- children: /* @__PURE__ */ jsx(Input, {
562
- id: "git-auth-token",
563
- "data-testid": "git-auth-token",
564
- type: "password",
565
- value: form.token,
566
- autoComplete: "new-password",
567
- placeholder: tokenSaved ? "Leave blank to keep it" : "Personal access token",
568
- onChange: (event) => update({ token: event.target.value }),
569
- className: "text-base"
570
- })
571
- })
572
- ] }) : null,
820
+ ", readable only by you."
821
+ ] })]
822
+ }),
573
823
  /* @__PURE__ */ jsxs(SettingsActions, {
574
824
  className: "gap-4",
575
825
  children: [/* @__PURE__ */ jsx(Button, {
576
826
  variant: "primary",
577
- size: "sm",
578
827
  "data-testid": "git-auth-save",
579
828
  disabled: problem !== void 0 || saving,
580
829
  loading: saving,
581
- loadingLabel: "Saving",
582
- onClick: () => onSave(saveRequestOf(form)),
830
+ loadingLabel: "Saving...",
831
+ onClick: () => {
832
+ if (!saving && problem === void 0) onSave(saveRequestOf(form));
833
+ },
583
834
  children: "Save connection"
584
- }), problem !== void 0 ? /* @__PURE__ */ jsx(SettingsNote, {
585
- "data-testid": "git-auth-problem",
586
- className: "text-po-dim",
587
- children: problem
588
- }) : saveError !== void 0 ? /* @__PURE__ */ jsx(SettingsNote, {
589
- role: "alert",
590
- "data-testid": "git-auth-error",
591
- className: "text-po-red",
592
- children: saveError
593
- }) : savedNotice ? /* @__PURE__ */ jsx(SettingsNote, {
835
+ }), savedNotice && !edited && problem === void 0 && saveError === void 0 ? /* @__PURE__ */ jsx("span", {
594
836
  "data-testid": "git-auth-saved",
595
- className: "text-po-green",
837
+ className: "text-sm text-po-green",
596
838
  children: "Saved."
597
839
  }) : null]
598
840
  }),
599
- /* @__PURE__ */ jsxs(SettingsNote, {
600
- className: "flex items-start gap-2",
601
- children: [/* @__PURE__ */ jsx(ShieldIcon, {
602
- "aria-hidden": true,
603
- className: "mt-0.5 size-3.5 shrink-0"
604
- }), /* @__PURE__ */ jsx("span", { children: "Used only when you pull, push or rebase from this workspace's sessions in the cockpit, worktrees included. The agent's own git commands never see these credentials. Stored outside the repository in ~/.po/git/credentials.json, readable only by you, and never in the system keychain." })]
605
- })
841
+ problem !== void 0 ? /* @__PURE__ */ jsx("p", {
842
+ "data-testid": "git-auth-problem",
843
+ className: "text-sm text-po-red",
844
+ children: problem
845
+ }) : null,
846
+ saveError !== void 0 ? /* @__PURE__ */ jsx("p", {
847
+ role: "alert",
848
+ "data-testid": "git-auth-error",
849
+ className: "text-sm text-po-red",
850
+ children: saveError
851
+ }) : null
606
852
  ]
607
853
  });
608
854
  }
@@ -796,7 +1042,7 @@ const worktreeActivity = defineSessionStore({
796
1042
  errorTarget: void 0
797
1043
  });
798
1044
  /** Captures the clicked card, so a focus change cannot retarget an open dialog. */
799
- const worktreeCreateDialog = defineGlobalStore(null);
1045
+ const worktreeCreateDialog = defineHostStore(null);
800
1046
  /**
801
1047
  * The page's hub socket sender, held for as long as the plugin runs.
802
1048
  *
@@ -804,7 +1050,7 @@ const worktreeCreateDialog = defineGlobalStore(null);
804
1050
  * sent in that window is dropped rather than queued, because a queue would
805
1051
  * replay a worktree create against a socket that has since changed sessions.
806
1052
  */
807
- const worktreeSender = defineGlobalStore(void 0);
1053
+ const worktreeSender = defineHostStore(void 0);
808
1054
  /** Binds the page's hub socket. The plugin host calls this once per page. */
809
1055
  function startWorktreeRuntime(runtime) {
810
1056
  const send = (frame) => {
@@ -845,7 +1091,10 @@ function optionalText$1(value) {
845
1091
  }
846
1092
  function optionalErrorTarget$1(value) {
847
1093
  if (!isRecord$2(value)) return void 0;
848
- if (value.action === "create") return { action: "create" };
1094
+ if (value.action === "create") return value.riftMissing === true ? {
1095
+ action: "create",
1096
+ riftMissing: true
1097
+ } : { action: "create" };
849
1098
  if (value.action === "close" && typeof value.id === "string" && value.id !== "") return {
850
1099
  action: "close",
851
1100
  id: value.id
@@ -893,200 +1142,391 @@ function requestWorktreeClose(sessionId, id) {
893
1142
  });
894
1143
  }
895
1144
  //#endregion
896
- //#region src/extensions/workspaces/sessions/(frontend)/_components/WorktreesPanel.tsx
897
- /**
898
- * The '# git' group's tab: this session's worktrees, and the form that makes one.
899
- *
900
- * DESIGN PATTERNS:
901
- * - Lives in the activity dock, opened by the group's name. A worktree is work
902
- * in progress belonging to the session that started it, so it sits beside
903
- * agents, runners and workflows rather than in a settings screen.
904
- * - Header, form, then cards, the same rhythm the runners and workflows panels
905
- * use. A worktree row is a card because it carries three facts and two
906
- * actions, which a single line cannot hold without becoming a puzzle.
907
- * - Local form state is never reset by a data refresh. Direct lifecycle events
908
- * update the list without discarding a half-typed branch name.
909
- * - Acts through the plugin's own hub channel, so a worktree made here and one
910
- * made by the tool take exactly the same path.
911
- * - Creating waits on the cockpit starting a session, so the hub reports each
912
- * phase on that channel and the header shows it turning. A button that looks
913
- * idle for two minutes reads as broken.
914
- *
915
- * AVOID:
916
- * - Deriving form state from refreshed store data instead of the user's input.
917
- * - Colour classes outside the token set. `po-error`, `po-line` and
918
- * `po-bright` are not tokens: they compile to nothing and the row silently
919
- * loses its border.
920
- */
921
- const WORKTREES_TAB_ID = "git-worktrees";
922
- function worktreesTab() {
923
- return {
924
- id: WORKTREES_TAB_ID,
925
- label: "worktrees",
926
- panel: WorktreesPanel
927
- };
1145
+ //#region src/extensions/workspaces/sessions/(frontend)/fill/_components/WorktreeCreateDialog.tsx
1146
+ function WorktreeCreateOverlay(props) {
1147
+ const target = useStore(worktreeCreateDialog.store);
1148
+ const { holdSessionChannels } = props;
1149
+ useEffect(() => {
1150
+ if (target === null) return;
1151
+ return holdSessionChannels?.(target.sessionId, (frame) => {
1152
+ if (frame.type !== worktreesChannel.channel) return;
1153
+ const payload = worktreesChannel.parse(frame.payload);
1154
+ if (payload !== null) worktreesChannel.apply(target.sessionId, payload);
1155
+ });
1156
+ }, [target, holdSessionChannels]);
1157
+ if (target === null) return null;
1158
+ return /* @__PURE__ */ jsx(Dialog, {
1159
+ open: true,
1160
+ onOpenChange: (open) => {
1161
+ if (!open) worktreeCreateDialog.update(() => null);
1162
+ },
1163
+ children: /* @__PURE__ */ jsxs(DialogContent, {
1164
+ width: "md",
1165
+ className: "w-96 overflow-y-auto border-0",
1166
+ "data-testid": "session-worktree-dialog",
1167
+ "aria-describedby": void 0,
1168
+ children: [/* @__PURE__ */ jsx(DialogTitle, {
1169
+ className: "sr-only",
1170
+ children: "Create a worktree session"
1171
+ }), /* @__PURE__ */ createElement(WorktreeCreateForm, {
1172
+ ...props,
1173
+ key: `${target.sessionId}:${target.reservationId ?? ""}`,
1174
+ sessionId: target.sessionId,
1175
+ sessionReservationId: target.reservationId,
1176
+ onCancel: () => worktreeCreateDialog.update(() => null),
1177
+ onCreated: () => worktreeCreateDialog.update(() => null)
1178
+ })]
1179
+ })
1180
+ });
928
1181
  }
929
- function WorktreesPanel({ sessionId, sessionReservationId }) {
1182
+ function WorktreeCreateForm({ sessionId, sessionReservationId, onCancel, onRequested, onCreated }) {
930
1183
  const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, sessionId));
931
1184
  const [branch, setBranch] = useState("");
932
1185
  const [baseRef, setBaseRef] = useState("");
933
- const busy = session.pending !== void 0;
934
- const canCreate = sessionId !== null && branch.trim() !== "" && !busy;
935
- const createError = session.errorTarget?.action === "create" ? session.error : void 0;
936
- const closeErrorId = session.errorTarget?.action === "close" ? session.errorTarget.id : void 0;
937
- const panelError = session.error !== void 0 && (session.errorTarget === void 0 || closeErrorId !== void 0 && !session.worktrees.some((worktree) => worktree.id === closeErrorId));
938
- const create = () => {
939
- if (sessionId === null || !canCreate) return;
940
- requestWorktreeCreate(sessionId, branch, baseRef, sessionReservationId);
941
- if (sessionReservationId === void 0) {
942
- setBranch("");
943
- setBaseRef("");
1186
+ const sent = useRef(void 0);
1187
+ useEffect(() => {
1188
+ const request = sent.current;
1189
+ if (request === void 0) return;
1190
+ if (session.pending !== void 0) {
1191
+ request.sawPending = true;
1192
+ return;
944
1193
  }
945
- };
1194
+ if (!session.worktrees.some((worktree) => worktree.branch === request.branch) && !request.sawPending) return;
1195
+ sent.current = void 0;
1196
+ if (session.errorTarget?.action !== "create") onCreated?.();
1197
+ }, [
1198
+ session.pending,
1199
+ session.worktrees,
1200
+ session.errorTarget,
1201
+ onCreated
1202
+ ]);
1203
+ return /* @__PURE__ */ jsx(WorktreeCreateView, {
1204
+ branch,
1205
+ baseRef,
1206
+ onBranchChange: setBranch,
1207
+ onBaseChange: setBaseRef,
1208
+ busy: session.pending !== void 0,
1209
+ error: session.errorTarget?.action === "create" ? session.error : void 0,
1210
+ riftMissing: session.errorTarget?.action === "create" && session.errorTarget.riftMissing === true,
1211
+ onCancel,
1212
+ onCreate: () => {
1213
+ if (sessionId !== null) {
1214
+ sent.current = {
1215
+ branch: branch.trim(),
1216
+ sawPending: false
1217
+ };
1218
+ onRequested?.(branch.trim());
1219
+ requestWorktreeCreate(sessionId, branch, baseRef, sessionReservationId);
1220
+ }
1221
+ },
1222
+ disabled: sessionId === null
1223
+ });
1224
+ }
1225
+ function WorktreeCreateView({ branch, baseRef, onBranchChange, onBaseChange, busy = false, error, riftMissing = false, onCancel, onCreate, disabled = false }) {
1226
+ const id = useId();
946
1227
  return /* @__PURE__ */ jsxs("div", {
947
- "data-testid": "git-worktrees-panel",
948
- className: "flex min-h-0 flex-1 flex-col overflow-auto",
1228
+ className: "rounded-lg border border-po-border-soft bg-po-panel p-5 text-po-text shadow-sm",
949
1229
  children: [
950
- /* @__PURE__ */ jsxs("div", {
951
- className: "flex min-h-11 shrink-0 items-center gap-2.5 border-b border-po-border-soft px-3 sm:px-[26px]",
952
- children: [
953
- /* @__PURE__ */ jsx("span", {
954
- className: "text-lg font-semibold text-po-hi",
955
- children: "worktrees"
956
- }),
957
- /* @__PURE__ */ jsx("span", {
958
- "data-testid": "git-worktrees-count",
959
- className: "text-sm text-po-dim",
960
- children: session.worktrees.length === 0 ? "none yet" : `${String(session.worktrees.length)} open`
961
- }),
962
- /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }),
963
- session.pending === void 0 ? null : /* @__PURE__ */ jsxs("span", {
964
- "data-testid": "git-worktree-pending",
965
- className: "flex min-w-0 items-center gap-1.5",
966
- children: [/* @__PURE__ */ jsx(Spinner, {
967
- className: "h-3 w-3 shrink-0 text-po-faint",
968
- label: session.pending
969
- }), /* @__PURE__ */ jsx("span", {
970
- className: "min-w-0 truncate text-sm text-po-dim",
971
- children: session.pending
972
- })]
973
- })
974
- ]
1230
+ /* @__PURE__ */ jsx("h2", {
1231
+ id: `${id}-title`,
1232
+ className: "text-xl font-semibold text-po-hi",
1233
+ children: "Create a worktree session"
975
1234
  }),
976
- /* @__PURE__ */ jsxs("div", {
977
- className: "flex shrink-0 flex-col gap-1.5 border-b border-po-border-soft px-3 py-2.5 sm:px-[26px]",
1235
+ /* @__PURE__ */ jsx("p", {
1236
+ className: "mt-2 text-sm leading-relaxed text-po-dim",
1237
+ children: "Create a separate checkout and session without moving your existing sessions."
1238
+ }),
1239
+ /* @__PURE__ */ jsxs("form", {
1240
+ onSubmit: (event) => {
1241
+ event.preventDefault();
1242
+ if (!busy && !disabled && branch.trim()) onCreate?.();
1243
+ },
978
1244
  children: [/* @__PURE__ */ jsxs("div", {
979
- className: "flex items-center gap-2",
980
- children: [
981
- /* @__PURE__ */ jsx(Input, {
982
- "data-testid": "git-worktree-branch",
983
- "aria-label": "Branch",
1245
+ className: "mt-5 flex flex-col gap-4",
1246
+ children: [/* @__PURE__ */ jsxs("div", {
1247
+ className: "flex flex-col gap-2",
1248
+ children: [
1249
+ /* @__PURE__ */ jsx("label", {
1250
+ htmlFor: `${id}-branch`,
1251
+ className: "text-base font-medium",
1252
+ children: "Branch"
1253
+ }),
1254
+ /* @__PURE__ */ jsx(Input, {
1255
+ id: `${id}-branch`,
1256
+ "data-testid": "git-worktree-branch",
1257
+ className: "font-mono",
1258
+ placeholder: "wt/fix-auth",
1259
+ value: branch,
1260
+ onChange: (e) => onBranchChange?.(e.target.value),
1261
+ disabled: busy,
1262
+ "aria-invalid": !!error,
1263
+ "aria-describedby": error ? `${id}-error` : void 0
1264
+ }),
1265
+ riftMissing ? /* @__PURE__ */ jsxs("div", {
1266
+ "data-testid": "rift-install-notice",
1267
+ role: "alert",
1268
+ className: "flex flex-col gap-2 rounded-md border border-po-edge-magenta bg-po-tint-magenta px-3 py-3 text-sm text-po-hi",
1269
+ children: [/* @__PURE__ */ jsx("p", { children: "This repository uses Rift, and its CLI is not installed here. Run these in the repository root, then try again." }), /* @__PURE__ */ jsx(CodeBlock, {
1270
+ text: `${RIFT_INSTALL_COMMAND}
1271
+ rift init`,
1272
+ className: "language-bash"
1273
+ })]
1274
+ }) : error && /* @__PURE__ */ jsx("p", {
1275
+ id: `${id}-error`,
1276
+ role: "alert",
1277
+ "data-testid": "git-worktree-error",
1278
+ className: "text-sm text-po-red",
1279
+ children: error
1280
+ })
1281
+ ]
1282
+ }), /* @__PURE__ */ jsxs("div", {
1283
+ className: "flex flex-col gap-2",
1284
+ children: [/* @__PURE__ */ jsx("label", {
1285
+ htmlFor: `${id}-base`,
1286
+ className: "text-base font-medium",
1287
+ children: "Start from"
1288
+ }), /* @__PURE__ */ jsx(Input, {
984
1289
  size: "sm",
985
- className: "min-w-0 flex-1",
986
- placeholder: "wt/fix-auth",
987
- value: branch,
988
- onChange: (event) => setBranch(event.target.value),
989
- onKeyDown: (event) => {
990
- if (event.key === "Enter") create();
991
- }
992
- }),
993
- /* @__PURE__ */ jsx(Input, {
1290
+ id: `${id}-base`,
994
1291
  "data-testid": "git-worktree-base",
995
- "aria-label": "Base ref",
996
- size: "sm",
997
- placeholder: "base (current)",
1292
+ className: "font-mono",
1293
+ placeholder: "Current branch",
998
1294
  value: baseRef,
999
- onChange: (event) => setBaseRef(event.target.value),
1000
- className: "w-32 shrink-0"
1001
- }),
1002
- /* @__PURE__ */ jsx(Button, {
1003
- "data-testid": "git-worktree-create",
1004
- size: "sm",
1005
- disabled: !canCreate,
1006
- onClick: create,
1007
- children: "Create"
1008
- })
1009
- ]
1010
- }), createError === void 0 ? /* @__PURE__ */ jsx("p", {
1011
- className: "text-sm text-po-dim",
1012
- children: "Creates the worktree outside the repository and starts a session nested under this one."
1013
- }) : /* @__PURE__ */ jsx("p", {
1014
- role: "alert",
1015
- "data-testid": "git-worktree-error",
1016
- className: "text-sm text-po-red",
1017
- children: createError
1295
+ onChange: (e) => onBaseChange?.(e.target.value),
1296
+ disabled: busy
1297
+ })]
1298
+ })]
1299
+ }), /* @__PURE__ */ jsxs("footer", {
1300
+ className: "mt-5 flex items-center justify-end gap-2 border-t border-po-border-soft pt-4",
1301
+ children: [/* @__PURE__ */ jsx(Button, {
1302
+ type: "button",
1303
+ variant: "ghost",
1304
+ disabled: busy,
1305
+ onClick: onCancel,
1306
+ children: "Cancel"
1307
+ }), /* @__PURE__ */ jsxs(Button, {
1308
+ type: "submit",
1309
+ variant: "primary",
1310
+ "data-testid": "git-worktree-create",
1311
+ disabled: busy || disabled || !branch.trim(),
1312
+ children: [busy && /* @__PURE__ */ jsx(Spinner, {
1313
+ className: "size-3",
1314
+ label: "Creating worktree"
1315
+ }), busy ? "Creating worktree..." : riftMissing ? "Try again" : "Create worktree"]
1316
+ })]
1317
+ })]
1318
+ })
1319
+ ]
1320
+ });
1321
+ }
1322
+ //#endregion
1323
+ //#region src/extensions/workspaces/sessions/(frontend)/_components/WorktreesPanel.tsx
1324
+ function worktreesTab() {
1325
+ return {
1326
+ id: "git-worktrees",
1327
+ label: "worktrees",
1328
+ panel: WorktreesPanel
1329
+ };
1330
+ }
1331
+ function WorktreesPanel(props) {
1332
+ const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, props.sessionId));
1333
+ const [creating, setCreating] = useState(session.errorTarget?.action === "create");
1334
+ const [requestedBranch, setRequestedBranch] = useState();
1335
+ const sawPending = useRef(false);
1336
+ useEffect(() => {
1337
+ if (!requestedBranch) return;
1338
+ if (session.worktrees.some((w) => w.branch === requestedBranch) || sawPending.current && session.pending === void 0) setRequestedBranch(void 0);
1339
+ else if (session.pending !== void 0) sawPending.current = true;
1340
+ }, [
1341
+ requestedBranch,
1342
+ session.pending,
1343
+ session.worktrees
1344
+ ]);
1345
+ return /* @__PURE__ */ jsx("div", {
1346
+ className: "min-h-0 flex-1 overflow-auto",
1347
+ children: /* @__PURE__ */ jsx(WorktreesPanelView, {
1348
+ worktrees: session.worktrees,
1349
+ pending: session.pending,
1350
+ startingBranch: session.pending === void 0 || session.worktrees.some((w) => w.branch === requestedBranch) ? void 0 : requestedBranch,
1351
+ error: session.errorTarget?.action === "create" && creating ? void 0 : session.error,
1352
+ closeErrorId: session.errorTarget?.action === "close" ? session.errorTarget.id : void 0,
1353
+ onNew: () => setCreating(true),
1354
+ onClose: props.sessionId === null ? void 0 : (id) => requestWorktreeClose(props.sessionId, id),
1355
+ form: creating ? /* @__PURE__ */ jsx(WorktreeCreateForm, {
1356
+ ...props,
1357
+ onCancel: () => setCreating(false),
1358
+ onCreated: () => setCreating(false),
1359
+ onRequested: (branch) => {
1360
+ sawPending.current = false;
1361
+ setRequestedBranch(branch);
1362
+ }
1363
+ }) : void 0
1364
+ })
1365
+ });
1366
+ }
1367
+ function WorktreesPanelView({ worktrees, pending, error, closeErrorId, onNew, onClose, form, startingIds = [], startingBranch }) {
1368
+ const groups = [worktrees.filter((w) => !w.orphaned && !w.unowned), worktrees.filter((w) => w.orphaned || w.unowned)];
1369
+ return /* @__PURE__ */ jsxs("div", {
1370
+ "data-testid": "git-worktrees-panel",
1371
+ className: "rounded-lg border border-po-border-soft bg-po-panel p-5",
1372
+ children: [
1373
+ /* @__PURE__ */ jsxs("header", {
1374
+ className: "flex items-center justify-between gap-4 border-b border-po-border-soft pb-4",
1375
+ children: [
1376
+ /* @__PURE__ */ jsx("h2", {
1377
+ className: "text-lg font-semibold text-po-hi",
1378
+ children: "Worktrees"
1379
+ }),
1380
+ /* @__PURE__ */ jsx("span", {
1381
+ "data-testid": "git-worktrees-count",
1382
+ className: "sr-only",
1383
+ children: worktrees.length === 0 ? "none yet" : `${worktrees.length} open`
1384
+ }),
1385
+ /* @__PURE__ */ jsx(Button, {
1386
+ variant: "outline",
1387
+ size: "sm",
1388
+ onClick: onNew,
1389
+ children: "New worktree"
1390
+ })
1391
+ ]
1392
+ }),
1393
+ form,
1394
+ pending && !startingBranch && /* @__PURE__ */ jsxs("p", {
1395
+ "data-testid": "git-worktree-pending",
1396
+ className: "flex items-center gap-2 pt-3 text-sm text-po-dim",
1397
+ children: [/* @__PURE__ */ jsx(Spinner, {
1398
+ className: "size-3",
1399
+ label: pending
1400
+ }), /* @__PURE__ */ jsx("span", {
1401
+ className: "inline-block first-letter:uppercase",
1402
+ children: pending
1018
1403
  })]
1019
1404
  }),
1020
- panelError ? /* @__PURE__ */ jsx("p", {
1405
+ error && (!closeErrorId || !worktrees.some((w) => w.id === closeErrorId)) && /* @__PURE__ */ jsx("p", {
1021
1406
  role: "alert",
1022
1407
  "data-testid": "git-worktree-error",
1023
- className: "px-3 pt-2 text-sm text-po-red sm:px-[26px]",
1024
- children: session.error
1025
- }) : null,
1026
- session.worktrees.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
1408
+ className: "text-sm text-po-red",
1409
+ children: error
1410
+ }),
1411
+ worktrees.length === 0 && !startingBranch ? /* @__PURE__ */ jsx(EmptyState, {
1027
1412
  "data-testid": "git-worktrees-empty",
1028
- className: "px-4 py-8",
1029
- title: "no worktrees yet",
1030
- description: "a worktree is its own checkout on its own branch, with its own session nested under this one."
1031
- }) : /* @__PURE__ */ jsx("ul", {
1413
+ className: "py-10",
1414
+ title: "No worktrees yet",
1415
+ description: "A worktree gives a branch its own checkout and a session nested under this one."
1416
+ }) : /* @__PURE__ */ jsx("div", {
1032
1417
  "data-testid": "git-worktrees-list",
1033
- className: "flex flex-col gap-2.5 px-3 py-3 sm:px-[26px]",
1034
- children: session.worktrees.map((worktree) => /* @__PURE__ */ jsx(WorktreeCard, {
1035
- worktree,
1036
- sessionId,
1037
- busy,
1038
- error: closeErrorId === worktree.id ? session.error : void 0
1039
- }, worktree.id))
1418
+ children: groups.map((group, i) => (group.length > 0 || i === 0 && startingBranch) && /* @__PURE__ */ jsxs("section", { children: [
1419
+ /* @__PURE__ */ jsxs("h3", {
1420
+ className: "flex items-center gap-2 pt-5 text-lg font-semibold text-po-hi",
1421
+ children: [
1422
+ i === 0 ? "Working" : "Needs a look",
1423
+ " ",
1424
+ /* @__PURE__ */ jsxs("span", {
1425
+ className: "text-sm font-normal text-po-dim",
1426
+ children: [group.length + (i === 0 && startingBranch ? 1 : 0), " open"]
1427
+ })
1428
+ ]
1429
+ }),
1430
+ i === 1 && /* @__PURE__ */ jsxs("p", {
1431
+ className: "pt-2 text-sm leading-relaxed text-po-dim",
1432
+ children: [
1433
+ group.length === 2 ? "Two worktrees" : group.length === 1 ? "One worktree" : `${group.length} worktrees`,
1434
+ " ",
1435
+ "would like your eye, whenever you are ready."
1436
+ ]
1437
+ }),
1438
+ i === 0 && startingBranch && /* @__PURE__ */ jsxs("div", {
1439
+ "data-testid": "git-worktree-starting",
1440
+ className: "flex min-w-0 flex-col gap-2 border-b border-po-border-soft py-4",
1441
+ children: [/* @__PURE__ */ jsxs("div", {
1442
+ className: "flex min-w-0 items-center gap-2",
1443
+ children: [/* @__PURE__ */ jsx(Spinner, {
1444
+ className: "size-3 shrink-0 text-po-dim",
1445
+ label: "Starting session"
1446
+ }), /* @__PURE__ */ jsx("span", {
1447
+ className: "min-w-0 flex-1 truncate font-mono text-base font-medium text-po-hi",
1448
+ children: startingBranch
1449
+ })]
1450
+ }), /* @__PURE__ */ jsx("p", {
1451
+ className: "pl-4 text-sm text-po-dim",
1452
+ children: "Starting session..."
1453
+ })]
1454
+ }),
1455
+ group.map((w) => /* @__PURE__ */ jsx(WorktreeRow, {
1456
+ worktree: w,
1457
+ starting: startingIds.includes(w.id) || !!pending?.includes("starting") && w.sessionId === null && !w.orphaned && !w.unowned,
1458
+ disabled: !!pending || !onClose,
1459
+ onClose: () => onClose?.(w.id),
1460
+ error: closeErrorId === w.id ? error : void 0
1461
+ }, w.id))
1462
+ ] }, i))
1040
1463
  })
1041
1464
  ]
1042
1465
  });
1043
1466
  }
1044
- /** One worktree: what it is, where it is, and the one thing you can do to it. */
1045
- function WorktreeCard({ worktree, sessionId, busy, error }) {
1046
- return /* @__PURE__ */ jsxs("li", {
1467
+ function WorktreeBadge({ worktree }) {
1468
+ if (worktree.orphaned) return /* @__PURE__ */ jsx(StatusBadge, {
1469
+ tone: "neutral",
1470
+ size: "xs",
1471
+ className: "bg-po-tint-yellow text-po-yellow",
1472
+ children: "Orphaned"
1473
+ });
1474
+ if (worktree.unowned) return /* @__PURE__ */ jsx(StatusBadge, {
1475
+ tone: "info",
1476
+ size: "xs",
1477
+ children: "Unowned"
1478
+ });
1479
+ return null;
1480
+ }
1481
+ function WorktreeRow({ worktree, compact = false, starting = false, error, disabled = false, onClose }) {
1482
+ return /* @__PURE__ */ jsxs("div", {
1047
1483
  "data-testid": `git-worktree-${worktree.id}`,
1048
- className: "flex min-w-0 flex-col gap-1.5 rounded-md border border-po-border-soft bg-po-panel p-2.5",
1484
+ className: compact ? "flex min-w-0 flex-col gap-1 py-2" : "flex min-w-0 flex-col gap-2 border-b border-po-border-soft py-4",
1049
1485
  children: [
1050
1486
  /* @__PURE__ */ jsxs("div", {
1051
- className: "flex min-w-0 items-center gap-1.5",
1487
+ className: "flex min-w-0 items-center gap-2",
1052
1488
  children: [
1053
- /* @__PURE__ */ jsx(Dot, { tone: worktree.orphaned ? "red" : worktree.sessionId === null ? "muted" : "blue" }),
1489
+ starting ? /* @__PURE__ */ jsx(Spinner, {
1490
+ className: "size-3 shrink-0 text-po-dim",
1491
+ label: "Starting session"
1492
+ }) : /* @__PURE__ */ jsx(Dot, {
1493
+ size: "md",
1494
+ tone: worktree.orphaned ? "yellow" : worktree.unowned ? "blue" : "green"
1495
+ }),
1054
1496
  /* @__PURE__ */ jsx("span", {
1055
- className: "min-w-0 flex-1 truncate text-base font-semibold text-po-hi",
1497
+ title: worktree.branch,
1498
+ className: "min-w-0 flex-1 truncate font-mono text-base font-medium text-po-hi",
1056
1499
  children: worktree.branch
1057
1500
  }),
1058
- worktree.orphaned ? /* @__PURE__ */ jsx(StatusBadge, {
1059
- tone: "error",
1060
- size: "xs",
1061
- children: "orphaned"
1062
- }) : null,
1063
- worktree.unowned ? /* @__PURE__ */ jsx(StatusBadge, {
1064
- tone: "info",
1065
- size: "xs",
1066
- children: "unowned"
1067
- }) : null
1501
+ /* @__PURE__ */ jsx(WorktreeBadge, { worktree }),
1502
+ !compact && /* @__PURE__ */ jsx(Button, {
1503
+ variant: "ghost",
1504
+ size: "sm",
1505
+ onClick: onClose,
1506
+ disabled: starting || disabled,
1507
+ "data-testid": `git-worktree-close-${worktree.id}`,
1508
+ "aria-label": `Close ${worktree.branch}`,
1509
+ children: "Close"
1510
+ })
1068
1511
  ]
1069
1512
  }),
1070
- /* @__PURE__ */ jsx("span", {
1071
- className: "min-w-0 truncate text-sm text-po-dim",
1513
+ !compact && /* @__PURE__ */ jsx("p", {
1514
+ className: "truncate pl-4 font-mono text-sm text-po-dim",
1515
+ title: worktree.path,
1072
1516
  children: worktree.path
1073
1517
  }),
1074
- /* @__PURE__ */ jsxs("div", {
1075
- className: "flex items-center gap-1.5 pt-0.5",
1076
- children: [/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }), sessionId === null ? null : /* @__PURE__ */ jsx(Button, {
1077
- variant: "danger-outline",
1078
- size: "xs",
1079
- disabled: busy,
1080
- "data-testid": `git-worktree-close-${worktree.id}`,
1081
- className: "px-2 ",
1082
- onClick: () => requestWorktreeClose(sessionId, worktree.id),
1083
- children: "close"
1084
- })]
1518
+ starting && /* @__PURE__ */ jsx("p", {
1519
+ className: "pl-4 text-sm text-po-dim",
1520
+ children: "Starting session..."
1521
+ }),
1522
+ !compact && (worktree.orphaned || worktree.unowned) && /* @__PURE__ */ jsx("p", {
1523
+ className: "pl-4 text-sm text-po-dim first-letter:uppercase",
1524
+ children: worktree.orphaned ? "its folder is missing" : "its session has ended"
1085
1525
  }),
1086
- error === void 0 ? null : /* @__PURE__ */ jsx("p", {
1526
+ error && /* @__PURE__ */ jsx("p", {
1087
1527
  role: "alert",
1088
1528
  "data-testid": "git-worktree-error",
1089
- className: "text-sm text-po-red",
1529
+ className: "pl-4 text-sm text-po-red",
1090
1530
  children: error
1091
1531
  })
1092
1532
  ]
@@ -1136,7 +1576,7 @@ const gitChanges = defineSessionStore({
1136
1576
  errorTarget: void 0
1137
1577
  });
1138
1578
  /** The page's hub socket sender; undefined before start and after dispose, when a command is dropped. */
1139
- const changesSender = defineGlobalStore(void 0);
1579
+ const changesSender = defineHostStore(void 0);
1140
1580
  /** Binds the page's hub socket for sync commands. The plugin host calls this once per page. */
1141
1581
  function startGitChangesRuntime(runtime) {
1142
1582
  const send = (frame) => {
@@ -1264,56 +1704,6 @@ var gitChanges_web_default = defineChannelFile(gitChangesChannel);
1264
1704
  //#region src/extensions/workspaces/sessions/(frontend)/channel/gitWorktrees.web.ts
1265
1705
  var gitWorktrees_web_default = defineChannelFile(worktreesChannel);
1266
1706
  //#endregion
1267
- //#region src/extensions/workspaces/sessions/(frontend)/fill/_components/WorktreeCreateDialog.tsx
1268
- function WorktreeSessionMenu({ sessionId, sessionReservationId }) {
1269
- return /* @__PURE__ */ jsx(DropdownMenuItem, {
1270
- disabled: sessionId === null,
1271
- "data-testid": `session-worktree-${sessionReservationId ?? sessionId}`,
1272
- onSelect: () => {
1273
- if (sessionId !== null) worktreeCreateDialog.update(() => ({
1274
- sessionId,
1275
- ...sessionReservationId === void 0 ? {} : { reservationId: sessionReservationId }
1276
- }));
1277
- },
1278
- children: "create worktree session…"
1279
- });
1280
- }
1281
- function WorktreeCreateOverlay(props) {
1282
- const target = useStore(worktreeCreateDialog.store);
1283
- const { holdSessionChannels } = props;
1284
- useEffect(() => {
1285
- if (target === null) return;
1286
- return holdSessionChannels?.(target.sessionId, (frame) => {
1287
- if (frame.type !== worktreesChannel.channel) return;
1288
- const payload = worktreesChannel.parse(frame.payload);
1289
- if (payload !== null) worktreesChannel.apply(target.sessionId, payload);
1290
- });
1291
- }, [target, holdSessionChannels]);
1292
- if (target === null) return null;
1293
- return /* @__PURE__ */ jsx(Dialog, {
1294
- open: true,
1295
- onOpenChange: (open) => {
1296
- if (!open) worktreeCreateDialog.update(() => null);
1297
- },
1298
- children: /* @__PURE__ */ jsxs(DialogContent, {
1299
- width: "lg",
1300
- "data-testid": "session-worktree-dialog",
1301
- children: [/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "create worktree session" }) }), /* @__PURE__ */ jsxs(DialogBody, { children: [/* @__PURE__ */ jsx(DialogDescription, { children: "Creates a separate checkout and a new session. Existing sessions stay in their current directories." }), /* @__PURE__ */ createElement(WorktreesPanel, {
1302
- ...props,
1303
- key: `${target.sessionId}:${target.reservationId ?? ""}`,
1304
- sessionId: target.sessionId,
1305
- sessionReservationId: target.reservationId
1306
- })] })]
1307
- })
1308
- });
1309
- }
1310
- //#endregion
1311
- //#region src/extensions/workspaces/sessions/(frontend)/fill/Worktree.session-menu.web.tsx
1312
- var Worktree_session_menu_web_default = defineFill({ component: WorktreeSessionMenu });
1313
- //#endregion
1314
- //#region src/extensions/workspaces/sessions/(frontend)/fill/WorktreeCreate.overlay.web.tsx
1315
- var WorktreeCreate_overlay_web_default = defineFill({ component: WorktreeCreateOverlay });
1316
- //#endregion
1317
1707
  //#region src/extensions/workspaces/sessions/(frontend)/_lib/gitReviewApi.ts
1318
1708
  /**
1319
1709
  * The review tab's half of the session API: the changed-file list and one
@@ -1370,16 +1760,34 @@ async function fetchReviewFile(sessionId, path, signal) {
1370
1760
  const gitReview = defineSessionStore({ comments: [] });
1371
1761
  function addReviewComment(sessionId, comment) {
1372
1762
  const id = globalThis.crypto.randomUUID();
1373
- gitReview.update(sessionId, (current) => ({ comments: [...current.comments, {
1374
- ...comment,
1375
- id
1376
- }] }));
1763
+ gitReview.update(sessionId, (current) => ({
1764
+ ...current,
1765
+ comments: [...current.comments, {
1766
+ ...comment,
1767
+ id
1768
+ }]
1769
+ }));
1377
1770
  }
1378
1771
  function removeReviewComment(sessionId, id) {
1379
- gitReview.update(sessionId, (current) => ({ comments: current.comments.filter((comment) => comment.id !== id) }));
1772
+ gitReview.update(sessionId, (current) => ({
1773
+ ...current,
1774
+ comments: current.comments.filter((comment) => comment.id !== id)
1775
+ }));
1380
1776
  }
1381
1777
  function clearReviewComments(sessionId) {
1382
- gitReview.update(sessionId, () => ({ comments: [] }));
1778
+ gitReview.update(sessionId, (current) => ({
1779
+ ...current,
1780
+ comments: []
1781
+ }));
1782
+ }
1783
+ function focusReviewFile(sessionId, path) {
1784
+ gitReview.update(sessionId, (current) => ({
1785
+ ...current,
1786
+ focus: {
1787
+ path,
1788
+ at: Date.now()
1789
+ }
1790
+ }));
1383
1791
  }
1384
1792
  //#endregion
1385
1793
  //#region src/extensions/workspaces/sessions/(frontend)/_lib/gitReviewView.ts
@@ -1411,6 +1819,23 @@ function conflictPrompt(branch, conflicts) {
1411
1819
  ].join("\n");
1412
1820
  }
1413
1821
  /**
1822
+ * The one sync the bar fills in: pull while the branch is behind (a push would
1823
+ * be rejected), push while it is only ahead or has no upstream yet. Nothing
1824
+ * while a rebase is paused, detached, or already level.
1825
+ */
1826
+ function suggestedSyncAction(changes) {
1827
+ if (changes?.branch === void 0 || changes.rebase !== void 0) return void 0;
1828
+ if (changes.upstream === void 0) return "push";
1829
+ if (changes.upstream.behind > 0) return "pull";
1830
+ return changes.upstream.ahead > 0 ? "push" : void 0;
1831
+ }
1832
+ /** "2 to push, 1 new on origin/feat/git", or "Up to date with origin/feat/git". */
1833
+ function upstreamSummary(upstream) {
1834
+ if (upstream === void 0) return "No upstream yet";
1835
+ const parts = [...upstream.ahead > 0 ? [`${String(upstream.ahead)} to push`] : [], ...upstream.behind > 0 ? [`${String(upstream.behind)} new on ${upstream.ref}`] : []];
1836
+ return parts.length === 0 ? `Up to date with ${upstream.ref}` : parts.join(", ");
1837
+ }
1838
+ /**
1414
1839
  * Hands one deferred follow-up to the session. Returns the reason it failed,
1415
1840
  * or undefined once sent. The sender throws when the session is disconnected.
1416
1841
  */
@@ -1426,485 +1851,302 @@ function deliverToAgent(send, sessionId, message) {
1426
1851
  }
1427
1852
  }
1428
1853
  //#endregion
1429
- //#region src/extensions/workspaces/sessions/(frontend)/_lib/gitReviewTree.ts
1430
- function buildTree(files) {
1431
- const root = {
1432
- path: "",
1433
- dirs: /* @__PURE__ */ new Map(),
1434
- files: []
1435
- };
1436
- for (const file of files) {
1437
- const parts = file.path.split("/");
1438
- parts.pop();
1439
- let dir = root;
1440
- for (const part of parts) {
1441
- let next = dir.dirs.get(part);
1442
- if (next === void 0) {
1443
- next = {
1444
- path: dir.path === "" ? part : `${dir.path}/${part}`,
1445
- dirs: /* @__PURE__ */ new Map(),
1446
- files: []
1447
- };
1448
- dir.dirs.set(part, next);
1449
- }
1450
- dir = next;
1451
- }
1452
- dir.files.push(file);
1453
- }
1454
- return root;
1455
- }
1456
- /** Folders first, then files, each alphabetical; single-child folder chains render as one row. */
1457
- function flattenTree(files, isOpen) {
1458
- const rows = [];
1459
- const walk = (dir, depth) => {
1460
- for (const [segment, child] of [...dir.dirs].sort(([left], [right]) => left.localeCompare(right))) {
1461
- let name = segment;
1462
- let node = child;
1463
- while (node.files.length === 0 && node.dirs.size === 1) {
1464
- const [[nextName, next]] = [...node.dirs];
1465
- name = `${name}/${nextName}`;
1466
- node = next;
1467
- }
1468
- const open = isOpen(node.path);
1469
- rows.push({
1470
- kind: "dir",
1471
- path: node.path,
1472
- name,
1473
- depth,
1474
- open
1475
- });
1476
- if (open) walk(node, depth + 1);
1477
- }
1478
- for (const file of [...dir.files].sort((left, right) => left.path.localeCompare(right.path))) rows.push({
1479
- kind: "file",
1480
- file,
1481
- depth
1482
- });
1483
- };
1484
- walk(buildTree(files), 0);
1485
- return rows;
1486
- }
1487
- //#endregion
1488
1854
  //#region src/extensions/workspaces/sessions/(frontend)/_components/GitReviewBrowser.tsx
1489
- /**
1490
- * The review tab's file list: every changed file as a folder tree (the VS Code
1491
- * explorer shape), with its status, its line counts and its comments.
1492
- *
1493
- * DESIGN PATTERNS:
1494
- * - Picking a row scrolls the diff pane to that file; the list never opens a
1495
- * tab of its own. One tab holds the whole review.
1496
- * - Rows show only the file name, so a long path never truncates away the part
1497
- * that tells files apart. Folders say the rest; the full path is the tooltip.
1498
- * - Folder chains with a single child collapse into one row (`src/web/lib`),
1499
- * like VS Code's compact folders, so deep trees stay shallow.
1500
- * - Folders fold on click; a search shows every match with its folders open.
1501
- * - Each row is a button, reachable with Tab; arrow keys move and pick in one
1502
- * step across the visible files, so the diff follows the cursor.
1503
- *
1504
- * AVOID:
1505
- * - Colour classes outside the token set.
1506
- */
1507
- const STATUS_MARK = {
1508
- added: {
1509
- letter: "A",
1510
- tone: "text-po-green",
1511
- label: "added"
1512
- },
1513
- modified: {
1514
- letter: "M",
1515
- tone: "text-po-yellow",
1516
- label: "modified"
1517
- },
1518
- deleted: {
1519
- letter: "D",
1520
- tone: "text-po-red",
1521
- label: "deleted"
1522
- },
1523
- untracked: {
1524
- letter: "U",
1525
- tone: "text-po-blue",
1526
- label: "untracked"
1527
- },
1528
- conflicted: {
1529
- letter: "C",
1530
- tone: "text-po-red",
1531
- label: "conflicted"
1532
- }
1855
+ const status = {
1856
+ added: [
1857
+ "A",
1858
+ "text-po-green",
1859
+ "Added"
1860
+ ],
1861
+ modified: [
1862
+ "M",
1863
+ "text-po-yellow",
1864
+ "Modified"
1865
+ ],
1866
+ deleted: [
1867
+ "D",
1868
+ "text-po-red",
1869
+ "Deleted"
1870
+ ],
1871
+ untracked: [
1872
+ "U",
1873
+ "text-po-blue",
1874
+ "Untracked"
1875
+ ],
1876
+ conflicted: [
1877
+ "C",
1878
+ "text-po-red",
1879
+ "Conflicted"
1880
+ ]
1533
1881
  };
1534
- const baseName = (path) => path.slice(path.lastIndexOf("/") + 1);
1535
- /** Left padding per depth level; tight so deep files keep room for their names. */
1536
- const indent = (depth) => ({ paddingLeft: `${String(.75 + depth * .5)}rem` });
1537
1882
  function GitReviewBrowser({ files, activePath, commentCounts, onPick }) {
1538
1883
  const [query, setQuery] = useState("");
1539
- const [collapsed, setCollapsed] = useState(/* @__PURE__ */ new Set());
1540
- const needle = query.trim().toLocaleLowerCase();
1541
- const shown = needle === "" ? files : files.filter((file) => file.path.toLocaleLowerCase().includes(needle));
1542
- const rows = flattenTree(shown, (dirPath) => needle !== "" || !collapsed.has(dirPath));
1543
- const ordered = rows.flatMap((row) => row.kind === "file" ? [row.file] : []);
1884
+ const shown = files.filter((f) => f.path.toLowerCase().includes(query.trim().toLowerCase()));
1544
1885
  const listRef = useRef(null);
1545
1886
  useEffect(() => {
1546
1887
  if (activePath === void 0) return;
1547
- (listRef.current?.querySelector(`[data-path="${CSS.escape(activePath)}"]`))?.scrollIntoView({ block: "nearest" });
1888
+ listRef.current?.querySelector(`[data-path="${CSS.escape(activePath)}"]`)?.scrollIntoView({ block: "nearest" });
1548
1889
  }, [activePath]);
1549
- const toggle = (dirPath) => {
1550
- setCollapsed((prev) => {
1551
- const next = new Set(prev);
1552
- if (!next.delete(dirPath)) next.add(dirPath);
1553
- return next;
1554
- });
1555
- };
1556
- const allDirs = () => new Set(flattenTree(files, () => true).flatMap((row) => row.kind === "dir" ? [row.path] : []));
1557
1890
  /** Arrow keys pick the neighbouring row and move focus with it, so the diff follows the cursor. */
1558
1891
  const onKeyDown = (event) => {
1559
1892
  if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
1560
- if (ordered.length === 0) return;
1893
+ if (shown.length === 0) return;
1561
1894
  event.preventDefault();
1562
- const current = ordered.findIndex((file) => file.path === activePath);
1895
+ const current = shown.findIndex((file) => file.path === activePath);
1563
1896
  const step = event.key === "ArrowDown" ? 1 : -1;
1564
- const next = current === -1 ? 0 : (current + step + ordered.length) % ordered.length;
1565
- const file = ordered[next];
1897
+ const next = current === -1 ? 0 : (current + step + shown.length) % shown.length;
1898
+ const file = shown[next];
1566
1899
  if (file === void 0) return;
1567
1900
  onPick(file.path);
1568
1901
  event.currentTarget.closest("[data-git-review-list]")?.querySelectorAll("[data-git-review-row]")[next]?.focus();
1569
1902
  };
1570
1903
  return /* @__PURE__ */ jsxs("nav", {
1904
+ "aria-label": "Changed files",
1571
1905
  "data-testid": "git-review-browser",
1572
- "aria-label": "changed files",
1573
- className: "flex min-h-0 w-64 shrink-0 flex-col border-r border-po-border-soft",
1906
+ className: "flex min-h-0 w-80 shrink-0 flex-col border-r border-po-border-soft",
1574
1907
  children: [/* @__PURE__ */ jsxs("div", {
1575
- className: "flex shrink-0 flex-col gap-1 px-3 pt-2.5 pb-1.5",
1908
+ className: "flex flex-col gap-3 border-b border-po-border-soft p-3",
1576
1909
  children: [/* @__PURE__ */ jsx(Input, {
1577
1910
  "data-testid": "git-review-search",
1578
- "aria-label": "search changed file paths",
1579
1911
  size: "sm",
1912
+ "aria-label": "Search paths",
1913
+ placeholder: "Search paths",
1580
1914
  value: query,
1581
- placeholder: "search paths…",
1582
- onChange: (event) => setQuery(event.target.value)
1583
- }), /* @__PURE__ */ jsxs("div", {
1584
- className: "flex items-center justify-between gap-2",
1585
- children: [/* @__PURE__ */ jsx("span", {
1586
- className: "text-sm text-po-dim",
1587
- children: needle === "" ? `${String(files.length)} changed` : `${String(shown.length)} of ${String(files.length)} match`
1588
- }), needle === "" ? /* @__PURE__ */ jsx(Button, {
1589
- variant: "link",
1590
- size: "xs",
1591
- "data-testid": "git-review-fold-all",
1592
- className: "h-auto px-0",
1593
- onClick: () => setCollapsed(collapsed.size === 0 ? allDirs() : /* @__PURE__ */ new Set()),
1594
- children: collapsed.size === 0 ? "collapse all" : "expand all"
1595
- }) : null]
1915
+ onChange: (e) => setQuery(e.target.value)
1916
+ }), /* @__PURE__ */ jsxs("span", {
1917
+ className: "text-sm text-po-dim",
1918
+ children: [shown.length, " changed"]
1596
1919
  })]
1597
1920
  }), /* @__PURE__ */ jsxs("div", {
1598
1921
  ref: listRef,
1599
1922
  "data-git-review-list": true,
1600
- className: "min-h-0 flex-1 overflow-y-auto pb-2",
1601
- children: [rows.map((row) => {
1602
- if (row.kind === "dir") {
1603
- const Chevron = row.open ? ChevronDownIcon : ChevronRightIcon;
1604
- return /* @__PURE__ */ jsxs(Button, {
1605
- variant: "ghost",
1606
- size: "card",
1607
- "aria-expanded": row.open,
1608
- "data-testid": `git-review-browser-dir-${row.path}`,
1609
- title: row.path,
1610
- onClick: () => toggle(row.path),
1611
- style: indent(row.depth),
1612
- className: "min-w-0 flex-row items-center gap-1 rounded-none border-l-2 border-transparent py-1 pr-3 hover:bg-po-panel/60",
1613
- children: [/* @__PURE__ */ jsx(Chevron, {
1614
- "aria-hidden": true,
1615
- className: "h-3 w-3 shrink-0 text-po-faint"
1616
- }), /* @__PURE__ */ jsx("span", {
1617
- className: "min-w-0 flex-1 truncate text-base text-po-dim",
1618
- children: row.name
1619
- })]
1620
- }, `dir:${row.path}`);
1621
- }
1622
- const { file } = row;
1623
- const mark = STATUS_MARK[file.status];
1624
- const comments = commentCounts[file.path] ?? 0;
1625
- const active = file.path === activePath;
1626
- return /* @__PURE__ */ jsxs(Button, {
1627
- variant: "ghost",
1628
- size: "card",
1923
+ className: "min-h-0 flex-1 overflow-y-auto",
1924
+ children: [shown.map((f) => {
1925
+ const slash = f.path.lastIndexOf("/");
1926
+ const count = commentCounts[f.path] ?? 0;
1927
+ return /* @__PURE__ */ jsxs("button", {
1629
1928
  "data-git-review-row": true,
1630
- "data-path": file.path,
1631
- "aria-current": active ? "true" : void 0,
1632
- "data-testid": `git-review-browser-file-${file.path}`,
1633
- title: `${file.path} (${mark.label})`,
1634
- onClick: () => onPick(file.path),
1929
+ "data-path": f.path,
1930
+ "data-testid": `git-review-browser-file-${f.path}`,
1635
1931
  onKeyDown,
1636
- style: indent(row.depth),
1637
- className: `min-w-0 flex-row items-center gap-1.5 rounded-none border-l-2 py-1 pr-3 ${active ? "border-po-blue bg-po-panel" : "border-transparent hover:bg-po-panel/60"}`,
1932
+ title: f.path,
1933
+ "aria-current": activePath === f.path ? "true" : void 0,
1934
+ onClick: () => onPick(f.path),
1935
+ className: `flex w-full min-w-0 items-start gap-2 border-l-2 px-3 py-3 text-left ${activePath === f.path ? "border-po-green bg-po-tint-green" : "border-transparent hover:bg-po-panel"}`,
1638
1936
  children: [
1639
1937
  /* @__PURE__ */ jsx("span", {
1640
- "aria-label": mark.label,
1641
- className: `w-3 shrink-0 text-center text-sm font-semibold ${mark.tone}`,
1642
- children: mark.letter
1643
- }),
1644
- /* @__PURE__ */ jsx("span", {
1645
- className: `min-w-0 flex-1 truncate text-base text-po-hi ${active ? "font-semibold" : ""} ${file.status === "deleted" ? "line-through opacity-70" : ""}`,
1646
- children: baseName(file.path)
1938
+ className: `pt-0.5 text-sm font-semibold ${status[f.status][1]}`,
1939
+ children: status[f.status][0]
1647
1940
  }),
1648
- comments === 0 ? null : /* @__PURE__ */ jsxs("span", {
1649
- className: "flex shrink-0 items-center gap-0.5 text-sm text-po-blue",
1650
- title: `${String(comments)} comments`,
1651
- children: [/* @__PURE__ */ jsx(MessageIcon, {
1652
- "aria-hidden": true,
1653
- className: "h-2.5 w-2.5"
1654
- }), comments]
1941
+ /* @__PURE__ */ jsxs("span", {
1942
+ className: "min-w-0 flex-1",
1943
+ children: [/* @__PURE__ */ jsx("span", {
1944
+ className: "block truncate text-base text-po-text",
1945
+ children: f.path.slice(slash + 1)
1946
+ }), slash < 0 ? null : /* @__PURE__ */ jsx("span", {
1947
+ className: "block truncate font-mono text-sm text-po-dim",
1948
+ children: f.path.slice(0, slash)
1949
+ })]
1655
1950
  }),
1656
- file.binary ? /* @__PURE__ */ jsx("span", {
1657
- className: "shrink-0 text-sm text-po-dim",
1658
- children: "binary"
1659
- }) : /* @__PURE__ */ jsxs("span", {
1660
- className: "shrink-0 text-2xs",
1661
- children: [
1951
+ /* @__PURE__ */ jsxs("span", {
1952
+ className: "flex shrink-0 flex-col items-end gap-1 text-sm",
1953
+ children: [/* @__PURE__ */ jsxs("span", { children: [
1662
1954
  /* @__PURE__ */ jsxs("span", {
1663
1955
  className: "text-po-green",
1664
- children: ["+", file.added]
1956
+ children: ["+", f.added]
1665
1957
  }),
1666
1958
  " ",
1667
1959
  /* @__PURE__ */ jsxs("span", {
1668
1960
  className: "text-po-red",
1669
- children: ["-", file.removed]
1961
+ children: ["-", f.removed]
1670
1962
  })
1671
- ]
1963
+ ] }), count > 0 && /* @__PURE__ */ jsxs("span", {
1964
+ className: "flex items-center gap-1 text-po-blue",
1965
+ children: [/* @__PURE__ */ jsx(MessageIcon, { className: "h-3 w-3" }), count]
1966
+ })]
1672
1967
  })
1673
1968
  ]
1674
- }, file.path);
1675
- }), ordered.length === 0 ? /* @__PURE__ */ jsx("p", {
1676
- className: "px-3 py-2 text-sm text-po-dim",
1677
- children: "no path matches"
1678
- }) : null]
1969
+ }, f.path);
1970
+ }), shown.length === 0 && /* @__PURE__ */ jsx("p", {
1971
+ className: "p-3 text-sm text-po-dim",
1972
+ children: "No paths match."
1973
+ })]
1679
1974
  })]
1680
1975
  });
1681
1976
  }
1682
1977
  //#endregion
1683
1978
  //#region src/extensions/workspaces/sessions/(frontend)/_components/GitSyncBar.tsx
1684
- /**
1685
- * The review tab's header: what is being reviewed, and the manual sync that
1686
- * goes with it.
1687
- *
1688
- * DESIGN PATTERNS:
1689
- * - Everything here is a report or a request. The hub runs the git, one
1690
- * command per session, and answers on the channel: pending while it runs,
1691
- * an error target when it fails, a paused rebase when it stops on conflicts.
1692
- * - A push the remote rejects is not an error to shrug at: the strip asks
1693
- * before forcing, and the force it sends is a lease, which git refuses if
1694
- * the remote holds commits this branch never fetched and integrated.
1695
- * - A paused rebase blocks the sync buttons. The two ways out are named on the
1696
- * banner, and abort says what it throws away.
1697
- *
1698
- * AVOID:
1699
- * - Colour classes outside the token set.
1700
- */
1701
- function GitSyncBar({ changes, mergeBase, pending, error, errorTarget, onSync, onForcePush, onAskAgent, onDismissError }) {
1702
- const busy = pending !== void 0;
1703
- const paused = changes?.rebase !== void 0;
1704
- const forceRequired = errorTarget?.action === "push" && "forceRequired" in errorTarget && errorTarget.forceRequired === true;
1705
- const syncError = error !== void 0 && !forceRequired ? error : void 0;
1706
- const upstream = changes?.upstream;
1979
+ function GitSyncBar({ secondary = false, ...props }) {
1980
+ const c = props.changes;
1981
+ const paused = c?.rebase !== void 0;
1982
+ const busy = props.pending !== void 0;
1983
+ const rejected = props.errorTarget?.action === "push" && props.errorTarget.forceRequired;
1984
+ const suggested = suggestedSyncAction(c);
1985
+ const upstream = upstreamSummary(c?.upstream);
1707
1986
  return /* @__PURE__ */ jsxs("div", {
1708
1987
  "data-testid": "git-sync-bar",
1709
- className: "flex shrink-0 flex-col gap-2 border-b border-po-border-soft px-3 py-2.5 sm:px-[26px]",
1988
+ className: "flex flex-col gap-3 border-b border-po-border-soft p-4",
1710
1989
  children: [
1711
1990
  /* @__PURE__ */ jsxs("div", {
1712
- className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5",
1991
+ className: "flex flex-wrap items-center gap-3 text-sm",
1713
1992
  children: [
1714
- /* @__PURE__ */ jsxs("span", {
1715
- className: "flex min-w-0 items-center gap-1.5",
1716
- children: [
1717
- /* @__PURE__ */ jsx(BranchIcon, {
1718
- "aria-hidden": true,
1719
- className: "h-3.5 w-3.5 shrink-0 text-po-faint"
1720
- }),
1721
- /* @__PURE__ */ jsx("span", {
1722
- "data-testid": "git-review-branch",
1723
- className: "truncate text-base font-semibold text-po-hi",
1724
- children: changes?.branch ?? "detached HEAD"
1725
- }),
1726
- /* @__PURE__ */ jsx("span", {
1727
- className: "shrink-0 text-sm text-po-dim",
1728
- children: changes?.base === void 0 ? "uncommitted changes" : `vs ${changes.base}`
1729
- }),
1730
- mergeBase === void 0 ? null : /* @__PURE__ */ jsxs("span", {
1731
- className: "shrink-0 text-sm text-po-dim",
1732
- children: ["from ", mergeBase]
1733
- })
1734
- ]
1993
+ /* @__PURE__ */ jsx(BranchIcon, { className: "h-4 w-4 text-po-dim" }),
1994
+ /* @__PURE__ */ jsx("span", {
1995
+ "data-testid": "git-review-branch",
1996
+ className: "font-mono text-base font-semibold text-po-hi",
1997
+ children: c?.branch ?? "Detached HEAD"
1998
+ }),
1999
+ /* @__PURE__ */ jsx("span", {
2000
+ className: "text-po-dim",
2001
+ children: c?.base === void 0 ? "Uncommitted changes" : /* @__PURE__ */ jsxs(Fragment, { children: ["vs ", /* @__PURE__ */ jsx("span", {
2002
+ className: "font-mono",
2003
+ children: c.base
2004
+ })] })
2005
+ }),
2006
+ props.mergeBase && /* @__PURE__ */ jsxs("span", {
2007
+ className: "text-po-dim",
2008
+ children: ["from ", /* @__PURE__ */ jsx("span", {
2009
+ className: "font-mono",
2010
+ children: props.mergeBase
2011
+ })]
1735
2012
  }),
1736
- changes === void 0 ? null : /* @__PURE__ */ jsxs("span", {
2013
+ c === void 0 ? null : /* @__PURE__ */ jsxs("span", {
1737
2014
  "data-testid": "git-review-totals",
1738
- className: "flex shrink-0 items-center gap-1.5 text-sm",
2015
+ className: "contents",
1739
2016
  children: [
1740
2017
  /* @__PURE__ */ jsxs("span", {
1741
- className: "font-semibold text-po-green",
1742
- children: ["+", changes.added]
2018
+ className: "text-po-green",
2019
+ children: ["+", c?.added]
1743
2020
  }),
1744
2021
  /* @__PURE__ */ jsxs("span", {
1745
- className: "font-semibold text-po-red",
1746
- children: ["-", changes.removed]
2022
+ className: "text-po-red",
2023
+ children: ["-", c?.removed]
1747
2024
  }),
1748
2025
  /* @__PURE__ */ jsxs("span", {
1749
2026
  className: "text-po-dim",
1750
2027
  children: [
1751
- changes.files,
1752
- changes.truncated ? "+" : "",
2028
+ c?.files,
2029
+ c?.truncated ? "+" : "",
1753
2030
  " ",
1754
- changes.files === 1 ? "file" : "files"
2031
+ c?.files === 1 ? "file" : "files"
1755
2032
  ]
1756
2033
  })
1757
2034
  ]
1758
2035
  }),
1759
- /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }),
1760
- upstream === void 0 ? /* @__PURE__ */ jsx("span", {
1761
- className: "shrink-0 text-sm text-po-dim",
1762
- children: "no upstream yet"
1763
- }) : /* @__PURE__ */ jsxs("span", {
1764
- className: "shrink-0 text-sm text-po-dim",
1765
- title: upstream.ref,
1766
- children: [
1767
- "↑",
1768
- upstream.ahead,
1769
- " ↓",
1770
- upstream.behind,
1771
- " ",
1772
- upstream.ref
1773
- ]
2036
+ /* @__PURE__ */ jsx("span", { className: "flex-1" }),
2037
+ /* @__PURE__ */ jsx("span", {
2038
+ className: "text-po-dim",
2039
+ children: c?.branch === void 0 ? "No branch checked out" : c.upstream === void 0 || !upstream.endsWith(c.upstream.ref) ? upstream : /* @__PURE__ */ jsxs(Fragment, { children: [upstream.slice(0, -c.upstream.ref.length), /* @__PURE__ */ jsx("span", {
2040
+ className: "font-mono",
2041
+ children: c.upstream.ref
2042
+ })] })
1774
2043
  }),
1775
- /* @__PURE__ */ jsxs("span", {
1776
- className: "flex shrink-0 items-center gap-1.5",
2044
+ /* @__PURE__ */ jsx("div", {
2045
+ className: "flex gap-1.5",
1777
2046
  children: [
1778
- /* @__PURE__ */ jsx(Button, {
1779
- size: "xs",
1780
- "data-testid": "git-sync-pull",
1781
- disabled: busy || paused || upstream === void 0,
1782
- title: upstream === void 0 ? "push once to set an upstream" : `fetch, then rebase onto ${upstream.ref}`,
1783
- onClick: () => onSync("pull"),
1784
- children: "pull"
1785
- }),
1786
- /* @__PURE__ */ jsx(Button, {
1787
- size: "xs",
1788
- "data-testid": "git-sync-push",
1789
- disabled: busy || paused || changes?.branch === void 0,
1790
- title: upstream === void 0 ? "push and set the upstream" : `push to ${upstream.ref}`,
1791
- onClick: () => onSync("push"),
1792
- children: "push"
1793
- }),
1794
- /* @__PURE__ */ jsx(Button, {
1795
- size: "xs",
1796
- "data-testid": "git-sync-rebase",
1797
- disabled: busy || paused || changes?.base === void 0,
1798
- title: changes?.base === void 0 ? "no base branch to rebase onto" : `fetch, then rebase onto ${changes.base}`,
1799
- onClick: () => onSync("rebase"),
1800
- children: "rebase"
1801
- })
1802
- ]
2047
+ "pull",
2048
+ "push",
2049
+ "rebase"
2050
+ ].map((action) => /* @__PURE__ */ jsx(Button, {
2051
+ "data-testid": `git-sync-${action}`,
2052
+ size: "sm",
2053
+ variant: !busy && !paused && !rejected && !props.error && c?.branch !== void 0 && suggested === action ? secondary ? "outline" : "primary" : "ghost",
2054
+ disabled: busy || paused || action !== "rebase" && c?.branch === void 0 || action === "pull" && c?.upstream === void 0 || action === "rebase" && c?.base === void 0,
2055
+ onClick: () => props.onSync(action),
2056
+ children: action === "pull" ? "Pull" : action === "push" ? "Push" : "Rebase"
2057
+ }, action))
1803
2058
  })
1804
2059
  ]
1805
2060
  }),
1806
- pending === void 0 ? null : /* @__PURE__ */ jsxs("span", {
2061
+ busy && /* @__PURE__ */ jsxs("div", {
1807
2062
  "data-testid": "git-sync-pending",
1808
- className: "flex min-w-0 items-center gap-1.5",
2063
+ className: "flex items-center gap-2 text-sm text-po-dim",
1809
2064
  children: [/* @__PURE__ */ jsx(Spinner, {
1810
- className: "h-3 w-3 shrink-0 text-po-faint",
1811
- label: pending
1812
- }), /* @__PURE__ */ jsx("span", {
1813
- className: "min-w-0 truncate text-sm text-po-dim",
1814
- children: pending
1815
- })]
1816
- }),
1817
- syncError === void 0 ? null : /* @__PURE__ */ jsxs("div", {
1818
- role: "alert",
1819
- "data-testid": "git-sync-error",
1820
- className: "flex min-w-0 items-start gap-1.5 text-sm text-po-red",
1821
- children: [
1822
- /* @__PURE__ */ jsx(AlertIcon, {
1823
- "aria-hidden": true,
1824
- className: "mt-px h-3 w-3 shrink-0"
1825
- }),
1826
- /* @__PURE__ */ jsx("span", {
1827
- className: "min-w-0 flex-1",
1828
- children: syncError
1829
- }),
1830
- /* @__PURE__ */ jsx(Button, {
1831
- variant: "ghost",
1832
- size: "xs",
1833
- className: "h-auto min-h-0 px-1 py-0 ",
1834
- onClick: onDismissError,
1835
- children: "dismiss"
1836
- })
1837
- ]
2065
+ className: "h-4 w-4 text-po-dim",
2066
+ label: props.pending
2067
+ }), props.pending]
1838
2068
  }),
1839
- forceRequired ? /* @__PURE__ */ jsxs("div", {
2069
+ rejected ? /* @__PURE__ */ jsxs("div", {
1840
2070
  "data-testid": "git-push-force-confirm",
1841
- className: "flex min-w-0 flex-wrap items-center gap-2 rounded-md border border-po-edge-yellow bg-po-tint-yellow px-2.5 py-2",
2071
+ className: "flex flex-wrap items-center gap-3 rounded-md border border-po-edge-yellow bg-po-tint-yellow p-3",
1842
2072
  children: [
1843
2073
  /* @__PURE__ */ jsx("span", {
1844
- className: "min-w-0 flex-1 text-base text-po-hi",
1845
- children: "The remote branch has commits yours replaced, usually after a rebase. Force push with lease? It is refused if the remote holds commits you never fetched and integrated."
2074
+ className: "flex-1 text-base text-po-text",
2075
+ children: "origin has commits you have not pulled yet."
1846
2076
  }),
1847
2077
  /* @__PURE__ */ jsx(Button, {
2078
+ size: "sm",
1848
2079
  variant: "danger-outline",
1849
- size: "xs",
1850
2080
  "data-testid": "git-push-force",
1851
2081
  disabled: busy,
1852
- onClick: onForcePush,
1853
- children: "force push"
2082
+ onClick: props.onForcePush,
2083
+ children: "Force push with lease"
1854
2084
  }),
1855
2085
  /* @__PURE__ */ jsx(Button, {
2086
+ size: "sm",
1856
2087
  variant: "ghost",
1857
- size: "xs",
1858
2088
  "data-testid": "git-push-force-cancel",
1859
- onClick: onDismissError,
1860
- children: "cancel"
2089
+ onClick: props.onDismissError,
2090
+ children: "Not now"
1861
2091
  })
1862
2092
  ]
1863
- }) : null,
1864
- changes?.rebase === void 0 ? null : /* @__PURE__ */ jsxs("div", {
2093
+ }) : props.error && /* @__PURE__ */ jsxs("div", {
2094
+ role: "alert",
2095
+ "data-testid": "git-sync-error",
2096
+ className: "flex items-center gap-3 rounded-md border border-po-edge-red bg-po-tint-red p-3 text-base text-po-red",
2097
+ children: [/* @__PURE__ */ jsx("span", {
2098
+ className: "flex-1",
2099
+ children: props.error
2100
+ }), /* @__PURE__ */ jsx(Button, {
2101
+ size: "sm",
2102
+ variant: "ghost",
2103
+ onClick: props.onDismissError,
2104
+ children: "Dismiss"
2105
+ })]
2106
+ }),
2107
+ paused && /* @__PURE__ */ jsxs("div", {
1865
2108
  "data-testid": "git-rebase-banner",
1866
- className: "flex min-w-0 flex-col gap-1.5 rounded-md border border-po-edge-red bg-po-tint-red px-2.5 py-2",
2109
+ className: "flex flex-col gap-2 rounded-md border border-po-edge-yellow bg-po-tint-yellow p-3",
1867
2110
  children: [
1868
- /* @__PURE__ */ jsxs("span", {
1869
- className: "flex min-w-0 items-center gap-1.5",
1870
- children: [/* @__PURE__ */ jsx(StatusBadge, {
1871
- tone: "error",
1872
- size: "xs",
1873
- children: "rebase paused"
1874
- }), /* @__PURE__ */ jsx("span", {
1875
- className: "text-base text-po-hi",
1876
- children: changes.rebase.conflicts.length === 0 ? "git stopped the rebase" : `conflicts in ${String(changes.rebase.conflicts.length)} ${changes.rebase.conflicts.length === 1 ? "file" : "files"}`
1877
- })]
1878
- }),
1879
- changes.rebase.conflicts.length === 0 ? null : /* @__PURE__ */ jsx("ul", {
1880
- className: "flex flex-col gap-0.5 pl-1",
1881
- children: changes.rebase.conflicts.map((file) => /* @__PURE__ */ jsx("li", {
1882
- className: "truncate font-mono text-sm text-po-dim",
1883
- children: file
1884
- }, file))
1885
- }),
1886
- /* @__PURE__ */ jsxs("span", {
1887
- className: "flex flex-wrap items-center gap-1.5",
2111
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(StatusBadge, {
2112
+ tone: "running",
2113
+ size: "xs",
2114
+ children: "Rebase paused"
2115
+ }), /* @__PURE__ */ jsxs("span", {
2116
+ className: "ml-2 text-base text-po-text",
2117
+ children: [
2118
+ "Conflicts in ",
2119
+ c.rebase?.conflicts.length,
2120
+ " ",
2121
+ c.rebase?.conflicts.length === 1 ? "file" : "files"
2122
+ ]
2123
+ })] }),
2124
+ c.rebase?.conflicts.map((path) => /* @__PURE__ */ jsx("p", {
2125
+ className: "font-mono text-sm text-po-dim",
2126
+ children: path
2127
+ }, path)),
2128
+ /* @__PURE__ */ jsxs("div", {
2129
+ className: "flex items-center gap-2",
1888
2130
  children: [
1889
2131
  /* @__PURE__ */ jsx(Button, {
1890
- variant: "primary",
1891
- size: "xs",
2132
+ variant: secondary ? "outline" : "primary",
2133
+ size: "sm",
1892
2134
  "data-testid": "git-rebase-ask-agent",
1893
2135
  disabled: busy,
1894
- onClick: onAskAgent,
1895
- children: "ask agent to resolve"
2136
+ onClick: props.onAskAgent,
2137
+ children: "Ask Po to resolve"
1896
2138
  }),
1897
2139
  /* @__PURE__ */ jsx(Button, {
1898
2140
  variant: "danger-outline",
1899
- size: "xs",
2141
+ size: "sm",
1900
2142
  "data-testid": "git-rebase-abort",
1901
2143
  disabled: busy,
1902
- onClick: () => onSync("abort-rebase"),
1903
- children: "abort rebase"
2144
+ onClick: () => props.onSync("abort-rebase"),
2145
+ children: "Abort rebase"
1904
2146
  }),
1905
2147
  /* @__PURE__ */ jsx("span", {
1906
2148
  className: "text-sm text-po-dim",
1907
- children: "abort discards any conflict resolution in progress"
2149
+ children: "Abort discards conflict resolution in progress."
1908
2150
  })
1909
2151
  ]
1910
2152
  })
@@ -1915,29 +2157,7 @@ function GitSyncBar({ changes, mergeBase, pending, error, errorTarget, onSync, o
1915
2157
  }
1916
2158
  //#endregion
1917
2159
  //#region src/extensions/workspaces/sessions/(frontend)/_components/GitReviewView.tsx
1918
- /**
1919
- * The review tab, drawn from what it is handed: the sync header, the changed
1920
- * files on the left, every diff stacked on the right, and one footer that
1921
- * sends every comment as a single message.
1922
- *
1923
- * DESIGN PATTERNS:
1924
- * - Like a pull request's file view. Picking a file in the list scrolls to it;
1925
- * each file's header stays pinned while its diff scrolls past.
1926
- * - Only nearby file bodies mount and load; distant files retain their headers
1927
- * and measured-height placeholders.
1928
- * - A comment is drawn under the line it is about, on the side it is about.
1929
- * The open draft sits in the same place, so writing happens in context.
1930
- * - Only UI state lives here (the open draft, which files are collapsed, which
1931
- * is active). Data and comments come in as props; the panel owns fetching.
1932
- *
1933
- * AVOID:
1934
- * - Clearing comments here. The owner clears them once the host took the send.
1935
- */
1936
- const PICK_ALIGNMENT_MS = 300;
1937
- const ESTIMATED_ROW_HEIGHT = 21;
1938
- const MAX_DIFF_ROWS = 5e3;
1939
2160
  const NO_FILES = [];
1940
- const NO_PATHS = /* @__PURE__ */ new Set();
1941
2161
  /** Stable, URL-safe element id for one file's section. */
1942
2162
  function sectionId(index) {
1943
2163
  return `git-review-file-${String(index)}`;
@@ -1945,122 +2165,30 @@ function sectionId(index) {
1945
2165
  function sideOf(row) {
1946
2166
  return row.marker === "-" ? "old" : "new";
1947
2167
  }
1948
- function GitReviewView({ sync, summary, files, comments, onLoadFile, onAddComment, onRemoveComment, onSendReview, onDiscard, onDraftChange, sendError, initialDraft }) {
2168
+ function GitReviewView({ sync, summary, files, comments, onLoadFile, onAddComment, onRemoveComment, onSendReview, onDiscard, onDraftChange, sendError, initialDraft, initialPath }) {
1949
2169
  const entries = summary.state === "ready" ? summary.summary.files : NO_FILES;
1950
- const [openOverride, setOpenOverride] = useState({});
1951
- const [picked, setPicked] = useState();
1952
- const [navigation, setNavigation] = useState();
1953
- const [proximity, setProximity] = useState({
1954
- entries: NO_FILES,
1955
- paths: NO_PATHS
1956
- });
1957
- const near = proximity.entries === entries ? proximity.paths : NO_PATHS;
1958
- const paneRef = useRef(null);
1959
- const [heights, setHeights] = useState(/* @__PURE__ */ new Map());
1960
- const pickedAt = useRef(0);
2170
+ const [picked, setPicked] = useState(initialPath ?? initialDraft?.path);
1961
2171
  const activePath = entries.some((entry) => entry.path === picked) ? picked : entries[0]?.path;
2172
+ const index = entries.findIndex((entry) => entry.path === activePath);
2173
+ const file = entries[index];
1962
2174
  const [draft, setDraft] = useState(initialDraft);
1963
2175
  useEffect(() => {
1964
- const pane = paneRef.current;
1965
- if (pane === null || typeof IntersectionObserver === "undefined") return;
1966
- setHeights(/* @__PURE__ */ new Map());
1967
- let observer;
1968
- const observe = () => {
1969
- observer?.disconnect();
1970
- observer = new IntersectionObserver((changes) => {
1971
- for (const change of changes) {
1972
- if (change.isIntersecting) continue;
1973
- const section = change.target;
1974
- const path = section.dataset.reviewPath;
1975
- const body = section.querySelector("[data-review-body=\"measured\"]");
1976
- if (path !== void 0 && body !== null) {
1977
- const height = body.offsetHeight;
1978
- setHeights((measured) => new Map(measured).set(path, height));
1979
- }
1980
- }
1981
- setProximity((current) => {
1982
- const next = new Set(current.entries === entries ? current.paths : NO_PATHS);
1983
- for (const change of changes) {
1984
- const path = change.target.dataset.reviewPath;
1985
- if (path === void 0) continue;
1986
- if (change.isIntersecting) next.add(path);
1987
- else next.delete(path);
1988
- }
1989
- return {
1990
- entries,
1991
- paths: next
1992
- };
1993
- });
1994
- }, {
1995
- root: pane,
1996
- rootMargin: `${String(pane.clientHeight)}px 0px`
1997
- });
1998
- for (const section of pane.querySelectorAll("[data-review-path]")) observer.observe(section);
1999
- };
2000
- observe();
2001
- const resize = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(observe);
2002
- resize?.observe(pane);
2003
- let frame = 0;
2004
- const scroll = () => {
2005
- cancelAnimationFrame(frame);
2006
- frame = requestAnimationFrame(() => {
2007
- if (Date.now() - pickedAt.current < PICK_ALIGNMENT_MS) return;
2008
- const rect = pane.getBoundingClientRect();
2009
- const section = document.elementFromPoint(rect.left + 8, rect.top + 1)?.closest("[data-review-path]");
2010
- if (section !== null && section !== void 0 && pane.contains(section)) setPicked(section.dataset.reviewPath);
2011
- });
2012
- };
2013
- pane.addEventListener("scroll", scroll, { passive: true });
2014
- return () => {
2015
- observer.disconnect();
2016
- resize?.disconnect();
2017
- pane.removeEventListener("scroll", scroll);
2018
- cancelAnimationFrame(frame);
2019
- };
2020
- }, [entries]);
2021
- useLayoutEffect(() => {
2022
- if (navigation === void 0) return;
2023
- [...paneRef.current?.querySelectorAll("[data-review-path]") ?? []].find((element) => element.dataset.reviewPath === navigation)?.scrollIntoView({ block: "start" });
2024
- }, [navigation, openOverride]);
2025
- useEffect(() => {
2026
- if (navigation === void 0) return;
2027
- const timeout = setTimeout(() => setNavigation(void 0), PICK_ALIGNMENT_MS);
2028
- return () => clearTimeout(timeout);
2029
- }, [navigation]);
2030
- useEffect(() => {
2031
- for (const file of entries) if ((openOverride[file.path] ?? true) && (near.has(file.path) || navigation === file.path || draft?.path === file.path || comments.some((comment) => comment.path === file.path)) && files[file.path] === void 0) onLoadFile(file.path);
2176
+ if (activePath !== void 0 && files[activePath] === void 0) onLoadFile(activePath);
2032
2177
  }, [
2033
- entries,
2178
+ activePath,
2034
2179
  files,
2035
- near,
2036
- navigation,
2037
- draft,
2038
- comments,
2039
- openOverride,
2040
2180
  onLoadFile
2041
2181
  ]);
2042
2182
  const commentCounts = {};
2043
2183
  for (const comment of comments) commentCounts[comment.path] = (commentCounts[comment.path] ?? 0) + 1;
2044
- const isOpen = (path) => openOverride[path] ?? true;
2045
- const open = (path) => {
2046
- setOpenOverride((current) => current[path] === true ? current : {
2047
- ...current,
2048
- [path]: true
2049
- });
2050
- };
2051
2184
  const pick = (path) => {
2052
2185
  if (!entries.some((entry) => entry.path === path)) return;
2053
- pickedAt.current = Date.now();
2186
+ if (path !== activePath && draft !== void 0) {
2187
+ if (!window.confirm("Discard the unsent comment and open another file?")) return;
2188
+ setDraft(void 0);
2189
+ onDraftChange?.(false);
2190
+ }
2054
2191
  setPicked(path);
2055
- setNavigation(path);
2056
- open(path);
2057
- };
2058
- const toggle = (path) => {
2059
- if (isOpen(path)) setOpenOverride((current) => ({
2060
- ...current,
2061
- [path]: false
2062
- }));
2063
- else open(path);
2064
2192
  };
2065
2193
  const submitDraft = (body) => {
2066
2194
  if (draft === void 0) return;
@@ -2082,87 +2210,116 @@ function GitReviewView({ sync, summary, files, comments, onLoadFile, onAddCommen
2082
2210
  children: [
2083
2211
  /* @__PURE__ */ jsx(GitSyncBar, {
2084
2212
  ...sync,
2213
+ secondary: comments.length > 0,
2085
2214
  ...summary.state === "ready" && summary.summary.mergeBase !== void 0 ? { mergeBase: summary.summary.mergeBase } : {}
2086
2215
  }),
2087
2216
  summary.state === "loading" ? /* @__PURE__ */ jsxs("div", {
2088
2217
  "data-testid": "git-review-loading",
2089
- className: "flex flex-1 items-start gap-2 px-4 py-6",
2218
+ className: "flex min-h-48 flex-1 items-center justify-center gap-2 text-sm text-po-dim",
2090
2219
  children: [/* @__PURE__ */ jsx(Spinner, {
2091
- className: "h-3 w-3 text-po-faint",
2092
- label: "reading changes"
2220
+ className: "h-4 w-4 text-po-dim",
2221
+ label: "Reading changes"
2093
2222
  }), /* @__PURE__ */ jsx("span", {
2094
2223
  className: "text-sm text-po-dim",
2095
- children: "reading changes…"
2224
+ children: "Reading changes..."
2096
2225
  })]
2097
- }) : summary.state === "error" ? /* @__PURE__ */ jsx("p", {
2098
- role: "alert",
2226
+ }) : summary.state === "error" ? /* @__PURE__ */ jsx(EmptyState, {
2099
2227
  "data-testid": "git-review-error",
2100
- className: "flex-1 px-4 py-6 text-sm text-po-red",
2101
- children: summary.error
2228
+ className: "min-h-48 text-po-red",
2229
+ title: /* @__PURE__ */ jsx("span", {
2230
+ className: "text-po-red",
2231
+ children: "Changes could not be read"
2232
+ }),
2233
+ description: summary.error
2102
2234
  }) : !summary.summary.repository ? /* @__PURE__ */ jsx(EmptyState, {
2103
2235
  "data-testid": "git-review-no-repository",
2104
- className: "px-4 py-8",
2105
- title: "not a git checkout",
2106
- description: "this session's folder is not inside a git repository, so there is nothing to review."
2236
+ className: "min-h-48",
2237
+ title: "Not a Git checkout",
2238
+ description: "This session's folder is not inside a Git repository."
2107
2239
  }) : entries.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
2108
2240
  "data-testid": "git-review-empty",
2109
- className: "px-4 py-8",
2110
- title: "no changes",
2111
- description: summary.summary.base === void 0 ? "nothing uncommitted in this checkout." : `nothing differs from ${summary.summary.base}, committed or not.`
2241
+ className: "min-h-48",
2242
+ title: "No changes yet",
2243
+ description: summary.summary.base === void 0 ? "Nothing uncommitted in this checkout." : `Nothing differs from ${summary.summary.base}, committed or not.`
2112
2244
  }) : /* @__PURE__ */ jsxs("div", {
2245
+ "data-testid": "git-review-content",
2113
2246
  className: "flex min-h-0 flex-1",
2114
2247
  children: [/* @__PURE__ */ jsx(GitReviewBrowser, {
2115
2248
  files: entries,
2116
2249
  commentCounts,
2117
2250
  onPick: pick,
2118
2251
  ...activePath === void 0 ? {} : { activePath }
2119
- }), /* @__PURE__ */ jsxs("div", {
2120
- ref: paneRef,
2252
+ }), /* @__PURE__ */ jsxs("main", {
2121
2253
  "data-testid": "git-review-diffs",
2122
2254
  className: "min-h-0 min-w-0 flex-1 overflow-y-auto",
2123
- children: [summary.summary.truncated ? /* @__PURE__ */ jsx("p", {
2124
- className: "px-4 pt-2 text-sm text-po-dim",
2125
- children: "more files changed than the review lists; the rest are left out."
2126
- }) : null, entries.map((file, index) => /* @__PURE__ */ jsx(FileSection, {
2127
- id: sectionId(index),
2128
- entry: file,
2129
- state: files[file.path],
2130
- collapsed: !isOpen(file.path),
2131
- mounted: near.has(file.path) || navigation === file.path || draft?.path === file.path || comments.some((comment) => comment.path === file.path),
2132
- placeholderHeight: heights.get(file.path) ?? (file.binary ? 40 : Math.min(MAX_DIFF_ROWS, file.added + file.removed + 6) * ESTIMATED_ROW_HEIGHT),
2133
- comments: comments.filter((comment) => comment.path === file.path),
2134
- draft: draft?.path === file.path ? draft.selection : void 0,
2135
- onToggle: () => toggle(file.path),
2136
- onSelect: (selection) => {
2137
- setPicked(file.path);
2138
- setDraft({
2139
- path: file.path,
2140
- selection
2141
- });
2142
- onDraftChange?.(true);
2143
- },
2144
- onSubmitDraft: submitDraft,
2145
- onCancelDraft: () => {
2146
- setDraft(void 0);
2147
- onDraftChange?.(false);
2148
- },
2149
- onRemoveComment,
2150
- onRetry: () => onLoadFile(file.path)
2151
- }, file.path))]
2255
+ children: [
2256
+ summary.summary.truncated ? /* @__PURE__ */ jsx("p", {
2257
+ className: "px-4 pt-2 text-sm text-po-dim",
2258
+ children: "More files changed than the review lists; the rest are left out."
2259
+ }) : null,
2260
+ /* @__PURE__ */ jsxs("div", {
2261
+ className: "flex items-center justify-between border-b border-po-border-soft px-4 py-2",
2262
+ children: [
2263
+ /* @__PURE__ */ jsx(Button, {
2264
+ variant: "ghost",
2265
+ size: "sm",
2266
+ disabled: index <= 0,
2267
+ onClick: () => pick(entries[index - 1].path),
2268
+ children: "Previous file"
2269
+ }),
2270
+ /* @__PURE__ */ jsxs("span", {
2271
+ className: "text-sm text-po-dim",
2272
+ children: [
2273
+ index + 1,
2274
+ " of ",
2275
+ entries.length
2276
+ ]
2277
+ }),
2278
+ /* @__PURE__ */ jsx(Button, {
2279
+ variant: "ghost",
2280
+ size: "sm",
2281
+ disabled: index >= entries.length - 1,
2282
+ onClick: () => pick(entries[index + 1].path),
2283
+ children: "Next file"
2284
+ })
2285
+ ]
2286
+ }),
2287
+ file === void 0 ? null : /* @__PURE__ */ jsx(FileSection, {
2288
+ id: sectionId(index),
2289
+ entry: file,
2290
+ state: files[file.path],
2291
+ comments: comments.filter((comment) => comment.path === file.path),
2292
+ draft: draft?.path === file.path ? draft.selection : void 0,
2293
+ onSelect: (selection) => {
2294
+ setDraft({
2295
+ path: file.path,
2296
+ selection
2297
+ });
2298
+ onDraftChange?.(true);
2299
+ },
2300
+ onSubmitDraft: submitDraft,
2301
+ onCancelDraft: () => {
2302
+ setDraft(void 0);
2303
+ onDraftChange?.(false);
2304
+ },
2305
+ onRemoveComment,
2306
+ onRetry: () => onLoadFile(file.path)
2307
+ }, file.path)
2308
+ ]
2152
2309
  })]
2153
2310
  }),
2154
2311
  /* @__PURE__ */ jsxs("div", {
2155
2312
  "data-testid": "git-review-footer",
2156
- className: "flex shrink-0 flex-wrap items-center gap-2 border-t border-po-border-soft bg-po-panel px-3 py-2 sm:px-[26px]",
2313
+ className: "flex shrink-0 flex-wrap items-center gap-3 border-t border-po-border-soft bg-po-panel px-4 py-3",
2157
2314
  children: [
2158
2315
  /* @__PURE__ */ jsx(MessageIcon, {
2159
2316
  "aria-hidden": true,
2160
- className: "h-3 w-3 text-po-faint"
2317
+ className: "h-4 w-4 text-po-blue"
2161
2318
  }),
2162
2319
  /* @__PURE__ */ jsx("span", {
2163
2320
  "data-testid": "git-review-comment-count",
2164
2321
  className: "text-sm text-po-dim",
2165
- children: comments.length === 0 ? "no comments yet: select lines or click a line number" : `${String(comments.length)} ${comments.length === 1 ? "comment" : "comments"}`
2322
+ children: comments.length === 0 ? "No comments yet: select lines or click a line number" : `${String(comments.length)} ${comments.length === 1 ? "comment" : "comments"} queued`
2166
2323
  }),
2167
2324
  /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }),
2168
2325
  sendError === void 0 ? null : /* @__PURE__ */ jsx("span", {
@@ -2173,11 +2330,11 @@ function GitReviewView({ sync, summary, files, comments, onLoadFile, onAddCommen
2173
2330
  }),
2174
2331
  /* @__PURE__ */ jsx(Button, {
2175
2332
  variant: "ghost",
2176
- size: "xs",
2333
+ size: "sm",
2177
2334
  "data-testid": "git-review-discard",
2178
2335
  disabled: comments.length === 0,
2179
2336
  onClick: onDiscard,
2180
- children: "discard"
2337
+ children: "Discard"
2181
2338
  }),
2182
2339
  /* @__PURE__ */ jsx(Button, {
2183
2340
  variant: "primary",
@@ -2185,7 +2342,7 @@ function GitReviewView({ sync, summary, files, comments, onLoadFile, onAddCommen
2185
2342
  "data-testid": "git-review-send",
2186
2343
  disabled: comments.length === 0,
2187
2344
  onClick: onSendReview,
2188
- children: "send review"
2345
+ children: "Send review"
2189
2346
  })
2190
2347
  ]
2191
2348
  })
@@ -2193,34 +2350,34 @@ function GitReviewView({ sync, summary, files, comments, onLoadFile, onAddCommen
2193
2350
  });
2194
2351
  }
2195
2352
  const STATUS_WORD = {
2196
- added: "added",
2197
- modified: "modified",
2198
- deleted: "deleted",
2199
- untracked: "new, untracked",
2200
- conflicted: "conflicted"
2353
+ added: "Added",
2354
+ modified: "Modified",
2355
+ deleted: "Deleted",
2356
+ untracked: "Untracked",
2357
+ conflicted: "Conflicted"
2201
2358
  };
2202
2359
  /** One file: a pinned header, then its diff with comments drawn under the lines they are about. */
2203
- function FileSection({ id, entry, state, collapsed, mounted, placeholderHeight, comments, draft, onToggle, onSelect, onSubmitDraft, onCancelDraft, onRemoveComment, onRetry }) {
2360
+ function FileSection({ id, entry, state, comments, draft, onSelect, onSubmitDraft, onCancelDraft, onRemoveComment, onRetry }) {
2204
2361
  const renderAfterRow = (row) => {
2205
2362
  const side = sideOf(row);
2206
2363
  const here = comments.filter((comment) => (comment.side ?? "new") === side && (comment.endLine ?? comment.startLine) === row.line);
2207
2364
  const drafting = draft !== void 0 && draft.side === side && draft.endLine === row.line;
2208
2365
  if (here.length === 0 && !drafting) return null;
2209
2366
  return /* @__PURE__ */ jsxs("div", {
2210
- className: "flex flex-col gap-1.5 border-y border-po-border-soft bg-po-bg px-2 py-1.5 font-sans whitespace-normal",
2367
+ className: "font-sans whitespace-normal",
2211
2368
  children: [here.map((comment) => /* @__PURE__ */ jsxs("div", {
2212
2369
  "data-testid": `git-review-comment-${comment.id}`,
2213
- className: "flex min-w-0 items-start gap-2 rounded-md border border-po-border-soft bg-po-panel px-2 py-1.5",
2370
+ className: "m-3 flex items-start gap-3 rounded-md border border-po-border-soft bg-po-panel p-3 font-sans whitespace-normal",
2214
2371
  children: [
2215
2372
  /* @__PURE__ */ jsx(MessageIcon, {
2216
2373
  "aria-hidden": true,
2217
- className: "mt-0.5 h-3 w-3 shrink-0 text-po-blue"
2374
+ className: "mt-1 h-4 w-4 shrink-0 text-po-blue"
2218
2375
  }),
2219
2376
  /* @__PURE__ */ jsxs("span", {
2220
- className: "flex min-w-0 flex-1 flex-col gap-0.5",
2221
- children: [/* @__PURE__ */ jsx("span", {
2222
- className: "font-mono text-sm text-po-dim",
2223
- children: reviewCommentAnchor(comment)
2377
+ className: "flex min-w-0 flex-1 flex-col",
2378
+ children: [/* @__PURE__ */ jsxs("span", {
2379
+ className: "mb-1 text-sm text-po-dim",
2380
+ children: ["You · line ", comment.endLine ?? comment.startLine]
2224
2381
  }), /* @__PURE__ */ jsx("span", {
2225
2382
  className: "text-base whitespace-pre-wrap text-po-text",
2226
2383
  children: comment.body
@@ -2228,15 +2385,15 @@ function FileSection({ id, entry, state, collapsed, mounted, placeholderHeight,
2228
2385
  }),
2229
2386
  /* @__PURE__ */ jsx(Button, {
2230
2387
  variant: "ghost",
2231
- size: "icon",
2232
- "aria-label": "remove comment",
2233
- title: "remove comment",
2388
+ size: "sm",
2389
+ "aria-label": "Remove comment",
2390
+ title: "Remove comment",
2234
2391
  onClick: () => onRemoveComment(comment.id),
2235
- children: /* @__PURE__ */ jsx(CloseIcon, { className: "h-3 w-3" })
2392
+ children: "Remove"
2236
2393
  })
2237
2394
  ]
2238
2395
  }, comment.id)), drafting ? /* @__PURE__ */ jsx("div", {
2239
- className: "rounded-md border border-po-border bg-po-panel",
2396
+ className: "m-3 rounded-md border border-po-border-soft bg-po-panel font-sans whitespace-normal [&_pre]:text-sm [&_p]:first-letter:uppercase",
2240
2397
  children: /* @__PURE__ */ jsx(ReviewCommentDraft, {
2241
2398
  snippet: draft.snippet,
2242
2399
  startLine: draft.startLine,
@@ -2253,90 +2410,73 @@ function FileSection({ id, entry, state, collapsed, mounted, placeholderHeight,
2253
2410
  id,
2254
2411
  "data-review-path": entry.path,
2255
2412
  "data-testid": `git-review-file-${entry.path}`,
2256
- className: "border-b border-po-border-soft",
2257
- children: [/* @__PURE__ */ jsxs(Button, {
2258
- variant: "ghost",
2259
- size: "card",
2260
- "aria-expanded": !collapsed,
2261
- onClick: onToggle,
2262
- className: "sticky top-0 z-10 flex-row items-center gap-1.5 rounded-none border-b border-po-border-soft bg-po-rail px-3 py-1.5 hover:bg-po-panel sm:px-4",
2413
+ children: [/* @__PURE__ */ jsxs("div", {
2414
+ className: "flex flex-wrap items-center gap-3 border-b border-po-border-soft bg-po-panel px-4 py-3",
2263
2415
  children: [
2264
- collapsed ? /* @__PURE__ */ jsx(ChevronRightIcon, {
2265
- "aria-hidden": true,
2266
- className: "h-3 w-3 shrink-0 text-po-faint"
2267
- }) : /* @__PURE__ */ jsx(ChevronDownIcon, {
2268
- "aria-hidden": true,
2269
- className: "h-3 w-3 shrink-0 text-po-faint"
2270
- }),
2271
2416
  /* @__PURE__ */ jsx("span", {
2272
- className: "min-w-0 flex-1 truncate font-mono text-base font-semibold text-po-hi",
2417
+ className: "min-w-0 flex-1 truncate font-mono text-base text-po-hi",
2273
2418
  children: entry.path
2274
2419
  }),
2275
2420
  /* @__PURE__ */ jsx("span", {
2276
- className: "shrink-0 text-sm font-semibold text-po-dim",
2421
+ className: "shrink-0 text-sm text-po-dim",
2277
2422
  children: STATUS_WORD[entry.status]
2278
2423
  }),
2424
+ entry.binary ? null : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
2425
+ className: "text-sm text-po-green",
2426
+ children: ["+", entry.added]
2427
+ }), /* @__PURE__ */ jsxs("span", {
2428
+ className: "text-sm text-po-red",
2429
+ children: ["-", entry.removed]
2430
+ })] }),
2279
2431
  comments.length === 0 ? null : /* @__PURE__ */ jsxs("span", {
2280
- className: "flex shrink-0 items-center gap-0.5 text-sm text-po-blue",
2281
- children: [/* @__PURE__ */ jsx(MessageIcon, {
2282
- "aria-hidden": true,
2283
- className: "h-2.5 w-2.5"
2284
- }), comments.length]
2285
- }),
2286
- entry.binary ? null : /* @__PURE__ */ jsxs("span", {
2287
- className: "shrink-0 text-2xs",
2432
+ className: "flex shrink-0 items-center gap-1 text-sm text-po-blue",
2288
2433
  children: [
2289
- /* @__PURE__ */ jsxs("span", {
2290
- className: "text-po-green",
2291
- children: ["+", entry.added]
2434
+ /* @__PURE__ */ jsx(MessageIcon, {
2435
+ "aria-hidden": true,
2436
+ className: "h-3 w-3"
2292
2437
  }),
2438
+ comments.length,
2293
2439
  " ",
2294
- /* @__PURE__ */ jsxs("span", {
2295
- className: "text-po-red",
2296
- children: ["-", entry.removed]
2297
- })
2440
+ comments.length === 1 ? "comment" : "comments"
2298
2441
  ]
2299
2442
  })
2300
2443
  ]
2301
- }), collapsed ? null : !mounted ? /* @__PURE__ */ jsx("div", {
2302
- "aria-hidden": true,
2303
- style: { height: placeholderHeight }
2304
- }) : /* @__PURE__ */ jsx("div", {
2444
+ }), /* @__PURE__ */ jsx("div", {
2305
2445
  "data-review-body": state === void 0 || state.state === "loading" ? "loading" : "measured",
2306
- style: state === void 0 || state.state === "loading" ? { minHeight: placeholderHeight } : void 0,
2307
2446
  children: state === void 0 || state.state === "loading" ? /* @__PURE__ */ jsxs("div", {
2308
2447
  className: "flex items-center gap-2 px-4 py-3",
2309
2448
  children: [/* @__PURE__ */ jsx(Spinner, {
2310
2449
  className: "h-3 w-3 text-po-faint",
2311
- label: `loading ${entry.path}`
2450
+ label: `Loading ${entry.path}`
2312
2451
  }), /* @__PURE__ */ jsx("span", {
2313
2452
  className: "text-sm text-po-dim",
2314
- children: "loading diff…"
2453
+ children: "Loading diff..."
2315
2454
  })]
2316
2455
  }) : state.state === "error" ? /* @__PURE__ */ jsxs("div", {
2317
- className: "flex items-center gap-2 px-4 py-3",
2456
+ className: "flex min-h-48 flex-col items-center justify-center gap-3",
2318
2457
  children: [/* @__PURE__ */ jsx("span", {
2319
2458
  role: "alert",
2320
- className: "text-sm text-po-red",
2459
+ className: "text-base text-po-red",
2321
2460
  children: state.error
2322
2461
  }), /* @__PURE__ */ jsx(Button, {
2323
- variant: "ghost",
2324
- size: "xs",
2462
+ variant: "outline",
2463
+ size: "sm",
2325
2464
  onClick: onRetry,
2326
- children: "retry"
2465
+ children: "Retry"
2327
2466
  })]
2328
- }) : state.diff.binary ? /* @__PURE__ */ jsx("p", {
2329
- className: "px-4 py-3 text-sm text-po-dim",
2330
- children: "binary file, not drawn"
2331
- }) : state.diff.tooLarge ? /* @__PURE__ */ jsx("p", {
2332
- className: "px-4 py-3 text-sm text-po-dim",
2333
- children: "this diff is too large to draw here"
2467
+ }) : state.diff.binary ? /* @__PURE__ */ jsx(EmptyState, {
2468
+ className: "min-h-48",
2469
+ title: "Binary file",
2470
+ description: `${entry.path} cannot be shown as a text diff.`
2471
+ }) : state.diff.tooLarge ? /* @__PURE__ */ jsx(EmptyState, {
2472
+ className: "min-h-48",
2473
+ title: "This diff is too large to show",
2474
+ description: "Other changed files are still available to review."
2334
2475
  }) : /* @__PURE__ */ jsx(DiffView, {
2335
2476
  hunks: state.diff.hunks,
2336
2477
  testId: `git-review-diff-${id}`,
2337
2478
  onSelect,
2338
- renderAfterRow,
2339
- className: "py-1"
2479
+ renderAfterRow
2340
2480
  })
2341
2481
  })]
2342
2482
  });
@@ -2371,6 +2511,7 @@ function reviewTab() {
2371
2511
  function GitReviewPanel({ sessionId, sendSessionFrame }) {
2372
2512
  const activity = useStore(gitChanges.store, (state) => gitChanges.select(state, sessionId));
2373
2513
  const comments = useStore(gitReview.store, (state) => gitReview.select(state, sessionId).comments);
2514
+ const focus = useStore(gitReview.store, (state) => gitReview.select(state, sessionId).focus);
2374
2515
  const [summary, setSummary] = useState({ state: "loading" });
2375
2516
  const [files, setFiles] = useState({});
2376
2517
  const [sendError, setSendError] = useState();
@@ -2465,6 +2606,7 @@ function GitReviewPanel({ sessionId, sendSessionFrame }) {
2465
2606
  if (failure === void 0) onSent?.();
2466
2607
  };
2467
2608
  return /* @__PURE__ */ jsx(GitReviewView, {
2609
+ ...focus === void 0 ? {} : { initialPath: focus.path },
2468
2610
  onDraftChange: (open) => setDraftSnapshot((current) => open ? current?.sessionId === sessionId ? current : {
2469
2611
  sessionId,
2470
2612
  fingerprint
@@ -2474,7 +2616,10 @@ function GitReviewPanel({ sessionId, sendSessionFrame }) {
2474
2616
  ...activity.pending === void 0 ? {} : { pending: activity.pending },
2475
2617
  ...error === void 0 ? {} : { error },
2476
2618
  ...activity.errorTarget === void 0 || error === void 0 ? {} : { errorTarget: activity.errorTarget },
2477
- onSync: (action) => requestGitSync(sessionId, action),
2619
+ onSync: (action) => {
2620
+ if (action === "abort-rebase" && !window.confirm("Abort rebase? This discards conflict resolution in progress.")) return;
2621
+ requestGitSync(sessionId, action);
2622
+ },
2478
2623
  onForcePush: () => requestGitSync(sessionId, "push", true),
2479
2624
  onAskAgent: () => send(conflictPrompt(branch, changes?.rebase?.conflicts ?? [])),
2480
2625
  onDismissError: () => setDismissedError(activity.error)
@@ -2488,16 +2633,37 @@ function GitReviewPanel({ sessionId, sendSessionFrame }) {
2488
2633
  onSendReview: () => send(buildReviewPrompt(comments, reviewHeading(comments.length, branch, base)), () => clearReviewComments(sessionId)),
2489
2634
  onDiscard: () => clearReviewComments(sessionId),
2490
2635
  ...sendError === void 0 ? {} : { sendError }
2491
- }, sessionId);
2636
+ }, `${sessionId}:${String(focus?.at ?? 0)}`);
2492
2637
  }
2493
2638
  //#endregion
2639
+ //#region src/extensions/workspaces/sessions/(frontend)/fill/GitReview.lint.finding-review.web.ts
2640
+ /** Lets code review findings open this checkout's diff review on their file. */
2641
+ var GitReview_lint_finding_review_web_default = defineFill({
2642
+ slot: "lint.finding-review",
2643
+ id: "git-review",
2644
+ data: {
2645
+ version: 1,
2646
+ label: "Open in review",
2647
+ open: (props, path) => {
2648
+ if (props.sessionId === null) return;
2649
+ focusReviewFile(props.sessionId, path);
2650
+ props.openTransientTab(reviewTab());
2651
+ }
2652
+ }
2653
+ });
2654
+ //#endregion
2655
+ //#region src/extensions/workspaces/sessions/(frontend)/fill/WorktreeCreate.overlay.web.tsx
2656
+ var WorktreeCreate_overlay_web_default = defineFill({ component: WorktreeCreateOverlay });
2657
+ //#endregion
2494
2658
  //#region src/extensions/workspaces/sessions/(frontend)/fill/_components/DiffActivitySection.tsx
2495
2659
  /**
2496
2660
  * The '# git' group's branch row: this session's code change against its base.
2497
2661
  *
2498
2662
  * DESIGN PATTERNS:
2499
- * - One lane, branch and `+A -R`. Files, base, upstream and a paused rebase live
2500
- * in the review tab's header, which this lane opens.
2663
+ * - One lane, branch and `+A -R`, straight on the group body like every other
2664
+ * activity group: the dock already draws the card, so no inner card or heading.
2665
+ * Files, base, upstream and a paused rebase live in the review tab's header,
2666
+ * which this lane opens.
2501
2667
  * - Stays clickable at zero, because the review tab is also where pull, push
2502
2668
  * and rebase live.
2503
2669
  * - Reads the focused session's checkout, whether it is a worktree or not.
@@ -2509,128 +2675,112 @@ function DiffActivitySection({ sessionId, openTransientTab }) {
2509
2675
  const session = useStore(gitChanges.store, (state) => gitChanges.select(state, sessionId));
2510
2676
  const changes = session.changes;
2511
2677
  if (sessionId === null || changes === void 0) return null;
2512
- const zero = changes.added === 0 && changes.removed === 0;
2513
- const against = changes.base === void 0 ? "uncommitted" : `vs ${changes.base}`;
2678
+ return /* @__PURE__ */ jsx(DiffActivityView, {
2679
+ changes,
2680
+ pending: session.pending,
2681
+ onReview: () => openTransientTab(reviewTab())
2682
+ });
2683
+ }
2684
+ function DiffActivityView({ changes, pending, onReview, branch }) {
2685
+ const zero = changes?.added === 0 && changes?.removed === 0;
2686
+ const against = changes?.base === void 0 ? "uncommitted" : `vs ${changes.base}`;
2514
2687
  return /* @__PURE__ */ jsxs("div", {
2515
- className: "flex min-w-0 items-center gap-2",
2688
+ className: "flex min-w-0 flex-col gap-1",
2516
2689
  children: [/* @__PURE__ */ jsxs(Button, {
2517
2690
  variant: "ghost",
2518
- size: "xs",
2691
+ size: "card",
2519
2692
  "data-testid": "activity-diff-changes",
2520
- "aria-label": `review ${changes.branch ?? "detached HEAD"} changes: ${String(changes.added)} added, ${String(changes.removed)} removed ${against}`,
2521
- title: `${String(changes.files)} ${changes.files === 1 ? "file" : "files"} ${against}`,
2522
- className: `h-auto min-w-0 flex-1 shrink gap-2 px-0 py-0.5 hover:bg-transparent ${zero ? "text-po-faint" : ""}`,
2523
- onClick: () => openTransientTab(reviewTab()),
2524
- children: [
2525
- /* @__PURE__ */ jsx("span", {
2526
- className: "min-w-0 flex-1 truncate text-left font-mono font-semibold text-po-hi",
2527
- children: changes.branch ?? "detached HEAD"
2528
- }),
2529
- /* @__PURE__ */ jsxs("span", {
2530
- className: zero ? "" : "text-po-green",
2693
+ className: "min-w-0 flex-row items-center gap-2 rounded-md px-1 py-1 font-normal hover:bg-po-panel",
2694
+ "aria-label": changes ? `review ${changes.branch ?? "detached HEAD"} changes: ${changes.added} added, ${changes.removed} removed ${against}` : "Changes not reported yet",
2695
+ title: changes ? `${changes.files} ${changes.files === 1 ? "file" : "files"} ${against}` : void 0,
2696
+ onClick: onReview,
2697
+ children: [/* @__PURE__ */ jsx("span", {
2698
+ className: "min-w-0 flex-1 truncate text-left font-mono text-sm text-po-hi",
2699
+ children: changes?.branch ?? branch ?? "detached HEAD"
2700
+ }), !changes || zero ? /* @__PURE__ */ jsx("span", {
2701
+ className: "shrink-0 text-sm text-po-dim",
2702
+ children: zero ? "No changes yet" : "Not reported yet"
2703
+ }) : /* @__PURE__ */ jsxs("span", {
2704
+ className: "flex shrink-0 gap-2 text-sm",
2705
+ children: [/* @__PURE__ */ jsxs("span", {
2706
+ className: "text-po-green",
2531
2707
  children: ["+", changes.added]
2532
- }),
2533
- /* @__PURE__ */ jsxs("span", {
2534
- className: zero ? "" : "text-po-red",
2708
+ }), /* @__PURE__ */ jsxs("span", {
2709
+ className: "text-po-red",
2535
2710
  children: ["-", changes.removed]
2536
- })
2537
- ]
2538
- }), session.pending === void 0 ? null : /* @__PURE__ */ jsxs("span", {
2539
- className: "flex min-w-0 items-center gap-1.5",
2711
+ })]
2712
+ })]
2713
+ }), pending && /* @__PURE__ */ jsxs("p", {
2714
+ className: "flex items-center gap-2 px-1 text-sm text-po-dim",
2540
2715
  children: [/* @__PURE__ */ jsx(Spinner, {
2541
- className: "h-3 w-3 shrink-0 text-po-faint",
2542
- label: session.pending
2716
+ className: "size-3",
2717
+ label: pending
2543
2718
  }), /* @__PURE__ */ jsx("span", {
2544
- className: "min-w-0 truncate text-sm text-po-dim",
2545
- children: session.pending
2719
+ className: "inline-block first-letter:uppercase",
2720
+ children: pending
2546
2721
  })]
2547
2722
  })]
2548
2723
  });
2549
2724
  }
2550
2725
  //#endregion
2551
2726
  //#region src/extensions/workspaces/sessions/(frontend)/fill/_components/WorktreesActivitySection.tsx
2552
- /**
2553
- * The '# git' group's body in the activity dock.
2554
- *
2555
- * DESIGN PATTERNS:
2556
- * - The focused checkout's branch and diff stay visible, even with no child worktrees.
2557
- * - One line per worktree, the same rule the runners rail follows: enough to
2558
- * notice it, not enough to work with it. The group's own name opens the tab
2559
- * that has room.
2560
- * - Idle still shows the launcher. A repository with no worktrees is the state
2561
- * where someone most wants to make one.
2562
- *
2563
- * AVOID:
2564
- * - Doing work here. This section reports and launches; the panel and the tool
2565
- * own everything else.
2566
- */
2567
2727
  function WorktreesActivitySection(props) {
2728
+ const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, props.sessionId));
2568
2729
  return /* @__PURE__ */ jsxs("div", {
2569
- className: "flex min-w-0 flex-col gap-2",
2570
- children: [/* @__PURE__ */ jsx(DiffActivitySection, { ...props }), /* @__PURE__ */ jsx(WorktreesSummary, { ...props })]
2730
+ className: "flex min-w-0 flex-col gap-1",
2731
+ children: [/* @__PURE__ */ jsx(DiffActivitySection, { ...props }), /* @__PURE__ */ jsx(WorktreesActivityView, {
2732
+ worktrees: session.worktrees.filter((w) => w.sessionId !== props.sessionId),
2733
+ pending: session.pending,
2734
+ onOpen: () => props.openTransientTab(worktreesTab()),
2735
+ onCreate: props.sessionId === null ? void 0 : () => worktreeCreateDialog.update(() => ({
2736
+ sessionId: props.sessionId,
2737
+ ...props.sessionReservationId === void 0 ? {} : { reservationId: props.sessionReservationId }
2738
+ }))
2739
+ })]
2571
2740
  });
2572
2741
  }
2573
- function WorktreesSummary({ sessionId, openTransientTab }) {
2574
- const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, sessionId));
2575
- const worktrees = session.worktrees.filter((worktree) => worktree.sessionId !== sessionId);
2576
- if (worktrees.length === 0 && session.pending === void 0) return /* @__PURE__ */ jsxs("div", {
2577
- className: "flex flex-wrap items-center gap-x-4 gap-y-1",
2578
- children: [/* @__PURE__ */ jsx("p", {
2579
- "data-testid": "activity-summary-git",
2580
- className: "text-sm text-po-dim",
2581
- children: "Idle"
2582
- }), sessionId === null ? null : /* @__PURE__ */ jsxs(Button, {
2742
+ function WorktreesActivityView({ worktrees, pending, onOpen, onCreate, startingIds = [] }) {
2743
+ return /* @__PURE__ */ jsxs("div", {
2744
+ className: "flex min-w-0 flex-col gap-1",
2745
+ children: [pending && /* @__PURE__ */ jsxs("p", {
2746
+ className: "flex items-center gap-2 px-1 text-sm text-po-dim",
2747
+ children: [/* @__PURE__ */ jsx(Spinner, {
2748
+ className: "size-3",
2749
+ label: pending
2750
+ }), /* @__PURE__ */ jsx("span", {
2751
+ className: "inline-block first-letter:uppercase",
2752
+ children: pending
2753
+ })]
2754
+ }), worktrees.length === 0 ? onCreate ? /* @__PURE__ */ jsxs(Button, {
2583
2755
  variant: "link",
2584
2756
  size: "sm",
2585
2757
  "data-testid": "activity-git-create",
2586
- className: "h-auto gap-1 px-0 text-po-green",
2587
- onClick: () => openTransientTab(worktreesTab()),
2758
+ className: "h-auto self-start gap-1 px-1 text-po-green",
2759
+ onClick: onCreate,
2588
2760
  children: ["Create a worktree", /* @__PURE__ */ jsx(ArrowRightIcon, {
2589
2761
  "aria-hidden": true,
2590
2762
  className: "size-3.5"
2591
2763
  })]
2764
+ }) : /* @__PURE__ */ jsx("span", {
2765
+ "data-testid": "activity-summary-git",
2766
+ className: "px-1 text-sm text-po-dim",
2767
+ children: "Idle"
2768
+ }) : /* @__PURE__ */ jsx("div", {
2769
+ "data-testid": "activity-git-worktrees",
2770
+ children: worktrees.map((w) => /* @__PURE__ */ jsx(Button, {
2771
+ variant: "ghost",
2772
+ size: "card",
2773
+ className: "block w-full min-w-0 p-0 text-left font-normal",
2774
+ "data-testid": `activity-git-worktree-${w.id}`,
2775
+ onClick: onOpen,
2776
+ children: /* @__PURE__ */ jsx(WorktreeRow, {
2777
+ compact: true,
2778
+ worktree: w,
2779
+ starting: startingIds.includes(w.id) || !!pending?.includes("starting") && w.sessionId === null && !w.orphaned && !w.unowned
2780
+ })
2781
+ }, w.id))
2592
2782
  })]
2593
2783
  });
2594
- return /* @__PURE__ */ jsxs("div", {
2595
- "data-testid": "activity-git-worktrees",
2596
- className: "flex flex-col gap-0.5",
2597
- children: [session.pending === void 0 ? null : /* @__PURE__ */ jsxs("span", {
2598
- className: "flex min-w-0 items-center gap-1.5 px-1",
2599
- children: [/* @__PURE__ */ jsx(Spinner, {
2600
- className: "h-3 w-3 shrink-0 text-po-faint",
2601
- label: session.pending
2602
- }), /* @__PURE__ */ jsx("span", {
2603
- className: "min-w-0 truncate text-sm text-po-dim",
2604
- children: session.pending
2605
- })]
2606
- }), worktrees.map((worktree) => /* @__PURE__ */ jsx(Button, {
2607
- variant: "ghost",
2608
- size: "card",
2609
- "data-testid": `activity-git-worktree-${worktree.id}`,
2610
- className: "min-w-0 gap-1.5 px-1",
2611
- onClick: () => openTransientTab(worktreesTab()),
2612
- children: /* @__PURE__ */ jsxs("span", {
2613
- className: "flex w-full min-w-0 items-center gap-1.5",
2614
- children: [
2615
- /* @__PURE__ */ jsx(Dot, { tone: worktree.orphaned ? "red" : worktree.sessionId === null ? "muted" : "blue" }),
2616
- /* @__PURE__ */ jsx("span", {
2617
- className: "min-w-0 flex-1 truncate text-left text-base font-semibold text-po-hi",
2618
- children: worktree.branch
2619
- }),
2620
- worktree.orphaned ? /* @__PURE__ */ jsx(StatusBadge, {
2621
- tone: "error",
2622
- size: "xs",
2623
- children: "orphaned"
2624
- }) : null,
2625
- worktree.unowned ? /* @__PURE__ */ jsx(StatusBadge, {
2626
- tone: "info",
2627
- size: "xs",
2628
- children: "unowned"
2629
- }) : null
2630
- ]
2631
- })
2632
- }, worktree.id))]
2633
- });
2634
2784
  }
2635
2785
  //#endregion
2636
2786
  //#region src/extensions/workspaces/sessions/(frontend)/fill/Worktrees.activity.git.web.tsx
@@ -2664,49 +2814,162 @@ function startGitRuntime(runtime) {
2664
2814
  var start_web_default = defineWebLifecycle(startGitRuntime);
2665
2815
  //#endregion
2666
2816
  //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/RunWorktreeToolMessage.tsx
2667
- const ACTION_LABEL = {
2668
- spawn_worktree: "Create worktree",
2669
- close_worktree: "Close worktree",
2670
- list: "List worktrees",
2671
- status: "Worktree status",
2672
- merge: "Merge worktree",
2673
- prune: "Prune worktrees",
2674
- send: "Message worktree",
2675
- messages: "Read worktree messages"
2817
+ const VERBS = {
2818
+ spawn_worktree: [
2819
+ "is creating",
2820
+ "created",
2821
+ "create"
2822
+ ],
2823
+ close_worktree: [
2824
+ "is closing",
2825
+ "closed",
2826
+ "close"
2827
+ ],
2828
+ list: [
2829
+ "is listing",
2830
+ "listed",
2831
+ "list"
2832
+ ],
2833
+ status: [
2834
+ "is checking",
2835
+ "checked",
2836
+ "check"
2837
+ ],
2838
+ merge: [
2839
+ "is merging",
2840
+ "merged",
2841
+ "merge"
2842
+ ],
2843
+ prune: [
2844
+ "is pruning",
2845
+ "pruned",
2846
+ "prune"
2847
+ ],
2848
+ send: [
2849
+ "is messaging",
2850
+ "messaged",
2851
+ "message"
2852
+ ],
2853
+ messages: [
2854
+ "is reading messages from",
2855
+ "read messages from",
2856
+ "read messages from"
2857
+ ]
2676
2858
  };
2677
- /**
2678
- * The timeline item for `run_worktree`.
2679
- *
2680
- * DESIGN PATTERNS:
2681
- * - Built on MessageItem, like every other tool renderer in the cockpit. That
2682
- * is what gives it the shared collapse toggle and the RUNNING/OK/ERROR badge
2683
- * rather than a hand-rolled ellipsis that never resolves.
2684
- * - The action and its subject go in the heading because that is what a reader
2685
- * scanning a transcript needs: "close_worktree a1b2c3d4" answers the question
2686
- * the raw JSON arguments make them decode.
2687
- * - A create takes as long as the cockpit needs to start a session, and the
2688
- * tool streams each phase into `output`, so the body is where the wait is
2689
- * visible.
2690
- */
2691
2859
  function RunWorktreeToolMessage({ args, output, running, isError }) {
2692
- const action = typeof args.action === "string" ? args.action : "";
2693
- const subject = typeof args.branch === "string" ? args.branch : typeof args.id === "string" ? args.id : "";
2694
- return /* @__PURE__ */ jsxs(MessageItem, {
2695
- tone: toolTone({
2696
- running,
2697
- isError
2698
- }),
2699
- expandable: output !== "",
2700
- children: [/* @__PURE__ */ jsx(MessageItemHeader, {
2701
- title: ACTION_LABEL[action] ?? "Worktree",
2702
- children: subject === "" ? null : /* @__PURE__ */ jsx("span", {
2703
- className: "min-w-0 truncate font-mono text-po-dim",
2704
- children: subject
2705
- })
2706
- }), output === "" ? null : /* @__PURE__ */ jsx(MessageItemBody, { children: /* @__PURE__ */ jsx("pre", {
2707
- className: `whitespace-pre-wrap font-mono text-sm ${isError ? "text-po-red" : "text-po-dim"}`,
2708
- children: output
2709
- }) })]
2860
+ return /* @__PURE__ */ jsx(RunWorktreeToolMessageView, {
2861
+ action: typeof args.action === "string" ? args.action : "",
2862
+ subject: typeof args.branch === "string" ? args.branch : typeof args.id === "string" ? args.id : "",
2863
+ output,
2864
+ running,
2865
+ isError
2866
+ });
2867
+ }
2868
+ function RunWorktreeToolMessageView({ action, subject = "", output = "", running = false, isError = false, defaultExpanded = false }) {
2869
+ const tone = running ? "neutral" : isError ? "error" : "ok";
2870
+ const verbs = VERBS[action] ?? [
2871
+ "is running",
2872
+ "finished",
2873
+ "run"
2874
+ ];
2875
+ const rows = action === "list" ? output.split("\n").map((line) => line.split(/\s{2,}/)).filter((parts) => parts.length >= 3) : [];
2876
+ const listingCount = output.match(/^(\d+) worktree/);
2877
+ return /* @__PURE__ */ jsx(MessageItem, {
2878
+ tone,
2879
+ expandable: true,
2880
+ defaultExpanded,
2881
+ className: "bg-po-panel",
2882
+ children: ({ expanded, toggle }) => /* @__PURE__ */ jsxs(Fragment, { children: [
2883
+ /* @__PURE__ */ jsxs("div", {
2884
+ className: "flex items-start gap-3 p-4",
2885
+ children: [/* @__PURE__ */ jsx("div", {
2886
+ className: "min-w-0 flex-1",
2887
+ children: /* @__PURE__ */ jsxs("p", {
2888
+ className: "text-base font-semibold leading-relaxed text-po-hi",
2889
+ children: [
2890
+ "Po ",
2891
+ isError && !running ? `could not ${verbs[2]}` : verbs[running ? 0 : 1],
2892
+ " ",
2893
+ action === "list" && !running && !isError ? `${listingCount?.[1] ?? rows.length} ${Number(listingCount?.[1] ?? rows.length) === 1 ? "worktree" : "worktrees"}` : subject ? /* @__PURE__ */ jsx("span", {
2894
+ className: "font-mono",
2895
+ children: subject
2896
+ }) : "worktrees",
2897
+ running ? "..." : isError && output ? `: ${output.split("\n")[0]}` : ""
2898
+ ]
2899
+ })
2900
+ }), /* @__PURE__ */ jsxs(StatusBadge, {
2901
+ tone,
2902
+ size: "xs",
2903
+ className: running ? "gap-1 bg-po-rail text-po-dim" : "",
2904
+ children: [running && /* @__PURE__ */ jsx(Spinner, {
2905
+ className: "size-3",
2906
+ label: "Running"
2907
+ }), running ? "Running" : isError ? "Failed" : "Completed"]
2908
+ })]
2909
+ }),
2910
+ /* @__PURE__ */ jsxs(Button, {
2911
+ variant: "ghost",
2912
+ size: "sm",
2913
+ onClick: toggle,
2914
+ "aria-expanded": expanded,
2915
+ className: "mb-2 ml-3 text-po-dim",
2916
+ children: ["Details ", expanded ? /* @__PURE__ */ jsx(ChevronUpIcon, { className: "size-3" }) : /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-3" })]
2917
+ }),
2918
+ expanded && /* @__PURE__ */ jsx(MessageItemBody, { children: rows.length > 0 && !isError ? /* @__PURE__ */ jsxs("table", {
2919
+ className: "w-full text-left text-sm",
2920
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", {
2921
+ className: "border-b border-po-border-soft",
2922
+ children: [
2923
+ /* @__PURE__ */ jsx("th", {
2924
+ className: "pb-2 font-medium",
2925
+ children: "Branch"
2926
+ }),
2927
+ /* @__PURE__ */ jsx("th", {
2928
+ className: "pb-2 font-medium",
2929
+ children: "Path"
2930
+ }),
2931
+ /* @__PURE__ */ jsx("th", {
2932
+ className: "pb-2 font-medium",
2933
+ children: "Status"
2934
+ })
2935
+ ]
2936
+ }) }), /* @__PURE__ */ jsx("tbody", { children: rows.map((parts, i) => {
2937
+ const real = parts.length >= 5;
2938
+ const status = parts[2];
2939
+ return /* @__PURE__ */ jsxs("tr", {
2940
+ className: "border-b border-po-border-soft",
2941
+ children: [
2942
+ /* @__PURE__ */ jsxs("td", {
2943
+ className: "py-3 pr-3 font-mono text-po-text",
2944
+ children: [real ? parts[1] : parts[0], real && /* @__PURE__ */ jsx("span", {
2945
+ className: "mt-1 block text-po-dim",
2946
+ children: parts[0]
2947
+ })]
2948
+ }),
2949
+ /* @__PURE__ */ jsx("td", {
2950
+ className: "py-3 pr-3 font-mono text-po-dim",
2951
+ children: real ? parts.slice(4).join(" ") : parts[1]
2952
+ }),
2953
+ /* @__PURE__ */ jsxs("td", { children: [/* @__PURE__ */ jsx(StatusBadge, {
2954
+ tone: status === "orphaned" ? "neutral" : status === "unowned" ? "info" : "ok",
2955
+ size: "xs",
2956
+ className: status === "orphaned" ? "bg-po-tint-yellow text-po-yellow" : "",
2957
+ children: /* @__PURE__ */ jsx("span", {
2958
+ className: "inline-block first-letter:uppercase",
2959
+ children: status
2960
+ })
2961
+ }), real && /* @__PURE__ */ jsx("span", {
2962
+ className: "ml-2 text-po-dim",
2963
+ children: parts[3]
2964
+ })] })
2965
+ ]
2966
+ }, i);
2967
+ }) })]
2968
+ }) : /* @__PURE__ */ jsx("pre", {
2969
+ className: `whitespace-pre-wrap font-mono text-sm ${isError ? "text-po-red" : "text-po-dim"}`,
2970
+ children: output
2971
+ }) })
2972
+ ] })
2710
2973
  });
2711
2974
  }
2712
2975
  //#endregion
@@ -2720,6 +2983,7 @@ const via = (identity, value) => value === void 0 ? void 0 : {
2720
2983
  };
2721
2984
  const webPlugin = defineWebPlugin({
2722
2985
  id: "git",
2986
+ packageName: "@agimon-ai/po-git",
2723
2987
  workspace: {
2724
2988
  get fills() {
2725
2989
  return [via({
@@ -2741,9 +3005,9 @@ const webPlugin = defineWebPlugin({
2741
3005
  get fills() {
2742
3006
  return [
2743
3007
  via({
2744
- slot: "session-menu",
2745
- id: "worktree"
2746
- }, Worktree_session_menu_web_default),
3008
+ slot: "lint.finding-review",
3009
+ id: "git-review"
3010
+ }, GitReview_lint_finding_review_web_default),
2747
3011
  via({
2748
3012
  slot: "overlay",
2749
3013
  id: "worktree-create"