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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/LICENSE +97 -8
  2. package/README.md +91 -21
  3. package/dist/apiContracts.cjs +78 -12
  4. package/dist/apiContracts.cjs.map +1 -1
  5. package/dist/apiContracts.d.mts +2 -2
  6. package/dist/apiContracts.d.mts.map +1 -1
  7. package/dist/apiContracts.mjs +78 -12
  8. package/dist/apiContracts.mjs.map +1 -1
  9. package/dist/extensions/native.mjs +2255 -544
  10. package/dist/extensions/native.mjs.map +1 -1
  11. package/dist/extensions/server.cjs +1553 -508
  12. package/dist/extensions/server.cjs.map +1 -1
  13. package/dist/extensions/server.d.mts.map +1 -1
  14. package/dist/extensions/server.mjs +1512 -467
  15. package/dist/extensions/server.mjs.map +1 -1
  16. package/dist/extensions/web.mjs +1747 -1374
  17. package/dist/extensions/web.mjs.map +1 -1
  18. package/dist/gitDependencies-D8bKxZSc.cjs +2690 -0
  19. package/dist/gitDependencies-D8bKxZSc.cjs.map +1 -0
  20. package/dist/gitDependencies-Delu4xip.mjs +2432 -0
  21. package/dist/gitDependencies-Delu4xip.mjs.map +1 -0
  22. package/dist/index.cjs +13 -22
  23. package/dist/index.d.mts +266 -14
  24. package/dist/index.d.mts.map +1 -1
  25. package/dist/index.mjs +3 -22
  26. package/dist/po-runtime-identity.json +1 -0
  27. package/llms.txt +3 -3
  28. package/package.json +99 -21
  29. package/src/prompts/codemode-how-to-git/SKILL.md +137 -0
  30. package/dist/index.cjs.map +0 -1
  31. package/dist/index.mjs.map +0 -1
  32. package/dist/worktreeOperations-Cd8Q12L4.mjs +0 -1064
  33. package/dist/worktreeOperations-Cd8Q12L4.mjs.map +0 -1
  34. package/dist/worktreeOperations-Dxs3txKL.cjs +0 -1220
  35. package/dist/worktreeOperations-Dxs3txKL.cjs.map +0 -1
  36. package/src/prompts/po-use-git/SKILL.md +0 -87
@@ -1,11 +1,497 @@
1
- import { createApiClient, defineActivityGroup, defineChannelFile, defineFill, defineGlobalStore, defineNativePlugin, defineSessionStore, defineWebLifecycle, nativeApiTransport, sessionApiAddress } from "@agimon-ai/po-core/native";
2
- import { BranchIcon, Button, Dot, Input, ListRow, Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle, Textarea, fontOf } from "@agimon-ai/po-native-components";
3
- import { createElement, useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
1
+ import { createApiClient, defineActivityGroup, defineChannelFile, defineFill, defineHostStore, defineNativePlugin, defineSessionStore, defineWebLifecycle, nativeApiTransport, sessionApiAddress, t, useT } from "@agimon-ai/po-core/native";
4
2
  import { View } from "react-native-unistyles/components/native/View";
5
3
  import { Text } from "react-native-unistyles/components/native/Text";
6
4
  import { ScrollView } from "react-native-unistyles/components/native/ScrollView";
7
- import { StyleSheet } from "react-native-unistyles";
5
+ import { AlertIcon, Badge, BranchIcon, Button, CheckIcon, ChevronRightIcon, Dot, EmptyState, FileIcon, Input, Label, ListRow, MessageIcon, SegmentedControl, Select, Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle, Spinner, SyntaxLine, Textarea, fontOf } from "@agimon-ai/po-native-components";
6
+ import { createElement, memo, useCallback, useEffect, useEffectEvent, useMemo, useRef, useState, useSyncExternalStore } from "react";
7
+ import { StyleSheet, useUnistyles } from "react-native-unistyles";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { Pressable } from "react-native-unistyles/components/native/Pressable";
10
+ const api = createApiClient({
11
+ /** Workspace: the new-session dialog's branch list. */
12
+ branches: {
13
+ method: "GET",
14
+ path: "/branches",
15
+ response: void 0
16
+ },
17
+ deleteBranch: {
18
+ method: "DELETE",
19
+ path: "/branches",
20
+ response: void 0
21
+ },
22
+ openBranchFolder: {
23
+ method: "POST",
24
+ path: "/branches/open",
25
+ response: void 0
26
+ },
27
+ /** Workspace: a top-level worktree session on an existing or new branch. */
28
+ createSession: {
29
+ method: "POST",
30
+ path: "/sessions",
31
+ response: void 0
32
+ },
33
+ /** Workspace: that workspace's saved remote auth, never the token itself. */
34
+ auth: {
35
+ method: "GET",
36
+ path: "/auth",
37
+ query: ["repositoryId"],
38
+ response: void 0
39
+ },
40
+ /** Workspace: replaces that workspace's remote auth. Passkey step-up gated for remote devices. */
41
+ saveAuth: {
42
+ method: "PUT",
43
+ path: "/auth",
44
+ query: ["repositoryId"],
45
+ response: void 0
46
+ },
47
+ /** Session: the files this session's checkout changed against its base. */
48
+ review: {
49
+ method: "GET",
50
+ path: "/review",
51
+ response: void 0
52
+ },
53
+ /** Session: one changed file's hunks. */
54
+ reviewFile: {
55
+ method: "GET",
56
+ path: "/review/file",
57
+ query: ["path"],
58
+ response: void 0
59
+ }
60
+ }, {
61
+ scopes: [
62
+ "host",
63
+ "workspace",
64
+ "session"
65
+ ],
66
+ basePath: "git",
67
+ transport: nativeApiTransport,
68
+ sessionAddress: sessionApiAddress
69
+ });
70
+ //#endregion
71
+ //#region src/extensions/workspaces/(frontend)/_lib/newSessionForm.ts
72
+ const MAX_LISTED = 200;
73
+ /** Full checkout is explicit; a locked default remains visible even if absent from the catalog. */
74
+ function sparseOptions(branches) {
75
+ return [.../* @__PURE__ */ new Set([
76
+ "full",
77
+ ...branches.sparseProfiles ?? [],
78
+ ...branches.defaultSparseProfile === void 0 ? [] : [branches.defaultSparseProfile]
79
+ ])];
80
+ }
81
+ /** The last segment of a path: enough to name a checkout without spelling out where it lives. */
82
+ function folderName(path) {
83
+ return path.split(/[\\/]/).filter((part) => part !== "").pop() ?? path;
84
+ }
85
+ /** Where a busy branch is checked out, short enough for one line. */
86
+ function busyNote(t, busyAt, workspaceRoot) {
87
+ return busyAt === workspaceRoot ? t("git.ui.checkedOutHere", "Checked out here") : t("git.branch.checkedOutIn", "Checked out in {folder}", { folder: folderName(busyAt) });
88
+ }
89
+ /**
90
+ * Local branches a session can take, then the checked-out ones, then remote-only ones, filtered by a
91
+ * case-insensitive substring.
92
+ */
93
+ function branchOptions(branches, query) {
94
+ const needle = query.trim().toLowerCase();
95
+ const matches = (text) => needle === "" || text.toLowerCase().includes(needle);
96
+ const local = branches.local.filter((branch) => matches(branch.name)).map((branch) => ({
97
+ key: `local:${branch.name}`,
98
+ name: branch.name,
99
+ current: branch.name === branches.current,
100
+ ...branch.checkedOutAt === void 0 ? {} : { busyAt: branch.checkedOutAt }
101
+ })).sort((a, b) => Number(a.busyAt !== void 0) - Number(b.busyAt !== void 0));
102
+ const remote = branches.remote.filter((branch) => matches(`${branch.remote}/${branch.name}`)).map((branch) => ({
103
+ key: `remote:${branch.remote}/${branch.name}`,
104
+ name: branch.name,
105
+ remote: branch.remote,
106
+ current: false
107
+ }));
108
+ return [...local, ...remote].slice(0, MAX_LISTED);
109
+ }
110
+ /** Every base a new branch can start from: the default first, then remote-tracking names, then local branches. */
111
+ function baseOptions(branches) {
112
+ return [.../* @__PURE__ */ new Set([
113
+ ...branches.defaultBase === void 0 ? [] : [branches.defaultBase],
114
+ ...branches.remote.map((branch) => `${branch.remote}/${branch.name}`),
115
+ ...branches.local.map((branch) => branch.name)
116
+ ])];
117
+ }
118
+ /** Why the form cannot be submitted yet, or undefined when it can. */
119
+ function formProblem(t, state) {
120
+ if (state.mode === "existing") {
121
+ if (state.selected === void 0) return t("git.ui.pickABranch", "Pick a branch.");
122
+ if (state.selected.busyAt !== void 0) return t("git.branch.busyAt", "That branch is checked out at {path}.", { path: state.selected.busyAt });
123
+ }
124
+ if (state.mode === "new" && state.newBranch.trim() === "") return t("git.ui.nameTheNewBranch", "Name the new branch.");
125
+ }
126
+ /** The launch profile choice for any session kind, or undefined when none was made. */
127
+ function launchSelection(state) {
128
+ return state.profile === void 0 ? void 0 : { profile: state.profile };
129
+ }
130
+ /** The worktree create request for the form, or undefined in plain mode. */
131
+ function createRequest(state, branches) {
132
+ const name = state.name.trim();
133
+ const chosen = launchSelection(state);
134
+ const sparseProfile = branches?.defaultSparseProfile ?? state.sparseProfile;
135
+ const named = {
136
+ ...sparseProfile === void 0 ? {} : { sparseProfile },
137
+ ...name === "" ? {} : { name },
138
+ ...chosen === void 0 ? {} : { selection: chosen }
139
+ };
140
+ if (state.mode === "existing" && state.selected !== void 0) return {
141
+ mode: "existing-branch",
142
+ branch: state.selected.name,
143
+ ...state.selected.remote === void 0 ? {} : { remote: state.selected.remote },
144
+ ...named
145
+ };
146
+ if (state.mode === "new") {
147
+ const baseRef = state.baseRef.trim();
148
+ return {
149
+ mode: "new-branch",
150
+ branch: state.newBranch.trim(),
151
+ ...baseRef === "" ? {} : { baseRef },
152
+ ...named
153
+ };
154
+ }
155
+ }
156
+ //#endregion
157
+ //#region src/extensions/workspaces/(frontend)/fill/_components/GitNewSessionSheet.native.tsx
158
+ /** The native twin of GitNewSessionDialogView: the same form state and checks, in sheet parts. */
159
+ function GitNewSessionSheetView({ workspaceRoot, branches, loadError = "", initialForm, busy = false, error = "", sparseCheckout, onCreate }) {
160
+ const t = useT();
161
+ const MODES = [
162
+ {
163
+ value: "existing",
164
+ label: t("git.ui.existing", "Existing")
165
+ },
166
+ {
167
+ value: "new",
168
+ label: t("git.ui.newBranch", "New branch")
169
+ },
170
+ {
171
+ value: "plain",
172
+ label: t("git.ui.noBranch", "No branch")
173
+ }
174
+ ];
175
+ const [form, setForm] = useState({
176
+ mode: "existing",
177
+ newBranch: "",
178
+ baseRef: "",
179
+ name: "",
180
+ ...initialForm
181
+ });
182
+ const [query, setQuery] = useState("");
183
+ const [basesOpen, setBasesOpen] = useState(false);
184
+ const ready = branches?.repository === true && loadError === "";
185
+ const loading = branches === null && loadError === "";
186
+ const mode = ready || loading ? form.mode : "plain";
187
+ const state = {
188
+ ...form,
189
+ mode,
190
+ baseRef: form.baseRef || branches?.defaultBase || ""
191
+ };
192
+ const problem = formProblem(t, state);
193
+ const update = (patch) => setForm((current) => ({
194
+ ...current,
195
+ ...patch
196
+ }));
197
+ const options = branches === null ? [] : branchOptions(branches, query);
198
+ const bases = branches === null ? [] : baseOptions(branches);
199
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: t("git.ui.newSession", "New session") }) }), /* @__PURE__ */ jsxs(SheetBody, {
200
+ style: styles$3.body,
201
+ children: [
202
+ /* @__PURE__ */ jsx(Text, {
203
+ style: styles$3.root,
204
+ numberOfLines: 1,
205
+ accessibilityLabel: t("git.session.workspace", "Workspace {path}", { path: workspaceRoot }),
206
+ children: folderName(workspaceRoot)
207
+ }),
208
+ !ready ? /* @__PURE__ */ jsx(Text, {
209
+ testID: "git-new-session-plain-note",
210
+ style: styles$3.dim,
211
+ children: loading ? t("git.ui.readingBranchesPending", "Reading branches...") : loadError || t("git.ui.thisWorkspaceIsNotAGitCheckoutStartAPlainSessionInThisFolder", "This workspace is not a git checkout. Start a plain session in this folder.")
212
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SegmentedControl, {
213
+ accessibilityLabel: t("git.ui.sessionKind", "Session kind"),
214
+ options: MODES,
215
+ value: mode,
216
+ disabled: busy,
217
+ onValueChange: (value) => update({ mode: value })
218
+ }), mode === "existing" ? /* @__PURE__ */ jsxs(View, {
219
+ style: styles$3.field,
220
+ children: [
221
+ /* @__PURE__ */ jsx(Label, { children: t("git.ui.branch", "Branch") }),
222
+ /* @__PURE__ */ jsx(Input, {
223
+ testID: "git-new-session-branch-search",
224
+ accessibilityLabel: t("git.ui.findABranch", "Find a branch"),
225
+ placeholder: t("git.ui.findABranch", "Find a branch"),
226
+ autoCapitalize: "none",
227
+ autoCorrect: false,
228
+ value: query,
229
+ onChangeText: setQuery,
230
+ disabled: busy
231
+ }),
232
+ /* @__PURE__ */ jsxs(ScrollView, {
233
+ style: styles$3.list,
234
+ nestedScrollEnabled: true,
235
+ accessibilityLabel: t("git.ui.branches", "Branches"),
236
+ children: [options.length === 0 ? /* @__PURE__ */ jsx(Text, {
237
+ style: [styles$3.dim, styles$3.pad],
238
+ children: t("git.ui.noMatchingBranches", "No matching branches")
239
+ }) : null, options.map((branch, index) => /* @__PURE__ */ jsxs(View, { children: [branch.remote !== void 0 && (index === 0 || options[index - 1]?.remote === void 0) ? /* @__PURE__ */ jsx(Text, {
240
+ style: [
241
+ styles$3.dim,
242
+ styles$3.pad,
243
+ styles$3.divider
244
+ ],
245
+ children: t("git.ui.remoteBranches", "Remote branches")
246
+ }) : null, /* @__PURE__ */ jsx(ListRow, {
247
+ title: /* @__PURE__ */ jsx(Text, {
248
+ style: styles$3.mono,
249
+ numberOfLines: 1,
250
+ ellipsizeMode: "middle",
251
+ children: branch.remote === void 0 ? branch.name : `${branch.remote}/${branch.name}`
252
+ }),
253
+ description: branch.busyAt !== void 0 ? /* @__PURE__ */ jsx(Text, {
254
+ style: styles$3.dim,
255
+ numberOfLines: 1,
256
+ children: busyNote(t, branch.busyAt, workspaceRoot)
257
+ }) : branch.current ? t("git.ui.current", "Current") : void 0,
258
+ trailing: form.selected?.key === branch.key ? /* @__PURE__ */ jsx(CheckIcon, {
259
+ size: 16,
260
+ color: "green"
261
+ }) : void 0,
262
+ selected: form.selected?.key === branch.key,
263
+ disabled: branch.busyAt !== void 0 || busy,
264
+ disclosure: false,
265
+ style: index > 0 && styles$3.divider,
266
+ onPress: () => update({ selected: branch })
267
+ })] }, branch.key))]
268
+ })
269
+ ]
270
+ }) : mode === "new" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(View, {
271
+ style: styles$3.field,
272
+ children: [/* @__PURE__ */ jsx(Label, { children: t("git.ui.branchName", "Branch name") }), /* @__PURE__ */ jsx(Input, {
273
+ testID: "git-new-session-new-branch",
274
+ accessibilityLabel: t("git.ui.branchName", "Branch name"),
275
+ placeholder: "feature/my-change",
276
+ autoCapitalize: "none",
277
+ autoCorrect: false,
278
+ style: styles$3.mono,
279
+ value: form.newBranch,
280
+ onChangeText: (newBranch) => update({ newBranch }),
281
+ disabled: busy
282
+ })]
283
+ }), /* @__PURE__ */ jsxs(View, {
284
+ style: styles$3.field,
285
+ children: [/* @__PURE__ */ jsx(Label, { children: t("git.ui.from", "From") }), /* @__PURE__ */ jsxs(ScrollView, {
286
+ style: styles$3.list,
287
+ nestedScrollEnabled: true,
288
+ children: [/* @__PURE__ */ jsx(ListRow, {
289
+ accessibilityLabel: t("git.ui.from", "From"),
290
+ title: /* @__PURE__ */ jsx(Text, {
291
+ style: styles$3.mono,
292
+ children: state.baseRef || t("git.ui.currentBranch", "Current branch")
293
+ }),
294
+ disabled: busy,
295
+ onPress: () => setBasesOpen((open) => !open)
296
+ }), basesOpen ? bases.map((base) => /* @__PURE__ */ jsx(ListRow, {
297
+ title: /* @__PURE__ */ jsx(Text, {
298
+ style: styles$3.mono,
299
+ children: base
300
+ }),
301
+ selected: state.baseRef === base,
302
+ disabled: busy,
303
+ disclosure: false,
304
+ onPress: () => {
305
+ update({ baseRef: base });
306
+ setBasesOpen(false);
307
+ }
308
+ }, base)) : null]
309
+ })]
310
+ })] }) : /* @__PURE__ */ jsx(Text, {
311
+ style: styles$3.dim,
312
+ children: t("git.ui.startInThisWorkspaceFolderWithoutCreatingAWorktree", "Start in this workspace folder, without creating a worktree.")
313
+ })] }),
314
+ /* @__PURE__ */ jsxs(View, {
315
+ style: styles$3.field,
316
+ children: [/* @__PURE__ */ jsx(Label, { children: t("git.ui.name", "Name") }), /* @__PURE__ */ jsx(Input, {
317
+ testID: "new-session-name",
318
+ accessibilityLabel: t("git.ui.sessionName", "Session name"),
319
+ placeholder: mode === "plain" ? t("git.ui.optional", "Optional") : t("git.ui.optionalDefaultsToTheBranch", "Optional, defaults to the branch"),
320
+ value: form.name,
321
+ onChangeText: (name) => update({ name }),
322
+ disabled: busy
323
+ })]
324
+ }),
325
+ mode !== "plain" && sparseCheckout !== void 0 ? /* @__PURE__ */ jsxs(View, {
326
+ style: styles$3.field,
327
+ children: [
328
+ /* @__PURE__ */ jsx(Label, { children: t("git.ui.sparseCheckout", "Sparse checkout") }),
329
+ /* @__PURE__ */ jsx(Select, {
330
+ title: t("git.ui.sparseCheckout", "Sparse checkout"),
331
+ value: sparseCheckout.defaultSparseProfile ?? form.sparseProfile ?? "full",
332
+ onValueChange: (sparseProfile) => update({ sparseProfile }),
333
+ disabled: busy || sparseCheckout.defaultSparseProfile !== void 0,
334
+ options: sparseOptions(sparseCheckout).map((profile) => ({
335
+ value: profile,
336
+ label: profile === "full" ? t("git.ui.fullCheckout", "Full checkout") : profile
337
+ }))
338
+ }),
339
+ sparseCheckout.defaultSparseProfile === void 0 ? null : /* @__PURE__ */ jsx(Text, {
340
+ style: styles$3.dim,
341
+ children: t("git.ui.workspaceSparseDefault", "Set by this workspace")
342
+ })
343
+ ]
344
+ }) : null,
345
+ mode !== "plain" ? /* @__PURE__ */ jsx(Text, {
346
+ testID: "new-session-hint",
347
+ style: styles$3.dim,
348
+ children: (loading ? void 0 : problem) ?? t("git.ui.runsInItsOwnWorktreeSoThisCheckoutStaysAsItIs", "Runs in its own worktree, so this checkout stays as it is.")
349
+ }) : null,
350
+ error ? /* @__PURE__ */ jsx(Text, {
351
+ testID: "new-session-error",
352
+ style: styles$3.error,
353
+ accessibilityRole: "alert",
354
+ children: error
355
+ }) : null,
356
+ /* @__PURE__ */ jsx(Button, {
357
+ testID: "new-session-create",
358
+ variant: "primary",
359
+ size: "lg",
360
+ loading: busy,
361
+ loadingLabel: mode === "plain" ? t("git.ui.creatingSession", "Creating session") : t("git.ui.creatingWorktree", "Creating worktree"),
362
+ disabled: loading || problem !== void 0,
363
+ accessibilityHint: problem,
364
+ onPress: () => onCreate(state),
365
+ children: t("git.ui.createSession", "Create session")
366
+ })
367
+ ]
368
+ })] });
369
+ }
370
+ function errorOf(body, status) {
371
+ return typeof body === "object" && body !== null && typeof body.error === "string" ? body.error : t("git.request.status", "The cockpit answered {status}.", { status });
372
+ }
373
+ /** The native new-session sheet when git is installed; mirrors GitNewSessionDialog's calls. */
374
+ function GitNewSessionSheet({ newSession }) {
375
+ const t = useT();
376
+ const [branches, setBranches] = useState(null);
377
+ const [loadError, setLoadError] = useState("");
378
+ const [error, setError] = useState("");
379
+ const [busy, setBusy] = useState(false);
380
+ const workspaceId = newSession?.workspaceId;
381
+ const request = useEffectEvent((input) => newSession?.requestWithStepUp(input));
382
+ useEffect(() => {
383
+ if (workspaceId === void 0) return;
384
+ let stale = false;
385
+ request(api.workspace(workspaceId).branches.url())?.then(async (response) => {
386
+ const body = await response.json().catch(() => void 0);
387
+ if (stale) return;
388
+ if (!response.ok) setLoadError(errorOf(body, response.status));
389
+ else setBranches(body);
390
+ }).catch(() => {
391
+ if (!stale) setLoadError(t("git.ui.theBranchesCouldNotBeLoaded", "The branches could not be loaded."));
392
+ });
393
+ return () => {
394
+ stale = true;
395
+ };
396
+ }, [workspaceId, t]);
397
+ if (newSession === void 0) return null;
398
+ const submit = async (state) => {
399
+ if (busy || formProblem(t, state) !== void 0) return;
400
+ setBusy(true);
401
+ setError("");
402
+ const body = createRequest(state);
403
+ let failure;
404
+ try {
405
+ if (body === void 0) failure = await newSession.createPlain(state.name);
406
+ else {
407
+ const response = await newSession.requestWithStepUp(api.workspace(newSession.workspaceId).createSession.url(), {
408
+ method: "POST",
409
+ headers: { "Content-Type": "application/json" },
410
+ body: JSON.stringify(body)
411
+ });
412
+ const answer = await response.json().catch(() => void 0);
413
+ failure = response.ok ? await newSession.openCreated(answer.sessionId) : errorOf(answer, response.status);
414
+ }
415
+ } catch {
416
+ failure = t("git.ui.theCockpitIsUnreachable", "The cockpit is unreachable.");
417
+ }
418
+ if (failure === void 0) return;
419
+ setError(failure);
420
+ setBusy(false);
421
+ };
422
+ return /* @__PURE__ */ jsx(GitNewSessionSheetView, {
423
+ workspaceRoot: newSession.workspaceRoot,
424
+ branches,
425
+ loadError,
426
+ busy,
427
+ error,
428
+ onCreate: (state) => void submit(state)
429
+ });
430
+ }
431
+ const styles$3 = StyleSheet.create((theme) => {
432
+ const sans = fontOf(theme.fontFamily.sans);
433
+ const mono = fontOf(theme.fontFamily.mono);
434
+ return {
435
+ body: {
436
+ gap: theme.spacing(4),
437
+ uni__dependencies: [0]
438
+ },
439
+ root: {
440
+ fontFamily: mono,
441
+ fontSize: theme.fontSize.sm,
442
+ lineHeight: theme.lineHeight.sm,
443
+ color: theme.colors.dim,
444
+ uni__dependencies: [0]
445
+ },
446
+ field: {
447
+ gap: theme.spacing(1.5),
448
+ uni__dependencies: [0]
449
+ },
450
+ dim: {
451
+ fontFamily: sans,
452
+ fontSize: theme.fontSize.sm,
453
+ lineHeight: theme.lineHeightRelaxed.sm,
454
+ color: theme.colors.dim,
455
+ uni__dependencies: [0]
456
+ },
457
+ error: {
458
+ fontFamily: sans,
459
+ fontSize: theme.fontSize.sm,
460
+ lineHeight: theme.lineHeightRelaxed.sm,
461
+ color: theme.colors.red,
462
+ uni__dependencies: [0]
463
+ },
464
+ mono: {
465
+ fontFamily: mono,
466
+ fontSize: theme.fontSize.base,
467
+ lineHeight: theme.lineHeight.base,
468
+ color: theme.colors.hi,
469
+ uni__dependencies: [0]
470
+ },
471
+ list: {
472
+ maxHeight: 156,
473
+ borderRadius: theme.borderRadius.lg,
474
+ borderWidth: 1,
475
+ borderColor: theme.colors["border-soft"],
476
+ overflow: "hidden",
477
+ uni__dependencies: [0]
478
+ },
479
+ pad: {
480
+ paddingHorizontal: theme.spacing(4),
481
+ paddingVertical: theme.spacing(2),
482
+ uni__dependencies: [0]
483
+ },
484
+ divider: {
485
+ borderTopWidth: StyleSheet.hairlineWidth,
486
+ borderTopColor: theme.colors["border-soft"],
487
+ uni__dependencies: [0]
488
+ }
489
+ };
490
+ });
491
+ //#endregion
492
+ //#region src/extensions/workspaces/(frontend)/fill/GitNewSession.new-session.native.tsx
493
+ var GitNewSession_new_session_native_default = defineFill({ component: GitNewSessionSheet });
494
+ //#endregion
9
495
  //#region src/types/webWorktrees.ts
10
496
  /**
11
497
  * The cockpit's view of this session's worktrees.
@@ -43,6 +529,15 @@ const GIT_WORKTREES_TYPE = "git_worktrees";
43
529
  * - `sendSessionFrame` for a command. It envelopes the frame as a session
44
530
  * command bound for the agent, which never reaches a channel's `receive`.
45
531
  */
532
+ /** Presentation state follows hub operation labels, including session startup progress. */
533
+ function worktreesPresentation(state) {
534
+ return {
535
+ working: state.worktrees.filter((item) => !item.orphaned && !item.unowned),
536
+ attention: state.worktrees.filter((item) => item.orphaned || item.unowned),
537
+ starting: state.requestedBranch !== void 0 ? !state.error && !state.worktrees.some((item) => item.branch === state.requestedBranch) : !!state.pending && /^(creating|starting session)/i.test(state.pending),
538
+ closeErrorId: state.errorTarget?.action === "close" ? state.errorTarget.id : void 0
539
+ };
540
+ }
46
541
  const worktreeActivity = defineSessionStore({
47
542
  worktrees: [],
48
543
  pending: void 0,
@@ -50,7 +545,7 @@ const worktreeActivity = defineSessionStore({
50
545
  errorTarget: void 0
51
546
  });
52
547
  /** Captures the clicked card, so a focus change cannot retarget an open dialog. */
53
- const worktreeCreateDialog = defineGlobalStore(null);
548
+ const worktreeCreateDialog = defineHostStore(null);
54
549
  /**
55
550
  * The page's hub socket sender, held for as long as the plugin runs.
56
551
  *
@@ -58,7 +553,7 @@ const worktreeCreateDialog = defineGlobalStore(null);
58
553
  * sent in that window is dropped rather than queued, because a queue would
59
554
  * replay a worktree create against a socket that has since changed sessions.
60
555
  */
61
- const worktreeSender = defineGlobalStore(void 0);
556
+ const worktreeSender = defineHostStore(void 0);
62
557
  /** Binds the page's hub socket. The plugin host calls this once per page. */
63
558
  function startWorktreeRuntime(runtime) {
64
559
  const send = (frame) => {
@@ -99,7 +594,10 @@ function optionalText$1(value) {
99
594
  }
100
595
  function optionalErrorTarget$1(value) {
101
596
  if (!isRecord$2(value)) return void 0;
102
- if (value.action === "create") return { action: "create" };
597
+ if (value.action === "create") return value.riftMissing === true ? {
598
+ action: "create",
599
+ riftMissing: true
600
+ } : { action: "create" };
103
601
  if (value.action === "close" && typeof value.id === "string" && value.id !== "") return {
104
602
  action: "close",
105
603
  id: value.id
@@ -117,8 +615,12 @@ const worktreesChannel = worktreeActivity.channel({
117
615
  errorTarget: optionalErrorTarget$1(input.errorTarget)
118
616
  };
119
617
  },
120
- reduce(_current, next) {
121
- return next;
618
+ reduce(current, next) {
619
+ const requestedBranch = current.requestedBranch;
620
+ return {
621
+ ...next,
622
+ ...requestedBranch && next.pending && !next.error ? { requestedBranch } : {}
623
+ };
122
624
  }
123
625
  });
124
626
  /** Sends one command to the session's worktrees channel. */
@@ -132,6 +634,13 @@ function command(sessionId, payload) {
132
634
  /** Asks the hub for a worktree. The hub answers on the same channel. */
133
635
  function requestWorktreeCreate(sessionId, branch, baseRef, reservationId) {
134
636
  const trimmedBase = baseRef.trim();
637
+ if (worktreeSender.store.state) worktreeActivity.update(sessionId, (current) => ({
638
+ ...current,
639
+ requestedBranch: branch.trim(),
640
+ pending: "creating",
641
+ error: void 0,
642
+ errorTarget: void 0
643
+ }));
135
644
  command(sessionId, {
136
645
  action: "create",
137
646
  branch: branch.trim(),
@@ -158,154 +667,521 @@ function useWorktrees(sessionId) {
158
667
  function worktreesTab() {
159
668
  return {
160
669
  id: "git-worktrees",
161
- label: "worktrees",
670
+ label: t("git.tab.worktrees", "worktrees"),
162
671
  panel: WorktreesPanel
163
672
  };
164
673
  }
165
- function WorktreesPanel({ sessionId, sessionReservationId, openSession }) {
166
- const state = useWorktrees(sessionId);
167
- const [creating, setCreating] = useState(false);
168
- const [branch, setBranch] = useState("");
169
- const [baseRef, setBaseRef] = useState("");
170
- const [closing, setClosing] = useState();
171
- const busy = state.pending !== void 0;
172
- return /* @__PURE__ */ jsxs(ScrollView, {
173
- contentContainerStyle: styles$1.body,
674
+ function WorktreesHeader({ activity = false, onNew, disabled = false, showNew = true }) {
675
+ const t = useT();
676
+ return /* @__PURE__ */ jsxs(View, {
677
+ style: styles$2.header,
678
+ children: [/* @__PURE__ */ jsx(Text, {
679
+ style: styles$2.title,
680
+ children: activity ? t("git.ui.activity", "Activity") : t("git.ui.worktrees", "Worktrees")
681
+ }), !activity && showNew ? /* @__PURE__ */ jsx(Button, {
682
+ testID: "git-worktree-create",
683
+ variant: "ghost",
684
+ style: styles$2.newPill,
685
+ disabled,
686
+ onPress: onNew,
687
+ children: /* @__PURE__ */ jsx(Text, {
688
+ style: styles$2.jade,
689
+ children: t("git.ui.new", "+ New")
690
+ })
691
+ }) : null]
692
+ });
693
+ }
694
+ function WorktreeRow({ item, error, compact = false, onClose, onOpen, disabled = false }) {
695
+ const t = useT();
696
+ return /* @__PURE__ */ jsxs(View, {
697
+ style: styles$2.worktree,
174
698
  children: [
175
- /* @__PURE__ */ jsx(Button, {
176
- testID: "git-worktree-create",
177
- disabled: sessionId === null || busy,
178
- onPress: () => setCreating(true),
179
- children: "Create a worktree"
180
- }),
181
- state.pending ? /* @__PURE__ */ jsx(Text, {
182
- style: styles$1.meta,
183
- children: state.pending
184
- }) : null,
185
- state.error ? /* @__PURE__ */ jsx(Text, {
186
- style: styles$1.error,
187
- children: state.error
188
- }) : null,
189
- state.worktrees.map((worktree) => /* @__PURE__ */ jsxs(View, {
190
- style: styles$1.card,
699
+ /* @__PURE__ */ jsxs(View, {
700
+ style: styles$2.line,
191
701
  children: [
192
- /* @__PURE__ */ jsx(ListRow, {
193
- title: worktree.branch,
194
- description: `${worktree.path}${worktree.orphaned ? "\nOrphaned" : ""}${worktree.unowned ? "\nUnowned" : ""}`
702
+ /* @__PURE__ */ jsx(Dot, {
703
+ tone: item.orphaned ? "yellow" : item.unowned ? "blue" : "green",
704
+ size: "md"
195
705
  }),
196
- worktree.sessionId && openSession ? /* @__PURE__ */ jsx(Button, {
197
- variant: "outline",
198
- onPress: () => openSession(worktree.sessionId),
199
- children: "Open session"
706
+ /* @__PURE__ */ jsxs(Pressable, {
707
+ style: styles$2.grow,
708
+ accessibilityRole: onOpen ? "button" : void 0,
709
+ accessibilityLabel: onOpen ? t("git.worktree.openSession", "Open session for {branch}", { branch: item.branch }) : void 0,
710
+ onPress: onOpen,
711
+ disabled: !onOpen,
712
+ children: [/* @__PURE__ */ jsx(Text, {
713
+ numberOfLines: 1,
714
+ ellipsizeMode: "middle",
715
+ style: styles$2.branch,
716
+ children: compact && item.branch.length > 36 ? `${item.branch.slice(0, 19)}…${item.branch.slice(-14)}` : item.branch
717
+ }), !compact ? /* @__PURE__ */ jsx(Text, {
718
+ style: styles$2.dim,
719
+ children: item.orphaned ? t("git.ui.itsFolderIsMissing", "Its folder is missing") : item.unowned ? t("git.ui.itsSessionHasEnded", "Its session has ended") : t("git.ui.sessionRunning", "Session running")
720
+ }) : null]
721
+ }),
722
+ item.orphaned ? /* @__PURE__ */ jsx(Badge, {
723
+ tone: "yellow",
724
+ style: styles$2.caution,
725
+ children: t("git.ui.orphaned", "Orphaned")
726
+ }) : null,
727
+ item.unowned ? /* @__PURE__ */ jsx(Badge, {
728
+ tone: "blue",
729
+ style: styles$2.info,
730
+ children: t("git.ui.unowned", "Unowned")
200
731
  }) : null,
201
- /* @__PURE__ */ jsx(Button, {
202
- variant: "danger-outline",
203
- disabled: sessionId === null || busy,
204
- testID: `git-worktree-close-${worktree.id}`,
205
- onPress: () => setClosing(worktree.id),
206
- children: "Close worktree"
732
+ !compact ? /* @__PURE__ */ jsx(Button, {
733
+ variant: "ghost",
734
+ style: styles$2.more,
735
+ accessibilityLabel: t("git.worktree.closeBranch", "Close {branch}", { branch: item.branch }),
736
+ testID: `git-worktree-close-${item.id}`,
737
+ onPress: onClose,
738
+ disabled,
739
+ children: "⋮"
740
+ }) : /* @__PURE__ */ jsx(ChevronRightIcon, {
741
+ size: 16,
742
+ color: "dim"
207
743
  })
208
744
  ]
209
- }, worktree.id)),
210
- state.worktrees.length === 0 ? /* @__PURE__ */ jsx(Text, {
211
- style: styles$1.meta,
212
- children: "No worktrees yet. A worktree is its own checkout, branch and session."
745
+ }),
746
+ !compact ? /* @__PURE__ */ jsx(Text, {
747
+ numberOfLines: 1,
748
+ ellipsizeMode: "middle",
749
+ style: styles$2.path,
750
+ children: item.path
213
751
  }) : null,
214
- /* @__PURE__ */ jsx(Sheet, {
215
- open: creating,
216
- onOpenChange: setCreating,
217
- children: /* @__PURE__ */ jsxs(SheetContent, { children: [/* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: "Create a worktree" }) }), /* @__PURE__ */ jsx(SheetBody, { children: /* @__PURE__ */ jsxs(View, {
218
- style: styles$1.body,
219
- children: [
220
- /* @__PURE__ */ jsx(Input, {
221
- accessibilityLabel: "Branch",
222
- placeholder: "wt/fix-auth",
223
- value: branch,
224
- onChangeText: setBranch
225
- }),
226
- /* @__PURE__ */ jsx(Input, {
227
- accessibilityLabel: "Base ref",
228
- placeholder: "Base (current)",
229
- value: baseRef,
230
- onChangeText: setBaseRef
752
+ error ? /* @__PURE__ */ jsx(Text, {
753
+ accessibilityRole: "alert",
754
+ style: styles$2.error,
755
+ children: error
756
+ }) : null
757
+ ]
758
+ });
759
+ }
760
+ function WorktreeStarting({ branch }) {
761
+ const t = useT();
762
+ return /* @__PURE__ */ jsxs(View, {
763
+ style: styles$2.starting,
764
+ children: [/* @__PURE__ */ jsx(Spinner, { label: t("git.ui.startingSessionPending", "Starting session...") }), /* @__PURE__ */ jsxs(View, {
765
+ style: styles$2.grow,
766
+ children: [branch ? /* @__PURE__ */ jsx(Text, {
767
+ numberOfLines: 1,
768
+ ellipsizeMode: "middle",
769
+ style: styles$2.branch,
770
+ children: branch
771
+ }) : null, /* @__PURE__ */ jsx(Text, {
772
+ style: styles$2.dim,
773
+ children: t("git.ui.startingSessionPending", "Starting session...")
774
+ })]
775
+ })]
776
+ });
777
+ }
778
+ function WorktreeGroup({ title, count }) {
779
+ return /* @__PURE__ */ jsxs(View, {
780
+ style: styles$2.group,
781
+ children: [/* @__PURE__ */ jsx(Text, {
782
+ style: styles$2.heading,
783
+ children: title
784
+ }), /* @__PURE__ */ jsx(Text, {
785
+ style: styles$2.dim,
786
+ children: count
787
+ })]
788
+ });
789
+ }
790
+ function WorktreeForm({ close = false, branch = "", baseRef = "", onBranch, onBaseRef, onConfirm, onCancel, disabled = false, framed = true }) {
791
+ const t = useT();
792
+ return /* @__PURE__ */ jsxs(View, {
793
+ style: [styles$2.sheet, !framed && styles$2.unframed],
794
+ children: [
795
+ framed ? /* @__PURE__ */ jsx(View, { style: styles$2.handle }) : null,
796
+ /* @__PURE__ */ jsx(Text, {
797
+ style: styles$2.sheetTitle,
798
+ children: close ? t("git.ui.closeThisWorktreeConfirm", "Close this worktree?") : t("git.ui.newWorktree", "New worktree")
799
+ }),
800
+ close ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Text, {
801
+ style: styles$2.branch,
802
+ children: branch
803
+ }), /* @__PURE__ */ jsx(Text, {
804
+ style: styles$2.body,
805
+ children: t("git.ui.removesTheCheckoutAndStopsItsSession", "Removes the checkout and stops its session.")
806
+ })] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
807
+ /* @__PURE__ */ jsx(Text, {
808
+ style: styles$2.body,
809
+ children: t("git.ui.aSeparateCheckoutOnItsOwnBranchWithItsOwnSessionThisSessionStaysWhereItIs", "A separate checkout on its own branch, with its own session. This session stays where it is.")
810
+ }),
811
+ /* @__PURE__ */ jsx(Text, {
812
+ style: styles$2.label,
813
+ children: t("git.ui.branch", "Branch")
814
+ }),
815
+ /* @__PURE__ */ jsx(Input, {
816
+ accessibilityLabel: t("git.ui.branch", "Branch"),
817
+ value: branch,
818
+ onChangeText: onBranch,
819
+ style: styles$2.monoInput
820
+ }),
821
+ /* @__PURE__ */ jsx(Text, {
822
+ style: styles$2.label,
823
+ children: t("git.ui.startFrom", "Start from")
824
+ }),
825
+ /* @__PURE__ */ jsx(Input, {
826
+ accessibilityLabel: t("git.ui.startFrom", "Start from"),
827
+ value: baseRef,
828
+ onChangeText: onBaseRef,
829
+ placeholder: t("git.ui.currentBranch", "Current branch")
830
+ })
831
+ ] }),
832
+ /* @__PURE__ */ jsx(Button, {
833
+ onPress: onConfirm,
834
+ disabled: disabled || !close && branch.trim() === "",
835
+ variant: close ? "danger" : "primary",
836
+ style: [styles$2.fullButton, !close && styles$2.createButton],
837
+ children: close ? t("git.ui.closeWorktree", "Close worktree") : /* @__PURE__ */ jsx(Text, {
838
+ style: styles$2.createLabel,
839
+ children: t("git.ui.createWorktree", "Create worktree")
840
+ })
841
+ }),
842
+ /* @__PURE__ */ jsx(Button, {
843
+ variant: "outline",
844
+ style: styles$2.fullButton,
845
+ onPress: onCancel,
846
+ children: t("git.ui.cancel", "Cancel")
847
+ })
848
+ ]
849
+ });
850
+ }
851
+ function WorktreesView({ state, disabled = false, onNew, onClose, onOpen }) {
852
+ const t = useT();
853
+ const { working, attention, starting, closeErrorId } = worktreesPresentation(state);
854
+ const empty = state.worktrees.length === 0 && !starting;
855
+ const busy = disabled || !!state.pending;
856
+ const row = (item) => /* @__PURE__ */ jsx(WorktreeRow, {
857
+ item,
858
+ disabled: disabled || !!state.pending,
859
+ onClose: () => onClose?.(item),
860
+ onOpen: item.sessionId && onOpen ? () => onOpen(item.sessionId) : void 0,
861
+ error: state.errorTarget?.action === "close" && state.errorTarget.id === item.id ? state.error : void 0
862
+ }, item.id);
863
+ return /* @__PURE__ */ jsxs(View, {
864
+ style: styles$2.screen,
865
+ children: [
866
+ /* @__PURE__ */ jsx(WorktreesHeader, {
867
+ disabled: busy,
868
+ onNew,
869
+ showNew: !empty
870
+ }),
871
+ !empty ? /* @__PURE__ */ jsxs(View, {
872
+ style: styles$2.content,
873
+ children: [
874
+ /* @__PURE__ */ jsx(WorktreeGroup, {
875
+ title: t("git.ui.working", "Working"),
876
+ count: t("git.worktree.openStarting", "{count} open{starting}", {
877
+ count: working.length,
878
+ starting: starting ? t("git.worktree.oneStarting", " · 1 starting") : ""
879
+ })
880
+ }),
881
+ working.map(row),
882
+ starting ? /* @__PURE__ */ jsx(WorktreeStarting, { branch: state.requestedBranch }) : null,
883
+ attention.length ? /* @__PURE__ */ jsxs(Fragment, { children: [
884
+ /* @__PURE__ */ jsx(WorktreeGroup, {
885
+ title: t("git.ui.needsALook", "Needs a look"),
886
+ count: t("git.worktree.openCount", "{count} open", { count: attention.length })
231
887
  }),
232
- /* @__PURE__ */ jsx(Text, {
233
- style: styles$1.meta,
234
- children: "Creates the worktree outside the repository and starts a session nested under this one."
888
+ /* @__PURE__ */ jsxs(Text, {
889
+ style: styles$2.dim,
890
+ children: [
891
+ attention.length === 2 ? t("git.ui.twoWorktrees", "Two worktrees") : attention.length === 1 ? t("git.ui.oneWorktree", "One worktree") : t("git.worktree.count", "{count} worktrees", { count: attention.length }),
892
+ " ",
893
+ t("git.ui.wouldLikeYourEyeWheneverYouAreReady", "would like your eye, whenever you are ready.")
894
+ ]
235
895
  }),
236
- /* @__PURE__ */ jsx(Button, {
237
- disabled: sessionId === null || busy || branch.trim() === "",
238
- onPress: () => {
239
- if (sessionId === null) return;
240
- requestWorktreeCreate(sessionId, branch, baseRef, sessionReservationId);
241
- setCreating(false);
242
- if (sessionReservationId === void 0) {
243
- setBranch("");
244
- setBaseRef("");
245
- }
246
- },
247
- children: "Create"
248
- })
249
- ]
250
- }) })] })
251
- }),
252
- /* @__PURE__ */ jsx(Sheet, {
253
- open: closing !== void 0,
254
- onOpenChange: (open) => {
255
- if (!open) setClosing(void 0);
256
- },
257
- children: /* @__PURE__ */ jsxs(SheetContent, { children: [/* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: "Close this worktree?" }) }), /* @__PURE__ */ jsxs(SheetBody, { children: [/* @__PURE__ */ jsx(Text, {
258
- style: styles$1.meta,
259
- children: "The checkout is removed. Git refuses a dirty worktree."
260
- }), /* @__PURE__ */ jsx(Button, {
261
- variant: "danger-outline",
896
+ attention.map(row)
897
+ ] }) : null
898
+ ]
899
+ }) : /* @__PURE__ */ jsx(EmptyState, {
900
+ testID: "git-worktrees-empty",
901
+ icon: /* @__PURE__ */ jsx(BranchIcon, { size: 20 }),
902
+ title: t("git.ui.noWorktreesYet", "No worktrees yet"),
903
+ description: t("git.ui.aWorktreeGivesABranchItsOwnCheckoutAndASessionNestedUnderThisOne", "A worktree gives a branch its own checkout and a session nested under this one."),
904
+ action: onNew ? {
905
+ label: t("git.ui.newWorktree", "New worktree"),
906
+ onAction: onNew,
262
907
  disabled: busy,
263
- onPress: () => {
264
- if (sessionId !== null && closing !== void 0) requestWorktreeClose(sessionId, closing);
265
- setClosing(void 0);
266
- },
267
- children: "Close worktree"
268
- })] })] })
269
- })
908
+ testId: "git-worktree-create"
909
+ } : void 0
910
+ }),
911
+ state.pending && !starting ? /* @__PURE__ */ jsx(Text, {
912
+ style: styles$2.dim,
913
+ children: state.pending
914
+ }) : null,
915
+ state.error && (!closeErrorId || !state.worktrees.some((item) => item.id === closeErrorId)) ? /* @__PURE__ */ jsx(Text, {
916
+ accessibilityRole: "alert",
917
+ style: styles$2.error,
918
+ children: state.error
919
+ }) : null
270
920
  ]
271
921
  });
272
922
  }
273
- const styles$1 = StyleSheet.create((theme) => ({
274
- body: {
275
- padding: theme.spacing(3),
923
+ function WorktreesPanel({ sessionId, sessionReservationId, openSession }) {
924
+ const state = useWorktrees(sessionId);
925
+ const [creating, setCreating] = useState(false);
926
+ const [branch, setBranch] = useState("");
927
+ const [baseRef, setBaseRef] = useState("");
928
+ const [closing, setClosing] = useState();
929
+ const busy = sessionId === null || state.pending !== void 0;
930
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
931
+ /* @__PURE__ */ jsx(ScrollView, {
932
+ contentContainerStyle: styles$2.scroll,
933
+ children: /* @__PURE__ */ jsx(WorktreesView, {
934
+ state,
935
+ disabled: sessionId === null,
936
+ onNew: () => setCreating(true),
937
+ onClose: setClosing,
938
+ onOpen: openSession
939
+ })
940
+ }),
941
+ /* @__PURE__ */ jsx(Sheet, {
942
+ open: creating,
943
+ onOpenChange: setCreating,
944
+ children: /* @__PURE__ */ jsx(SheetContent, { children: /* @__PURE__ */ jsx(WorktreeForm, {
945
+ framed: false,
946
+ branch,
947
+ baseRef,
948
+ onBranch: setBranch,
949
+ onBaseRef: setBaseRef,
950
+ disabled: busy,
951
+ onCancel: () => setCreating(false),
952
+ onConfirm: () => {
953
+ if (sessionId === null) return;
954
+ requestWorktreeCreate(sessionId, branch, baseRef, sessionReservationId);
955
+ setCreating(false);
956
+ if (sessionReservationId === void 0) {
957
+ setBranch("");
958
+ setBaseRef("");
959
+ }
960
+ }
961
+ }) })
962
+ }),
963
+ /* @__PURE__ */ jsx(Sheet, {
964
+ open: !!closing,
965
+ onOpenChange: (open) => {
966
+ if (!open) setClosing(void 0);
967
+ },
968
+ children: /* @__PURE__ */ jsx(SheetContent, { children: /* @__PURE__ */ jsx(WorktreeForm, {
969
+ framed: false,
970
+ close: true,
971
+ branch: closing?.branch,
972
+ disabled: busy,
973
+ onCancel: () => setClosing(void 0),
974
+ onConfirm: () => {
975
+ if (sessionId !== null && closing) requestWorktreeClose(sessionId, closing.id);
976
+ setClosing(void 0);
977
+ }
978
+ }) })
979
+ })
980
+ ] });
981
+ }
982
+ const styles$2 = StyleSheet.create((theme) => ({
983
+ screen: {
984
+ flex: 1,
985
+ backgroundColor: theme.colors.rail,
986
+ uni__dependencies: [0]
987
+ },
988
+ scroll: { flexGrow: 1 },
989
+ header: {
990
+ flexDirection: "row",
991
+ alignItems: "center",
992
+ justifyContent: "space-between",
993
+ padding: theme.spacing(5),
994
+ minHeight: 88,
995
+ uni__dependencies: [0]
996
+ },
997
+ title: {
998
+ fontFamily: fontOf(theme.fontFamily.sans),
999
+ fontSize: theme.fontSize["2xl"],
1000
+ fontWeight: "600",
1001
+ color: theme.colors.hi,
1002
+ uni__dependencies: [0]
1003
+ },
1004
+ newPill: {
1005
+ backgroundColor: theme.colors["tint-green"],
1006
+ borderRadius: theme.borderRadius.full,
1007
+ minHeight: 44,
1008
+ paddingHorizontal: theme.spacing(4),
1009
+ uni__dependencies: [0]
1010
+ },
1011
+ content: {
1012
+ paddingHorizontal: theme.spacing(5),
276
1013
  gap: theme.spacing(2),
277
1014
  uni__dependencies: [0]
278
1015
  },
279
- card: {
280
- borderWidth: 1,
1016
+ group: {
1017
+ flexDirection: "row",
1018
+ alignItems: "center",
1019
+ gap: theme.spacing(3),
1020
+ paddingTop: theme.spacing(4),
1021
+ paddingBottom: theme.spacing(2),
1022
+ borderBottomWidth: StyleSheet.hairlineWidth,
281
1023
  borderColor: theme.colors["border-soft"],
282
- borderRadius: theme.borderRadius.md,
283
- backgroundColor: theme.colors.panel,
284
- padding: theme.spacing(2),
285
- gap: theme.spacing(1),
286
1024
  uni__dependencies: [0]
287
1025
  },
288
- meta: {
289
- color: theme.colors.dim,
290
- fontSize: theme.fontSize.sm,
1026
+ heading: {
1027
+ fontFamily: fontOf(theme.fontFamily.sans),
1028
+ fontSize: theme.fontSize.lg,
1029
+ lineHeight: theme.lineHeight.lg,
1030
+ fontWeight: "600",
1031
+ color: theme.colors.hi,
291
1032
  uni__dependencies: [0]
292
1033
  },
293
- error: {
294
- color: theme.colors.red,
1034
+ dim: {
1035
+ fontFamily: fontOf(theme.fontFamily.sans),
295
1036
  fontSize: theme.fontSize.sm,
1037
+ lineHeight: theme.lineHeight.sm,
1038
+ color: theme.colors.dim,
296
1039
  uni__dependencies: [0]
297
- }
298
- }));
299
- //#endregion
300
- //#region src/types/gitReview.ts
301
- /**
302
- * The cockpit's view of what this session changed against its base: the counts
303
- * the '# diff' group shows, what the review tab lists and draws, and the manual
304
- * sync that sits beside them.
305
- *
306
- * DESIGN PATTERNS:
307
- * - Declarations only, shared by the hub and the page.
308
- * - Its own channel, apart from worktrees. Worktrees are repository
1040
+ },
1041
+ body: {
1042
+ fontFamily: fontOf(theme.fontFamily.sans),
1043
+ fontSize: theme.fontSize.base,
1044
+ lineHeight: theme.lineHeight.lg,
1045
+ color: theme.colors.dim,
1046
+ uni__dependencies: [0]
1047
+ },
1048
+ label: {
1049
+ fontFamily: fontOf(theme.fontFamily.sans),
1050
+ fontSize: theme.fontSize.base,
1051
+ fontWeight: "500",
1052
+ color: theme.colors.text,
1053
+ marginTop: theme.spacing(2),
1054
+ uni__dependencies: [0]
1055
+ },
1056
+ branch: {
1057
+ fontFamily: fontOf(theme.fontFamily.mono),
1058
+ fontSize: theme.fontSize.base,
1059
+ lineHeight: theme.lineHeight.lg,
1060
+ color: theme.colors.hi,
1061
+ uni__dependencies: [0]
1062
+ },
1063
+ path: {
1064
+ fontFamily: fontOf(theme.fontFamily.mono),
1065
+ fontSize: theme.fontSize.sm,
1066
+ lineHeight: theme.lineHeight.sm,
1067
+ color: theme.colors.dim,
1068
+ marginLeft: theme.spacing(4.5),
1069
+ uni__dependencies: [0]
1070
+ },
1071
+ worktree: {
1072
+ gap: theme.spacing(1),
1073
+ paddingVertical: theme.spacing(2),
1074
+ borderBottomWidth: StyleSheet.hairlineWidth,
1075
+ borderColor: theme.colors["border-soft"],
1076
+ uni__dependencies: [0]
1077
+ },
1078
+ line: {
1079
+ flexDirection: "row",
1080
+ alignItems: "center",
1081
+ gap: theme.spacing(2),
1082
+ minHeight: 44,
1083
+ uni__dependencies: [0]
1084
+ },
1085
+ grow: {
1086
+ flex: 1,
1087
+ minWidth: 0,
1088
+ minHeight: 44,
1089
+ justifyContent: "center",
1090
+ gap: theme.spacing(1),
1091
+ uni__dependencies: [0]
1092
+ },
1093
+ more: {
1094
+ width: 44,
1095
+ height: 44,
1096
+ padding: 0
1097
+ },
1098
+ caution: {
1099
+ backgroundColor: theme.colors["tint-yellow"],
1100
+ uni__dependencies: [0]
1101
+ },
1102
+ info: {
1103
+ backgroundColor: theme.colors["tint-blue"],
1104
+ uni__dependencies: [0]
1105
+ },
1106
+ starting: {
1107
+ flexDirection: "row",
1108
+ alignItems: "center",
1109
+ gap: theme.spacing(2),
1110
+ minHeight: 52,
1111
+ uni__dependencies: [0]
1112
+ },
1113
+ jade: {
1114
+ fontFamily: fontOf(theme.fontFamily.sans),
1115
+ fontSize: theme.fontSize.base,
1116
+ lineHeight: theme.lineHeight.base,
1117
+ color: theme.colors.green,
1118
+ fontWeight: "500",
1119
+ uni__dependencies: [0]
1120
+ },
1121
+ error: {
1122
+ fontFamily: fontOf(theme.fontFamily.sans),
1123
+ fontSize: theme.fontSize.sm,
1124
+ lineHeight: theme.lineHeight.sm,
1125
+ color: theme.colors.red,
1126
+ uni__dependencies: [0]
1127
+ },
1128
+ unframed: { borderTopWidth: 0 },
1129
+ sheet: {
1130
+ backgroundColor: theme.colors.bg,
1131
+ borderTopWidth: 1,
1132
+ borderColor: theme.colors.border,
1133
+ borderTopLeftRadius: theme.borderRadius.lg,
1134
+ borderTopRightRadius: theme.borderRadius.lg,
1135
+ padding: theme.spacing(5),
1136
+ gap: theme.spacing(3),
1137
+ uni__dependencies: [0]
1138
+ },
1139
+ handle: {
1140
+ alignSelf: "center",
1141
+ width: 40,
1142
+ height: 4,
1143
+ borderRadius: theme.borderRadius.full,
1144
+ backgroundColor: theme.colors.border,
1145
+ marginBottom: theme.spacing(2),
1146
+ uni__dependencies: [0]
1147
+ },
1148
+ sheetTitle: {
1149
+ fontFamily: fontOf(theme.fontFamily.sans),
1150
+ fontSize: theme.fontSize.xl,
1151
+ fontWeight: "600",
1152
+ color: theme.colors.hi,
1153
+ uni__dependencies: [0]
1154
+ },
1155
+ monoInput: {
1156
+ fontFamily: fontOf(theme.fontFamily.mono),
1157
+ uni__dependencies: [0]
1158
+ },
1159
+ fullButton: {
1160
+ height: 44,
1161
+ alignSelf: "stretch"
1162
+ },
1163
+ createButton: {
1164
+ backgroundColor: theme.colors.green,
1165
+ uni__dependencies: [0]
1166
+ },
1167
+ createLabel: {
1168
+ fontFamily: fontOf(theme.fontFamily.sans),
1169
+ fontSize: theme.fontSize.base,
1170
+ fontWeight: "600",
1171
+ color: theme.colors.bg,
1172
+ uni__dependencies: [0]
1173
+ }
1174
+ }));
1175
+ //#endregion
1176
+ //#region src/types/gitReview.ts
1177
+ /**
1178
+ * The cockpit's view of what this session changed against its base: the counts
1179
+ * the '# diff' group shows, what the review tab lists and draws, and the manual
1180
+ * sync that sits beside them.
1181
+ *
1182
+ * DESIGN PATTERNS:
1183
+ * - Declarations only, shared by the hub and the page.
1184
+ * - Its own channel, apart from worktrees. Worktrees are repository
309
1185
  * management; the diff is this session's code change.
310
1186
  * - A diff row carries one line number whose file follows from its marker: the
311
1187
  * new file's for context and additions, the old file's for removals. It is
@@ -340,7 +1216,7 @@ const gitChanges = defineSessionStore({
340
1216
  errorTarget: void 0
341
1217
  });
342
1218
  /** The page's hub socket sender; undefined before start and after dispose, when a command is dropped. */
343
- const changesSender = defineGlobalStore(void 0);
1219
+ const changesSender = defineHostStore(void 0);
344
1220
  /** Binds the page's hub socket for sync commands. The plugin host calls this once per page. */
345
1221
  function startGitChangesRuntime(runtime) {
346
1222
  const send = (frame) => {
@@ -442,6 +1318,7 @@ function requestGitSync(sessionId, action, force = false) {
442
1318
  //#endregion
443
1319
  //#region src/extensions/workspaces/sessions/(frontend)/activity-group/git.native.ts
444
1320
  var git_native_default = defineActivityGroup({
1321
+ label: "Git",
445
1322
  keys: "g w",
446
1323
  icon: () => createElement(BranchIcon),
447
1324
  activeSource: {
@@ -458,8 +1335,7 @@ var git_native_default = defineActivityGroup({
458
1335
  }
459
1336
  },
460
1337
  marksBackgroundWork: false,
461
- transientTab: worktreesTab,
462
- order: 30
1338
+ transientTab: worktreesTab
463
1339
  });
464
1340
  //#endregion
465
1341
  //#region src/extensions/workspaces/sessions/(frontend)/channel/git-changes.native.ts
@@ -467,56 +1343,6 @@ var git_changes_native_default = defineChannelFile(gitChangesChannel);
467
1343
  //#endregion
468
1344
  //#region src/extensions/workspaces/sessions/(frontend)/channel/git-worktrees.native.ts
469
1345
  var git_worktrees_native_default = defineChannelFile(worktreesChannel);
470
- const api = createApiClient({
471
- /** Workspace: the new-session dialog's branch list. */
472
- branches: {
473
- method: "GET",
474
- path: "/branches",
475
- response: void 0
476
- },
477
- /** Workspace: a top-level worktree session on an existing or new branch. */
478
- createSession: {
479
- method: "POST",
480
- path: "/sessions",
481
- response: void 0
482
- },
483
- /** Workspace: that workspace's saved remote auth, never the token itself. */
484
- auth: {
485
- method: "GET",
486
- path: "/auth",
487
- query: ["repositoryId"],
488
- response: void 0
489
- },
490
- /** Workspace: replaces that workspace's remote auth. Passkey step-up gated for remote devices. */
491
- saveAuth: {
492
- method: "PUT",
493
- path: "/auth",
494
- query: ["repositoryId"],
495
- response: void 0
496
- },
497
- /** Session: the files this session's checkout changed against its base. */
498
- review: {
499
- method: "GET",
500
- path: "/review",
501
- response: void 0
502
- },
503
- /** Session: one changed file's hunks. */
504
- reviewFile: {
505
- method: "GET",
506
- path: "/review/file",
507
- query: ["path"],
508
- response: void 0
509
- }
510
- }, {
511
- scopes: [
512
- "global",
513
- "workspace",
514
- "session"
515
- ],
516
- basePath: "git",
517
- transport: nativeApiTransport,
518
- sessionAddress: sessionApiAddress
519
- });
520
1346
  //#endregion
521
1347
  //#region src/extensions/workspaces/sessions/(frontend)/_lib/gitReviewApi.native.ts
522
1348
  /**
@@ -527,14 +1353,14 @@ const api = createApiClient({
527
1353
  * spells a route or reaches for `fetch`. What travels is file contents, which a
528
1354
  * tunnel's relay must never see in the clear.
529
1355
  */
530
- const UNREACHABLE = "The session is unreachable.";
1356
+ const unreachable = () => t("git.ui.theSessionIsUnreachable", "The session is unreachable.");
531
1357
  function isRecord(value) {
532
1358
  return typeof value === "object" && value !== null && !Array.isArray(value);
533
1359
  }
534
1360
  /** The message a reader is shown: the route's own words, or why there were none. */
535
1361
  function messageOf(result) {
536
- if (result.status === 0) return UNREACHABLE;
537
- return result.error === "" ? `The session answered ${String(result.status)}.` : result.error;
1362
+ if (result.status === 0) return unreachable();
1363
+ return result.error === "" ? t("git.request.sessionStatus", "The session answered {status}.", { status: result.status }) : result.error;
538
1364
  }
539
1365
  async function fetchReviewSummary(sessionId, signal) {
540
1366
  const result = await api.session(sessionId).review(signal === void 0 ? {} : { signal });
@@ -544,7 +1370,7 @@ async function fetchReviewSummary(sessionId, signal) {
544
1370
  };
545
1371
  if (!isRecord(result.data) || !Array.isArray(result.data.files)) return {
546
1372
  ok: false,
547
- error: "The session answered with no file list."
1373
+ error: t("git.ui.theSessionAnsweredWithNoFileList", "The session answered with no file list.")
548
1374
  };
549
1375
  return {
550
1376
  ok: true,
@@ -562,7 +1388,7 @@ async function fetchReviewFile(sessionId, path, signal) {
562
1388
  };
563
1389
  if (!isRecord(result.data) || !Array.isArray(result.data.hunks)) return {
564
1390
  ok: false,
565
- error: "The session answered with no diff."
1391
+ error: t("git.ui.theSessionAnsweredWithNoDiff", "The session answered with no diff.")
566
1392
  };
567
1393
  return {
568
1394
  ok: true,
@@ -570,6 +1396,31 @@ async function fetchReviewFile(sessionId, path, signal) {
570
1396
  };
571
1397
  }
572
1398
  //#endregion
1399
+ //#region src/extensions/workspaces/sessions/(frontend)/_lib/gitReviewSelection.ts
1400
+ /** A different side starts a fresh selection. The second same-side tap completes it. */
1401
+ function selectReviewLine(anchor, row) {
1402
+ const side = row.marker === "-" ? "old" : "new";
1403
+ if (!anchor || anchor.side !== side) return {
1404
+ range: {
1405
+ side,
1406
+ startLine: row.line,
1407
+ endLine: row.line
1408
+ },
1409
+ complete: false
1410
+ };
1411
+ return {
1412
+ range: {
1413
+ side,
1414
+ startLine: Math.min(anchor.startLine, row.line),
1415
+ endLine: Math.max(anchor.startLine, row.line)
1416
+ },
1417
+ complete: true
1418
+ };
1419
+ }
1420
+ function reviewRangeRows(rows, range) {
1421
+ return rows.filter((row) => (row.marker === "-" ? "old" : "new") === range.side && row.line >= range.startLine && row.line <= range.endLine);
1422
+ }
1423
+ //#endregion
573
1424
  //#region src/extensions/workspaces/sessions/(frontend)/_lib/gitReviewStore.native.ts
574
1425
  const gitReview = defineSessionStore({ comments: [] });
575
1426
  function addReviewComment(sessionId, comment) {
@@ -615,10 +1466,30 @@ function conflictPrompt(branch, conflicts) {
615
1466
  ].join("\n");
616
1467
  }
617
1468
  /**
1469
+ * The one sync the bar fills in: pull while the branch is behind (a push would
1470
+ * be rejected), push while it is only ahead or has no upstream yet. Nothing
1471
+ * while a rebase is paused, detached, or already level.
1472
+ */
1473
+ function suggestedSyncAction(changes) {
1474
+ if (changes?.branch === void 0 || changes.rebase !== void 0) return void 0;
1475
+ if (changes.upstream === void 0) return "push";
1476
+ if (changes.upstream.behind > 0) return "pull";
1477
+ return changes.upstream.ahead > 0 ? "push" : void 0;
1478
+ }
1479
+ /** "2 to push, 1 new on origin/feat/git", or "Up to date with origin/feat/git". */
1480
+ function upstreamSummary(t, upstream) {
1481
+ if (upstream === void 0) return t("git.ui.noUpstreamYet", "No upstream yet");
1482
+ const parts = [...upstream.ahead > 0 ? [t("git.sync.toPush", "{count} to push", { count: upstream.ahead })] : [], ...upstream.behind > 0 ? [t("git.sync.newOn", "{count} new on {ref}", {
1483
+ count: upstream.behind,
1484
+ ref: upstream.ref
1485
+ })] : []];
1486
+ return parts.length === 0 ? t("git.sync.upToDate", "Up to date with {ref}", { ref: upstream.ref }) : parts.join(", ");
1487
+ }
1488
+ /**
618
1489
  * Hands one deferred follow-up to the session. Returns the reason it failed,
619
1490
  * or undefined once sent. The sender throws when the session is disconnected.
620
1491
  */
621
- function deliverToAgent(send, sessionId, message) {
1492
+ function deliverToAgent(t, send, sessionId, message) {
622
1493
  try {
623
1494
  send(sessionId, {
624
1495
  type: "follow_up",
@@ -626,415 +1497,1248 @@ function deliverToAgent(send, sessionId, message) {
626
1497
  });
627
1498
  return;
628
1499
  } catch (error) {
629
- return error instanceof Error ? error.message : "The session did not take the message.";
1500
+ return error instanceof Error ? error.message : t("git.ui.theSessionDidNotTakeTheMessage", "The session did not take the message.");
630
1501
  }
631
1502
  }
632
1503
  //#endregion
633
- //#region src/extensions/workspaces/sessions/(frontend)/_components/GitReviewPanel.native.tsx
634
- function useGitChanges(sessionId) {
635
- const subscribe = useCallback((listener) => {
636
- const sub = gitChanges.store.subscribe(listener);
637
- return () => sub.unsubscribe();
638
- }, []);
639
- return useSyncExternalStore(subscribe, () => gitChanges.select(gitChanges.store.state, sessionId));
1504
+ //#region src/extensions/workspaces/sessions/(frontend)/_components/GitReviewView.native.tsx
1505
+ function Action({ children, variant = "outline", disabled = false, onPress }) {
1506
+ const { theme } = useUnistyles();
1507
+ return /* @__PURE__ */ jsx(Button, {
1508
+ onPress,
1509
+ variant,
1510
+ disabled,
1511
+ style: [styles$1.action, variant === "primary" && styles$1.primary],
1512
+ children: variant === "primary" ? /* @__PURE__ */ jsx(Text, {
1513
+ style: [styles$1.primaryLabel, { color: theme.scheme === "dark" ? theme.colors.rail : theme.colors["on-selected"] }],
1514
+ children
1515
+ }) : children
1516
+ });
640
1517
  }
641
- function reviewTab() {
642
- return {
643
- id: "git-review",
644
- label: "review",
645
- panel: GitReviewPanel
646
- };
1518
+ function Footer({ count, discard = false, confirmation = false, onReview, onSend, onDiscard }) {
1519
+ const t = useT();
1520
+ return /* @__PURE__ */ jsxs(View, {
1521
+ style: styles$1.footer,
1522
+ children: [discard ? /* @__PURE__ */ jsx(Action, {
1523
+ variant: "ghost",
1524
+ onPress: onDiscard,
1525
+ children: t("git.ui.discard", "Discard")
1526
+ }) : /* @__PURE__ */ jsxs(Pressable, {
1527
+ accessibilityRole: "button",
1528
+ accessibilityLabel: t("git.ui.reviewQueuedComments", "Review queued comments"),
1529
+ onPress: onReview,
1530
+ style: [styles$1.inline, styles$1.action],
1531
+ children: [/* @__PURE__ */ jsx(MessageIcon, {
1532
+ size: 16,
1533
+ color: "blue"
1534
+ }), /* @__PURE__ */ jsx(Text, {
1535
+ style: styles$1.dim,
1536
+ children: count === 1 ? t("git.ui.queuedCommentCount", "{count} comment queued", { count }) : t("git.ui.queuedCommentsCount", "{count} comments queued", { count })
1537
+ })]
1538
+ }), /* @__PURE__ */ jsx(Action, {
1539
+ variant: confirmation ? "outline" : "primary",
1540
+ disabled: count === 0,
1541
+ onPress: onSend,
1542
+ children: t("git.ui.sendReview", "Send review")
1543
+ })]
1544
+ });
647
1545
  }
648
- function GitReviewPanel({ sessionId, sendSessionFrame }) {
649
- const activity = useGitChanges(sessionId);
650
- const subscribe = useCallback((listener) => {
651
- const sub = gitReview.store.subscribe(listener);
652
- return () => sub.unsubscribe();
653
- }, []);
654
- const comments = useSyncExternalStore(subscribe, () => gitReview.select(gitReview.store.state, sessionId).comments);
655
- const [summary, setSummary] = useState();
656
- const [file, setFile] = useState();
657
- const [error, setError] = useState();
658
- const [dismissedError, setDismissedError] = useState();
659
- const [confirm, setConfirm] = useState();
660
- const [draft, setDraft] = useState();
661
- const [comment, setComment] = useState("");
662
- const [start, setStart] = useState("");
663
- const [end, setEnd] = useState("");
664
- const request = useRef(void 0);
665
- const fingerprint = JSON.stringify(activity.changes);
666
- useEffect(() => {
667
- if (sessionId === null) return void 0;
668
- const controller = new AbortController();
669
- fetchReviewSummary(sessionId, controller.signal).then((result) => {
670
- if (!controller.signal.aborted) {
671
- if (result.ok) setSummary(result.summary);
672
- else setError(result.error);
673
- }
674
- }).catch((cause) => {
675
- if (!controller.signal.aborted) setError(cause instanceof Error ? cause.message : String(cause));
676
- });
677
- return () => {
678
- controller.abort();
679
- request.current?.abort();
680
- };
681
- }, [sessionId, fingerprint]);
682
- const loadFile = async (path) => {
683
- if (sessionId === null) return;
684
- request.current?.abort();
685
- const controller = new AbortController();
686
- request.current = controller;
687
- setFile(void 0);
688
- setError(void 0);
689
- try {
690
- const result = await fetchReviewFile(sessionId, path, controller.signal);
691
- if (!controller.signal.aborted) {
692
- if (result.ok) setFile(result.diff);
693
- else setError(result.error);
694
- }
695
- } catch (cause) {
696
- if (!controller.signal.aborted) setError(cause instanceof Error ? cause.message : String(cause));
697
- }
698
- };
699
- if (sessionId === null) return null;
700
- const changes = activity.changes;
701
- const busy = activity.pending !== void 0;
702
- const paused = changes?.rebase !== void 0;
703
- const send = (message, onSent) => {
704
- const failure = deliverToAgent(sendSessionFrame, sessionId, message);
705
- setError(failure);
706
- if (failure === void 0) onSent?.();
707
- };
708
- const sync = (action) => requestGitSync(sessionId, action);
709
- const forceRequired = activity.error !== dismissedError && activity.errorTarget?.action === "push" && activity.errorTarget.forceRequired === true;
710
- return /* @__PURE__ */ jsxs(ScrollView, {
711
- contentContainerStyle: styles.body,
1546
+ function SyncCard({ changes, busy = false, onSync }) {
1547
+ const t = useT();
1548
+ const suggested = suggestedSyncAction(changes);
1549
+ return /* @__PURE__ */ jsxs(View, {
1550
+ style: styles$1.card,
712
1551
  children: [
713
- /* @__PURE__ */ jsx(Text, {
714
- style: styles.title,
715
- children: changes?.branch ?? "Detached HEAD"
716
- }),
717
- /* @__PURE__ */ jsxs(Text, {
718
- style: styles.meta,
719
- children: [
720
- changes?.base ? `vs ${changes.base}` : "Uncommitted changes",
721
- " · +",
722
- changes?.added ?? 0,
723
- " -",
724
- changes?.removed ?? 0,
725
- "\\n",
726
- changes?.upstream ? `↑${changes.upstream.ahead} ↓${changes.upstream.behind} ${changes.upstream.ref}` : "No upstream yet"
727
- ]
728
- }),
729
1552
  /* @__PURE__ */ jsxs(View, {
730
- style: styles.actions,
1553
+ style: styles$1.inline,
731
1554
  children: [
732
- /* @__PURE__ */ jsx(Button, {
733
- variant: "outline",
734
- disabled: busy || paused || changes?.upstream === void 0,
735
- onPress: () => sync("pull"),
736
- children: "Pull"
1555
+ /* @__PURE__ */ jsx(BranchIcon, {
1556
+ size: 18,
1557
+ color: "dim"
737
1558
  }),
738
- /* @__PURE__ */ jsx(Button, {
739
- variant: "outline",
740
- disabled: busy || paused || changes?.branch === void 0,
741
- onPress: () => sync("push"),
742
- children: "Push"
1559
+ /* @__PURE__ */ jsx(Text, {
1560
+ style: styles$1.branch,
1561
+ children: changes?.branch ?? t("git.ui.detachedHEAD", "Detached HEAD")
743
1562
  }),
744
- /* @__PURE__ */ jsx(Button, {
745
- variant: "outline",
746
- disabled: busy || paused || changes?.base === void 0,
747
- onPress: () => sync("rebase"),
748
- children: "Rebase"
749
- })
750
- ]
751
- }),
752
- activity.pending ? /* @__PURE__ */ jsx(Text, {
753
- style: styles.meta,
754
- children: activity.pending
755
- }) : null,
756
- activity.error && activity.error !== dismissedError ? /* @__PURE__ */ jsxs(View, { children: [/* @__PURE__ */ jsx(Text, {
757
- style: styles.error,
758
- children: activity.error
759
- }), /* @__PURE__ */ jsx(Button, {
760
- variant: "ghost",
761
- onPress: () => setDismissedError(activity.error),
762
- children: "Dismiss"
763
- })] }) : null,
764
- forceRequired ? /* @__PURE__ */ jsx(Button, {
765
- variant: "danger-outline",
766
- disabled: busy,
767
- onPress: () => setConfirm("force"),
768
- children: "Force push with lease…"
769
- }) : null,
770
- paused ? /* @__PURE__ */ jsxs(View, {
771
- style: styles.body,
772
- children: [
1563
+ /* @__PURE__ */ jsx(View, { style: styles$1.grow }),
773
1564
  /* @__PURE__ */ jsxs(Text, {
774
- style: styles.error,
775
- children: ["Rebase paused\\n", changes.rebase?.conflicts.join("\n")]
776
- }),
777
- /* @__PURE__ */ jsx(Button, {
778
- disabled: busy,
779
- onPress: () => send(conflictPrompt(changes.branch, changes.rebase?.conflicts ?? [])),
780
- children: "Ask agent to resolve"
1565
+ style: styles$1.green,
1566
+ children: ["+", changes?.added ?? 0]
781
1567
  }),
782
- /* @__PURE__ */ jsx(Button, {
783
- variant: "danger-outline",
784
- disabled: busy,
785
- onPress: () => setConfirm("abort"),
786
- children: "Abort rebase…"
1568
+ /* @__PURE__ */ jsxs(Text, {
1569
+ style: styles$1.red,
1570
+ children: ["-", changes?.removed ?? 0]
787
1571
  })
788
1572
  ]
789
- }) : null,
790
- error ? /* @__PURE__ */ jsx(Text, {
791
- style: styles.error,
792
- children: error
793
- }) : null,
794
- summary ? summary.files.map((entry) => /* @__PURE__ */ jsxs(Button, {
795
- variant: "ghost",
796
- testID: `git-review-file-${entry.path}`,
797
- onPress: () => void loadFile(entry.path),
798
- children: [
799
- entry.path,
800
- " · ",
801
- entry.status,
802
- " · +",
803
- entry.added,
804
- " -",
805
- entry.removed
806
- ]
807
- }, entry.path)) : /* @__PURE__ */ jsx(Text, {
808
- style: styles.meta,
809
- children: "Loading changes…"
810
1573
  }),
811
- summary?.files.length === 0 ? /* @__PURE__ */ jsx(Text, {
812
- style: styles.meta,
813
- children: summary.repository ? "No changed files" : "Not a Git checkout"
814
- }) : null,
815
- summary?.truncated ? /* @__PURE__ */ jsx(Text, {
816
- style: styles.meta,
817
- children: "The file list was truncated."
818
- }) : null,
819
- file ? /* @__PURE__ */ jsxs(View, {
820
- style: styles.body,
1574
+ /* @__PURE__ */ jsx(Text, {
1575
+ style: [styles$1.dim, styles$1.mono],
1576
+ children: changes?.base ? t("git.review.versus", "vs {base}", { base: changes.base }) : t("git.ui.uncommittedChanges", "Uncommitted changes")
1577
+ }),
1578
+ /* @__PURE__ */ jsx(Text, {
1579
+ style: styles$1.dim,
1580
+ children: upstreamSummary(t, changes?.upstream)
1581
+ }),
1582
+ /* @__PURE__ */ jsx(View, {
1583
+ style: styles$1.inline,
821
1584
  children: [
822
- /* @__PURE__ */ jsx(Text, {
823
- style: styles.title,
824
- children: file.path
1585
+ "pull",
1586
+ "push",
1587
+ "rebase"
1588
+ ].map((action) => /* @__PURE__ */ jsx(Button, {
1589
+ variant: suggested === action ? "outline" : "ghost",
1590
+ style: suggested === action ? [styles$1.action, styles$1.suggested] : styles$1.action,
1591
+ disabled: busy || changes?.rebase !== void 0 || (action === "pull" ? changes?.upstream === void 0 : action === "push" ? changes?.branch === void 0 : changes?.base === void 0),
1592
+ onPress: () => onSync?.(action),
1593
+ children: action === "pull" ? t("git.ui.pull", "Pull") : action === "push" ? t("git.ui.push", "Push") : t("git.ui.rebase", "Rebase")
1594
+ }, action))
1595
+ })
1596
+ ]
1597
+ });
1598
+ }
1599
+ function FileList({ files, comments = [], onFile }) {
1600
+ const t = useT();
1601
+ return /* @__PURE__ */ jsxs(View, {
1602
+ style: styles$1.list,
1603
+ children: [/* @__PURE__ */ jsxs(Text, {
1604
+ style: styles$1.section,
1605
+ children: [
1606
+ files.length,
1607
+ " ",
1608
+ t("git.ui.files", "files")
1609
+ ]
1610
+ }), files.map((file) => /* @__PURE__ */ jsxs(Pressable, {
1611
+ accessibilityRole: "button",
1612
+ testID: `git-review-file-${file.path}`,
1613
+ onPress: () => onFile?.(file.path),
1614
+ style: styles$1.fileRow,
1615
+ children: [
1616
+ /* @__PURE__ */ jsx(Text, {
1617
+ style: file.status === "added" ? styles$1.green : file.status === "untracked" ? styles$1.blue : styles$1.yellow,
1618
+ children: file.status[0]?.toUpperCase()
1619
+ }),
1620
+ /* @__PURE__ */ jsxs(View, {
1621
+ style: styles$1.grow,
1622
+ children: [/* @__PURE__ */ jsx(Text, {
1623
+ style: styles$1.body,
1624
+ children: file.path.split("/").at(-1)
1625
+ }), /* @__PURE__ */ jsx(Text, {
1626
+ numberOfLines: 1,
1627
+ style: [styles$1.dim, styles$1.mono],
1628
+ children: file.path.split("/").slice(0, -1).join("/") || "."
1629
+ })]
1630
+ }),
1631
+ /* @__PURE__ */ jsxs(Text, { children: [
1632
+ /* @__PURE__ */ jsxs(Text, {
1633
+ style: styles$1.green,
1634
+ children: ["+", file.added]
825
1635
  }),
826
- file.binary || file.tooLarge ? /* @__PURE__ */ jsx(Text, {
827
- style: styles.meta,
828
- children: file.binary ? "Binary file" : "Diff too large to display"
829
- }) : file.hunks.map((hunk, index) => /* @__PURE__ */ jsx(View, { children: hunk.rows.map((row, rowIndex) => /* @__PURE__ */ jsxs(Text, {
830
- selectable: true,
831
- style: styles.diff(row.marker),
832
- onPress: () => {
833
- setDraft({
834
- path: file.path,
835
- rows: hunk.rows
836
- });
837
- setStart(String(row.line));
838
- setEnd(String(row.line));
839
- },
840
- children: [
841
- row.marker,
842
- " ",
843
- row.line,
844
- " ",
845
- row.content
846
- ]
847
- }, rowIndex)) }, index)),
848
- /* @__PURE__ */ jsx(Button, {
849
- variant: "outline",
850
- onPress: () => {
851
- setDraft({
852
- path: file.path,
853
- rows: []
854
- });
855
- setStart("");
856
- setEnd("");
857
- },
858
- children: "Comment on file"
1636
+ " ",
1637
+ /* @__PURE__ */ jsxs(Text, {
1638
+ style: styles$1.red,
1639
+ children: ["-", file.removed]
859
1640
  })
860
- ]
861
- }) : null,
862
- comments.map((item) => /* @__PURE__ */ jsxs(View, { children: [/* @__PURE__ */ jsxs(Text, {
863
- style: styles.meta,
1641
+ ] }),
1642
+ comments.some((comment) => comment.path === file.path) ? /* @__PURE__ */ jsxs(View, {
1643
+ style: styles$1.inline,
1644
+ children: [/* @__PURE__ */ jsx(MessageIcon, {
1645
+ size: 12,
1646
+ color: "blue"
1647
+ }), /* @__PURE__ */ jsx(Text, {
1648
+ style: styles$1.blue,
1649
+ children: comments.filter((comment) => comment.path === file.path).length
1650
+ })]
1651
+ }) : null,
1652
+ /* @__PURE__ */ jsx(ChevronRightIcon, {
1653
+ size: 16,
1654
+ color: "dim"
1655
+ })
1656
+ ]
1657
+ }, file.path))]
1658
+ });
1659
+ }
1660
+ function RebaseCard({ confirmation = false, conflicts, busy = false, onResolve, onAbort }) {
1661
+ const t = useT();
1662
+ return /* @__PURE__ */ jsxs(View, {
1663
+ style: [styles$1.card, styles$1.caution],
1664
+ children: [
1665
+ /* @__PURE__ */ jsxs(View, {
1666
+ style: styles$1.inline,
1667
+ children: [/* @__PURE__ */ jsx(AlertIcon, {
1668
+ size: 20,
1669
+ color: "yellow"
1670
+ }), /* @__PURE__ */ jsx(Text, {
1671
+ style: styles$1.section,
1672
+ children: t("git.ui.rebasePaused", "Rebase paused")
1673
+ })]
1674
+ }),
1675
+ /* @__PURE__ */ jsx(Text, {
1676
+ style: styles$1.body,
1677
+ children: t("git.ui.resolveConflictsOrAskPoToDoItForYou", "Resolve conflicts or ask Po to do it for you.")
1678
+ }),
1679
+ /* @__PURE__ */ jsx(Text, {
1680
+ style: [styles$1.dim, styles$1.mono],
1681
+ children: conflicts.join("\n")
1682
+ }),
1683
+ /* @__PURE__ */ jsx(Action, {
1684
+ disabled: busy,
1685
+ onPress: onResolve,
1686
+ variant: confirmation ? "outline" : "primary",
1687
+ children: t("git.ui.askPoToResolve", "Ask Po to resolve")
1688
+ }),
1689
+ /* @__PURE__ */ jsx(Action, {
1690
+ disabled: busy,
1691
+ onPress: onAbort,
1692
+ variant: "danger-outline",
1693
+ children: t("git.ui.abortRebase", "Abort rebase")
1694
+ })
1695
+ ]
1696
+ });
1697
+ }
1698
+ function FileHeader({ entry, index, total, onPrevious, onNext, onChanges }) {
1699
+ const t = useT();
1700
+ return /* @__PURE__ */ jsxs(View, {
1701
+ style: styles$1.content,
1702
+ children: [
1703
+ /* @__PURE__ */ jsx(Text, {
1704
+ style: styles$1.heading,
1705
+ children: entry.path.split("/").at(-1)
1706
+ }),
1707
+ /* @__PURE__ */ jsx(Text, {
1708
+ style: [styles$1.dim, styles$1.mono],
1709
+ children: entry.path.split("/").slice(0, -1).join("/") || "."
1710
+ }),
1711
+ /* @__PURE__ */ jsxs(View, {
1712
+ style: styles$1.inline,
864
1713
  children: [
865
- item.relPath,
866
- item.startLine === void 0 ? "" : `:${item.startLine}-${item.endLine ?? item.startLine}`,
867
- "\\n",
868
- item.body
1714
+ /* @__PURE__ */ jsxs(Text, {
1715
+ style: styles$1.dim,
1716
+ children: [entry.status[0]?.toUpperCase(), entry.status.slice(1)]
1717
+ }),
1718
+ /* @__PURE__ */ jsxs(Text, {
1719
+ style: styles$1.green,
1720
+ children: ["+", entry.added]
1721
+ }),
1722
+ /* @__PURE__ */ jsxs(Text, {
1723
+ style: styles$1.red,
1724
+ children: ["-", entry.removed]
1725
+ })
869
1726
  ]
870
- }), /* @__PURE__ */ jsx(Button, {
1727
+ }),
1728
+ /* @__PURE__ */ jsxs(View, {
1729
+ style: styles$1.navigation,
1730
+ children: [
1731
+ /* @__PURE__ */ jsx(Action, {
1732
+ variant: "ghost",
1733
+ disabled: index === 0,
1734
+ onPress: onPrevious,
1735
+ children: t("git.ui.previous", "Previous")
1736
+ }),
1737
+ /* @__PURE__ */ jsx(Pressable, {
1738
+ accessibilityRole: "button",
1739
+ accessibilityLabel: t("git.ui.returnToChanges", "Return to changes"),
1740
+ onPress: onChanges,
1741
+ style: [styles$1.inline, styles$1.action],
1742
+ children: /* @__PURE__ */ jsxs(Text, {
1743
+ style: styles$1.dim,
1744
+ children: [
1745
+ onChanges ? t("git.ui.changes", "Changes · ") : "",
1746
+ index + 1,
1747
+ " ",
1748
+ t("git.ui.of", "of"),
1749
+ " ",
1750
+ total
1751
+ ]
1752
+ })
1753
+ }),
1754
+ /* @__PURE__ */ jsx(Action, {
1755
+ variant: "ghost",
1756
+ disabled: index === total - 1,
1757
+ onPress: onNext,
1758
+ children: t("git.ui.next", "Next")
1759
+ })
1760
+ ]
1761
+ })
1762
+ ]
1763
+ });
1764
+ }
1765
+ const DiffRows = memo(function DiffRows({ rows, comments = [], selection, onLine, showInlineComments = true, gutterDigits }) {
1766
+ const anchoredComments = useMemo(() => {
1767
+ const index = /* @__PURE__ */ new Map();
1768
+ for (const comment of comments) {
1769
+ const key = `${comment.side}:${comment.endLine ?? comment.startLine}`;
1770
+ const entries = index.get(key);
1771
+ if (entries) entries.push(comment);
1772
+ else index.set(key, [comment]);
1773
+ }
1774
+ return index;
1775
+ }, [comments]);
1776
+ const digits = gutterDigits ?? rows.reduce((max, row) => Math.max(max, String(row.line).length), 1);
1777
+ return /* @__PURE__ */ jsx(View, { children: rows.map((row, i) => {
1778
+ const side = row.marker === "-" ? "old" : "new";
1779
+ const anchored = anchoredComments.get(`${side}:${row.line}`) ?? [];
1780
+ return /* @__PURE__ */ jsxs(View, { children: [/* @__PURE__ */ jsxs(Pressable, {
1781
+ accessibilityRole: "button",
1782
+ accessibilityLabel: t("git.review.selectLine", "Select {side} line {line}", {
1783
+ side: side === "old" ? t("git.review.oldSide", "old") : t("git.review.newSide", "new"),
1784
+ line: row.line
1785
+ }),
1786
+ onPress: () => onLine?.(row),
1787
+ style: [
1788
+ styles$1.diffRow,
1789
+ row.marker === "+" && styles$1.added,
1790
+ row.marker === "-" && styles$1.removed,
1791
+ selection?.side === side && row.line >= selection.startLine && row.line <= selection.endLine && styles$1.selection
1792
+ ],
1793
+ children: [
1794
+ /* @__PURE__ */ jsx(Text, {
1795
+ numberOfLines: 1,
1796
+ style: [styles$1.mono, styles$1.gutter],
1797
+ children: String(row.line).padStart(digits, "\xA0")
1798
+ }),
1799
+ /* @__PURE__ */ jsx(Text, {
1800
+ style: [styles$1.dim, styles$1.mono],
1801
+ children: row.marker
1802
+ }),
1803
+ /* @__PURE__ */ jsx(SyntaxLine, {
1804
+ text: row.content || " ",
1805
+ style: [styles$1.mono, styles$1.code]
1806
+ }),
1807
+ anchored.length ? /* @__PURE__ */ jsx(MessageIcon, {
1808
+ size: 12,
1809
+ color: "blue"
1810
+ }) : null
1811
+ ]
1812
+ }), showInlineComments && anchored.map((comment) => /* @__PURE__ */ jsxs(View, {
1813
+ style: styles$1.inlineComment,
1814
+ children: [/* @__PURE__ */ jsxs(Text, {
1815
+ style: styles$1.blue,
1816
+ children: [
1817
+ t("git.ui.queuedComment", "Queued comment ·"),
1818
+ " ",
1819
+ lineLabel(comment)
1820
+ ]
1821
+ }), /* @__PURE__ */ jsx(Text, {
1822
+ style: styles$1.body,
1823
+ children: comment.body
1824
+ })]
1825
+ }, comment.id))] }, i);
1826
+ }) });
1827
+ });
1828
+ function lineLabel(comment) {
1829
+ return comment.startLine === void 0 ? t("git.ui.fileComment", "File comment") : comment.endLine === comment.startLine || comment.endLine === void 0 ? t("git.review.line", "Line {line}", { line: comment.startLine }) : t("git.review.lines", "Lines {start} to {end}", {
1830
+ start: comment.startLine,
1831
+ end: comment.endLine
1832
+ });
1833
+ }
1834
+ function CommentSheet({ range, snippet, value, onChange, onAdd, onCancel }) {
1835
+ const t = useT();
1836
+ return /* @__PURE__ */ jsxs(View, {
1837
+ style: styles$1.sheet,
1838
+ children: [
1839
+ /* @__PURE__ */ jsx(View, { style: styles$1.handle }),
1840
+ /* @__PURE__ */ jsx(Text, {
1841
+ style: styles$1.sheetTitle,
1842
+ children: range ? lineLabel(range) : t("git.ui.commentOnFile", "Comment on file")
1843
+ }),
1844
+ snippet ? /* @__PURE__ */ jsx(View, {
1845
+ style: styles$1.quote,
1846
+ children: /* @__PURE__ */ jsx(SyntaxLine, {
1847
+ text: snippet,
1848
+ style: [styles$1.body, styles$1.mono]
1849
+ })
1850
+ }) : null,
1851
+ /* @__PURE__ */ jsx(Textarea, {
1852
+ accessibilityLabel: t("git.ui.whatShouldChangeHereConfirm", "What should change here?"),
1853
+ placeholder: t("git.ui.whatShouldChangeHereConfirm", "What should change here?"),
1854
+ rows: 4,
1855
+ value,
1856
+ onChangeText: onChange
1857
+ }),
1858
+ /* @__PURE__ */ jsx(Action, {
1859
+ variant: "primary",
1860
+ disabled: value !== void 0 && value.trim() === "",
1861
+ onPress: onAdd,
1862
+ children: t("git.ui.addComment", "Add comment")
1863
+ }),
1864
+ /* @__PURE__ */ jsx(Action, {
871
1865
  variant: "ghost",
872
- onPress: () => removeReviewComment(sessionId, item.id),
873
- children: "Remove comment"
874
- })] }, item.id)),
875
- comments.length > 0 ? /* @__PURE__ */ jsxs(View, {
876
- style: styles.actions,
877
- children: [/* @__PURE__ */ jsx(Button, {
878
- onPress: () => {
879
- const body = comments.map((item) => {
880
- return `### ${item.startLine === void 0 ? item.relPath : item.side === "old" ? `${item.relPath} (removed lines ${item.startLine}-${item.endLine ?? item.startLine})` : `${item.relPath}:${item.startLine}-${item.endLine ?? item.startLine}`}\n\n${item.snippet.split("\n").slice(0, 20).join("\n").slice(0, 2e3).split("\n").map((line) => `> ${line}`).join("\n")}\n\n${item.body.trim()}`;
881
- }).join("\n\n");
882
- send(`${reviewHeading(comments.length, summary?.branch, summary?.base)}\n\n${body}`, () => clearReviewComments(sessionId));
883
- },
884
- children: "Send review"
885
- }), /* @__PURE__ */ jsx(Button, {
886
- variant: "outline",
887
- onPress: () => setConfirm("discard"),
888
- children: "Discard review…"
889
- })]
1866
+ onPress: onCancel,
1867
+ children: t("git.ui.cancel", "Cancel")
1868
+ })
1869
+ ]
1870
+ });
1871
+ }
1872
+ function CommentCards({ comments, onRemove }) {
1873
+ const t = useT();
1874
+ return /* @__PURE__ */ jsxs(View, {
1875
+ style: styles$1.content,
1876
+ children: [/* @__PURE__ */ jsx(Text, {
1877
+ style: styles$1.body,
1878
+ children: comments.length === 1 ? t("git.review.readyCommentsOne", "{count} comment queued for Po, whenever you are ready.", { count: comments.length }) : t("git.review.readyComments", "{count} comments queued for Po, whenever you are ready.", { count: comments.length })
1879
+ }), comments.map((comment) => /* @__PURE__ */ jsxs(View, {
1880
+ style: styles$1.card,
1881
+ children: [
1882
+ /* @__PURE__ */ jsx(Text, {
1883
+ style: [styles$1.body, styles$1.mono],
1884
+ children: comment.relPath
1885
+ }),
1886
+ /* @__PURE__ */ jsx(Text, {
1887
+ style: styles$1.dim,
1888
+ children: lineLabel(comment)
1889
+ }),
1890
+ comment.snippet ? /* @__PURE__ */ jsx(View, {
1891
+ style: styles$1.quote,
1892
+ children: /* @__PURE__ */ jsx(SyntaxLine, {
1893
+ text: comment.snippet,
1894
+ style: [styles$1.body, styles$1.mono]
1895
+ })
1896
+ }) : null,
1897
+ /* @__PURE__ */ jsx(Text, {
1898
+ style: styles$1.body,
1899
+ children: comment.body
1900
+ }),
1901
+ /* @__PURE__ */ jsx(View, {
1902
+ style: styles$1.remove,
1903
+ children: /* @__PURE__ */ jsx(Action, {
1904
+ variant: "ghost",
1905
+ onPress: () => onRemove?.(comment.id),
1906
+ children: t("git.ui.remove", "Remove")
1907
+ })
1908
+ })
1909
+ ]
1910
+ }, comment.id))]
1911
+ });
1912
+ }
1913
+ const styles$1 = StyleSheet.create((theme) => ({
1914
+ heading: {
1915
+ fontFamily: fontOf(theme.fontFamily.sans),
1916
+ fontSize: theme.fontSize["2xl"],
1917
+ fontWeight: "600",
1918
+ color: theme.colors.hi,
1919
+ uni__dependencies: [0]
1920
+ },
1921
+ sheetTitle: {
1922
+ fontFamily: fontOf(theme.fontFamily.sans),
1923
+ fontSize: theme.fontSize.xl,
1924
+ fontWeight: "600",
1925
+ color: theme.colors.hi,
1926
+ uni__dependencies: [0]
1927
+ },
1928
+ section: {
1929
+ fontFamily: fontOf(theme.fontFamily.sans),
1930
+ fontSize: theme.fontSize.lg,
1931
+ fontWeight: "600",
1932
+ color: theme.colors.hi,
1933
+ uni__dependencies: [0]
1934
+ },
1935
+ body: {
1936
+ fontFamily: fontOf(theme.fontFamily.sans),
1937
+ fontSize: theme.fontSize.base,
1938
+ lineHeight: theme.lineHeightRelaxed.base,
1939
+ color: theme.colors.text,
1940
+ uni__dependencies: [0]
1941
+ },
1942
+ dim: {
1943
+ fontFamily: fontOf(theme.fontFamily.sans),
1944
+ fontSize: theme.fontSize.sm,
1945
+ lineHeight: theme.lineHeightRelaxed.sm,
1946
+ color: theme.colors.dim,
1947
+ uni__dependencies: [0]
1948
+ },
1949
+ mono: {
1950
+ fontFamily: fontOf(theme.fontFamily.mono),
1951
+ fontSize: theme.fontSize.sm,
1952
+ lineHeight: theme.lineHeightRelaxed.sm,
1953
+ uni__dependencies: [0]
1954
+ },
1955
+ branch: {
1956
+ fontFamily: fontOf(theme.fontFamily.mono),
1957
+ fontSize: theme.fontSize.lg,
1958
+ fontWeight: "600",
1959
+ color: theme.colors.hi,
1960
+ uni__dependencies: [0]
1961
+ },
1962
+ green: {
1963
+ fontSize: theme.fontSize.sm,
1964
+ color: theme.colors.green,
1965
+ uni__dependencies: [0]
1966
+ },
1967
+ red: {
1968
+ fontSize: theme.fontSize.sm,
1969
+ color: theme.colors.red,
1970
+ uni__dependencies: [0]
1971
+ },
1972
+ blue: {
1973
+ fontFamily: fontOf(theme.fontFamily.sans),
1974
+ fontSize: theme.fontSize.sm,
1975
+ color: theme.colors.blue,
1976
+ uni__dependencies: [0]
1977
+ },
1978
+ yellow: {
1979
+ fontSize: theme.fontSize.sm,
1980
+ color: theme.colors.yellow,
1981
+ uni__dependencies: [0]
1982
+ },
1983
+ content: {
1984
+ padding: theme.spacing(4),
1985
+ gap: theme.spacing(3),
1986
+ uni__dependencies: [0]
1987
+ },
1988
+ card: {
1989
+ borderWidth: 1,
1990
+ borderColor: theme.colors.border,
1991
+ borderRadius: theme.borderRadius.lg,
1992
+ padding: theme.spacing(3),
1993
+ gap: theme.spacing(2),
1994
+ uni__dependencies: [0]
1995
+ },
1996
+ inline: {
1997
+ flexDirection: "row",
1998
+ alignItems: "center",
1999
+ gap: theme.spacing(2),
2000
+ uni__dependencies: [0]
2001
+ },
2002
+ grow: {
2003
+ flex: 1,
2004
+ minWidth: 0
2005
+ },
2006
+ action: { minHeight: 44 },
2007
+ primary: {
2008
+ backgroundColor: theme.colors.green,
2009
+ uni__dependencies: [0]
2010
+ },
2011
+ primaryLabel: {
2012
+ fontFamily: fontOf(theme.fontFamily.sans),
2013
+ fontSize: theme.fontSize.base,
2014
+ fontWeight: "600",
2015
+ color: theme.scheme === "dark" ? theme.colors.rail : theme.colors["on-selected"],
2016
+ uni__dependencies: [0]
2017
+ },
2018
+ suggested: {
2019
+ backgroundColor: theme.colors["tint-green"],
2020
+ borderColor: theme.colors["edge-green"],
2021
+ flex: 1,
2022
+ uni__dependencies: [0]
2023
+ },
2024
+ list: {
2025
+ gap: theme.spacing(2),
2026
+ uni__dependencies: [0]
2027
+ },
2028
+ fileRow: {
2029
+ minHeight: 44,
2030
+ paddingVertical: theme.spacing(2),
2031
+ flexDirection: "row",
2032
+ alignItems: "center",
2033
+ gap: theme.spacing(2),
2034
+ borderBottomWidth: StyleSheet.hairlineWidth,
2035
+ borderColor: theme.colors.border,
2036
+ uni__dependencies: [0]
2037
+ },
2038
+ footer: {
2039
+ minHeight: 76,
2040
+ padding: theme.spacing(4),
2041
+ flexDirection: "row",
2042
+ alignItems: "center",
2043
+ justifyContent: "space-between",
2044
+ gap: theme.spacing(2),
2045
+ borderTopWidth: 1,
2046
+ borderColor: theme.colors.border,
2047
+ backgroundColor: theme.colors.rail,
2048
+ uni__dependencies: [0]
2049
+ },
2050
+ caution: {
2051
+ backgroundColor: theme.colors["tint-yellow"],
2052
+ borderColor: theme.colors["edge-yellow"],
2053
+ uni__dependencies: [0]
2054
+ },
2055
+ failure: {
2056
+ backgroundColor: theme.colors["tint-red"],
2057
+ borderColor: theme.colors["edge-red"],
2058
+ uni__dependencies: [0]
2059
+ },
2060
+ sheet: {
2061
+ padding: theme.spacing(4),
2062
+ gap: theme.spacing(3),
2063
+ borderTopWidth: 1,
2064
+ borderColor: theme.colors.border,
2065
+ borderTopLeftRadius: theme.borderRadius.lg,
2066
+ borderTopRightRadius: theme.borderRadius.lg,
2067
+ backgroundColor: theme.colors.rail,
2068
+ uni__dependencies: [0]
2069
+ },
2070
+ handle: {
2071
+ height: 4,
2072
+ width: 40,
2073
+ borderRadius: theme.borderRadius.md,
2074
+ backgroundColor: theme.colors.border,
2075
+ alignSelf: "center",
2076
+ uni__dependencies: [0]
2077
+ },
2078
+ navigation: {
2079
+ flexDirection: "row",
2080
+ justifyContent: "space-between",
2081
+ alignItems: "center"
2082
+ },
2083
+ diffRow: {
2084
+ flexDirection: "row",
2085
+ alignItems: "flex-start",
2086
+ gap: theme.spacing(2),
2087
+ paddingHorizontal: theme.spacing(2),
2088
+ paddingVertical: theme.spacing(1),
2089
+ borderLeftWidth: 3,
2090
+ borderLeftColor: theme.colors.bg,
2091
+ uni__dependencies: [0]
2092
+ },
2093
+ gutter: {
2094
+ color: theme.colors.dim,
2095
+ width: "auto",
2096
+ minWidth: 24,
2097
+ flexShrink: 0,
2098
+ textAlign: "right",
2099
+ uni__dependencies: [0]
2100
+ },
2101
+ disclosure: {
2102
+ padding: theme.spacing(3),
2103
+ gap: theme.spacing(2),
2104
+ borderTopWidth: 1,
2105
+ borderColor: theme.colors.border,
2106
+ backgroundColor: theme.colors.bg,
2107
+ uni__dependencies: [0]
2108
+ },
2109
+ code: {
2110
+ flex: 1,
2111
+ minWidth: 0,
2112
+ color: theme.colors.text,
2113
+ uni__dependencies: [0]
2114
+ },
2115
+ added: {
2116
+ backgroundColor: theme.colors["tint-green"],
2117
+ uni__dependencies: [0]
2118
+ },
2119
+ removed: {
2120
+ backgroundColor: theme.colors["tint-red"],
2121
+ uni__dependencies: [0]
2122
+ },
2123
+ selection: {
2124
+ borderLeftColor: theme.colors.green,
2125
+ uni__dependencies: [0]
2126
+ },
2127
+ inlineComment: {
2128
+ margin: theme.spacing(2),
2129
+ padding: theme.spacing(3),
2130
+ borderWidth: 1,
2131
+ borderColor: theme.colors["edge-blue"],
2132
+ borderRadius: theme.borderRadius.md,
2133
+ gap: theme.spacing(1),
2134
+ uni__dependencies: [0]
2135
+ },
2136
+ quote: {
2137
+ padding: theme.spacing(2),
2138
+ backgroundColor: theme.colors.panel,
2139
+ borderRadius: theme.borderRadius.md,
2140
+ uni__dependencies: [0]
2141
+ },
2142
+ remove: { alignSelf: "flex-end" }
2143
+ }));
2144
+ const DIFF_ROW_STEP = 200;
2145
+ function GitReviewView(props) {
2146
+ const t = useT();
2147
+ const { screen, activity, summary, file, path, comments } = props;
2148
+ const rows = useMemo(() => file?.hunks.flatMap((hunk) => hunk.rows) ?? [], [file?.hunks]);
2149
+ const gutterDigits = useMemo(() => rows.reduce((max, row) => Math.max(max, String(row.line).length), 1), [rows]);
2150
+ const fileComments = useMemo(() => comments.filter((comment) => comment.path === path), [comments, path]);
2151
+ const initialLimit = props.initialVisibleRows ?? DIFF_ROW_STEP;
2152
+ const [disclosure, setDisclosure] = useState({
2153
+ rows,
2154
+ path,
2155
+ limit: initialLimit
2156
+ });
2157
+ const current = disclosure.rows === rows && disclosure.path === path ? disclosure : {
2158
+ rows,
2159
+ path,
2160
+ limit: initialLimit
2161
+ };
2162
+ if (current !== disclosure) setDisclosure(current);
2163
+ const visibleRows = useMemo(() => rows.slice(0, current.limit), [rows, current.limit]);
2164
+ const index = summary?.files.findIndex((entry) => entry.path === path) ?? -1;
2165
+ const entry = summary?.files[index];
2166
+ return /* @__PURE__ */ jsxs(View, {
2167
+ style: styles$1.grow,
2168
+ children: [
2169
+ screen === "review" ? /* @__PURE__ */ jsxs(View, {
2170
+ style: styles$1.inline,
2171
+ children: [/* @__PURE__ */ jsx(Action, {
2172
+ variant: "ghost",
2173
+ onPress: () => props.onScreen("changes"),
2174
+ children: t("git.ui.changesLabel", "Changes")
2175
+ }), screen === "review" && path ? /* @__PURE__ */ jsx(Action, {
2176
+ variant: "ghost",
2177
+ onPress: () => props.onScreen("file"),
2178
+ children: t("git.ui.fileDiff", "File diff")
2179
+ }) : null]
890
2180
  }) : null,
891
- /* @__PURE__ */ jsx(Sheet, {
892
- open: draft !== void 0,
893
- onOpenChange: (open) => {
894
- if (!open) setDraft(void 0);
895
- },
896
- children: /* @__PURE__ */ jsxs(SheetContent, { children: [/* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: "Review comment" }) }), /* @__PURE__ */ jsx(SheetBody, { children: /* @__PURE__ */ jsxs(View, {
897
- style: styles.body,
2181
+ /* @__PURE__ */ jsxs(ScrollView, {
2182
+ style: styles$1.grow,
2183
+ children: [screen === "changes" ? /* @__PURE__ */ jsxs(View, {
2184
+ style: styles$1.content,
898
2185
  children: [
899
- draft?.rows.length ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Input, {
900
- accessibilityLabel: "Start line",
901
- value: start,
902
- onChangeText: setStart,
903
- keyboardType: "number-pad"
904
- }), /* @__PURE__ */ jsx(Input, {
905
- accessibilityLabel: "End line",
906
- value: end,
907
- onChangeText: setEnd,
908
- keyboardType: "number-pad"
909
- })] }) : null,
910
- /* @__PURE__ */ jsx(Textarea, {
911
- accessibilityLabel: "Comment",
912
- value: comment,
913
- onChangeText: setComment
2186
+ summary?.repository !== false ? /* @__PURE__ */ jsx(SyncCard, {
2187
+ changes: activity.changes,
2188
+ busy: activity.pending !== void 0,
2189
+ onSync: props.onSync
2190
+ }) : null,
2191
+ activity.pending ? /* @__PURE__ */ jsx(Text, {
2192
+ style: styles$1.dim,
2193
+ children: activity.pending
2194
+ }) : null,
2195
+ activity.error ? /* @__PURE__ */ jsxs(View, {
2196
+ style: [styles$1.card, props.forceRequired ? styles$1.caution : styles$1.failure],
2197
+ children: [
2198
+ /* @__PURE__ */ jsx(Text, {
2199
+ style: styles$1.body,
2200
+ children: activity.error
2201
+ }),
2202
+ props.forceRequired ? /* @__PURE__ */ jsx(Action, {
2203
+ variant: "danger-outline",
2204
+ onPress: props.onForce,
2205
+ children: t("git.ui.forcePushWithLease", "Force push with lease")
2206
+ }) : null,
2207
+ /* @__PURE__ */ jsx(Action, {
2208
+ variant: "ghost",
2209
+ onPress: props.onDismiss,
2210
+ children: t("git.ui.dismiss", "Dismiss")
2211
+ })
2212
+ ]
2213
+ }) : null,
2214
+ activity.changes?.rebase ? /* @__PURE__ */ jsx(RebaseCard, {
2215
+ conflicts: activity.changes.rebase.conflicts,
2216
+ busy: activity.pending !== void 0,
2217
+ onResolve: props.onResolve,
2218
+ onAbort: props.onAbort
2219
+ }) : null,
2220
+ !summary ? /* @__PURE__ */ jsx(Text, {
2221
+ style: styles$1.dim,
2222
+ children: t("git.ui.loadingChangesProgress", "Loading changes…")
2223
+ }) : summary.files.length ? /* @__PURE__ */ jsx(FileList, {
2224
+ files: summary.files,
2225
+ comments,
2226
+ onFile: props.onFile
2227
+ }) : summary.repository ? /* @__PURE__ */ jsx(EmptyState, {
2228
+ testID: "git-review-empty",
2229
+ icon: /* @__PURE__ */ jsx(BranchIcon, { size: 20 }),
2230
+ title: t("git.ui.noChangesYet", "No changes yet"),
2231
+ description: summary.base === void 0 ? t("git.ui.nothingUncommittedInThisCheckout", "Nothing uncommitted in this checkout.") : t("git.review.nothingDiffers", "Nothing differs from {base}, committed or not.", { base: summary.base })
2232
+ }) : /* @__PURE__ */ jsx(EmptyState, {
2233
+ testID: "git-review-no-repository",
2234
+ icon: /* @__PURE__ */ jsx(BranchIcon, { size: 20 }),
2235
+ title: t("git.ui.notAGitCheckout", "Not a Git checkout"),
2236
+ description: t("git.ui.thisSessionSFolderIsNotInsideAGitRepository", "This session's folder is not inside a Git repository.")
914
2237
  }),
915
- /* @__PURE__ */ jsx(Button, {
916
- disabled: comment.trim() === "" || Boolean(draft?.rows.length) && (!Number.isInteger(Number(start)) || Number(start) < 1 || !Number.isInteger(Number(end)) || Number(end) < Number(start)),
917
- onPress: () => {
918
- if (!draft) return;
919
- const rows = draft.rows.filter((row) => row.line >= Number(start) && row.line <= Number(end));
920
- const kept = rows.filter((row) => row.marker !== "-");
921
- const numbered = kept.length > 0 ? kept : rows;
922
- addReviewComment(sessionId, {
923
- path: draft.path,
924
- relPath: draft.path,
925
- body: comment.trim(),
926
- snippet: numbered.map((row) => row.content).join("\n"),
927
- ...numbered.length === 0 ? {} : {
928
- side: kept.length > 0 ? "new" : "old",
929
- startLine: Math.min(...numbered.map((row) => row.line)),
930
- endLine: Math.max(...numbered.map((row) => row.line))
931
- }
932
- });
933
- setDraft(void 0);
934
- setComment("");
935
- },
936
- children: "Add comment"
937
- })
2238
+ summary?.truncated ? /* @__PURE__ */ jsx(Text, {
2239
+ style: styles$1.dim,
2240
+ children: t("git.ui.theFileListWasTruncated", "The file list was truncated.")
2241
+ }) : null
938
2242
  ]
939
- }) })] })
2243
+ }) : screen === "file" ? /* @__PURE__ */ jsxs(Fragment, { children: [
2244
+ entry ? /* @__PURE__ */ jsx(FileHeader, {
2245
+ entry,
2246
+ index,
2247
+ total: summary?.files.length ?? 0,
2248
+ onChanges: () => props.onScreen("changes"),
2249
+ onPrevious: () => {
2250
+ const previous = summary?.files[index - 1];
2251
+ if (previous) props.onFile(previous.path);
2252
+ },
2253
+ onNext: () => {
2254
+ const next = summary?.files[index + 1];
2255
+ if (next) props.onFile(next.path);
2256
+ }
2257
+ }) : /* @__PURE__ */ jsx(Text, {
2258
+ style: styles$1.heading,
2259
+ children: path
2260
+ }),
2261
+ !file ? /* @__PURE__ */ jsxs(View, {
2262
+ style: styles$1.content,
2263
+ children: [/* @__PURE__ */ jsx(Text, {
2264
+ style: styles$1.dim,
2265
+ children: props.error ? t("git.ui.theDiffCouldNotBeLoadedPleaseTryAgain", "The diff could not be loaded. Please try again.") : t("git.ui.loadingDiffProgress", "Loading diff…")
2266
+ }), props.error && path ? /* @__PURE__ */ jsx(Action, {
2267
+ onPress: () => props.onFile(path),
2268
+ children: t("git.ui.retry", "Retry")
2269
+ }) : null]
2270
+ }) : file.binary || file.tooLarge ? /* @__PURE__ */ jsx(View, {
2271
+ style: styles$1.content,
2272
+ children: /* @__PURE__ */ jsx(Text, {
2273
+ style: styles$1.section,
2274
+ children: file.binary ? t("git.ui.binaryFile", "Binary file") : t("git.ui.diffTooLargeToDisplay", "Diff too large to display")
2275
+ })
2276
+ }) : /* @__PURE__ */ jsx(DiffRows, {
2277
+ rows: visibleRows,
2278
+ comments: fileComments,
2279
+ selection: props.selection,
2280
+ onLine: props.onLine,
2281
+ gutterDigits
2282
+ }),
2283
+ fileComments.filter((comment) => comment.startLine === void 0).map((comment) => /* @__PURE__ */ jsxs(View, {
2284
+ style: styles$1.inlineComment,
2285
+ children: [/* @__PURE__ */ jsx(Text, {
2286
+ style: styles$1.blue,
2287
+ children: t("git.ui.queuedFileComment", "Queued file comment")
2288
+ }), /* @__PURE__ */ jsx(Text, {
2289
+ style: styles$1.body,
2290
+ children: comment.body
2291
+ })]
2292
+ }, comment.id)),
2293
+ /* @__PURE__ */ jsx(View, {
2294
+ style: styles$1.content,
2295
+ children: /* @__PURE__ */ jsx(Action, {
2296
+ onPress: props.onComment,
2297
+ children: t("git.ui.commentOnFile", "Comment on file")
2298
+ })
2299
+ })
2300
+ ] }) : /* @__PURE__ */ jsx(CommentCards, {
2301
+ comments,
2302
+ onRemove: props.onRemove
2303
+ }), props.error ? /* @__PURE__ */ jsx(Text, {
2304
+ style: [styles$1.red, styles$1.content],
2305
+ children: props.error
2306
+ }) : null]
2307
+ }, `${screen}:${path ?? ""}`),
2308
+ /* @__PURE__ */ jsx(Footer, {
2309
+ count: comments.length,
2310
+ confirmation: screen === "changes" && activity.changes?.rebase !== void 0,
2311
+ discard: screen === "review",
2312
+ onReview: () => props.onScreen("review"),
2313
+ onSend: props.onSend,
2314
+ onDiscard: props.onDiscard
940
2315
  }),
941
- /* @__PURE__ */ jsx(Sheet, {
942
- open: confirm !== void 0,
943
- onOpenChange: (open) => {
944
- if (!open) setConfirm(void 0);
2316
+ screen === "file" && file && !file.binary && !file.tooLarge ? /* @__PURE__ */ jsxs(View, {
2317
+ style: styles$1.disclosure,
2318
+ children: [/* @__PURE__ */ jsxs(Text, {
2319
+ style: styles$1.dim,
2320
+ accessibilityLiveRegion: "polite",
2321
+ children: [t("git.review.rowsShown", "{shown} of {total} diff rows shown", {
2322
+ shown: Math.min(current.limit, rows.length),
2323
+ total: rows.length
2324
+ }), props.selection ? t("git.review.selectedLine", " · {side} line {line} selected", {
2325
+ side: props.selection.side === "old" ? t("git.review.oldSide", "old") : t("git.review.newSide", "new"),
2326
+ line: props.selection.startLine
2327
+ }) : ""]
2328
+ }), current.limit < rows.length ? /* @__PURE__ */ jsx(Button, {
2329
+ variant: "outline",
2330
+ onPress: () => setDisclosure({
2331
+ ...current,
2332
+ limit: Math.min(rows.length, current.limit + DIFF_ROW_STEP)
2333
+ }),
2334
+ children: t("git.review.showMoreRows", "Show {count} more rows", { count: Math.min(DIFF_ROW_STEP, rows.length - current.limit) })
2335
+ }) : /* @__PURE__ */ jsx(Text, {
2336
+ style: styles$1.dim,
2337
+ children: t("git.ui.allDiffRowsShown", "All diff rows shown")
2338
+ })]
2339
+ }) : null
2340
+ ]
2341
+ });
2342
+ }
2343
+ //#endregion
2344
+ //#region src/extensions/workspaces/sessions/(frontend)/_components/GitReviewPanel.native.tsx
2345
+ function useGitChanges(sessionId) {
2346
+ const subscribe = useCallback((listener) => {
2347
+ const sub = gitChanges.store.subscribe(listener);
2348
+ return () => sub.unsubscribe();
2349
+ }, []);
2350
+ return useSyncExternalStore(subscribe, () => gitChanges.select(gitChanges.store.state, sessionId));
2351
+ }
2352
+ function reviewTab() {
2353
+ return {
2354
+ id: "git-review",
2355
+ label: t("git.tab.review", "review"),
2356
+ panel: GitReviewPanel
2357
+ };
2358
+ }
2359
+ function GitReviewPanel(props) {
2360
+ return /* @__PURE__ */ jsx(GitReviewPanelSession, { ...props }, props.sessionId);
2361
+ }
2362
+ function GitReviewPanelSession({ sessionId, sendSessionFrame }) {
2363
+ const t = useT();
2364
+ const activity = useGitChanges(sessionId);
2365
+ const subscribe = useCallback((listener) => {
2366
+ const sub = gitReview.store.subscribe(listener);
2367
+ return () => sub.unsubscribe();
2368
+ }, []);
2369
+ const comments = useSyncExternalStore(subscribe, () => gitReview.select(gitReview.store.state, sessionId).comments);
2370
+ const [summary, setSummary] = useState();
2371
+ const [file, setFile] = useState();
2372
+ const [error, setError] = useState();
2373
+ const [dismissedError, setDismissedError] = useState();
2374
+ const [confirm, setConfirm] = useState();
2375
+ const [screen, setScreen] = useState("changes");
2376
+ const [path, setPath] = useState();
2377
+ const [selection, setSelection] = useState();
2378
+ const [draft, setDraft] = useState();
2379
+ const request = useRef(void 0);
2380
+ const fingerprint = JSON.stringify(activity.changes);
2381
+ useEffect(() => {
2382
+ if (sessionId === null) return void 0;
2383
+ const controller = new AbortController();
2384
+ fetchReviewSummary(sessionId, controller.signal).then((result) => {
2385
+ if (!controller.signal.aborted) {
2386
+ if (result.ok) setSummary(result.summary);
2387
+ else setError(result.error);
2388
+ }
2389
+ }).catch((cause) => {
2390
+ if (!controller.signal.aborted) setError(cause instanceof Error ? cause.message : String(cause));
2391
+ });
2392
+ return () => {
2393
+ controller.abort();
2394
+ request.current?.abort();
2395
+ };
2396
+ }, [sessionId, fingerprint]);
2397
+ const loadFile = async (path) => {
2398
+ if (sessionId === null) return;
2399
+ setScreen("file");
2400
+ setPath(path);
2401
+ setSelection(void 0);
2402
+ setDraft(void 0);
2403
+ request.current?.abort();
2404
+ const controller = new AbortController();
2405
+ request.current = controller;
2406
+ setFile(void 0);
2407
+ setError(void 0);
2408
+ try {
2409
+ const result = await fetchReviewFile(sessionId, path, controller.signal);
2410
+ if (!controller.signal.aborted) {
2411
+ if (result.ok) setFile(result.diff);
2412
+ else setError(result.error);
2413
+ }
2414
+ } catch (cause) {
2415
+ if (!controller.signal.aborted) setError(cause instanceof Error ? cause.message : String(cause));
2416
+ }
2417
+ };
2418
+ if (sessionId === null) return null;
2419
+ const changes = activity.changes;
2420
+ const send = (message, onSent) => {
2421
+ const failure = deliverToAgent(t, sendSessionFrame, sessionId, message);
2422
+ setError(failure);
2423
+ if (failure === void 0) onSent?.();
2424
+ };
2425
+ const sync = (action) => requestGitSync(sessionId, action);
2426
+ const forceRequired = activity.error !== dismissedError && activity.errorTarget?.action === "push" && activity.errorTarget.forceRequired === true;
2427
+ const sendReview = () => {
2428
+ if (comments.length === 0) return;
2429
+ const body = comments.map((item) => {
2430
+ return `### ${item.startLine === void 0 ? item.relPath : item.side === "old" ? `${item.relPath} (removed lines ${item.startLine}-${item.endLine ?? item.startLine})` : `${item.relPath}:${item.startLine}-${item.endLine ?? item.startLine}`}\n\n${item.snippet.split("\n").slice(0, 20).join("\n").slice(0, 2e3).split("\n").map((line) => `> ${line}`).join("\n")}\n\n${item.body.trim()}`;
2431
+ }).join("\n\n");
2432
+ send(`${reviewHeading(comments.length, summary?.branch, summary?.base)}\n\n${body}`, () => clearReviewComments(sessionId));
2433
+ };
2434
+ const selectLine = (row) => {
2435
+ if (!file) return;
2436
+ const next = selectReviewLine(selection, row);
2437
+ setSelection(next.range);
2438
+ if (next.complete) {
2439
+ const rows = reviewRangeRows(file.hunks.flatMap((hunk) => hunk.rows), next.range);
2440
+ setDraft({
2441
+ path: file.path,
2442
+ range: next.range,
2443
+ snippet: rows.map((item) => item.content).join("\n")
2444
+ });
2445
+ }
2446
+ };
2447
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2448
+ /* @__PURE__ */ jsx(GitReviewView, {
2449
+ screen,
2450
+ activity: {
2451
+ ...activity,
2452
+ error: activity.error === dismissedError ? void 0 : activity.error
2453
+ },
2454
+ summary,
2455
+ file,
2456
+ path,
2457
+ comments,
2458
+ error,
2459
+ forceRequired,
2460
+ selection,
2461
+ onScreen: setScreen,
2462
+ onFile: (path) => void loadFile(path),
2463
+ onLine: selectLine,
2464
+ onSync: sync,
2465
+ onForce: () => setConfirm("force"),
2466
+ onAbort: () => setConfirm("abort"),
2467
+ onResolve: () => send(conflictPrompt(changes?.branch, changes?.rebase?.conflicts ?? [])),
2468
+ onDismiss: () => setDismissedError(activity.error),
2469
+ onComment: () => {
2470
+ if (path) {
2471
+ setSelection(void 0);
2472
+ setDraft({
2473
+ path,
2474
+ snippet: ""
2475
+ });
2476
+ }
2477
+ },
2478
+ onRemove: (id) => removeReviewComment(sessionId, id),
2479
+ onSend: sendReview,
2480
+ onDiscard: () => setConfirm("discard")
2481
+ }),
2482
+ /* @__PURE__ */ jsx(Sheet, {
2483
+ open: draft !== void 0,
2484
+ onOpenChange: (open) => {
2485
+ if (!open) {
2486
+ setDraft(void 0);
2487
+ setSelection(void 0);
2488
+ }
2489
+ },
2490
+ children: /* @__PURE__ */ jsx(SheetContent, { children: /* @__PURE__ */ jsx(SheetBody, { children: /* @__PURE__ */ jsx(CommentEditor, {
2491
+ range: draft?.range,
2492
+ snippet: draft?.snippet ?? "",
2493
+ onCancel: () => {
2494
+ setDraft(void 0);
2495
+ setSelection(void 0);
945
2496
  },
946
- children: /* @__PURE__ */ jsxs(SheetContent, { children: [/* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: confirm === "force" ? "Force push with lease?" : confirm === "abort" ? "Abort rebase?" : "Discard review?" }) }), /* @__PURE__ */ jsxs(SheetBody, { children: [/* @__PURE__ */ jsx(Text, {
947
- style: styles.meta,
948
- children: confirm === "force" ? "Git refuses this if the remote holds commits you never fetched and integrated." : confirm === "abort" ? "Abort discards any conflict resolution in progress." : "Your queued comments will be removed."
949
- }), /* @__PURE__ */ jsx(Button, {
950
- variant: "danger-outline",
2497
+ onAdd: (comment) => {
2498
+ if (!draft || !comment.trim()) return;
2499
+ addReviewComment(sessionId, {
2500
+ path: draft.path,
2501
+ relPath: draft.path,
2502
+ body: comment.trim(),
2503
+ snippet: draft.snippet,
2504
+ ...draft.range
2505
+ });
2506
+ setDraft(void 0);
2507
+ setSelection(void 0);
2508
+ }
2509
+ }, draft ? "open" : "closed") }) })
2510
+ }),
2511
+ /* @__PURE__ */ jsx(Sheet, {
2512
+ open: confirm !== void 0,
2513
+ onOpenChange: (open) => {
2514
+ if (!open) setConfirm(void 0);
2515
+ },
2516
+ children: /* @__PURE__ */ jsxs(SheetContent, { children: [/* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: confirm === "force" ? t("git.ui.forcePushWithLeaseConfirm", "Force push with lease?") : confirm === "abort" ? t("git.ui.abortRebaseConfirm", "Abort rebase?") : t("git.ui.discardReviewConfirm", "Discard review?") }) }), /* @__PURE__ */ jsxs(SheetBody, { children: [
2517
+ /* @__PURE__ */ jsx(Text, {
2518
+ style: styles$1.dim,
2519
+ children: confirm === "force" ? t("git.ui.gitRefusesThisIfTheRemoteHoldsCommitsYouNeverFetchedAndIntegrated", "Git refuses this if the remote holds commits you never fetched and integrated.") : confirm === "abort" ? t("git.ui.abortDiscardsAnyConflictResolutionInProgress", "Abort discards any conflict resolution in progress.") : t("git.ui.yourQueuedCommentsWillBeRemoved", "Your queued comments will be removed.")
2520
+ }),
2521
+ /* @__PURE__ */ jsx(Button, {
2522
+ variant: "danger",
2523
+ disabled: confirm !== "discard" && activity.pending !== void 0,
951
2524
  onPress: () => {
952
2525
  if (confirm === "force") requestGitSync(sessionId, "push", true);
953
2526
  else if (confirm === "abort") sync("abort-rebase");
954
2527
  else clearReviewComments(sessionId);
955
2528
  setConfirm(void 0);
956
2529
  },
957
- children: "Confirm"
958
- })] })] })
959
- })
2530
+ children: confirm === "force" ? t("git.ui.forcePushWithLease", "Force push with lease") : confirm === "abort" ? t("git.ui.abortRebase", "Abort rebase") : t("git.ui.discard", "Discard")
2531
+ }),
2532
+ /* @__PURE__ */ jsx(Button, {
2533
+ variant: "ghost",
2534
+ onPress: () => setConfirm(void 0),
2535
+ children: t("git.ui.cancel", "Cancel")
2536
+ })
2537
+ ] })] })
2538
+ })
2539
+ ] });
2540
+ }
2541
+ function CommentEditor({ onAdd, ...props }) {
2542
+ const [body, setBody] = useState("");
2543
+ return /* @__PURE__ */ jsx(CommentSheet, {
2544
+ ...props,
2545
+ value: body,
2546
+ onChange: setBody,
2547
+ onAdd: () => onAdd(body)
2548
+ });
2549
+ }
2550
+ //#endregion
2551
+ //#region src/extensions/workspaces/sessions/(frontend)/fill/_components/WorktreesActivitySection.native.tsx
2552
+ function GitChangesRow({ state = "changes", branch = t("git.ui.detachedHEAD", "Detached HEAD"), added = 0, removed = 0, onReview }) {
2553
+ const t$1 = useT();
2554
+ return /* @__PURE__ */ jsxs(Pressable, {
2555
+ testID: "activity-diff-changes",
2556
+ accessibilityRole: "button",
2557
+ accessibilityLabel: t$1("git.ui.openChangesReview", "Open changes review"),
2558
+ onPress: onReview,
2559
+ style: styles.changeRow,
2560
+ children: [/* @__PURE__ */ jsxs(View, {
2561
+ style: styles.line,
2562
+ children: [
2563
+ /* @__PURE__ */ jsx(FileIcon, {
2564
+ size: 18,
2565
+ color: "dim"
2566
+ }),
2567
+ /* @__PURE__ */ jsx(Text, {
2568
+ style: [styles.heading, styles.grow],
2569
+ children: t$1("git.ui.changesLabel", "Changes")
2570
+ }),
2571
+ /* @__PURE__ */ jsx(ChevronRightIcon, {
2572
+ size: 16,
2573
+ color: "dim"
2574
+ })
2575
+ ]
2576
+ }), /* @__PURE__ */ jsxs(View, {
2577
+ style: styles.changeDetail,
2578
+ children: [/* @__PURE__ */ jsx(Text, {
2579
+ style: [styles.branch, styles.grow],
2580
+ children: branch
2581
+ }), state === "changes" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Text, {
2582
+ style: styles.jade,
2583
+ children: ["+", added]
2584
+ }), /* @__PURE__ */ jsxs(Text, {
2585
+ style: styles.error,
2586
+ children: ["-", removed]
2587
+ })] }) : state === "pushing" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Spinner, { label: t$1("git.ui.pushingPending", "Pushing...") }), /* @__PURE__ */ jsx(Text, {
2588
+ style: styles.dim,
2589
+ children: t$1("git.ui.pushingPending", "Pushing...")
2590
+ })] }) : /* @__PURE__ */ jsx(Text, {
2591
+ style: styles.dim,
2592
+ children: t$1("git.ui.noChangesYet", "No changes yet")
2593
+ })]
2594
+ })]
2595
+ });
2596
+ }
2597
+ function WorktreesActivityView({ git, state, disabled = false, onReview, onWorktrees }) {
2598
+ const t = useT();
2599
+ const { starting } = worktreesPresentation(state);
2600
+ return /* @__PURE__ */ jsxs(View, {
2601
+ style: styles.section,
2602
+ children: [
2603
+ git.changes ? /* @__PURE__ */ jsx(GitChangesRow, {
2604
+ branch: git.changes.branch ?? t("git.ui.detachedHEAD", "Detached HEAD"),
2605
+ added: git.changes.added,
2606
+ removed: git.changes.removed,
2607
+ state: git.pending?.startsWith("pushing") ? "pushing" : git.changes.added === 0 && git.changes.removed === 0 && git.changes.files === 0 ? "clean" : "changes",
2608
+ onReview
2609
+ }) : null,
2610
+ /* @__PURE__ */ jsx(WorktreeGroup, {
2611
+ title: t("git.ui.worktrees", "Worktrees"),
2612
+ count: t("git.worktree.openStarting", "{count} open{starting}", {
2613
+ count: state.worktrees.length,
2614
+ starting: starting ? t("git.worktree.oneStarting", " · 1 starting") : ""
2615
+ })
2616
+ }),
2617
+ state.worktrees.map((item) => /* @__PURE__ */ jsx(WorktreeRow, {
2618
+ item,
2619
+ compact: true,
2620
+ onOpen: onWorktrees
2621
+ }, item.id)),
2622
+ starting ? /* @__PURE__ */ jsx(WorktreeStarting, { branch: state.requestedBranch }) : state.pending ? /* @__PURE__ */ jsx(Text, {
2623
+ style: styles.dim,
2624
+ children: state.pending
2625
+ }) : null,
2626
+ state.worktrees.length === 0 && !state.pending ? /* @__PURE__ */ jsxs(View, {
2627
+ style: styles.idle,
2628
+ children: [/* @__PURE__ */ jsx(Text, {
2629
+ style: styles.dim,
2630
+ children: t("git.ui.idle", "Idle")
2631
+ }), /* @__PURE__ */ jsx(Button, {
2632
+ testID: "activity-git-create",
2633
+ variant: "ghost",
2634
+ style: styles.link,
2635
+ disabled,
2636
+ onPress: onWorktrees,
2637
+ children: /* @__PURE__ */ jsx(Text, {
2638
+ style: styles.jade,
2639
+ children: t("git.ui.createAWorktree", "Create a worktree →")
2640
+ })
2641
+ })]
2642
+ }) : null
960
2643
  ]
961
2644
  });
962
2645
  }
2646
+ function WorktreesActivitySection({ sessionId, openTransientTab }) {
2647
+ const git = useGitChanges(sessionId);
2648
+ const state = useWorktrees(sessionId);
2649
+ return /* @__PURE__ */ jsx(WorktreesActivityView, {
2650
+ git,
2651
+ state: {
2652
+ ...state,
2653
+ worktrees: state.worktrees.filter((item) => item.sessionId !== sessionId)
2654
+ },
2655
+ disabled: sessionId === null,
2656
+ onReview: () => openTransientTab(reviewTab()),
2657
+ onWorktrees: () => openTransientTab(worktreesTab())
2658
+ });
2659
+ }
963
2660
  const styles = StyleSheet.create((theme) => ({
964
- body: {
965
- padding: theme.spacing(3),
2661
+ section: {
966
2662
  gap: theme.spacing(2),
967
2663
  uni__dependencies: [0]
968
2664
  },
969
- actions: {
2665
+ heading: {
2666
+ fontFamily: fontOf(theme.fontFamily.sans),
2667
+ fontSize: theme.fontSize.lg,
2668
+ lineHeight: theme.lineHeight.lg,
2669
+ fontWeight: "600",
2670
+ color: theme.colors.hi,
2671
+ uni__dependencies: [0]
2672
+ },
2673
+ dim: {
2674
+ fontFamily: fontOf(theme.fontFamily.sans),
2675
+ fontSize: theme.fontSize.sm,
2676
+ lineHeight: theme.lineHeight.sm,
2677
+ color: theme.colors.dim,
2678
+ uni__dependencies: [0]
2679
+ },
2680
+ branch: {
2681
+ fontFamily: fontOf(theme.fontFamily.mono),
2682
+ fontSize: theme.fontSize.base,
2683
+ lineHeight: theme.lineHeight.lg,
2684
+ color: theme.colors.hi,
2685
+ uni__dependencies: [0]
2686
+ },
2687
+ line: {
970
2688
  flexDirection: "row",
971
- flexWrap: "wrap",
2689
+ alignItems: "center",
2690
+ gap: theme.spacing(2),
2691
+ minHeight: 44,
2692
+ uni__dependencies: [0]
2693
+ },
2694
+ grow: {
2695
+ flex: 1,
2696
+ minWidth: 0,
972
2697
  gap: theme.spacing(1),
973
2698
  uni__dependencies: [0]
974
2699
  },
975
- title: {
976
- color: theme.colors.hi,
2700
+ jade: {
2701
+ fontFamily: fontOf(theme.fontFamily.sans),
977
2702
  fontSize: theme.fontSize.base,
978
- fontWeight: "600",
2703
+ lineHeight: theme.lineHeight.base,
2704
+ color: theme.colors.green,
2705
+ fontWeight: "500",
979
2706
  uni__dependencies: [0]
980
2707
  },
981
- meta: {
982
- color: theme.colors.dim,
2708
+ error: {
2709
+ fontFamily: fontOf(theme.fontFamily.sans),
983
2710
  fontSize: theme.fontSize.sm,
2711
+ lineHeight: theme.lineHeight.sm,
2712
+ color: theme.colors.red,
984
2713
  uni__dependencies: [0]
985
2714
  },
986
- error: {
987
- color: theme.colors.red,
988
- fontSize: theme.fontSize.sm,
2715
+ changeRow: {
2716
+ gap: theme.spacing(1),
2717
+ paddingVertical: theme.spacing(2),
2718
+ borderBottomWidth: StyleSheet.hairlineWidth,
2719
+ borderColor: theme.colors["border-soft"],
989
2720
  uni__dependencies: [0]
990
2721
  },
991
- diff: (marker) => ({
992
- fontFamily: fontOf(theme.fontFamily.mono),
993
- fontSize: theme.fontSize.sm,
994
- color: marker === "+" ? theme.colors.green : marker === "-" ? theme.colors.red : theme.colors.text,
995
- paddingVertical: theme.spacing(1),
2722
+ changeDetail: {
2723
+ flexDirection: "row",
2724
+ alignItems: "center",
2725
+ gap: theme.spacing(3),
2726
+ paddingLeft: theme.spacing(6),
2727
+ minHeight: 28,
996
2728
  uni__dependencies: [0]
997
- })
2729
+ },
2730
+ idle: {
2731
+ flexDirection: "row",
2732
+ alignItems: "center",
2733
+ gap: theme.spacing(4),
2734
+ uni__dependencies: [0]
2735
+ },
2736
+ link: {
2737
+ minHeight: 44,
2738
+ paddingHorizontal: 0
2739
+ }
998
2740
  }));
999
2741
  //#endregion
1000
- //#region src/extensions/workspaces/sessions/(frontend)/fill/_components/WorktreesActivitySection.native.tsx
1001
- function WorktreesActivitySection({ sessionId, openTransientTab }) {
1002
- const git = useGitChanges(sessionId);
1003
- const state = useWorktrees(sessionId);
1004
- const worktrees = state.worktrees.filter((item) => item.sessionId !== sessionId);
1005
- return /* @__PURE__ */ jsxs(View, { children: [
1006
- git.changes ? /* @__PURE__ */ jsxs(Button, {
1007
- variant: "ghost",
1008
- testID: "activity-diff-changes",
1009
- onPress: () => openTransientTab(reviewTab()),
1010
- children: [
1011
- git.changes.branch ?? "Detached HEAD",
1012
- " · +",
1013
- git.changes.added,
1014
- " -",
1015
- git.changes.removed
1016
- ]
1017
- }) : null,
1018
- state.pending ? /* @__PURE__ */ jsx(ListRow, { title: state.pending }) : null,
1019
- worktrees.map((item) => /* @__PURE__ */ jsx(ListRow, {
1020
- leading: /* @__PURE__ */ jsx(Dot, { tone: item.orphaned ? "red" : item.sessionId === null ? "muted" : "blue" }),
1021
- title: /* @__PURE__ */ jsx(Button, {
1022
- variant: "ghost",
1023
- onPress: () => openTransientTab(worktreesTab()),
1024
- children: item.branch
1025
- }),
1026
- description: [item.orphaned ? "Orphaned" : "", item.unowned ? "Unowned" : ""].filter(Boolean).join(" · ")
1027
- }, item.id)),
1028
- worktrees.length === 0 && state.pending === void 0 ? /* @__PURE__ */ jsx(Button, {
1029
- variant: "ghost",
1030
- testID: "activity-git-create",
1031
- disabled: sessionId === null,
1032
- onPress: () => openTransientTab(worktreesTab()),
1033
- children: "Create a worktree"
1034
- }) : null
1035
- ] });
1036
- }
1037
- //#endregion
1038
2742
  //#region src/extensions/workspaces/sessions/(frontend)/fill/Worktrees.activity.git.native.tsx
1039
2743
  var Worktrees_activity_git_native_default = defineFill({ component: WorktreesActivitySection });
1040
2744
  //#endregion
@@ -1055,6 +2759,13 @@ const via = (identity, value) => value === void 0 ? void 0 : {
1055
2759
  };
1056
2760
  const nativePlugin = defineNativePlugin({
1057
2761
  id: "git",
2762
+ packageName: "@agimon-ai/po-git",
2763
+ workspace: { get fills() {
2764
+ return [via({
2765
+ slot: "new-session",
2766
+ id: "git-new-session"
2767
+ }, GitNewSession_new_session_native_default)];
2768
+ } },
1058
2769
  session: {
1059
2770
  get activityGroups() {
1060
2771
  return [via({ name: "git" }, git_native_default)];