@agimon-ai/po-git 0.0.0-alpha.2 → 0.0.0-alpha.200

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.
Files changed (37) hide show
  1. package/LICENSE +97 -8
  2. package/README.md +91 -21
  3. package/dist/apiContracts.cjs +82 -16
  4. package/dist/apiContracts.cjs.map +1 -1
  5. package/dist/apiContracts.d.mts +2 -2
  6. package/dist/apiContracts.d.mts.map +1 -1
  7. package/dist/apiContracts.mjs +82 -16
  8. package/dist/apiContracts.mjs.map +1 -1
  9. package/dist/extensions/native.mjs +2255 -544
  10. package/dist/extensions/native.mjs.map +1 -1
  11. package/dist/extensions/server.cjs +1562 -514
  12. package/dist/extensions/server.cjs.map +1 -1
  13. package/dist/extensions/server.d.mts +2 -2
  14. package/dist/extensions/server.d.mts.map +1 -1
  15. package/dist/extensions/server.mjs +1525 -477
  16. package/dist/extensions/server.mjs.map +1 -1
  17. package/dist/extensions/web.mjs +1761 -1388
  18. package/dist/extensions/web.mjs.map +1 -1
  19. package/dist/gitDependencies-D8bKxZSc.cjs +2690 -0
  20. package/dist/gitDependencies-D8bKxZSc.cjs.map +1 -0
  21. package/dist/gitDependencies-Delu4xip.mjs +2432 -0
  22. package/dist/gitDependencies-Delu4xip.mjs.map +1 -0
  23. package/dist/index.cjs +13 -22
  24. package/dist/index.d.mts +266 -14
  25. package/dist/index.d.mts.map +1 -1
  26. package/dist/index.mjs +3 -22
  27. package/dist/po-runtime-identity.json +1 -0
  28. package/llms.txt +3 -3
  29. package/package.json +104 -26
  30. package/src/prompts/codemode-how-to-git/SKILL.md +137 -0
  31. package/dist/index.cjs.map +0 -1
  32. package/dist/index.mjs.map +0 -1
  33. package/dist/worktreeOperations-CaqwGsD_.mjs +0 -1065
  34. package/dist/worktreeOperations-CaqwGsD_.mjs.map +0 -1
  35. package/dist/worktreeOperations-MgIVDDu3.cjs +0 -1221
  36. package/dist/worktreeOperations-MgIVDDu3.cjs.map +0 -1
  37. package/src/prompts/po-use-git/SKILL.md +0 -87
@@ -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, t, useT } 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, SearchIcon, 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,41 @@ 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
+ /** Full checkout is explicit; a locked default remains visible even if absent from the catalog. */
75
+ function sparseOptions(branches) {
76
+ return [.../* @__PURE__ */ new Set([
77
+ "full",
78
+ ...branches.sparseProfiles ?? [],
79
+ ...branches.defaultSparseProfile === void 0 ? [] : [branches.defaultSparseProfile]
80
+ ])];
81
+ }
82
+ /** The last segment of a path: enough to name a checkout without spelling out where it lives. */
83
+ function folderName(path) {
84
+ return path.split(/[\\/]/).filter((part) => part !== "").pop() ?? path;
85
+ }
86
+ /** Where a busy branch is checked out, short enough for one line. */
87
+ function busyNote(t, busyAt, workspaceRoot) {
88
+ return busyAt === workspaceRoot ? t("git.ui.checkedOutHere", "Checked out here") : t("git.branch.checkedOutIn", "Checked out in {folder}", { folder: folderName(busyAt) });
89
+ }
90
+ /**
91
+ * Local branches a session can take, then the checked-out ones, then remote-only ones, filtered by a
92
+ * case-insensitive substring.
93
+ */
61
94
  function branchOptions(branches, query) {
62
95
  const needle = query.trim().toLowerCase();
63
96
  const matches = (text) => needle === "" || text.toLowerCase().includes(needle);
@@ -66,7 +99,7 @@ function branchOptions(branches, query) {
66
99
  name: branch.name,
67
100
  current: branch.name === branches.current,
68
101
  ...branch.checkedOutAt === void 0 ? {} : { busyAt: branch.checkedOutAt }
69
- }));
102
+ })).sort((a, b) => Number(a.busyAt !== void 0) - Number(b.busyAt !== void 0));
70
103
  const remote = branches.remote.filter((branch) => matches(`${branch.remote}/${branch.name}`)).map((branch) => ({
71
104
  key: `remote:${branch.remote}/${branch.name}`,
72
105
  name: branch.name,
@@ -84,17 +117,27 @@ function baseOptions(branches) {
84
117
  ])];
85
118
  }
86
119
  /** Why the form cannot be submitted yet, or undefined when it can. */
87
- function formProblem$1(state) {
120
+ function formProblem$1(t, state) {
88
121
  if (state.mode === "existing") {
89
- if (state.selected === void 0) return "Pick a branch.";
90
- if (state.selected.busyAt !== void 0) return `That branch is checked out at ${state.selected.busyAt}.`;
122
+ if (state.selected === void 0) return t("git.ui.pickABranch", "Pick a branch.");
123
+ if (state.selected.busyAt !== void 0) return t("git.branch.busyAt", "That branch is checked out at {path}.", { path: state.selected.busyAt });
91
124
  }
92
- if (state.mode === "new" && state.newBranch.trim() === "") return "Name the new branch.";
125
+ if (state.mode === "new" && state.newBranch.trim() === "") return t("git.ui.nameTheNewBranch", "Name the new branch.");
126
+ }
127
+ /** The launch profile choice for any session kind, or undefined when none was made. */
128
+ function launchSelection(state) {
129
+ return state.profile === void 0 ? void 0 : { profile: state.profile };
93
130
  }
94
131
  /** The worktree create request for the form, or undefined in plain mode. */
95
- function createRequest(state) {
132
+ function createRequest(state, branches) {
96
133
  const name = state.name.trim();
97
- const named = name === "" ? {} : { name };
134
+ const chosen = launchSelection(state);
135
+ const sparseProfile = branches?.defaultSparseProfile ?? state.sparseProfile;
136
+ const named = {
137
+ ...sparseProfile === void 0 ? {} : { sparseProfile },
138
+ ...name === "" ? {} : { name },
139
+ ...chosen === void 0 ? {} : { selection: chosen }
140
+ };
98
141
  if (state.mode === "existing" && state.selected !== void 0) return {
99
142
  mode: "existing-branch",
100
143
  branch: state.selected.name,
@@ -113,22 +156,342 @@ function createRequest(state) {
113
156
  }
114
157
  //#endregion
115
158
  //#region src/extensions/workspaces/(frontend)/fill/_components/GitNewSessionDialog.tsx
116
- const MODES = [
117
- {
159
+ function Field$1({ label, children }) {
160
+ return /* @__PURE__ */ jsxs("label", {
161
+ className: "flex flex-col gap-2 text-base text-po-text",
162
+ children: [/* @__PURE__ */ jsx("span", { children: label }), children]
163
+ });
164
+ }
165
+ /** Inline presentation also lets story capture inspect content, rather than a portal-only root. */
166
+ function GitNewSessionDialogView({ workspaceRoot, branches, loadError = "", initialForm, busy = false, error = "", riftMissing = false, profileCatalog, sparseCheckout, onClose, onCreate, onDeleteBranch, onOpenBranchFolder }) {
167
+ const t = useT();
168
+ const [form, setForm] = useState({
118
169
  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
- ];
170
+ newBranch: "",
171
+ baseRef: branches?.defaultBase ?? "",
172
+ name: "",
173
+ ...initialForm
174
+ });
175
+ const [query, setQuery] = useState("");
176
+ const [deleting, setDeleting] = useState();
177
+ const ready = branches?.repository === true && loadError === "";
178
+ const loading = branches === null && loadError === "";
179
+ const mode = ready || loading ? form.mode : "plain";
180
+ const state = {
181
+ ...form,
182
+ mode,
183
+ baseRef: form.baseRef || branches?.defaultBase || ""
184
+ };
185
+ const problem = formProblem$1(t, state);
186
+ const update = (patch) => setForm((current) => ({
187
+ ...current,
188
+ ...patch
189
+ }));
190
+ const options = branches === null ? [] : branchOptions(branches, query);
191
+ const bases = branches === null ? [] : baseOptions(branches);
192
+ const submit = () => {
193
+ if (!busy && !loading && deleting === void 0 && problem === void 0) onCreate(state);
194
+ };
195
+ return /* @__PURE__ */ jsxs("section", {
196
+ "data-testid": "new-session-dialog",
197
+ "aria-label": t("git.ui.newSession", "New session"),
198
+ className: "shrink-0 overflow-hidden rounded-lg border border-po-border bg-po-panel shadow-sm",
199
+ children: [
200
+ /* @__PURE__ */ jsxs("header", {
201
+ className: "border-b border-po-border-soft px-6 py-4",
202
+ children: [/* @__PURE__ */ jsx("h3", {
203
+ className: "text-xl font-semibold text-po-hi",
204
+ children: t("git.ui.newSession", "New session")
205
+ }), /* @__PURE__ */ jsx("p", {
206
+ className: "mt-1 font-mono text-sm text-po-dim",
207
+ title: workspaceRoot,
208
+ children: folderName(workspaceRoot)
209
+ })]
210
+ }),
211
+ /* @__PURE__ */ jsxs("div", {
212
+ className: "flex flex-col gap-5 p-6",
213
+ children: [
214
+ !ready ? /* @__PURE__ */ jsx("p", {
215
+ "data-testid": "git-new-session-plain-note",
216
+ className: "text-base text-po-dim",
217
+ children: loading ? t("git.ui.readingBranchesPending", "Reading branches...") : loadError || t("git.ui.thisWorkspaceIsNotAGitCheckoutStartAPlainSessionInThisFolder", "This workspace is not a git checkout. Start a plain session in this folder.")
218
+ }) : /* @__PURE__ */ jsxs(Tabs, {
219
+ value: mode,
220
+ onValueChange: (value) => update({ mode: value }),
221
+ className: "flex flex-col gap-5",
222
+ children: [
223
+ /* @__PURE__ */ jsxs(TabsList, {
224
+ "aria-label": t("git.ui.sessionKind", "Session kind"),
225
+ className: "rounded-md border border-po-border-soft bg-po-bg p-1",
226
+ children: [
227
+ /* @__PURE__ */ jsx(TabsTrigger, {
228
+ "data-testid": "git-new-session-mode-existing",
229
+ value: "existing",
230
+ disabled: busy,
231
+ className: "flex-1 justify-center",
232
+ children: t("git.ui.existingBranch", "Existing branch")
233
+ }),
234
+ /* @__PURE__ */ jsx(TabsTrigger, {
235
+ "data-testid": "git-new-session-mode-new",
236
+ value: "new",
237
+ disabled: busy,
238
+ className: "flex-1 justify-center",
239
+ children: t("git.ui.newBranch", "New branch")
240
+ }),
241
+ /* @__PURE__ */ jsx(TabsTrigger, {
242
+ "data-testid": "git-new-session-mode-plain",
243
+ value: "plain",
244
+ disabled: busy,
245
+ className: "flex-1 justify-center",
246
+ children: t("git.ui.noBranch", "No branch")
247
+ })
248
+ ]
249
+ }),
250
+ /* @__PURE__ */ jsxs(TabsContent, {
251
+ value: "existing",
252
+ className: "flex flex-col gap-2",
253
+ children: [
254
+ /* @__PURE__ */ jsx("p", {
255
+ className: "text-base font-medium",
256
+ children: t("git.ui.branch", "Branch")
257
+ }),
258
+ /* @__PURE__ */ jsx(Input, {
259
+ "data-testid": "git-new-session-branch-search",
260
+ "aria-label": t("git.ui.findABranch", "Find a branch"),
261
+ placeholder: t("git.ui.findABranch", "Find a branch"),
262
+ value: query,
263
+ onChange: (event) => setQuery(event.target.value),
264
+ disabled: busy
265
+ }),
266
+ /* @__PURE__ */ jsxs("fieldset", {
267
+ "aria-label": t("git.ui.branches", "Branches"),
268
+ className: "max-h-64 min-w-0 overflow-y-auto rounded-md border border-po-border-soft bg-po-bg p-1",
269
+ children: [options.length === 0 ? /* @__PURE__ */ jsx("p", {
270
+ className: "px-3 py-2 text-sm text-po-dim",
271
+ children: t("git.ui.noMatchingBranches", "No matching branches")
272
+ }) : null, options.map((branch, index) => /* @__PURE__ */ jsxs("div", { children: [branch.remote !== void 0 && (index === 0 || options[index - 1]?.remote === void 0) ? /* @__PURE__ */ jsx("p", {
273
+ className: "mt-1 border-t border-po-border-soft px-3 pt-2 text-sm text-po-dim",
274
+ children: t("git.ui.remoteBranches", "Remote branches")
275
+ }) : null, /* @__PURE__ */ jsxs("div", {
276
+ className: "flex min-w-0 items-start gap-1",
277
+ children: [/* @__PURE__ */ jsxs("button", {
278
+ "data-testid": "git-new-session-branch-option",
279
+ "data-branch": branch.name,
280
+ "data-remote": branch.remote,
281
+ "aria-pressed": form.selected?.key === branch.key,
282
+ disabled: branch.busyAt !== void 0 || busy,
283
+ onClick: () => update({ selected: branch }),
284
+ 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"}`,
285
+ children: [/* @__PURE__ */ jsxs("span", {
286
+ className: "flex items-center justify-between gap-2",
287
+ children: [/* @__PURE__ */ jsx("span", {
288
+ className: "font-mono break-all",
289
+ children: branch.remote === void 0 ? branch.name : `${branch.remote}/${branch.name}`
290
+ }), form.selected?.key === branch.key ? /* @__PURE__ */ jsx(CheckIcon, { className: "size-4 shrink-0" }) : null]
291
+ }), branch.busyAt !== void 0 ? /* @__PURE__ */ jsx("span", {
292
+ className: "truncate text-sm text-po-dim",
293
+ title: branch.busyAt,
294
+ children: busyNote(t, branch.busyAt, workspaceRoot)
295
+ }) : branch.current ? /* @__PURE__ */ jsx("span", {
296
+ className: "text-sm text-po-dim",
297
+ children: t("git.ui.current", "Current")
298
+ }) : null]
299
+ }), /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
300
+ asChild: true,
301
+ children: /* @__PURE__ */ jsx(Button, {
302
+ variant: "ghost",
303
+ size: "icon-md",
304
+ className: "mt-1",
305
+ "aria-label": t("git.branch.actionsFor", "Actions for {branch}", { branch: branch.remote === void 0 ? branch.name : `${branch.remote}/${branch.name}` }),
306
+ disabled: busy,
307
+ children: /* @__PURE__ */ jsx(KebabIcon, { className: "size-4" })
308
+ })
309
+ }), /* @__PURE__ */ jsxs(DropdownMenuContent, { children: [
310
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
311
+ disabled: branch.busyAt === void 0 || onOpenBranchFolder === void 0,
312
+ title: branch.busyAt === void 0 ? t("git.ui.thisBranchHasNoCheckedOutFolder", "This branch has no checked-out folder.") : branch.busyAt,
313
+ onSelect: () => onOpenBranchFolder?.(branch.name),
314
+ children: [/* @__PURE__ */ jsx(FolderIcon, { className: "size-4" }), t("git.ui.openInFinder", "Open in Finder")]
315
+ }),
316
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
317
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
318
+ variant: "destructive",
319
+ disabled: branch.remote !== void 0 || branch.busyAt !== void 0 || branch.current || onDeleteBranch === void 0,
320
+ title: branch.remote !== void 0 ? t("git.ui.onlyLocalBranchesCanBeDeletedHere", "Only local branches can be deleted here.") : branch.busyAt !== void 0 || branch.current ? t("git.ui.closeThisBranchSWorktreeBeforeDeletingIt", "Close this branch’s worktree before deleting it.") : void 0,
321
+ onSelect: () => setDeleting(branch),
322
+ children: [/* @__PURE__ */ jsx(TrashIcon, { className: "size-4" }), t("git.ui.deleteBranch", "Delete branch")]
323
+ })
324
+ ] })] })]
325
+ })] }, branch.key))]
326
+ }),
327
+ deleting !== void 0 ? /* @__PURE__ */ jsxs("fieldset", {
328
+ "aria-label": t("git.ui.confirmBranchDeletion", "Confirm branch deletion"),
329
+ className: "flex flex-col gap-3 rounded-md border border-po-edge-red bg-po-tint-red p-3",
330
+ children: [/* @__PURE__ */ jsxs("p", {
331
+ className: "text-sm text-po-text",
332
+ children: [
333
+ t("git.ui.deleteLocalBranch", "Delete local branch"),
334
+ " ",
335
+ /* @__PURE__ */ jsx("span", {
336
+ className: "font-mono break-all",
337
+ children: deleting.name
338
+ }),
339
+ t("git.ui.gitWillRefuseIfItContainsUnmergedCommitsNoWorktreeOrRemoteBranchWillBeRemoved", "? Git will refuse if it contains unmerged commits. No worktree or remote branch will be removed.")
340
+ ]
341
+ }), /* @__PURE__ */ jsxs("div", {
342
+ className: "flex justify-end gap-2",
343
+ children: [/* @__PURE__ */ jsx(Button, {
344
+ variant: "ghost",
345
+ disabled: busy,
346
+ onClick: () => setDeleting(void 0),
347
+ children: t("git.ui.cancelDeletion", "Cancel deletion")
348
+ }), /* @__PURE__ */ jsx(Button, {
349
+ variant: "danger-outline",
350
+ disabled: busy,
351
+ onClick: async () => {
352
+ if (busy || onDeleteBranch === void 0) return;
353
+ if (await onDeleteBranch(deleting.name)) {
354
+ if (form.selected?.key === deleting.key) update({ selected: void 0 });
355
+ setDeleting(void 0);
356
+ }
357
+ },
358
+ children: t("git.ui.deleteBranch", "Delete branch")
359
+ })]
360
+ })]
361
+ }) : null
362
+ ]
363
+ }),
364
+ /* @__PURE__ */ jsxs(TabsContent, {
365
+ value: "new",
366
+ className: "flex flex-col gap-4",
367
+ children: [/* @__PURE__ */ jsx(Field$1, {
368
+ label: t("git.ui.branchName", "Branch name"),
369
+ children: /* @__PURE__ */ jsx(Input, {
370
+ "data-testid": "git-new-session-new-branch",
371
+ "aria-label": t("git.ui.branchName", "Branch name"),
372
+ placeholder: "feature/my-change",
373
+ className: "font-mono",
374
+ value: form.newBranch,
375
+ onChange: (event) => update({ newBranch: event.target.value }),
376
+ disabled: busy
377
+ })
378
+ }), /* @__PURE__ */ jsx(Field$1, {
379
+ label: t("git.ui.from", "From"),
380
+ children: /* @__PURE__ */ jsxs(Select, {
381
+ value: form.baseRef || branches?.defaultBase || "",
382
+ onValueChange: (baseRef) => update({ baseRef }),
383
+ disabled: busy,
384
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
385
+ "data-testid": "git-new-session-base",
386
+ "aria-label": t("git.ui.from", "From"),
387
+ className: "font-mono",
388
+ children: /* @__PURE__ */ jsx(SelectValue, {})
389
+ }), /* @__PURE__ */ jsx(SelectContent, { children: bases.map((base) => /* @__PURE__ */ jsx(SelectItem, {
390
+ value: base,
391
+ children: base
392
+ }, base)) })]
393
+ })
394
+ })]
395
+ }),
396
+ /* @__PURE__ */ jsx(TabsContent, {
397
+ value: "plain",
398
+ children: /* @__PURE__ */ jsx("p", {
399
+ className: "text-base text-po-dim",
400
+ children: t("git.ui.startInThisWorkspaceFolderWithoutCreatingAWorktree", "Start in this workspace folder, without creating a worktree.")
401
+ })
402
+ })
403
+ ]
404
+ }),
405
+ /* @__PURE__ */ jsx(Field$1, {
406
+ label: /* @__PURE__ */ jsxs(Fragment, { children: [
407
+ t("git.ui.name", "Name"),
408
+ " ",
409
+ /* @__PURE__ */ jsx("span", {
410
+ className: "text-sm text-po-dim",
411
+ children: mode === "plain" ? t("git.ui.optionalHint", "(optional)") : t("git.ui.hintoptionalDefaultsToTheBranch", "(optional, defaults to the branch)")
412
+ })
413
+ ] }),
414
+ children: /* @__PURE__ */ jsx(Input, {
415
+ "data-testid": "new-session-name",
416
+ "aria-label": t("git.ui.sessionName", "Session name"),
417
+ placeholder: t("git.ui.sessionName", "Session name"),
418
+ value: form.name,
419
+ onChange: (event) => update({ name: event.target.value }),
420
+ onKeyDown: (event) => {
421
+ if (event.key === "Enter") submit();
422
+ },
423
+ disabled: busy
424
+ })
425
+ }),
426
+ mode !== "plain" && sparseCheckout !== void 0 ? /* @__PURE__ */ jsxs(Field$1, {
427
+ label: t("git.ui.sparseCheckout", "Sparse checkout"),
428
+ children: [/* @__PURE__ */ jsxs(Select, {
429
+ value: sparseCheckout.defaultSparseProfile ?? form.sparseProfile ?? "full",
430
+ onValueChange: (sparseProfile) => update({ sparseProfile }),
431
+ disabled: busy || sparseCheckout.defaultSparseProfile !== void 0,
432
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
433
+ "aria-label": t("git.ui.sparseCheckout", "Sparse checkout"),
434
+ children: /* @__PURE__ */ jsx(SelectValue, {})
435
+ }), /* @__PURE__ */ jsx(SelectContent, { children: sparseOptions(sparseCheckout).map((profile) => /* @__PURE__ */ jsx(SelectItem, {
436
+ value: profile,
437
+ children: profile === "full" ? t("git.ui.fullCheckout", "Full checkout") : profile
438
+ }, profile)) })]
439
+ }), sparseCheckout.defaultSparseProfile === void 0 ? null : /* @__PURE__ */ jsx("span", {
440
+ className: "text-sm text-po-dim",
441
+ children: t("git.ui.workspaceSparseDefault", "Set by this workspace")
442
+ })]
443
+ }) : null,
444
+ profileCatalog === void 0 ? null : /* @__PURE__ */ jsx(ProfilePicker, {
445
+ profiles: profileCatalog.profiles,
446
+ status: profileCatalog.status,
447
+ value: form.profile,
448
+ onChange: (profile) => update({ profile }),
449
+ disabled: busy
450
+ }),
451
+ mode !== "plain" ? /* @__PURE__ */ jsx("p", {
452
+ "data-testid": "new-session-hint",
453
+ className: "text-sm leading-relaxed text-po-dim",
454
+ children: (loading ? void 0 : problem) ?? t("git.ui.runsInItsOwnWorktreeSoThisCheckoutStaysAsItIs", "Runs in its own worktree, so this checkout stays as it is.")
455
+ }) : null,
456
+ riftMissing ? /* @__PURE__ */ jsxs("div", {
457
+ "data-testid": "rift-install-notice",
458
+ role: "alert",
459
+ 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",
460
+ children: [/* @__PURE__ */ jsx("p", { children: t("git.ui.thisRepositoryUsesRiftAndItsCLIIsNotInstalledHereRunTheseInTheRepositoryRootThenTryAgain", "This repository uses Rift, and its CLI is not installed here. Run these in the repository root, then try again.") }), /* @__PURE__ */ jsx(CodeBlock, {
461
+ text: `${RIFT_INSTALL_COMMAND}
462
+ rift init`,
463
+ className: "language-bash"
464
+ })]
465
+ }) : error ? /* @__PURE__ */ jsx("p", {
466
+ "data-testid": "new-session-error",
467
+ role: "alert",
468
+ className: "rounded-md border border-po-edge-red bg-po-tint-red p-3 text-sm text-po-red",
469
+ children: error
470
+ }) : null
471
+ ]
472
+ }),
473
+ /* @__PURE__ */ jsxs("footer", {
474
+ className: "flex items-center justify-between border-t border-po-border-soft px-6 py-4",
475
+ children: [/* @__PURE__ */ jsx(Button, {
476
+ "data-testid": "new-session-cancel",
477
+ variant: "ghost",
478
+ disabled: busy,
479
+ onClick: onClose,
480
+ children: t("git.ui.cancel", "Cancel")
481
+ }), /* @__PURE__ */ jsx(Button, {
482
+ "data-testid": "new-session-create",
483
+ variant: "primary",
484
+ title: problem,
485
+ disabled: busy || loading || deleting !== void 0 || problem !== void 0,
486
+ onClick: submit,
487
+ children: busy ? mode === "plain" ? t("git.ui.creatingSessionPending", "Creating session...") : t("git.ui.creatingWorktreePending", "Creating worktree...") : riftMissing ? t("git.ui.tryAgain", "Try again") : t("git.ui.createSession", "Create session")
488
+ })]
489
+ })
490
+ ]
491
+ });
492
+ }
130
493
  function errorOf$1(body, status) {
131
- return typeof body === "object" && body !== null && typeof body.error === "string" ? body.error : `The cockpit answered ${String(status)}.`;
494
+ return typeof body === "object" && body !== null && typeof body.error === "string" ? body.error : t("git.request.status", "The cockpit answered {status}.", { status });
132
495
  }
133
496
  /**
134
497
  * The new-session dialog when git is installed: a worktree on an existing or a
@@ -136,234 +499,115 @@ function errorOf$1(body, status) {
136
499
  * starts at the top level of the rail, with no parent.
137
500
  */
138
501
  function GitNewSessionDialog({ newSession }) {
502
+ const t = useT();
139
503
  const [branches, setBranches] = useState(null);
140
504
  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
505
  const [error, setError] = useState("");
506
+ const [riftMissing, setRiftMissing] = useState(false);
149
507
  const [busy, setBusy] = useState(false);
150
508
  const workspaceId = newSession?.workspaceId;
151
- const request = newSession?.requestWithStepUp;
509
+ const request = useEffectEvent((input) => newSession?.requestWithStepUp(input));
510
+ const profileCatalog = useProfileCatalog(workspaceId ?? "", newSession?.loadProfiles);
152
511
  useEffect(() => {
153
- if (workspaceId === void 0 || request === void 0) return;
512
+ if (workspaceId === void 0) return;
154
513
  let stale = false;
155
514
  const url = api.workspace(workspaceId).branches.url();
156
- request(url).then(async (response) => {
515
+ request(url)?.then(async (response) => {
157
516
  const body = await response.json().catch(() => void 0);
158
517
  if (stale) return;
159
518
  if (!response.ok) {
160
519
  setLoadError(errorOf$1(body, response.status));
161
520
  return;
162
521
  }
163
- const loaded = body;
164
- setBranches(loaded);
165
- setForm((current) => ({
166
- ...current,
167
- baseRef: loaded.defaultBase ?? ""
168
- }));
522
+ setBranches(body);
169
523
  }).catch(() => {
170
- if (!stale) setLoadError("The branches could not be loaded.");
524
+ if (!stale) setLoadError(t("git.ui.theBranchesCouldNotBeLoaded", "The branches could not be loaded."));
171
525
  });
172
526
  return () => {
173
527
  stale = true;
174
528
  };
175
- }, [workspaceId, request]);
529
+ }, [workspaceId, t]);
176
530
  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;
531
+ const submit = async (state) => {
532
+ if (busy || formProblem$1(t, state) !== void 0) return;
192
533
  setBusy(true);
193
534
  setError("");
535
+ setRiftMissing(false);
194
536
  const body = createRequest(state);
195
537
  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);
538
+ try {
539
+ if (body === void 0) failure = await newSession.createPlain(state.name, launchSelection(state));
540
+ else {
541
+ const response = await newSession.requestWithStepUp(api.workspace(newSession.workspaceId).createSession.url(), {
542
+ method: "POST",
543
+ headers: { "Content-Type": "application/json" },
544
+ body: JSON.stringify(body)
545
+ });
546
+ const answer = await response.json().catch(() => void 0);
547
+ failure = response.ok ? await newSession.openCreated(answer.sessionId) : errorOf$1(answer, response.status);
548
+ setRiftMissing(!response.ok && answer?.code === "rift_missing");
549
+ }
205
550
  } catch {
206
- failure = "The cockpit is unreachable.";
551
+ failure = t("git.ui.theCockpitIsUnreachable", "The cockpit is unreachable.");
207
552
  }
208
553
  if (failure === void 0) return;
209
554
  setError(failure);
210
555
  setBusy(false);
211
556
  };
557
+ const branchAction = async (branch, action) => {
558
+ if (busy) return false;
559
+ setBusy(true);
560
+ setError("");
561
+ setRiftMissing(false);
562
+ try {
563
+ const workspace = api.workspace(newSession.workspaceId);
564
+ const response = await newSession.requestWithStepUp(action === "delete" ? workspace.deleteBranch.url() : workspace.openBranchFolder.url(), {
565
+ method: action === "delete" ? "DELETE" : "POST",
566
+ headers: { "Content-Type": "application/json" },
567
+ body: JSON.stringify({ branch })
568
+ });
569
+ const body = await response.json().catch(() => void 0);
570
+ if (!response.ok) {
571
+ setError(errorOf$1(body, response.status));
572
+ return false;
573
+ }
574
+ if (action === "delete") setBranches((current) => current === null ? null : {
575
+ ...current,
576
+ local: current.local.filter((item) => item.name !== branch)
577
+ });
578
+ return true;
579
+ } catch {
580
+ setError(t("git.ui.theCockpitIsUnreachable", "The cockpit is unreachable."));
581
+ return false;
582
+ } finally {
583
+ setBusy(false);
584
+ }
585
+ };
212
586
  return /* @__PURE__ */ jsx(Dialog, {
213
587
  open: true,
214
- onOpenChange: (next) => !next && !busy && newSession.close(),
588
+ onOpenChange: (next) => {
589
+ if (!next && !busy) newSession.close();
590
+ },
215
591
  children: /* @__PURE__ */ jsxs(DialogContent, {
216
592
  width: "md",
217
- "data-testid": "new-session-dialog",
593
+ className: "overflow-y-auto p-0",
218
594
  "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-doom-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-doom-blue/60 text-doom-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-doom-dim",
242
- children: "reading branches…"
243
- }) : /* @__PURE__ */ jsx("p", {
244
- "data-testid": "git-new-session-plain-note",
245
- className: "text-sm text-doom-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-doom-border bg-doom-deep p-1",
262
- children: [options.length === 0 ? /* @__PURE__ */ jsx("p", {
263
- className: "px-2 py-1 text-sm text-doom-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-doom-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-doom-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-doom-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-doom-dim",
326
- children: ["name ", /* @__PURE__ */ jsxs("span", {
327
- className: "text-doom-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-doom-edge-red bg-doom-tint-red/40 px-2.5 py-2 text-sm whitespace-pre-wrap text-doom-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
- ] })]
595
+ children: [/* @__PURE__ */ jsx(DialogTitle, {
596
+ className: "sr-only",
597
+ children: t("git.ui.newSession", "New session")
598
+ }), /* @__PURE__ */ jsx(GitNewSessionDialogView, {
599
+ workspaceRoot: newSession.workspaceRoot,
600
+ branches,
601
+ loadError,
602
+ busy,
603
+ error,
604
+ riftMissing,
605
+ profileCatalog,
606
+ onClose: newSession.close,
607
+ onCreate: (state) => void submit(state),
608
+ onDeleteBranch: (branch) => branchAction(branch, "delete"),
609
+ onOpenBranchFolder: (branch) => void branchAction(branch, "open")
610
+ }, newSession.workspaceId)]
367
611
  })
368
612
  });
369
613
  }
@@ -397,16 +641,16 @@ function formProblem(form, saved) {
397
641
  if (form.method === "ssh") {
398
642
  const keyPath = form.keyPath.trim();
399
643
  if (keyPath === "") return void 0;
400
- if (hasControl(keyPath)) return "The key path has a control character in it.";
401
- if (!keyPath.startsWith("/") && !keyPath.startsWith("~/")) return "Give the key as an absolute path or one under ~/.";
644
+ if (hasControl(keyPath)) return t("git.ui.theKeyPathHasAControlCharacterInIt", "The key path has a control character in it.");
645
+ if (!keyPath.startsWith("/") && !keyPath.startsWith("~/")) return t("git.ui.giveTheKeyAsAnAbsolutePathOrOneUnder", "Give the key as an absolute path or one under ~/.");
402
646
  return;
403
647
  }
404
648
  if (form.method === "https") {
405
649
  const host = form.host.trim().toLowerCase();
406
- if (!HOST_PATTERN.test(host)) return "The host should look like github.com, with an optional :port.";
407
- if (form.username.trim() === "") return "A username is required.";
408
- if (hasControl(form.username) || hasControl(form.token)) return "Remove the control character from the username or token.";
409
- if (form.token === "" && !keepsToken(form, saved)) return saved.https?.hasToken === true ? "The host changed, so enter the token for the new host." : "A token is required.";
650
+ if (!HOST_PATTERN.test(host)) return t("git.ui.theHostShouldLookLikeGithubComWithAnOptionalPort", "The host should look like github.com, with an optional :port.");
651
+ if (form.username.trim() === "") return t("git.ui.aUsernameIsRequired", "A username is required.");
652
+ if (hasControl(form.username) || hasControl(form.token)) return t("git.ui.removeTheControlCharacterFromTheUsernameOrToken", "Remove the control character from the username or token.");
653
+ if (form.token === "" && !keepsToken(form, saved)) return saved.https?.hasToken === true ? t("git.ui.theHostChangedSoEnterTheTokenForTheNewHost", "The host changed, so enter the token for the new host.") : t("git.ui.aTokenIsRequired", "A token is required.");
410
654
  }
411
655
  }
412
656
  /** What a save sends. The token goes only when the reader typed one. */
@@ -446,163 +690,199 @@ function saveRequestOf(form) {
446
690
  * AVOID:
447
691
  * - Echoing a token back. The view the server sends has none to echo.
448
692
  */
449
- const METHODS = [
450
- {
451
- method: "none",
452
- title: "This machine's git",
453
- detail: "Whatever git here already does: your credential helper, SSH config and agent."
454
- },
455
- {
456
- method: "ssh",
457
- title: "SSH key",
458
- detail: "A key file on this machine, or your ssh-agent."
459
- },
460
- {
461
- method: "https",
462
- title: "HTTPS token",
463
- detail: "A username and personal access token for one host."
464
- }
465
- ];
693
+ function Field({ label, children }) {
694
+ return /* @__PURE__ */ jsxs("label", {
695
+ className: "flex flex-col gap-2 text-base text-po-text",
696
+ children: [/* @__PURE__ */ jsx("span", { children: label }), children]
697
+ });
698
+ }
466
699
  function GitAuthForm({ saved, saving, saveError, savedNotice = false, onSave }) {
700
+ const t = useT();
701
+ const METHODS = [
702
+ {
703
+ method: "none",
704
+ title: t("git.ui.thisMachineSGit", "This machine's git"),
705
+ detail: t("git.ui.yourCredentialHelperSSHConfigAndAgentAsTheyAre", "Your credential helper, SSH config and agent, as they are.")
706
+ },
707
+ {
708
+ method: "ssh",
709
+ title: t("git.ui.sshKey", "SSH key"),
710
+ detail: t("git.ui.aKeyFileOnThisMachineOrYourSshAgent", "A key file on this machine, or your ssh-agent.")
711
+ },
712
+ {
713
+ method: "https",
714
+ title: t("git.ui.httpsToken", "HTTPS token"),
715
+ detail: t("git.ui.aUsernameAndPersonalAccessTokenForOneHost", "A username and personal access token for one host.")
716
+ }
717
+ ];
467
718
  const [form, setForm] = useState(() => formFromView(saved));
468
- const update = (patch) => setForm((current) => ({
469
- ...current,
470
- ...patch
471
- }));
719
+ const [edited, setEdited] = useState(false);
720
+ const update = (patch) => {
721
+ setEdited(true);
722
+ setForm((current) => ({
723
+ ...current,
724
+ ...patch
725
+ }));
726
+ };
472
727
  const problem = formProblem(form, saved);
473
728
  const tokenSaved = saved.https?.hasToken === true && saved.https.host === form.host.trim().toLowerCase();
474
- const host = form.host.trim() === "" ? "this host" : form.host.trim();
729
+ const host = form.host.trim() === "" ? t("git.ui.thisHost", "this host") : form.host.trim();
475
730
  return /* @__PURE__ */ jsxs(SettingsSection, {
476
731
  "data-testid": "git-auth-form",
477
732
  children: [
478
- /* @__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, {
480
- "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-doom-hi",
492
- children: choice.title
493
- }), /* @__PURE__ */ jsx("span", {
494
- className: "text-sm leading-relaxed text-doom-dim",
495
- children: choice.detail
496
- })]
497
- }), form.method === choice.method ? /* @__PURE__ */ jsx(CheckIcon, { className: "size-4 shrink-0 text-doom-green" }) : null]
733
+ /* @__PURE__ */ jsxs(SettingsSectionHeader, { children: [/* @__PURE__ */ jsx(SettingsSectionTitle, { children: t("git.ui.connection", "Connection") }), /* @__PURE__ */ jsx(SettingsSectionDescription, { children: t("git.ui.worktreeSessionsUseTheSetupOfTheWorkspaceTheyBelongTo", "Worktree sessions use the setup of the workspace they belong to.") })] }),
734
+ /* @__PURE__ */ jsx("div", {
735
+ "aria-label": t("git.ui.howGitReachesYourRemote", "How git reaches your remote"),
736
+ className: "flex flex-col gap-3",
737
+ children: METHODS.map((choice) => /* @__PURE__ */ jsxs("div", {
738
+ className: `overflow-hidden rounded-lg border ${form.method === choice.method ? "border-po-green" : "border-po-border-soft"}`,
739
+ children: [
740
+ /* @__PURE__ */ jsxs("button", {
741
+ type: "button",
742
+ "aria-pressed": form.method === choice.method,
743
+ disabled: saving,
744
+ "data-testid": `git-auth-method-${choice.method}`,
745
+ onClick: () => update({ method: choice.method }),
746
+ className: `flex w-full items-start gap-3 p-4 text-left ${form.method === choice.method ? "bg-po-tint-green" : "bg-po-bg"}`,
747
+ children: [/* @__PURE__ */ jsxs("span", {
748
+ className: "flex flex-1 flex-col gap-1",
749
+ children: [/* @__PURE__ */ jsx("span", {
750
+ className: "text-base font-semibold text-po-hi",
751
+ children: choice.title
752
+ }), /* @__PURE__ */ jsx("span", {
753
+ className: "text-sm leading-relaxed text-po-dim",
754
+ children: choice.detail
755
+ })]
756
+ }), form.method === choice.method ? /* @__PURE__ */ jsx(CheckIcon, { className: "mt-0.5 size-4 shrink-0 text-po-green" }) : null]
757
+ }),
758
+ form.method === choice.method && form.method === "ssh" ? /* @__PURE__ */ jsxs("div", {
759
+ className: "flex flex-col gap-3 border-t border-po-border-soft p-4",
760
+ children: [/* @__PURE__ */ jsx(Field, {
761
+ label: t("git.ui.keyPath", "Key path"),
762
+ children: /* @__PURE__ */ jsx(Input, {
763
+ "data-testid": "git-auth-key-path",
764
+ value: form.keyPath,
765
+ placeholder: "~/.ssh/id_ed25519",
766
+ spellCheck: false,
767
+ disabled: saving,
768
+ onChange: (event) => update({ keyPath: event.target.value }),
769
+ className: "font-mono"
770
+ })
771
+ }), /* @__PURE__ */ jsx("p", {
772
+ className: "text-sm leading-relaxed text-po-dim",
773
+ children: t("git.ui.leaveBlankToUseSSHConfigAndSshAgentPassphrasesNeedSshAgentTrustAnUnknownHostInATerminalFirst", "Leave blank to use SSH config and ssh-agent. Passphrases need ssh-agent. Trust an unknown host in a terminal first.")
774
+ })]
775
+ }) : null,
776
+ form.method === choice.method && form.method === "https" ? /* @__PURE__ */ jsxs("div", {
777
+ className: "flex flex-col gap-4 border-t border-po-border-soft p-4",
778
+ children: [
779
+ /* @__PURE__ */ jsxs("div", {
780
+ className: "grid grid-cols-2 gap-3",
781
+ children: [/* @__PURE__ */ jsx(Field, {
782
+ label: t("git.ui.host", "Host"),
783
+ children: /* @__PURE__ */ jsx(Input, {
784
+ "data-testid": "git-auth-host",
785
+ value: form.host,
786
+ spellCheck: false,
787
+ disabled: saving,
788
+ onChange: (event) => update({ host: event.target.value }),
789
+ className: "font-mono"
790
+ })
791
+ }), /* @__PURE__ */ jsx(Field, {
792
+ label: t("git.ui.username", "Username"),
793
+ children: /* @__PURE__ */ jsx(Input, {
794
+ "data-testid": "git-auth-username",
795
+ value: form.username,
796
+ autoComplete: "username",
797
+ spellCheck: false,
798
+ disabled: saving,
799
+ onChange: (event) => update({ username: event.target.value })
800
+ })
801
+ })]
802
+ }),
803
+ /* @__PURE__ */ jsx(Field, {
804
+ label: /* @__PURE__ */ jsxs(Fragment, { children: [
805
+ t("git.ui.token", "Token"),
806
+ " ",
807
+ tokenSaved ? /* @__PURE__ */ jsx("span", {
808
+ "data-testid": "git-auth-token-saved",
809
+ className: "ml-2 text-sm text-po-green",
810
+ children: t("git.ui.aTokenIsSaved", "A token is saved")
811
+ }) : null
812
+ ] }),
813
+ children: /* @__PURE__ */ jsx(Input, {
814
+ "data-testid": "git-auth-token",
815
+ type: "password",
816
+ value: form.token,
817
+ autoComplete: "new-password",
818
+ placeholder: tokenSaved ? t("git.ui.leaveBlankToKeepIt", "Leave blank to keep it") : t("git.ui.personalAccessToken", "Personal access token"),
819
+ disabled: saving,
820
+ onChange: (event) => update({ token: event.target.value })
821
+ })
822
+ }),
823
+ /* @__PURE__ */ jsxs("p", {
824
+ className: "text-sm text-po-dim",
825
+ children: [
826
+ t("git.ui.sentOnlyTo", "Sent only to"),
827
+ " ",
828
+ /* @__PURE__ */ jsx("span", {
829
+ className: "font-mono",
830
+ children: host
831
+ }),
832
+ t("git.ui.otherHostsUseThisMachineSGit", ". Other hosts use this machine's git.")
833
+ ]
834
+ })
835
+ ]
836
+ }) : null
837
+ ]
498
838
  }, choice.method))
499
839
  }),
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", {
840
+ /* @__PURE__ */ jsxs(SettingsNote, {
841
+ className: "flex items-start gap-2 leading-relaxed",
842
+ children: [/* @__PURE__ */ jsx(ShieldIcon, {
843
+ "aria-hidden": true,
844
+ className: "mt-0.5 size-4 shrink-0"
845
+ }), /* @__PURE__ */ jsxs("span", { children: [
846
+ t("git.ui.onlyCockpitPullPushAndRebaseUseTheseCredentialsNotTheAgent", "Only cockpit pull, push and rebase use these credentials, not the agent."),
847
+ /* @__PURE__ */ jsx("br", {}),
848
+ t("git.ui.storedIn", "Stored in"),
849
+ " ",
850
+ /* @__PURE__ */ jsx("span", {
506
851
  className: "font-mono",
507
- children: "ssh -T git@github.com"
852
+ children: "~/.po/git/credentials.json"
508
853
  }),
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-doom-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,
854
+ t("git.ui.readableOnlyByYou", ", readable only by you.")
855
+ ] })]
856
+ }),
573
857
  /* @__PURE__ */ jsxs(SettingsActions, {
574
858
  className: "gap-4",
575
859
  children: [/* @__PURE__ */ jsx(Button, {
576
860
  variant: "primary",
577
- size: "sm",
578
861
  "data-testid": "git-auth-save",
579
862
  disabled: problem !== void 0 || saving,
580
863
  loading: saving,
581
- loadingLabel: "Saving",
582
- onClick: () => onSave(saveRequestOf(form)),
583
- children: "Save connection"
584
- }), problem !== void 0 ? /* @__PURE__ */ jsx(SettingsNote, {
585
- "data-testid": "git-auth-problem",
586
- className: "text-doom-dim",
587
- children: problem
588
- }) : saveError !== void 0 ? /* @__PURE__ */ jsx(SettingsNote, {
589
- role: "alert",
590
- "data-testid": "git-auth-error",
591
- className: "text-doom-red",
592
- children: saveError
593
- }) : savedNotice ? /* @__PURE__ */ jsx(SettingsNote, {
864
+ loadingLabel: t("git.ui.savingPending", "Saving..."),
865
+ onClick: () => {
866
+ if (!saving && problem === void 0) onSave(saveRequestOf(form));
867
+ },
868
+ children: t("git.ui.saveConnection", "Save connection")
869
+ }), savedNotice && !edited && problem === void 0 && saveError === void 0 ? /* @__PURE__ */ jsx("span", {
594
870
  "data-testid": "git-auth-saved",
595
- className: "text-doom-green",
596
- children: "Saved."
871
+ className: "text-sm text-po-green",
872
+ children: t("git.ui.saved", "Saved.")
597
873
  }) : null]
598
874
  }),
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
- })
875
+ problem !== void 0 ? /* @__PURE__ */ jsx("p", {
876
+ "data-testid": "git-auth-problem",
877
+ className: "text-sm text-po-red",
878
+ children: problem
879
+ }) : null,
880
+ saveError !== void 0 ? /* @__PURE__ */ jsx("p", {
881
+ role: "alert",
882
+ "data-testid": "git-auth-error",
883
+ className: "text-sm text-po-red",
884
+ children: saveError
885
+ }) : null
606
886
  ]
607
887
  });
608
888
  }
@@ -630,7 +910,7 @@ function isAuthView(value) {
630
910
  ].includes(String(value.method));
631
911
  }
632
912
  function errorOf(body, status) {
633
- return typeof body === "object" && body !== null && typeof body.error === "string" ? body.error : `The cockpit answered ${String(status)}.`;
913
+ return typeof body === "object" && body !== null && typeof body.error === "string" ? body.error : t("git.request.status", "The cockpit answered {status}.", { status });
634
914
  }
635
915
  /** The one-row card every non-form state of this panel is told in. */
636
916
  function StateCard({ testId, title, children, action }) {
@@ -640,6 +920,7 @@ function StateCard({ testId, title, children, action }) {
640
920
  });
641
921
  }
642
922
  function GitAuthPanel({ repository, request, requestWithStepUp }) {
923
+ const t = useT();
643
924
  const repositoryId = repository?.id;
644
925
  const [loaded, setLoaded] = useState();
645
926
  const [loadError, setLoadError] = useState();
@@ -665,7 +946,7 @@ function GitAuthPanel({ repository, request, requestWithStepUp }) {
665
946
  }).catch(() => {
666
947
  if (!stale) setLoadError({
667
948
  repositoryId,
668
- error: "The cockpit is unreachable."
949
+ error: t("git.ui.theCockpitIsUnreachable", "The cockpit is unreachable.")
669
950
  });
670
951
  });
671
952
  return () => {
@@ -674,12 +955,13 @@ function GitAuthPanel({ repository, request, requestWithStepUp }) {
674
955
  }, [
675
956
  repositoryId,
676
957
  request,
677
- attempt
958
+ attempt,
959
+ t
678
960
  ]);
679
961
  if (repository === null || repositoryId === void 0) return /* @__PURE__ */ jsx(StateCard, {
680
962
  testId: "git-auth-no-repository",
681
- title: "No repository picked",
682
- children: "Git remote access is set per workspace. Pick one above."
963
+ title: t("git.ui.noRepositoryPicked", "No repository picked"),
964
+ children: t("git.ui.gitRemoteAccessIsSetPerWorkspacePickOneAbove", "Git remote access is set per workspace. Pick one above.")
683
965
  });
684
966
  const save = async (next) => {
685
967
  setSaving(true);
@@ -701,7 +983,7 @@ function GitAuthPanel({ repository, request, requestWithStepUp }) {
701
983
  setSavedNotice(true);
702
984
  } else setSaveError(errorOf(body, response.status));
703
985
  } catch {
704
- setSaveError("The cockpit is unreachable.");
986
+ setSaveError(t("git.ui.theCockpitIsUnreachable", "The cockpit is unreachable."));
705
987
  } finally {
706
988
  setSaving(false);
707
989
  }
@@ -711,7 +993,7 @@ function GitAuthPanel({ repository, request, requestWithStepUp }) {
711
993
  "data-testid": "git-auth-load-error",
712
994
  children: /* @__PURE__ */ jsxs(StateCard, {
713
995
  testId: "git-auth-load-error-card",
714
- title: "Po couldn't read this workspace's git settings just now",
996
+ title: t("git.ui.poCouldnTReadThisWorkspaceSGitSettingsJustNow", "Po couldn't read this workspace's git settings just now"),
715
997
  action: /* @__PURE__ */ jsx(Button, {
716
998
  variant: "outline",
717
999
  size: "sm",
@@ -719,20 +1001,24 @@ function GitAuthPanel({ repository, request, requestWithStepUp }) {
719
1001
  setLoadError(void 0);
720
1002
  setAttempt((current) => current + 1);
721
1003
  },
722
- children: "Try again"
1004
+ children: t("git.ui.tryAgain", "Try again")
723
1005
  }),
724
- children: [loadError.error, " Nothing has changed."]
1006
+ children: [
1007
+ loadError.error,
1008
+ " ",
1009
+ t("git.ui.nothingHasChanged", "Nothing has changed.")
1010
+ ]
725
1011
  })
726
1012
  });
727
1013
  if (loaded?.repositoryId !== repositoryId) return /* @__PURE__ */ jsx(StateCard, {
728
1014
  testId: "git-auth-loading",
729
- title: "Reading git settings",
1015
+ title: t("git.ui.readingGitSettings", "Reading git settings"),
730
1016
  children: /* @__PURE__ */ jsxs("span", {
731
1017
  className: "inline-flex items-center gap-2",
732
1018
  children: [/* @__PURE__ */ jsx(Spinner, {
733
- className: "size-3 text-doom-faint",
734
- label: "Loading git settings"
735
- }), "This takes a moment."]
1019
+ className: "size-3 text-po-faint",
1020
+ label: t("git.ui.loadingGitSettings", "Loading git settings")
1021
+ }), t("git.ui.thisTakesAMoment", "This takes a moment.")]
736
1022
  })
737
1023
  });
738
1024
  return /* @__PURE__ */ jsx(GitAuthForm, {
@@ -746,8 +1032,8 @@ function GitAuthPanel({ repository, request, requestWithStepUp }) {
746
1032
  //#endregion
747
1033
  //#region src/extensions/workspaces/(frontend)/repository-settings-panel/git.web.tsx
748
1034
  var git_web_default$1 = defineRepositorySettingsPanel({
749
- label: "Git remote",
750
- detail: "How this workspace's sessions reach the remote when you pull, push or rebase from the cockpit.",
1035
+ label: t("git.ui.gitRemote", "Git remote"),
1036
+ detail: t("git.ui.howThisWorkspaceSSessionsReachTheRemoteWhenYouPullPushOrRebaseFromTheCockpit", "How this workspace's sessions reach the remote when you pull, push or rebase from the cockpit."),
751
1037
  order: 50,
752
1038
  component: GitAuthPanel
753
1039
  });
@@ -796,7 +1082,7 @@ const worktreeActivity = defineSessionStore({
796
1082
  errorTarget: void 0
797
1083
  });
798
1084
  /** Captures the clicked card, so a focus change cannot retarget an open dialog. */
799
- const worktreeCreateDialog = defineGlobalStore(null);
1085
+ const worktreeCreateDialog = defineHostStore(null);
800
1086
  /**
801
1087
  * The page's hub socket sender, held for as long as the plugin runs.
802
1088
  *
@@ -804,7 +1090,7 @@ const worktreeCreateDialog = defineGlobalStore(null);
804
1090
  * sent in that window is dropped rather than queued, because a queue would
805
1091
  * replay a worktree create against a socket that has since changed sessions.
806
1092
  */
807
- const worktreeSender = defineGlobalStore(void 0);
1093
+ const worktreeSender = defineHostStore(void 0);
808
1094
  /** Binds the page's hub socket. The plugin host calls this once per page. */
809
1095
  function startWorktreeRuntime(runtime) {
810
1096
  const send = (frame) => {
@@ -845,7 +1131,10 @@ function optionalText$1(value) {
845
1131
  }
846
1132
  function optionalErrorTarget$1(value) {
847
1133
  if (!isRecord$2(value)) return void 0;
848
- if (value.action === "create") return { action: "create" };
1134
+ if (value.action === "create") return value.riftMissing === true ? {
1135
+ action: "create",
1136
+ riftMissing: true
1137
+ } : { action: "create" };
849
1138
  if (value.action === "close" && typeof value.id === "string" && value.id !== "") return {
850
1139
  action: "close",
851
1140
  id: value.id
@@ -893,200 +1182,407 @@ function requestWorktreeClose(sessionId, id) {
893
1182
  });
894
1183
  }
895
1184
  //#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. `doom-error`, `doom-line` and
918
- * `doom-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
- };
1185
+ //#region src/extensions/workspaces/sessions/(frontend)/fill/_components/WorktreeCreateDialog.tsx
1186
+ function WorktreeCreateOverlay(props) {
1187
+ const t = useT();
1188
+ const target = useStore(worktreeCreateDialog.store);
1189
+ const { holdSessionChannels } = props;
1190
+ useEffect(() => {
1191
+ if (target === null) return;
1192
+ return holdSessionChannels?.(target.sessionId, (frame) => {
1193
+ if (frame.type !== worktreesChannel.channel) return;
1194
+ const payload = worktreesChannel.parse(frame.payload);
1195
+ if (payload !== null) worktreesChannel.apply(target.sessionId, payload);
1196
+ });
1197
+ }, [target, holdSessionChannels]);
1198
+ if (target === null) return null;
1199
+ return /* @__PURE__ */ jsx(Dialog, {
1200
+ open: true,
1201
+ onOpenChange: (open) => {
1202
+ if (!open) worktreeCreateDialog.update(() => null);
1203
+ },
1204
+ children: /* @__PURE__ */ jsxs(DialogContent, {
1205
+ width: "md",
1206
+ className: "w-96 overflow-y-auto border-0",
1207
+ "data-testid": "session-worktree-dialog",
1208
+ "aria-describedby": void 0,
1209
+ children: [/* @__PURE__ */ jsx(DialogTitle, {
1210
+ className: "sr-only",
1211
+ children: t("git.ui.createAWorktreeSession", "Create a worktree session")
1212
+ }), /* @__PURE__ */ createElement(WorktreeCreateForm, {
1213
+ ...props,
1214
+ key: `${target.sessionId}:${target.reservationId ?? ""}`,
1215
+ sessionId: target.sessionId,
1216
+ sessionReservationId: target.reservationId,
1217
+ onCancel: () => worktreeCreateDialog.update(() => null),
1218
+ onCreated: () => worktreeCreateDialog.update(() => null)
1219
+ })]
1220
+ })
1221
+ });
928
1222
  }
929
- function WorktreesPanel({ sessionId, sessionReservationId }) {
1223
+ function WorktreeCreateForm({ sessionId, sessionReservationId, onCancel, onRequested, onCreated }) {
930
1224
  const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, sessionId));
931
1225
  const [branch, setBranch] = useState("");
932
1226
  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("");
1227
+ const sent = useRef(void 0);
1228
+ useEffect(() => {
1229
+ const request = sent.current;
1230
+ if (request === void 0) return;
1231
+ if (session.pending !== void 0) {
1232
+ request.sawPending = true;
1233
+ return;
944
1234
  }
945
- };
1235
+ if (!session.worktrees.some((worktree) => worktree.branch === request.branch) && !request.sawPending) return;
1236
+ sent.current = void 0;
1237
+ if (session.errorTarget?.action !== "create") onCreated?.();
1238
+ }, [
1239
+ session.pending,
1240
+ session.worktrees,
1241
+ session.errorTarget,
1242
+ onCreated
1243
+ ]);
1244
+ return /* @__PURE__ */ jsx(WorktreeCreateView, {
1245
+ branch,
1246
+ baseRef,
1247
+ onBranchChange: setBranch,
1248
+ onBaseChange: setBaseRef,
1249
+ busy: session.pending !== void 0,
1250
+ error: session.errorTarget?.action === "create" ? session.error : void 0,
1251
+ riftMissing: session.errorTarget?.action === "create" && session.errorTarget.riftMissing === true,
1252
+ onCancel,
1253
+ onCreate: () => {
1254
+ if (sessionId !== null) {
1255
+ sent.current = {
1256
+ branch: branch.trim(),
1257
+ sawPending: false
1258
+ };
1259
+ onRequested?.(branch.trim());
1260
+ requestWorktreeCreate(sessionId, branch, baseRef, sessionReservationId);
1261
+ }
1262
+ },
1263
+ disabled: sessionId === null
1264
+ });
1265
+ }
1266
+ function WorktreeCreateView({ branch, baseRef, onBranchChange, onBaseChange, busy = false, error, riftMissing = false, onCancel, onCreate, disabled = false }) {
1267
+ const t = useT();
1268
+ const id = useId();
946
1269
  return /* @__PURE__ */ jsxs("div", {
947
- "data-testid": "git-worktrees-panel",
948
- className: "flex min-h-0 flex-1 flex-col overflow-auto",
1270
+ className: "rounded-lg border border-po-border-soft bg-po-panel p-5 text-po-text shadow-sm",
949
1271
  children: [
950
- /* @__PURE__ */ jsxs("div", {
951
- className: "flex min-h-11 shrink-0 items-center gap-2.5 border-b border-doom-border-soft px-3 sm:px-[26px]",
952
- children: [
953
- /* @__PURE__ */ jsx("span", {
954
- className: "text-lg font-semibold text-doom-hi",
955
- children: "worktrees"
956
- }),
1272
+ /* @__PURE__ */ jsx("h2", {
1273
+ id: `${id}-title`,
1274
+ className: "text-xl font-semibold text-po-hi",
1275
+ children: t("git.ui.createAWorktreeSession", "Create a worktree session")
1276
+ }),
1277
+ /* @__PURE__ */ jsx("p", {
1278
+ className: "mt-2 text-sm leading-relaxed text-po-dim",
1279
+ children: t("git.ui.createASeparateCheckoutAndSessionWithoutMovingYourExistingSessions", "Create a separate checkout and session without moving your existing sessions.")
1280
+ }),
1281
+ /* @__PURE__ */ jsxs("form", {
1282
+ onSubmit: (event) => {
1283
+ event.preventDefault();
1284
+ if (!busy && !disabled && branch.trim()) onCreate?.();
1285
+ },
1286
+ children: [/* @__PURE__ */ jsxs("div", {
1287
+ className: "mt-5 flex flex-col gap-4",
1288
+ children: [/* @__PURE__ */ jsxs("div", {
1289
+ className: "flex flex-col gap-2",
1290
+ children: [
1291
+ /* @__PURE__ */ jsx("label", {
1292
+ htmlFor: `${id}-branch`,
1293
+ className: "text-base font-medium",
1294
+ children: t("git.ui.branch", "Branch")
1295
+ }),
1296
+ /* @__PURE__ */ jsx(Input, {
1297
+ id: `${id}-branch`,
1298
+ "data-testid": "git-worktree-branch",
1299
+ className: "font-mono",
1300
+ placeholder: "wt/fix-auth",
1301
+ value: branch,
1302
+ onChange: (e) => onBranchChange?.(e.target.value),
1303
+ disabled: busy,
1304
+ "aria-invalid": !!error,
1305
+ "aria-describedby": error ? `${id}-error` : void 0
1306
+ }),
1307
+ riftMissing ? /* @__PURE__ */ jsxs("div", {
1308
+ "data-testid": "rift-install-notice",
1309
+ role: "alert",
1310
+ 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",
1311
+ children: [/* @__PURE__ */ jsx("p", { children: t("git.ui.thisRepositoryUsesRiftAndItsCLIIsNotInstalledHereRunTheseInTheRepositoryRootThenTryAgain", "This repository uses Rift, and its CLI is not installed here. Run these in the repository root, then try again.") }), /* @__PURE__ */ jsx(CodeBlock, {
1312
+ text: `${RIFT_INSTALL_COMMAND}
1313
+ rift init`,
1314
+ className: "language-bash"
1315
+ })]
1316
+ }) : error && /* @__PURE__ */ jsx("p", {
1317
+ id: `${id}-error`,
1318
+ role: "alert",
1319
+ "data-testid": "git-worktree-error",
1320
+ className: "text-sm text-po-red",
1321
+ children: error
1322
+ })
1323
+ ]
1324
+ }), /* @__PURE__ */ jsxs("div", {
1325
+ className: "flex flex-col gap-2",
1326
+ children: [/* @__PURE__ */ jsx("label", {
1327
+ htmlFor: `${id}-base`,
1328
+ className: "text-base font-medium",
1329
+ children: t("git.ui.startFrom", "Start from")
1330
+ }), /* @__PURE__ */ jsx(Input, {
1331
+ size: "sm",
1332
+ id: `${id}-base`,
1333
+ "data-testid": "git-worktree-base",
1334
+ className: "font-mono",
1335
+ placeholder: t("git.ui.currentBranch", "Current branch"),
1336
+ value: baseRef,
1337
+ onChange: (e) => onBaseChange?.(e.target.value),
1338
+ disabled: busy
1339
+ })]
1340
+ })]
1341
+ }), /* @__PURE__ */ jsxs("footer", {
1342
+ className: "mt-5 flex items-center justify-end gap-2 border-t border-po-border-soft pt-4",
1343
+ children: [/* @__PURE__ */ jsx(Button, {
1344
+ type: "button",
1345
+ variant: "ghost",
1346
+ disabled: busy,
1347
+ onClick: onCancel,
1348
+ children: t("git.ui.cancel", "Cancel")
1349
+ }), /* @__PURE__ */ jsxs(Button, {
1350
+ type: "submit",
1351
+ variant: "primary",
1352
+ "data-testid": "git-worktree-create",
1353
+ disabled: busy || disabled || !branch.trim(),
1354
+ children: [busy && /* @__PURE__ */ jsx(Spinner, {
1355
+ className: "size-3",
1356
+ label: t("git.ui.creatingWorktree", "Creating worktree")
1357
+ }), busy ? t("git.ui.creatingWorktreePending", "Creating worktree...") : riftMissing ? t("git.ui.tryAgain", "Try again") : t("git.ui.createWorktree", "Create worktree")]
1358
+ })]
1359
+ })]
1360
+ })
1361
+ ]
1362
+ });
1363
+ }
1364
+ //#endregion
1365
+ //#region src/extensions/workspaces/sessions/(frontend)/_components/WorktreesPanel.tsx
1366
+ function worktreesTab() {
1367
+ return {
1368
+ id: "git-worktrees",
1369
+ label: t("git.tab.worktrees", "worktrees"),
1370
+ panel: WorktreesPanel
1371
+ };
1372
+ }
1373
+ function WorktreesPanel(props) {
1374
+ const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, props.sessionId));
1375
+ const [creating, setCreating] = useState(session.errorTarget?.action === "create");
1376
+ const [requestedBranch, setRequestedBranch] = useState();
1377
+ const sawPending = useRef(false);
1378
+ useEffect(() => {
1379
+ if (!requestedBranch) return;
1380
+ if (session.worktrees.some((w) => w.branch === requestedBranch) || sawPending.current && session.pending === void 0) setRequestedBranch(void 0);
1381
+ else if (session.pending !== void 0) sawPending.current = true;
1382
+ }, [
1383
+ requestedBranch,
1384
+ session.pending,
1385
+ session.worktrees
1386
+ ]);
1387
+ return /* @__PURE__ */ jsx("div", {
1388
+ className: "min-h-0 flex-1 overflow-auto",
1389
+ children: /* @__PURE__ */ jsx(WorktreesPanelView, {
1390
+ worktrees: session.worktrees,
1391
+ pending: session.pending,
1392
+ startingBranch: session.pending === void 0 || session.worktrees.some((w) => w.branch === requestedBranch) ? void 0 : requestedBranch,
1393
+ error: session.errorTarget?.action === "create" && creating ? void 0 : session.error,
1394
+ closeErrorId: session.errorTarget?.action === "close" ? session.errorTarget.id : void 0,
1395
+ onNew: () => setCreating(true),
1396
+ onClose: props.sessionId === null ? void 0 : (id) => requestWorktreeClose(props.sessionId, id),
1397
+ form: creating ? /* @__PURE__ */ jsx(WorktreeCreateForm, {
1398
+ ...props,
1399
+ onCancel: () => setCreating(false),
1400
+ onCreated: () => setCreating(false),
1401
+ onRequested: (branch) => {
1402
+ sawPending.current = false;
1403
+ setRequestedBranch(branch);
1404
+ }
1405
+ }) : void 0
1406
+ })
1407
+ });
1408
+ }
1409
+ function WorktreesPanelView({ worktrees, pending, error, closeErrorId, onNew, onClose, form, startingIds = [], startingBranch }) {
1410
+ const t = useT();
1411
+ const groups = [worktrees.filter((w) => !w.orphaned && !w.unowned), worktrees.filter((w) => w.orphaned || w.unowned)];
1412
+ const empty = worktrees.length === 0 && !startingBranch;
1413
+ return /* @__PURE__ */ jsxs("div", {
1414
+ "data-testid": "git-worktrees-panel",
1415
+ className: "rounded-lg border border-po-border-soft bg-po-panel p-5",
1416
+ children: [
1417
+ /* @__PURE__ */ jsxs("header", {
1418
+ className: "flex items-center justify-between gap-4 border-b border-po-border-soft pb-4",
1419
+ children: [
1420
+ /* @__PURE__ */ jsx("h2", {
1421
+ className: "text-lg font-semibold text-po-hi",
1422
+ children: t("git.ui.worktrees", "Worktrees")
1423
+ }),
957
1424
  /* @__PURE__ */ jsx("span", {
958
1425
  "data-testid": "git-worktrees-count",
959
- className: "text-sm text-doom-dim",
960
- children: session.worktrees.length === 0 ? "none yet" : `${String(session.worktrees.length)} open`
1426
+ className: "sr-only",
1427
+ children: worktrees.length === 0 ? t("git.ui.noneYet", "none yet") : t("git.worktree.openCount", "{count} open", { count: worktrees.length })
961
1428
  }),
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-doom-faint",
968
- label: session.pending
969
- }), /* @__PURE__ */ jsx("span", {
970
- className: "min-w-0 truncate text-sm text-doom-dim",
971
- children: session.pending
972
- })]
1429
+ !empty && /* @__PURE__ */ jsx(Button, {
1430
+ variant: "outline",
1431
+ size: "sm",
1432
+ onClick: onNew,
1433
+ children: t("git.ui.newWorktree", "New worktree")
973
1434
  })
974
1435
  ]
975
1436
  }),
976
- /* @__PURE__ */ jsxs("div", {
977
- className: "flex shrink-0 flex-col gap-1.5 border-b border-doom-border-soft px-3 py-2.5 sm:px-[26px]",
978
- 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",
984
- 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, {
994
- "data-testid": "git-worktree-base",
995
- "aria-label": "Base ref",
996
- size: "sm",
997
- placeholder: "base (current)",
998
- 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-doom-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-doom-red",
1017
- children: createError
1437
+ form,
1438
+ pending && !startingBranch && /* @__PURE__ */ jsxs("p", {
1439
+ "data-testid": "git-worktree-pending",
1440
+ className: "flex items-center gap-2 pt-3 text-sm text-po-dim",
1441
+ children: [/* @__PURE__ */ jsx(Spinner, {
1442
+ className: "size-3",
1443
+ label: pending
1444
+ }), /* @__PURE__ */ jsx("span", {
1445
+ className: "inline-block first-letter:uppercase",
1446
+ children: pending
1018
1447
  })]
1019
1448
  }),
1020
- panelError ? /* @__PURE__ */ jsx("p", {
1449
+ error && (!closeErrorId || !worktrees.some((w) => w.id === closeErrorId)) && /* @__PURE__ */ jsx("p", {
1021
1450
  role: "alert",
1022
1451
  "data-testid": "git-worktree-error",
1023
- className: "px-3 pt-2 text-sm text-doom-red sm:px-[26px]",
1024
- children: session.error
1025
- }) : null,
1026
- session.worktrees.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
1452
+ className: "text-sm text-po-red",
1453
+ children: error
1454
+ }),
1455
+ empty ? /* @__PURE__ */ jsx(EmptyState, {
1027
1456
  "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", {
1457
+ surface: "plain",
1458
+ className: "py-10",
1459
+ icon: /* @__PURE__ */ jsx(BranchIcon, {}),
1460
+ title: t("git.ui.noWorktreesYet", "No worktrees yet"),
1461
+ description: t("git.ui.aWorktreeGivesABranchItsOwnCheckoutAndASessionNestedUnderThisOne", "A worktree gives a branch its own checkout and a session nested under this one."),
1462
+ action: onNew && !form ? {
1463
+ label: t("git.ui.newWorktree", "New worktree"),
1464
+ onAction: onNew
1465
+ } : void 0
1466
+ }) : /* @__PURE__ */ jsx("div", {
1032
1467
  "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))
1468
+ children: groups.map((group, i) => (group.length > 0 || i === 0 && startingBranch) && /* @__PURE__ */ jsxs("section", { children: [
1469
+ /* @__PURE__ */ jsxs("h3", {
1470
+ className: "flex items-center gap-2 pt-5 text-lg font-semibold text-po-hi",
1471
+ children: [
1472
+ i === 0 ? t("git.ui.working", "Working") : t("git.ui.needsALook", "Needs a look"),
1473
+ " ",
1474
+ /* @__PURE__ */ jsxs("span", {
1475
+ className: "text-sm font-normal text-po-dim",
1476
+ children: [
1477
+ group.length + (i === 0 && startingBranch ? 1 : 0),
1478
+ " ",
1479
+ t("git.ui.open", "open")
1480
+ ]
1481
+ })
1482
+ ]
1483
+ }),
1484
+ i === 1 && /* @__PURE__ */ jsxs("p", {
1485
+ className: "pt-2 text-sm leading-relaxed text-po-dim",
1486
+ children: [
1487
+ group.length === 2 ? t("git.ui.twoWorktrees", "Two worktrees") : group.length === 1 ? t("git.ui.oneWorktree", "One worktree") : t("git.worktree.count", "{count} worktrees", { count: group.length }),
1488
+ " ",
1489
+ t("git.ui.wouldLikeYourEyeWheneverYouAreReady", "would like your eye, whenever you are ready.")
1490
+ ]
1491
+ }),
1492
+ i === 0 && startingBranch && /* @__PURE__ */ jsxs("div", {
1493
+ "data-testid": "git-worktree-starting",
1494
+ className: "flex min-w-0 flex-col gap-2 border-b border-po-border-soft py-4",
1495
+ children: [/* @__PURE__ */ jsxs("div", {
1496
+ className: "flex min-w-0 items-center gap-2",
1497
+ children: [/* @__PURE__ */ jsx(Spinner, {
1498
+ className: "size-3 shrink-0 text-po-dim",
1499
+ label: t("git.ui.startingSession", "Starting session")
1500
+ }), /* @__PURE__ */ jsx("span", {
1501
+ className: "min-w-0 flex-1 truncate font-mono text-base font-medium text-po-hi",
1502
+ children: startingBranch
1503
+ })]
1504
+ }), /* @__PURE__ */ jsx("p", {
1505
+ className: "pl-4 text-sm text-po-dim",
1506
+ children: t("git.ui.startingSessionPending", "Starting session...")
1507
+ })]
1508
+ }),
1509
+ group.map((w) => /* @__PURE__ */ jsx(WorktreeRow, {
1510
+ worktree: w,
1511
+ starting: startingIds.includes(w.id) || !!pending?.includes("starting") && w.sessionId === null && !w.orphaned && !w.unowned,
1512
+ disabled: !!pending || !onClose,
1513
+ onClose: () => onClose?.(w.id),
1514
+ error: closeErrorId === w.id ? error : void 0
1515
+ }, w.id))
1516
+ ] }, i))
1040
1517
  })
1041
1518
  ]
1042
1519
  });
1043
1520
  }
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", {
1521
+ function WorktreeBadge({ worktree }) {
1522
+ const t = useT();
1523
+ if (worktree.orphaned) return /* @__PURE__ */ jsx(StatusBadge, {
1524
+ tone: "neutral",
1525
+ size: "xs",
1526
+ className: "bg-po-tint-yellow text-po-yellow",
1527
+ children: t("git.ui.orphaned", "Orphaned")
1528
+ });
1529
+ if (worktree.unowned) return /* @__PURE__ */ jsx(StatusBadge, {
1530
+ tone: "info",
1531
+ size: "xs",
1532
+ children: t("git.ui.unowned", "Unowned")
1533
+ });
1534
+ return null;
1535
+ }
1536
+ function WorktreeRow({ worktree, compact = false, starting = false, error, disabled = false, onClose }) {
1537
+ const t = useT();
1538
+ return /* @__PURE__ */ jsxs("div", {
1047
1539
  "data-testid": `git-worktree-${worktree.id}`,
1048
- className: "flex min-w-0 flex-col gap-1.5 rounded-md border border-doom-border-soft bg-doom-panel p-2.5",
1540
+ 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
1541
  children: [
1050
1542
  /* @__PURE__ */ jsxs("div", {
1051
- className: "flex min-w-0 items-center gap-1.5",
1543
+ className: "flex min-w-0 items-center gap-2",
1052
1544
  children: [
1053
- /* @__PURE__ */ jsx(Dot, { tone: worktree.orphaned ? "red" : worktree.sessionId === null ? "muted" : "blue" }),
1545
+ starting ? /* @__PURE__ */ jsx(Spinner, {
1546
+ className: "size-3 shrink-0 text-po-dim",
1547
+ label: t("git.ui.startingSession", "Starting session")
1548
+ }) : /* @__PURE__ */ jsx(Dot, {
1549
+ size: "md",
1550
+ tone: worktree.orphaned ? "yellow" : worktree.unowned ? "blue" : "green"
1551
+ }),
1054
1552
  /* @__PURE__ */ jsx("span", {
1055
- className: "min-w-0 flex-1 truncate text-base font-semibold text-doom-hi",
1553
+ title: worktree.branch,
1554
+ className: "min-w-0 flex-1 truncate font-mono text-base font-medium text-po-hi",
1056
1555
  children: worktree.branch
1057
1556
  }),
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
1557
+ /* @__PURE__ */ jsx(WorktreeBadge, { worktree }),
1558
+ !compact && /* @__PURE__ */ jsx(Button, {
1559
+ variant: "ghost",
1560
+ size: "sm",
1561
+ onClick: onClose,
1562
+ disabled: starting || disabled,
1563
+ "data-testid": `git-worktree-close-${worktree.id}`,
1564
+ "aria-label": t("git.worktree.closeBranch", "Close {branch}", { branch: worktree.branch }),
1565
+ children: t("git.ui.close", "Close")
1566
+ })
1068
1567
  ]
1069
1568
  }),
1070
- /* @__PURE__ */ jsx("span", {
1071
- className: "min-w-0 truncate text-sm text-doom-dim",
1569
+ !compact && /* @__PURE__ */ jsx("p", {
1570
+ className: "truncate pl-4 font-mono text-sm text-po-dim",
1571
+ title: worktree.path,
1072
1572
  children: worktree.path
1073
1573
  }),
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
- })]
1574
+ starting && /* @__PURE__ */ jsx("p", {
1575
+ className: "pl-4 text-sm text-po-dim",
1576
+ children: t("git.ui.startingSessionPending", "Starting session...")
1577
+ }),
1578
+ !compact && (worktree.orphaned || worktree.unowned) && /* @__PURE__ */ jsx("p", {
1579
+ className: "pl-4 text-sm text-po-dim first-letter:uppercase",
1580
+ children: worktree.orphaned ? t("git.worktree.folderMissing", "its folder is missing") : t("git.worktree.sessionEnded", "its session has ended")
1085
1581
  }),
1086
- error === void 0 ? null : /* @__PURE__ */ jsx("p", {
1582
+ error && /* @__PURE__ */ jsx("p", {
1087
1583
  role: "alert",
1088
1584
  "data-testid": "git-worktree-error",
1089
- className: "text-sm text-doom-red",
1585
+ className: "pl-4 text-sm text-po-red",
1090
1586
  children: error
1091
1587
  })
1092
1588
  ]
@@ -1136,7 +1632,7 @@ const gitChanges = defineSessionStore({
1136
1632
  errorTarget: void 0
1137
1633
  });
1138
1634
  /** The page's hub socket sender; undefined before start and after dispose, when a command is dropped. */
1139
- const changesSender = defineGlobalStore(void 0);
1635
+ const changesSender = defineHostStore(void 0);
1140
1636
  /** Binds the page's hub socket for sync commands. The plugin host calls this once per page. */
1141
1637
  function startGitChangesRuntime(runtime) {
1142
1638
  const send = (frame) => {
@@ -1238,6 +1734,7 @@ function requestGitSync(sessionId, action, force = false) {
1238
1734
  //#endregion
1239
1735
  //#region src/extensions/workspaces/sessions/(frontend)/activity-group/git.web.ts
1240
1736
  var git_web_default = defineActivityGroup({
1737
+ label: "Git",
1241
1738
  keys: "g w",
1242
1739
  icon: BranchIcon,
1243
1740
  activeSource: {
@@ -1254,8 +1751,7 @@ var git_web_default = defineActivityGroup({
1254
1751
  }
1255
1752
  },
1256
1753
  marksBackgroundWork: false,
1257
- transientTab: worktreesTab,
1258
- order: 30
1754
+ transientTab: worktreesTab
1259
1755
  });
1260
1756
  //#endregion
1261
1757
  //#region src/extensions/workspaces/sessions/(frontend)/channel/gitChanges.web.ts
@@ -1264,56 +1760,6 @@ var gitChanges_web_default = defineChannelFile(gitChangesChannel);
1264
1760
  //#region src/extensions/workspaces/sessions/(frontend)/channel/gitWorktrees.web.ts
1265
1761
  var gitWorktrees_web_default = defineChannelFile(worktreesChannel);
1266
1762
  //#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
1763
  //#region src/extensions/workspaces/sessions/(frontend)/_lib/gitReviewApi.ts
1318
1764
  /**
1319
1765
  * The review tab's half of the session API: the changed-file list and one
@@ -1323,14 +1769,14 @@ var WorktreeCreate_overlay_web_default = defineFill({ component: WorktreeCreateO
1323
1769
  * spells a route or reaches for `fetch`. What travels is file contents, which a
1324
1770
  * tunnel's relay must never see in the clear.
1325
1771
  */
1326
- const UNREACHABLE = "The session is unreachable.";
1772
+ const unreachable = () => t("git.ui.theSessionIsUnreachable", "The session is unreachable.");
1327
1773
  function isRecord(value) {
1328
1774
  return typeof value === "object" && value !== null && !Array.isArray(value);
1329
1775
  }
1330
1776
  /** The message a reader is shown: the route's own words, or why there were none. */
1331
1777
  function messageOf(result) {
1332
- if (result.status === 0) return UNREACHABLE;
1333
- return result.error === "" ? `The session answered ${String(result.status)}.` : result.error;
1778
+ if (result.status === 0) return unreachable();
1779
+ return result.error === "" ? t("git.request.sessionStatus", "The session answered {status}.", { status: result.status }) : result.error;
1334
1780
  }
1335
1781
  async function fetchReviewSummary(sessionId, signal) {
1336
1782
  const result = await api.session(sessionId).review(signal === void 0 ? {} : { signal });
@@ -1340,7 +1786,7 @@ async function fetchReviewSummary(sessionId, signal) {
1340
1786
  };
1341
1787
  if (!isRecord(result.data) || !Array.isArray(result.data.files)) return {
1342
1788
  ok: false,
1343
- error: "The session answered with no file list."
1789
+ error: t("git.ui.theSessionAnsweredWithNoFileList", "The session answered with no file list.")
1344
1790
  };
1345
1791
  return {
1346
1792
  ok: true,
@@ -1358,7 +1804,7 @@ async function fetchReviewFile(sessionId, path, signal) {
1358
1804
  };
1359
1805
  if (!isRecord(result.data) || !Array.isArray(result.data.hunks)) return {
1360
1806
  ok: false,
1361
- error: "The session answered with no diff."
1807
+ error: t("git.ui.theSessionAnsweredWithNoDiff", "The session answered with no diff.")
1362
1808
  };
1363
1809
  return {
1364
1810
  ok: true,
@@ -1370,16 +1816,34 @@ async function fetchReviewFile(sessionId, path, signal) {
1370
1816
  const gitReview = defineSessionStore({ comments: [] });
1371
1817
  function addReviewComment(sessionId, comment) {
1372
1818
  const id = globalThis.crypto.randomUUID();
1373
- gitReview.update(sessionId, (current) => ({ comments: [...current.comments, {
1374
- ...comment,
1375
- id
1376
- }] }));
1819
+ gitReview.update(sessionId, (current) => ({
1820
+ ...current,
1821
+ comments: [...current.comments, {
1822
+ ...comment,
1823
+ id
1824
+ }]
1825
+ }));
1377
1826
  }
1378
1827
  function removeReviewComment(sessionId, id) {
1379
- gitReview.update(sessionId, (current) => ({ comments: current.comments.filter((comment) => comment.id !== id) }));
1828
+ gitReview.update(sessionId, (current) => ({
1829
+ ...current,
1830
+ comments: current.comments.filter((comment) => comment.id !== id)
1831
+ }));
1380
1832
  }
1381
1833
  function clearReviewComments(sessionId) {
1382
- gitReview.update(sessionId, () => ({ comments: [] }));
1834
+ gitReview.update(sessionId, (current) => ({
1835
+ ...current,
1836
+ comments: []
1837
+ }));
1838
+ }
1839
+ function focusReviewFile(sessionId, path) {
1840
+ gitReview.update(sessionId, (current) => ({
1841
+ ...current,
1842
+ focus: {
1843
+ path,
1844
+ at: Date.now()
1845
+ }
1846
+ }));
1383
1847
  }
1384
1848
  //#endregion
1385
1849
  //#region src/extensions/workspaces/sessions/(frontend)/_lib/gitReviewView.ts
@@ -1411,10 +1875,30 @@ function conflictPrompt(branch, conflicts) {
1411
1875
  ].join("\n");
1412
1876
  }
1413
1877
  /**
1878
+ * The one sync the bar fills in: pull while the branch is behind (a push would
1879
+ * be rejected), push while it is only ahead or has no upstream yet. Nothing
1880
+ * while a rebase is paused, detached, or already level.
1881
+ */
1882
+ function suggestedSyncAction(changes) {
1883
+ if (changes?.branch === void 0 || changes.rebase !== void 0) return void 0;
1884
+ if (changes.upstream === void 0) return "push";
1885
+ if (changes.upstream.behind > 0) return "pull";
1886
+ return changes.upstream.ahead > 0 ? "push" : void 0;
1887
+ }
1888
+ /** "2 to push, 1 new on origin/feat/git", or "Up to date with origin/feat/git". */
1889
+ function upstreamSummary(t, upstream) {
1890
+ if (upstream === void 0) return t("git.ui.noUpstreamYet", "No upstream yet");
1891
+ const parts = [...upstream.ahead > 0 ? [t("git.sync.toPush", "{count} to push", { count: upstream.ahead })] : [], ...upstream.behind > 0 ? [t("git.sync.newOn", "{count} new on {ref}", {
1892
+ count: upstream.behind,
1893
+ ref: upstream.ref
1894
+ })] : []];
1895
+ return parts.length === 0 ? t("git.sync.upToDate", "Up to date with {ref}", { ref: upstream.ref }) : parts.join(", ");
1896
+ }
1897
+ /**
1414
1898
  * Hands one deferred follow-up to the session. Returns the reason it failed,
1415
1899
  * or undefined once sent. The sender throws when the session is disconnected.
1416
1900
  */
1417
- function deliverToAgent(send, sessionId, message) {
1901
+ function deliverToAgent(t, send, sessionId, message) {
1418
1902
  try {
1419
1903
  send(sessionId, {
1420
1904
  type: "follow_up",
@@ -1422,489 +1906,329 @@ function deliverToAgent(send, sessionId, message) {
1422
1906
  });
1423
1907
  return;
1424
1908
  } catch (error) {
1425
- return error instanceof Error ? error.message : "The session did not take the message.";
1909
+ return error instanceof Error ? error.message : t("git.ui.theSessionDidNotTakeTheMessage", "The session did not take the message.");
1426
1910
  }
1427
1911
  }
1428
1912
  //#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
1913
  //#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-doom-green",
1511
- label: "added"
1512
- },
1513
- modified: {
1514
- letter: "M",
1515
- tone: "text-doom-yellow",
1516
- label: "modified"
1517
- },
1518
- deleted: {
1519
- letter: "D",
1520
- tone: "text-doom-red",
1521
- label: "deleted"
1522
- },
1523
- untracked: {
1524
- letter: "U",
1525
- tone: "text-doom-blue",
1526
- label: "untracked"
1527
- },
1528
- conflicted: {
1529
- letter: "C",
1530
- tone: "text-doom-red",
1531
- label: "conflicted"
1532
- }
1533
- };
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
1914
  function GitReviewBrowser({ files, activePath, commentCounts, onPick }) {
1915
+ const t = useT();
1916
+ const status = {
1917
+ added: [
1918
+ "A",
1919
+ "text-po-green",
1920
+ t("git.ui.added", "Added")
1921
+ ],
1922
+ modified: [
1923
+ "M",
1924
+ "text-po-yellow",
1925
+ t("git.ui.modified", "Modified")
1926
+ ],
1927
+ deleted: [
1928
+ "D",
1929
+ "text-po-red",
1930
+ t("git.ui.deleted", "Deleted")
1931
+ ],
1932
+ untracked: [
1933
+ "U",
1934
+ "text-po-blue",
1935
+ t("git.ui.untracked", "Untracked")
1936
+ ],
1937
+ conflicted: [
1938
+ "C",
1939
+ "text-po-red",
1940
+ t("git.ui.conflicted", "Conflicted")
1941
+ ]
1942
+ };
1538
1943
  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] : []);
1944
+ const shown = files.filter((f) => f.path.toLowerCase().includes(query.trim().toLowerCase()));
1544
1945
  const listRef = useRef(null);
1545
1946
  useEffect(() => {
1546
1947
  if (activePath === void 0) return;
1547
- (listRef.current?.querySelector(`[data-path="${CSS.escape(activePath)}"]`))?.scrollIntoView({ block: "nearest" });
1948
+ listRef.current?.querySelector(`[data-path="${CSS.escape(activePath)}"]`)?.scrollIntoView({ block: "nearest" });
1548
1949
  }, [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
1950
  /** Arrow keys pick the neighbouring row and move focus with it, so the diff follows the cursor. */
1558
1951
  const onKeyDown = (event) => {
1559
1952
  if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
1560
- if (ordered.length === 0) return;
1953
+ if (shown.length === 0) return;
1561
1954
  event.preventDefault();
1562
- const current = ordered.findIndex((file) => file.path === activePath);
1955
+ const current = shown.findIndex((file) => file.path === activePath);
1563
1956
  const step = event.key === "ArrowDown" ? 1 : -1;
1564
- const next = current === -1 ? 0 : (current + step + ordered.length) % ordered.length;
1565
- const file = ordered[next];
1957
+ const next = current === -1 ? 0 : (current + step + shown.length) % shown.length;
1958
+ const file = shown[next];
1566
1959
  if (file === void 0) return;
1567
1960
  onPick(file.path);
1568
1961
  event.currentTarget.closest("[data-git-review-list]")?.querySelectorAll("[data-git-review-row]")[next]?.focus();
1569
1962
  };
1570
1963
  return /* @__PURE__ */ jsxs("nav", {
1964
+ "aria-label": t("git.ui.changedFiles", "Changed files"),
1571
1965
  "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-doom-border-soft",
1966
+ className: "flex min-h-0 w-80 shrink-0 flex-col border-r border-po-border-soft",
1574
1967
  children: [/* @__PURE__ */ jsxs("div", {
1575
- className: "flex shrink-0 flex-col gap-1 px-3 pt-2.5 pb-1.5",
1968
+ className: "flex flex-col gap-3 border-b border-po-border-soft p-3",
1576
1969
  children: [/* @__PURE__ */ jsx(Input, {
1577
1970
  "data-testid": "git-review-search",
1578
- "aria-label": "search changed file paths",
1579
1971
  size: "sm",
1972
+ "aria-label": t("git.ui.searchPaths", "Search paths"),
1973
+ placeholder: t("git.ui.searchPaths", "Search paths"),
1580
1974
  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-doom-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]
1975
+ onChange: (e) => setQuery(e.target.value)
1976
+ }), /* @__PURE__ */ jsxs("span", {
1977
+ className: "text-sm text-po-dim",
1978
+ children: [
1979
+ shown.length,
1980
+ " ",
1981
+ t("git.ui.changed", "changed")
1982
+ ]
1596
1983
  })]
1597
1984
  }), /* @__PURE__ */ jsxs("div", {
1598
1985
  ref: listRef,
1599
1986
  "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-doom-panel/60",
1613
- children: [/* @__PURE__ */ jsx(Chevron, {
1614
- "aria-hidden": true,
1615
- className: "h-3 w-3 shrink-0 text-doom-faint"
1616
- }), /* @__PURE__ */ jsx("span", {
1617
- className: "min-w-0 flex-1 truncate text-base text-doom-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",
1987
+ className: "min-h-0 flex-1 overflow-y-auto",
1988
+ children: [shown.map((f) => {
1989
+ const slash = f.path.lastIndexOf("/");
1990
+ const count = commentCounts[f.path] ?? 0;
1991
+ return /* @__PURE__ */ jsxs("button", {
1629
1992
  "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),
1993
+ "data-path": f.path,
1994
+ "data-testid": `git-review-browser-file-${f.path}`,
1635
1995
  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-doom-blue bg-doom-panel" : "border-transparent hover:bg-doom-panel/60"}`,
1996
+ title: f.path,
1997
+ "aria-current": activePath === f.path ? "true" : void 0,
1998
+ onClick: () => onPick(f.path),
1999
+ 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
2000
  children: [
1639
2001
  /* @__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-doom-hi ${active ? "font-semibold" : ""} ${file.status === "deleted" ? "line-through opacity-70" : ""}`,
1646
- children: baseName(file.path)
2002
+ className: `pt-0.5 text-sm font-semibold ${status[f.status][1]}`,
2003
+ children: status[f.status][0]
1647
2004
  }),
1648
- comments === 0 ? null : /* @__PURE__ */ jsxs("span", {
1649
- className: "flex shrink-0 items-center gap-0.5 text-sm text-doom-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]
2005
+ /* @__PURE__ */ jsxs("span", {
2006
+ className: "min-w-0 flex-1",
2007
+ children: [/* @__PURE__ */ jsx("span", {
2008
+ className: "block truncate text-base text-po-text",
2009
+ children: f.path.slice(slash + 1)
2010
+ }), slash < 0 ? null : /* @__PURE__ */ jsx("span", {
2011
+ className: "block truncate font-mono text-sm text-po-dim",
2012
+ children: f.path.slice(0, slash)
2013
+ })]
1655
2014
  }),
1656
- file.binary ? /* @__PURE__ */ jsx("span", {
1657
- className: "shrink-0 text-sm text-doom-dim",
1658
- children: "binary"
1659
- }) : /* @__PURE__ */ jsxs("span", {
1660
- className: "shrink-0 text-2xs",
1661
- children: [
2015
+ /* @__PURE__ */ jsxs("span", {
2016
+ className: "flex shrink-0 flex-col items-end gap-1 text-sm",
2017
+ children: [/* @__PURE__ */ jsxs("span", { children: [
1662
2018
  /* @__PURE__ */ jsxs("span", {
1663
- className: "text-doom-green",
1664
- children: ["+", file.added]
2019
+ className: "text-po-green",
2020
+ children: ["+", f.added]
1665
2021
  }),
1666
2022
  " ",
1667
2023
  /* @__PURE__ */ jsxs("span", {
1668
- className: "text-doom-red",
1669
- children: ["-", file.removed]
2024
+ className: "text-po-red",
2025
+ children: ["-", f.removed]
1670
2026
  })
1671
- ]
2027
+ ] }), count > 0 && /* @__PURE__ */ jsxs("span", {
2028
+ className: "flex items-center gap-1 text-po-blue",
2029
+ children: [/* @__PURE__ */ jsx(MessageIcon, { className: "h-3 w-3" }), count]
2030
+ })]
1672
2031
  })
1673
2032
  ]
1674
- }, file.path);
1675
- }), ordered.length === 0 ? /* @__PURE__ */ jsx("p", {
1676
- className: "px-3 py-2 text-sm text-doom-dim",
1677
- children: "no path matches"
1678
- }) : null]
2033
+ }, f.path);
2034
+ }), shown.length === 0 && /* @__PURE__ */ jsx(EmptyState, {
2035
+ "data-testid": "git-review-browser-no-match",
2036
+ size: "compact",
2037
+ surface: "plain",
2038
+ icon: /* @__PURE__ */ jsx(SearchIcon, {}),
2039
+ title: t("git.ui.noPathsMatch", "No paths match"),
2040
+ description: query.trim() ? t("git.review.noMatchingPath", "No changed file path contains \"{query}\".", { query: query.trim() }) : void 0,
2041
+ secondaryAction: {
2042
+ label: t("git.ui.clearFilter", "Clear filter"),
2043
+ onAction: () => setQuery("")
2044
+ }
2045
+ })]
1679
2046
  })]
1680
2047
  });
1681
2048
  }
1682
2049
  //#endregion
1683
2050
  //#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;
2051
+ function GitSyncBar({ secondary = false, ...props }) {
2052
+ const t = useT();
2053
+ const c = props.changes;
2054
+ const paused = c?.rebase !== void 0;
2055
+ const busy = props.pending !== void 0;
2056
+ const rejected = props.errorTarget?.action === "push" && props.errorTarget.forceRequired;
2057
+ const suggested = suggestedSyncAction(c);
2058
+ const upstream = upstreamSummary(t, c?.upstream);
1707
2059
  return /* @__PURE__ */ jsxs("div", {
1708
2060
  "data-testid": "git-sync-bar",
1709
- className: "flex shrink-0 flex-col gap-2 border-b border-doom-border-soft px-3 py-2.5 sm:px-[26px]",
2061
+ className: "flex flex-col gap-3 border-b border-po-border-soft p-4",
1710
2062
  children: [
1711
2063
  /* @__PURE__ */ jsxs("div", {
1712
- className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5",
2064
+ className: "flex flex-wrap items-center gap-3 text-sm",
1713
2065
  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-doom-faint"
1720
- }),
2066
+ /* @__PURE__ */ jsx(BranchIcon, { className: "h-4 w-4 text-po-dim" }),
2067
+ /* @__PURE__ */ jsx("span", {
2068
+ "data-testid": "git-review-branch",
2069
+ className: "font-mono text-base font-semibold text-po-hi",
2070
+ children: c?.branch ?? t("git.ui.detachedHEAD", "Detached HEAD")
2071
+ }),
2072
+ /* @__PURE__ */ jsx("span", {
2073
+ className: "text-po-dim",
2074
+ children: c?.base === void 0 ? t("git.ui.uncommittedChanges", "Uncommitted changes") : /* @__PURE__ */ jsxs(Fragment, { children: [
2075
+ t("git.ui.vs", "vs"),
2076
+ " ",
1721
2077
  /* @__PURE__ */ jsx("span", {
1722
- "data-testid": "git-review-branch",
1723
- className: "truncate text-base font-semibold text-doom-hi",
1724
- children: changes?.branch ?? "detached HEAD"
1725
- }),
2078
+ className: "font-mono",
2079
+ children: c.base
2080
+ })
2081
+ ] })
2082
+ }),
2083
+ props.mergeBase && /* @__PURE__ */ jsxs("span", {
2084
+ className: "text-po-dim",
2085
+ children: [
2086
+ t("git.ui.fromLabel", "from"),
2087
+ " ",
1726
2088
  /* @__PURE__ */ jsx("span", {
1727
- className: "shrink-0 text-sm text-doom-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-doom-dim",
1732
- children: ["from ", mergeBase]
2089
+ className: "font-mono",
2090
+ children: props.mergeBase
1733
2091
  })
1734
2092
  ]
1735
2093
  }),
1736
- changes === void 0 ? null : /* @__PURE__ */ jsxs("span", {
2094
+ c === void 0 ? null : /* @__PURE__ */ jsxs("span", {
1737
2095
  "data-testid": "git-review-totals",
1738
- className: "flex shrink-0 items-center gap-1.5 text-sm",
2096
+ className: "contents",
1739
2097
  children: [
1740
2098
  /* @__PURE__ */ jsxs("span", {
1741
- className: "font-semibold text-doom-green",
1742
- children: ["+", changes.added]
2099
+ className: "text-po-green",
2100
+ children: ["+", c?.added]
1743
2101
  }),
1744
2102
  /* @__PURE__ */ jsxs("span", {
1745
- className: "font-semibold text-doom-red",
1746
- children: ["-", changes.removed]
2103
+ className: "text-po-red",
2104
+ children: ["-", c?.removed]
1747
2105
  }),
1748
2106
  /* @__PURE__ */ jsxs("span", {
1749
- className: "text-doom-dim",
2107
+ className: "text-po-dim",
1750
2108
  children: [
1751
- changes.files,
1752
- changes.truncated ? "+" : "",
2109
+ c?.files,
2110
+ c?.truncated ? "+" : "",
1753
2111
  " ",
1754
- changes.files === 1 ? "file" : "files"
2112
+ c?.files === 1 ? t("git.ui.file", "file") : t("git.ui.files", "files")
1755
2113
  ]
1756
2114
  })
1757
2115
  ]
1758
2116
  }),
1759
- /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }),
1760
- upstream === void 0 ? /* @__PURE__ */ jsx("span", {
1761
- className: "shrink-0 text-sm text-doom-dim",
1762
- children: "no upstream yet"
1763
- }) : /* @__PURE__ */ jsxs("span", {
1764
- className: "shrink-0 text-sm text-doom-dim",
1765
- title: upstream.ref,
1766
- children: [
1767
- "↑",
1768
- upstream.ahead,
1769
- " ↓",
1770
- upstream.behind,
1771
- " ",
1772
- upstream.ref
1773
- ]
2117
+ /* @__PURE__ */ jsx("span", { className: "flex-1" }),
2118
+ /* @__PURE__ */ jsx("span", {
2119
+ className: "text-po-dim",
2120
+ children: c?.branch === void 0 ? t("git.ui.noBranchCheckedOut", "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", {
2121
+ className: "font-mono",
2122
+ children: c.upstream.ref
2123
+ })] })
1774
2124
  }),
1775
- /* @__PURE__ */ jsxs("span", {
1776
- className: "flex shrink-0 items-center gap-1.5",
2125
+ /* @__PURE__ */ jsx("div", {
2126
+ className: "flex gap-1.5",
1777
2127
  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
- ]
2128
+ "pull",
2129
+ "push",
2130
+ "rebase"
2131
+ ].map((action) => /* @__PURE__ */ jsx(Button, {
2132
+ "data-testid": `git-sync-${action}`,
2133
+ size: "sm",
2134
+ variant: !busy && !paused && !rejected && !props.error && c?.branch !== void 0 && suggested === action ? secondary ? "outline" : "primary" : "ghost",
2135
+ disabled: busy || paused || action !== "rebase" && c?.branch === void 0 || action === "pull" && c?.upstream === void 0 || action === "rebase" && c?.base === void 0,
2136
+ onClick: () => props.onSync(action),
2137
+ children: action === "pull" ? t("git.ui.pull", "Pull") : action === "push" ? t("git.ui.push", "Push") : t("git.ui.rebase", "Rebase")
2138
+ }, action))
1803
2139
  })
1804
2140
  ]
1805
2141
  }),
1806
- pending === void 0 ? null : /* @__PURE__ */ jsxs("span", {
2142
+ busy && /* @__PURE__ */ jsxs("div", {
1807
2143
  "data-testid": "git-sync-pending",
1808
- className: "flex min-w-0 items-center gap-1.5",
2144
+ className: "flex items-center gap-2 text-sm text-po-dim",
1809
2145
  children: [/* @__PURE__ */ jsx(Spinner, {
1810
- className: "h-3 w-3 shrink-0 text-doom-faint",
1811
- label: pending
1812
- }), /* @__PURE__ */ jsx("span", {
1813
- className: "min-w-0 truncate text-sm text-doom-dim",
1814
- children: pending
1815
- })]
2146
+ className: "h-4 w-4 text-po-dim",
2147
+ label: props.pending
2148
+ }), props.pending]
1816
2149
  }),
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-doom-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
- ]
1838
- }),
1839
- forceRequired ? /* @__PURE__ */ jsxs("div", {
2150
+ rejected ? /* @__PURE__ */ jsxs("div", {
1840
2151
  "data-testid": "git-push-force-confirm",
1841
- className: "flex min-w-0 flex-wrap items-center gap-2 rounded-md border border-doom-edge-yellow bg-doom-tint-yellow px-2.5 py-2",
2152
+ className: "flex flex-wrap items-center gap-3 rounded-md border border-po-edge-yellow bg-po-tint-yellow p-3",
1842
2153
  children: [
1843
2154
  /* @__PURE__ */ jsx("span", {
1844
- className: "min-w-0 flex-1 text-base text-doom-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."
2155
+ className: "flex-1 text-base text-po-text",
2156
+ children: t("git.ui.originHasCommitsYouHaveNotPulledYet", "origin has commits you have not pulled yet.")
1846
2157
  }),
1847
2158
  /* @__PURE__ */ jsx(Button, {
2159
+ size: "sm",
1848
2160
  variant: "danger-outline",
1849
- size: "xs",
1850
2161
  "data-testid": "git-push-force",
1851
2162
  disabled: busy,
1852
- onClick: onForcePush,
1853
- children: "force push"
2163
+ onClick: props.onForcePush,
2164
+ children: t("git.ui.forcePushWithLease", "Force push with lease")
1854
2165
  }),
1855
2166
  /* @__PURE__ */ jsx(Button, {
2167
+ size: "sm",
1856
2168
  variant: "ghost",
1857
- size: "xs",
1858
2169
  "data-testid": "git-push-force-cancel",
1859
- onClick: onDismissError,
1860
- children: "cancel"
2170
+ onClick: props.onDismissError,
2171
+ children: t("git.ui.notNow", "Not now")
1861
2172
  })
1862
2173
  ]
1863
- }) : null,
1864
- changes?.rebase === void 0 ? null : /* @__PURE__ */ jsxs("div", {
2174
+ }) : props.error && /* @__PURE__ */ jsxs("div", {
2175
+ role: "alert",
2176
+ "data-testid": "git-sync-error",
2177
+ className: "flex items-center gap-3 rounded-md border border-po-edge-red bg-po-tint-red p-3 text-base text-po-red",
2178
+ children: [/* @__PURE__ */ jsx("span", {
2179
+ className: "flex-1",
2180
+ children: props.error
2181
+ }), /* @__PURE__ */ jsx(Button, {
2182
+ size: "sm",
2183
+ variant: "ghost",
2184
+ onClick: props.onDismissError,
2185
+ children: t("git.ui.dismiss", "Dismiss")
2186
+ })]
2187
+ }),
2188
+ paused && /* @__PURE__ */ jsxs("div", {
1865
2189
  "data-testid": "git-rebase-banner",
1866
- className: "flex min-w-0 flex-col gap-1.5 rounded-md border border-doom-edge-red bg-doom-tint-red px-2.5 py-2",
2190
+ className: "flex flex-col gap-2 rounded-md border border-po-edge-yellow bg-po-tint-yellow p-3",
1867
2191
  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-doom-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-doom-dim",
1883
- children: file
1884
- }, file))
1885
- }),
1886
- /* @__PURE__ */ jsxs("span", {
1887
- className: "flex flex-wrap items-center gap-1.5",
2192
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(StatusBadge, {
2193
+ tone: "running",
2194
+ size: "xs",
2195
+ children: t("git.ui.rebasePaused", "Rebase paused")
2196
+ }), /* @__PURE__ */ jsxs("span", {
2197
+ className: "ml-2 text-base text-po-text",
2198
+ children: [
2199
+ t("git.ui.conflictsIn", "Conflicts in"),
2200
+ " ",
2201
+ c.rebase?.conflicts.length,
2202
+ " ",
2203
+ c.rebase?.conflicts.length === 1 ? t("git.ui.file", "file") : t("git.ui.files", "files")
2204
+ ]
2205
+ })] }),
2206
+ c.rebase?.conflicts.map((path) => /* @__PURE__ */ jsx("p", {
2207
+ className: "font-mono text-sm text-po-dim",
2208
+ children: path
2209
+ }, path)),
2210
+ /* @__PURE__ */ jsxs("div", {
2211
+ className: "flex items-center gap-2",
1888
2212
  children: [
1889
2213
  /* @__PURE__ */ jsx(Button, {
1890
- variant: "primary",
1891
- size: "xs",
2214
+ variant: secondary ? "outline" : "primary",
2215
+ size: "sm",
1892
2216
  "data-testid": "git-rebase-ask-agent",
1893
2217
  disabled: busy,
1894
- onClick: onAskAgent,
1895
- children: "ask agent to resolve"
2218
+ onClick: props.onAskAgent,
2219
+ children: t("git.ui.askPoToResolve", "Ask Po to resolve")
1896
2220
  }),
1897
2221
  /* @__PURE__ */ jsx(Button, {
1898
2222
  variant: "danger-outline",
1899
- size: "xs",
2223
+ size: "sm",
1900
2224
  "data-testid": "git-rebase-abort",
1901
2225
  disabled: busy,
1902
- onClick: () => onSync("abort-rebase"),
1903
- children: "abort rebase"
2226
+ onClick: () => props.onSync("abort-rebase"),
2227
+ children: t("git.ui.abortRebase", "Abort rebase")
1904
2228
  }),
1905
2229
  /* @__PURE__ */ jsx("span", {
1906
- className: "text-sm text-doom-dim",
1907
- children: "abort discards any conflict resolution in progress"
2230
+ className: "text-sm text-po-dim",
2231
+ children: t("git.ui.abortDiscardsConflictResolutionInProgress", "Abort discards conflict resolution in progress.")
1908
2232
  })
1909
2233
  ]
1910
2234
  })
@@ -1915,29 +2239,7 @@ function GitSyncBar({ changes, mergeBase, pending, error, errorTarget, onSync, o
1915
2239
  }
1916
2240
  //#endregion
1917
2241
  //#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
2242
  const NO_FILES = [];
1940
- const NO_PATHS = /* @__PURE__ */ new Set();
1941
2243
  /** Stable, URL-safe element id for one file's section. */
1942
2244
  function sectionId(index) {
1943
2245
  return `git-review-file-${String(index)}`;
@@ -1945,122 +2247,31 @@ function sectionId(index) {
1945
2247
  function sideOf(row) {
1946
2248
  return row.marker === "-" ? "old" : "new";
1947
2249
  }
1948
- function GitReviewView({ sync, summary, files, comments, onLoadFile, onAddComment, onRemoveComment, onSendReview, onDiscard, onDraftChange, sendError, initialDraft }) {
2250
+ function GitReviewView({ sync, summary, files, comments, onLoadFile, onAddComment, onRemoveComment, onSendReview, onDiscard, onDraftChange, sendError, initialDraft, initialPath }) {
2251
+ const t = useT();
1949
2252
  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);
2253
+ const [picked, setPicked] = useState(initialPath ?? initialDraft?.path);
1961
2254
  const activePath = entries.some((entry) => entry.path === picked) ? picked : entries[0]?.path;
2255
+ const index = entries.findIndex((entry) => entry.path === activePath);
2256
+ const file = entries[index];
1962
2257
  const [draft, setDraft] = useState(initialDraft);
1963
2258
  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);
2259
+ if (activePath !== void 0 && files[activePath] === void 0) onLoadFile(activePath);
2032
2260
  }, [
2033
- entries,
2261
+ activePath,
2034
2262
  files,
2035
- near,
2036
- navigation,
2037
- draft,
2038
- comments,
2039
- openOverride,
2040
2263
  onLoadFile
2041
2264
  ]);
2042
2265
  const commentCounts = {};
2043
2266
  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
2267
  const pick = (path) => {
2052
2268
  if (!entries.some((entry) => entry.path === path)) return;
2053
- pickedAt.current = Date.now();
2269
+ if (path !== activePath && draft !== void 0) {
2270
+ if (!window.confirm(t("git.ui.discardTheUnsentCommentAndOpenAnotherFileConfirm", "Discard the unsent comment and open another file?"))) return;
2271
+ setDraft(void 0);
2272
+ onDraftChange?.(false);
2273
+ }
2054
2274
  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
2275
  };
2065
2276
  const submitDraft = (body) => {
2066
2277
  if (draft === void 0) return;
@@ -2082,102 +2293,133 @@ function GitReviewView({ sync, summary, files, comments, onLoadFile, onAddCommen
2082
2293
  children: [
2083
2294
  /* @__PURE__ */ jsx(GitSyncBar, {
2084
2295
  ...sync,
2296
+ secondary: comments.length > 0,
2085
2297
  ...summary.state === "ready" && summary.summary.mergeBase !== void 0 ? { mergeBase: summary.summary.mergeBase } : {}
2086
2298
  }),
2087
2299
  summary.state === "loading" ? /* @__PURE__ */ jsxs("div", {
2088
2300
  "data-testid": "git-review-loading",
2089
- className: "flex flex-1 items-start gap-2 px-4 py-6",
2301
+ className: "flex min-h-48 flex-1 items-center justify-center gap-2 text-sm text-po-dim",
2090
2302
  children: [/* @__PURE__ */ jsx(Spinner, {
2091
- className: "h-3 w-3 text-doom-faint",
2092
- label: "reading changes"
2303
+ className: "h-4 w-4 text-po-dim",
2304
+ label: t("git.ui.readingChanges", "Reading changes")
2093
2305
  }), /* @__PURE__ */ jsx("span", {
2094
- className: "text-sm text-doom-dim",
2095
- children: "reading changes…"
2306
+ className: "text-sm text-po-dim",
2307
+ children: t("git.ui.readingChangesPending", "Reading changes...")
2096
2308
  })]
2097
- }) : summary.state === "error" ? /* @__PURE__ */ jsx("p", {
2098
- role: "alert",
2309
+ }) : summary.state === "error" ? /* @__PURE__ */ jsx(EmptyState, {
2099
2310
  "data-testid": "git-review-error",
2100
- className: "flex-1 px-4 py-6 text-sm text-doom-red",
2101
- children: summary.error
2311
+ className: "min-h-48 text-po-red",
2312
+ title: /* @__PURE__ */ jsx("span", {
2313
+ className: "text-po-red",
2314
+ children: t("git.ui.changesCouldNotBeRead", "Changes could not be read")
2315
+ }),
2316
+ description: summary.error
2102
2317
  }) : !summary.summary.repository ? /* @__PURE__ */ jsx(EmptyState, {
2103
2318
  "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."
2319
+ className: "min-h-48",
2320
+ title: t("git.ui.notAGitCheckout", "Not a Git checkout"),
2321
+ description: t("git.ui.thisSessionSFolderIsNotInsideAGitRepository", "This session's folder is not inside a Git repository.")
2107
2322
  }) : entries.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
2108
2323
  "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.`
2324
+ className: "min-h-48",
2325
+ title: t("git.ui.noChangesYet", "No changes yet"),
2326
+ description: summary.summary.base === void 0 ? t("git.ui.nothingUncommittedInThisCheckout", "Nothing uncommitted in this checkout.") : t("git.review.nothingDiffers", "Nothing differs from {base}, committed or not.", { base: summary.summary.base })
2112
2327
  }) : /* @__PURE__ */ jsxs("div", {
2328
+ "data-testid": "git-review-content",
2113
2329
  className: "flex min-h-0 flex-1",
2114
2330
  children: [/* @__PURE__ */ jsx(GitReviewBrowser, {
2115
2331
  files: entries,
2116
2332
  commentCounts,
2117
2333
  onPick: pick,
2118
2334
  ...activePath === void 0 ? {} : { activePath }
2119
- }), /* @__PURE__ */ jsxs("div", {
2120
- ref: paneRef,
2335
+ }), /* @__PURE__ */ jsxs("main", {
2121
2336
  "data-testid": "git-review-diffs",
2122
2337
  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-doom-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))]
2338
+ children: [
2339
+ summary.summary.truncated ? /* @__PURE__ */ jsx("p", {
2340
+ className: "px-4 pt-2 text-sm text-po-dim",
2341
+ children: t("git.ui.moreFilesChangedThanTheReviewListsTheRestAreLeftOut", "More files changed than the review lists; the rest are left out.")
2342
+ }) : null,
2343
+ /* @__PURE__ */ jsxs("div", {
2344
+ className: "flex items-center justify-between border-b border-po-border-soft px-4 py-2",
2345
+ children: [
2346
+ /* @__PURE__ */ jsx(Button, {
2347
+ variant: "ghost",
2348
+ size: "sm",
2349
+ disabled: index <= 0,
2350
+ onClick: () => pick(entries[index - 1].path),
2351
+ children: t("git.ui.previousFile", "Previous file")
2352
+ }),
2353
+ /* @__PURE__ */ jsxs("span", {
2354
+ className: "text-sm text-po-dim",
2355
+ children: [
2356
+ index + 1,
2357
+ " ",
2358
+ t("git.ui.of", "of"),
2359
+ " ",
2360
+ entries.length
2361
+ ]
2362
+ }),
2363
+ /* @__PURE__ */ jsx(Button, {
2364
+ variant: "ghost",
2365
+ size: "sm",
2366
+ disabled: index >= entries.length - 1,
2367
+ onClick: () => pick(entries[index + 1].path),
2368
+ children: t("git.ui.nextFile", "Next file")
2369
+ })
2370
+ ]
2371
+ }),
2372
+ file === void 0 ? null : /* @__PURE__ */ jsx(FileSection, {
2373
+ id: sectionId(index),
2374
+ entry: file,
2375
+ state: files[file.path],
2376
+ comments: comments.filter((comment) => comment.path === file.path),
2377
+ draft: draft?.path === file.path ? draft.selection : void 0,
2378
+ onSelect: (selection) => {
2379
+ setDraft({
2380
+ path: file.path,
2381
+ selection
2382
+ });
2383
+ onDraftChange?.(true);
2384
+ },
2385
+ onSubmitDraft: submitDraft,
2386
+ onCancelDraft: () => {
2387
+ setDraft(void 0);
2388
+ onDraftChange?.(false);
2389
+ },
2390
+ onRemoveComment,
2391
+ onRetry: () => onLoadFile(file.path)
2392
+ }, file.path)
2393
+ ]
2152
2394
  })]
2153
2395
  }),
2154
2396
  /* @__PURE__ */ jsxs("div", {
2155
2397
  "data-testid": "git-review-footer",
2156
- className: "flex shrink-0 flex-wrap items-center gap-2 border-t border-doom-border-soft bg-doom-panel px-3 py-2 sm:px-[26px]",
2398
+ className: "flex shrink-0 flex-wrap items-center gap-3 border-t border-po-border-soft bg-po-panel px-4 py-3",
2157
2399
  children: [
2158
2400
  /* @__PURE__ */ jsx(MessageIcon, {
2159
2401
  "aria-hidden": true,
2160
- className: "h-3 w-3 text-doom-faint"
2402
+ className: "h-4 w-4 text-po-blue"
2161
2403
  }),
2162
2404
  /* @__PURE__ */ jsx("span", {
2163
2405
  "data-testid": "git-review-comment-count",
2164
- className: "text-sm text-doom-dim",
2165
- children: comments.length === 0 ? "no comments yet: select lines or click a line number" : `${String(comments.length)} ${comments.length === 1 ? "comment" : "comments"}`
2406
+ className: "text-sm text-po-dim",
2407
+ children: comments.length === 0 ? t("git.ui.noCommentsYetSelectLinesOrClickALineNumber", "No comments yet: select lines or click a line number") : comments.length === 1 ? t("git.review.commentsQueuedOne", "{count} comment queued", { count: comments.length }) : t("git.review.commentsQueued", "{count} comments queued", { count: comments.length })
2166
2408
  }),
2167
2409
  /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }),
2168
2410
  sendError === void 0 ? null : /* @__PURE__ */ jsx("span", {
2169
2411
  role: "alert",
2170
2412
  "data-testid": "git-review-send-error",
2171
- className: "min-w-0 truncate text-sm text-doom-red",
2413
+ className: "min-w-0 truncate text-sm text-po-red",
2172
2414
  children: sendError
2173
2415
  }),
2174
2416
  /* @__PURE__ */ jsx(Button, {
2175
2417
  variant: "ghost",
2176
- size: "xs",
2418
+ size: "sm",
2177
2419
  "data-testid": "git-review-discard",
2178
2420
  disabled: comments.length === 0,
2179
2421
  onClick: onDiscard,
2180
- children: "discard"
2422
+ children: t("git.ui.discard", "Discard")
2181
2423
  }),
2182
2424
  /* @__PURE__ */ jsx(Button, {
2183
2425
  variant: "primary",
@@ -2185,58 +2427,63 @@ function GitReviewView({ sync, summary, files, comments, onLoadFile, onAddCommen
2185
2427
  "data-testid": "git-review-send",
2186
2428
  disabled: comments.length === 0,
2187
2429
  onClick: onSendReview,
2188
- children: "send review"
2430
+ children: t("git.ui.sendReview", "Send review")
2189
2431
  })
2190
2432
  ]
2191
2433
  })
2192
2434
  ]
2193
2435
  });
2194
2436
  }
2195
- const STATUS_WORD = {
2196
- added: "added",
2197
- modified: "modified",
2198
- deleted: "deleted",
2199
- untracked: "new, untracked",
2200
- conflicted: "conflicted"
2201
- };
2202
2437
  /** 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 }) {
2438
+ function FileSection({ id, entry, state, comments, draft, onSelect, onSubmitDraft, onCancelDraft, onRemoveComment, onRetry }) {
2439
+ const t = useT();
2440
+ const STATUS_WORD = {
2441
+ added: t("git.ui.added", "Added"),
2442
+ modified: t("git.ui.modified", "Modified"),
2443
+ deleted: t("git.ui.deleted", "Deleted"),
2444
+ untracked: t("git.ui.untracked", "Untracked"),
2445
+ conflicted: t("git.ui.conflicted", "Conflicted")
2446
+ };
2204
2447
  const renderAfterRow = (row) => {
2205
2448
  const side = sideOf(row);
2206
2449
  const here = comments.filter((comment) => (comment.side ?? "new") === side && (comment.endLine ?? comment.startLine) === row.line);
2207
2450
  const drafting = draft !== void 0 && draft.side === side && draft.endLine === row.line;
2208
2451
  if (here.length === 0 && !drafting) return null;
2209
2452
  return /* @__PURE__ */ jsxs("div", {
2210
- className: "flex flex-col gap-1.5 border-y border-doom-border-soft bg-doom-bg px-2 py-1.5 font-sans whitespace-normal",
2453
+ className: "font-sans whitespace-normal",
2211
2454
  children: [here.map((comment) => /* @__PURE__ */ jsxs("div", {
2212
2455
  "data-testid": `git-review-comment-${comment.id}`,
2213
- className: "flex min-w-0 items-start gap-2 rounded-md border border-doom-border-soft bg-doom-panel px-2 py-1.5",
2456
+ 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
2457
  children: [
2215
2458
  /* @__PURE__ */ jsx(MessageIcon, {
2216
2459
  "aria-hidden": true,
2217
- className: "mt-0.5 h-3 w-3 shrink-0 text-doom-blue"
2460
+ className: "mt-1 h-4 w-4 shrink-0 text-po-blue"
2218
2461
  }),
2219
2462
  /* @__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-doom-dim",
2223
- children: reviewCommentAnchor(comment)
2463
+ className: "flex min-w-0 flex-1 flex-col",
2464
+ children: [/* @__PURE__ */ jsxs("span", {
2465
+ className: "mb-1 text-sm text-po-dim",
2466
+ children: [
2467
+ t("git.ui.youLine", "You · line"),
2468
+ " ",
2469
+ comment.endLine ?? comment.startLine
2470
+ ]
2224
2471
  }), /* @__PURE__ */ jsx("span", {
2225
- className: "text-base whitespace-pre-wrap text-doom-text",
2472
+ className: "text-base whitespace-pre-wrap text-po-text",
2226
2473
  children: comment.body
2227
2474
  })]
2228
2475
  }),
2229
2476
  /* @__PURE__ */ jsx(Button, {
2230
2477
  variant: "ghost",
2231
- size: "icon",
2232
- "aria-label": "remove comment",
2233
- title: "remove comment",
2478
+ size: "sm",
2479
+ "aria-label": t("git.ui.removeComment", "Remove comment"),
2480
+ title: t("git.ui.removeComment", "Remove comment"),
2234
2481
  onClick: () => onRemoveComment(comment.id),
2235
- children: /* @__PURE__ */ jsx(CloseIcon, { className: "h-3 w-3" })
2482
+ children: t("git.ui.remove", "Remove")
2236
2483
  })
2237
2484
  ]
2238
2485
  }, comment.id)), drafting ? /* @__PURE__ */ jsx("div", {
2239
- className: "rounded-md border border-doom-border bg-doom-panel",
2486
+ 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
2487
  children: /* @__PURE__ */ jsx(ReviewCommentDraft, {
2241
2488
  snippet: draft.snippet,
2242
2489
  startLine: draft.startLine,
@@ -2253,90 +2500,68 @@ function FileSection({ id, entry, state, collapsed, mounted, placeholderHeight,
2253
2500
  id,
2254
2501
  "data-review-path": entry.path,
2255
2502
  "data-testid": `git-review-file-${entry.path}`,
2256
- className: "border-b border-doom-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-doom-border-soft bg-doom-rail px-3 py-1.5 hover:bg-doom-panel sm:px-4",
2503
+ children: [/* @__PURE__ */ jsxs("div", {
2504
+ className: "flex flex-wrap items-center gap-3 border-b border-po-border-soft bg-po-panel px-4 py-3",
2263
2505
  children: [
2264
- collapsed ? /* @__PURE__ */ jsx(ChevronRightIcon, {
2265
- "aria-hidden": true,
2266
- className: "h-3 w-3 shrink-0 text-doom-faint"
2267
- }) : /* @__PURE__ */ jsx(ChevronDownIcon, {
2268
- "aria-hidden": true,
2269
- className: "h-3 w-3 shrink-0 text-doom-faint"
2270
- }),
2271
2506
  /* @__PURE__ */ jsx("span", {
2272
- className: "min-w-0 flex-1 truncate font-mono text-base font-semibold text-doom-hi",
2507
+ className: "min-w-0 flex-1 truncate font-mono text-base text-po-hi",
2273
2508
  children: entry.path
2274
2509
  }),
2275
2510
  /* @__PURE__ */ jsx("span", {
2276
- className: "shrink-0 text-sm font-semibold text-doom-dim",
2511
+ className: "shrink-0 text-sm text-po-dim",
2277
2512
  children: STATUS_WORD[entry.status]
2278
2513
  }),
2514
+ entry.binary ? null : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
2515
+ className: "text-sm text-po-green",
2516
+ children: ["+", entry.added]
2517
+ }), /* @__PURE__ */ jsxs("span", {
2518
+ className: "text-sm text-po-red",
2519
+ children: ["-", entry.removed]
2520
+ })] }),
2279
2521
  comments.length === 0 ? null : /* @__PURE__ */ jsxs("span", {
2280
- className: "flex shrink-0 items-center gap-0.5 text-sm text-doom-blue",
2522
+ className: "flex shrink-0 items-center gap-1 text-sm text-po-blue",
2281
2523
  children: [/* @__PURE__ */ jsx(MessageIcon, {
2282
2524
  "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",
2288
- children: [
2289
- /* @__PURE__ */ jsxs("span", {
2290
- className: "text-doom-green",
2291
- children: ["+", entry.added]
2292
- }),
2293
- " ",
2294
- /* @__PURE__ */ jsxs("span", {
2295
- className: "text-doom-red",
2296
- children: ["-", entry.removed]
2297
- })
2298
- ]
2525
+ className: "h-3 w-3"
2526
+ }), comments.length === 1 ? t("git.ui.commentCount", "{count} comment", { count: comments.length }) : t("git.ui.commentsCount", "{count} comments", { count: comments.length })]
2299
2527
  })
2300
2528
  ]
2301
- }), collapsed ? null : !mounted ? /* @__PURE__ */ jsx("div", {
2302
- "aria-hidden": true,
2303
- style: { height: placeholderHeight }
2304
- }) : /* @__PURE__ */ jsx("div", {
2529
+ }), /* @__PURE__ */ jsx("div", {
2305
2530
  "data-review-body": state === void 0 || state.state === "loading" ? "loading" : "measured",
2306
- style: state === void 0 || state.state === "loading" ? { minHeight: placeholderHeight } : void 0,
2307
2531
  children: state === void 0 || state.state === "loading" ? /* @__PURE__ */ jsxs("div", {
2308
2532
  className: "flex items-center gap-2 px-4 py-3",
2309
2533
  children: [/* @__PURE__ */ jsx(Spinner, {
2310
- className: "h-3 w-3 text-doom-faint",
2311
- label: `loading ${entry.path}`
2534
+ className: "h-3 w-3 text-po-faint",
2535
+ label: t("git.review.loadingFile", "Loading {path}", { path: entry.path })
2312
2536
  }), /* @__PURE__ */ jsx("span", {
2313
- className: "text-sm text-doom-dim",
2314
- children: "loading diff…"
2537
+ className: "text-sm text-po-dim",
2538
+ children: t("git.ui.loadingDiffPending", "Loading diff...")
2315
2539
  })]
2316
2540
  }) : state.state === "error" ? /* @__PURE__ */ jsxs("div", {
2317
- className: "flex items-center gap-2 px-4 py-3",
2541
+ className: "flex min-h-48 flex-col items-center justify-center gap-3",
2318
2542
  children: [/* @__PURE__ */ jsx("span", {
2319
2543
  role: "alert",
2320
- className: "text-sm text-doom-red",
2544
+ className: "text-base text-po-red",
2321
2545
  children: state.error
2322
2546
  }), /* @__PURE__ */ jsx(Button, {
2323
- variant: "ghost",
2324
- size: "xs",
2547
+ variant: "outline",
2548
+ size: "sm",
2325
2549
  onClick: onRetry,
2326
- children: "retry"
2550
+ children: t("git.ui.retry", "Retry")
2327
2551
  })]
2328
- }) : state.diff.binary ? /* @__PURE__ */ jsx("p", {
2329
- className: "px-4 py-3 text-sm text-doom-dim",
2330
- children: "binary file, not drawn"
2331
- }) : state.diff.tooLarge ? /* @__PURE__ */ jsx("p", {
2332
- className: "px-4 py-3 text-sm text-doom-dim",
2333
- children: "this diff is too large to draw here"
2552
+ }) : state.diff.binary ? /* @__PURE__ */ jsx(EmptyState, {
2553
+ className: "min-h-48",
2554
+ title: t("git.ui.binaryFile", "Binary file"),
2555
+ description: t("git.review.binaryDescription", "{path} cannot be shown as a text diff.", { path: entry.path })
2556
+ }) : state.diff.tooLarge ? /* @__PURE__ */ jsx(EmptyState, {
2557
+ className: "min-h-48",
2558
+ title: t("git.ui.thisDiffIsTooLargeToShow", "This diff is too large to show"),
2559
+ description: t("git.ui.otherChangedFilesAreStillAvailableToReview", "Other changed files are still available to review.")
2334
2560
  }) : /* @__PURE__ */ jsx(DiffView, {
2335
2561
  hunks: state.diff.hunks,
2336
2562
  testId: `git-review-diff-${id}`,
2337
2563
  onSelect,
2338
- renderAfterRow,
2339
- className: "py-1"
2564
+ renderAfterRow
2340
2565
  })
2341
2566
  })]
2342
2567
  });
@@ -2364,13 +2589,15 @@ const REVIEW_TAB_ID = "git-review";
2364
2589
  function reviewTab() {
2365
2590
  return {
2366
2591
  id: REVIEW_TAB_ID,
2367
- label: "review",
2592
+ label: t("git.tab.review", "review"),
2368
2593
  panel: GitReviewPanel
2369
2594
  };
2370
2595
  }
2371
2596
  function GitReviewPanel({ sessionId, sendSessionFrame }) {
2597
+ const t = useT();
2372
2598
  const activity = useStore(gitChanges.store, (state) => gitChanges.select(state, sessionId));
2373
2599
  const comments = useStore(gitReview.store, (state) => gitReview.select(state, sessionId).comments);
2600
+ const focus = useStore(gitReview.store, (state) => gitReview.select(state, sessionId).focus);
2374
2601
  const [summary, setSummary] = useState({ state: "loading" });
2375
2602
  const [files, setFiles] = useState({});
2376
2603
  const [sendError, setSendError] = useState();
@@ -2415,7 +2642,7 @@ function GitReviewPanel({ sessionId, sendSessionFrame }) {
2415
2642
  if (controller.signal.aborted) return;
2416
2643
  setSummary({
2417
2644
  state: "error",
2418
- error: error instanceof Error ? error.message : "The changes could not be read."
2645
+ error: error instanceof Error ? error.message : t("git.ui.theChangesCouldNotBeRead", "The changes could not be read.")
2419
2646
  });
2420
2647
  });
2421
2648
  return () => {
@@ -2425,7 +2652,11 @@ function GitReviewPanel({ sessionId, sendSessionFrame }) {
2425
2652
  for (const request of pending.values()) request.abort();
2426
2653
  pending.clear();
2427
2654
  };
2428
- }, [sessionId, refreshFingerprint]);
2655
+ }, [
2656
+ sessionId,
2657
+ refreshFingerprint,
2658
+ t
2659
+ ]);
2429
2660
  const loadFile = useCallback((path) => {
2430
2661
  if (sessionId === null || !readyGeneration.current || pendingFiles.current.has(path)) return;
2431
2662
  const requestGeneration = generation.current;
@@ -2450,21 +2681,22 @@ function GitReviewPanel({ sessionId, sendSessionFrame }) {
2450
2681
  error: result.error
2451
2682
  })).catch((error) => settle({
2452
2683
  state: "error",
2453
- error: error instanceof Error ? error.message : "The diff could not be read."
2684
+ error: error instanceof Error ? error.message : t("git.ui.theDiffCouldNotBeRead", "The diff could not be read.")
2454
2685
  })).finally(() => {
2455
2686
  if (pendingFiles.current.get(path) === controller) pendingFiles.current.delete(path);
2456
2687
  });
2457
- }, [sessionId]);
2688
+ }, [sessionId, t]);
2458
2689
  if (sessionId === null) return null;
2459
2690
  const branch = summary.state === "ready" ? summary.summary.branch : changes?.branch;
2460
2691
  const base = summary.state === "ready" ? summary.summary.base : changes?.base;
2461
2692
  const error = activity.error === dismissedError ? void 0 : activity.error;
2462
2693
  const send = (message, onSent) => {
2463
- const failure = deliverToAgent(sendSessionFrame, sessionId, message);
2694
+ const failure = deliverToAgent(t, sendSessionFrame, sessionId, message);
2464
2695
  setSendError(failure);
2465
2696
  if (failure === void 0) onSent?.();
2466
2697
  };
2467
2698
  return /* @__PURE__ */ jsx(GitReviewView, {
2699
+ ...focus === void 0 ? {} : { initialPath: focus.path },
2468
2700
  onDraftChange: (open) => setDraftSnapshot((current) => open ? current?.sessionId === sessionId ? current : {
2469
2701
  sessionId,
2470
2702
  fingerprint
@@ -2474,7 +2706,10 @@ function GitReviewPanel({ sessionId, sendSessionFrame }) {
2474
2706
  ...activity.pending === void 0 ? {} : { pending: activity.pending },
2475
2707
  ...error === void 0 ? {} : { error },
2476
2708
  ...activity.errorTarget === void 0 || error === void 0 ? {} : { errorTarget: activity.errorTarget },
2477
- onSync: (action) => requestGitSync(sessionId, action),
2709
+ onSync: (action) => {
2710
+ if (action === "abort-rebase" && !window.confirm(t("git.ui.abortRebaseThisDiscardsConflictResolutionInProgress", "Abort rebase? This discards conflict resolution in progress."))) return;
2711
+ requestGitSync(sessionId, action);
2712
+ },
2478
2713
  onForcePush: () => requestGitSync(sessionId, "push", true),
2479
2714
  onAskAgent: () => send(conflictPrompt(branch, changes?.rebase?.conflicts ?? [])),
2480
2715
  onDismissError: () => setDismissedError(activity.error)
@@ -2488,16 +2723,37 @@ function GitReviewPanel({ sessionId, sendSessionFrame }) {
2488
2723
  onSendReview: () => send(buildReviewPrompt(comments, reviewHeading(comments.length, branch, base)), () => clearReviewComments(sessionId)),
2489
2724
  onDiscard: () => clearReviewComments(sessionId),
2490
2725
  ...sendError === void 0 ? {} : { sendError }
2491
- }, sessionId);
2726
+ }, `${sessionId}:${String(focus?.at ?? 0)}`);
2492
2727
  }
2493
2728
  //#endregion
2729
+ //#region src/extensions/workspaces/sessions/(frontend)/fill/GitReview.lint.finding-review.web.ts
2730
+ /** Lets code review findings open this checkout's diff review on their file. */
2731
+ var GitReview_lint_finding_review_web_default = defineFill({
2732
+ slot: "lint.finding-review",
2733
+ id: "git-review",
2734
+ data: {
2735
+ version: 1,
2736
+ label: t("git.ui.openInReview", "Open in review"),
2737
+ open: (props, path) => {
2738
+ if (props.sessionId === null) return;
2739
+ focusReviewFile(props.sessionId, path);
2740
+ props.openTransientTab(reviewTab());
2741
+ }
2742
+ }
2743
+ });
2744
+ //#endregion
2745
+ //#region src/extensions/workspaces/sessions/(frontend)/fill/WorktreeCreate.overlay.web.tsx
2746
+ var WorktreeCreate_overlay_web_default = defineFill({ component: WorktreeCreateOverlay });
2747
+ //#endregion
2494
2748
  //#region src/extensions/workspaces/sessions/(frontend)/fill/_components/DiffActivitySection.tsx
2495
2749
  /**
2496
2750
  * The '# git' group's branch row: this session's code change against its base.
2497
2751
  *
2498
2752
  * 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.
2753
+ * - One lane, branch and `+A -R`, straight on the group body like every other
2754
+ * activity group: the dock already draws the card, so no inner card or heading.
2755
+ * Files, base, upstream and a paused rebase live in the review tab's header,
2756
+ * which this lane opens.
2501
2757
  * - Stays clickable at zero, because the review tab is also where pull, push
2502
2758
  * and rebase live.
2503
2759
  * - Reads the focused session's checkout, whether it is a worktree or not.
@@ -2509,128 +2765,125 @@ function DiffActivitySection({ sessionId, openTransientTab }) {
2509
2765
  const session = useStore(gitChanges.store, (state) => gitChanges.select(state, sessionId));
2510
2766
  const changes = session.changes;
2511
2767
  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}`;
2768
+ return /* @__PURE__ */ jsx(DiffActivityView, {
2769
+ changes,
2770
+ pending: session.pending,
2771
+ onReview: () => openTransientTab(reviewTab())
2772
+ });
2773
+ }
2774
+ function DiffActivityView({ changes, pending, onReview, branch }) {
2775
+ const t = useT();
2776
+ const zero = changes?.added === 0 && changes?.removed === 0;
2777
+ const against = changes?.base === void 0 ? t("git.review.uncommitted", "uncommitted") : t("git.review.versus", "vs {base}", { base: changes.base });
2514
2778
  return /* @__PURE__ */ jsxs("div", {
2515
- className: "flex min-w-0 items-center gap-2",
2779
+ className: "flex min-w-0 flex-col gap-1",
2516
2780
  children: [/* @__PURE__ */ jsxs(Button, {
2517
2781
  variant: "ghost",
2518
- size: "xs",
2782
+ size: "card",
2519
2783
  "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-doom-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-doom-hi",
2527
- children: changes.branch ?? "detached HEAD"
2528
- }),
2529
- /* @__PURE__ */ jsxs("span", {
2530
- className: zero ? "" : "text-doom-green",
2784
+ className: "min-w-0 flex-row items-center gap-2 rounded-md px-1 py-1 font-normal hover:bg-po-panel",
2785
+ "aria-label": changes ? t("git.review.changesLabel", "review {branch} changes: {added} added, {removed} removed {against}", {
2786
+ branch: changes.branch ?? t("git.review.detachedHeadLower", "detached HEAD"),
2787
+ added: changes.added,
2788
+ removed: changes.removed,
2789
+ against
2790
+ }) : t("git.ui.changesNotReportedYet", "Changes not reported yet"),
2791
+ title: changes ? changes.files === 1 ? t("git.review.filesAgainstOne", "{count} file {against}", {
2792
+ count: changes.files,
2793
+ against
2794
+ }) : t("git.review.filesAgainst", "{count} files {against}", {
2795
+ count: changes.files,
2796
+ against
2797
+ }) : void 0,
2798
+ onClick: onReview,
2799
+ children: [/* @__PURE__ */ jsx("span", {
2800
+ className: "min-w-0 flex-1 truncate text-left font-mono text-sm text-po-hi",
2801
+ children: changes?.branch ?? branch ?? t("git.review.detachedHeadLower", "detached HEAD")
2802
+ }), !changes || zero ? /* @__PURE__ */ jsx("span", {
2803
+ className: "shrink-0 text-sm text-po-dim",
2804
+ children: zero ? t("git.ui.noChangesYet", "No changes yet") : t("git.ui.notReportedYet", "Not reported yet")
2805
+ }) : /* @__PURE__ */ jsxs("span", {
2806
+ className: "flex shrink-0 gap-2 text-sm",
2807
+ children: [/* @__PURE__ */ jsxs("span", {
2808
+ className: "text-po-green",
2531
2809
  children: ["+", changes.added]
2532
- }),
2533
- /* @__PURE__ */ jsxs("span", {
2534
- className: zero ? "" : "text-doom-red",
2810
+ }), /* @__PURE__ */ jsxs("span", {
2811
+ className: "text-po-red",
2535
2812
  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",
2813
+ })]
2814
+ })]
2815
+ }), pending && /* @__PURE__ */ jsxs("p", {
2816
+ className: "flex items-center gap-2 px-1 text-sm text-po-dim",
2540
2817
  children: [/* @__PURE__ */ jsx(Spinner, {
2541
- className: "h-3 w-3 shrink-0 text-doom-faint",
2542
- label: session.pending
2818
+ className: "size-3",
2819
+ label: pending
2543
2820
  }), /* @__PURE__ */ jsx("span", {
2544
- className: "min-w-0 truncate text-sm text-doom-dim",
2545
- children: session.pending
2821
+ className: "inline-block first-letter:uppercase",
2822
+ children: pending
2546
2823
  })]
2547
2824
  })]
2548
2825
  });
2549
2826
  }
2550
2827
  //#endregion
2551
2828
  //#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
2829
  function WorktreesActivitySection(props) {
2830
+ const session = useStore(worktreeActivity.store, (state) => worktreeActivity.select(state, props.sessionId));
2568
2831
  return /* @__PURE__ */ jsxs("div", {
2569
- className: "flex min-w-0 flex-col gap-2",
2570
- children: [/* @__PURE__ */ jsx(DiffActivitySection, { ...props }), /* @__PURE__ */ jsx(WorktreesSummary, { ...props })]
2832
+ className: "flex min-w-0 flex-col gap-1",
2833
+ children: [/* @__PURE__ */ jsx(DiffActivitySection, { ...props }), /* @__PURE__ */ jsx(WorktreesActivityView, {
2834
+ worktrees: session.worktrees.filter((w) => w.sessionId !== props.sessionId),
2835
+ pending: session.pending,
2836
+ onOpen: () => props.openTransientTab(worktreesTab()),
2837
+ onCreate: props.sessionId === null ? void 0 : () => worktreeCreateDialog.update(() => ({
2838
+ sessionId: props.sessionId,
2839
+ ...props.sessionReservationId === void 0 ? {} : { reservationId: props.sessionReservationId }
2840
+ }))
2841
+ })]
2571
2842
  });
2572
2843
  }
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-doom-dim",
2581
- children: "Idle"
2582
- }), sessionId === null ? null : /* @__PURE__ */ jsxs(Button, {
2844
+ function WorktreesActivityView({ worktrees, pending, onOpen, onCreate, startingIds = [] }) {
2845
+ const t = useT();
2846
+ return /* @__PURE__ */ jsxs("div", {
2847
+ className: "flex min-w-0 flex-col gap-1",
2848
+ children: [pending && /* @__PURE__ */ jsxs("p", {
2849
+ className: "flex items-center gap-2 px-1 text-sm text-po-dim",
2850
+ children: [/* @__PURE__ */ jsx(Spinner, {
2851
+ className: "size-3",
2852
+ label: pending
2853
+ }), /* @__PURE__ */ jsx("span", {
2854
+ className: "inline-block first-letter:uppercase",
2855
+ children: pending
2856
+ })]
2857
+ }), worktrees.length === 0 ? onCreate ? /* @__PURE__ */ jsxs(Button, {
2583
2858
  variant: "link",
2584
2859
  size: "sm",
2585
2860
  "data-testid": "activity-git-create",
2586
- className: "h-auto gap-1 px-0 text-doom-green",
2587
- onClick: () => openTransientTab(worktreesTab()),
2588
- children: ["Create a worktree", /* @__PURE__ */ jsx(ArrowRightIcon, {
2861
+ className: "h-auto self-start gap-1 px-1 text-po-green",
2862
+ onClick: onCreate,
2863
+ children: [t("git.ui.createAWorktreeLabel", "Create a worktree"), /* @__PURE__ */ jsx(ArrowRightIcon, {
2589
2864
  "aria-hidden": true,
2590
2865
  className: "size-3.5"
2591
2866
  })]
2867
+ }) : /* @__PURE__ */ jsx("span", {
2868
+ "data-testid": "activity-summary-git",
2869
+ className: "px-1 text-sm text-po-dim",
2870
+ children: t("git.ui.idle", "Idle")
2871
+ }) : /* @__PURE__ */ jsx("div", {
2872
+ "data-testid": "activity-git-worktrees",
2873
+ children: worktrees.map((w) => /* @__PURE__ */ jsx(Button, {
2874
+ variant: "ghost",
2875
+ size: "card",
2876
+ className: "block w-full min-w-0 p-0 text-left font-normal",
2877
+ "data-testid": `activity-git-worktree-${w.id}`,
2878
+ onClick: onOpen,
2879
+ children: /* @__PURE__ */ jsx(WorktreeRow, {
2880
+ compact: true,
2881
+ worktree: w,
2882
+ starting: startingIds.includes(w.id) || !!pending?.includes("starting") && w.sessionId === null && !w.orphaned && !w.unowned
2883
+ })
2884
+ }, w.id))
2592
2885
  })]
2593
2886
  });
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-doom-faint",
2601
- label: session.pending
2602
- }), /* @__PURE__ */ jsx("span", {
2603
- className: "min-w-0 truncate text-sm text-doom-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-doom-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
2887
  }
2635
2888
  //#endregion
2636
2889
  //#region src/extensions/workspaces/sessions/(frontend)/fill/Worktrees.activity.git.web.tsx
@@ -2643,8 +2896,8 @@ var review_web_default = defineLeaderBinding({
2643
2896
  label: "goal"
2644
2897
  }, {
2645
2898
  key: "d",
2646
- label: "diff",
2647
- detail: "review this checkout’s changes"
2899
+ label: t("git.leader.diff", "diff"),
2900
+ detail: t("git.ui.reviewThisCheckoutSChanges", "review this checkout’s changes")
2648
2901
  }],
2649
2902
  run: (context) => context.openTransientTab(reviewTab())
2650
2903
  });
@@ -2664,49 +2917,168 @@ function startGitRuntime(runtime) {
2664
2917
  var start_web_default = defineWebLifecycle(startGitRuntime);
2665
2918
  //#endregion
2666
2919
  //#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"
2676
- };
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
2920
  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-doom-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-doom-red" : "text-doom-dim"}`,
2708
- children: output
2709
- }) })]
2921
+ return /* @__PURE__ */ jsx(RunWorktreeToolMessageView, {
2922
+ action: typeof args.action === "string" ? args.action : "",
2923
+ subject: typeof args.branch === "string" ? args.branch : typeof args.id === "string" ? args.id : "",
2924
+ output,
2925
+ running,
2926
+ isError
2927
+ });
2928
+ }
2929
+ function RunWorktreeToolMessageView({ action, subject = "", output = "", running = false, isError = false, defaultExpanded = false }) {
2930
+ const t = useT();
2931
+ const VERBS = {
2932
+ spawn_worktree: [
2933
+ t("git.tool.isCreating", "is creating"),
2934
+ t("git.tool.created", "created"),
2935
+ t("git.tool.create", "create")
2936
+ ],
2937
+ close_worktree: [
2938
+ t("git.tool.isClosing", "is closing"),
2939
+ t("git.tool.closed", "closed"),
2940
+ t("git.tool.close", "close")
2941
+ ],
2942
+ list: [
2943
+ t("git.tool.isListing", "is listing"),
2944
+ t("git.tool.listed", "listed"),
2945
+ t("git.tool.list", "list")
2946
+ ],
2947
+ status: [
2948
+ t("git.tool.isChecking", "is checking"),
2949
+ t("git.tool.checked", "checked"),
2950
+ t("git.tool.check", "check")
2951
+ ],
2952
+ merge: [
2953
+ t("git.tool.isMerging", "is merging"),
2954
+ t("git.tool.merged", "merged"),
2955
+ t("git.tool.merge", "merge")
2956
+ ],
2957
+ prune: [
2958
+ t("git.tool.isPruning", "is pruning"),
2959
+ t("git.tool.pruned", "pruned"),
2960
+ t("git.tool.prune", "prune")
2961
+ ],
2962
+ send: [
2963
+ t("git.tool.isMessaging", "is messaging"),
2964
+ t("git.tool.messaged", "messaged"),
2965
+ t("git.tool.message", "message")
2966
+ ],
2967
+ messages: [
2968
+ t("git.tool.isReadingMessagesFrom", "is reading messages from"),
2969
+ t("git.tool.readMessagesFrom", "read messages from"),
2970
+ t("git.tool.readMessagesFrom", "read messages from")
2971
+ ]
2972
+ };
2973
+ const tone = running ? "neutral" : isError ? "error" : "ok";
2974
+ const verbs = VERBS[action] ?? [
2975
+ t("git.tool.isRunning", "is running"),
2976
+ t("git.tool.finished", "finished"),
2977
+ t("git.tool.run", "run")
2978
+ ];
2979
+ const rows = action === "list" ? output.split("\n").map((line) => line.split(/\s{2,}/)).filter((parts) => parts.length >= 3) : [];
2980
+ const listingCount = output.match(/^(\d+) worktree/);
2981
+ return /* @__PURE__ */ jsx(MessageItem, {
2982
+ tone,
2983
+ expandable: true,
2984
+ defaultExpanded,
2985
+ className: "bg-po-panel",
2986
+ children: ({ expanded, toggle }) => /* @__PURE__ */ jsxs(Fragment, { children: [
2987
+ /* @__PURE__ */ jsxs("div", {
2988
+ className: "flex items-start gap-3 p-4",
2989
+ children: [/* @__PURE__ */ jsx("div", {
2990
+ className: "min-w-0 flex-1",
2991
+ children: /* @__PURE__ */ jsxs("p", {
2992
+ className: "text-base font-semibold leading-relaxed text-po-hi",
2993
+ children: [
2994
+ "Po",
2995
+ " ",
2996
+ isError && !running ? t("git.tool.couldNot", "could not {action}", { action: verbs[2] }) : verbs[running ? 0 : 1],
2997
+ " ",
2998
+ action === "list" && !running && !isError ? Number(listingCount?.[1] ?? rows.length) === 1 ? t("git.tool.worktreeCountOne", "{count} worktree", { count: listingCount?.[1] ?? rows.length }) : t("git.tool.worktreeCount", "{count} worktrees", { count: listingCount?.[1] ?? rows.length }) : subject ? /* @__PURE__ */ jsx("span", {
2999
+ className: "font-mono",
3000
+ children: subject
3001
+ }) : t("git.tool.worktrees", "worktrees"),
3002
+ running ? "..." : isError && output ? `: ${output.split("\n")[0]}` : ""
3003
+ ]
3004
+ })
3005
+ }), /* @__PURE__ */ jsxs(StatusBadge, {
3006
+ tone,
3007
+ size: "xs",
3008
+ className: running ? "gap-1 bg-po-rail text-po-dim" : "",
3009
+ children: [running && /* @__PURE__ */ jsx(Spinner, {
3010
+ className: "size-3",
3011
+ label: t("git.ui.running", "Running")
3012
+ }), running ? t("git.ui.running", "Running") : isError ? t("git.ui.failed", "Failed") : t("git.ui.completed", "Completed")]
3013
+ })]
3014
+ }),
3015
+ /* @__PURE__ */ jsxs(Button, {
3016
+ variant: "ghost",
3017
+ size: "sm",
3018
+ onClick: toggle,
3019
+ "aria-expanded": expanded,
3020
+ className: "mb-2 ml-3 text-po-dim",
3021
+ children: [
3022
+ t("git.ui.details", "Details"),
3023
+ " ",
3024
+ expanded ? /* @__PURE__ */ jsx(ChevronUpIcon, { className: "size-3" }) : /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-3" })
3025
+ ]
3026
+ }),
3027
+ expanded && /* @__PURE__ */ jsx(MessageItemBody, { children: rows.length > 0 && !isError ? /* @__PURE__ */ jsxs("table", {
3028
+ className: "w-full text-left text-sm",
3029
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", {
3030
+ className: "border-b border-po-border-soft",
3031
+ children: [
3032
+ /* @__PURE__ */ jsx("th", {
3033
+ className: "pb-2 font-medium",
3034
+ children: t("git.ui.branch", "Branch")
3035
+ }),
3036
+ /* @__PURE__ */ jsx("th", {
3037
+ className: "pb-2 font-medium",
3038
+ children: t("git.ui.path", "Path")
3039
+ }),
3040
+ /* @__PURE__ */ jsx("th", {
3041
+ className: "pb-2 font-medium",
3042
+ children: t("git.ui.status", "Status")
3043
+ })
3044
+ ]
3045
+ }) }), /* @__PURE__ */ jsx("tbody", { children: rows.map((parts, i) => {
3046
+ const real = parts.length >= 5;
3047
+ const status = parts[2];
3048
+ return /* @__PURE__ */ jsxs("tr", {
3049
+ className: "border-b border-po-border-soft",
3050
+ children: [
3051
+ /* @__PURE__ */ jsxs("td", {
3052
+ className: "py-3 pr-3 font-mono text-po-text",
3053
+ children: [real ? parts[1] : parts[0], real && /* @__PURE__ */ jsx("span", {
3054
+ className: "mt-1 block text-po-dim",
3055
+ children: parts[0]
3056
+ })]
3057
+ }),
3058
+ /* @__PURE__ */ jsx("td", {
3059
+ className: "py-3 pr-3 font-mono text-po-dim",
3060
+ children: real ? parts.slice(4).join(" ") : parts[1]
3061
+ }),
3062
+ /* @__PURE__ */ jsxs("td", { children: [/* @__PURE__ */ jsx(StatusBadge, {
3063
+ tone: status === "orphaned" ? "neutral" : status === "unowned" ? "info" : "ok",
3064
+ size: "xs",
3065
+ className: status === "orphaned" ? "bg-po-tint-yellow text-po-yellow" : "",
3066
+ children: /* @__PURE__ */ jsx("span", {
3067
+ className: "inline-block first-letter:uppercase",
3068
+ children: status
3069
+ })
3070
+ }), real && /* @__PURE__ */ jsx("span", {
3071
+ className: "ml-2 text-po-dim",
3072
+ children: parts[3]
3073
+ })] })
3074
+ ]
3075
+ }, i);
3076
+ }) })]
3077
+ }) : /* @__PURE__ */ jsx("pre", {
3078
+ className: `whitespace-pre-wrap font-mono text-sm ${isError ? "text-po-red" : "text-po-dim"}`,
3079
+ children: output
3080
+ }) })
3081
+ ] })
2710
3082
  });
2711
3083
  }
2712
3084
  //#endregion
@@ -2720,6 +3092,7 @@ const via = (identity, value) => value === void 0 ? void 0 : {
2720
3092
  };
2721
3093
  const webPlugin = defineWebPlugin({
2722
3094
  id: "git",
3095
+ packageName: "@agimon-ai/po-git",
2723
3096
  workspace: {
2724
3097
  get fills() {
2725
3098
  return [via({
@@ -2741,9 +3114,9 @@ const webPlugin = defineWebPlugin({
2741
3114
  get fills() {
2742
3115
  return [
2743
3116
  via({
2744
- slot: "session-menu",
2745
- id: "worktree"
2746
- }, Worktree_session_menu_web_default),
3117
+ slot: "lint.finding-review",
3118
+ id: "git-review"
3119
+ }, GitReview_lint_finding_review_web_default),
2747
3120
  via({
2748
3121
  slot: "overlay",
2749
3122
  id: "worktree-create"