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