@agimon-ai/po-git 0.0.0-alpha.17 → 0.0.0-alpha.170

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