@eliya-oss/agent-diff 0.1.0-alpha.46 → 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,23 @@
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
+
15
+ ## 0.1.0-alpha.47
16
+
17
+ ### Minor Changes
18
+
19
+ - `adiff upgrade` upgrades. It runs the command for the install it found instead of printing it, shows the package manager working, and ends by naming the version you now have. `--check` reports without running, `--run` still works and does nothing, and a route adiff cannot do for you, a downloaded binary or a checkout, explains why and exits 1.
20
+
3
21
  ## 0.1.0-alpha.46
4
22
 
5
23
  ### Patch Changes
package/dist/main.js CHANGED
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
2
2
  import { appendFile, mkdir, readFile, realpath, writeFile } from "node:fs/promises";
3
3
  import { text } from "node:stream/consumers";
4
4
  import { dirname, join, resolve } from "node:path";
5
- import { execFile } from "node:child_process";
5
+ import { execFile, spawn } from "node:child_process";
6
6
  import { promisify } from "node:util";
7
7
  import { homedir, hostname, platform } from "node:os";
8
8
  import { existsSync, mkdirSync, readFileSync, watch } from "node:fs";
@@ -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$1, 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
- ran$1 = (binary, args) => callback$1((resume) => {
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$1(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,10 +9201,10 @@ var init_pane = __esmMin((() => {
9199
9201
  init_commands();
9200
9202
  init_init();
9201
9203
  init_pane();
9202
- var version$1 = "0.1.0-alpha.46";
9204
+ var version$1 = "0.1.0-alpha.48";
9203
9205
  //#endregion
9204
9206
  //#region src/cli/upgrade.ts
9205
- var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf, newer, tagIn, fetched, askLatest, ran, here, statusOf$1, ranLine, failedLine, noteFor, offerFor, restOf, sayUpgrade, upgradeAdiff;
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;
9206
9208
  var init_upgrade$1 = __esmMin((() => {
9207
9209
  init_dist();
9208
9210
  PACKAGE = "@eliya-oss/agent-diff";
@@ -9221,6 +9223,14 @@ var init_upgrade$1 = __esmMin((() => {
9221
9223
  if (!INSTALLED.test(module)) return "source";
9222
9224
  return BUN_GLOBAL.test(module) ? "bun" : "npm";
9223
9225
  };
9226
+ ROUTES = [
9227
+ "brew",
9228
+ "npm",
9229
+ "bun",
9230
+ "binary",
9231
+ "source"
9232
+ ];
9233
+ asRoute = (named) => ROUTES.find((route) => route === named);
9224
9234
  checkoutOf = (module) => module.replace(/[/\\](?:src|dist)[/\\].*$/, "").replace(/[/\\](?:src|dist)$/, "");
9225
9235
  assetOf = () => `adiff-${process.platform}-${process.arch}`;
9226
9236
  commandFor = (route, executable, module) => {
@@ -9237,6 +9247,10 @@ var init_upgrade$1 = __esmMin((() => {
9237
9247
  binary: "This is a downloaded binary, so nothing upgrades it on its own, and a running executable cannot rewrite itself.",
9238
9248
  source: "This is running from a checkout, so git is what updates it."
9239
9249
  };
9250
+ REFUSALS = {
9251
+ binary: `adiff cannot do this one for you. Every build is listed on ${RELEASES}.`,
9252
+ source: "adiff will not pull your checkout for you."
9253
+ };
9240
9254
  RUNNABLE = /* @__PURE__ */ new Set([
9241
9255
  "brew",
9242
9256
  "npm",
@@ -9278,64 +9292,90 @@ var init_upgrade$1 = __esmMin((() => {
9278
9292
  };
9279
9293
  fetched = (url) => fetch(url, { signal: AbortSignal.timeout(ASK_MS) }).then((response) => response.ok ? response.json() : void 0).then(tagIn).catch(() => void 0);
9280
9294
  askLatest = promise(() => fetched(process.env["ADIFF_REGISTRY"] ?? REGISTRY));
9281
- ran = (command) => callback$1((resume) => {
9282
- execFile("/bin/sh", ["-c", command], { timeout: RUN_MS }, (cause) => resume(succeed(!cause)));
9283
- });
9284
9295
  here = () => ({
9285
9296
  executable: process.execPath,
9286
9297
  module: fileURLToPath(new URL(".", import.meta.url))
9287
9298
  });
9288
- statusOf$1 = (told) => {
9289
- if (!told.checked) return `adiff ${told.version} is installed. The registry did not answer, so adiff cannot tell whether a newer build is out.`;
9290
- if (told.current === true) return `adiff ${told.version} is the newest build.`;
9291
- return `adiff ${told.version} is installed, and ${told.latest} is out.`;
9292
- };
9293
- ranLine = (told) => told.latest === void 0 ? `Ran \`${told.command}\`. Run \`adiff --version\` to see what you have now.` : `Ran \`${told.command}\`, so the next adiff you run will be ${told.latest}.`;
9294
- failedLine = (told) => `Ran \`${told.command}\` and it did not work. Run it yourself to see what it said.`;
9295
- noteFor = (told, run) => {
9296
- if (told.current === true) return statusOf$1(told);
9297
- if (told.ran) return `${statusOf$1(told)} ${ranLine(told)}`;
9298
- if (run && RUNNABLE.has(told.route)) return `${statusOf$1(told)} ${failedLine(told)}`;
9299
- const refused = run ? " adiff will not run this one for you; run it yourself." : "";
9300
- return `${statusOf$1(told)} ${NOTES[told.route]}${refused} Run \`${told.command}\` to upgrade.`;
9301
- };
9302
- offerFor = (told) => RUNNABLE.has(told.route) ? "Or run `adiff upgrade --run` and adiff runs that for you." : `Every build is listed on ${RELEASES}.`;
9303
- restOf = (told, run) => {
9304
- if (told.ran) return [ranLine(told)];
9305
- if (run && RUNNABLE.has(told.route)) return [failedLine(told)];
9306
- const refused = run ? " adiff will not run this one for you; run it yourself." : "";
9307
- return [
9308
- `${NOTES[told.route]}${refused}`,
9309
- ` ${told.command}`,
9310
- offerFor(told)
9311
- ];
9312
- };
9313
- sayUpgrade = (told, run) => told.current === true ? statusOf$1(told) : [statusOf$1(told), ...restOf(told, run)].join("\n\n");
9314
- upgradeAdiff = fn("Cli.upgradeAdiff")(function* (run) {
9299
+ findUpgrade = gen(function* () {
9315
9300
  const { executable, module } = here();
9316
- const route = routeOf(executable, module);
9301
+ const route = asRoute(process.env["ADIFF_UPGRADE_ROUTE"]) ?? routeOf(executable, module);
9317
9302
  const version = version$1;
9318
9303
  const command = commandFor(route, executable, module);
9319
9304
  const latest = yield* askLatest;
9320
- const current = latest === void 0 ? void 0 : !newer(latest, version);
9321
9305
  const known = latest === void 0 ? {} : {
9322
9306
  latest,
9323
- current: current === true
9307
+ current: !newer(latest, version)
9324
9308
  };
9325
- const performed = run && RUNNABLE.has(route) && current !== true ? yield* ran(command) : false;
9326
- const told = {
9309
+ return {
9327
9310
  route,
9328
9311
  version,
9329
9312
  checked: latest !== void 0,
9330
9313
  ...known,
9331
- command,
9332
- ran: performed
9314
+ command
9333
9315
  };
9316
+ }).pipe(withSpan("Cli.findUpgrade"));
9317
+ willUpgrade = (found, check) => !check && found.current !== true && RUNNABLE.has(found.route);
9318
+ runUpgrade = (found, quiet) => callback$1((resume) => {
9319
+ let answered = false;
9320
+ const settle = (worked) => {
9321
+ if (answered) return;
9322
+ answered = true;
9323
+ resume(succeed(worked));
9324
+ };
9325
+ const child = spawn("/bin/sh", ["-c", found.command], {
9326
+ timeout: RUN_MS,
9327
+ stdio: quiet ? "ignore" : [
9328
+ "ignore",
9329
+ "inherit",
9330
+ "inherit"
9331
+ ]
9332
+ });
9333
+ child.on("error", () => settle(false));
9334
+ child.on("close", (code) => settle(code === 0));
9335
+ }).pipe(withSpan("Cli.runUpgrade"));
9336
+ statusOf$1 = (found) => {
9337
+ if (!found.checked) return `adiff ${found.version} is installed. The registry did not answer, so adiff cannot tell whether a newer build is out.`;
9338
+ if (found.current === true) return `adiff ${found.version} is the newest build.`;
9339
+ return `adiff ${found.version} is installed, and ${found.latest} is out.`;
9340
+ };
9341
+ refusalOf = (found) => {
9342
+ const refusal = REFUSALS[found.route];
9343
+ return refusal === void 0 ? NOTES[found.route] : `${NOTES[found.route]} ${refusal}`;
9344
+ };
9345
+ OFFER = "Run `adiff upgrade` and adiff runs that for you.";
9346
+ sayFound = (found, check) => {
9347
+ if (found.current === true) return statusOf$1(found);
9348
+ if (willUpgrade(found, check)) return [
9349
+ statusOf$1(found),
9350
+ `${NOTES[found.route]} Running it now:`,
9351
+ ` ${found.command}`
9352
+ ].join("\n\n");
9353
+ const offer = RUNNABLE.has(found.route) ? [OFFER] : [];
9354
+ return [
9355
+ statusOf$1(found),
9356
+ refusalOf(found),
9357
+ ` ${found.command}`,
9358
+ ...offer
9359
+ ].join("\n\n");
9360
+ };
9361
+ sayDone = (found, ran) => {
9362
+ if (!ran) return `That did not work. Run \`${found.command}\` yourself to see what it said.`;
9363
+ if (found.latest === void 0) return "That worked. Run `adiff --version` to see which build you have now.";
9364
+ return `adiff ${found.latest} is installed now.`;
9365
+ };
9366
+ attempted = (found, ran) => {
9367
+ if (!ran) return `Ran \`${found.command}\` and it did not work. Run it yourself to see what it said.`;
9368
+ if (found.latest === void 0) return `Ran \`${found.command}\`. Run \`adiff --version\` to see which build you have now.`;
9369
+ return `Ran \`${found.command}\`, and adiff ${found.latest} is installed now.`;
9370
+ };
9371
+ upgradeReport = (found, ran, check) => {
9372
+ const note = found.current === true ? statusOf$1(found) : willUpgrade(found, check) ? `${statusOf$1(found)} ${attempted(found, ran)}` : `${statusOf$1(found)} ${refusalOf(found)} Run \`${found.command}\` to upgrade.`;
9334
9373
  return {
9335
- ...told,
9336
- note: noteFor(told, run)
9374
+ ...found,
9375
+ ran,
9376
+ note
9337
9377
  };
9338
- });
9378
+ };
9339
9379
  }));
9340
9380
  //#endregion
9341
9381
  //#region src/cli/search.ts
@@ -9866,7 +9906,7 @@ var init_parse = __esmMin((() => {
9866
9906
  }));
9867
9907
  //#endregion
9868
9908
  //#region src/cli/catalog.ts
9869
- 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;
9870
9910
  var init_catalog = __esmMin((() => {
9871
9911
  worktreeOf = {
9872
9912
  name: "worktree",
@@ -9897,6 +9937,12 @@ var init_catalog = __esmMin((() => {
9897
9937
  value: "path",
9898
9938
  about: "Repository whose worktrees are reviewed"
9899
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
+ };
9900
9946
  file = {
9901
9947
  name: "file",
9902
9948
  required: true,
@@ -9948,21 +9994,21 @@ var init_catalog = __esmMin((() => {
9948
9994
  },
9949
9995
  {
9950
9996
  name: "review open",
9951
- 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",
9952
9998
  group: READ_A_BRANCH,
9953
9999
  addresses: "repo",
9954
10000
  safety: "read",
9955
- options: [repo],
10001
+ options: [repo, opening$1],
9956
10002
  dataKey: "",
9957
- example: "adiff review open --repo ."
10003
+ example: "adiff review open --repo . --branch cdr-1"
9958
10004
  },
9959
10005
  {
9960
10006
  name: "review pane",
9961
- 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",
9962
10008
  group: READ_A_BRANCH,
9963
10009
  addresses: "repo",
9964
10010
  safety: "read",
9965
- options: [repo],
10011
+ options: [repo, opening$1],
9966
10012
  dataKey: "pane",
9967
10013
  example: "adiff review pane --repo ."
9968
10014
  },
@@ -10196,15 +10242,15 @@ var init_catalog = __esmMin((() => {
10196
10242
  },
10197
10243
  {
10198
10244
  name: "upgrade",
10199
- about: "Say whether a newer adiff is out and name the one command that installs it. Answers a person in plain text, and a caller in JSON with --json",
10245
+ about: "Upgrade this install to the newest build, using whatever installed it. Answers a person in plain text, and a caller in JSON with --json",
10200
10246
  group: SET_UP,
10201
10247
  addresses: "none",
10202
- safety: "read",
10248
+ safety: "write",
10203
10249
  options: [{
10204
- name: "run",
10250
+ name: "check",
10205
10251
  required: false,
10206
10252
  value: "flag",
10207
- about: "Run the command instead of printing it. Ignored for a downloaded binary or a checkout, which adiff will not rewrite under itself"
10253
+ about: "Report what would happen and name the command, without running anything. Always exits 0"
10208
10254
  }, {
10209
10255
  name: "json",
10210
10256
  required: false,
@@ -10212,7 +10258,7 @@ var init_catalog = __esmMin((() => {
10212
10258
  about: "Answer with the usual envelope instead of plain text. This is the only command that needs it"
10213
10259
  }],
10214
10260
  dataKey: "upgrade",
10215
- example: "adiff upgrade --json --fields route,command"
10261
+ example: "adiff upgrade --check --json --fields route,latest,current"
10216
10262
  },
10217
10263
  {
10218
10264
  name: "describe",
@@ -10848,13 +10894,20 @@ var init_tree = __esmMin((() => {
10848
10894
  return node.children.reduce((total, child) => total + filesUnder(tree, child), 0);
10849
10895
  };
10850
10896
  crowdedDirectories = (tree, limit) => tree.nodes.filter((node) => node.kind === "directory" && directFiles(tree, node.id) > limit).map((node) => node.path);
10851
- })), 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;
10852
10898
  var init_model = __esmMin((() => {
10853
10899
  init_dist();
10854
10900
  init_patch();
10855
10901
  init_gaps();
10856
10902
  init_tree();
10903
+ nothingReviewed = {
10904
+ arrived: [],
10905
+ panelOpen: true,
10906
+ panelIndex: 0,
10907
+ columns: 0
10908
+ };
10857
10909
  initialState = (branches) => ({
10910
+ ...nothingReviewed,
10858
10911
  screen: "branches",
10859
10912
  branches,
10860
10913
  branchIndex: 0,
@@ -10866,6 +10919,7 @@ var init_model = __esmMin((() => {
10866
10919
  anchorRow: 0,
10867
10920
  selecting: false,
10868
10921
  draft: "",
10922
+ caret: 0,
10869
10923
  notice: "",
10870
10924
  waiting: "",
10871
10925
  query: "",
@@ -10880,6 +10934,7 @@ var init_model = __esmMin((() => {
10880
10934
  editing: void 0,
10881
10935
  viewport: 20,
10882
10936
  context: 3,
10937
+ contextWas: 3,
10883
10938
  top: 0,
10884
10939
  source: [],
10885
10940
  full: [],
@@ -10899,6 +10954,22 @@ var init_model = __esmMin((() => {
10899
10954
  matchIndex: 0,
10900
10955
  rail: "tree"
10901
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);
10902
10973
  onLayers = (state) => state.rail === "layers" && state.layers.length > 0;
10903
10974
  selectedLayer = (state) => state.layers[state.layerIndex];
10904
10975
  proseFor = (state, path) => {
@@ -11067,6 +11138,31 @@ var init_model = __esmMin((() => {
11067
11138
  onNone: () => "-",
11068
11139
  onSome: (line) => String(line)
11069
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));
11070
11166
  editedComment = (state) => state.editing === void 0 ? void 0 : state.pending.find((entry) => entry.id === state.editing);
11071
11167
  composeTarget = (state) => {
11072
11168
  const edited = editedComment(state);
@@ -11160,6 +11256,8 @@ var init_model = __esmMin((() => {
11160
11256
  60,
11161
11257
  WHOLE_FILE
11162
11258
  ];
11259
+ wholeFileOff = (state) => state.context < WHOLE_FILE;
11260
+ contextToggled = (state) => wholeFileOff(state) ? WHOLE_FILE : state.contextWas;
11163
11261
  layerContext = (current, delta) => {
11164
11262
  const at = CONTEXT_STEPS.indexOf(current);
11165
11263
  const next = Math.max(0, Math.min(CONTEXT_STEPS.length - 1, (at === -1 ? 0 : at) + delta));
@@ -11212,6 +11310,36 @@ var init_model = __esmMin((() => {
11212
11310
  };
11213
11311
  filesWithComments = (state) => state.patches.flatMap((patch, index) => [...state.pending, ...state.sent].some((entry) => entry.file === patch.path) ? [index] : []);
11214
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];
11215
11343
  spokenSince = (seen, now) => Math.max(0, answerCount(now) - answerCount(seen));
11216
11344
  hunkStarts = (state) => {
11217
11345
  const patch = selectedPatch(state);
@@ -11442,6 +11570,12 @@ var init_command = __esmMin((() => {
11442
11570
  keys: ["-", "_"],
11443
11571
  screens: ["review"]
11444
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
+ }),
11445
11579
  command({
11446
11580
  action: "comment.next",
11447
11581
  title: "Next comment",
@@ -11490,6 +11624,13 @@ var init_command = __esmMin((() => {
11490
11624
  keys: ["tab"],
11491
11625
  screens: ["review"]
11492
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
+ }),
11493
11634
  command({
11494
11635
  action: "nav.zoom",
11495
11636
  title: "Hide the file list",
@@ -11891,7 +12032,7 @@ var init_match = __esmMin((() => {
11891
12032
  }));
11892
12033
  //#endregion
11893
12034
  //#region src/tui/reduce.ts
11894
- 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;
11895
12036
  var init_reduce = __esmMin((() => {
11896
12037
  init_dist();
11897
12038
  init_patch();
@@ -12020,7 +12161,30 @@ var init_reduce = __esmMin((() => {
12020
12161
  };
12021
12162
  };
12022
12163
  inRail = (state, delta) => onLayers(state) ? moveLayer(state, delta) : moveFile(state, delta);
12023
- 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
+ };
12024
12188
  toggleRail = (state) => {
12025
12189
  if (state.layers.length === 0) return withNotice(state, "no layers for this branch");
12026
12190
  if (state.rail === "layers") return {
@@ -12105,6 +12269,7 @@ var init_reduce = __esmMin((() => {
12105
12269
  ...state,
12106
12270
  screen: "compose",
12107
12271
  draft: "",
12272
+ caret: 0,
12108
12273
  anchorRow: state.selecting ? state.anchorRow : state.cursor
12109
12274
  };
12110
12275
  };
@@ -12122,7 +12287,8 @@ var init_reduce = __esmMin((() => {
12122
12287
  if (state.screen === "report") return {
12123
12288
  ...state,
12124
12289
  screen: state.returnTo,
12125
- draft: ""
12290
+ draft: "",
12291
+ caret: 0
12126
12292
  };
12127
12293
  if (state.screen === "palette") return {
12128
12294
  ...state,
@@ -12136,7 +12302,8 @@ var init_reduce = __esmMin((() => {
12136
12302
  if (state.screen === "compose") return {
12137
12303
  ...state,
12138
12304
  screen: "review",
12139
- draft: ""
12305
+ draft: "",
12306
+ caret: 0
12140
12307
  };
12141
12308
  if (state.selecting) return {
12142
12309
  ...state,
@@ -12188,6 +12355,7 @@ var init_reduce = __esmMin((() => {
12188
12355
  "cursor.pageUp": (state) => moveCursor(state, -Math.max(1, Math.floor(state.viewport / 2))),
12189
12356
  "context.more": (state) => state,
12190
12357
  "context.less": (state) => state,
12358
+ "context.whole": (state) => state,
12191
12359
  "comment.next": (state) => layerComment(state, 1),
12192
12360
  "comment.prev": (state) => layerComment(state, -1),
12193
12361
  "hunk.next": (state) => layerHunk(state, 1),
@@ -12207,15 +12375,13 @@ var init_reduce = __esmMin((() => {
12207
12375
  "pending.drop": (state) => state,
12208
12376
  "pending.next": (state) => movePending(state, 1),
12209
12377
  "pending.prev": (state) => movePending(state, -1),
12210
- "compose.newline": (state) => ({
12211
- ...state,
12212
- draft: `${state.draft}\n`
12213
- }),
12378
+ "compose.newline": (state) => inserted(state, "\n"),
12214
12379
  "focus.toggle": (state) => ({
12215
12380
  ...state,
12216
- focus: state.focus === "diff" ? "tree" : "diff",
12381
+ focus: nextFocus(state),
12217
12382
  navOpen: true
12218
12383
  }),
12384
+ "panel.toggle": togglePanel,
12219
12385
  "nav.zoom": (state) => ({
12220
12386
  ...state,
12221
12387
  navOpen: !state.navOpen,
@@ -12240,6 +12406,7 @@ var init_reduce = __esmMin((() => {
12240
12406
  ...state,
12241
12407
  screen: "report",
12242
12408
  draft: "",
12409
+ caret: 0,
12243
12410
  returnTo: state.screen
12244
12411
  }),
12245
12412
  "report.send": (state) => state,
@@ -12267,6 +12434,7 @@ var init_reduce = __esmMin((() => {
12267
12434
  withContext = (state, context, patches, cursor) => ({
12268
12435
  ...state,
12269
12436
  context,
12437
+ contextWas: state.context < 1e5 ? state.context : state.contextWas,
12270
12438
  patches,
12271
12439
  revealed: [],
12272
12440
  cursor,
@@ -12315,7 +12483,17 @@ var init_reduce = __esmMin((() => {
12315
12483
  };
12316
12484
  withSent = (state, sent) => ({
12317
12485
  ...state,
12318
- 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
12319
12497
  });
12320
12498
  withLayers = (state, told) => {
12321
12499
  const layers = told.layers;
@@ -12357,14 +12535,17 @@ var init_reduce = __esmMin((() => {
12357
12535
  ...state,
12358
12536
  vouched
12359
12537
  });
12360
- restoredTo = (state, path, line) => {
12538
+ restoredTo = (state, path, line, offset) => {
12361
12539
  const index = state.patches.findIndex((patch) => patch.path === path);
12362
12540
  const patch = state.patches[index];
12363
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));
12364
12544
  return withCursorVisible({
12365
12545
  ...state,
12366
12546
  patchIndex: index,
12367
- cursor: line === void 0 ? 0 : rowAtSourceLine(patch, line)
12547
+ cursor,
12548
+ top
12368
12549
  });
12369
12550
  };
12370
12551
  withPatches = (state, patches) => ({
@@ -12383,22 +12564,59 @@ var init_reduce = __esmMin((() => {
12383
12564
  anchorRow: 0,
12384
12565
  selecting: false
12385
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
+ };
12386
12575
  typed = (state, character) => state.screen === "palette" ? {
12387
12576
  ...state,
12388
12577
  query: `${state.query}${character}`,
12389
12578
  paletteIndex: 0
12390
- } : {
12391
- ...state,
12392
- 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
+ };
12593
+ };
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
+ };
12393
12602
  };
12394
- backspaced = (state) => state.screen === "palette" ? {
12603
+ caretMoved = (state, delta) => ({
12395
12604
  ...state,
12396
- query: state.query.slice(0, -1),
12397
- paletteIndex: 0
12398
- } : {
12605
+ caret: clamp(caretAt(state) + delta, 0, state.draft.length)
12606
+ });
12607
+ caretJumped = (state, delta) => ({
12399
12608
  ...state,
12400
- draft: state.draft.slice(0, -1)
12401
- };
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
+ });
12402
12620
  paletteMoved = (state, delta) => movePalette(state, delta);
12403
12621
  paletteClosed = (state) => ({
12404
12622
  ...state,
@@ -12425,6 +12643,7 @@ var init_reduce = __esmMin((() => {
12425
12643
  ...state,
12426
12644
  screen: "review",
12427
12645
  draft: "",
12646
+ caret: 0,
12428
12647
  selecting: false,
12429
12648
  notice
12430
12649
  });
@@ -12712,6 +12931,9 @@ var init_diffview = __esmMin((() => {
12712
12931
  pinNode() {
12713
12932
  return this.pinBox;
12714
12933
  }
12934
+ pinRows() {
12935
+ return this.pinBox.height;
12936
+ }
12715
12937
  noteRoom() {
12716
12938
  return Math.max(NOTE_MIN, this.code.width - this.gutterWidth() - 3);
12717
12939
  }
@@ -12865,12 +13087,23 @@ var init_diffview = __esmMin((() => {
12865
13087
  if (sources.length === 0) return false;
12866
13088
  return visual > 0 && sources[visual] === sources[visual - 1];
12867
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
+ }
12868
13102
  scrollTo(row, cursor) {
12869
13103
  const highest = Math.max(0, this.tallest() - this.rows());
12870
- const wanted = this.visualOf(this.starts.get(row) ?? row);
12871
- const line = this.starts.get(cursor);
12872
- const at = line === void 0 ? void 0 : this.visualOf(line);
12873
- 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;
12874
13107
  const clamped = Math.max(0, Math.min(highest, kept));
12875
13108
  if (this.code.scrollY !== clamped) this.code.scrollY = clamped;
12876
13109
  return clamped;
@@ -13033,7 +13266,7 @@ var init_diffview = __esmMin((() => {
13033
13266
  }));
13034
13267
  //#endregion
13035
13268
  //#region src/tui/render.ts
13036
- 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;
13037
13270
  var init_render = __esmMin((() => {
13038
13271
  init_command();
13039
13272
  init_patch();
@@ -13068,23 +13301,12 @@ var init_render = __esmMin((() => {
13068
13301
  PANEL_FOOT = 2;
13069
13302
  PANEL_QUARTER = 4;
13070
13303
  PANEL_FIFTH = 5;
13071
- TREE_MAX = 34;
13072
- TREE_MIN = 18;
13073
- TREE_SHARE = .3;
13074
- DIFF_MIN = 24;
13075
- BODY_BORDER = 2;
13076
13304
  PANE_CHROME = 3;
13077
13305
  BRANCH_WIDTH = 82;
13078
13306
  BRANCH_NAME_MIN = 12;
13079
13307
  BRANCH_TAIL = 45;
13080
13308
  EMPTY_LIST = " nothing to review. No worktree differs from the branch it started from.";
13081
13309
  MODAL_MARGIN = 4;
13082
- bodyRoom = (width) => Math.max(0, width - 2 - BODY_BORDER);
13083
- treeWidth = (width) => {
13084
- const room = bodyRoom(width);
13085
- const wanted = Math.min(TREE_MAX, Math.max(TREE_MIN, Math.floor(room * TREE_SHARE)));
13086
- return Math.max(0, Math.min(wanted, room - DIFF_MIN));
13087
- };
13088
13310
  shareOf = (width, least) => Math.max(least, Math.min(PANEL_MAX, Math.floor(width * PANEL_SHARE)));
13089
13311
  homeWidth = (width, longest) => Math.max(0, Math.min(width - 2, Math.min(PANEL_MAX, Math.max(BRANCH_WIDTH, longest + BRANCH_TAIL))));
13090
13312
  longestName = (state) => Math.max(0, ...state.branches.map((branch) => branch.branch.length));
@@ -13158,6 +13380,31 @@ var init_render = __esmMin((() => {
13158
13380
  overflow: "hidden",
13159
13381
  visible: false
13160
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
+ };
13161
13408
  makeListParts = (renderer) => {
13162
13409
  const pane = makeList(renderer);
13163
13410
  const text = makeListText(renderer);
@@ -13556,12 +13803,79 @@ var init_render = __esmMin((() => {
13556
13803
  if (row.kind === "note") return palette.faint;
13557
13804
  return row.index === state.layerIndex ? palette.ink : palette.muted;
13558
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
+ };
13559
13871
  Screen = class {
13560
13872
  header;
13561
13873
  body;
13562
13874
  listPane;
13563
13875
  list;
13564
13876
  diffPane;
13877
+ panelPane;
13878
+ panel;
13565
13879
  scrim;
13566
13880
  gutter;
13567
13881
  diffScroll;
@@ -13616,6 +13930,9 @@ var init_render = __esmMin((() => {
13616
13930
  this.landing = home.path;
13617
13931
  this.landingKeys = home.keys;
13618
13932
  this.diffPane = makeDiffPane(renderer);
13933
+ const panel = makePanel(renderer);
13934
+ this.panelPane = panel.pane;
13935
+ this.panel = panel.text;
13619
13936
  this.diffScroll = makeScroll(renderer);
13620
13937
  this.view = new DiffView(renderer);
13621
13938
  const inside = makeComposeParts(renderer);
@@ -13642,8 +13959,17 @@ var init_render = __esmMin((() => {
13642
13959
  this.foundChoices = modals.found.choices;
13643
13960
  this.assemble(renderer);
13644
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
+ }
13645
13969
  listen(mouse) {
13646
13970
  this.mouse = mouse;
13971
+ this.wheelOnSheet(this.keys);
13972
+ this.wheelOnSheet(this.palette);
13647
13973
  this.view.listenTo({
13648
13974
  scroll: (delta) => this.mouse?.onScroll(delta),
13649
13975
  pan: (delta) => this.mouse?.onPan(delta),
@@ -13672,7 +13998,8 @@ var init_render = __esmMin((() => {
13672
13998
  return this.view.room();
13673
13999
  }
13674
14000
  diffRows() {
13675
- 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);
13676
14003
  }
13677
14004
  update(state) {
13678
14005
  this.shown = state;
@@ -13692,6 +14019,7 @@ var init_render = __esmMin((() => {
13692
14019
  this.landingKeys.content = this.homeKeys(state);
13693
14020
  this.diffPane.visible = state.screen !== "branches" && !atHome(state);
13694
14021
  if (this.diffPane.visible) this.paintDiff(state);
14022
+ this.paintPanel(state);
13695
14023
  this.paintPane(state);
13696
14024
  this.paintCompose(state);
13697
14025
  this.paintPalette(state);
@@ -13773,6 +14101,17 @@ var init_render = __esmMin((() => {
13773
14101
  paneRoom() {
13774
14102
  return treeWidth(this.renderer.width);
13775
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
+ }
13776
14115
  listText(state) {
13777
14116
  if (atHome(state)) return this.branchTable(state);
13778
14117
  if (onLayers(state)) return this.layerRail(state);
@@ -13804,7 +14143,7 @@ var init_render = __esmMin((() => {
13804
14143
  this.view.setWrap(state.wrap);
13805
14144
  this.view.setPan(state.pan);
13806
14145
  this.view.show(patch, notesFor(state, patch.path), gapRowSet(shown), proseFor(state, patch.path));
13807
- this.view.fit(this.diffScroll.height);
14146
+ this.view.fit(this.diffRows());
13808
14147
  const height = this.view.rows();
13809
14148
  const top = this.view.scrollTo(state.top, state.cursor);
13810
14149
  this.lastTop = top;
@@ -13842,6 +14181,7 @@ var init_render = __esmMin((() => {
13842
14181
  this.watchChips();
13843
14182
  this.body.add(this.listPane);
13844
14183
  this.body.add(this.diffPane);
14184
+ this.body.add(this.panelPane);
13845
14185
  stack(this.compose, [
13846
14186
  this.composeTitle,
13847
14187
  this.composeBody,
@@ -13997,7 +14337,7 @@ var init_render = __esmMin((() => {
13997
14337
  const lines = laidOut([
13998
14338
  "What went wrong? Everything on screen is attached for you.",
13999
14339
  "",
14000
- `${state.draft}▌`
14340
+ drafted(state)
14001
14341
  ], room.text);
14002
14342
  this.composeTitle.content = "Report a bug";
14003
14343
  this.composeBody.content = lines.join("\n");
@@ -14054,7 +14394,7 @@ var init_render = __esmMin((() => {
14054
14394
  const more = selectedLineCount(state) - snippet.length;
14055
14395
  const tail = more > 0 ? [` … ${more} more lines`] : [];
14056
14396
  const quoted = [...snippet, ...tail].map((line) => clip(line, room.text));
14057
- const written = laidOut(`${state.draft}▌`.split("\n"), room.text);
14397
+ const written = laidOut(drafted(state).split("\n"), room.text);
14058
14398
  const lines = [
14059
14399
  ...quoted,
14060
14400
  "",
@@ -14088,6 +14428,7 @@ var init_display = __esmMin((() => {
14088
14428
  paint: paintWith(screen),
14089
14429
  rows: sync(() => screen.viewportRows()),
14090
14430
  room: sync(() => screen.noteRoom()),
14431
+ columns: sync(() => screen.columns()),
14091
14432
  listen: listenWith(screen)
14092
14433
  });
14093
14434
  displayOn = (renderer, repo) => sync$1(Display)(() => shapeOf(new Screen(renderer, repo)));
@@ -14167,7 +14508,7 @@ var init_upgrade = __esmMin((() => {
14167
14508
  return due ? `adiff ${latest} is out · adiff upgrade` : "";
14168
14509
  }).pipe(withSpan("Tui.upgradeHint"));
14169
14510
  upgradeHint = worded.pipe(orElseSucceed(() => ""));
14170
- })), 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;
14171
14512
  var init_app = __esmMin((() => {
14172
14513
  init_dist();
14173
14514
  init_report();
@@ -14205,6 +14546,27 @@ var init_app = __esmMin((() => {
14205
14546
  if (!opened) return "could not reach the pull request";
14206
14547
  return state.length === 0 ? "opened the pull request" : `opened the ${state} pull request`;
14207
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);
14208
14570
  keyName = (key) => {
14209
14571
  const base = key.shift && key.name.length === 1 ? key.name.toUpperCase() : key.name;
14210
14572
  return key.ctrl ? `ctrl+${base}` : base;
@@ -14277,7 +14639,7 @@ var init_app = __esmMin((() => {
14277
14639
  const sent = yield* this.loadSent(branch.branch);
14278
14640
  const said = spokenSince(this.state.sent, sent);
14279
14641
  if (said === 0) return;
14280
- this.commit(withWaiting(this.state, `${said} answered · press r`));
14642
+ this.commit(withWaiting(withArrived(this.state, sent), `${said} answered · press r`));
14281
14643
  });
14282
14644
  }
14283
14645
  noticeOnList() {
@@ -14363,6 +14725,10 @@ var init_app = __esmMin((() => {
14363
14725
  if (down === 0 && across === 0) return;
14364
14726
  this.wheel = 0;
14365
14727
  this.sideways = 0;
14728
+ if (listens(this.state.screen)) {
14729
+ if (down !== 0) this.commit(paletteMoved(this.state, down));
14730
+ return;
14731
+ }
14366
14732
  const moved = down === 0 ? this.measured() : scrolled(this.measured(), down);
14367
14733
  this.commit(across === 0 ? moved : panBy(moved, across));
14368
14734
  }
@@ -14375,6 +14741,11 @@ var init_app = __esmMin((() => {
14375
14741
  });
14376
14742
  return;
14377
14743
  }
14744
+ const columns = runSync(this.display.columns);
14745
+ if (columns !== this.state.columns) {
14746
+ this.commit(withColumns(this.state, columns));
14747
+ return;
14748
+ }
14378
14749
  const room = runSync(this.display.room);
14379
14750
  if (room === this.roomed) return;
14380
14751
  this.roomed = room;
@@ -14434,6 +14805,7 @@ var init_app = __esmMin((() => {
14434
14805
  quit: () => sync(() => this.renderer.destroy()),
14435
14806
  "branch.open": () => this.openBranch(),
14436
14807
  "branch.pull": () => this.showPull(),
14808
+ "compose.open": () => this.compose(),
14437
14809
  "compose.submit": () => this.send(),
14438
14810
  "compose.stage": () => this.stage(),
14439
14811
  "palette.run": () => this.runChoice(),
@@ -14461,6 +14833,7 @@ var init_app = __esmMin((() => {
14461
14833
  "report.send": () => this.sendReport(),
14462
14834
  "context.more": () => this.expand(1),
14463
14835
  "context.less": () => this.expand(-1),
14836
+ "context.whole": () => this.widen(contextToggled(this.state)),
14464
14837
  "tree.expand": () => this.unfold(1),
14465
14838
  "tree.collapse": () => this.unfold(-1)
14466
14839
  };
@@ -14515,8 +14888,16 @@ var init_app = __esmMin((() => {
14515
14888
  this.commit(paletteMoved(this.state, -1));
14516
14889
  return;
14517
14890
  }
14891
+ if (this.onCaret(key)) return;
14518
14892
  if (PRINTABLE.test(key.sequence)) this.commit(typed(this.state, key.sequence));
14519
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
+ }
14520
14901
  runChoice() {
14521
14902
  return gen({ self: this }, function* () {
14522
14903
  const chosen = paletteChoice(this.state);
@@ -14606,6 +14987,36 @@ var init_app = __esmMin((() => {
14606
14987
  yield* this.loadSource();
14607
14988
  });
14608
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
+ }
14609
15020
  settleHere() {
14610
15021
  return gen({ self: this }, function* () {
14611
15022
  const branch = selectedBranch(this.state);
@@ -14660,8 +15071,10 @@ var init_app = __esmMin((() => {
14660
15071
  if (branch === void 0) return;
14661
15072
  const path = selectedPatch(this.state)?.path;
14662
15073
  const line = sourceLineAt(this.state, this.state.cursor);
15074
+ const offset = this.state.cursor - this.state.top;
14663
15075
  const read = yield* this.readBranch(branch.branch);
14664
- 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"), ""));
14665
15078
  yield* this.loadSource();
14666
15079
  });
14667
15080
  }
@@ -14766,7 +15179,8 @@ var init_app = __esmMin((() => {
14766
15179
  const next = withPending({
14767
15180
  ...this.state,
14768
15181
  editing: void 0,
14769
- draft: ""
15182
+ draft: "",
15183
+ caret: 0
14770
15184
  }, pending, "pending");
14771
15185
  this.commit(withNoticeHere(next, "reworded"));
14772
15186
  });
@@ -14805,9 +15219,11 @@ var init_app = __esmMin((() => {
14805
15219
  });
14806
15220
  }
14807
15221
  expand(delta) {
15222
+ return this.widen(layerContext(this.state.context, delta));
15223
+ }
15224
+ widen(next) {
14808
15225
  return gen({ self: this }, function* () {
14809
15226
  const branch = selectedBranch(this.state);
14810
- const next = layerContext(this.state.context, delta);
14811
15227
  if (branch === void 0 || next === this.state.context) return;
14812
15228
  const line = sourceLineAt(this.state, this.state.cursor);
14813
15229
  const patches = yield* listPatches(this.repo, branch.branch, next);
@@ -14832,12 +15248,11 @@ var init_app = __esmMin((() => {
14832
15248
  editStagedComment() {
14833
15249
  const entry = this.state.pending[this.state.pendingIndex];
14834
15250
  if (entry?.id === void 0) return;
14835
- this.commit({
15251
+ this.commit(withDraft({
14836
15252
  ...this.state,
14837
15253
  screen: "compose",
14838
- draft: entry.body,
14839
15254
  editing: entry.id
14840
- });
15255
+ }, entry.body));
14841
15256
  }
14842
15257
  dropStagedComment() {
14843
15258
  return gen({ self: this }, function* () {
@@ -14888,7 +15303,8 @@ var init_app = __esmMin((() => {
14888
15303
  const closed = {
14889
15304
  ...this.state,
14890
15305
  screen: this.state.returnTo,
14891
- draft: ""
15306
+ draft: "",
15307
+ caret: 0
14892
15308
  };
14893
15309
  this.commit(withNotice(closed, `report copied — ${path}`));
14894
15310
  });
@@ -14921,10 +15337,22 @@ var init_app = __esmMin((() => {
14921
15337
  }
14922
15338
  };
14923
15339
  settledPath = (path) => promise(() => realpath(path).catch(() => resolve(path)));
14924
- 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;
14925
15352
  const repo = yield* settledPath(asked);
14926
15353
  const branches = yield* listBranches(repo);
14927
- 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);
14928
15356
  const store = yield* Store;
14929
15357
  const wrap = (yield* store.settings).wrap === true;
14930
15358
  const display = yield* Display.pipe(provide(displayOn(renderer, repo)));
@@ -14957,13 +15385,16 @@ var init_app = __esmMin((() => {
14957
15385
  untilDestroyed = (renderer) => callback$1((resume) => {
14958
15386
  renderer.on("destroy", () => resume(void_));
14959
15387
  });
14960
- runOn = fn("Tui.runOn")(function* (repo, renderer, sessionPath) {
14961
- 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
+ });
14962
15393
  yield* untilDestroyed(renderer);
14963
15394
  });
14964
- runTui = fn("Tui.run")(function* (repo, sessionPath) {
15395
+ runTui = fn("Tui.run")(function* (repo, sessionPath, branch) {
14965
15396
  const renderer = yield* promise(() => createCliRenderer({ exitOnCtrlC: true }));
14966
- yield* runOn(repo, renderer, sessionPath);
15397
+ yield* runOn(repo, renderer, sessionPath, branch);
14967
15398
  });
14968
15399
  }));
14969
15400
  //#endregion
@@ -15138,6 +15569,15 @@ const init = fn("Main.init")(function* (options) {
15138
15569
  changes: report.changes
15139
15570
  });
15140
15571
  });
15572
+ const reviewPane = fn("Main.reviewPane")(function* (options) {
15573
+ const report = yield* openPane(yield* required(options, "repo"), options["branch"]);
15574
+ yield* answer(options, {
15575
+ opened: report.opened,
15576
+ pane: report.pane,
15577
+ command: report.command
15578
+ });
15579
+ });
15580
+ const say = (line) => sync(() => process.stdout.write(line));
15141
15581
  const routes = {
15142
15582
  "branch list": branchList,
15143
15583
  "comment send": commentSend,
@@ -15150,23 +15590,24 @@ const routes = {
15150
15590
  "comment remove": commentRemove,
15151
15591
  "comment restore": commentRestore,
15152
15592
  "review send": reviewSend,
15153
- "review pane": fn("Main.reviewPane")(function* (options) {
15154
- const report = yield* openPane(yield* required(options, "repo"));
15155
- yield* answer(options, {
15156
- opened: report.opened,
15157
- pane: report.pane,
15158
- command: report.command
15159
- });
15160
- }),
15593
+ "review pane": reviewPane,
15161
15594
  "review progress": reviewStatus,
15162
15595
  "layers set": layersSet,
15163
15596
  "layers show": layersShow,
15164
15597
  init,
15165
15598
  upgrade: fn("Main.upgrade")(function* (options) {
15166
- const run = options["run"] !== void 0;
15167
- const report = yield* upgradeAdiff(run);
15168
- if (options["json"] !== void 0) return yield* answer(options, { upgrade: report });
15169
- return yield* sync(() => process.stdout.write(`${sayUpgrade(report, run)}\n`));
15599
+ const check = options["check"] !== void 0;
15600
+ const quiet = options["json"] !== void 0;
15601
+ const found = yield* findUpgrade;
15602
+ const upgrading = willUpgrade(found, check);
15603
+ if (!quiet) yield* say(`${sayFound(found, check)}\n${upgrading ? "\n" : ""}`);
15604
+ const ran = upgrading ? yield* runUpgrade(found, quiet) : false;
15605
+ if (quiet) return yield* answer(options, { upgrade: upgradeReport(found, ran, check) });
15606
+ if (upgrading) yield* say(`\n${sayDone(found, ran)}\n`);
15607
+ const settled = check || found.current === true || ran;
15608
+ return yield* sync(() => {
15609
+ if (!settled) process.exitCode = 1;
15610
+ });
15170
15611
  }),
15171
15612
  describe: fn("Main.describe")(function* (options) {
15172
15613
  const wanted = options["command"];
@@ -15217,7 +15658,7 @@ const dispatch = fn("Main.dispatch")(function* (name, given) {
15217
15658
  if (name === "file review") return yield* fileReview(options);
15218
15659
  if (name === "review open") {
15219
15660
  const { runTui } = yield* promise(() => Promise.resolve().then(() => (init_tui(), tui_exports)));
15220
- 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"]);
15221
15662
  }
15222
15663
  return yield* unknown(name);
15223
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.46",
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