@eliya-oss/agent-diff 0.1.0-alpha.47 → 0.1.0-alpha.49

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,23 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.49
4
+
5
+ ### Patch Changes
6
+
7
+ - `z` gives the diff the whole window: it clears the review panel as well as the file list, and pressing it again brings back whatever was there before. The key that hides the panel on its own, `a`, is named in the footer instead of only in the sheet of keys.
8
+
9
+ ## 0.1.0-alpha.48
10
+
11
+ ### Patch Changes
12
+
13
+ - `review open` and `review pane` take `--branch`, so an agent handing over a review can name the branch and land the reviewer on its diff rather than on the worktree list. `F` shows the whole file the change sits in and `F` again gives the diff back, returning to whatever context width you had chosen.
14
+
15
+ - A wide terminal now carries the whole review beside the diff: what you have staged, what the agent already has, and what it has answered, in one panel you can walk with `tab` and open with `enter`. When an answer lands while you are reading, the panel names the comment it answers instead of only counting it, so you can tell whether pulling is worth doing before you press `r`.
16
+
17
+ - The wheel scrolls the sheet of keys you are looking at rather than the diff behind it. Reading the branch again with `r` keeps the lines you were looking at where they were, instead of moving them to an edge of the pane.
18
+
19
+ - Writing a comment has a caret: `left` and `right` move it, `alt` with either moves a word, `home` and `end` reach the ends of the line, and typing, `backspace` and `delete` all act where it stands, so fixing a typo near the start of a sentence no longer costs the rest of it.
20
+
3
21
  ## 0.1.0-alpha.47
4
22
 
5
23
  ### Minor Changes
package/dist/main.js CHANGED
@@ -9098,7 +9098,7 @@ var init_init = __esmMin((() => {
9098
9098
  }));
9099
9099
  //#endregion
9100
9100
  //#region src/cli/pane.ts
9101
- var TIMEOUT_MS$1, set, splitters, selfInvocation, ran, split, openPane;
9101
+ var TIMEOUT_MS$1, set, splitters, onBranch, selfInvocation, ran, split, openPane;
9102
9102
  var init_pane = __esmMin((() => {
9103
9103
  init_dist();
9104
9104
  TIMEOUT_MS$1 = 5e3;
@@ -9159,7 +9159,8 @@ var init_pane = __esmMin((() => {
9159
9159
  ]
9160
9160
  }
9161
9161
  ];
9162
- selfInvocation = (repo) => {
9162
+ onBranch = (branch) => branch === void 0 ? [] : ["--branch", branch];
9163
+ selfInvocation = (repo, branch) => {
9163
9164
  const entry = process.argv[1];
9164
9165
  return [
9165
9166
  ...entry === void 0 ? ["adiff"] : [
@@ -9170,17 +9171,18 @@ var init_pane = __esmMin((() => {
9170
9171
  "review",
9171
9172
  "open",
9172
9173
  "--repo",
9173
- repo
9174
+ repo,
9175
+ ...onBranch(branch)
9174
9176
  ];
9175
9177
  };
9176
9178
  ran = (binary, args) => callback$1((resume) => {
9177
9179
  execFile(binary, [...args], { timeout: TIMEOUT_MS$1 }, (cause) => resume(succeed(cause === null)));
9178
9180
  });
9179
- split = fn("Cli.split")(function* (chosen, repo) {
9180
- return yield* ran(chosen.binary, chosen.args(repo, selfInvocation(repo)));
9181
+ split = fn("Cli.split")(function* (chosen, repo, branch) {
9182
+ return yield* ran(chosen.binary, chosen.args(repo, selfInvocation(repo, branch)));
9181
9183
  });
9182
- openPane = fn("Cli.openPane")(function* (repo) {
9183
- const command = `adiff review open --repo ${repo}`;
9184
+ openPane = fn("Cli.openPane")(function* (repo, branch) {
9185
+ const command = `adiff review open --repo ${repo}${branch === void 0 ? "" : ` --branch ${branch}`}`;
9184
9186
  const chosen = splitters.find((candidate) => candidate.present());
9185
9187
  if (chosen === void 0) return {
9186
9188
  opened: false,
@@ -9188,7 +9190,7 @@ var init_pane = __esmMin((() => {
9188
9190
  command
9189
9191
  };
9190
9192
  return {
9191
- opened: yield* split(chosen, repo),
9193
+ opened: yield* split(chosen, repo, branch),
9192
9194
  pane: chosen.pane,
9193
9195
  command
9194
9196
  };
@@ -9199,7 +9201,7 @@ var init_pane = __esmMin((() => {
9199
9201
  init_commands();
9200
9202
  init_init();
9201
9203
  init_pane();
9202
- var version$1 = "0.1.0-alpha.47";
9204
+ var version$1 = "0.1.0-alpha.49";
9203
9205
  //#endregion
9204
9206
  //#region src/cli/upgrade.ts
9205
9207
  var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, REFUSALS, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, runUpgrade, statusOf$1, refusalOf, OFFER, sayFound, sayDone, attempted, upgradeReport;
@@ -9904,7 +9906,7 @@ var init_parse = __esmMin((() => {
9904
9906
  }));
9905
9907
  //#endregion
9906
9908
  //#region src/cli/catalog.ts
9907
- var worktreeOf, repoOf, branchOf, addressing, repo, file, range, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, SET_UP, catalog, commandNames, findCommand, verbsUnder, groups, NEAR, distance, NEAR_ENOUGH, nearestCommand;
9909
+ var worktreeOf, repoOf, branchOf, addressing, repo, opening$1, file, range, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, SET_UP, catalog, commandNames, findCommand, verbsUnder, groups, NEAR, distance, NEAR_ENOUGH, nearestCommand;
9908
9910
  var init_catalog = __esmMin((() => {
9909
9911
  worktreeOf = {
9910
9912
  name: "worktree",
@@ -9935,6 +9937,12 @@ var init_catalog = __esmMin((() => {
9935
9937
  value: "path",
9936
9938
  about: "Repository whose worktrees are reviewed"
9937
9939
  };
9940
+ opening$1 = {
9941
+ name: "branch",
9942
+ required: false,
9943
+ value: "name",
9944
+ about: "Branch to open on, as `branch list` reports it. Without it the review opens on the list"
9945
+ };
9938
9946
  file = {
9939
9947
  name: "file",
9940
9948
  required: true,
@@ -9986,21 +9994,21 @@ var init_catalog = __esmMin((() => {
9986
9994
  },
9987
9995
  {
9988
9996
  name: "review open",
9989
- about: "Open the review terminal. The only command that does not answer in JSON",
9997
+ about: "Open the review terminal. With --branch it opens on that branch rather than the worktree list. The only command that does not answer in JSON",
9990
9998
  group: READ_A_BRANCH,
9991
9999
  addresses: "repo",
9992
10000
  safety: "read",
9993
- options: [repo],
10001
+ options: [repo, opening$1],
9994
10002
  dataKey: "",
9995
- example: "adiff review open --repo ."
10003
+ example: "adiff review open --repo . --branch cdr-1"
9996
10004
  },
9997
10005
  {
9998
10006
  name: "review pane",
9999
- about: "Open the review beside the conversation, in whichever multiplexer is running. Answers with the command when none is",
10007
+ about: "Open the review beside the conversation, in whichever multiplexer is running. With --branch it opens on that branch. Answers with the command when none is",
10000
10008
  group: READ_A_BRANCH,
10001
10009
  addresses: "repo",
10002
10010
  safety: "read",
10003
- options: [repo],
10011
+ options: [repo, opening$1],
10004
10012
  dataKey: "pane",
10005
10013
  example: "adiff review pane --repo ."
10006
10014
  },
@@ -10886,13 +10894,21 @@ var init_tree = __esmMin((() => {
10886
10894
  return node.children.reduce((total, child) => total + filesUnder(tree, child), 0);
10887
10895
  };
10888
10896
  crowdedDirectories = (tree, limit) => tree.nodes.filter((node) => node.kind === "directory" && directFiles(tree, node.id) > limit).map((node) => node.path);
10889
- })), initialState, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, NO_NOTE, noteRows$1, proseRow, proseRows$1, titleRows, clipEnd, FILE_LEAD, fileRows, layerRows, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, treeOf, treeRows, crowdedOf, directoryOfFile, isReviewed, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, editedComment, composeTarget, selectedLines, KEYWORDS, NAME, longestName$1, searchTerm, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, spokenSince, hunkStarts, changeAround, nextUnreviewed, reviewedCount, fileOrder, layerFile, selectionRange;
10897
+ })), nothingReviewed, initialState, BODY_BORDER, TREE_MAX, TREE_MIN, TREE_SHARE, DIFF_MIN, PANEL_WIDTH, DIFF_ROOMY, bodyRoom, treeWidth, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, NO_NOTE, noteRows$1, proseRow, proseRows$1, titleRows, clipEnd, FILE_LEAD, fileRows, layerRows, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, treeOf, treeRows, crowdedOf, directoryOfFile, isReviewed, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, caretAt, drafted, WORD, wordLeft, wordRight, caretByWord, lineStart, lineEnd, caretToEdge, editedComment, composeTarget, selectedLines, KEYWORDS, NAME, longestName$1, searchTerm, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersIn, newerOf, sectionOf, sentEntry, panelEntries, panelEntry, spokenSince, hunkStarts, changeAround, nextUnreviewed, reviewedCount, fileOrder, layerFile, selectionRange;
10890
10898
  var init_model = __esmMin((() => {
10891
10899
  init_dist();
10892
10900
  init_patch();
10893
10901
  init_gaps();
10894
10902
  init_tree();
10903
+ nothingReviewed = {
10904
+ arrived: [],
10905
+ panelOpen: true,
10906
+ panelWas: true,
10907
+ panelIndex: 0,
10908
+ columns: 0
10909
+ };
10895
10910
  initialState = (branches) => ({
10911
+ ...nothingReviewed,
10896
10912
  screen: "branches",
10897
10913
  branches,
10898
10914
  branchIndex: 0,
@@ -10904,6 +10920,7 @@ var init_model = __esmMin((() => {
10904
10920
  anchorRow: 0,
10905
10921
  selecting: false,
10906
10922
  draft: "",
10923
+ caret: 0,
10907
10924
  notice: "",
10908
10925
  waiting: "",
10909
10926
  query: "",
@@ -10918,6 +10935,7 @@ var init_model = __esmMin((() => {
10918
10935
  editing: void 0,
10919
10936
  viewport: 20,
10920
10937
  context: 3,
10938
+ contextWas: 3,
10921
10939
  top: 0,
10922
10940
  source: [],
10923
10941
  full: [],
@@ -10937,6 +10955,22 @@ var init_model = __esmMin((() => {
10937
10955
  matchIndex: 0,
10938
10956
  rail: "tree"
10939
10957
  });
10958
+ BODY_BORDER = 2;
10959
+ TREE_MAX = 34;
10960
+ TREE_MIN = 18;
10961
+ TREE_SHARE = .3;
10962
+ DIFF_MIN = 24;
10963
+ PANEL_WIDTH = 34;
10964
+ DIFF_ROOMY = 56;
10965
+ bodyRoom = (columns) => Math.max(0, columns - 2 - BODY_BORDER);
10966
+ treeWidth = (columns) => {
10967
+ const room = bodyRoom(columns);
10968
+ const wanted = Math.min(TREE_MAX, Math.max(TREE_MIN, Math.floor(room * TREE_SHARE)));
10969
+ return Math.max(0, Math.min(wanted, room - DIFF_MIN));
10970
+ };
10971
+ reviewWidth = () => PANEL_WIDTH;
10972
+ panelFits = (state) => bodyRoom(state.columns) - treeWidth(state.columns) - PANEL_WIDTH >= DIFF_ROOMY;
10973
+ panelShown = (state) => state.screen !== "branches" && state.panelOpen && panelFits(state);
10940
10974
  onLayers = (state) => state.rail === "layers" && state.layers.length > 0;
10941
10975
  selectedLayer = (state) => state.layers[state.layerIndex];
10942
10976
  proseFor = (state, path) => {
@@ -11105,6 +11139,31 @@ var init_model = __esmMin((() => {
11105
11139
  onNone: () => "-",
11106
11140
  onSome: (line) => String(line)
11107
11141
  });
11142
+ caretAt = (state) => Math.max(0, Math.min(state.draft.length, state.caret));
11143
+ drafted = (state) => {
11144
+ const at = caretAt(state);
11145
+ return `${state.draft.slice(0, at)}▌${state.draft.slice(at)}`;
11146
+ };
11147
+ WORD = /[\p{L}\p{N}_]/u;
11148
+ wordLeft = (draft, from) => {
11149
+ let at = from;
11150
+ while (at > 0 && !WORD.test(draft[at - 1] ?? "")) at -= 1;
11151
+ while (at > 0 && WORD.test(draft[at - 1] ?? "")) at -= 1;
11152
+ return at;
11153
+ };
11154
+ wordRight = (draft, from) => {
11155
+ let at = from;
11156
+ while (at < draft.length && !WORD.test(draft[at] ?? "")) at += 1;
11157
+ while (at < draft.length && WORD.test(draft[at] ?? "")) at += 1;
11158
+ return at;
11159
+ };
11160
+ caretByWord = (state, delta) => delta < 0 ? wordLeft(state.draft, caretAt(state)) : wordRight(state.draft, caretAt(state));
11161
+ lineStart = (draft, at) => draft.lastIndexOf("\n", at - 1) + 1;
11162
+ lineEnd = (draft, at) => {
11163
+ const found = draft.indexOf("\n", at);
11164
+ return found === -1 ? draft.length : found;
11165
+ };
11166
+ caretToEdge = (state, edge) => edge === "start" ? lineStart(state.draft, caretAt(state)) : lineEnd(state.draft, caretAt(state));
11108
11167
  editedComment = (state) => state.editing === void 0 ? void 0 : state.pending.find((entry) => entry.id === state.editing);
11109
11168
  composeTarget = (state) => {
11110
11169
  const edited = editedComment(state);
@@ -11198,6 +11257,8 @@ var init_model = __esmMin((() => {
11198
11257
  60,
11199
11258
  WHOLE_FILE
11200
11259
  ];
11260
+ wholeFileOff = (state) => state.context < WHOLE_FILE;
11261
+ contextToggled = (state) => wholeFileOff(state) ? WHOLE_FILE : state.contextWas;
11201
11262
  layerContext = (current, delta) => {
11202
11263
  const at = CONTEXT_STEPS.indexOf(current);
11203
11264
  const next = Math.max(0, Math.min(CONTEXT_STEPS.length - 1, (at === -1 ? 0 : at) + delta));
@@ -11250,6 +11311,36 @@ var init_model = __esmMin((() => {
11250
11311
  };
11251
11312
  filesWithComments = (state) => state.patches.flatMap((patch, index) => [...state.pending, ...state.sent].some((entry) => entry.file === patch.path) ? [index] : []);
11252
11313
  answerCount = (comments) => comments.reduce((total, entry) => total + (entry.answers?.length ?? 0), 0);
11314
+ answersIn = (comment) => comment.answers?.length ?? 0;
11315
+ newerOf = (state, comment) => {
11316
+ if (comment.id === void 0) return comment;
11317
+ const later = state.arrived.find((entry) => entry.id === comment.id);
11318
+ if (later === void 0) return comment;
11319
+ return answersIn(later) > answersIn(comment) ? later : comment;
11320
+ };
11321
+ sectionOf = (comment) => answersIn(comment) > 0 || comment.settled === true ? "answered" : "with";
11322
+ sentEntry = (state, comment) => {
11323
+ const newer = newerOf(state, comment);
11324
+ return {
11325
+ section: sectionOf(newer),
11326
+ comment: newer,
11327
+ fresh: newer !== comment
11328
+ };
11329
+ };
11330
+ panelEntries = (state) => {
11331
+ const staged = state.pending.map((comment) => ({
11332
+ section: "staged",
11333
+ comment,
11334
+ fresh: false
11335
+ }));
11336
+ const delivered = state.sent.map((comment) => sentEntry(state, comment));
11337
+ return [
11338
+ ...staged,
11339
+ ...delivered.filter((entry) => entry.section === "with"),
11340
+ ...delivered.filter((entry) => entry.section === "answered")
11341
+ ];
11342
+ };
11343
+ panelEntry = (state) => panelEntries(state)[state.panelIndex];
11253
11344
  spokenSince = (seen, now) => Math.max(0, answerCount(now) - answerCount(seen));
11254
11345
  hunkStarts = (state) => {
11255
11346
  const patch = selectedPatch(state);
@@ -11480,6 +11571,12 @@ var init_command = __esmMin((() => {
11480
11571
  keys: ["-", "_"],
11481
11572
  screens: ["review"]
11482
11573
  }),
11574
+ command({
11575
+ action: "context.whole",
11576
+ title: "Show the whole file, or go back to the diff",
11577
+ keys: ["F"],
11578
+ screens: ["review"]
11579
+ }),
11483
11580
  command({
11484
11581
  action: "comment.next",
11485
11582
  title: "Next comment",
@@ -11528,9 +11625,17 @@ var init_command = __esmMin((() => {
11528
11625
  keys: ["tab"],
11529
11626
  screens: ["review"]
11530
11627
  }),
11628
+ command({
11629
+ action: "panel.toggle",
11630
+ title: "Show or hide the review panel",
11631
+ category: "Review",
11632
+ keys: ["a"],
11633
+ screens: ["review"],
11634
+ hint: "review"
11635
+ }),
11531
11636
  command({
11532
11637
  action: "nav.zoom",
11533
- title: "Hide the file list",
11638
+ title: "Hide the file list and the review panel",
11534
11639
  category: "General",
11535
11640
  keys: ["z", "\\"],
11536
11641
  screens: ["review"]
@@ -11929,7 +12034,7 @@ var init_match = __esmMin((() => {
11929
12034
  }));
11930
12035
  //#endregion
11931
12036
  //#region src/tui/reduce.ts
11932
- var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, draggedTo, atRow, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, movePending, moveLayer, inRail, layerDown, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, moveFile, selectHunk, swapEnds, atBranch, startSelection, openCompose, goBack, walkMatches, openPalette, openKeys, movePalette, paletteMatches, offered, paletteChoice, transitions, reduce, atFile, withContext, withFull, revealsAfter, gapOpened, withPending, panBy, withSent, withLayers, withPulls, withSilentForge, withBranches, withSource, withVouched, restoredTo, withPatches, typed, backspaced, paletteMoved, paletteClosed, withWaiting, withMatches, withNoticeHere, withNotice;
12037
+ var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, draggedTo, atRow, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, movePending, moveLayer, inRail, movePanel, layerDown, nextFocus, togglePanel, packedAway, zoom, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, moveFile, selectHunk, swapEnds, atBranch, startSelection, openCompose, goBack, walkMatches, openPalette, openKeys, movePalette, paletteMatches, offered, paletteChoice, transitions, reduce, atFile, withContext, withFull, revealsAfter, gapOpened, withPending, panBy, withSent, withArrived, withColumns, withLayers, withPulls, withSilentForge, withBranches, withSource, withVouched, restoredTo, withPatches, inserted, typed, backspaced, deleted, caretMoved, caretJumped, caretHomed, withDraft, paletteMoved, paletteClosed, withWaiting, withMatches, withNoticeHere, withNotice;
11933
12038
  var init_reduce = __esmMin((() => {
11934
12039
  init_dist();
11935
12040
  init_patch();
@@ -12058,7 +12163,43 @@ var init_reduce = __esmMin((() => {
12058
12163
  };
12059
12164
  };
12060
12165
  inRail = (state, delta) => onLayers(state) ? moveLayer(state, delta) : moveFile(state, delta);
12061
- layerDown = (state, delta) => state.focus === "tree" ? inRail(state, delta) : stepStop(state, delta);
12166
+ movePanel = (state, delta) => ({
12167
+ ...state,
12168
+ panelIndex: clamp(state.panelIndex + delta, 0, Math.max(0, panelEntries(state).length - 1))
12169
+ });
12170
+ layerDown = (state, delta) => {
12171
+ if (state.focus === "tree") return inRail(state, delta);
12172
+ if (state.focus === "review") return movePanel(state, delta);
12173
+ return stepStop(state, delta);
12174
+ };
12175
+ nextFocus = (state) => {
12176
+ if (state.focus === "diff") return "tree";
12177
+ if (state.focus === "tree") return panelShown(state) ? "review" : "diff";
12178
+ return "diff";
12179
+ };
12180
+ togglePanel = (state) => {
12181
+ if (!state.panelOpen && !panelFits(state)) return withNotice(state, "the terminal is too narrow for the review panel");
12182
+ const panelOpen = !state.panelOpen;
12183
+ return {
12184
+ ...state,
12185
+ panelOpen,
12186
+ panelWas: panelOpen,
12187
+ focus: panelOpen ? state.focus : "diff",
12188
+ panelIndex: 0
12189
+ };
12190
+ };
12191
+ packedAway = (state) => !state.navOpen && !state.panelOpen;
12192
+ zoom = (state) => packedAway(state) ? {
12193
+ ...state,
12194
+ navOpen: true,
12195
+ panelOpen: state.panelWas,
12196
+ focus: "diff"
12197
+ } : {
12198
+ ...state,
12199
+ navOpen: false,
12200
+ panelOpen: false,
12201
+ focus: "diff"
12202
+ };
12062
12203
  toggleRail = (state) => {
12063
12204
  if (state.layers.length === 0) return withNotice(state, "no layers for this branch");
12064
12205
  if (state.rail === "layers") return {
@@ -12143,6 +12284,7 @@ var init_reduce = __esmMin((() => {
12143
12284
  ...state,
12144
12285
  screen: "compose",
12145
12286
  draft: "",
12287
+ caret: 0,
12146
12288
  anchorRow: state.selecting ? state.anchorRow : state.cursor
12147
12289
  };
12148
12290
  };
@@ -12160,7 +12302,8 @@ var init_reduce = __esmMin((() => {
12160
12302
  if (state.screen === "report") return {
12161
12303
  ...state,
12162
12304
  screen: state.returnTo,
12163
- draft: ""
12305
+ draft: "",
12306
+ caret: 0
12164
12307
  };
12165
12308
  if (state.screen === "palette") return {
12166
12309
  ...state,
@@ -12174,7 +12317,8 @@ var init_reduce = __esmMin((() => {
12174
12317
  if (state.screen === "compose") return {
12175
12318
  ...state,
12176
12319
  screen: "review",
12177
- draft: ""
12320
+ draft: "",
12321
+ caret: 0
12178
12322
  };
12179
12323
  if (state.selecting) return {
12180
12324
  ...state,
@@ -12226,6 +12370,7 @@ var init_reduce = __esmMin((() => {
12226
12370
  "cursor.pageUp": (state) => moveCursor(state, -Math.max(1, Math.floor(state.viewport / 2))),
12227
12371
  "context.more": (state) => state,
12228
12372
  "context.less": (state) => state,
12373
+ "context.whole": (state) => state,
12229
12374
  "comment.next": (state) => layerComment(state, 1),
12230
12375
  "comment.prev": (state) => layerComment(state, -1),
12231
12376
  "hunk.next": (state) => layerHunk(state, 1),
@@ -12245,20 +12390,14 @@ var init_reduce = __esmMin((() => {
12245
12390
  "pending.drop": (state) => state,
12246
12391
  "pending.next": (state) => movePending(state, 1),
12247
12392
  "pending.prev": (state) => movePending(state, -1),
12248
- "compose.newline": (state) => ({
12249
- ...state,
12250
- draft: `${state.draft}\n`
12251
- }),
12393
+ "compose.newline": (state) => inserted(state, "\n"),
12252
12394
  "focus.toggle": (state) => ({
12253
12395
  ...state,
12254
- focus: state.focus === "diff" ? "tree" : "diff",
12396
+ focus: nextFocus(state),
12255
12397
  navOpen: true
12256
12398
  }),
12257
- "nav.zoom": (state) => ({
12258
- ...state,
12259
- navOpen: !state.navOpen,
12260
- focus: "diff"
12261
- }),
12399
+ "panel.toggle": togglePanel,
12400
+ "nav.zoom": zoom,
12262
12401
  "wrap.toggle": (state) => ({
12263
12402
  ...state,
12264
12403
  wrap: !state.wrap,
@@ -12278,6 +12417,7 @@ var init_reduce = __esmMin((() => {
12278
12417
  ...state,
12279
12418
  screen: "report",
12280
12419
  draft: "",
12420
+ caret: 0,
12281
12421
  returnTo: state.screen
12282
12422
  }),
12283
12423
  "report.send": (state) => state,
@@ -12305,6 +12445,7 @@ var init_reduce = __esmMin((() => {
12305
12445
  withContext = (state, context, patches, cursor) => ({
12306
12446
  ...state,
12307
12447
  context,
12448
+ contextWas: state.context < 1e5 ? state.context : state.contextWas,
12308
12449
  patches,
12309
12450
  revealed: [],
12310
12451
  cursor,
@@ -12353,7 +12494,17 @@ var init_reduce = __esmMin((() => {
12353
12494
  };
12354
12495
  withSent = (state, sent) => ({
12355
12496
  ...state,
12356
- sent
12497
+ sent,
12498
+ arrived: [],
12499
+ panelIndex: 0
12500
+ });
12501
+ withArrived = (state, arrived) => ({
12502
+ ...state,
12503
+ arrived
12504
+ });
12505
+ withColumns = (state, columns) => ({
12506
+ ...state,
12507
+ columns
12357
12508
  });
12358
12509
  withLayers = (state, told) => {
12359
12510
  const layers = told.layers;
@@ -12395,14 +12546,17 @@ var init_reduce = __esmMin((() => {
12395
12546
  ...state,
12396
12547
  vouched
12397
12548
  });
12398
- restoredTo = (state, path, line) => {
12549
+ restoredTo = (state, path, line, offset) => {
12399
12550
  const index = state.patches.findIndex((patch) => patch.path === path);
12400
12551
  const patch = state.patches[index];
12401
12552
  if (patch === void 0) return state;
12553
+ const cursor = line === void 0 ? 0 : rowAtSourceLine(patch, line);
12554
+ const top = clamp(cursor - Math.max(0, offset), 0, Math.max(0, patch.rows.length - 1));
12402
12555
  return withCursorVisible({
12403
12556
  ...state,
12404
12557
  patchIndex: index,
12405
- cursor: line === void 0 ? 0 : rowAtSourceLine(patch, line)
12558
+ cursor,
12559
+ top
12406
12560
  });
12407
12561
  };
12408
12562
  withPatches = (state, patches) => ({
@@ -12421,22 +12575,59 @@ var init_reduce = __esmMin((() => {
12421
12575
  anchorRow: 0,
12422
12576
  selecting: false
12423
12577
  });
12578
+ inserted = (state, text) => {
12579
+ const at = caretAt(state);
12580
+ return {
12581
+ ...state,
12582
+ draft: `${state.draft.slice(0, at)}${text}${state.draft.slice(at)}`,
12583
+ caret: at + text.length
12584
+ };
12585
+ };
12424
12586
  typed = (state, character) => state.screen === "palette" ? {
12425
12587
  ...state,
12426
12588
  query: `${state.query}${character}`,
12427
12589
  paletteIndex: 0
12428
- } : {
12429
- ...state,
12430
- draft: `${state.draft}${character}`
12590
+ } : inserted(state, character);
12591
+ backspaced = (state) => {
12592
+ if (state.screen === "palette") return {
12593
+ ...state,
12594
+ query: state.query.slice(0, -1),
12595
+ paletteIndex: 0
12596
+ };
12597
+ const at = caretAt(state);
12598
+ if (at === 0) return state;
12599
+ return {
12600
+ ...state,
12601
+ draft: `${state.draft.slice(0, at - 1)}${state.draft.slice(at)}`,
12602
+ caret: at - 1
12603
+ };
12431
12604
  };
12432
- backspaced = (state) => state.screen === "palette" ? {
12605
+ deleted = (state) => {
12606
+ const at = caretAt(state);
12607
+ if (at >= state.draft.length) return state;
12608
+ return {
12609
+ ...state,
12610
+ draft: `${state.draft.slice(0, at)}${state.draft.slice(at + 1)}`,
12611
+ caret: at
12612
+ };
12613
+ };
12614
+ caretMoved = (state, delta) => ({
12433
12615
  ...state,
12434
- query: state.query.slice(0, -1),
12435
- paletteIndex: 0
12436
- } : {
12616
+ caret: clamp(caretAt(state) + delta, 0, state.draft.length)
12617
+ });
12618
+ caretJumped = (state, delta) => ({
12437
12619
  ...state,
12438
- draft: state.draft.slice(0, -1)
12439
- };
12620
+ caret: caretByWord(state, delta)
12621
+ });
12622
+ caretHomed = (state, edge) => ({
12623
+ ...state,
12624
+ caret: caretToEdge(state, edge)
12625
+ });
12626
+ withDraft = (state, draft) => ({
12627
+ ...state,
12628
+ draft,
12629
+ caret: draft.length
12630
+ });
12440
12631
  paletteMoved = (state, delta) => movePalette(state, delta);
12441
12632
  paletteClosed = (state) => ({
12442
12633
  ...state,
@@ -12463,6 +12654,7 @@ var init_reduce = __esmMin((() => {
12463
12654
  ...state,
12464
12655
  screen: "review",
12465
12656
  draft: "",
12657
+ caret: 0,
12466
12658
  selecting: false,
12467
12659
  notice
12468
12660
  });
@@ -12750,6 +12942,9 @@ var init_diffview = __esmMin((() => {
12750
12942
  pinNode() {
12751
12943
  return this.pinBox;
12752
12944
  }
12945
+ pinRows() {
12946
+ return this.pinBox.height;
12947
+ }
12753
12948
  noteRoom() {
12754
12949
  return Math.max(NOTE_MIN, this.code.width - this.gutterWidth() - 3);
12755
12950
  }
@@ -12903,12 +13098,23 @@ var init_diffview = __esmMin((() => {
12903
13098
  if (sources.length === 0) return false;
12904
13099
  return visual > 0 && sources[visual] === sources[visual - 1];
12905
13100
  }
13101
+ lineOfRow(row) {
13102
+ if (this.starts.size === 0) return void 0;
13103
+ for (let at = Math.max(0, row); at >= 0; at -= 1) {
13104
+ const line = this.starts.get(at);
13105
+ if (line !== void 0) return line;
13106
+ }
13107
+ return 0;
13108
+ }
13109
+ visualOfRow(row) {
13110
+ const line = this.lineOfRow(row);
13111
+ return line === void 0 ? void 0 : this.visualOf(line);
13112
+ }
12906
13113
  scrollTo(row, cursor) {
12907
13114
  const highest = Math.max(0, this.tallest() - this.rows());
12908
- const wanted = this.visualOf(this.starts.get(row) ?? row);
12909
- const line = this.starts.get(cursor);
12910
- const at = line === void 0 ? void 0 : this.visualOf(line);
12911
- const kept = cursor >= row && cursor < row + this.rows() && at !== void 0 ? Math.max(wanted, at - this.rows() + 1) : wanted;
13115
+ const wanted = this.visualOfRow(row) ?? row;
13116
+ const at = this.visualOfRow(cursor);
13117
+ const kept = at !== void 0 && at >= wanted ? Math.max(wanted, at - this.rows() + 1) : wanted;
12912
13118
  const clamped = Math.max(0, Math.min(highest, kept));
12913
13119
  if (this.code.scrollY !== clamped) this.code.scrollY = clamped;
12914
13120
  return clamped;
@@ -13071,7 +13277,7 @@ var init_diffview = __esmMin((() => {
13071
13277
  }));
13072
13278
  //#endregion
13073
13279
  //#region src/tui/render.ts
13074
- var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, COMPOSE_PAD, COMPOSE_MIN_TEXT, reportActions, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, TREE_MAX, TREE_MIN, TREE_SHARE, DIFF_MIN, BODY_BORDER, PANE_CHROME, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_TAIL, EMPTY_LIST, MODAL_MARGIN, bodyRoom, treeWidth, shareOf, homeWidth, longestName, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut, STICKY_MAX, pickPaint, SELECTION, CURSOR, ACCENT, GAP_PAINT, bar, makeList, makeDiffPane, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, makePaletteParts, makePendingParts, makeChoices, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, makeComposeParts, makeCompose, clip, clipHead, clipMiddle, clipPath, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, contextLabel, nameRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, stateCell, branchCells, headerParts, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, STEP_NUMBER, STEP_LEAD, NOTE_LEAD, STEP_GAP, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerFold, layerHead, layerText, layerPaint, Screen;
13280
+ var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, COMPOSE_PAD, COMPOSE_MIN_TEXT, reportActions, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_TAIL, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut, STICKY_MAX, pickPaint, SELECTION, CURSOR, ACCENT, GAP_PAINT, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, makePaletteParts, makePendingParts, makeChoices, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, makeComposeParts, makeCompose, clip, clipHead, clipMiddle, clipPath, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, contextLabel, nameRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, stateCell, branchCells, headerParts, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, STEP_NUMBER, STEP_LEAD, NOTE_LEAD, STEP_GAP, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerFold, layerHead, layerText, layerPaint, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, panelMark, panelWhere, panelBody, panelPair, panelSection, PULL_HINT, panelText, Screen;
13075
13281
  var init_render = __esmMin((() => {
13076
13282
  init_command();
13077
13283
  init_patch();
@@ -13106,23 +13312,12 @@ var init_render = __esmMin((() => {
13106
13312
  PANEL_FOOT = 2;
13107
13313
  PANEL_QUARTER = 4;
13108
13314
  PANEL_FIFTH = 5;
13109
- TREE_MAX = 34;
13110
- TREE_MIN = 18;
13111
- TREE_SHARE = .3;
13112
- DIFF_MIN = 24;
13113
- BODY_BORDER = 2;
13114
13315
  PANE_CHROME = 3;
13115
13316
  BRANCH_WIDTH = 82;
13116
13317
  BRANCH_NAME_MIN = 12;
13117
13318
  BRANCH_TAIL = 45;
13118
13319
  EMPTY_LIST = " nothing to review. No worktree differs from the branch it started from.";
13119
13320
  MODAL_MARGIN = 4;
13120
- bodyRoom = (width) => Math.max(0, width - 2 - BODY_BORDER);
13121
- treeWidth = (width) => {
13122
- const room = bodyRoom(width);
13123
- const wanted = Math.min(TREE_MAX, Math.max(TREE_MIN, Math.floor(room * TREE_SHARE)));
13124
- return Math.max(0, Math.min(wanted, room - DIFF_MIN));
13125
- };
13126
13321
  shareOf = (width, least) => Math.max(least, Math.min(PANEL_MAX, Math.floor(width * PANEL_SHARE)));
13127
13322
  homeWidth = (width, longest) => Math.max(0, Math.min(width - 2, Math.min(PANEL_MAX, Math.max(BRANCH_WIDTH, longest + BRANCH_TAIL))));
13128
13323
  longestName = (state) => Math.max(0, ...state.branches.map((branch) => branch.branch.length));
@@ -13196,6 +13391,31 @@ var init_render = __esmMin((() => {
13196
13391
  overflow: "hidden",
13197
13392
  visible: false
13198
13393
  });
13394
+ makePanel = (renderer) => {
13395
+ const pane = new BoxRenderable(renderer, {
13396
+ id: "panel-pane",
13397
+ width: 0,
13398
+ flexShrink: 0,
13399
+ flexDirection: "column",
13400
+ minHeight: 0,
13401
+ overflow: "hidden",
13402
+ border: ["left"],
13403
+ borderColor: palette.rule,
13404
+ visible: false
13405
+ });
13406
+ const text = new TextRenderable(renderer, {
13407
+ id: "panel",
13408
+ content: "",
13409
+ fg: palette.ink,
13410
+ flexGrow: 1,
13411
+ wrapMode: "none"
13412
+ });
13413
+ pane.add(text);
13414
+ return {
13415
+ pane,
13416
+ text
13417
+ };
13418
+ };
13199
13419
  makeListParts = (renderer) => {
13200
13420
  const pane = makeList(renderer);
13201
13421
  const text = makeListText(renderer);
@@ -13594,12 +13814,79 @@ var init_render = __esmMin((() => {
13594
13814
  if (row.kind === "note") return palette.faint;
13595
13815
  return row.index === state.layerIndex ? palette.ink : palette.muted;
13596
13816
  };
13817
+ PANEL_TITLES = {
13818
+ staged: "Staged",
13819
+ with: "With the agent",
13820
+ answered: "Answered"
13821
+ };
13822
+ PANEL_ORDER = [
13823
+ "staged",
13824
+ "with",
13825
+ "answered"
13826
+ ];
13827
+ PANEL_LEAD = 3;
13828
+ PANEL_EMPTY = "No comment on this branch yet.";
13829
+ panelMark = (state, at) => {
13830
+ if (at !== state.panelIndex) return " ";
13831
+ return state.focus === "review" ? "▸" : "·";
13832
+ };
13833
+ panelWhere = (entry, room) => {
13834
+ const where = `:${entry.comment.end}`;
13835
+ return `${clipPath(entry.comment.file, Math.max(4, room - where.length))}${where}`;
13836
+ };
13837
+ panelBody = (entry) => entry.comment.body.split("\n").find((line) => line.trim().length > 0) ?? "";
13838
+ panelPair = (state, placed, room) => {
13839
+ const { entry } = placed;
13840
+ return [{
13841
+ text: `${`${panelMark(state, placed.at)}${entry.fresh ? marks().comment : " "} `}${panelWhere(entry, room - PANEL_LEAD)}`,
13842
+ tone: palette.ink
13843
+ }, {
13844
+ text: ` ${clip(panelBody(entry), Math.max(4, room - PANEL_LEAD))}`,
13845
+ tone: palette.muted
13846
+ }];
13847
+ };
13848
+ panelSection = (state, placed, section, room) => {
13849
+ const here = placed.filter((one) => one.entry.section === section);
13850
+ if (here.length === 0) return [];
13851
+ return [
13852
+ {
13853
+ text: "",
13854
+ tone: palette.faint
13855
+ },
13856
+ {
13857
+ text: `${PANEL_TITLES[section]} ${here.length}`,
13858
+ tone: palette.faint
13859
+ },
13860
+ ...here.flatMap((one) => panelPair(state, one, room))
13861
+ ];
13862
+ };
13863
+ PULL_HINT = "answered, press r to pull";
13864
+ panelText = (state, room) => {
13865
+ const placed = panelEntries(state).map((entry, at) => ({
13866
+ entry,
13867
+ at
13868
+ }));
13869
+ const fresh = placed.filter((one) => one.entry.fresh).length;
13870
+ const banner = fresh === 0 ? [] : [{
13871
+ text: clip(`${fresh} ${PULL_HINT}`, room),
13872
+ tone: palette.attention
13873
+ }];
13874
+ const sections = PANEL_ORDER.flatMap((section) => panelSection(state, placed, section, room));
13875
+ const body = sections.slice(sections[0]?.text === "" ? 1 : 0);
13876
+ const lines = body.length === 0 ? [{
13877
+ text: PANEL_EMPTY,
13878
+ tone: palette.muted
13879
+ }] : body;
13880
+ return new StyledText([...banner, ...lines].map((line) => fg(line.tone)(`${line.text}\n`)));
13881
+ };
13597
13882
  Screen = class {
13598
13883
  header;
13599
13884
  body;
13600
13885
  listPane;
13601
13886
  list;
13602
13887
  diffPane;
13888
+ panelPane;
13889
+ panel;
13603
13890
  scrim;
13604
13891
  gutter;
13605
13892
  diffScroll;
@@ -13654,6 +13941,9 @@ var init_render = __esmMin((() => {
13654
13941
  this.landing = home.path;
13655
13942
  this.landingKeys = home.keys;
13656
13943
  this.diffPane = makeDiffPane(renderer);
13944
+ const panel = makePanel(renderer);
13945
+ this.panelPane = panel.pane;
13946
+ this.panel = panel.text;
13657
13947
  this.diffScroll = makeScroll(renderer);
13658
13948
  this.view = new DiffView(renderer);
13659
13949
  const inside = makeComposeParts(renderer);
@@ -13680,8 +13970,17 @@ var init_render = __esmMin((() => {
13680
13970
  this.foundChoices = modals.found.choices;
13681
13971
  this.assemble(renderer);
13682
13972
  }
13973
+ wheelOnSheet(box) {
13974
+ box.onMouseScroll = (event) => {
13975
+ const way = event.scroll?.direction;
13976
+ if (way !== "up" && way !== "down") return;
13977
+ this.mouse?.onScroll(way === "down" ? 1 : -1);
13978
+ };
13979
+ }
13683
13980
  listen(mouse) {
13684
13981
  this.mouse = mouse;
13982
+ this.wheelOnSheet(this.keys);
13983
+ this.wheelOnSheet(this.palette);
13685
13984
  this.view.listenTo({
13686
13985
  scroll: (delta) => this.mouse?.onScroll(delta),
13687
13986
  pan: (delta) => this.mouse?.onPan(delta),
@@ -13710,7 +14009,8 @@ var init_render = __esmMin((() => {
13710
14009
  return this.view.room();
13711
14010
  }
13712
14011
  diffRows() {
13713
- return Math.max(1, this.diffScroll.height);
14012
+ const pane = this.diffPane.height - this.view.pinRows();
14013
+ return Math.max(1, pane > 0 ? pane : this.diffScroll.height);
13714
14014
  }
13715
14015
  update(state) {
13716
14016
  this.shown = state;
@@ -13730,6 +14030,7 @@ var init_render = __esmMin((() => {
13730
14030
  this.landingKeys.content = this.homeKeys(state);
13731
14031
  this.diffPane.visible = state.screen !== "branches" && !atHome(state);
13732
14032
  if (this.diffPane.visible) this.paintDiff(state);
14033
+ this.paintPanel(state);
13733
14034
  this.paintPane(state);
13734
14035
  this.paintCompose(state);
13735
14036
  this.paintPalette(state);
@@ -13811,6 +14112,17 @@ var init_render = __esmMin((() => {
13811
14112
  paneRoom() {
13812
14113
  return treeWidth(this.renderer.width);
13813
14114
  }
14115
+ columns() {
14116
+ return this.renderer.width;
14117
+ }
14118
+ paintPanel(state) {
14119
+ const shown = this.diffPane.visible && panelShown(state);
14120
+ this.panelPane.visible = shown;
14121
+ this.panelPane.width = shown ? reviewWidth() : 0;
14122
+ this.panelPane.paddingLeft = shown ? 1 : 0;
14123
+ this.panelPane.paddingTop = shown ? 1 : 0;
14124
+ this.panel.content = shown ? panelText(state, reviewWidth() - PANE_CHROME) : "";
14125
+ }
13814
14126
  listText(state) {
13815
14127
  if (atHome(state)) return this.branchTable(state);
13816
14128
  if (onLayers(state)) return this.layerRail(state);
@@ -13842,7 +14154,7 @@ var init_render = __esmMin((() => {
13842
14154
  this.view.setWrap(state.wrap);
13843
14155
  this.view.setPan(state.pan);
13844
14156
  this.view.show(patch, notesFor(state, patch.path), gapRowSet(shown), proseFor(state, patch.path));
13845
- this.view.fit(this.diffScroll.height);
14157
+ this.view.fit(this.diffRows());
13846
14158
  const height = this.view.rows();
13847
14159
  const top = this.view.scrollTo(state.top, state.cursor);
13848
14160
  this.lastTop = top;
@@ -13880,6 +14192,7 @@ var init_render = __esmMin((() => {
13880
14192
  this.watchChips();
13881
14193
  this.body.add(this.listPane);
13882
14194
  this.body.add(this.diffPane);
14195
+ this.body.add(this.panelPane);
13883
14196
  stack(this.compose, [
13884
14197
  this.composeTitle,
13885
14198
  this.composeBody,
@@ -14035,7 +14348,7 @@ var init_render = __esmMin((() => {
14035
14348
  const lines = laidOut([
14036
14349
  "What went wrong? Everything on screen is attached for you.",
14037
14350
  "",
14038
- `${state.draft}▌`
14351
+ drafted(state)
14039
14352
  ], room.text);
14040
14353
  this.composeTitle.content = "Report a bug";
14041
14354
  this.composeBody.content = lines.join("\n");
@@ -14092,7 +14405,7 @@ var init_render = __esmMin((() => {
14092
14405
  const more = selectedLineCount(state) - snippet.length;
14093
14406
  const tail = more > 0 ? [` … ${more} more lines`] : [];
14094
14407
  const quoted = [...snippet, ...tail].map((line) => clip(line, room.text));
14095
- const written = laidOut(`${state.draft}▌`.split("\n"), room.text);
14408
+ const written = laidOut(drafted(state).split("\n"), room.text);
14096
14409
  const lines = [
14097
14410
  ...quoted,
14098
14411
  "",
@@ -14126,6 +14439,7 @@ var init_display = __esmMin((() => {
14126
14439
  paint: paintWith(screen),
14127
14440
  rows: sync(() => screen.viewportRows()),
14128
14441
  room: sync(() => screen.noteRoom()),
14442
+ columns: sync(() => screen.columns()),
14129
14443
  listen: listenWith(screen)
14130
14444
  });
14131
14445
  displayOn = (renderer, repo) => sync$1(Display)(() => shapeOf(new Screen(renderer, repo)));
@@ -14205,7 +14519,7 @@ var init_upgrade = __esmMin((() => {
14205
14519
  return due ? `adiff ${latest} is out · adiff upgrade` : "";
14206
14520
  }).pipe(withSpan("Tui.upgradeHint"));
14207
14521
  upgradeHint = worded.pipe(orElseSucceed(() => ""));
14208
- })), PRINTABLE, KEY_HISTORY, copyToClipboard, asKey, openedPull, keyName, App, settledPath, launch, told, untilDestroyed, runOn, runTui;
14522
+ })), PRINTABLE, KEY_HISTORY, copyToClipboard, asKey, openedPull, byWord, WORD_STEP, caretSideways, caretFor, LISTENS, listens, keyName, App, settledPath, openingOn, launch, told, untilDestroyed, runOn, runTui;
14209
14523
  var init_app = __esmMin((() => {
14210
14524
  init_dist();
14211
14525
  init_report();
@@ -14243,6 +14557,27 @@ var init_app = __esmMin((() => {
14243
14557
  if (!opened) return "could not reach the pull request";
14244
14558
  return state.length === 0 ? "opened the pull request" : `opened the ${state} pull request`;
14245
14559
  };
14560
+ byWord = (key) => key.option || key.meta || key.ctrl;
14561
+ WORD_STEP = {
14562
+ b: -1,
14563
+ f: 1
14564
+ };
14565
+ caretSideways = (state, key) => {
14566
+ const step = key.name === "left" ? -1 : key.name === "right" ? 1 : 0;
14567
+ if (step === 0) return void 0;
14568
+ return byWord(key) ? caretJumped(state, step) : caretMoved(state, step);
14569
+ };
14570
+ caretFor = (state, key) => {
14571
+ const sideways = caretSideways(state, key);
14572
+ if (sideways !== void 0) return sideways;
14573
+ const word = byWord(key) ? WORD_STEP[key.name] : void 0;
14574
+ if (word !== void 0) return caretJumped(state, word);
14575
+ if (key.name === "home") return caretHomed(state, "start");
14576
+ if (key.name === "end") return caretHomed(state, "end");
14577
+ return key.name === "delete" ? deleted(state) : void 0;
14578
+ };
14579
+ LISTENS = /* @__PURE__ */ new Set(["keys", "palette"]);
14580
+ listens = (screen) => LISTENS.has(screen);
14246
14581
  keyName = (key) => {
14247
14582
  const base = key.shift && key.name.length === 1 ? key.name.toUpperCase() : key.name;
14248
14583
  return key.ctrl ? `ctrl+${base}` : base;
@@ -14315,7 +14650,7 @@ var init_app = __esmMin((() => {
14315
14650
  const sent = yield* this.loadSent(branch.branch);
14316
14651
  const said = spokenSince(this.state.sent, sent);
14317
14652
  if (said === 0) return;
14318
- this.commit(withWaiting(this.state, `${said} answered · press r`));
14653
+ this.commit(withWaiting(withArrived(this.state, sent), `${said} answered · press r`));
14319
14654
  });
14320
14655
  }
14321
14656
  noticeOnList() {
@@ -14401,6 +14736,10 @@ var init_app = __esmMin((() => {
14401
14736
  if (down === 0 && across === 0) return;
14402
14737
  this.wheel = 0;
14403
14738
  this.sideways = 0;
14739
+ if (listens(this.state.screen)) {
14740
+ if (down !== 0) this.commit(paletteMoved(this.state, down));
14741
+ return;
14742
+ }
14404
14743
  const moved = down === 0 ? this.measured() : scrolled(this.measured(), down);
14405
14744
  this.commit(across === 0 ? moved : panBy(moved, across));
14406
14745
  }
@@ -14413,6 +14752,11 @@ var init_app = __esmMin((() => {
14413
14752
  });
14414
14753
  return;
14415
14754
  }
14755
+ const columns = runSync(this.display.columns);
14756
+ if (columns !== this.state.columns) {
14757
+ this.commit(withColumns(this.state, columns));
14758
+ return;
14759
+ }
14416
14760
  const room = runSync(this.display.room);
14417
14761
  if (room === this.roomed) return;
14418
14762
  this.roomed = room;
@@ -14472,6 +14816,7 @@ var init_app = __esmMin((() => {
14472
14816
  quit: () => sync(() => this.renderer.destroy()),
14473
14817
  "branch.open": () => this.openBranch(),
14474
14818
  "branch.pull": () => this.showPull(),
14819
+ "compose.open": () => this.compose(),
14475
14820
  "compose.submit": () => this.send(),
14476
14821
  "compose.stage": () => this.stage(),
14477
14822
  "palette.run": () => this.runChoice(),
@@ -14499,6 +14844,7 @@ var init_app = __esmMin((() => {
14499
14844
  "report.send": () => this.sendReport(),
14500
14845
  "context.more": () => this.expand(1),
14501
14846
  "context.less": () => this.expand(-1),
14847
+ "context.whole": () => this.widen(contextToggled(this.state)),
14502
14848
  "tree.expand": () => this.unfold(1),
14503
14849
  "tree.collapse": () => this.unfold(-1)
14504
14850
  };
@@ -14553,8 +14899,16 @@ var init_app = __esmMin((() => {
14553
14899
  this.commit(paletteMoved(this.state, -1));
14554
14900
  return;
14555
14901
  }
14902
+ if (this.onCaret(key)) return;
14556
14903
  if (PRINTABLE.test(key.sequence)) this.commit(typed(this.state, key.sequence));
14557
14904
  }
14905
+ onCaret(key) {
14906
+ if (this.state.screen === "palette") return false;
14907
+ const moved = caretFor(this.state, key);
14908
+ if (moved === void 0) return false;
14909
+ this.commit(moved);
14910
+ return true;
14911
+ }
14558
14912
  runChoice() {
14559
14913
  return gen({ self: this }, function* () {
14560
14914
  const chosen = paletteChoice(this.state);
@@ -14644,6 +14998,36 @@ var init_app = __esmMin((() => {
14644
14998
  yield* this.loadSource();
14645
14999
  });
14646
15000
  }
15001
+ compose() {
15002
+ return gen({ self: this }, function* () {
15003
+ if (this.state.focus !== "review") {
15004
+ this.commit(reduce(this.measured(), "compose.open"));
15005
+ return;
15006
+ }
15007
+ yield* this.openPanelEntry();
15008
+ });
15009
+ }
15010
+ openPanelEntry() {
15011
+ return gen({ self: this }, function* () {
15012
+ const entry = panelEntry(this.state);
15013
+ if (entry === void 0) {
15014
+ this.commit(withNoticeHere(this.state, "nothing in the review yet"));
15015
+ return;
15016
+ }
15017
+ const at = this.state.patches.findIndex((patch) => patch.path === entry.comment.file);
15018
+ const patch = this.state.patches[at];
15019
+ if (patch === void 0) {
15020
+ this.commit(withNoticeHere(this.state, `${entry.comment.file} is not on this branch`));
15021
+ return;
15022
+ }
15023
+ const landed = atFile(this.state, at);
15024
+ this.commit({
15025
+ ...landed,
15026
+ cursor: rowAtSourceLine(patch, entry.comment.end)
15027
+ });
15028
+ yield* this.loadSource();
15029
+ });
15030
+ }
14647
15031
  settleHere() {
14648
15032
  return gen({ self: this }, function* () {
14649
15033
  const branch = selectedBranch(this.state);
@@ -14698,8 +15082,10 @@ var init_app = __esmMin((() => {
14698
15082
  if (branch === void 0) return;
14699
15083
  const path = selectedPatch(this.state)?.path;
14700
15084
  const line = sourceLineAt(this.state, this.state.cursor);
15085
+ const offset = this.state.cursor - this.state.top;
14701
15086
  const read = yield* this.readBranch(branch.branch);
14702
- this.commit(withWaiting(withNotice(restoredTo(read, path, line), "read the branch again"), ""));
15087
+ const held = restoredTo(read, path, line, offset);
15088
+ this.commit(withWaiting(withNotice(held, "read the branch again"), ""));
14703
15089
  yield* this.loadSource();
14704
15090
  });
14705
15091
  }
@@ -14804,7 +15190,8 @@ var init_app = __esmMin((() => {
14804
15190
  const next = withPending({
14805
15191
  ...this.state,
14806
15192
  editing: void 0,
14807
- draft: ""
15193
+ draft: "",
15194
+ caret: 0
14808
15195
  }, pending, "pending");
14809
15196
  this.commit(withNoticeHere(next, "reworded"));
14810
15197
  });
@@ -14843,9 +15230,11 @@ var init_app = __esmMin((() => {
14843
15230
  });
14844
15231
  }
14845
15232
  expand(delta) {
15233
+ return this.widen(layerContext(this.state.context, delta));
15234
+ }
15235
+ widen(next) {
14846
15236
  return gen({ self: this }, function* () {
14847
15237
  const branch = selectedBranch(this.state);
14848
- const next = layerContext(this.state.context, delta);
14849
15238
  if (branch === void 0 || next === this.state.context) return;
14850
15239
  const line = sourceLineAt(this.state, this.state.cursor);
14851
15240
  const patches = yield* listPatches(this.repo, branch.branch, next);
@@ -14870,12 +15259,11 @@ var init_app = __esmMin((() => {
14870
15259
  editStagedComment() {
14871
15260
  const entry = this.state.pending[this.state.pendingIndex];
14872
15261
  if (entry?.id === void 0) return;
14873
- this.commit({
15262
+ this.commit(withDraft({
14874
15263
  ...this.state,
14875
15264
  screen: "compose",
14876
- draft: entry.body,
14877
15265
  editing: entry.id
14878
- });
15266
+ }, entry.body));
14879
15267
  }
14880
15268
  dropStagedComment() {
14881
15269
  return gen({ self: this }, function* () {
@@ -14926,7 +15314,8 @@ var init_app = __esmMin((() => {
14926
15314
  const closed = {
14927
15315
  ...this.state,
14928
15316
  screen: this.state.returnTo,
14929
- draft: ""
15317
+ draft: "",
15318
+ caret: 0
14930
15319
  };
14931
15320
  this.commit(withNotice(closed, `report copied — ${path}`));
14932
15321
  });
@@ -14959,10 +15348,22 @@ var init_app = __esmMin((() => {
14959
15348
  }
14960
15349
  };
14961
15350
  settledPath = (path) => promise(() => realpath(path).catch(() => resolve(path)));
14962
- launch = fn("Tui.launch")(function* (asked, renderer, noticeMs, sessionPath) {
15351
+ openingOn = (branches, branch) => {
15352
+ if (branch === void 0) return none();
15353
+ const at = branches.findIndex((candidate) => candidate.branch === branch);
15354
+ return at === -1 ? none() : some({
15355
+ branchIndex: at,
15356
+ patchIndex: 0,
15357
+ cursor: 0,
15358
+ top: 0
15359
+ });
15360
+ };
15361
+ launch = fn("Tui.launch")(function* (asked, renderer, options = {}) {
15362
+ const { noticeMs, sessionPath } = options;
14963
15363
  const repo = yield* settledPath(asked);
14964
15364
  const branches = yield* listBranches(repo);
14965
- const resume = sessionPath === void 0 ? none() : yield* readSession(sessionPath);
15365
+ const asOpened = openingOn(branches, options.branch);
15366
+ const resume = isSome(asOpened) ? asOpened : sessionPath === void 0 ? none() : yield* readSession(sessionPath);
14966
15367
  const store = yield* Store;
14967
15368
  const wrap = (yield* store.settings).wrap === true;
14968
15369
  const display = yield* Display.pipe(provide(displayOn(renderer, repo)));
@@ -14995,13 +15396,16 @@ var init_app = __esmMin((() => {
14995
15396
  untilDestroyed = (renderer) => callback$1((resume) => {
14996
15397
  renderer.on("destroy", () => resume(void_));
14997
15398
  });
14998
- runOn = fn("Tui.runOn")(function* (repo, renderer, sessionPath) {
14999
- yield* launch(repo, renderer, void 0, sessionPath);
15399
+ runOn = fn("Tui.runOn")(function* (repo, renderer, sessionPath, branch) {
15400
+ yield* launch(repo, renderer, {
15401
+ sessionPath,
15402
+ branch
15403
+ });
15000
15404
  yield* untilDestroyed(renderer);
15001
15405
  });
15002
- runTui = fn("Tui.run")(function* (repo, sessionPath) {
15406
+ runTui = fn("Tui.run")(function* (repo, sessionPath, branch) {
15003
15407
  const renderer = yield* promise(() => createCliRenderer({ exitOnCtrlC: true }));
15004
- yield* runOn(repo, renderer, sessionPath);
15408
+ yield* runOn(repo, renderer, sessionPath, branch);
15005
15409
  });
15006
15410
  }));
15007
15411
  //#endregion
@@ -15177,7 +15581,7 @@ const init = fn("Main.init")(function* (options) {
15177
15581
  });
15178
15582
  });
15179
15583
  const reviewPane = fn("Main.reviewPane")(function* (options) {
15180
- const report = yield* openPane(yield* required(options, "repo"));
15584
+ const report = yield* openPane(yield* required(options, "repo"), options["branch"]);
15181
15585
  yield* answer(options, {
15182
15586
  opened: report.opened,
15183
15587
  pane: report.pane,
@@ -15265,7 +15669,7 @@ const dispatch = fn("Main.dispatch")(function* (name, given) {
15265
15669
  if (name === "file review") return yield* fileReview(options);
15266
15670
  if (name === "review open") {
15267
15671
  const { runTui } = yield* promise(() => Promise.resolve().then(() => (init_tui(), tui_exports)));
15268
- return yield* runTui(yield* required(options, "repo"), process.env["ADIFF_SESSION"]);
15672
+ return yield* runTui(yield* required(options, "repo"), process.env["ADIFF_SESSION"], options["branch"]);
15269
15673
  }
15270
15674
  return yield* unknown(name);
15271
15675
  });
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "bin": {
24
24
  "adiff": "./bin/adiff.js"
25
25
  },
26
- "version": "0.1.0-alpha.47",
26
+ "version": "0.1.0-alpha.49",
27
27
  "description": "Review the work an agent left you without losing the thread: comments live on the lines, the agent answers them, and each point stays open until you settle it.",
28
28
  "license": "MIT",
29
29
  "repository": {
@@ -107,14 +107,14 @@ extra work you do on request, and it has its own section further down.
107
107
  When someone asks you for a review, open it rather than describing how:
108
108
 
109
109
  ```bash
110
- adiff review pane --repo <repo>
110
+ adiff review pane --repo <repo> --branch <branch>
111
111
  ```
112
112
 
113
113
  It splits the pane they are already looking at, so their next move is to look right rather than to
114
114
  type. The answer says what happened:
115
115
 
116
116
  ```json
117
- {"ok":true,"opened":true,"pane":"tmux","command":"adiff review open --repo /work/api"}
117
+ {"ok":true,"opened":true,"pane":"tmux","command":"adiff review open --repo /work/api --branch cdr-1"}
118
118
  ```
119
119
 
120
120
  `opened:false` means nothing could be split, which is ordinary: a terminal without tmux, Zellij,
@@ -129,12 +129,15 @@ someone's screen uninvited is worse than a line they have to copy.
129
129
  Whether or not a pane opened, say what to do with it. Name the repository they should point at,
130
130
  which is the repository the worktree belongs to:
131
131
 
132
- > Open it with `adiff review open --repo <repo>`, then press `enter` on this branch. The sidebar
133
- > lists the files; `j` and `k` move down the diff, `]` and `[` walk between files. Select lines with
132
+ > Open it with `adiff review open --repo <repo> --branch <branch>`, which lands on this branch's
133
+ > diff. The sidebar lists the files; `j` and `k` move down the diff, `]` and `[` walk between
134
+ > files, `}` and `{` jump to the next and previous change, `G` goes to the end. Select lines with
134
135
  > `v`, write a comment with `c`, stage it with `ctrl+a`, and send the whole review with `S`. Press
135
136
  > `?` for the rest.
136
137
 
137
- Fill the repository path in yourself so nobody has to compose the command.
138
+ Fill the repository path and the branch in yourself, so nobody has to compose the command or find
139
+ the branch in a list. `--branch` takes the name `branch list` reports; without it the review opens
140
+ on the worktree list.
138
141
 
139
142
  Say what you want looked at hardest, and where you are unsure. A reviewer who knows which part you
140
143
  doubt spends their attention there. Offer a reading order rather than writing one: if the change is