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

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,17 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.48
4
+
5
+ ### Patch Changes
6
+
7
+ - `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.
8
+
9
+ - 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`.
10
+
11
+ - 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.
12
+
13
+ - 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.
14
+
3
15
  ## 0.1.0-alpha.47
4
16
 
5
17
  ### 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.48";
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,20 @@ 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
+ panelIndex: 0,
10907
+ columns: 0
10908
+ };
10895
10909
  initialState = (branches) => ({
10910
+ ...nothingReviewed,
10896
10911
  screen: "branches",
10897
10912
  branches,
10898
10913
  branchIndex: 0,
@@ -10904,6 +10919,7 @@ var init_model = __esmMin((() => {
10904
10919
  anchorRow: 0,
10905
10920
  selecting: false,
10906
10921
  draft: "",
10922
+ caret: 0,
10907
10923
  notice: "",
10908
10924
  waiting: "",
10909
10925
  query: "",
@@ -10918,6 +10934,7 @@ var init_model = __esmMin((() => {
10918
10934
  editing: void 0,
10919
10935
  viewport: 20,
10920
10936
  context: 3,
10937
+ contextWas: 3,
10921
10938
  top: 0,
10922
10939
  source: [],
10923
10940
  full: [],
@@ -10937,6 +10954,22 @@ var init_model = __esmMin((() => {
10937
10954
  matchIndex: 0,
10938
10955
  rail: "tree"
10939
10956
  });
10957
+ BODY_BORDER = 2;
10958
+ TREE_MAX = 34;
10959
+ TREE_MIN = 18;
10960
+ TREE_SHARE = .3;
10961
+ DIFF_MIN = 24;
10962
+ PANEL_WIDTH = 34;
10963
+ DIFF_ROOMY = 56;
10964
+ bodyRoom = (columns) => Math.max(0, columns - 2 - BODY_BORDER);
10965
+ treeWidth = (columns) => {
10966
+ const room = bodyRoom(columns);
10967
+ const wanted = Math.min(TREE_MAX, Math.max(TREE_MIN, Math.floor(room * TREE_SHARE)));
10968
+ return Math.max(0, Math.min(wanted, room - DIFF_MIN));
10969
+ };
10970
+ reviewWidth = () => PANEL_WIDTH;
10971
+ panelFits = (state) => bodyRoom(state.columns) - treeWidth(state.columns) - PANEL_WIDTH >= DIFF_ROOMY;
10972
+ panelShown = (state) => state.screen !== "branches" && state.panelOpen && panelFits(state);
10940
10973
  onLayers = (state) => state.rail === "layers" && state.layers.length > 0;
10941
10974
  selectedLayer = (state) => state.layers[state.layerIndex];
10942
10975
  proseFor = (state, path) => {
@@ -11105,6 +11138,31 @@ var init_model = __esmMin((() => {
11105
11138
  onNone: () => "-",
11106
11139
  onSome: (line) => String(line)
11107
11140
  });
11141
+ caretAt = (state) => Math.max(0, Math.min(state.draft.length, state.caret));
11142
+ drafted = (state) => {
11143
+ const at = caretAt(state);
11144
+ return `${state.draft.slice(0, at)}▌${state.draft.slice(at)}`;
11145
+ };
11146
+ WORD = /[\p{L}\p{N}_]/u;
11147
+ wordLeft = (draft, from) => {
11148
+ let at = from;
11149
+ while (at > 0 && !WORD.test(draft[at - 1] ?? "")) at -= 1;
11150
+ while (at > 0 && WORD.test(draft[at - 1] ?? "")) at -= 1;
11151
+ return at;
11152
+ };
11153
+ wordRight = (draft, from) => {
11154
+ let at = from;
11155
+ while (at < draft.length && !WORD.test(draft[at] ?? "")) at += 1;
11156
+ while (at < draft.length && WORD.test(draft[at] ?? "")) at += 1;
11157
+ return at;
11158
+ };
11159
+ caretByWord = (state, delta) => delta < 0 ? wordLeft(state.draft, caretAt(state)) : wordRight(state.draft, caretAt(state));
11160
+ lineStart = (draft, at) => draft.lastIndexOf("\n", at - 1) + 1;
11161
+ lineEnd = (draft, at) => {
11162
+ const found = draft.indexOf("\n", at);
11163
+ return found === -1 ? draft.length : found;
11164
+ };
11165
+ caretToEdge = (state, edge) => edge === "start" ? lineStart(state.draft, caretAt(state)) : lineEnd(state.draft, caretAt(state));
11108
11166
  editedComment = (state) => state.editing === void 0 ? void 0 : state.pending.find((entry) => entry.id === state.editing);
11109
11167
  composeTarget = (state) => {
11110
11168
  const edited = editedComment(state);
@@ -11198,6 +11256,8 @@ var init_model = __esmMin((() => {
11198
11256
  60,
11199
11257
  WHOLE_FILE
11200
11258
  ];
11259
+ wholeFileOff = (state) => state.context < WHOLE_FILE;
11260
+ contextToggled = (state) => wholeFileOff(state) ? WHOLE_FILE : state.contextWas;
11201
11261
  layerContext = (current, delta) => {
11202
11262
  const at = CONTEXT_STEPS.indexOf(current);
11203
11263
  const next = Math.max(0, Math.min(CONTEXT_STEPS.length - 1, (at === -1 ? 0 : at) + delta));
@@ -11250,6 +11310,36 @@ var init_model = __esmMin((() => {
11250
11310
  };
11251
11311
  filesWithComments = (state) => state.patches.flatMap((patch, index) => [...state.pending, ...state.sent].some((entry) => entry.file === patch.path) ? [index] : []);
11252
11312
  answerCount = (comments) => comments.reduce((total, entry) => total + (entry.answers?.length ?? 0), 0);
11313
+ answersIn = (comment) => comment.answers?.length ?? 0;
11314
+ newerOf = (state, comment) => {
11315
+ if (comment.id === void 0) return comment;
11316
+ const later = state.arrived.find((entry) => entry.id === comment.id);
11317
+ if (later === void 0) return comment;
11318
+ return answersIn(later) > answersIn(comment) ? later : comment;
11319
+ };
11320
+ sectionOf = (comment) => answersIn(comment) > 0 || comment.settled === true ? "answered" : "with";
11321
+ sentEntry = (state, comment) => {
11322
+ const newer = newerOf(state, comment);
11323
+ return {
11324
+ section: sectionOf(newer),
11325
+ comment: newer,
11326
+ fresh: newer !== comment
11327
+ };
11328
+ };
11329
+ panelEntries = (state) => {
11330
+ const staged = state.pending.map((comment) => ({
11331
+ section: "staged",
11332
+ comment,
11333
+ fresh: false
11334
+ }));
11335
+ const delivered = state.sent.map((comment) => sentEntry(state, comment));
11336
+ return [
11337
+ ...staged,
11338
+ ...delivered.filter((entry) => entry.section === "with"),
11339
+ ...delivered.filter((entry) => entry.section === "answered")
11340
+ ];
11341
+ };
11342
+ panelEntry = (state) => panelEntries(state)[state.panelIndex];
11253
11343
  spokenSince = (seen, now) => Math.max(0, answerCount(now) - answerCount(seen));
11254
11344
  hunkStarts = (state) => {
11255
11345
  const patch = selectedPatch(state);
@@ -11480,6 +11570,12 @@ var init_command = __esmMin((() => {
11480
11570
  keys: ["-", "_"],
11481
11571
  screens: ["review"]
11482
11572
  }),
11573
+ command({
11574
+ action: "context.whole",
11575
+ title: "Show the whole file, or go back to the diff",
11576
+ keys: ["F"],
11577
+ screens: ["review"]
11578
+ }),
11483
11579
  command({
11484
11580
  action: "comment.next",
11485
11581
  title: "Next comment",
@@ -11528,6 +11624,13 @@ var init_command = __esmMin((() => {
11528
11624
  keys: ["tab"],
11529
11625
  screens: ["review"]
11530
11626
  }),
11627
+ command({
11628
+ action: "panel.toggle",
11629
+ title: "Show or hide the review panel",
11630
+ category: "Review",
11631
+ keys: ["a"],
11632
+ screens: ["review"]
11633
+ }),
11531
11634
  command({
11532
11635
  action: "nav.zoom",
11533
11636
  title: "Hide the file list",
@@ -11929,7 +12032,7 @@ var init_match = __esmMin((() => {
11929
12032
  }));
11930
12033
  //#endregion
11931
12034
  //#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;
12035
+ 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, 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
12036
  var init_reduce = __esmMin((() => {
11934
12037
  init_dist();
11935
12038
  init_patch();
@@ -12058,7 +12161,30 @@ var init_reduce = __esmMin((() => {
12058
12161
  };
12059
12162
  };
12060
12163
  inRail = (state, delta) => onLayers(state) ? moveLayer(state, delta) : moveFile(state, delta);
12061
- layerDown = (state, delta) => state.focus === "tree" ? inRail(state, delta) : stepStop(state, delta);
12164
+ movePanel = (state, delta) => ({
12165
+ ...state,
12166
+ panelIndex: clamp(state.panelIndex + delta, 0, Math.max(0, panelEntries(state).length - 1))
12167
+ });
12168
+ layerDown = (state, delta) => {
12169
+ if (state.focus === "tree") return inRail(state, delta);
12170
+ if (state.focus === "review") return movePanel(state, delta);
12171
+ return stepStop(state, delta);
12172
+ };
12173
+ nextFocus = (state) => {
12174
+ if (state.focus === "diff") return "tree";
12175
+ if (state.focus === "tree") return panelShown(state) ? "review" : "diff";
12176
+ return "diff";
12177
+ };
12178
+ togglePanel = (state) => {
12179
+ if (!state.panelOpen && !panelFits(state)) return withNotice(state, "the terminal is too narrow for the review panel");
12180
+ const panelOpen = !state.panelOpen;
12181
+ return {
12182
+ ...state,
12183
+ panelOpen,
12184
+ focus: panelOpen ? state.focus : "diff",
12185
+ panelIndex: 0
12186
+ };
12187
+ };
12062
12188
  toggleRail = (state) => {
12063
12189
  if (state.layers.length === 0) return withNotice(state, "no layers for this branch");
12064
12190
  if (state.rail === "layers") return {
@@ -12143,6 +12269,7 @@ var init_reduce = __esmMin((() => {
12143
12269
  ...state,
12144
12270
  screen: "compose",
12145
12271
  draft: "",
12272
+ caret: 0,
12146
12273
  anchorRow: state.selecting ? state.anchorRow : state.cursor
12147
12274
  };
12148
12275
  };
@@ -12160,7 +12287,8 @@ var init_reduce = __esmMin((() => {
12160
12287
  if (state.screen === "report") return {
12161
12288
  ...state,
12162
12289
  screen: state.returnTo,
12163
- draft: ""
12290
+ draft: "",
12291
+ caret: 0
12164
12292
  };
12165
12293
  if (state.screen === "palette") return {
12166
12294
  ...state,
@@ -12174,7 +12302,8 @@ var init_reduce = __esmMin((() => {
12174
12302
  if (state.screen === "compose") return {
12175
12303
  ...state,
12176
12304
  screen: "review",
12177
- draft: ""
12305
+ draft: "",
12306
+ caret: 0
12178
12307
  };
12179
12308
  if (state.selecting) return {
12180
12309
  ...state,
@@ -12226,6 +12355,7 @@ var init_reduce = __esmMin((() => {
12226
12355
  "cursor.pageUp": (state) => moveCursor(state, -Math.max(1, Math.floor(state.viewport / 2))),
12227
12356
  "context.more": (state) => state,
12228
12357
  "context.less": (state) => state,
12358
+ "context.whole": (state) => state,
12229
12359
  "comment.next": (state) => layerComment(state, 1),
12230
12360
  "comment.prev": (state) => layerComment(state, -1),
12231
12361
  "hunk.next": (state) => layerHunk(state, 1),
@@ -12245,15 +12375,13 @@ var init_reduce = __esmMin((() => {
12245
12375
  "pending.drop": (state) => state,
12246
12376
  "pending.next": (state) => movePending(state, 1),
12247
12377
  "pending.prev": (state) => movePending(state, -1),
12248
- "compose.newline": (state) => ({
12249
- ...state,
12250
- draft: `${state.draft}\n`
12251
- }),
12378
+ "compose.newline": (state) => inserted(state, "\n"),
12252
12379
  "focus.toggle": (state) => ({
12253
12380
  ...state,
12254
- focus: state.focus === "diff" ? "tree" : "diff",
12381
+ focus: nextFocus(state),
12255
12382
  navOpen: true
12256
12383
  }),
12384
+ "panel.toggle": togglePanel,
12257
12385
  "nav.zoom": (state) => ({
12258
12386
  ...state,
12259
12387
  navOpen: !state.navOpen,
@@ -12278,6 +12406,7 @@ var init_reduce = __esmMin((() => {
12278
12406
  ...state,
12279
12407
  screen: "report",
12280
12408
  draft: "",
12409
+ caret: 0,
12281
12410
  returnTo: state.screen
12282
12411
  }),
12283
12412
  "report.send": (state) => state,
@@ -12305,6 +12434,7 @@ var init_reduce = __esmMin((() => {
12305
12434
  withContext = (state, context, patches, cursor) => ({
12306
12435
  ...state,
12307
12436
  context,
12437
+ contextWas: state.context < 1e5 ? state.context : state.contextWas,
12308
12438
  patches,
12309
12439
  revealed: [],
12310
12440
  cursor,
@@ -12353,7 +12483,17 @@ var init_reduce = __esmMin((() => {
12353
12483
  };
12354
12484
  withSent = (state, sent) => ({
12355
12485
  ...state,
12356
- sent
12486
+ sent,
12487
+ arrived: [],
12488
+ panelIndex: 0
12489
+ });
12490
+ withArrived = (state, arrived) => ({
12491
+ ...state,
12492
+ arrived
12493
+ });
12494
+ withColumns = (state, columns) => ({
12495
+ ...state,
12496
+ columns
12357
12497
  });
12358
12498
  withLayers = (state, told) => {
12359
12499
  const layers = told.layers;
@@ -12395,14 +12535,17 @@ var init_reduce = __esmMin((() => {
12395
12535
  ...state,
12396
12536
  vouched
12397
12537
  });
12398
- restoredTo = (state, path, line) => {
12538
+ restoredTo = (state, path, line, offset) => {
12399
12539
  const index = state.patches.findIndex((patch) => patch.path === path);
12400
12540
  const patch = state.patches[index];
12401
12541
  if (patch === void 0) return state;
12542
+ const cursor = line === void 0 ? 0 : rowAtSourceLine(patch, line);
12543
+ const top = clamp(cursor - Math.max(0, offset), 0, Math.max(0, patch.rows.length - 1));
12402
12544
  return withCursorVisible({
12403
12545
  ...state,
12404
12546
  patchIndex: index,
12405
- cursor: line === void 0 ? 0 : rowAtSourceLine(patch, line)
12547
+ cursor,
12548
+ top
12406
12549
  });
12407
12550
  };
12408
12551
  withPatches = (state, patches) => ({
@@ -12421,22 +12564,59 @@ var init_reduce = __esmMin((() => {
12421
12564
  anchorRow: 0,
12422
12565
  selecting: false
12423
12566
  });
12567
+ inserted = (state, text) => {
12568
+ const at = caretAt(state);
12569
+ return {
12570
+ ...state,
12571
+ draft: `${state.draft.slice(0, at)}${text}${state.draft.slice(at)}`,
12572
+ caret: at + text.length
12573
+ };
12574
+ };
12424
12575
  typed = (state, character) => state.screen === "palette" ? {
12425
12576
  ...state,
12426
12577
  query: `${state.query}${character}`,
12427
12578
  paletteIndex: 0
12428
- } : {
12429
- ...state,
12430
- draft: `${state.draft}${character}`
12579
+ } : inserted(state, character);
12580
+ backspaced = (state) => {
12581
+ if (state.screen === "palette") return {
12582
+ ...state,
12583
+ query: state.query.slice(0, -1),
12584
+ paletteIndex: 0
12585
+ };
12586
+ const at = caretAt(state);
12587
+ if (at === 0) return state;
12588
+ return {
12589
+ ...state,
12590
+ draft: `${state.draft.slice(0, at - 1)}${state.draft.slice(at)}`,
12591
+ caret: at - 1
12592
+ };
12431
12593
  };
12432
- backspaced = (state) => state.screen === "palette" ? {
12594
+ deleted = (state) => {
12595
+ const at = caretAt(state);
12596
+ if (at >= state.draft.length) return state;
12597
+ return {
12598
+ ...state,
12599
+ draft: `${state.draft.slice(0, at)}${state.draft.slice(at + 1)}`,
12600
+ caret: at
12601
+ };
12602
+ };
12603
+ caretMoved = (state, delta) => ({
12433
12604
  ...state,
12434
- query: state.query.slice(0, -1),
12435
- paletteIndex: 0
12436
- } : {
12605
+ caret: clamp(caretAt(state) + delta, 0, state.draft.length)
12606
+ });
12607
+ caretJumped = (state, delta) => ({
12437
12608
  ...state,
12438
- draft: state.draft.slice(0, -1)
12439
- };
12609
+ caret: caretByWord(state, delta)
12610
+ });
12611
+ caretHomed = (state, edge) => ({
12612
+ ...state,
12613
+ caret: caretToEdge(state, edge)
12614
+ });
12615
+ withDraft = (state, draft) => ({
12616
+ ...state,
12617
+ draft,
12618
+ caret: draft.length
12619
+ });
12440
12620
  paletteMoved = (state, delta) => movePalette(state, delta);
12441
12621
  paletteClosed = (state) => ({
12442
12622
  ...state,
@@ -12463,6 +12643,7 @@ var init_reduce = __esmMin((() => {
12463
12643
  ...state,
12464
12644
  screen: "review",
12465
12645
  draft: "",
12646
+ caret: 0,
12466
12647
  selecting: false,
12467
12648
  notice
12468
12649
  });
@@ -12750,6 +12931,9 @@ var init_diffview = __esmMin((() => {
12750
12931
  pinNode() {
12751
12932
  return this.pinBox;
12752
12933
  }
12934
+ pinRows() {
12935
+ return this.pinBox.height;
12936
+ }
12753
12937
  noteRoom() {
12754
12938
  return Math.max(NOTE_MIN, this.code.width - this.gutterWidth() - 3);
12755
12939
  }
@@ -12903,12 +13087,23 @@ var init_diffview = __esmMin((() => {
12903
13087
  if (sources.length === 0) return false;
12904
13088
  return visual > 0 && sources[visual] === sources[visual - 1];
12905
13089
  }
13090
+ lineOfRow(row) {
13091
+ if (this.starts.size === 0) return void 0;
13092
+ for (let at = Math.max(0, row); at >= 0; at -= 1) {
13093
+ const line = this.starts.get(at);
13094
+ if (line !== void 0) return line;
13095
+ }
13096
+ return 0;
13097
+ }
13098
+ visualOfRow(row) {
13099
+ const line = this.lineOfRow(row);
13100
+ return line === void 0 ? void 0 : this.visualOf(line);
13101
+ }
12906
13102
  scrollTo(row, cursor) {
12907
13103
  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;
13104
+ const wanted = this.visualOfRow(row) ?? row;
13105
+ const at = this.visualOfRow(cursor);
13106
+ const kept = at !== void 0 && at >= wanted ? Math.max(wanted, at - this.rows() + 1) : wanted;
12912
13107
  const clamped = Math.max(0, Math.min(highest, kept));
12913
13108
  if (this.code.scrollY !== clamped) this.code.scrollY = clamped;
12914
13109
  return clamped;
@@ -13071,7 +13266,7 @@ var init_diffview = __esmMin((() => {
13071
13266
  }));
13072
13267
  //#endregion
13073
13268
  //#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;
13269
+ 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
13270
  var init_render = __esmMin((() => {
13076
13271
  init_command();
13077
13272
  init_patch();
@@ -13106,23 +13301,12 @@ var init_render = __esmMin((() => {
13106
13301
  PANEL_FOOT = 2;
13107
13302
  PANEL_QUARTER = 4;
13108
13303
  PANEL_FIFTH = 5;
13109
- TREE_MAX = 34;
13110
- TREE_MIN = 18;
13111
- TREE_SHARE = .3;
13112
- DIFF_MIN = 24;
13113
- BODY_BORDER = 2;
13114
13304
  PANE_CHROME = 3;
13115
13305
  BRANCH_WIDTH = 82;
13116
13306
  BRANCH_NAME_MIN = 12;
13117
13307
  BRANCH_TAIL = 45;
13118
13308
  EMPTY_LIST = " nothing to review. No worktree differs from the branch it started from.";
13119
13309
  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
13310
  shareOf = (width, least) => Math.max(least, Math.min(PANEL_MAX, Math.floor(width * PANEL_SHARE)));
13127
13311
  homeWidth = (width, longest) => Math.max(0, Math.min(width - 2, Math.min(PANEL_MAX, Math.max(BRANCH_WIDTH, longest + BRANCH_TAIL))));
13128
13312
  longestName = (state) => Math.max(0, ...state.branches.map((branch) => branch.branch.length));
@@ -13196,6 +13380,31 @@ var init_render = __esmMin((() => {
13196
13380
  overflow: "hidden",
13197
13381
  visible: false
13198
13382
  });
13383
+ makePanel = (renderer) => {
13384
+ const pane = new BoxRenderable(renderer, {
13385
+ id: "panel-pane",
13386
+ width: 0,
13387
+ flexShrink: 0,
13388
+ flexDirection: "column",
13389
+ minHeight: 0,
13390
+ overflow: "hidden",
13391
+ border: ["left"],
13392
+ borderColor: palette.rule,
13393
+ visible: false
13394
+ });
13395
+ const text = new TextRenderable(renderer, {
13396
+ id: "panel",
13397
+ content: "",
13398
+ fg: palette.ink,
13399
+ flexGrow: 1,
13400
+ wrapMode: "none"
13401
+ });
13402
+ pane.add(text);
13403
+ return {
13404
+ pane,
13405
+ text
13406
+ };
13407
+ };
13199
13408
  makeListParts = (renderer) => {
13200
13409
  const pane = makeList(renderer);
13201
13410
  const text = makeListText(renderer);
@@ -13594,12 +13803,79 @@ var init_render = __esmMin((() => {
13594
13803
  if (row.kind === "note") return palette.faint;
13595
13804
  return row.index === state.layerIndex ? palette.ink : palette.muted;
13596
13805
  };
13806
+ PANEL_TITLES = {
13807
+ staged: "Staged",
13808
+ with: "With the agent",
13809
+ answered: "Answered"
13810
+ };
13811
+ PANEL_ORDER = [
13812
+ "staged",
13813
+ "with",
13814
+ "answered"
13815
+ ];
13816
+ PANEL_LEAD = 3;
13817
+ PANEL_EMPTY = "No comment on this branch yet.";
13818
+ panelMark = (state, at) => {
13819
+ if (at !== state.panelIndex) return " ";
13820
+ return state.focus === "review" ? "▸" : "·";
13821
+ };
13822
+ panelWhere = (entry, room) => {
13823
+ const where = `:${entry.comment.end}`;
13824
+ return `${clipPath(entry.comment.file, Math.max(4, room - where.length))}${where}`;
13825
+ };
13826
+ panelBody = (entry) => entry.comment.body.split("\n").find((line) => line.trim().length > 0) ?? "";
13827
+ panelPair = (state, placed, room) => {
13828
+ const { entry } = placed;
13829
+ return [{
13830
+ text: `${`${panelMark(state, placed.at)}${entry.fresh ? marks().comment : " "} `}${panelWhere(entry, room - PANEL_LEAD)}`,
13831
+ tone: palette.ink
13832
+ }, {
13833
+ text: ` ${clip(panelBody(entry), Math.max(4, room - PANEL_LEAD))}`,
13834
+ tone: palette.muted
13835
+ }];
13836
+ };
13837
+ panelSection = (state, placed, section, room) => {
13838
+ const here = placed.filter((one) => one.entry.section === section);
13839
+ if (here.length === 0) return [];
13840
+ return [
13841
+ {
13842
+ text: "",
13843
+ tone: palette.faint
13844
+ },
13845
+ {
13846
+ text: `${PANEL_TITLES[section]} ${here.length}`,
13847
+ tone: palette.faint
13848
+ },
13849
+ ...here.flatMap((one) => panelPair(state, one, room))
13850
+ ];
13851
+ };
13852
+ PULL_HINT = "answered, press r to pull";
13853
+ panelText = (state, room) => {
13854
+ const placed = panelEntries(state).map((entry, at) => ({
13855
+ entry,
13856
+ at
13857
+ }));
13858
+ const fresh = placed.filter((one) => one.entry.fresh).length;
13859
+ const banner = fresh === 0 ? [] : [{
13860
+ text: clip(`${fresh} ${PULL_HINT}`, room),
13861
+ tone: palette.attention
13862
+ }];
13863
+ const sections = PANEL_ORDER.flatMap((section) => panelSection(state, placed, section, room));
13864
+ const body = sections.slice(sections[0]?.text === "" ? 1 : 0);
13865
+ const lines = body.length === 0 ? [{
13866
+ text: PANEL_EMPTY,
13867
+ tone: palette.muted
13868
+ }] : body;
13869
+ return new StyledText([...banner, ...lines].map((line) => fg(line.tone)(`${line.text}\n`)));
13870
+ };
13597
13871
  Screen = class {
13598
13872
  header;
13599
13873
  body;
13600
13874
  listPane;
13601
13875
  list;
13602
13876
  diffPane;
13877
+ panelPane;
13878
+ panel;
13603
13879
  scrim;
13604
13880
  gutter;
13605
13881
  diffScroll;
@@ -13654,6 +13930,9 @@ var init_render = __esmMin((() => {
13654
13930
  this.landing = home.path;
13655
13931
  this.landingKeys = home.keys;
13656
13932
  this.diffPane = makeDiffPane(renderer);
13933
+ const panel = makePanel(renderer);
13934
+ this.panelPane = panel.pane;
13935
+ this.panel = panel.text;
13657
13936
  this.diffScroll = makeScroll(renderer);
13658
13937
  this.view = new DiffView(renderer);
13659
13938
  const inside = makeComposeParts(renderer);
@@ -13680,8 +13959,17 @@ var init_render = __esmMin((() => {
13680
13959
  this.foundChoices = modals.found.choices;
13681
13960
  this.assemble(renderer);
13682
13961
  }
13962
+ wheelOnSheet(box) {
13963
+ box.onMouseScroll = (event) => {
13964
+ const way = event.scroll?.direction;
13965
+ if (way !== "up" && way !== "down") return;
13966
+ this.mouse?.onScroll(way === "down" ? 1 : -1);
13967
+ };
13968
+ }
13683
13969
  listen(mouse) {
13684
13970
  this.mouse = mouse;
13971
+ this.wheelOnSheet(this.keys);
13972
+ this.wheelOnSheet(this.palette);
13685
13973
  this.view.listenTo({
13686
13974
  scroll: (delta) => this.mouse?.onScroll(delta),
13687
13975
  pan: (delta) => this.mouse?.onPan(delta),
@@ -13710,7 +13998,8 @@ var init_render = __esmMin((() => {
13710
13998
  return this.view.room();
13711
13999
  }
13712
14000
  diffRows() {
13713
- return Math.max(1, this.diffScroll.height);
14001
+ const pane = this.diffPane.height - this.view.pinRows();
14002
+ return Math.max(1, pane > 0 ? pane : this.diffScroll.height);
13714
14003
  }
13715
14004
  update(state) {
13716
14005
  this.shown = state;
@@ -13730,6 +14019,7 @@ var init_render = __esmMin((() => {
13730
14019
  this.landingKeys.content = this.homeKeys(state);
13731
14020
  this.diffPane.visible = state.screen !== "branches" && !atHome(state);
13732
14021
  if (this.diffPane.visible) this.paintDiff(state);
14022
+ this.paintPanel(state);
13733
14023
  this.paintPane(state);
13734
14024
  this.paintCompose(state);
13735
14025
  this.paintPalette(state);
@@ -13811,6 +14101,17 @@ var init_render = __esmMin((() => {
13811
14101
  paneRoom() {
13812
14102
  return treeWidth(this.renderer.width);
13813
14103
  }
14104
+ columns() {
14105
+ return this.renderer.width;
14106
+ }
14107
+ paintPanel(state) {
14108
+ const shown = this.diffPane.visible && panelShown(state);
14109
+ this.panelPane.visible = shown;
14110
+ this.panelPane.width = shown ? reviewWidth() : 0;
14111
+ this.panelPane.paddingLeft = shown ? 1 : 0;
14112
+ this.panelPane.paddingTop = shown ? 1 : 0;
14113
+ this.panel.content = shown ? panelText(state, reviewWidth() - PANE_CHROME) : "";
14114
+ }
13814
14115
  listText(state) {
13815
14116
  if (atHome(state)) return this.branchTable(state);
13816
14117
  if (onLayers(state)) return this.layerRail(state);
@@ -13842,7 +14143,7 @@ var init_render = __esmMin((() => {
13842
14143
  this.view.setWrap(state.wrap);
13843
14144
  this.view.setPan(state.pan);
13844
14145
  this.view.show(patch, notesFor(state, patch.path), gapRowSet(shown), proseFor(state, patch.path));
13845
- this.view.fit(this.diffScroll.height);
14146
+ this.view.fit(this.diffRows());
13846
14147
  const height = this.view.rows();
13847
14148
  const top = this.view.scrollTo(state.top, state.cursor);
13848
14149
  this.lastTop = top;
@@ -13880,6 +14181,7 @@ var init_render = __esmMin((() => {
13880
14181
  this.watchChips();
13881
14182
  this.body.add(this.listPane);
13882
14183
  this.body.add(this.diffPane);
14184
+ this.body.add(this.panelPane);
13883
14185
  stack(this.compose, [
13884
14186
  this.composeTitle,
13885
14187
  this.composeBody,
@@ -14035,7 +14337,7 @@ var init_render = __esmMin((() => {
14035
14337
  const lines = laidOut([
14036
14338
  "What went wrong? Everything on screen is attached for you.",
14037
14339
  "",
14038
- `${state.draft}▌`
14340
+ drafted(state)
14039
14341
  ], room.text);
14040
14342
  this.composeTitle.content = "Report a bug";
14041
14343
  this.composeBody.content = lines.join("\n");
@@ -14092,7 +14394,7 @@ var init_render = __esmMin((() => {
14092
14394
  const more = selectedLineCount(state) - snippet.length;
14093
14395
  const tail = more > 0 ? [` … ${more} more lines`] : [];
14094
14396
  const quoted = [...snippet, ...tail].map((line) => clip(line, room.text));
14095
- const written = laidOut(`${state.draft}▌`.split("\n"), room.text);
14397
+ const written = laidOut(drafted(state).split("\n"), room.text);
14096
14398
  const lines = [
14097
14399
  ...quoted,
14098
14400
  "",
@@ -14126,6 +14428,7 @@ var init_display = __esmMin((() => {
14126
14428
  paint: paintWith(screen),
14127
14429
  rows: sync(() => screen.viewportRows()),
14128
14430
  room: sync(() => screen.noteRoom()),
14431
+ columns: sync(() => screen.columns()),
14129
14432
  listen: listenWith(screen)
14130
14433
  });
14131
14434
  displayOn = (renderer, repo) => sync$1(Display)(() => shapeOf(new Screen(renderer, repo)));
@@ -14205,7 +14508,7 @@ var init_upgrade = __esmMin((() => {
14205
14508
  return due ? `adiff ${latest} is out · adiff upgrade` : "";
14206
14509
  }).pipe(withSpan("Tui.upgradeHint"));
14207
14510
  upgradeHint = worded.pipe(orElseSucceed(() => ""));
14208
- })), PRINTABLE, KEY_HISTORY, copyToClipboard, asKey, openedPull, keyName, App, settledPath, launch, told, untilDestroyed, runOn, runTui;
14511
+ })), PRINTABLE, KEY_HISTORY, copyToClipboard, asKey, openedPull, byWord, WORD_STEP, caretSideways, caretFor, LISTENS, listens, keyName, App, settledPath, openingOn, launch, told, untilDestroyed, runOn, runTui;
14209
14512
  var init_app = __esmMin((() => {
14210
14513
  init_dist();
14211
14514
  init_report();
@@ -14243,6 +14546,27 @@ var init_app = __esmMin((() => {
14243
14546
  if (!opened) return "could not reach the pull request";
14244
14547
  return state.length === 0 ? "opened the pull request" : `opened the ${state} pull request`;
14245
14548
  };
14549
+ byWord = (key) => key.option || key.meta || key.ctrl;
14550
+ WORD_STEP = {
14551
+ b: -1,
14552
+ f: 1
14553
+ };
14554
+ caretSideways = (state, key) => {
14555
+ const step = key.name === "left" ? -1 : key.name === "right" ? 1 : 0;
14556
+ if (step === 0) return void 0;
14557
+ return byWord(key) ? caretJumped(state, step) : caretMoved(state, step);
14558
+ };
14559
+ caretFor = (state, key) => {
14560
+ const sideways = caretSideways(state, key);
14561
+ if (sideways !== void 0) return sideways;
14562
+ const word = byWord(key) ? WORD_STEP[key.name] : void 0;
14563
+ if (word !== void 0) return caretJumped(state, word);
14564
+ if (key.name === "home") return caretHomed(state, "start");
14565
+ if (key.name === "end") return caretHomed(state, "end");
14566
+ return key.name === "delete" ? deleted(state) : void 0;
14567
+ };
14568
+ LISTENS = /* @__PURE__ */ new Set(["keys", "palette"]);
14569
+ listens = (screen) => LISTENS.has(screen);
14246
14570
  keyName = (key) => {
14247
14571
  const base = key.shift && key.name.length === 1 ? key.name.toUpperCase() : key.name;
14248
14572
  return key.ctrl ? `ctrl+${base}` : base;
@@ -14315,7 +14639,7 @@ var init_app = __esmMin((() => {
14315
14639
  const sent = yield* this.loadSent(branch.branch);
14316
14640
  const said = spokenSince(this.state.sent, sent);
14317
14641
  if (said === 0) return;
14318
- this.commit(withWaiting(this.state, `${said} answered · press r`));
14642
+ this.commit(withWaiting(withArrived(this.state, sent), `${said} answered · press r`));
14319
14643
  });
14320
14644
  }
14321
14645
  noticeOnList() {
@@ -14401,6 +14725,10 @@ var init_app = __esmMin((() => {
14401
14725
  if (down === 0 && across === 0) return;
14402
14726
  this.wheel = 0;
14403
14727
  this.sideways = 0;
14728
+ if (listens(this.state.screen)) {
14729
+ if (down !== 0) this.commit(paletteMoved(this.state, down));
14730
+ return;
14731
+ }
14404
14732
  const moved = down === 0 ? this.measured() : scrolled(this.measured(), down);
14405
14733
  this.commit(across === 0 ? moved : panBy(moved, across));
14406
14734
  }
@@ -14413,6 +14741,11 @@ var init_app = __esmMin((() => {
14413
14741
  });
14414
14742
  return;
14415
14743
  }
14744
+ const columns = runSync(this.display.columns);
14745
+ if (columns !== this.state.columns) {
14746
+ this.commit(withColumns(this.state, columns));
14747
+ return;
14748
+ }
14416
14749
  const room = runSync(this.display.room);
14417
14750
  if (room === this.roomed) return;
14418
14751
  this.roomed = room;
@@ -14472,6 +14805,7 @@ var init_app = __esmMin((() => {
14472
14805
  quit: () => sync(() => this.renderer.destroy()),
14473
14806
  "branch.open": () => this.openBranch(),
14474
14807
  "branch.pull": () => this.showPull(),
14808
+ "compose.open": () => this.compose(),
14475
14809
  "compose.submit": () => this.send(),
14476
14810
  "compose.stage": () => this.stage(),
14477
14811
  "palette.run": () => this.runChoice(),
@@ -14499,6 +14833,7 @@ var init_app = __esmMin((() => {
14499
14833
  "report.send": () => this.sendReport(),
14500
14834
  "context.more": () => this.expand(1),
14501
14835
  "context.less": () => this.expand(-1),
14836
+ "context.whole": () => this.widen(contextToggled(this.state)),
14502
14837
  "tree.expand": () => this.unfold(1),
14503
14838
  "tree.collapse": () => this.unfold(-1)
14504
14839
  };
@@ -14553,8 +14888,16 @@ var init_app = __esmMin((() => {
14553
14888
  this.commit(paletteMoved(this.state, -1));
14554
14889
  return;
14555
14890
  }
14891
+ if (this.onCaret(key)) return;
14556
14892
  if (PRINTABLE.test(key.sequence)) this.commit(typed(this.state, key.sequence));
14557
14893
  }
14894
+ onCaret(key) {
14895
+ if (this.state.screen === "palette") return false;
14896
+ const moved = caretFor(this.state, key);
14897
+ if (moved === void 0) return false;
14898
+ this.commit(moved);
14899
+ return true;
14900
+ }
14558
14901
  runChoice() {
14559
14902
  return gen({ self: this }, function* () {
14560
14903
  const chosen = paletteChoice(this.state);
@@ -14644,6 +14987,36 @@ var init_app = __esmMin((() => {
14644
14987
  yield* this.loadSource();
14645
14988
  });
14646
14989
  }
14990
+ compose() {
14991
+ return gen({ self: this }, function* () {
14992
+ if (this.state.focus !== "review") {
14993
+ this.commit(reduce(this.measured(), "compose.open"));
14994
+ return;
14995
+ }
14996
+ yield* this.openPanelEntry();
14997
+ });
14998
+ }
14999
+ openPanelEntry() {
15000
+ return gen({ self: this }, function* () {
15001
+ const entry = panelEntry(this.state);
15002
+ if (entry === void 0) {
15003
+ this.commit(withNoticeHere(this.state, "nothing in the review yet"));
15004
+ return;
15005
+ }
15006
+ const at = this.state.patches.findIndex((patch) => patch.path === entry.comment.file);
15007
+ const patch = this.state.patches[at];
15008
+ if (patch === void 0) {
15009
+ this.commit(withNoticeHere(this.state, `${entry.comment.file} is not on this branch`));
15010
+ return;
15011
+ }
15012
+ const landed = atFile(this.state, at);
15013
+ this.commit({
15014
+ ...landed,
15015
+ cursor: rowAtSourceLine(patch, entry.comment.end)
15016
+ });
15017
+ yield* this.loadSource();
15018
+ });
15019
+ }
14647
15020
  settleHere() {
14648
15021
  return gen({ self: this }, function* () {
14649
15022
  const branch = selectedBranch(this.state);
@@ -14698,8 +15071,10 @@ var init_app = __esmMin((() => {
14698
15071
  if (branch === void 0) return;
14699
15072
  const path = selectedPatch(this.state)?.path;
14700
15073
  const line = sourceLineAt(this.state, this.state.cursor);
15074
+ const offset = this.state.cursor - this.state.top;
14701
15075
  const read = yield* this.readBranch(branch.branch);
14702
- this.commit(withWaiting(withNotice(restoredTo(read, path, line), "read the branch again"), ""));
15076
+ const held = restoredTo(read, path, line, offset);
15077
+ this.commit(withWaiting(withNotice(held, "read the branch again"), ""));
14703
15078
  yield* this.loadSource();
14704
15079
  });
14705
15080
  }
@@ -14804,7 +15179,8 @@ var init_app = __esmMin((() => {
14804
15179
  const next = withPending({
14805
15180
  ...this.state,
14806
15181
  editing: void 0,
14807
- draft: ""
15182
+ draft: "",
15183
+ caret: 0
14808
15184
  }, pending, "pending");
14809
15185
  this.commit(withNoticeHere(next, "reworded"));
14810
15186
  });
@@ -14843,9 +15219,11 @@ var init_app = __esmMin((() => {
14843
15219
  });
14844
15220
  }
14845
15221
  expand(delta) {
15222
+ return this.widen(layerContext(this.state.context, delta));
15223
+ }
15224
+ widen(next) {
14846
15225
  return gen({ self: this }, function* () {
14847
15226
  const branch = selectedBranch(this.state);
14848
- const next = layerContext(this.state.context, delta);
14849
15227
  if (branch === void 0 || next === this.state.context) return;
14850
15228
  const line = sourceLineAt(this.state, this.state.cursor);
14851
15229
  const patches = yield* listPatches(this.repo, branch.branch, next);
@@ -14870,12 +15248,11 @@ var init_app = __esmMin((() => {
14870
15248
  editStagedComment() {
14871
15249
  const entry = this.state.pending[this.state.pendingIndex];
14872
15250
  if (entry?.id === void 0) return;
14873
- this.commit({
15251
+ this.commit(withDraft({
14874
15252
  ...this.state,
14875
15253
  screen: "compose",
14876
- draft: entry.body,
14877
15254
  editing: entry.id
14878
- });
15255
+ }, entry.body));
14879
15256
  }
14880
15257
  dropStagedComment() {
14881
15258
  return gen({ self: this }, function* () {
@@ -14926,7 +15303,8 @@ var init_app = __esmMin((() => {
14926
15303
  const closed = {
14927
15304
  ...this.state,
14928
15305
  screen: this.state.returnTo,
14929
- draft: ""
15306
+ draft: "",
15307
+ caret: 0
14930
15308
  };
14931
15309
  this.commit(withNotice(closed, `report copied — ${path}`));
14932
15310
  });
@@ -14959,10 +15337,22 @@ var init_app = __esmMin((() => {
14959
15337
  }
14960
15338
  };
14961
15339
  settledPath = (path) => promise(() => realpath(path).catch(() => resolve(path)));
14962
- launch = fn("Tui.launch")(function* (asked, renderer, noticeMs, sessionPath) {
15340
+ openingOn = (branches, branch) => {
15341
+ if (branch === void 0) return none();
15342
+ const at = branches.findIndex((candidate) => candidate.branch === branch);
15343
+ return at === -1 ? none() : some({
15344
+ branchIndex: at,
15345
+ patchIndex: 0,
15346
+ cursor: 0,
15347
+ top: 0
15348
+ });
15349
+ };
15350
+ launch = fn("Tui.launch")(function* (asked, renderer, options = {}) {
15351
+ const { noticeMs, sessionPath } = options;
14963
15352
  const repo = yield* settledPath(asked);
14964
15353
  const branches = yield* listBranches(repo);
14965
- const resume = sessionPath === void 0 ? none() : yield* readSession(sessionPath);
15354
+ const asOpened = openingOn(branches, options.branch);
15355
+ const resume = isSome(asOpened) ? asOpened : sessionPath === void 0 ? none() : yield* readSession(sessionPath);
14966
15356
  const store = yield* Store;
14967
15357
  const wrap = (yield* store.settings).wrap === true;
14968
15358
  const display = yield* Display.pipe(provide(displayOn(renderer, repo)));
@@ -14995,13 +15385,16 @@ var init_app = __esmMin((() => {
14995
15385
  untilDestroyed = (renderer) => callback$1((resume) => {
14996
15386
  renderer.on("destroy", () => resume(void_));
14997
15387
  });
14998
- runOn = fn("Tui.runOn")(function* (repo, renderer, sessionPath) {
14999
- yield* launch(repo, renderer, void 0, sessionPath);
15388
+ runOn = fn("Tui.runOn")(function* (repo, renderer, sessionPath, branch) {
15389
+ yield* launch(repo, renderer, {
15390
+ sessionPath,
15391
+ branch
15392
+ });
15000
15393
  yield* untilDestroyed(renderer);
15001
15394
  });
15002
- runTui = fn("Tui.run")(function* (repo, sessionPath) {
15395
+ runTui = fn("Tui.run")(function* (repo, sessionPath, branch) {
15003
15396
  const renderer = yield* promise(() => createCliRenderer({ exitOnCtrlC: true }));
15004
- yield* runOn(repo, renderer, sessionPath);
15397
+ yield* runOn(repo, renderer, sessionPath, branch);
15005
15398
  });
15006
15399
  }));
15007
15400
  //#endregion
@@ -15177,7 +15570,7 @@ const init = fn("Main.init")(function* (options) {
15177
15570
  });
15178
15571
  });
15179
15572
  const reviewPane = fn("Main.reviewPane")(function* (options) {
15180
- const report = yield* openPane(yield* required(options, "repo"));
15573
+ const report = yield* openPane(yield* required(options, "repo"), options["branch"]);
15181
15574
  yield* answer(options, {
15182
15575
  opened: report.opened,
15183
15576
  pane: report.pane,
@@ -15265,7 +15658,7 @@ const dispatch = fn("Main.dispatch")(function* (name, given) {
15265
15658
  if (name === "file review") return yield* fileReview(options);
15266
15659
  if (name === "review open") {
15267
15660
  const { runTui } = yield* promise(() => Promise.resolve().then(() => (init_tui(), tui_exports)));
15268
- return yield* runTui(yield* required(options, "repo"), process.env["ADIFF_SESSION"]);
15661
+ return yield* runTui(yield* required(options, "repo"), process.env["ADIFF_SESSION"], options["branch"]);
15269
15662
  }
15270
15663
  return yield* unknown(name);
15271
15664
  });
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.48",
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