@eliya-oss/agent-diff 0.1.0-alpha.108 → 0.1.0-alpha.109

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/main.js +315 -77
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.109
4
+
5
+ ### Patch Changes
6
+
7
+ - The line under the cursor, and the lines in a selection, keep their colour. It used to be repainted a flat grey with a bright blue gutter, so on the one line you were looking at you could not tell whether it had been added or deleted — the `+` sat at 1.18:1 against its own background. The cursor and the selection now lift the line's own tint instead of replacing it, and the line numbers were lifted out of the 1.6:1 they sat at on a tinted row. Comment bodies are no longer the dimmest text on the screen: they were 3.9:1 while the agent's narration beside them was 8.2:1, which had it backwards.
8
+
9
+ - The two counters in the header no longer look like the same number. `2/14 3/14 reviewed` put a position and a progress fraction two spaces apart in one colour, with different denominators when a file sat in more than one layer. They now read `file 2 of 14` and `3 reviewed`.
10
+
11
+ - An option value that begins with two dashes is kept rather than thrown away. `--body "--force is risky here"` used to store the word `true` and report success, so the comment the reviewer wrote was silently replaced. Options can also be written as `--name=value`.
12
+
13
+ adiff now refuses what it used to swallow: an option a command does not take, a `--side` that is neither `old` nor `new`, a line number that is not a whole number, and a `--fields` name the answer does not carry. Each refusal names what was given and what is allowed. `--fields` itself is now listed by `adiff describe`, and the nine failures that used to report "Unexpected failure, try again" — an unreachable forge, a git command that failed, a store file that could not be read — say what actually went wrong and that retrying will not help.
14
+
15
+ - Four things a bug bash of the review terminal turned up.
16
+
17
+ Copying a selection that crosses a change put both versions of every changed line on the clipboard, so the paste was code that existed in neither version of the file. It now copies the version being kept, and still copies deleted lines when that is all you picked.
18
+
19
+ A comment you were part way through writing is no longer thrown away when the box closes. Escape or ctrl+c keeps it, and reopening on the same lines brings it back. A comment of nothing but spaces is refused with a message instead of reaching the agent as an empty thread.
20
+
21
+ A terminal too narrow to draw the review in used to leave it blank for good, with no way back short of restarting. It says it needs more room, and comes back when the terminal does.
22
+
23
+ - Wrapped lines follow the pane when it grows. Hiding the rails with `z` widened the diff from 66 columns to 148 and the text kept breaking at 62, so the one key that buys the most room did nothing for anyone reading with wrapping on.
24
+
3
25
  ## 0.1.0-alpha.108
4
26
 
5
27
  ### Patch Changes
package/dist/main.js CHANGED
@@ -9378,7 +9378,7 @@ var init_preferences = __esmMin((() => {
9378
9378
  }));
9379
9379
  //#endregion
9380
9380
  //#region src/cli/error.ts
9381
- var UnknownBranch, UnknownBase, UnknownFile, UnknownComment, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownCommand, MissingOption, UnknownWorktree, MalformedLayers, UnknownDraft, NothingDrafted, PullMoved, NoLayers, InitUnwritable;
9381
+ var UnknownBranch, UnknownBase, UnknownFile, UnknownComment, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownCommand, MissingOption, UnknownWorktree, MalformedLayers, UnknownField, UnknownOption, BadOption, UnknownDraft, NothingDrafted, PullMoved, NoLayers, InitUnwritable;
9382
9382
  var init_error = __esmMin((() => {
9383
9383
  init_dist();
9384
9384
  UnknownBranch = class extends TaggedError("UnknownBranch") {};
@@ -9392,6 +9392,9 @@ var init_error = __esmMin((() => {
9392
9392
  MissingOption = class extends TaggedError("MissingOption") {};
9393
9393
  UnknownWorktree = class extends TaggedError("UnknownWorktree") {};
9394
9394
  MalformedLayers = class extends TaggedError("MalformedLayers") {};
9395
+ UnknownField = class extends TaggedError("UnknownField") {};
9396
+ UnknownOption = class extends TaggedError("UnknownOption") {};
9397
+ BadOption = class extends TaggedError("BadOption") {};
9395
9398
  UnknownDraft = class extends TaggedError("UnknownDraft") {};
9396
9399
  NothingDrafted = class extends TaggedError("NothingDrafted") {};
9397
9400
  PullMoved = class extends TaggedError("PullMoved") {};
@@ -10253,7 +10256,7 @@ var init_pane = __esmMin((() => {
10253
10256
  init_drafts();
10254
10257
  init_init();
10255
10258
  init_pane();
10256
- var version$1 = "0.1.0-alpha.108";
10259
+ var version$1 = "0.1.0-alpha.109";
10257
10260
  //#endregion
10258
10261
  //#region src/cli/upgrade.ts
10259
10262
  var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, runUpgrade, statusOf$1, sayFound, sayDone, attempted, REFRESH_MS, refreshSkills, updatedIn, sayRefreshed, upgradeReport;
@@ -11027,19 +11030,68 @@ var init_threads = __esmMin((() => {
11027
11030
  }));
11028
11031
  //#endregion
11029
11032
  //#region src/cli/parse.ts
11030
- var optionsFrom, required, numeric;
11033
+ var FLAG, flagOn, tokenOn, optionsFrom, onlyKnown, oneOf, required, numeric;
11031
11034
  var init_parse = __esmMin((() => {
11032
11035
  init_dist();
11033
11036
  init_error();
11034
- optionsFrom = (argv) => {
11035
- const options = {};
11036
- for (let index = 0; index < argv.length; index += 1) {
11037
- const token = argv[index];
11038
- if (token === void 0 || !token.startsWith("--")) continue;
11039
- const next = argv[index + 1];
11040
- options[token.slice(2)] = next === void 0 || next.startsWith("--") ? "true" : next;
11041
- }
11042
- return options;
11037
+ FLAG = /^--(?<name>[^=]+)(?:=(?<value>[\s\S]*))?$/;
11038
+ flagOn = (taken, token, valued) => {
11039
+ const found = FLAG.exec(token)?.groups;
11040
+ if (found === void 0) return taken;
11041
+ const name = found["name"] ?? "";
11042
+ const given = found["value"];
11043
+ if (given !== void 0) return {
11044
+ options: {
11045
+ ...taken.options,
11046
+ [name]: given
11047
+ },
11048
+ held: void 0
11049
+ };
11050
+ if (valued.has(name)) return {
11051
+ options: taken.options,
11052
+ held: name
11053
+ };
11054
+ return {
11055
+ options: {
11056
+ ...taken.options,
11057
+ [name]: "true"
11058
+ },
11059
+ held: void 0
11060
+ };
11061
+ };
11062
+ tokenOn = (taken, token, valued) => taken.held === void 0 ? flagOn(taken, token, valued) : {
11063
+ options: {
11064
+ ...taken.options,
11065
+ [taken.held]: token
11066
+ },
11067
+ held: void 0
11068
+ };
11069
+ optionsFrom = (argv, valued = /* @__PURE__ */ new Set()) => {
11070
+ const taken = argv.reduce((held, token) => tokenOn(held, token, valued), {
11071
+ options: {},
11072
+ held: void 0
11073
+ });
11074
+ return taken.held === void 0 ? taken.options : {
11075
+ ...taken.options,
11076
+ [taken.held]: ""
11077
+ };
11078
+ };
11079
+ onlyKnown = (options, known) => {
11080
+ const strange = Object.keys(options).find((name) => !known.has(name));
11081
+ return strange === void 0 ? succeed$1(options) : fail(new UnknownOption({
11082
+ option: strange,
11083
+ known: [...known].toSorted()
11084
+ }));
11085
+ };
11086
+ oneOf = (options, name, allowed, byDefault) => {
11087
+ const given = options[name];
11088
+ if (given === void 0) return succeed$1(byDefault);
11089
+ const found = allowed.find((one) => one === given);
11090
+ return found === void 0 ? fail(new BadOption({
11091
+ option: name,
11092
+ given,
11093
+ allowed
11094
+ })) : succeed$1(found);
11043
11095
  };
11044
11096
  required = fn("Cli.required")(function* (options, name) {
11045
11097
  const value = fromNullishOr(options[name]);
@@ -11051,12 +11103,16 @@ var init_parse = __esmMin((() => {
11051
11103
  numeric = fn("Cli.numeric")(function* (options, name) {
11052
11104
  const raw = yield* required(options, name);
11053
11105
  const parsed = Number(raw);
11054
- return yield* Number.isFinite(parsed) ? succeed$1(parsed) : new MissingOption({ option: name });
11106
+ return yield* Number.isInteger(parsed) && parsed >= 1 ? succeed$1(parsed) : new BadOption({
11107
+ option: name,
11108
+ given: raw,
11109
+ allowed: ["a whole number of 1 or more"]
11110
+ });
11055
11111
  });
11056
11112
  }));
11057
11113
  //#endregion
11058
11114
  //#region src/cli/catalog.ts
11059
- var worktreeOf, repoOf, branchOf, addressing, baseOf, based, repo, opening$2, file, range, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, DRAFTS, SET_UP, catalog, commandNames, findCommand, verbsUnder, groups, NEAR, distance, NEAR_ENOUGH, nearestCommand;
11115
+ var worktreeOf, repoOf, branchOf, fieldsOption, addressing, baseOf, based, repo, opening$2, file, range, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, DRAFTS, SET_UP, withFields, commands$1, catalog, commandNames, findCommand, VALUED_ANYWHERE, KNOWN_ANYWHERE, valuedIn, knownIn, verbsUnder, groups, NEAR, distance, NEAR_ENOUGH, nearestCommand;
11060
11116
  var init_catalog = __esmMin((() => {
11061
11117
  worktreeOf = {
11062
11118
  name: "worktree",
@@ -11076,6 +11132,12 @@ var init_catalog = __esmMin((() => {
11076
11132
  value: "name",
11077
11133
  about: "Branch to act on, as `branch list` reports it. Give this with --repo, or give --worktree"
11078
11134
  };
11135
+ fieldsOption = {
11136
+ name: "fields",
11137
+ required: false,
11138
+ value: "names",
11139
+ about: "Keep only these fields of the answer, comma separated. An unknown name is refused"
11140
+ };
11079
11141
  addressing = [
11080
11142
  worktreeOf,
11081
11143
  repoOf,
@@ -11139,7 +11201,11 @@ var init_catalog = __esmMin((() => {
11139
11201
  FOLLOW_UP = "Follow up";
11140
11202
  DRAFTS = "Draft a review of somebody else's pull request";
11141
11203
  SET_UP = "Set up";
11142
- catalog = [
11204
+ withFields = (command) => command.dataKey.length === 0 ? command : {
11205
+ ...command,
11206
+ options: [...command.options, fieldsOption]
11207
+ };
11208
+ commands$1 = [
11143
11209
  {
11144
11210
  name: "branch list",
11145
11211
  about: "Branches with changes against their merge base, and how large each is",
@@ -11571,8 +11637,23 @@ var init_catalog = __esmMin((() => {
11571
11637
  example: "adiff describe --command 'comment send'"
11572
11638
  }
11573
11639
  ];
11640
+ catalog = commands$1.map(withFields);
11574
11641
  commandNames = catalog.map((command) => command.name);
11575
11642
  findCommand = (name) => catalog.find((command) => command.name === name);
11643
+ VALUED_ANYWHERE = [
11644
+ "fields",
11645
+ "id",
11646
+ "at"
11647
+ ];
11648
+ KNOWN_ANYWHERE = [
11649
+ ...VALUED_ANYWHERE,
11650
+ "help",
11651
+ "json",
11652
+ "run",
11653
+ "quiet"
11654
+ ];
11655
+ valuedIn = (name) => /* @__PURE__ */ new Set([...VALUED_ANYWHERE, ...(findCommand(name)?.options ?? []).filter((option) => option.value !== "flag").map((option) => option.name)]);
11656
+ knownIn = (name) => /* @__PURE__ */ new Set([...KNOWN_ANYWHERE, ...(findCommand(name)?.options ?? []).map((option) => option.name)]);
11576
11657
  verbsUnder = (noun) => commandNames.filter((name) => name.startsWith(`${noun} `));
11577
11658
  groups = [...new Set(catalog.map((command) => command.group))];
11578
11659
  NEAR = 3;
@@ -11602,7 +11683,7 @@ var init_catalog = __esmMin((() => {
11602
11683
  })).toSorted((left, right) => left.gap - right.gap)[0];
11603
11684
  return scored !== void 0 && scored.gap <= room ? scored.known : void 0;
11604
11685
  };
11605
- })), ADVICE, FALLBACK, tagOf, project, fieldsOf, narrow, sharpen, failure;
11686
+ })), ADVICE, FALLBACK, tagOf, project, fieldsOf, narrow, keysIn, strangeField, sharpen, failure;
11606
11687
  var init_report$1 = __esmMin((() => {
11607
11688
  ADVICE = {
11608
11689
  UnknownCommand: {
@@ -11660,6 +11741,56 @@ var init_report$1 = __esmMin((() => {
11660
11741
  suggestion: "No comment carries that id. `adiff comment take` reports the ids an agent can answer, and `adiff comment list` reports every id on a review.",
11661
11742
  retriable: false
11662
11743
  },
11744
+ UnknownField: {
11745
+ exit: 2,
11746
+ suggestion: "That is not a field this answer carries. The ones it does are named above.",
11747
+ retriable: false
11748
+ },
11749
+ UnknownOption: {
11750
+ exit: 2,
11751
+ suggestion: "That option is not one this command takes. `adiff <command> --help` lists the options it does.",
11752
+ retriable: false
11753
+ },
11754
+ BadOption: {
11755
+ exit: 2,
11756
+ suggestion: "That value is not one the option allows. The allowed ones are named above.",
11757
+ retriable: false
11758
+ },
11759
+ ForgeUnavailable: {
11760
+ exit: 1,
11761
+ suggestion: "The forge could not be reached. Check that `gh` is installed and authenticated, and that this repository has a remote on it. Nothing was sent.",
11762
+ retriable: false
11763
+ },
11764
+ NotARepository: {
11765
+ exit: 3,
11766
+ suggestion: "That path is not a git repository. Point --repo at one.",
11767
+ retriable: false
11768
+ },
11769
+ GitCommandFailed: {
11770
+ exit: 1,
11771
+ suggestion: "git refused the command adiff ran. The reason it gave is above.",
11772
+ retriable: false
11773
+ },
11774
+ FileUnreadable: {
11775
+ exit: 1,
11776
+ suggestion: "That file could not be read. Check it is still there and that you can read it.",
11777
+ retriable: false
11778
+ },
11779
+ StoreUnreadable: {
11780
+ exit: 1,
11781
+ suggestion: "A file adiff keeps this review in could not be read. The path is above; move it aside to start the review's history again, or repair the line that is malformed.",
11782
+ retriable: false
11783
+ },
11784
+ StoreUnwritable: {
11785
+ exit: 1,
11786
+ suggestion: "A file adiff keeps this review in could not be written. Check the path above is a directory you can write to.",
11787
+ retriable: false
11788
+ },
11789
+ WatchUnavailable: {
11790
+ exit: 1,
11791
+ suggestion: "adiff could not watch that path for changes. The reason it gave is above.",
11792
+ retriable: false
11793
+ },
11663
11794
  UnknownDraft: {
11664
11795
  exit: 3,
11665
11796
  suggestion: "No held comment carries that id. `adiff draft list` reports the drafts waiting on a review.",
@@ -11703,6 +11834,21 @@ var init_report$1 = __esmMin((() => {
11703
11834
  return raw === void 0 || raw === "true" ? [] : raw.split(",").map((field) => field.trim());
11704
11835
  };
11705
11836
  narrow = (value, fields) => fields.length === 0 ? value : project(value, fields);
11837
+ keysIn = (value) => {
11838
+ if (Array.isArray(value)) return value.flatMap((one) => keysIn(one));
11839
+ if (typeof value !== "object" || value === null) return [];
11840
+ return Object.keys(value);
11841
+ };
11842
+ strangeField = (body, fields) => {
11843
+ if (fields.length === 0) return void 0;
11844
+ const known = [...new Set(Object.values(body).flatMap((value) => keysIn(value)))];
11845
+ if (known.length === 0) return void 0;
11846
+ const field = fields.find((one) => !known.includes(one));
11847
+ return field === void 0 ? void 0 : {
11848
+ field,
11849
+ known: known.toSorted()
11850
+ };
11851
+ };
11706
11852
  sharpen = (tag, detail, fallback) => {
11707
11853
  const meant = detail["didYouMean"];
11708
11854
  const named = detail["name"];
@@ -12112,7 +12258,7 @@ var init_tree = __esmMin((() => {
12112
12258
  return node.children.reduce((total, child) => total + filesUnder(tree, child), 0);
12113
12259
  };
12114
12260
  crowdedDirectories = (tree, limit) => tree.nodes.filter((node) => node.kind === "directory" && directFiles(tree, node.id) > limit).map((node) => node.path);
12115
- })), nothingReviewed, initialState, TREE_MAX, TREE_ROOMY, TREE_WIDE, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, clip$1, TITLE_ROWS, titleRows, shortDir, fileRow$1, shownFiles, dirOf, fileRows, layerRead, layerDone, countRow, layerBody, layerRows, nearFirst, layerFitted, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, kept, treeOf, reviewedCountIn, treeRows, crowdedOf, foldersOfFile, isReviewed, treeStart, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, brokenAt, laidLine, laidDraft, caretRow, caretColumn, caretOn, COMPOSE_BOX, COMPOSE_MARGIN, COMPOSE_PAD, COMPOSE_LEAST, composeBox, composeRoom$1, composeTarget, replyTarget, pickedText, selectedLines, shownMatches, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersIn, newerOf, spokeLast, sectionOf, sentEntry, panelEntries, panelEntry, threadChosen, spokenSince, hunkStarts, openingRow, changeAround, nextUnreviewed, reviewedCount, fileOrder, filePlace, readingOrder, placeIn, layerFile, layerAfter, selectionRange;
12261
+ })), nothingReviewed, initialState, TREE_MAX, TREE_ROOMY, TREE_WIDE, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, tooSmall, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, clip$1, TITLE_ROWS, titleRows, shortDir, fileRow$1, shownFiles, dirOf, fileRows, layerRead, layerDone, countRow, layerBody, layerRows, nearFirst, layerFitted, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, kept, treeOf, reviewedCountIn, treeRows, crowdedOf, foldersOfFile, isReviewed, treeStart, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, brokenAt, laidLine, laidDraft, caretRow, caretColumn, caretOn, COMPOSE_BOX, COMPOSE_MARGIN, COMPOSE_PAD, COMPOSE_LEAST, composeBox, composeRoom$1, composeTarget, replyTarget, pickedText, selectedLines, shownMatches, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersIn, newerOf, spokeLast, sectionOf, sentEntry, panelEntries, panelEntry, threadChosen, spokenSince, hunkStarts, openingRow, changeAround, nextUnreviewed, reviewedCount, fileOrder, filePlace, readingOrder, placeIn, layerFile, layerAfter, selectionRange;
12116
12262
  var init_model = __esmMin((() => {
12117
12263
  init_dist();
12118
12264
  init_patch();
@@ -12148,6 +12294,7 @@ var init_model = __esmMin((() => {
12148
12294
  anchorRow: 0,
12149
12295
  selecting: false,
12150
12296
  draft: "",
12297
+ draftAt: "",
12151
12298
  notice: "",
12152
12299
  waiting: "",
12153
12300
  query: "",
@@ -12194,6 +12341,7 @@ var init_model = __esmMin((() => {
12194
12341
  const wanted = Math.min(spare >= TREE_WIDE ? TREE_WIDE : spare >= TREE_ROOMY ? TREE_ROOMY : TREE_MAX, Math.max(TREE_MIN, Math.floor(room * TREE_SHARE)));
12195
12342
  return Math.max(0, Math.min(wanted, room - DIFF_MIN));
12196
12343
  };
12344
+ tooSmall = (columns, rows) => columns < 24 || rows < 6;
12197
12345
  reviewWidth = () => 36;
12198
12346
  panelFits = (state) => bodyRoom(state.columns) - treeWidth(state.columns) - reviewWidth() >= DIFF_ROOMY;
12199
12347
  panelShown = (state) => state.screen !== "branches" && state.panelOpen && panelFits(state);
@@ -12502,7 +12650,8 @@ var init_model = __esmMin((() => {
12502
12650
  const patch = selectedPatch(state);
12503
12651
  if (patch === void 0) return [];
12504
12652
  const [from, to] = selectionRange(state);
12505
- return patch.rows.slice(from, to + 1).map((row) => row.text);
12653
+ const rows = patch.rows.slice(from, to + 1);
12654
+ return (rows.every((row) => row.kind === "removed") ? rows : rows.filter((row) => row.kind !== "removed")).map((row) => row.text);
12506
12655
  };
12507
12656
  shownMatches = (state) => {
12508
12657
  const wanted = state.query.trim().toLowerCase();
@@ -12650,7 +12799,7 @@ var init_model = __esmMin((() => {
12650
12799
  const start = Math.max(0, order.indexOf(from));
12651
12800
  return [...order.slice(start + 1), ...order.slice(0, start + 1)].find((index) => !isReviewed(state, index));
12652
12801
  };
12653
- reviewedCount = (state) => `${state.vouched.length}/${state.patches.length} reviewed`;
12802
+ reviewedCount = (state) => `${state.vouched.length} reviewed`;
12654
12803
  fileOrder = (state) => onLayers(state) ? state.layers.flatMap((_, at) => layerFiles(state, at)) : flattenTree(treeOf(state), []).flatMap((row) => row.fileIndex === void 0 ? [] : [row.fileIndex]);
12655
12804
  filePlace = (state) => {
12656
12805
  const order = [...new Set(fileOrder(state))];
@@ -13434,7 +13583,7 @@ var init_match = __esmMin((() => {
13434
13583
  }));
13435
13584
  //#endregion
13436
13585
  //#region src/tui/reduce.ts
13437
- var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, restingOn, draggedTo, pickedIn, atRow, noneLeft, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, moveLayer, inRail, railScrolled, movePanel, layerDown, PANES, panesShown, focusStepped, togglePanel, packedAway, zoom, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, landingOn, revealing, atTheEnd, moveFile, selectHunk, swapEnds, atBranch, grownBy, startSelection, openCompose, goBack, walkMatches, openPalette, openKeys, movePalette, paletteMatches, keyMatches, offered, paletteChoice, transitions, reduce, resumedAt, atFile, withContext, withFull, revealsAfter, gapShown, gapOpened, panBy, withSent, withArrived, withColumns, laidOver, withLayers, withPulls, withSilentForge, withBranches, withSource, withVouched, restoredTo, openedAt, withPatches, TAB_WIDTH, SPACE_CODE, ERASED_FROM, ERASED_TO, readable, legible, withDraft, paletteMoved, paletteClosed, withWaiting, withFinder, withMatches, withNoticeHere, withNotice;
13586
+ var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, restingOn, draggedTo, pickedIn, atRow, noneLeft, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, moveLayer, inRail, railScrolled, movePanel, layerDown, PANES, panesShown, focusStepped, togglePanel, packedAway, zoom, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, landingOn, revealing, atTheEnd, moveFile, selectHunk, swapEnds, atBranch, grownBy, startSelection, draftMark, openCompose, goBack, walkMatches, openPalette, openKeys, movePalette, paletteMatches, keyMatches, offered, paletteChoice, transitions, reduce, resumedAt, atFile, withContext, withFull, revealsAfter, gapShown, gapOpened, panBy, withSent, withArrived, withColumns, laidOver, withLayers, withPulls, withSilentForge, withBranches, withSource, withVouched, restoredTo, openedAt, withPatches, TAB_WIDTH, SPACE_CODE, ERASED_FROM, ERASED_TO, readable, legible, withDraft, paletteMoved, paletteClosed, withWaiting, withFinder, withMatches, withNoticeHere, withNotice;
13438
13587
  var init_reduce = __esmMin((() => {
13439
13588
  init_dist();
13440
13589
  init_patch();
@@ -13767,14 +13916,21 @@ var init_reduce = __esmMin((() => {
13767
13916
  selecting: true,
13768
13917
  anchorRow: state.cursor
13769
13918
  });
13919
+ draftMark = (state) => {
13920
+ const [from, to] = selectionRange(state);
13921
+ return `${selectedPatch(state)?.path ?? ""}:${from}-${to}`;
13922
+ };
13770
13923
  openCompose = (state) => {
13771
13924
  const patch = selectedPatch(state);
13772
13925
  const [from, to] = selectionRange(state);
13773
13926
  if (!(patch !== void 0 && isSome(anchorFor(patch, from, to)))) return withNoticeHere(state, "no line here to comment on");
13927
+ const mark = draftMark(state);
13928
+ const kept = state.draftAt === mark ? state.draft : "";
13774
13929
  return {
13775
13930
  ...state,
13776
13931
  screen: "compose",
13777
- draft: "",
13932
+ draft: kept,
13933
+ draftAt: mark,
13778
13934
  replyTo: void 0,
13779
13935
  anchorRow: state.selecting ? state.anchorRow : state.cursor
13780
13936
  };
@@ -13805,7 +13961,6 @@ var init_reduce = __esmMin((() => {
13805
13961
  if (state.screen === "compose") return {
13806
13962
  ...state,
13807
13963
  screen: "review",
13808
- draft: "",
13809
13964
  replyTo: void 0
13810
13965
  };
13811
13966
  if (state.selecting) return {
@@ -14304,7 +14459,19 @@ var init_theme = __esmMin((() => {
14304
14459
  addedBg: "#0f2a19",
14305
14460
  removedBg: "#2e1418",
14306
14461
  addedGutter: "#1d4a2b",
14307
- removedGutter: "#4a1f26"
14462
+ removedGutter: "#4a1f26",
14463
+ pickedOn: "#2b3854",
14464
+ pickedOnAdded: "#22432f",
14465
+ pickedOnRemoved: "#4a2733",
14466
+ pickedGutter: "#38496b",
14467
+ pickedGutterAdded: "#2d5c3f",
14468
+ pickedGutterRemoved: "#63323f",
14469
+ cursorOn: "#243a4f",
14470
+ cursorOnAdded: "#1a3d26",
14471
+ cursorOnRemoved: "#40202a",
14472
+ cursorGutter: "#2f4a68",
14473
+ cursorGutterAdded: "#27573a",
14474
+ cursorGutterRemoved: "#5a2b36"
14308
14475
  };
14309
14476
  syntaxTheme = {
14310
14477
  keyword: { fg: violet },
@@ -14332,15 +14499,9 @@ var init_theme = __esmMin((() => {
14332
14499
  "punctuation.delimiter": { fg: inkFaint },
14333
14500
  gap: { fg: inkFaint },
14334
14501
  picked: { bg: "#2b3854" },
14335
- note: {
14336
- fg: "#9aa7c7",
14337
- italic: true
14338
- },
14339
- prose: { fg: "#a9b4cc" },
14340
- "note.sent": {
14341
- fg: "#6d7893",
14342
- italic: true
14343
- },
14502
+ note: { fg: "#c8d0dc" },
14503
+ prose: { fg: "#8b95a7" },
14504
+ "note.sent": { fg: "#c8d0dc" },
14344
14505
  "note.label": { fg: "#7aa2f7" },
14345
14506
  default: { fg: ink }
14346
14507
  };
@@ -14450,7 +14611,7 @@ var init_diffview = __esmMin((() => {
14450
14611
  this.numbers = new LineNumberRenderable(renderer, {
14451
14612
  id: "diff-lines",
14452
14613
  target: this.code,
14453
- fg: palette.faint,
14614
+ fg: palette.muted,
14454
14615
  minWidth: 4,
14455
14616
  paddingRight: 1,
14456
14617
  flexGrow: 1,
@@ -14490,6 +14651,9 @@ var init_diffview = __esmMin((() => {
14490
14651
  room() {
14491
14652
  return this.noteRoom();
14492
14653
  }
14654
+ paneWidth() {
14655
+ return this.numbers.width;
14656
+ }
14493
14657
  gutterWidth() {
14494
14658
  return Math.max(0, this.code.x - this.numbers.x) + SIGN_WIDTH;
14495
14659
  }
@@ -14637,14 +14801,14 @@ var init_diffview = __esmMin((() => {
14637
14801
  return [...(this.ownSpans() ?? highlights).filter((highlight) => !spans.some(([from, to]) => highlight[0] < to && highlight[1] > from)), ...spans];
14638
14802
  };
14639
14803
  }
14640
- setWrap(on) {
14804
+ setWrap(on, pane) {
14641
14805
  if (on !== this.wrapped) {
14642
14806
  this.wrapped = on;
14643
14807
  this.code.wrapMode = on ? "word" : "none";
14644
14808
  this.code.requestRender();
14645
14809
  this.numbers.requestRender();
14646
14810
  }
14647
- this.fitWrapWidth();
14811
+ this.fitWrapWidth(pane);
14648
14812
  }
14649
14813
  panLimit() {
14650
14814
  return this.wrapped ? 0 : Math.max(this.code.maxScrollX, this.pinned.maxScrollX);
@@ -14658,8 +14822,8 @@ var init_diffview = __esmMin((() => {
14658
14822
  if (this.code.scrollX !== wanted) this.code.scrollX = wanted;
14659
14823
  if (this.pinned.scrollX !== wanted) this.pinned.scrollX = wanted;
14660
14824
  }
14661
- fitWrapWidth() {
14662
- const room = this.numbers.width - Math.max(0, this.code.x - this.numbers.x);
14825
+ fitWrapWidth(pane) {
14826
+ const room = pane - Math.max(0, this.code.x - this.numbers.x);
14663
14827
  const wanted = this.wrapped && room > 0 ? room : "100%";
14664
14828
  if (this.code.width !== wanted) this.code.width = wanted;
14665
14829
  }
@@ -14996,7 +15160,7 @@ var init_diffview = __esmMin((() => {
14996
15160
  }));
14997
15161
  //#endregion
14998
15162
  //#region src/tui/render.ts
14999
- var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, 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, PANE_EDGES, PANE_INSET, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_FIXED, STATE_MIN, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, longestState, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, SELECTION, CURSOR, ACCENT, GAP_PAINT, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, asking, makePaletteParts, makeChoices, LIST_LEAD, windowed, listText, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, MAC_KEYS, makeComposeParts, makeCompose, clip, clipHead, clipMiddle, clipPath, INDENT_MAX, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, SUMMARY_LINES, summaryLines, contextLabel, nameRoom, stateRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, placeLabel, headerParts, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, GUTTER, DIR_LEAD, TITLE_LEAD, FILE_LEAD, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerMark, layerLead, layerGutter, layerText, litRow, leftOver, titlePaint, layerPaint, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, restingOrHere, FOUND_LEAST, nothingYet, foundTitle, fileRow, blockOf, aroundRow, windowedBlocks, panelWhere, panelBody, panelPair, panelSection, PULL_HINT, panelText, Screen;
15163
+ var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, 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, PANE_EDGES, PANE_INSET, DIFF_FLOOR, CRAMPED, CRAMPED_ROWS, DIFF_CHROME_MOST, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_FIXED, STATE_MIN, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, longestState, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, PLAIN_PICKED, PICKED, PLAIN_CURSOR, UNDER_CURSOR, GAP_PAINT, frameRoot, crampedBar, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, asking, makePaletteParts, makeChoices, LIST_LEAD, windowed, listText, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, MAC_KEYS, makeComposeParts, makeCompose, clip, clipHead, clipMiddle, clipPath, INDENT_MAX, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, SUMMARY_LINES, summaryLines, contextLabel, nameRoom, stateRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, placeLabel, headerParts, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, GUTTER, DIR_LEAD, TITLE_LEAD, FILE_LEAD, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerMark, layerLead, layerGutter, layerText, litRow, leftOver, titlePaint, layerPaint, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, restingOrHere, FOUND_LEAST, nothingYet, foundTitle, fileRow, blockOf, aroundRow, windowedBlocks, panelWhere, panelBody, panelPair, panelSection, PULL_HINT, panelText, Screen;
15000
15164
  var init_render = __esmMin((() => {
15001
15165
  init_command();
15002
15166
  init_layers$1();
@@ -15033,6 +15197,10 @@ var init_render = __esmMin((() => {
15033
15197
  PANE_CHROME = 3;
15034
15198
  PANE_EDGES = 2;
15035
15199
  PANE_INSET = 1;
15200
+ DIFF_FLOOR = 24;
15201
+ CRAMPED = "adiff needs more room than this";
15202
+ CRAMPED_ROWS = 4;
15203
+ DIFF_CHROME_MOST = 16;
15036
15204
  BRANCH_WIDTH = 82;
15037
15205
  BRANCH_NAME_MIN = 12;
15038
15206
  BRANCH_FIXED = 36;
@@ -15062,24 +15230,56 @@ var init_render = __esmMin((() => {
15062
15230
  });
15063
15231
  STICKY_MAX = 4;
15064
15232
  pickPaint = (view, kind, flags) => {
15065
- if (flags.cursor) return {
15066
- gutter: ACCENT,
15067
- content: CURSOR
15068
- };
15069
- if (flags.selected) return {
15070
- gutter: SELECTION,
15071
- content: SELECTION
15072
- };
15233
+ if (flags.cursor) return UNDER_CURSOR[kind] ?? PLAIN_CURSOR;
15234
+ if (flags.selected) return PICKED[kind] ?? PLAIN_PICKED;
15073
15235
  if (flags.gap) return GAP_PAINT;
15074
15236
  return view.washOf(kind);
15075
15237
  };
15076
- SELECTION = RGBA.fromHex(palette.selection);
15077
- CURSOR = RGBA.fromHex(palette.cursor);
15078
- ACCENT = RGBA.fromHex(palette.accent);
15238
+ PLAIN_PICKED = {
15239
+ gutter: RGBA.fromHex(palette.pickedGutter),
15240
+ content: RGBA.fromHex(palette.pickedOn)
15241
+ };
15242
+ PICKED = {
15243
+ added: {
15244
+ gutter: RGBA.fromHex(palette.pickedGutterAdded),
15245
+ content: RGBA.fromHex(palette.pickedOnAdded)
15246
+ },
15247
+ removed: {
15248
+ gutter: RGBA.fromHex(palette.pickedGutterRemoved),
15249
+ content: RGBA.fromHex(palette.pickedOnRemoved)
15250
+ }
15251
+ };
15252
+ PLAIN_CURSOR = {
15253
+ gutter: RGBA.fromHex(palette.cursorGutter),
15254
+ content: RGBA.fromHex(palette.cursorOn)
15255
+ };
15256
+ UNDER_CURSOR = {
15257
+ added: {
15258
+ gutter: RGBA.fromHex(palette.cursorGutterAdded),
15259
+ content: RGBA.fromHex(palette.cursorOnAdded)
15260
+ },
15261
+ removed: {
15262
+ gutter: RGBA.fromHex(palette.cursorGutterRemoved),
15263
+ content: RGBA.fromHex(palette.cursorOnRemoved)
15264
+ }
15265
+ };
15079
15266
  GAP_PAINT = {
15080
15267
  gutter: RGBA.fromHex(palette.overlay),
15081
15268
  content: RGBA.fromHex(palette.overlay)
15082
15269
  };
15270
+ frameRoot = (renderer) => {
15271
+ renderer.root.flexDirection = "column";
15272
+ renderer.root.paddingLeft = FRAME_PAD;
15273
+ renderer.root.paddingRight = FRAME_PAD;
15274
+ renderer.root.paddingTop = 0;
15275
+ renderer.root.paddingBottom = 0;
15276
+ };
15277
+ crampedBar = (renderer) => {
15278
+ const made = bar(renderer, "cramped", palette.muted);
15279
+ made.wrapMode = "word";
15280
+ made.height = CRAMPED_ROWS;
15281
+ return made;
15282
+ };
15083
15283
  bar = (renderer, id, color) => new TextRenderable(renderer, {
15084
15284
  id,
15085
15285
  content: "",
@@ -15561,7 +15761,7 @@ var init_render = __esmMin((() => {
15561
15761
  });
15562
15762
  placeLabel = (state) => {
15563
15763
  const place = filePlace(state);
15564
- return `${place.at}/${place.of}`;
15764
+ return `file ${place.at} of ${place.of}`;
15565
15765
  };
15566
15766
  headerParts = (state, branch, path, pan) => [
15567
15767
  branch,
@@ -15781,6 +15981,7 @@ var init_render = __esmMin((() => {
15781
15981
  landingKeys;
15782
15982
  hovered = -1;
15783
15983
  lead = 0;
15984
+ chrome = 0;
15784
15985
  shown;
15785
15986
  chips = [];
15786
15987
  composeTitle;
@@ -15788,6 +15989,7 @@ var init_render = __esmMin((() => {
15788
15989
  composeBody;
15789
15990
  composeActions;
15790
15991
  footer;
15992
+ cramped;
15791
15993
  palette;
15792
15994
  paletteTitle;
15793
15995
  paletteQuery;
@@ -15808,13 +16010,10 @@ var init_render = __esmMin((() => {
15808
16010
  constructor(renderer, repo = "") {
15809
16011
  this.renderer = renderer;
15810
16012
  this.repo = repo;
15811
- renderer.root.flexDirection = "column";
15812
- renderer.root.paddingLeft = FRAME_PAD;
15813
- renderer.root.paddingRight = FRAME_PAD;
15814
- renderer.root.paddingTop = 0;
15815
- renderer.root.paddingBottom = 0;
16013
+ frameRoot(renderer);
15816
16014
  this.header = bar(renderer, "header", palette.ink);
15817
16015
  this.footer = bar(renderer, "footer", palette.faint);
16016
+ this.cramped = crampedBar(renderer);
15818
16017
  this.body = makeBody(renderer);
15819
16018
  const list = makeListParts(renderer);
15820
16019
  this.listPane = list.pane;
@@ -15966,15 +16165,24 @@ var init_render = __esmMin((() => {
15966
16165
  this.landing.content = `${elide(shortPath(this.repo), room)} · ${many}`;
15967
16166
  this.landingKeys.content = this.homeKeys(state);
15968
16167
  this.diffPane.visible = state.screen !== "branches" && !atHome(state);
15969
- if (this.diffPane.visible) this.paintDiff(state);
15970
16168
  this.paintPanel(state);
15971
16169
  this.paintPane(state);
16170
+ if (this.diffPane.visible) this.paintDiff(state);
15972
16171
  this.paintCompose(state);
15973
16172
  this.paintPalette(state);
15974
16173
  this.paintKeys(state);
15975
16174
  this.paintFound(state);
15976
16175
  this.paintReport(state);
15977
16176
  this.scrim.visible = state.screen !== "branches" && state.screen !== "review";
16177
+ this.paintCramped();
16178
+ }
16179
+ paintCramped() {
16180
+ const cramped = tooSmall(this.renderer.width, this.renderer.height);
16181
+ this.cramped.visible = cramped;
16182
+ this.body.visible = !cramped;
16183
+ this.header.visible = !cramped;
16184
+ this.footer.visible = !cramped;
16185
+ if (cramped) this.cramped.content = wrapped(CRAMPED, this.renderer.width - 1).join("\n");
15978
16186
  }
15979
16187
  paintPalette(state) {
15980
16188
  this.palette.visible = state.screen === "palette";
@@ -16038,6 +16246,15 @@ var init_render = __esmMin((() => {
16038
16246
  paneRoom() {
16039
16247
  return treeWidth(this.renderer.width);
16040
16248
  }
16249
+ railsRoom() {
16250
+ return (this.listPane.visible ? this.listPane.width : 0) + (this.panelPane.visible ? this.panelPane.width : 0);
16251
+ }
16252
+ diffRoom() {
16253
+ const measured = this.view.paneWidth();
16254
+ const settled = this.renderer.width - this.railsRoom() - measured;
16255
+ if (settled >= 0 && settled < DIFF_CHROME_MOST) this.chrome = settled;
16256
+ return Math.max(DIFF_FLOOR, this.renderer.width - this.railsRoom() - this.chrome);
16257
+ }
16041
16258
  columns() {
16042
16259
  return this.renderer.width;
16043
16260
  }
@@ -16103,7 +16320,7 @@ var init_render = __esmMin((() => {
16103
16320
  const shown = shownOf(state);
16104
16321
  if (shown === void 0) return;
16105
16322
  const patch = shown.patch;
16106
- this.view.setWrap(state.wrap);
16323
+ this.view.setWrap(state.wrap, this.diffRoom());
16107
16324
  this.view.setPan(state.pan);
16108
16325
  this.view.show(patch, notesFor(state, patch.path), gapRowSet(shown), proseFor(state, patch.path));
16109
16326
  this.view.pick(state.picked);
@@ -16135,6 +16352,7 @@ var init_render = __esmMin((() => {
16135
16352
  this.composeActions
16136
16353
  ]);
16137
16354
  stack(renderer.root, [
16355
+ this.cramped,
16138
16356
  this.header,
16139
16357
  this.body,
16140
16358
  this.footer,
@@ -16513,7 +16731,7 @@ var init_upgrade = __esmMin((() => {
16513
16731
  return due ? `adiff ${latest} is out · adiff upgrade` : "";
16514
16732
  }).pipe(withSpan("Tui.upgradeHint"));
16515
16733
  upgradeHint = worded.pipe(orElseSucceed(() => ""));
16516
- })), LOOK_MS, LEAVING_SAID, layersAsk, askedFor, alongFrom, NOTICE_MS, KEY_HISTORY, DRAIN_PASSES, TRAIL_HISTORY, clockOf, momentOf, noticeOf, COPIERS, wayland, seedFor, handOver, throughMultiplexer, copyToClipboard, lineUnder, asKey, openedPull, LISTENS, WRITES, OVER, overReview, writesInto, listens, LETTER, laidOut, ARROWS, SHIFTED, keyName, App, turnedOver, settledPath, restsWhereItLanded, lonelyGaps, chosenIn, settingsHeld, firstBranches, missing, openingOn, launch, told, untilDestroyed, runOn, runTui;
16734
+ })), LOOK_MS, LEAVING_SAID, NOTHING_WRITTEN, layersAsk, askedFor, alongFrom, NOTICE_MS, KEY_HISTORY, DRAIN_PASSES, TRAIL_HISTORY, clockOf, momentOf, noticeOf, COPIERS, wayland, seedFor, handOver, throughMultiplexer, copyToClipboard, lineUnder, asKey, openedPull, LISTENS, WRITES, OVER, overReview, writesInto, listens, LETTER, laidOut, ARROWS, SHIFTED, keyName, App, sentAway, turnedOver, settledPath, restsWhereItLanded, lonelyGaps, chosenIn, settingsHeld, firstBranches, missing, openingOn, launch, told, untilDestroyed, runOn, runTui;
16517
16735
  var init_app = __esmMin((() => {
16518
16736
  init_dist();
16519
16737
  init_report();
@@ -16533,6 +16751,7 @@ var init_app = __esmMin((() => {
16533
16751
  init_upgrade();
16534
16752
  LOOK_MS = 110;
16535
16753
  LEAVING_SAID = "press ctrl+c again to leave";
16754
+ NOTHING_WRITTEN = "nothing written yet";
16536
16755
  layersAsk = (state) => {
16537
16756
  if (state.layers.length === 0) return "Please write a reading order for this branch with `adiff layers set`, so the diff can be read in the order the change was made rather than by filename.";
16538
16757
  if (state.layersStale) return "The reading order on this branch describes an older commit. Please read the diff again and write a new one with `adiff layers set`.";
@@ -17087,7 +17306,10 @@ var init_app = __esmMin((() => {
17087
17306
  if (listens(next.screen) !== listens(this.state.screen) || next.screen !== this.state.screen) runSync(this.display.askOn(listens(next.screen) ? next.screen : void 0));
17088
17307
  const was = writesInto(this.state.screen);
17089
17308
  const now = writesInto(next.screen);
17090
- if (was === now) return;
17309
+ if (was === now) {
17310
+ if (now && next.draftAt !== this.state.draftAt) runSync(this.display.write(next.draft));
17311
+ return;
17312
+ }
17091
17313
  if (now) runSync(this.display.write(next.draft));
17092
17314
  runSync(this.display.writeOn(now));
17093
17315
  }
@@ -17675,7 +17897,11 @@ var init_app = __esmMin((() => {
17675
17897
  sendReply(to) {
17676
17898
  return gen({ self: this }, function* () {
17677
17899
  const branch = selectedBranch(this.state);
17678
- if (branch === void 0 || this.state.draft.length === 0) return;
17900
+ if (branch === void 0) return;
17901
+ if (this.state.draft.trim().length === 0) {
17902
+ this.commit(withNotice(this.state, NOTHING_WRITTEN));
17903
+ return;
17904
+ }
17679
17905
  yield* submitReply({
17680
17906
  repo: this.repo,
17681
17907
  branch: branch.branch,
@@ -17685,10 +17911,7 @@ var init_app = __esmMin((() => {
17685
17911
  at: (/* @__PURE__ */ new Date()).toISOString()
17686
17912
  });
17687
17913
  const sent = yield* this.loadSent(branch.branch);
17688
- this.commit(withNotice(withSent({
17689
- ...this.state,
17690
- replyTo: void 0
17691
- }, sent), "sent to the agent"));
17914
+ this.commit(withNotice(sentAway(withSent(this.state, sent)), "sent to the agent"));
17692
17915
  });
17693
17916
  }
17694
17917
  askForLayers() {
@@ -17716,7 +17939,11 @@ var init_app = __esmMin((() => {
17716
17939
  const patch = selectedPatch(this.state);
17717
17940
  const branch = selectedBranch(this.state);
17718
17941
  const [from, to] = selectionRange(this.state);
17719
- if (patch === void 0 || branch === void 0 || this.state.draft.length === 0) return;
17942
+ if (patch === void 0 || branch === void 0) return;
17943
+ if (this.state.draft.trim().length === 0) {
17944
+ this.commit(withNotice(this.state, NOTHING_WRITTEN));
17945
+ return;
17946
+ }
17720
17947
  const anchor = anchorFor(patch, from, to);
17721
17948
  if (isNone(anchor)) {
17722
17949
  this.commit(withNotice(this.state, "nothing selected"));
@@ -17734,10 +17961,17 @@ var init_app = __esmMin((() => {
17734
17961
  at: (/* @__PURE__ */ new Date()).toISOString()
17735
17962
  });
17736
17963
  const sent = yield* this.loadSent(branch.branch);
17737
- this.commit(withNotice(withSent(this.state, sent), "sent to the agent"));
17964
+ this.commit(withNotice(sentAway(withSent(this.state, sent)), "sent to the agent"));
17738
17965
  });
17739
17966
  }
17740
17967
  };
17968
+ sentAway = (state) => ({
17969
+ ...state,
17970
+ screen: "review",
17971
+ draft: "",
17972
+ draftAt: "",
17973
+ replyTo: void 0
17974
+ });
17741
17975
  turnedOver = (state) => ({
17742
17976
  ...state,
17743
17977
  picked: void 0,
@@ -17887,14 +18121,18 @@ init_git();
17887
18121
  init_forge();
17888
18122
  init_store();
17889
18123
  const WAIT_UNIT = 1e3;
17890
- const answer = (options, body) => sync(() => {
18124
+ const answer = (options, body) => {
17891
18125
  const fields = fieldsOf(options);
17892
- const narrowed = Object.fromEntries(Object.entries(body).map(([key, value]) => [key, narrow(value, fields)]));
17893
- process.stdout.write(`${JSON.stringify({
17894
- ok: true,
17895
- ...narrowed
17896
- })}\n`);
17897
- });
18126
+ const strange = strangeField(body, fields);
18127
+ if (strange !== void 0) return fail(new UnknownField(strange));
18128
+ return sync(() => {
18129
+ const narrowed = Object.fromEntries(Object.entries(body).map(([key, value]) => [key, narrow(value, fields)]));
18130
+ process.stdout.write(`${JSON.stringify({
18131
+ ok: true,
18132
+ ...narrowed
18133
+ })}\n`);
18134
+ });
18135
+ };
17898
18136
  const branchList = fn("Main.branchList")(function* (options) {
17899
18137
  const branches = yield* listBranches(yield* required(options, "repo"), options["base"]);
17900
18138
  yield* answer(options, { branches });
@@ -17915,7 +18153,7 @@ const commentSend = fn("Main.commentSend")(function* (options) {
17915
18153
  start: yield* numeric(options, "start"),
17916
18154
  end: yield* numeric(options, "end"),
17917
18155
  body: yield* required(options, "body"),
17918
- side: options["side"] === "old" ? "old" : "new",
18156
+ side: yield* oneOf(options, "side", ["old", "new"], "new"),
17919
18157
  id: options["id"] ?? randomUUID(),
17920
18158
  at: options["at"] ?? (/* @__PURE__ */ new Date()).toISOString()
17921
18159
  });
@@ -17933,7 +18171,7 @@ const draftAdd = fn("Main.draftAdd")(function* (options) {
17933
18171
  start: yield* numeric(options, "start"),
17934
18172
  end: yield* numeric(options, "end"),
17935
18173
  body: yield* required(options, "body"),
17936
- side: options["side"] === "old" ? "old" : "new",
18174
+ side: yield* oneOf(options, "side", ["old", "new"], "new"),
17937
18175
  id: options["id"] ?? randomUUID(),
17938
18176
  at: options["at"] ?? (/* @__PURE__ */ new Date()).toISOString(),
17939
18177
  wroteBy: "agent"
@@ -18184,7 +18422,7 @@ const wanting = (name) => (error) => {
18184
18422
  usage: usageOf(command)
18185
18423
  }));
18186
18424
  };
18187
- const run = (name, options) => dispatch(name, options).pipe(catchTag("MissingOption", wanting(name)));
18425
+ const run = (name, options) => onlyKnown(options, knownIn(name)).pipe(flatMap(() => dispatch(name, options)), catchTag("MissingOption", wanting(name)));
18188
18426
  const leading = (argv) => {
18189
18427
  const stop = argv.findIndex((token) => token.startsWith("-"));
18190
18428
  return stop === -1 ? argv : argv.slice(0, stop);
@@ -18229,6 +18467,6 @@ const reportFailure = (cause) => sync(() => {
18229
18467
  process.stderr.write(`${reported.line}\n`);
18230
18468
  process.exitCode = reported.exit;
18231
18469
  });
18232
- runFork(run(opening ? "review open" : nameOf(argv), opening ? { repo: "." } : optionsFrom(argv)).pipe(provide(layer), catchCause(reportFailure)));
18470
+ runFork(run(opening ? "review open" : nameOf(argv), opening ? { repo: "." } : optionsFrom(argv, valuedIn(nameOf(argv)))).pipe(provide(layer), catchCause(reportFailure)));
18233
18471
  //#endregion
18234
18472
  export {};
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.108",
26
+ "version": "0.1.0-alpha.109",
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": {