@eliya-oss/agent-diff 0.1.0-alpha.3 → 0.1.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Wheel bursts move the diff once a frame, the worktree list shows which branches carry a reading order, and a story the branch has moved past says so.
8
+
9
+ - Scrolling with a trackpad settles as soon as your fingers stop.
10
+
11
+ ## 0.1.0-alpha.4
12
+
13
+ ### Patch Changes
14
+
15
+ - Open the lines a diff leaves out one gap at a time with l, and put them away with h.
16
+
3
17
  ## 0.1.0-alpha.3
4
18
 
5
19
  ### Patch Changes
package/README.md CHANGED
@@ -34,6 +34,10 @@ sends the whole set as one wake-up, so the agent reads a review rather than a st
34
34
  a comment, `ctrl+s` sends it and `ctrl+a` adds it to the review instead. `m` marks a file reviewed,
35
35
  `ctrl+p` finds any command by name, and the footer lists the keys for wherever you are.
36
36
 
37
+ Where the diff leaves lines out, a row says how many. Put the cursor on it and `l` brings ten of
38
+ them back where you are standing, `h` puts them away again, and the rest of the file stays as small
39
+ as it was. Opened lines are ordinary lines: you can select them and comment on them.
40
+
37
41
  ## The agent side
38
42
 
39
43
  In the worktree being reviewed:
package/dist/main.js CHANGED
@@ -10524,6 +10524,7 @@ const openHunk = (draft, line) => {
10524
10524
  marker: line,
10525
10525
  scope: (header?.[3] ?? "").trim(),
10526
10526
  startRow: draft.rows.length,
10527
+ newStart: draft.newLine,
10527
10528
  rows: [],
10528
10529
  skipped: draft.hunks.length === 0 ? 0 : Math.max(0, draft.newLine - previousNew)
10529
10530
  });
@@ -10951,6 +10952,7 @@ var NoStory = class extends TaggedError("NoStory") {};
10951
10952
  //#endregion
10952
10953
  //#region src/cli/commands.ts
10953
10954
  const CONTEXT = 3;
10955
+ const WHOLE_FILE$1 = 1e5;
10954
10956
  const POLL = "500 millis";
10955
10957
  const findBranch = fn("Cli.findBranch")(function* (repo, branch) {
10956
10958
  const worktrees = yield* (yield* Git).worktrees(repo);
@@ -10961,8 +10963,8 @@ const findBranch = fn("Cli.findBranch")(function* (repo, branch) {
10961
10963
  known: worktrees.map((w) => w.branch)
10962
10964
  }) : succeed(found);
10963
10965
  });
10964
- const patchesOf = fn("Cli.patchesOf")(function* (worktree) {
10965
- const raw = yield* (yield* Git).diff(worktree, CONTEXT);
10966
+ const patchesOf = fn("Cli.patchesOf")(function* (worktree, context = CONTEXT) {
10967
+ const raw = yield* (yield* Git).diff(worktree, context);
10966
10968
  return parsePatches(raw);
10967
10969
  });
10968
10970
  const findPatch = (patches, file) => fromNullishOr(patches.find((patch) => patch.path === file));
@@ -10974,9 +10976,18 @@ const waitingOn = fn("Cli.waitingOn")(function* (worktree) {
10974
10976
  const store = yield* Store;
10975
10977
  const state = yield* store.state(worktree.path);
10976
10978
  const batches = yield* store.inbox(worktree.path);
10979
+ const told = yield* store.story(worktree.path);
10977
10980
  return {
10978
10981
  staged: state.pending.length,
10979
- unread: Math.max(0, batches.length - state.consumed)
10982
+ unread: Math.max(0, batches.length - state.consumed),
10983
+ steps: match$2(told, {
10984
+ onNone: () => 0,
10985
+ onSome: (story) => story.steps.length
10986
+ }),
10987
+ stale: match$2(told, {
10988
+ onNone: () => false,
10989
+ onSome: (story) => story.head !== worktree.head
10990
+ })
10980
10991
  };
10981
10992
  });
10982
10993
  const listBranches = fn("Cli.listBranches")(function* (repo) {
@@ -10994,7 +11005,9 @@ const listBranches = fn("Cli.listBranches")(function* (repo) {
10994
11005
  added: stat.added,
10995
11006
  removed: stat.removed,
10996
11007
  staged: waiting.staged,
10997
- unread: waiting.unread
11008
+ unread: waiting.unread,
11009
+ steps: waiting.steps,
11010
+ stale: waiting.stale
10998
11011
  });
10999
11012
  }
11000
11013
  return summaries.filter((summary) => summary.files > 0);
@@ -11041,7 +11054,7 @@ const reviewProgress = fn("Cli.reviewProgress")(function* (repo, branch) {
11041
11054
  });
11042
11055
  const anchorRequest = fn("Cli.anchorRequest")(function* (request) {
11043
11056
  const worktree = yield* findBranch(request.repo, request.branch);
11044
- const patches = yield* patchesOf(worktree);
11057
+ const patches = yield* patchesOf(worktree, WHOLE_FILE$1);
11045
11058
  const resolved = yield* match$2(findPatch(patches, request.file), {
11046
11059
  onNone: () => new UnknownFile({
11047
11060
  file: request.file,
@@ -11124,7 +11137,7 @@ const submitReview = fn("Cli.submitReview")(function* (repo, branch, id, at) {
11124
11137
  const submitComment = fn("Cli.submitComment")(function* (request) {
11125
11138
  const store = yield* Store;
11126
11139
  const worktree = yield* findBranch(request.repo, request.branch);
11127
- const patches = yield* patchesOf(worktree);
11140
+ const patches = yield* patchesOf(worktree, WHOLE_FILE$1);
11128
11141
  const patch = findPatch(patches, request.file);
11129
11142
  const resolved = yield* match$2(patch, {
11130
11143
  onNone: () => new UnknownFile({
@@ -11200,7 +11213,8 @@ const codeBlockOf$1 = (span) => ({
11200
11213
  end: span.end
11201
11214
  });
11202
11215
  const codeBlocks = (step) => step.blocks.filter((block) => block.kind === "code");
11203
- const spansOf = (steps) => steps.flatMap((step) => codeBlocks(step).map(({ path, start, end }) => ({
11216
+ const noteOf = (step) => step.blocks.filter((block) => block.kind === "prose").map((block) => block.markdown.trim()).filter((markdown) => markdown.length > 0).join(" ");
11217
+ const spansOf$1 = (steps) => steps.flatMap((step) => codeBlocks(step).map(({ path, start, end }) => ({
11204
11218
  path,
11205
11219
  start,
11206
11220
  end
@@ -11218,7 +11232,7 @@ const spanOfHunk = (patch, hunk) => {
11218
11232
  };
11219
11233
  const overlaps = (a, b) => a.path === b.path && a.start <= b.end && a.end >= b.start;
11220
11234
  const coverage = (patches, steps) => {
11221
- const claimed = spansOf(steps);
11235
+ const claimed = spansOf$1(steps);
11222
11236
  const hunks = patches.flatMap((patch) => patch.hunks.flatMap((hunk) => match$2(spanOfHunk(patch, hunk), {
11223
11237
  onNone: () => [],
11224
11238
  onSome: (s) => [s]
@@ -11250,7 +11264,7 @@ const withFullCoverage = (patches, story) => {
11250
11264
  const statusOf = (patches, story, branchHead) => {
11251
11265
  const gap = coverage(patches, story.steps);
11252
11266
  const present = new Set(patches.map((patch) => patch.path));
11253
- const mentioned = new Set(spansOf(story.steps).map((span) => span.path));
11267
+ const mentioned = new Set(spansOf$1(story.steps).map((span) => span.path));
11254
11268
  return {
11255
11269
  version: story.version,
11256
11270
  parent: story.parent,
@@ -11342,6 +11356,7 @@ const stepsOf = (patches, story) => {
11342
11356
  const present = new Set(patches.map((patch) => patch.path));
11343
11357
  return withFullCoverage(patches, story).steps.map((step) => ({
11344
11358
  title: step.title,
11359
+ note: noteOf(step),
11345
11360
  files: unique(spansOfStep(step).map((span) => span.path)).filter((path) => present.has(path)),
11346
11361
  spans: spansOfStep(step)
11347
11362
  }));
@@ -11414,8 +11429,15 @@ const showStory = fn("Cli.showStory")(function* (worktreePath) {
11414
11429
  const listStorySteps = fn("Cli.listStorySteps")(function* (repo, branch) {
11415
11430
  const worktree = yield* findBranch(repo, branch);
11416
11431
  const found = yield* storyOf(worktree);
11417
- if (isNone(found)) return [];
11418
- return stepsOf(yield* patchesOf(worktree), found.value);
11432
+ if (isNone(found)) return {
11433
+ steps: [],
11434
+ stale: false
11435
+ };
11436
+ const patches = yield* patchesOf(worktree);
11437
+ return {
11438
+ steps: stepsOf(patches, found.value),
11439
+ stale: found.value.head !== worktree.head
11440
+ };
11419
11441
  });
11420
11442
  //#endregion
11421
11443
  //#region src/cli/parse.ts
@@ -11725,6 +11747,142 @@ const failure = (cause) => {
11725
11747
  };
11726
11748
  };
11727
11749
  //#endregion
11750
+ //#region src/tui/gaps.ts
11751
+ const sourceLength = (source) => source.at(-1)?.trim() === "" ? source.length - 1 : source.length;
11752
+ const markerText = (hidden) => `⋯ ${hidden} lines hidden · press l`;
11753
+ const lastNewLine = (patch) => {
11754
+ const found = patch.rows.findLast((row) => isSome(row.newLine));
11755
+ return found === void 0 ? 0 : getOrElse(found.newLine, () => 0);
11756
+ };
11757
+ const spansOf = (patch, total) => {
11758
+ const leading = {
11759
+ lo: 1,
11760
+ hi: (patch.hunks[0]?.newStart ?? 1) - 1
11761
+ };
11762
+ const between = patch.hunks.slice(1).map((hunk) => ({
11763
+ lo: hunk.newStart - hunk.skipped,
11764
+ hi: hunk.newStart - 1
11765
+ }));
11766
+ const trailing = {
11767
+ lo: lastNewLine(patch) + 1,
11768
+ hi: total
11769
+ };
11770
+ return [
11771
+ leading,
11772
+ ...between,
11773
+ trailing
11774
+ ];
11775
+ };
11776
+ const linesFrom = (build, from, to) => build.full === void 0 || to < from ? [] : build.full.rows.filter((row) => match$2(row.newLine, {
11777
+ onNone: () => false,
11778
+ onSome: (line) => line >= from && line <= to
11779
+ }));
11780
+ const push = (made, row) => {
11781
+ made.rows.push({
11782
+ ...row,
11783
+ index: made.rows.length
11784
+ });
11785
+ };
11786
+ const markGap = (made, index, hidden) => {
11787
+ made.gaps.push({
11788
+ index,
11789
+ hidden,
11790
+ row: made.rows.length
11791
+ });
11792
+ push(made, {
11793
+ kind: "context",
11794
+ oldLine: none(),
11795
+ newLine: none(),
11796
+ text: markerText(hidden)
11797
+ });
11798
+ };
11799
+ const openOf = (build, index, count) => {
11800
+ if (build.full === void 0) return 0;
11801
+ const asked = build.reveals.find((entry) => entry.gap === index)?.lines ?? 0;
11802
+ return Math.min(count, Math.max(0, asked));
11803
+ };
11804
+ const countOf = (span) => Math.max(0, span.hi - span.lo + 1);
11805
+ const openAbove = (made, build, index) => {
11806
+ const span = build.spans[index];
11807
+ if (span === void 0) return 0;
11808
+ const count = countOf(span);
11809
+ const open = openOf(build, index, count);
11810
+ const left = count - open;
11811
+ if (left > 0) markGap(made, index, left);
11812
+ for (const row of linesFrom(build, span.hi - open + 1, span.hi)) push(made, row);
11813
+ return left;
11814
+ };
11815
+ const openBelow = (made, build) => {
11816
+ const index = build.base.hunks.length;
11817
+ const span = build.spans[index];
11818
+ if (span === void 0) return;
11819
+ const count = countOf(span);
11820
+ const open = openOf(build, index, count);
11821
+ for (const row of linesFrom(build, span.lo, span.lo + open - 1)) push(made, row);
11822
+ if (count - open > 0) markGap(made, index, count - open);
11823
+ };
11824
+ const makeRows = (build) => {
11825
+ const made = {
11826
+ rows: [],
11827
+ hunks: [],
11828
+ gaps: []
11829
+ };
11830
+ for (const [index, hunk] of build.base.hunks.entries()) {
11831
+ const left = openAbove(made, build, index);
11832
+ const startRow = made.rows.length;
11833
+ for (const row of hunk.rows) push(made, row);
11834
+ made.hunks.push({
11835
+ ...hunk,
11836
+ startRow,
11837
+ rows: made.rows.slice(startRow),
11838
+ skipped: index === 0 ? 0 : left
11839
+ });
11840
+ }
11841
+ openBelow(made, build);
11842
+ return made;
11843
+ };
11844
+ const compose = (build) => {
11845
+ const made = makeRows(build);
11846
+ return {
11847
+ patch: {
11848
+ ...build.base,
11849
+ rows: made.rows,
11850
+ hunks: made.hunks
11851
+ },
11852
+ gaps: made.gaps
11853
+ };
11854
+ };
11855
+ const cache = /* @__PURE__ */ new WeakMap();
11856
+ const keyOf = (total, full, reveals) => [
11857
+ total,
11858
+ full === void 0 ? 0 : full.rows.length,
11859
+ reveals.map((entry) => `${entry.gap}-${entry.lines}`).join(",")
11860
+ ].join(":");
11861
+ const shownOf = (state) => {
11862
+ const base = state.patches[state.patchIndex];
11863
+ if (base === void 0) return void 0;
11864
+ const full = state.full.find((patch) => patch.path === base.path);
11865
+ const total = sourceLength(state.source);
11866
+ const reveals = state.revealed.filter((entry) => entry.file === base.path);
11867
+ const key = keyOf(total, full, reveals);
11868
+ const known = cache.get(base);
11869
+ const found = known?.get(key);
11870
+ if (found !== void 0) return found;
11871
+ const made = compose({
11872
+ base,
11873
+ full,
11874
+ spans: spansOf(base, total),
11875
+ reveals
11876
+ });
11877
+ const map = known ?? /* @__PURE__ */ new Map();
11878
+ map.set(key, made);
11879
+ cache.set(base, map);
11880
+ return made;
11881
+ };
11882
+ const gapAtRow = (state, row) => shownOf(state)?.gaps.find((gap) => gap.row === row);
11883
+ const gapNumbered = (state, index) => shownOf(state)?.gaps.find((gap) => gap.index === index);
11884
+ const gapRowSet = (shown) => new Set(shown.gaps.map((gap) => gap.row));
11885
+ //#endregion
11728
11886
  //#region src/tui/tree.ts
11729
11887
  const add = (tree, input) => {
11730
11888
  const id = tree.nodes.length;
@@ -11875,10 +12033,14 @@ const initialState = (branches) => ({
11875
12033
  context: 3,
11876
12034
  top: 0,
11877
12035
  source: [],
12036
+ full: [],
12037
+ revealed: [],
11878
12038
  focus: "diff",
11879
12039
  navOpen: true,
11880
12040
  steps: [],
12041
+ storyStale: false,
11881
12042
  stepIndex: 0,
12043
+ openSteps: [],
11882
12044
  rail: "tree"
11883
12045
  });
11884
12046
  const onSteps = (state) => state.rail === "steps" && state.steps.length > 0;
@@ -11895,22 +12057,50 @@ const stepHolding = (state, fileIndex) => {
11895
12057
  const at = state.steps.findIndex((step) => step.files.includes(path ?? ""));
11896
12058
  return at === -1 ? state.stepIndex : at;
11897
12059
  };
11898
- const stepWindow = (state, height) => {
11899
- const titles = state.steps.map((step) => step.title);
11900
- if (titles.length <= height) return {
11901
- first: 0,
11902
- titles,
12060
+ const stepOpen = (state, stepIndex) => state.openSteps.includes(stepIndex);
12061
+ const chunked = (word, room) => word.length <= room ? [word] : [word.slice(0, room), ...chunked(word.slice(room), room)];
12062
+ const packed = (lines, word, room) => {
12063
+ const last = lines.at(-1);
12064
+ if (last === void 0 || last.length + 1 + word.length > room) return [...lines, word];
12065
+ return [...lines.slice(0, -1), `${last} ${word}`];
12066
+ };
12067
+ const wrapped = (text, room) => {
12068
+ const width = Math.max(1, room);
12069
+ return text.split(/\s+/).filter((word) => word.length > 0).flatMap((word) => chunked(word, width)).reduce((lines, word) => packed(lines, word, width), []);
12070
+ };
12071
+ const NO_NOTE = "no note";
12072
+ const noteRows$1 = (state, stepIndex, room) => {
12073
+ const lines = wrapped(state.steps[stepIndex]?.note ?? "", room);
12074
+ return (lines.length === 0 ? [NO_NOTE] : lines).map((text) => ({
12075
+ index: stepIndex,
12076
+ kind: "note",
12077
+ text,
12078
+ lead: false
12079
+ }));
12080
+ };
12081
+ const titleRows = (state, stepIndex, room) => wrapped(state.steps[stepIndex]?.title ?? "", room).map((text, at) => ({
12082
+ index: stepIndex,
12083
+ kind: "title",
12084
+ text,
12085
+ lead: at === 0
12086
+ }));
12087
+ const stepRows = (state, titleRoom, noteRoom) => state.steps.flatMap((_, index) => stepOpen(state, index) ? [...titleRows(state, index, titleRoom), ...noteRows$1(state, index, noteRoom)] : titleRows(state, index, titleRoom));
12088
+ const railWindow = (rows, height, stepIndex) => {
12089
+ if (rows.length <= height) return {
12090
+ rows,
11903
12091
  more: 0
11904
12092
  };
11905
- const start = Math.max(0, Math.min(titles.length - height, state.stepIndex - Math.floor(height / 2)));
12093
+ const first = Math.max(0, rows.findIndex((row) => row.index === stepIndex));
12094
+ const block = rows.findLastIndex((row) => row.index === stepIndex) - first + 1;
12095
+ const wanted = block >= height ? first : first - Math.floor((height - block) / 2);
12096
+ const start = Math.max(0, Math.min(rows.length - height, wanted));
11906
12097
  return {
11907
- first: start,
11908
- titles: titles.slice(start, start + height),
11909
- more: titles.length - height
12098
+ rows: rows.slice(start, start + height),
12099
+ more: rows.length - height
11910
12100
  };
11911
12101
  };
11912
12102
  const selectedBranch = (state) => state.branches[state.branchIndex];
11913
- const selectedPatch = (state) => state.patches[state.patchIndex];
12103
+ const selectedPatch = (state) => shownOf(state)?.patch;
11914
12104
  const treeOf = (state) => buildTree(state.patches.map((patch) => patch.path));
11915
12105
  const treeRows = (state) => {
11916
12106
  const tree = treeOf(state);
@@ -11946,23 +12136,7 @@ const commentsOn = (state, fileIndex) => {
11946
12136
  if (patch === void 0) return 0;
11947
12137
  return state.pending.filter((entry) => entry.file === patch.path).length;
11948
12138
  };
11949
- const firstShownLine = (patch) => {
11950
- const found = patch.rows.find((row) => isSome(row.newLine));
11951
- return found === void 0 ? 1 : getOrElse(found.newLine, () => 1);
11952
- };
11953
- const lastShownLine = (patch) => {
11954
- const found = patch.rows.findLast((row) => isSome(row.newLine));
11955
- return found === void 0 ? 0 : getOrElse(found.newLine, () => 0);
11956
- };
11957
- const hiddenLines = (state) => {
11958
- const patch = selectedPatch(state);
11959
- if (patch === void 0) return 0;
11960
- const between = patch.hunks.reduce((total, hunk) => total + hunk.skipped, 0);
11961
- const above = Math.max(0, firstShownLine(patch) - 1);
11962
- const lines = state.source.at(-1)?.trim() === "" ? state.source.length - 1 : state.source.length;
11963
- const below = lines === 0 ? 0 : Math.max(0, lines - lastShownLine(patch));
11964
- return between + above + below;
11965
- };
12139
+ const hiddenLines = (state) => shownOf(state)?.gaps.reduce((total, gap) => total + gap.hidden, 0) ?? 0;
11966
12140
  const markedRows = (state) => {
11967
12141
  const patch = selectedPatch(state);
11968
12142
  if (patch === void 0) return /* @__PURE__ */ new Set();
@@ -11998,12 +12172,13 @@ const selectionReadout = (state) => {
11998
12172
  const lines = to - from + 1;
11999
12173
  return `${patch.path} ${lines} lines`;
12000
12174
  };
12175
+ const WHOLE_FILE = 1e5;
12001
12176
  const CONTEXT_STEPS = [
12002
12177
  3,
12003
12178
  10,
12004
12179
  25,
12005
12180
  60,
12006
- 1e5
12181
+ WHOLE_FILE
12007
12182
  ];
12008
12183
  const stepContext = (current, delta) => {
12009
12184
  const at = CONTEXT_STEPS.indexOf(current);
@@ -12030,7 +12205,7 @@ const rowAtSourceLine = (patch, line) => {
12030
12205
  };
12031
12206
  const lineOnSide = (row, side) => getOrUndefined$1(side === "old" ? row.oldLine : row.newLine);
12032
12207
  const commentRowsIn = (state, fileIndex) => {
12033
- const patch = state.patches[fileIndex];
12208
+ const patch = fileIndex === state.patchIndex ? selectedPatch(state) : state.patches[fileIndex];
12034
12209
  if (patch === void 0) return [];
12035
12210
  const notes = [...state.pending, ...state.sent].filter((entry) => entry.file === patch.path);
12036
12211
  return patch.rows.filter((row) => notes.some((note) => lineOnSide(row, note.side) === note.end)).map((row) => row.index).toSorted((left, right) => left - right);
@@ -12258,14 +12433,14 @@ const commands = [
12258
12433
  }),
12259
12434
  command({
12260
12435
  action: "tree.collapse",
12261
- title: "Collapse the file tree",
12436
+ title: "Close the folder, step, or gap",
12262
12437
  category: "Files",
12263
12438
  keys: ["h"],
12264
12439
  screens: ["review"]
12265
12440
  }),
12266
12441
  command({
12267
12442
  action: "tree.expand",
12268
- title: "Expand the file tree",
12443
+ title: "Open the folder, step, or gap",
12269
12444
  category: "Files",
12270
12445
  keys: ["l"],
12271
12446
  screens: ["review"]
@@ -12571,6 +12746,14 @@ const foldDirectory = (state, shut) => {
12571
12746
  closed: shut ? [...closed, directory] : closed
12572
12747
  };
12573
12748
  };
12749
+ const foldStep = (state, shut) => {
12750
+ const open = state.openSteps.filter((index) => index !== state.stepIndex);
12751
+ return {
12752
+ ...state,
12753
+ openSteps: shut ? open : [...open, state.stepIndex]
12754
+ };
12755
+ };
12756
+ const fold = (state, shut) => onSteps(state) ? foldStep(state, shut) : foldDirectory(state, shut);
12574
12757
  const moveBranch = (state, delta) => ({
12575
12758
  ...state,
12576
12759
  branchIndex: clamp(state.branchIndex + delta, 0, Math.max(0, state.branches.length - 1))
@@ -12681,8 +12864,8 @@ const transitions = {
12681
12864
  "rail.toggle": toggleRail,
12682
12865
  "file.vouch": (state) => state,
12683
12866
  "file.vouch.next": (state) => state,
12684
- "tree.collapse": (state) => foldDirectory(state, true),
12685
- "tree.expand": (state) => foldDirectory(state, false),
12867
+ "tree.collapse": (state) => fold(state, true),
12868
+ "tree.expand": (state) => fold(state, false),
12686
12869
  "report.open": (state) => ({
12687
12870
  ...state,
12688
12871
  screen: "report",
@@ -12707,10 +12890,40 @@ const withContext = (state, context, patches, cursor) => ({
12707
12890
  ...state,
12708
12891
  context,
12709
12892
  patches,
12893
+ revealed: [],
12710
12894
  cursor,
12711
12895
  anchorRow: cursor,
12712
12896
  selecting: false
12713
12897
  });
12898
+ const withFull = (state, full) => ({
12899
+ ...state,
12900
+ full
12901
+ });
12902
+ const revealsAfter = (state, gap, lines) => {
12903
+ const path = state.patches[state.patchIndex]?.path ?? "";
12904
+ const others = state.revealed.filter((entry) => entry.file !== path || entry.gap !== gap);
12905
+ return lines <= 0 ? others : [...others, {
12906
+ file: path,
12907
+ gap,
12908
+ lines
12909
+ }];
12910
+ };
12911
+ const gapOpened = (state, gap, delta) => {
12912
+ const path = state.patches[state.patchIndex]?.path ?? "";
12913
+ const now = state.revealed.find((entry) => entry.file === path && entry.gap === gap)?.lines ?? 0;
12914
+ const opened = {
12915
+ ...state,
12916
+ revealed: revealsAfter(state, gap, now + delta)
12917
+ };
12918
+ const wanted = gapNumbered(opened, gap)?.row ?? state.cursor;
12919
+ const landed = clamp(wanted, 0, lastRow(selectedPatch(opened)));
12920
+ return withCursorVisible({
12921
+ ...opened,
12922
+ cursor: landed,
12923
+ anchorRow: landed,
12924
+ selecting: false
12925
+ });
12926
+ };
12714
12927
  const withPending = (state, pending, screen) => ({
12715
12928
  ...state,
12716
12929
  pending,
@@ -12722,11 +12935,14 @@ const withSent = (state, sent) => ({
12722
12935
  ...state,
12723
12936
  sent
12724
12937
  });
12725
- const withStory = (state, steps) => {
12938
+ const withStory = (state, told) => {
12939
+ const steps = told.steps;
12726
12940
  const opened = {
12727
12941
  ...state,
12728
12942
  steps,
12943
+ storyStale: told.stale,
12729
12944
  stepIndex: 0,
12945
+ openSteps: [],
12730
12946
  rail: steps.length === 0 ? "tree" : "steps"
12731
12947
  };
12732
12948
  if (steps.length === 0) return opened;
@@ -12754,6 +12970,8 @@ const withPatches = (state, patches) => ({
12754
12970
  ...state,
12755
12971
  screen: "review",
12756
12972
  patches,
12973
+ full: [],
12974
+ revealed: [],
12757
12975
  closed: crowdedOf(patches),
12758
12976
  patchIndex: fileOrder({
12759
12977
  ...state,
@@ -12937,6 +13155,7 @@ const syntaxTheme = {
12937
13155
  punctuation: { fg: inkFaint },
12938
13156
  "punctuation.bracket": { fg: inkFaint },
12939
13157
  "punctuation.delimiter": { fg: inkFaint },
13158
+ gap: { fg: inkFaint },
12940
13159
  note: {
12941
13160
  fg: "#9aa7c7",
12942
13161
  italic: true
@@ -13085,20 +13304,20 @@ var DiffView = class {
13085
13304
  rows() {
13086
13305
  return this.fitted;
13087
13306
  }
13088
- show(patch, notes) {
13307
+ show(patch, notes, gaps) {
13089
13308
  const room = notes.length === 0 ? NOTE_MIN : this.noteRoom();
13090
13309
  const key = [room, ...notes.map((note) => `${note.side}${note.line}:${note.body}`)].join("\0");
13091
13310
  if (patch === this.shown && key === this.noted) return;
13092
13311
  this.pinnedText = "";
13093
13312
  this.shown = patch;
13094
13313
  this.noted = key;
13095
- this.display = layout(patch, notes, room);
13314
+ this.display = layout(patch, notes, room, gaps);
13096
13315
  this.starts = /* @__PURE__ */ new Map();
13097
13316
  for (const [index, entry] of this.display.entries()) if (!entry.comment && !this.starts.has(entry.row)) this.starts.set(entry.row, index);
13098
13317
  this.code.filetype = pathToFiletype(patch.path) ?? "text";
13099
13318
  this.code.content = this.display.map((entry) => entry.text).join("\n");
13100
13319
  this.numbers.setLineNumbers(lineNumbers(patch, this.display));
13101
- this.numbers.setHideLineNumbers(new Set(this.display.flatMap((entry, index) => entry.comment ? [index] : [])));
13320
+ this.numbers.setHideLineNumbers(new Set(this.display.flatMap((entry, index) => entry.comment || entry.gap ? [index] : [])));
13102
13321
  this.numbers.setLineSigns(lineSigns(patch, this.display));
13103
13322
  this.numbers.setLineColors(/* @__PURE__ */ new Map());
13104
13323
  const spans = noteSpans(this.display);
@@ -13135,18 +13354,22 @@ var DiffView = class {
13135
13354
  return WASH[kind];
13136
13355
  }
13137
13356
  };
13357
+ const groupOf = (entry) => {
13358
+ if (entry.gap) return "gap";
13359
+ if (!entry.comment) return void 0;
13360
+ if (entry.label) return "note.label";
13361
+ return entry.sent ? "note.sent" : "note";
13362
+ };
13138
13363
  const noteSpans = (display) => {
13139
13364
  const spans = [];
13140
13365
  let at = 0;
13141
13366
  for (const entry of display) {
13142
- if (entry.comment) {
13143
- const group = entry.label ? "note.label" : entry.sent ? "note.sent" : "note";
13144
- spans.push([
13145
- at,
13146
- at + entry.text.length,
13147
- group
13148
- ]);
13149
- }
13367
+ const group = groupOf(entry);
13368
+ if (group !== void 0) spans.push([
13369
+ at,
13370
+ at + entry.text.length,
13371
+ group
13372
+ ]);
13150
13373
  at += entry.text.length + 1;
13151
13374
  }
13152
13375
  return spans;
@@ -13172,9 +13395,10 @@ const noteRows = (note, row, room) => noteLines(note, room).map((line, index) =>
13172
13395
  row,
13173
13396
  comment: true,
13174
13397
  sent: note.sent,
13175
- label: index === 0
13398
+ label: index === 0,
13399
+ gap: false
13176
13400
  }));
13177
- const layout = (patch, notes, room) => {
13401
+ const layout = (patch, notes, room, gaps) => {
13178
13402
  const display = [];
13179
13403
  for (const row of patch.rows) {
13180
13404
  display.push({
@@ -13182,7 +13406,8 @@ const layout = (patch, notes, room) => {
13182
13406
  row: row.index,
13183
13407
  comment: false,
13184
13408
  sent: false,
13185
- label: false
13409
+ label: false,
13410
+ gap: gaps.has(row.index)
13186
13411
  });
13187
13412
  for (const note of notes) if (sideLineOf(row, note.side) === note.line) display.push(...noteRows(note, row.index, room));
13188
13413
  }
@@ -13222,6 +13447,8 @@ const FRAME_PAD = 1;
13222
13447
  const MODAL_ROOM = 8;
13223
13448
  const COMPOSE_CHROME = 3;
13224
13449
  const COMPOSE_ACTION_ROWS = 2;
13450
+ const COMPOSE_PAD = 5;
13451
+ const COMPOSE_MIN_TEXT = 8;
13225
13452
  const reportActions = () => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("copy and save")}`;
13226
13453
  const actionsText = () => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^a")} ${fg(palette.muted)("add to review")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("comment now")}`;
13227
13454
  const SNIPPET_LINES = 4;
@@ -13238,7 +13465,7 @@ const PANE_CHROME = 3;
13238
13465
  const BRANCH_WIDTH = 82;
13239
13466
  const BRANCH_NAME = 44;
13240
13467
  const BRANCH_NAME_MIN = 12;
13241
- const BRANCH_TAIL = 35;
13468
+ const BRANCH_TAIL = 45;
13242
13469
  const MODAL_MARGIN = 4;
13243
13470
  const bodyRoom = (width) => Math.max(0, width - 2 - BODY_BORDER);
13244
13471
  const treeWidth = (width) => {
@@ -13248,6 +13475,17 @@ const treeWidth = (width) => {
13248
13475
  };
13249
13476
  const homeWidth = (width) => Math.max(0, Math.min(BRANCH_WIDTH, width - 2));
13250
13477
  const modalWidth = (width, wanted) => Math.max(0, Math.min(wanted, width - MODAL_MARGIN));
13478
+ const composeRoom = (width) => {
13479
+ const box = modalWidth(width, COMPOSE_WIDTH);
13480
+ return {
13481
+ box,
13482
+ text: Math.max(COMPOSE_MIN_TEXT, box - COMPOSE_PAD)
13483
+ };
13484
+ };
13485
+ const laidOut = (lines, room) => lines.flatMap((line) => {
13486
+ const parts = wrapped(line, room);
13487
+ return parts.length === 0 ? [""] : parts;
13488
+ });
13251
13489
  const STICKY_MAX = 4;
13252
13490
  const pickPaint = (view, kind, flags) => {
13253
13491
  if (flags.cursor) return {
@@ -13258,11 +13496,16 @@ const pickPaint = (view, kind, flags) => {
13258
13496
  gutter: SELECTION,
13259
13497
  content: SELECTION
13260
13498
  };
13499
+ if (flags.gap) return GAP_PAINT;
13261
13500
  return view.washOf(kind);
13262
13501
  };
13263
13502
  const SELECTION = RGBA.fromHex(palette.selection);
13264
13503
  const CURSOR = RGBA.fromHex(palette.cursor);
13265
13504
  const ACCENT = RGBA.fromHex(palette.accent);
13505
+ const GAP_PAINT = {
13506
+ gutter: RGBA.fromHex(palette.overlay),
13507
+ content: RGBA.fromHex(palette.overlay)
13508
+ };
13266
13509
  const bar = (renderer, id, color) => new TextRenderable(renderer, {
13267
13510
  id,
13268
13511
  content: "",
@@ -13445,18 +13688,21 @@ const makeComposeParts = (renderer) => ({
13445
13688
  title: new TextRenderable(renderer, {
13446
13689
  id: "compose-title",
13447
13690
  content: "",
13448
- fg: palette.ink
13691
+ fg: palette.ink,
13692
+ wrapMode: "none"
13449
13693
  }),
13450
13694
  body: new TextRenderable(renderer, {
13451
13695
  id: "compose-body",
13452
13696
  content: "",
13453
- fg: palette.ink
13697
+ fg: palette.ink,
13698
+ wrapMode: "none"
13454
13699
  }),
13455
13700
  actions: new TextRenderable(renderer, {
13456
13701
  id: "compose-actions",
13457
13702
  content: "",
13458
13703
  fg: palette.muted,
13459
- marginTop: 1
13704
+ marginTop: 1,
13705
+ wrapMode: "none"
13460
13706
  })
13461
13707
  });
13462
13708
  const makeCompose = (renderer) => new BoxRenderable(renderer, {
@@ -13503,21 +13749,27 @@ const contextLabel = (context) => {
13503
13749
  return context >= 1e5 ? "whole file" : `±${context}`;
13504
13750
  };
13505
13751
  const nameRoom = (pane) => Math.max(BRANCH_NAME_MIN, Math.min(BRANCH_NAME, pane - BRANCH_TAIL));
13506
- const columns = (cells, room) => `${clip(cells.name, room).padEnd(room)}${cells.files.padStart(5)}${cells.added.padStart(8)}${cells.gone.padStart(8)} ${cells.state}`;
13752
+ const columns = (cells, room) => `${clip(cells.name, room).padEnd(room)}${cells.files.padStart(5)}${cells.added.padStart(8)}${cells.gone.padStart(8)} ${cells.story.padStart(8)} ${cells.state}`;
13507
13753
  const branchHeading = (room) => ` ${columns({
13508
13754
  name: "WORKTREE",
13509
13755
  files: "FILES",
13510
13756
  added: "+",
13511
13757
  gone: "-",
13758
+ story: "STORY",
13512
13759
  state: "STATE"
13513
13760
  }, room)}`;
13514
13761
  const atHome = (state) => state.screen === "branches" || state.screen === "palette" && state.returnTo === "branches";
13762
+ const storyCell = (branch) => {
13763
+ if (branch.steps === 0) return "";
13764
+ return branch.stale ? `${branch.steps} stale` : `${branch.steps} story`;
13765
+ };
13515
13766
  const branchCells = (branch, here, room) => ({
13516
13767
  lead: `${here ? marks().cursor : " "} `,
13517
13768
  name: clip(branch.branch, room).padEnd(room),
13518
13769
  files: `${branch.files}`.padStart(5),
13519
13770
  added: `+${branch.added}`.padStart(8),
13520
13771
  gone: `-${branch.removed}`.padStart(8),
13772
+ story: storyCell(branch),
13521
13773
  state: waitingLabel(branch).trim()
13522
13774
  });
13523
13775
  const headerParts = (state, branch, path) => [
@@ -13547,14 +13799,33 @@ const treeLine = (state, row, pane) => {
13547
13799
  return `${treeMarks(state, row)}${clip(treeLabel(state, row), room).padEnd(room)}${tail}`;
13548
13800
  };
13549
13801
  const STEP_NUMBER = 3;
13550
- const stepLine = (state, index, pane) => {
13551
- const step = state.steps[index];
13552
- if (step === void 0) return "";
13553
- const mark = index === state.stepIndex ? state.focus === "tree" ? "▸" : "·" : " ";
13554
- const number = `${index + 1}.`.padStart(STEP_NUMBER);
13555
- const tail = `${step.files.length}`;
13556
- const room = Math.max(4, pane - PANE_CHROME - STEP_NUMBER - tail.length - 3);
13557
- return `${mark} ${number} ${clip(step.title, room).padEnd(room)}${tail}`;
13802
+ const STEP_LEAD = 8;
13803
+ const NOTE_LEAD = 10;
13804
+ const STEP_GAP = 1;
13805
+ const stepRoom = (state, pane) => {
13806
+ const tally = Math.max(1, ...state.steps.map((step) => `${step.files.length}`.length));
13807
+ return {
13808
+ title: Math.max(4, pane - PANE_CHROME - STEP_LEAD - STEP_GAP - tally),
13809
+ note: Math.max(4, pane - PANE_CHROME - NOTE_LEAD),
13810
+ tally
13811
+ };
13812
+ };
13813
+ const stepFold = (state, index) => {
13814
+ if (stepOpen(state, index)) return "▾";
13815
+ return (state.steps[index]?.note ?? "").length === 0 ? " " : "▸";
13816
+ };
13817
+ const stepHead = (state, row) => {
13818
+ if (!row.lead) return " ".repeat(STEP_LEAD);
13819
+ return `${row.index === state.stepIndex ? state.focus === "tree" ? "▸" : "·" : " "} ${stepFold(state, row.index)} ${`${row.index + 1}.`.padStart(STEP_NUMBER)} `;
13820
+ };
13821
+ const stepText = (state, row, room) => {
13822
+ if (row.kind === "note") return `${" ".repeat(NOTE_LEAD)}${row.text}`;
13823
+ const tail = (row.lead ? `${state.steps[row.index]?.files.length ?? 0}` : "").padStart(room.tally + STEP_GAP);
13824
+ return `${stepHead(state, row)}${row.text.padEnd(room.title)}${tail}`;
13825
+ };
13826
+ const stepPaint = (state, row) => {
13827
+ if (row.kind === "note") return palette.faint;
13828
+ return row.index === state.stepIndex ? palette.ink : palette.muted;
13558
13829
  };
13559
13830
  var Screen = class {
13560
13831
  header;
@@ -13730,21 +14001,23 @@ var Screen = class {
13730
14001
  }
13731
14002
  stepRail(state) {
13732
14003
  const height = Math.max(1, this.listPane.height - 1);
13733
- const pane = this.paneRoom();
13734
- const window = stepWindow(state, height);
13735
- const rows = window.titles.map((_, offset) => {
13736
- const index = window.first + offset;
13737
- const paint = index === state.stepIndex ? palette.ink : palette.muted;
13738
- return fg(paint)(`${stepLine(state, index, pane)}\n`);
13739
- });
14004
+ const room = stepRoom(state, this.paneRoom());
14005
+ const window = railWindow(stepRows(state, room.title, room.note), height, state.stepIndex);
14006
+ const rows = window.rows.map((row) => fg(stepPaint(state, row))(`${stepText(state, row, room)}\n`));
13740
14007
  const more = window.more > 0 ? [fg(palette.faint)(` … ${window.more} more`)] : [];
13741
- return new StyledText([...rows, ...more]);
14008
+ const warn = state.storyStale ? [fg(palette.attention)(` stale, the branch moved on\n\n`)] : [];
14009
+ return new StyledText([
14010
+ ...warn,
14011
+ ...rows,
14012
+ ...more
14013
+ ]);
13742
14014
  }
13743
14015
  paintDiff(state) {
13744
- const patch = selectedPatch(state);
13745
- if (patch === void 0) return;
14016
+ const shown = shownOf(state);
14017
+ if (shown === void 0) return;
14018
+ const patch = shown.patch;
13746
14019
  this.paintSticky(state, state.top);
13747
- this.view.show(patch, notesFor(state, patch.path));
14020
+ this.view.show(patch, notesFor(state, patch.path), gapRowSet(shown));
13748
14021
  this.view.fit(this.diffScroll.height);
13749
14022
  const height = this.view.rows();
13750
14023
  const top = this.view.scrollTo(state.top, state.cursor);
@@ -13828,6 +14101,7 @@ var Screen = class {
13828
14101
  fg(palette.faint)(cells.files),
13829
14102
  fg(palette.added)(cells.added),
13830
14103
  fg(palette.removed)(cells.gone),
14104
+ fg(palette.accent)(` ${cells.story.padStart(8)}`),
13831
14105
  fg(palette.attention)(` ${cells.state}\n`)
13832
14106
  ];
13833
14107
  });
@@ -13883,18 +14157,18 @@ var Screen = class {
13883
14157
  paintReport(state) {
13884
14158
  this.compose.visible = state.screen === "compose" || state.screen === "report";
13885
14159
  if (state.screen !== "report") return;
13886
- const lines = [
14160
+ const room = composeRoom(this.renderer.width);
14161
+ const lines = laidOut([
13887
14162
  "What went wrong? Everything on screen is attached for you.",
13888
14163
  "",
13889
14164
  `${state.draft}▌`
13890
- ];
14165
+ ], room.text);
13891
14166
  this.composeTitle.content = "Report a bug";
13892
14167
  this.composeBody.content = lines.join("\n");
13893
14168
  this.composeActions.content = reportActions();
13894
- const room = modalWidth(this.renderer.width, COMPOSE_WIDTH);
13895
14169
  this.compose.height = lines.length + COMPOSE_ACTION_ROWS + COMPOSE_CHROME;
13896
- this.compose.width = room;
13897
- this.compose.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room) / 2));
14170
+ this.compose.width = room.box;
14171
+ this.compose.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room.box) / 2));
13898
14172
  this.compose.top = Math.max(2, Math.floor(this.renderer.height / 4));
13899
14173
  }
13900
14174
  paintGutter(state, top, height) {
@@ -13915,13 +14189,16 @@ var Screen = class {
13915
14189
  linePaint(state) {
13916
14190
  const [from, to] = selectionRange(state);
13917
14191
  const selecting = state.selecting || state.screen === "compose";
13918
- const rows = selectedPatch(state)?.rows ?? [];
14192
+ const shown = shownOf(state);
14193
+ const rows = shown?.patch.rows ?? [];
14194
+ const gaps = shown === void 0 ? /* @__PURE__ */ new Set() : gapRowSet(shown);
13919
14195
  return (row) => {
13920
14196
  const kind = rows[row]?.kind;
13921
14197
  if (kind === void 0) return void 0;
13922
14198
  return pickPaint(this.view, kind, {
13923
14199
  cursor: row === state.cursor,
13924
- selected: selecting && row >= from && row <= to
14200
+ selected: selecting && row >= from && row <= to,
14201
+ gap: gaps.has(row)
13925
14202
  });
13926
14203
  };
13927
14204
  }
@@ -13931,24 +14208,24 @@ var Screen = class {
13931
14208
  this.composeBody.content = "";
13932
14209
  return;
13933
14210
  }
14211
+ const room = composeRoom(this.renderer.width);
13934
14212
  const snippet = snippetOf(state, SNIPPET_LINES);
13935
14213
  const more = selectionRange(state)[1] - selectionRange(state)[0] + 1 - snippet.length;
13936
14214
  const tail = more > 0 ? [` … ${more} more lines`] : [];
13937
- const written = `${state.draft}▌`.split("\n");
14215
+ const quoted = [...snippet, ...tail].map((line) => clip(line, room.text));
14216
+ const written = laidOut(`${state.draft}▌`.split("\n"), room.text);
13938
14217
  const lines = [
13939
- ...snippet,
13940
- ...tail,
14218
+ ...quoted,
13941
14219
  "",
13942
14220
  ...written
13943
14221
  ];
13944
- this.composeTitle.content = composeTarget(state);
14222
+ this.composeTitle.content = clip(composeTarget(state), room.text);
13945
14223
  this.composeBody.content = lines.join("\n");
13946
14224
  this.composeActions.content = actionsText();
13947
14225
  const height = lines.length + COMPOSE_ACTION_ROWS + COMPOSE_CHROME;
13948
- const room = modalWidth(this.renderer.width, COMPOSE_WIDTH);
13949
14226
  this.compose.height = height;
13950
- this.compose.width = room;
13951
- this.compose.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room) / 2));
14227
+ this.compose.width = room.box;
14228
+ this.compose.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room.box) / 2));
13952
14229
  this.compose.top = Math.max(2, Math.floor((this.renderer.height - height) / 2));
13953
14230
  }
13954
14231
  };
@@ -14007,6 +14284,7 @@ var App = class {
14007
14284
  remembered = "";
14008
14285
  keys = [];
14009
14286
  fading;
14287
+ wheel = 0;
14010
14288
  constructor(options) {
14011
14289
  this.renderer = options.renderer;
14012
14290
  this.repo = options.repo;
@@ -14018,13 +14296,14 @@ var App = class {
14018
14296
  this.screen = new Screen(renderer, options.repo);
14019
14297
  this.screen.update(this.state);
14020
14298
  this.screen.listen({
14021
- onScroll: (delta) => this.commit(scrolled(this.measured(), delta)),
14299
+ onScroll: (delta) => this.onWheel(delta),
14022
14300
  onDrag: (from, to) => this.commit(draggedTo(this.measured(), from, to)),
14023
14301
  onChip: (key) => this.dispatchTask(() => this.onKey(asKey(key)))
14024
14302
  });
14025
14303
  renderer.keyInput.on("keypress", (key) => this.dispatch(key));
14026
14304
  renderer.on("destroy", () => this.stopFading());
14027
14305
  renderer.on("frame", () => this.syncGeometry());
14306
+ renderer.setFrameCallback(async () => this.applyWheel());
14028
14307
  const resume = options.resume;
14029
14308
  if (resume !== void 0) this.dispatchTask(() => this.resume(resume));
14030
14309
  }
@@ -14068,6 +14347,16 @@ var App = class {
14068
14347
  settled() {
14069
14348
  return this.pending;
14070
14349
  }
14350
+ onWheel(delta) {
14351
+ this.wheel += delta;
14352
+ this.renderer.requestRender();
14353
+ }
14354
+ applyWheel() {
14355
+ const delta = this.wheel;
14356
+ if (delta === 0) return;
14357
+ this.wheel = 0;
14358
+ this.commit(scrolled(this.measured(), delta));
14359
+ }
14071
14360
  syncGeometry() {
14072
14361
  const rows = this.screen.viewportRows();
14073
14362
  if (rows === this.state.viewport) return;
@@ -14126,9 +14415,24 @@ var App = class {
14126
14415
  back: () => this.goBack(),
14127
14416
  "report.send": () => this.sendReport(),
14128
14417
  "context.more": () => this.expand(1),
14129
- "context.less": () => this.expand(-1)
14418
+ "context.less": () => this.expand(-1),
14419
+ "tree.expand": () => this.unfold(1),
14420
+ "tree.collapse": () => this.unfold(-1)
14130
14421
  };
14131
14422
  }
14423
+ async unfold(delta) {
14424
+ const gap = this.state.focus === "diff" ? gapAtRow(this.state, this.state.cursor) : void 0;
14425
+ const action = delta > 0 ? "tree.expand" : "tree.collapse";
14426
+ if (gap === void 0) return this.commit(reduce(this.measured(), action));
14427
+ if (delta > 0) await this.loadFull();
14428
+ this.commit(gapOpened(this.measured(), gap.index, delta * 10));
14429
+ }
14430
+ async loadFull() {
14431
+ const branch = selectedBranch(this.state);
14432
+ if (branch === void 0 || this.state.full.length > 0) return;
14433
+ const full = await this.run(listPatches(this.repo, branch.branch, WHOLE_FILE));
14434
+ this.commit(withFull(this.state, full));
14435
+ }
14132
14436
  async onKey(key, forced) {
14133
14437
  const action = forced ?? actionFor(this.state.screen, keyName(key));
14134
14438
  this.remember(action, key);
@@ -14246,7 +14550,8 @@ var App = class {
14246
14550
  if (branch === void 0 || next === this.state.context) return;
14247
14551
  const line = sourceLineAt(this.state, this.state.cursor);
14248
14552
  const patches = await this.run(listPatches(this.repo, branch.branch, next));
14249
- const patch = patches[this.state.patchIndex];
14553
+ const widened = withContext(this.state, next, patches, 0);
14554
+ const patch = selectedPatch(widened);
14250
14555
  const cursor = patch === void 0 || line === void 0 ? 0 : rowAtSourceLine(patch, line);
14251
14556
  this.commit(withContext(this.state, next, patches, cursor));
14252
14557
  }
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "bin": {
22
22
  "adiff": "./bin/adiff.js"
23
23
  },
24
- "version": "0.1.0-alpha.3",
24
+ "version": "0.1.0-alpha.5",
25
25
  "description": "Review agent work across git worktrees like a PR, and hand the comments back to the agent.",
26
26
  "license": "MIT",
27
27
  "repository": {
@@ -35,6 +35,14 @@ adiff comment take --worktree . --wait 300
35
35
  Blocks until a comment arrives or the timeout in seconds elapses, then returns the same envelope.
36
36
  An empty `comments` array means the wait expired with nothing new — that is not an error.
37
37
 
38
+ Run the wait in the background, not in the foreground. A foreground wait holds the turn, so you
39
+ cannot do anything else and the person you are working with cannot talk to you. Backgrounded, the
40
+ harness brings you back the moment a comment lands.
41
+
42
+ Re-arm it after each comment you handle, and keep it running while you work. A reviewer reads at
43
+ their own pace, so comments arrive minutes apart, and the whole point is that they reach you as
44
+ events rather than by you asking. When you finish a piece of work, say you are still listening.
45
+
38
46
  ## Acting on a comment
39
47
 
40
48
  Read `snippet` before opening the file: the reviewer commented on the diff, and the file may have