@eliya-oss/agent-diff 0.1.0-alpha.105 → 0.1.0-alpha.107

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,27 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.107
4
+
5
+ ### Patch Changes
6
+
7
+ - The key that swaps the rail says where it would take you — `s file tree` while you are reading layers, `s layers` while you are reading files — and it is offered from the diff as well as from the rail. A layer set that has gone stale says so in the header, so you can see it from the file tree and not only from the layers rail.
8
+
9
+ ## 0.1.0-alpha.106
10
+
11
+ ### Minor Changes
12
+
13
+ - A layer in the rail is a card: its title, what it says, and the files it covers, each ticked off as it is reviewed, with a count of how many are done. `]` and `[` walk that reading order from one layer into the next, and switching to the file tree survives a reload.
14
+
15
+ ### Patch Changes
16
+
17
+ - Layers read as chapters. The rail no longer repeats each layer's note word for word — the diff already shows it above the code it describes — and prints the reading order instead: a numbered title, the directories the layer touches, and the file names under them, with a tick against the ones you have read. It expands as many layers as fit rather than collapsing all but one, marks the current file in the accent colour, and says how many layers sit above and below.
18
+
19
+ - Making the terminal smaller no longer blanks the review for good. Every panel kept its old width, the draw underneath failed, and nothing was drawn again until adiff was restarted. Mark-and-go-to-next also stopped un-marking a file that was already reviewed.
20
+
21
+ - `layers set` says which layer it would not take and why, instead of one sentence for five different mistakes. Spans that end before they start, or start before line one, are refused rather than dropped in silence; a layer given both spans and blocks keeps both; `./src/one.ts` is the same path as `src/one.ts`; and `layers show` reports covered, partial and vanished for each layer, not only for the document as a whole.
22
+
23
+ - Walking a layered review reaches the end of it. Two layers naming the same file used to send `]` and `[` back to the first layer that claimed it, leaving the tail of the review unreachable, and the header counted a file once per layer that mentioned it.
24
+
3
25
  ## 0.1.0-alpha.105
4
26
 
5
27
  ### Patch Changes
package/dist/main.js CHANGED
@@ -9927,7 +9927,7 @@ var init_pane = __esmMin((() => {
9927
9927
  init_commands();
9928
9928
  init_init();
9929
9929
  init_pane();
9930
- var version$1 = "0.1.0-alpha.105";
9930
+ var version$1 = "0.1.0-alpha.107";
9931
9931
  //#endregion
9932
9932
  //#region src/cli/upgrade.ts
9933
9933
  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;
@@ -10189,7 +10189,7 @@ var init_model$1 = __esmMin((() => {
10189
10189
  }));
10190
10190
  //#endregion
10191
10191
  //#region src/domain/layers/coverage.ts
10192
- var codeBlockOf$1, codeBlocks, noteOf, spansOf$1, changedLines, holds, runsOf, tallyOf, coverage, withFullCoverage, proseAnchors;
10192
+ var codeBlockOf$1, codeBlocks, noteOf, spansOf$1, changedLines, holds, runsOf, tallyOf, coverage, missingSaid, withFullCoverage, proseAnchors;
10193
10193
  var init_coverage = __esmMin((() => {
10194
10194
  init_dist();
10195
10195
  init_model$1();
@@ -10245,6 +10245,7 @@ var init_coverage = __esmMin((() => {
10245
10245
  missing: tallies.flatMap((tally) => tally.missing)
10246
10246
  };
10247
10247
  };
10248
+ missingSaid = (count) => count === 1 ? "One run of changed lines the layers do not account for." : `${count} runs of changed lines the layers do not account for.`;
10248
10249
  withFullCoverage = (patches, layers) => {
10249
10250
  const gap = coverage(patches, layers.layers);
10250
10251
  if (gap.missing.length === 0) return layers;
@@ -10252,7 +10253,7 @@ var init_coverage = __esmMin((() => {
10252
10253
  title: REMAINDER_TITLE,
10253
10254
  blocks: [{
10254
10255
  kind: "prose",
10255
- markdown: `${gap.missing.length} runs of changed lines the agent did not account for.`
10256
+ markdown: missingSaid(gap.missing.length)
10256
10257
  }, ...gap.missing.map((span) => codeBlockOf$1(span))]
10257
10258
  };
10258
10259
  return {
@@ -10317,7 +10318,7 @@ var init_layers$1 = __esmMin((() => {
10317
10318
  init_coverage();
10318
10319
  init_version();
10319
10320
  init_model$1();
10320
- })), STALE_ADVICE, unique, spansOfLayer, isSpan, isBlock, codeBlockOf, blocksOf, layerOf, parsed, readLayers, fromStored, toStored, reportedLayers, reportOf, resolve$1, resolveAll, worktreeAt, storedLayers, setLayers, showLayers, layersIn;
10321
+ })), STALE_ADVICE, unique, spansOfLayer, tidyPath, spanFault, blockFault, codeBlockOf, tidyBlock, blocksOf, layerFault, layerOf, parsed, readLayers, fromStored, toStored, reportedLayers, reportOf, resolve$1, resolveAll, worktreeAt, storedLayers, setLayers, showLayers, layersIn;
10321
10322
  var init_layers = __esmMin((() => {
10322
10323
  init_dist();
10323
10324
  init_layers$1();
@@ -10332,38 +10333,61 @@ var init_layers = __esmMin((() => {
10332
10333
  start,
10333
10334
  end
10334
10335
  }));
10335
- isSpan = (value) => {
10336
+ tidyPath = (path) => path.replace(/^\.\/+/, "").replace(/^\/+/, "");
10337
+ spanFault = (value) => {
10336
10338
  const span = value;
10337
- return typeof span?.path === "string" && typeof span.start === "number" && typeof span.end === "number";
10338
- };
10339
- isBlock = (value) => {
10339
+ if (typeof span?.path !== "string" || span.path.trim().length === 0) return "a span needs a path";
10340
+ if (!Number.isInteger(span.start) || !Number.isInteger(span.end)) return `the span on ${span.path} needs whole numbers for start and end`;
10341
+ const start = span.start;
10342
+ const end = span.end;
10343
+ if (start < 1) return `the span on ${span.path} starts at ${start}, and lines count from 1`;
10344
+ if (end < start) return `the span on ${span.path} ends at ${end}, before it starts at ${start}`;
10345
+ };
10346
+ blockFault = (value) => {
10340
10347
  const block = value;
10341
- if (block?.kind === "prose") return typeof block.markdown === "string";
10342
- return block?.kind === "code" && isSpan(value);
10348
+ if (block?.kind === "prose") return typeof block.markdown === "string" ? void 0 : "a prose block needs markdown";
10349
+ if (block?.kind !== "code") return `a block needs a kind of prose or code, not ${String(block?.kind)}`;
10350
+ return spanFault(value);
10343
10351
  };
10344
10352
  codeBlockOf = (span) => ({
10345
10353
  kind: "code",
10346
- path: span.path,
10354
+ path: tidyPath(span.path),
10347
10355
  start: span.start,
10348
10356
  end: span.end
10349
10357
  });
10358
+ tidyBlock = (block) => block.kind === "code" ? {
10359
+ ...block,
10360
+ path: tidyPath(block.path)
10361
+ } : block;
10350
10362
  blocksOf = (layer) => {
10351
- if (Array.isArray(layer.blocks)) return layer.blocks.filter(isBlock);
10352
- const note = typeof layer.note === "string" ? [{
10363
+ const note = typeof layer.note === "string" && layer.note.trim().length > 0 ? [{
10353
10364
  kind: "prose",
10354
10365
  markdown: layer.note
10355
10366
  }] : [];
10356
- const spans = Array.isArray(layer.spans) ? layer.spans.filter(isSpan) : [];
10357
- return [...note, ...spans.map(codeBlockOf)];
10358
- };
10359
- layerOf = (value) => {
10360
- const layer = value;
10361
- const title = typeof layer?.title === "string" ? layer.title.trim() : "";
10362
- if (layer === void 0 || title.length === 0) return none();
10363
- const blocks = blocksOf(layer);
10364
- return blocks.length === 0 ? none() : some({
10365
- title,
10366
- blocks
10367
+ const given = Array.isArray(layer.blocks) ? layer.blocks.map(tidyBlock) : [];
10368
+ const spans = Array.isArray(layer.spans) ? layer.spans : [];
10369
+ return [
10370
+ ...note,
10371
+ ...given,
10372
+ ...spans.map(codeBlockOf)
10373
+ ];
10374
+ };
10375
+ layerFault = (layer, at) => {
10376
+ const named = `layer ${at + 1}`;
10377
+ if (typeof layer.title !== "string" || layer.title.trim().length === 0) return `${named} needs a title`;
10378
+ const said = `${named}, "${layer.title.trim()}",`;
10379
+ const blocks = Array.isArray(layer.blocks) ? layer.blocks : [];
10380
+ const spans = Array.isArray(layer.spans) ? layer.spans : [];
10381
+ const fault = [...blocks.map(blockFault), ...spans.map(spanFault)].find((one) => one !== void 0);
10382
+ if (fault !== void 0) return `${said} ${fault}`;
10383
+ if (blocks.length === 0 && spans.length === 0) return `${said} needs at least one span or block`;
10384
+ };
10385
+ layerOf = (value, at) => {
10386
+ const layer = value ?? {};
10387
+ if (layerFault(layer, at) !== void 0) return none();
10388
+ return some({
10389
+ title: String(layer.title).trim(),
10390
+ blocks: blocksOf(layer)
10367
10391
  });
10368
10392
  };
10369
10393
  parsed = (text) => {
@@ -10380,11 +10404,13 @@ var init_layers = __esmMin((() => {
10380
10404
  onSome: succeed$1
10381
10405
  });
10382
10406
  const raw = document["layers"];
10383
- const layers = (Array.isArray(raw) ? raw : []).flatMap((entry) => match$3(layerOf(entry), {
10407
+ if (!Array.isArray(raw) || raw.length === 0) return yield* new MalformedLayers({ reason: "the document needs a layers array" });
10408
+ const fault = raw.map((entry, at) => layerFault(entry ?? {}, at)).find((said) => said !== void 0);
10409
+ if (fault !== void 0) return yield* new MalformedLayers({ reason: fault });
10410
+ const layers = raw.flatMap((entry, at) => match$3(layerOf(entry, at), {
10384
10411
  onNone: () => [],
10385
10412
  onSome: (layer) => [layer]
10386
10413
  }));
10387
- if (layers.length === 0) return yield* new MalformedLayers({ reason: "every layer needs a title and at least one span or block" });
10388
10414
  const summary = document["summary"];
10389
10415
  return {
10390
10416
  summary: typeof summary === "string" ? summary : "",
@@ -10401,13 +10427,20 @@ var init_layers = __esmMin((() => {
10401
10427
  });
10402
10428
  reportedLayers = (patches, layers) => {
10403
10429
  const present = new Set(patches.map((patch) => patch.path));
10404
- return withFullCoverage(patches, layers).layers.map((layer) => ({
10405
- title: layer.title,
10406
- note: noteOf(layer),
10407
- files: unique(spansOfLayer(layer).map((span) => span.path)).filter((path) => present.has(path)),
10408
- spans: spansOfLayer(layer),
10409
- prose: proseAnchors(layer).filter((anchor) => present.has(anchor.path))
10410
- }));
10430
+ return withFullCoverage(patches, layers).layers.map((layer) => {
10431
+ const named = unique(spansOfLayer(layer).map((span) => span.path));
10432
+ const gap = coverage(patches, [layer]);
10433
+ return {
10434
+ title: layer.title,
10435
+ note: noteOf(layer),
10436
+ files: named.filter((path) => present.has(path)),
10437
+ spans: spansOfLayer(layer),
10438
+ prose: proseAnchors(layer).filter((anchor) => present.has(anchor.path)),
10439
+ covered: gap.covered,
10440
+ partial: gap.partial,
10441
+ vanished: named.filter((path) => !present.has(path))
10442
+ };
10443
+ });
10411
10444
  };
10412
10445
  reportOf = (patches, layers, branchHead) => {
10413
10446
  const status = statusOf(patches, layers, branchHead);
@@ -11770,7 +11803,7 @@ var init_tree = __esmMin((() => {
11770
11803
  return node.children.reduce((total, child) => total + filesUnder(tree, child), 0);
11771
11804
  };
11772
11805
  crowdedDirectories = (tree, limit) => tree.nodes.filter((node) => node.kind === "directory" && directFiles(tree, node.id) > limit).map((node) => node.path);
11773
- })), nothingReviewed, initialState, TREE_MAX, TREE_ROOMY, TREE_MIN, TREE_SHARE, DIFF_MIN, 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, 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, layerFile, selectionRange;
11806
+ })), 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;
11774
11807
  var init_model = __esmMin((() => {
11775
11808
  init_dist();
11776
11809
  init_patch();
@@ -11840,6 +11873,7 @@ var init_model = __esmMin((() => {
11840
11873
  });
11841
11874
  TREE_MAX = 34;
11842
11875
  TREE_ROOMY = 40;
11876
+ TREE_WIDE = 52;
11843
11877
  TREE_MIN = 18;
11844
11878
  TREE_SHARE = .3;
11845
11879
  DIFF_MIN = 26;
@@ -11847,8 +11881,8 @@ var init_model = __esmMin((() => {
11847
11881
  bodyRoom = (columns) => Math.max(0, columns - 2);
11848
11882
  treeWidth = (columns) => {
11849
11883
  const room = bodyRoom(columns);
11850
- const most = room - reviewWidth() - DIFF_ROOMY >= TREE_ROOMY ? TREE_ROOMY : TREE_MAX;
11851
- const wanted = Math.min(most, Math.max(TREE_MIN, Math.floor(room * TREE_SHARE)));
11884
+ const spare = room - reviewWidth() - DIFF_ROOMY;
11885
+ 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)));
11852
11886
  return Math.max(0, Math.min(wanted, room - DIFF_MIN));
11853
11887
  };
11854
11888
  reviewWidth = () => 36;
@@ -11891,73 +11925,123 @@ var init_model = __esmMin((() => {
11891
11925
  const width = Math.max(1, room);
11892
11926
  return text.split(/\s+/).filter((word) => word.length > 0).flatMap((word) => chunked(word, width)).reduce((lines, word) => packed(lines, word, width), []);
11893
11927
  };
11894
- NO_NOTE = "no note";
11895
- noteRows$1 = (state, layerIndex, room) => {
11896
- const lines = wrapped(state.layers[layerIndex]?.note ?? "", room);
11897
- return (lines.length === 0 ? [NO_NOTE] : lines).map((text) => ({
11928
+ clip$1 = (label, room) => label.length > room ? `${label.slice(0, Math.max(0, room - 1))}…` : label;
11929
+ TITLE_ROWS = 2;
11930
+ titleRows = (state, layerIndex, room) => {
11931
+ const lines = wordWrapped(state.layers[layerIndex]?.title ?? "", room);
11932
+ const kept = lines.slice(0, TITLE_ROWS);
11933
+ const last = kept.at(-1) ?? "";
11934
+ return (lines.length > TITLE_ROWS ? [...kept.slice(0, -1), clip$1(`${last} …`, room)] : kept).map((text, at) => ({
11898
11935
  index: layerIndex,
11899
- kind: "note",
11936
+ kind: "title",
11900
11937
  text,
11901
- lead: false
11938
+ lead: at === 0
11902
11939
  }));
11903
11940
  };
11904
- proseRow = (layerIndex, text) => ({
11905
- index: layerIndex,
11906
- kind: "note",
11907
- text,
11908
- lead: false
11909
- });
11910
- proseRows$1 = (state, layerIndex, room) => {
11911
- const blocks = state.layers[layerIndex]?.prose ?? [];
11941
+ shortDir = (dir, room) => {
11942
+ const whole = `${dir}/`;
11943
+ if (whole.length <= room) return whole;
11944
+ const parts = dir.split("/");
11945
+ if (parts.length < 3) return `${clip$1(dir, Math.max(1, room - 1))}/`;
11946
+ return `${parts[0] ?? ""}/…/${parts.at(-1) ?? ""}/`;
11947
+ };
11948
+ fileRow$1 = (state, layerIndex, at, room) => {
11949
+ const path = state.patches[at]?.path ?? "";
11950
+ const name = path.split("/").at(-1) ?? path;
11951
+ return {
11952
+ index: layerIndex,
11953
+ kind: "file",
11954
+ text: clip$1(name, room),
11955
+ lead: false,
11956
+ fileIndex: at,
11957
+ reviewed: isReviewed(state, at),
11958
+ here: at === state.patchIndex
11959
+ };
11960
+ };
11961
+ shownFiles = (state, layerIndex) => layerFiles(state, layerIndex).filter((at) => !(state.hideReviewed && isReviewed(state, at) && at !== state.patchIndex));
11962
+ dirOf = (state, at) => {
11963
+ return (state.patches[at]?.path ?? "").split("/").slice(0, -1).join("/");
11964
+ };
11965
+ fileRows = (state, layerIndex, room) => {
11912
11966
  const rows = [];
11913
- for (const [at, block] of blocks.entries()) {
11914
- if (at > 0) rows.push(proseRow(layerIndex, ""));
11915
- for (const text of wrapped(block.markdown, room)) rows.push(proseRow(layerIndex, text));
11916
- rows.push({
11967
+ let held;
11968
+ for (const at of shownFiles(state, layerIndex)) {
11969
+ const dir = dirOf(state, at);
11970
+ if (dir !== held && dir.length > 0) rows.push({
11917
11971
  index: layerIndex,
11918
- kind: "file",
11919
- text: clipEnd(block.path, Math.max(1, room - FILE_LEAD)),
11972
+ kind: "dir",
11973
+ text: shortDir(dir, room.dir),
11920
11974
  lead: false
11921
11975
  });
11976
+ held = dir;
11977
+ rows.push(fileRow$1(state, layerIndex, at, room.file));
11922
11978
  }
11923
11979
  return rows;
11924
11980
  };
11925
- titleRows = (state, layerIndex, room) => wordWrapped(state.layers[layerIndex]?.title ?? "", room).map((text, at) => ({
11926
- index: layerIndex,
11927
- kind: "title",
11928
- text,
11929
- lead: at === 0
11930
- }));
11931
- clipEnd = (text, room) => {
11932
- if (text.length <= room) return text;
11933
- const parts = text.split("/");
11934
- const kept = [];
11935
- for (const part of parts.toReversed()) {
11936
- if ([part, ...kept].join("/").length + 2 > room) break;
11937
- kept.unshift(part);
11938
- }
11939
- return `…/${kept.length === 0 ? parts.at(-1) ?? text : kept.join("/")}`;
11940
- };
11941
- FILE_LEAD = 2;
11942
- fileRows = (state, layerIndex, room) => (state.layers[layerIndex]?.files ?? []).map((path) => ({
11943
- index: layerIndex,
11944
- kind: "file",
11945
- text: clipEnd(path, Math.max(1, room - FILE_LEAD)),
11946
- lead: false
11947
- }));
11948
- layerRows = (state, titleRoom, noteRoom) => state.layers.flatMap((_, index) => layerOpen(state, index) ? [...titleRows(state, index, titleRoom), ...(state.layers[index]?.prose ?? []).length > 0 ? proseRows$1(state, index, noteRoom) : [...noteRows$1(state, index, noteRoom), ...fileRows(state, index, noteRoom)]] : titleRows(state, index, titleRoom));
11981
+ layerRead = (state, layerIndex) => {
11982
+ const files = layerFiles(state, layerIndex);
11983
+ return {
11984
+ done: files.filter((at) => isReviewed(state, at)).length,
11985
+ all: files.length
11986
+ };
11987
+ };
11988
+ layerDone = (state, layerIndex) => {
11989
+ const read = layerRead(state, layerIndex);
11990
+ return read.all > 0 && read.done === read.all;
11991
+ };
11992
+ countRow = (state, index, room) => {
11993
+ const read = layerRead(state, index);
11994
+ if (read.all === 0) return [];
11995
+ const one = read.all === 1 ? "file" : "files";
11996
+ const said = `${read.done} of ${read.all} ${one} read`;
11997
+ return [{
11998
+ index,
11999
+ kind: "count",
12000
+ text: clip$1(said, room),
12001
+ lead: false
12002
+ }];
12003
+ };
12004
+ layerBody = (state, index, room, shown) => layerOpen(state, index) && shown.has(index) ? fileRows(state, index, room) : countRow(state, index, room.file);
12005
+ layerRows = (state, room, shown) => state.layers.flatMap((_, index) => [
12006
+ ...index > 0 ? [{
12007
+ index,
12008
+ kind: "gap",
12009
+ text: "",
12010
+ lead: false
12011
+ }] : [],
12012
+ ...titleRows(state, index, room.title),
12013
+ ...layerBody(state, index, room, shown)
12014
+ ]);
12015
+ nearFirst = (state) => state.layers.map((_, at) => at).filter((at) => layerOpen(state, at)).toSorted((one, two) => Math.abs(one - state.layerIndex) - Math.abs(two - state.layerIndex));
12016
+ layerFitted = (state, room, height) => {
12017
+ const every = new Set(state.layers.map((_, at) => at));
12018
+ const whole = layerRows(state, room, every);
12019
+ if (whole.length <= height) return whole;
12020
+ const shown = /* @__PURE__ */ new Set([state.layerIndex]);
12021
+ for (const at of nearFirst(state)) {
12022
+ shown.add(at);
12023
+ if (layerRows(state, room, shown).length > height) shown.delete(at);
12024
+ }
12025
+ shown.add(state.layerIndex);
12026
+ return layerRows(state, room, shown);
12027
+ };
11949
12028
  railWindow = (rows, height, layerIndex) => {
11950
12029
  if (rows.length <= height) return {
11951
12030
  rows,
11952
- more: 0
12031
+ more: 0,
12032
+ above: 0
11953
12033
  };
11954
12034
  const first = Math.max(0, rows.findIndex((row) => row.index === layerIndex));
11955
12035
  const block = rows.findLastIndex((row) => row.index === layerIndex) - first + 1;
11956
12036
  const wanted = block >= height ? first : first - Math.floor((height - block) / 2);
11957
12037
  const start = Math.max(0, Math.min(rows.length - height, wanted));
12038
+ const shown = rows.slice(start, start + height);
12039
+ const here = new Set(shown.map((row) => row.index));
12040
+ const seen = (from) => new Set(from.filter((row) => !here.has(row.index)).map((row) => row.index)).size;
11958
12041
  return {
11959
- rows: rows.slice(start, start + height),
11960
- more: rows.length - (start + height)
12042
+ rows: shown,
12043
+ more: seen(rows.slice(start + height)),
12044
+ above: seen(rows.slice(0, start))
11961
12045
  };
11962
12046
  };
11963
12047
  selectedBranch = (state) => state.branches[state.branchIndex];
@@ -12258,9 +12342,9 @@ var init_model = __esmMin((() => {
12258
12342
  return [...order.slice(start + 1), ...order.slice(0, start + 1)].find((index) => !isReviewed(state, index));
12259
12343
  };
12260
12344
  reviewedCount = (state) => `${state.vouched.length}/${state.patches.length} reviewed`;
12261
- fileOrder = (state) => onLayers(state) ? layerFiles(state, state.layerIndex) : flattenTree(treeOf(state), []).flatMap((row) => row.fileIndex === void 0 ? [] : [row.fileIndex]);
12345
+ fileOrder = (state) => onLayers(state) ? state.layers.flatMap((_, at) => layerFiles(state, at)) : flattenTree(treeOf(state), []).flatMap((row) => row.fileIndex === void 0 ? [] : [row.fileIndex]);
12262
12346
  filePlace = (state) => {
12263
- const order = fileOrder(state);
12347
+ const order = [...new Set(fileOrder(state))];
12264
12348
  const at = order.indexOf(state.patchIndex);
12265
12349
  if (at === -1) return {
12266
12350
  at: state.patchIndex + 1,
@@ -12271,11 +12355,29 @@ var init_model = __esmMin((() => {
12271
12355
  of: order.length
12272
12356
  };
12273
12357
  };
12358
+ readingOrder = (state) => onLayers(state) ? state.layers.flatMap((_, layer) => layerFiles(state, layer).map((file) => ({
12359
+ layer,
12360
+ file
12361
+ }))) : fileOrder(state).map((file) => ({
12362
+ layer: state.layerIndex,
12363
+ file
12364
+ }));
12365
+ placeIn = (state) => {
12366
+ const order = readingOrder(state);
12367
+ const at = order.findIndex((one) => one.file === state.patchIndex && (!onLayers(state) || one.layer === state.layerIndex));
12368
+ return at === -1 ? order.findIndex((one) => one.file === state.patchIndex) : at;
12369
+ };
12274
12370
  layerFile = (state, delta) => {
12275
- const order = fileOrder(state);
12276
- const position = order.indexOf(state.patchIndex);
12277
- if (position === -1) return order[0] ?? state.patchIndex;
12278
- return order[Math.max(0, Math.min(order.length - 1, position + delta))] ?? state.patchIndex;
12371
+ const order = readingOrder(state);
12372
+ const at = placeIn(state);
12373
+ if (at === -1) return order[0]?.file ?? state.patchIndex;
12374
+ return order[Math.max(0, Math.min(order.length - 1, at + delta))]?.file ?? state.patchIndex;
12375
+ };
12376
+ layerAfter = (state, delta) => {
12377
+ const order = readingOrder(state);
12378
+ const at = placeIn(state);
12379
+ if (at === -1) return order[0]?.layer ?? state.layerIndex;
12380
+ return order[Math.max(0, Math.min(order.length - 1, at + delta))]?.layer ?? state.layerIndex;
12279
12381
  };
12280
12382
  selectionRange = (state) => state.anchorRow <= state.cursor ? [state.anchorRow, state.cursor] : [state.cursor, state.anchorRow];
12281
12383
  }));
@@ -12366,7 +12468,7 @@ var init_watch = __esmMin((() => {
12366
12468
  }));
12367
12469
  //#endregion
12368
12470
  //#region src/tui/command.ts
12369
- var EVERY_PANE, command, commands, TEXT_SCREENS, PRINTABLE_KEY, takesText, commandsFor, listableFor, glossaryFor, actionFor, GLYPHS, displayKey, hintsFor;
12471
+ var EVERY_PANE, command, commands, TEXT_SCREENS, PRINTABLE_KEY, takesText, commandsFor, listableFor, glossaryFor, actionFor, GLYPHS, displayKey, hintOf, hintsFor;
12370
12472
  var init_command = __esmMin((() => {
12371
12473
  EVERY_PANE = [
12372
12474
  "tree",
@@ -12779,7 +12881,7 @@ var init_command = __esmMin((() => {
12779
12881
  }),
12780
12882
  command({
12781
12883
  action: "rail.toggle",
12782
- panes: ["tree"],
12884
+ panes: ["tree", "diff"],
12783
12885
  title: "Switch between layers and files",
12784
12886
  category: "Files",
12785
12887
  keys: ["s"],
@@ -12978,9 +13080,13 @@ var init_command = __esmMin((() => {
12978
13080
  if (key.startsWith("ctrl+")) return `^${key.slice(5)}`;
12979
13081
  return GLYPHS[key] ?? key;
12980
13082
  };
13083
+ hintOf = (entry, offered) => {
13084
+ if (entry.action === "rail.toggle") return offered.onLayers ? "file tree" : "layers";
13085
+ return entry.counted ? `${entry.hint} ${offered.comments}` : entry.hint;
13086
+ };
12981
13087
  hintsFor = (screen, offered) => commandsFor(screen).filter((entry) => entry.hint.length > 0).filter((entry) => !entry.whenComments || offered.comments > 0).filter((entry) => !entry.whenLayers || offered.layers > 0).filter((entry) => !entry.whenThread || offered.onThread).filter((entry) => !entry.whenSelecting || offered.selecting).filter((entry) => !entry.whenReviewed || offered.reviewed > 0).filter((entry) => !entry.whenPull || offered.pull).filter((entry) => entry.panes.includes(offered.pane)).toSorted((left, right) => left.rank - right.rank).map((entry) => ({
12982
13088
  key: displayKey(entry.keys[0] ?? ""),
12983
- hint: entry.counted ? `${entry.hint} ${offered.comments}` : entry.hint,
13089
+ hint: hintOf(entry, offered),
12984
13090
  press: entry.keys[0] ?? ""
12985
13091
  }));
12986
13092
  }));
@@ -13012,7 +13118,7 @@ var init_match = __esmMin((() => {
13012
13118
  }));
13013
13119
  //#endregion
13014
13120
  //#region src/tui/reduce.ts
13015
- 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, 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, 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;
13121
+ 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;
13016
13122
  var init_reduce = __esmMin((() => {
13017
13123
  init_dist();
13018
13124
  init_patch();
@@ -13152,17 +13258,18 @@ var init_reduce = __esmMin((() => {
13152
13258
  };
13153
13259
  };
13154
13260
  moveLayer = (state, delta) => {
13155
- const layerIndex = clamp(state.layerIndex + delta, 0, Math.max(0, state.layers.length - 1));
13156
- const landed = {
13157
- ...state,
13158
- layerIndex
13159
- };
13160
- const patchIndex = layerFiles(landed, layerIndex)[0] ?? landed.patchIndex;
13261
+ const order = readingOrder(state);
13262
+ if (order.length === 0) return state;
13263
+ const at = placeIn(state);
13264
+ const landed = order[clamp((at === -1 ? 0 : at) + delta, 0, order.length - 1)];
13265
+ if (landed === void 0) return state;
13161
13266
  return {
13162
- ...landed,
13163
- patchIndex,
13267
+ ...state,
13268
+ layerIndex: landed.layer,
13269
+ openLayers: state.openLayers.includes(landed.layer) ? state.openLayers : [...state.openLayers, landed.layer],
13270
+ patchIndex: landed.file,
13164
13271
  top: 0,
13165
- cursor: 0,
13272
+ cursor: landingOn(state, landed.file),
13166
13273
  anchorRow: 0,
13167
13274
  selecting: false
13168
13275
  };
@@ -13286,12 +13393,20 @@ var init_reduce = __esmMin((() => {
13286
13393
  }, patchIndex);
13287
13394
  return state.closed.filter((path) => !wanted.includes(path));
13288
13395
  };
13396
+ atTheEnd = (state, delta) => {
13397
+ const at = placeIn(state);
13398
+ const wanted = at + delta;
13399
+ return at !== -1 && (wanted < 0 || wanted >= readingOrder(state).length);
13400
+ };
13289
13401
  moveFile = (state, delta) => {
13402
+ if (atTheEnd(state, delta)) return withNoticeHere(state, delta > 0 ? "last file" : "first file");
13290
13403
  const next = layerFile(state, delta);
13291
- if (next === state.patchIndex) return withNoticeHere(state, delta > 0 ? "last file" : "first file");
13404
+ const layer = onLayers(state) ? layerAfter(state, delta) : state.layerIndex;
13292
13405
  return {
13293
13406
  ...state,
13294
13407
  notice: "",
13408
+ layerIndex: layer,
13409
+ openLayers: state.openLayers.includes(layer) ? state.openLayers : [...state.openLayers, layer],
13295
13410
  closed: revealing(state, next),
13296
13411
  patchIndex: next,
13297
13412
  top: 0,
@@ -13604,18 +13719,20 @@ var init_reduce = __esmMin((() => {
13604
13719
  ...state,
13605
13720
  columns
13606
13721
  });
13722
+ laidOver = (state, told, anew) => ({
13723
+ ...state,
13724
+ layers: told.layers,
13725
+ layersStale: told.stale,
13726
+ summary: told.summary ?? "",
13727
+ layerIndex: anew ? 0 : Math.min(state.layerIndex, Math.max(0, told.layers.length - 1)),
13728
+ openLayers: anew ? told.layers.map((_, at) => at) : state.openLayers.filter((at) => at < told.layers.length),
13729
+ rail: told.layers.length === 0 ? "tree" : anew ? "layers" : state.rail
13730
+ });
13607
13731
  withLayers = (state, told) => {
13608
13732
  const layers = told.layers;
13609
- const opened = {
13610
- ...state,
13611
- layers,
13612
- layersStale: told.stale,
13613
- summary: told.summary ?? "",
13614
- layerIndex: 0,
13615
- openLayers: [],
13616
- rail: layers.length === 0 ? "tree" : "layers"
13617
- };
13618
- if (layers.length === 0) return opened;
13733
+ const anew = state.layers.length === 0;
13734
+ const opened = laidOver(state, told, anew);
13735
+ if (layers.length === 0 || !anew) return opened;
13619
13736
  return {
13620
13737
  ...opened,
13621
13738
  patchIndex: layerFiles(opened, 0)[0] ?? opened.patchIndex,
@@ -13865,7 +13982,7 @@ var init_theme = __esmMin((() => {
13865
13982
  note: "#9aa7c7",
13866
13983
  cursor: "#232936",
13867
13984
  selection: "#2b3854",
13868
- resting: "#1b2233",
13985
+ resting: "#243043",
13869
13986
  marker: blue,
13870
13987
  addedBg: "#0f2a19",
13871
13988
  removedBg: "#2e1418",
@@ -14562,9 +14679,10 @@ var init_diffview = __esmMin((() => {
14562
14679
  }));
14563
14680
  //#endregion
14564
14681
  //#region src/tui/render.ts
14565
- 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, 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, restingOrHere, FOUND_LEAST, nothingYet, foundTitle, fileRow, blockOf, aroundRow, windowedBlocks, panelWhere, panelBody, panelPair, panelSection, PULL_HINT, panelText, Screen;
14682
+ 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;
14566
14683
  var init_render = __esmMin((() => {
14567
14684
  init_command();
14685
+ init_layers$1();
14568
14686
  init_patch();
14569
14687
  init_diffview();
14570
14688
  init_gaps();
@@ -15076,14 +15194,15 @@ var init_render = __esmMin((() => {
15076
15194
  `…/${name}`
15077
15195
  ].find((option) => option.length <= room) ?? clipMiddle(name, room);
15078
15196
  };
15079
- SUMMARY_LINES = 3;
15080
- summaryLines = (summary, room) => {
15197
+ SUMMARY_LINES = 5;
15198
+ summaryLines = (summary, room, rail = Number.MAX_SAFE_INTEGER) => {
15081
15199
  const said = summary.trim();
15082
15200
  if (said.length === 0) return [];
15201
+ const most = Math.max(2, Math.min(SUMMARY_LINES, Math.floor(rail / 6)));
15083
15202
  const lines = wrapped(said, Math.max(1, room));
15084
- const kept = lines.slice(0, SUMMARY_LINES);
15203
+ const kept = lines.slice(0, most);
15085
15204
  const last = kept.at(-1) ?? "";
15086
- return [...(lines.length > SUMMARY_LINES ? [...kept.slice(0, -1), clip(`${last}…`, room)] : kept).map((line) => ` ${line}`), ""];
15205
+ return [...(lines.length > most ? [...kept.slice(0, -1), clip(`${last}…`, room)] : kept).map((line) => ` ${line}`), ""];
15087
15206
  };
15088
15207
  contextLabel = (context) => {
15089
15208
  if (context === 3) return "";
@@ -15134,6 +15253,7 @@ var init_render = __esmMin((() => {
15134
15253
  pullHere(state).length === 0 ? "" : `${pullHere(state)} pull request`,
15135
15254
  state.vouched.length === 0 ? "" : reviewedCount(state),
15136
15255
  contextLabel(state.context),
15256
+ state.layersStale ? "layers stale" : "",
15137
15257
  hiddenLines(state) === 0 ? "" : `⋯ ${hiddenLines(state)} ${hiddenLines(state) === 1 ? "line" : "lines"} hidden`,
15138
15258
  pan === 0 ? "" : `→ ${pan} columns`
15139
15259
  ];
@@ -15164,40 +15284,54 @@ var init_render = __esmMin((() => {
15164
15284
  const room = Math.max(4, pane - PANE_CHROME - 2 - tail.length);
15165
15285
  return `${treeMarks(state, row)}${clip(treeLabel(state, row, room), room).padEnd(room)}${tail}`;
15166
15286
  };
15167
- STEP_NUMBER = 3;
15168
- STEP_LEAD = 8;
15169
- NOTE_LEAD = 10;
15170
- STEP_GAP = 1;
15287
+ GUTTER = 3;
15288
+ DIR_LEAD = GUTTER;
15289
+ TITLE_LEAD = 4;
15290
+ FILE_LEAD = 6;
15171
15291
  STALE_ROOM = 13;
15172
15292
  STALE_LONG = "stale, the branch moved on";
15173
15293
  STALE_SHORT = "stale";
15174
- staleBanner = (room) => wrapped(room >= STALE_ROOM ? STALE_LONG : STALE_SHORT, room).map((line) => ` ${line}`).join("\n");
15175
- layerRoom = (state, pane) => {
15176
- const tally = Math.max(1, ...state.layers.map((layer) => `${layer.files.length}`.length));
15294
+ staleBanner = (room) => wrapped(room >= STALE_ROOM ? STALE_LONG : STALE_SHORT, room).map((line) => ` ${line}`).join("\n");
15295
+ layerRoom = (pane) => {
15296
+ const whole = Math.max(8, pane - PANE_CHROME);
15177
15297
  return {
15178
- title: Math.max(4, pane - PANE_CHROME - STEP_LEAD - STEP_GAP - tally),
15179
- note: Math.max(4, pane - PANE_CHROME - NOTE_LEAD),
15180
- tally
15298
+ title: Math.max(4, whole - TITLE_LEAD),
15299
+ dir: Math.max(4, whole - DIR_LEAD),
15300
+ file: Math.max(4, whole - FILE_LEAD)
15181
15301
  };
15182
15302
  };
15183
- layerFold = (state, index) => {
15184
- if (layerOpen(state, index)) return "▾";
15185
- return (state.layers[index]?.note ?? "").length === 0 ? " " : "▸";
15303
+ layerMark = (state, row) => {
15304
+ if (row.kind === "file") return row.reviewed === true ? marks().reviewed : " ";
15305
+ if (row.kind !== "title" || !row.lead) return " ";
15306
+ if (layerDone(state, row.index)) return marks().reviewed;
15307
+ if (leftOver(state, row.index)) return "·";
15308
+ return `${row.index + 1}`;
15186
15309
  };
15187
- layerHead = (state, row) => {
15188
- if (!row.lead) return " ".repeat(STEP_LEAD);
15189
- return `${row.index === state.layerIndex ? state.focus === "tree" ? "▸" : "·" : " "} ${layerFold(state, row.index)} ${`${row.index + 1}.`.padStart(STEP_NUMBER)} `;
15310
+ layerLead = (row) => {
15311
+ if (row.kind === "file") return FILE_LEAD;
15312
+ if (row.kind === "dir") return DIR_LEAD;
15313
+ return TITLE_LEAD;
15314
+ };
15315
+ layerGutter = (state, row) => {
15316
+ return `${row.here === true ? "▎" : " "}${layerMark(state, row).padStart(2)}`;
15190
15317
  };
15191
15318
  layerText = (state, row, room) => {
15192
- if (row.kind === "file") return `${" ".repeat(NOTE_LEAD)}${marks().file} ${row.text}`;
15193
- if (row.kind === "note") return `${" ".repeat(NOTE_LEAD)}${row.text}`;
15194
- const tail = (row.lead ? `${state.layers[row.index]?.files.length ?? 0}` : "").padStart(room.tally + STEP_GAP);
15195
- return `${layerHead(state, row)}${row.text.padEnd(room.title)}${tail}`;
15319
+ if (row.kind === "gap") return "";
15320
+ const lead = layerLead(row) - GUTTER;
15321
+ return `${layerGutter(state, row)}${" ".repeat(lead)}${row.text}`.padEnd(room.title + TITLE_LEAD);
15322
+ };
15323
+ litRow = (row, state, drawn) => row.here === true ? bg(restingOrHere(state.focus === "tree"))(drawn) : drawn;
15324
+ leftOver = (state, layerIndex) => state.layers[layerIndex]?.title === REMAINDER_TITLE;
15325
+ titlePaint = (state, layerIndex) => {
15326
+ const here = layerIndex === state.layerIndex;
15327
+ if (leftOver(state, layerIndex)) return here ? palette.attention : palette.faint;
15328
+ if (layerDone(state, layerIndex)) return palette.faint;
15329
+ return here ? palette.ink : palette.muted;
15196
15330
  };
15197
15331
  layerPaint = (state, row) => {
15198
- if (row.kind === "file") return palette.ink;
15199
- if (row.kind === "note") return palette.faint;
15200
- return row.index === state.layerIndex ? palette.ink : palette.muted;
15332
+ if (row.kind === "file") return row.reviewed === true ? palette.added : palette.ink;
15333
+ if (row.kind === "dir" || row.kind === "count") return palette.faint;
15334
+ return titlePaint(state, row.index);
15201
15335
  };
15202
15336
  PANEL_TITLES = {
15203
15337
  with: "With the agent",
@@ -15503,7 +15637,8 @@ var init_render = __esmMin((() => {
15503
15637
  selecting: state.selecting,
15504
15638
  reviewed: reviewedCountIn(state),
15505
15639
  pull: pullHere(state).length > 0,
15506
- pane: state.screen === "review" ? state.focus : "diff"
15640
+ pane: state.screen === "review" ? state.focus : "diff",
15641
+ onLayers: onLayers(state)
15507
15642
  });
15508
15643
  this.header.content = this.headerText(state);
15509
15644
  this.footer.content = this.footerText(state);
@@ -15616,24 +15751,37 @@ var init_render = __esmMin((() => {
15616
15751
  return Math.max(1, this.listPane.height - edges);
15617
15752
  }
15618
15753
  layerRail(state) {
15619
- const room = layerRoom(state, this.paneRoom());
15620
- const said = summaryLines(state.summary, room.note);
15754
+ const room = layerRoom(this.paneRoom());
15755
+ const said = summaryLines(state.summary, room.title, this.listRoom());
15621
15756
  const banner = (state.layersStale ? 1 : 0) + said.length;
15622
15757
  const height = Math.max(1, this.listRoom() - banner);
15623
- const all = layerRows(state, room.title, room.note);
15624
- const whole = railWindow(all, height, state.layerIndex);
15625
- const window = whole.more === 0 ? whole : railWindow(all, Math.max(1, height - 1), state.layerIndex);
15626
- const rows = window.rows.map((row) => fg(layerPaint(state, row))(`${layerText(state, row, room)}\n`));
15627
- const more = window.more > 0 ? [fg(palette.faint)(` … ${window.more} more`)] : [];
15628
- const warn = state.layersStale ? [fg(palette.attention)(`${staleBanner(room.note)}\n`)] : [];
15758
+ const all = layerFitted(state, room, height);
15759
+ const window = this.railFitted(state, all, height);
15760
+ const rows = window.rows.flatMap((row) => this.layerLine(state, row, room));
15761
+ const above = window.above > 0 ? [fg(palette.faint)(` ▲ ${window.above} more\n`)] : [];
15762
+ const more = window.more > 0 ? [fg(palette.faint)(` ▼ ${window.more} more`)] : [];
15763
+ const warn = state.layersStale ? [fg(palette.attention)(`${staleBanner(room.title)}\n`)] : [];
15629
15764
  const told = said.map((line) => fg(palette.muted)(`${line}\n`));
15630
15765
  return new StyledText([
15631
15766
  ...told,
15632
15767
  ...warn,
15768
+ ...above,
15633
15769
  ...rows,
15634
15770
  ...more
15635
15771
  ]);
15636
15772
  }
15773
+ layerLine(state, row, room) {
15774
+ const drawn = layerText(state, row, room);
15775
+ const body = fg(layerPaint(state, row))(`${drawn.slice(1)}\n`);
15776
+ return [fg(row.here === true ? palette.marker : palette.faint)(drawn.slice(0, 1)), litRow(row, state, body)];
15777
+ }
15778
+ railFitted(state, all, height) {
15779
+ const whole = railWindow(all, height, state.layerIndex);
15780
+ if (whole.more === 0 && whole.above === 0) return whole;
15781
+ const once = railWindow(all, Math.max(1, height - 1), state.layerIndex);
15782
+ if (once.above === 0 || once.more === 0) return once;
15783
+ return railWindow(all, Math.max(1, height - 2), state.layerIndex);
15784
+ }
15637
15785
  paintDiff(state) {
15638
15786
  const shown = shownOf(state);
15639
15787
  if (shown === void 0) return;
@@ -16048,7 +16196,7 @@ var init_upgrade = __esmMin((() => {
16048
16196
  return due ? `adiff ${latest} is out · adiff upgrade` : "";
16049
16197
  }).pipe(withSpan("Tui.upgradeHint"));
16050
16198
  upgradeHint = worded.pipe(orElseSucceed(() => ""));
16051
- })), LOOK_MS, LEAVING_SAID, 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;
16199
+ })), LOOK_MS, LEAVING_SAID, 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;
16052
16200
  var init_app = __esmMin((() => {
16053
16201
  init_dist();
16054
16202
  init_report();
@@ -16068,6 +16216,10 @@ var init_app = __esmMin((() => {
16068
16216
  init_upgrade();
16069
16217
  LOOK_MS = 110;
16070
16218
  LEAVING_SAID = "press ctrl+c again to leave";
16219
+ alongFrom = (state) => {
16220
+ const along = nextUnreviewed(state, state.patchIndex);
16221
+ return along === void 0 ? withNotice(state, "every file reviewed") : atFile(state, along);
16222
+ };
16071
16223
  NOTICE_MS = 2200;
16072
16224
  KEY_HISTORY = 40;
16073
16225
  DRAIN_PASSES = 8;
@@ -16254,6 +16406,7 @@ var init_app = __esmMin((() => {
16254
16406
  renderer.on("destroy", () => this.stopPainting());
16255
16407
  renderer.on("destroy", () => this.stopConsuming());
16256
16408
  renderer.on("frame", () => this.syncGeometry());
16409
+ renderer.on("resize", () => this.resized());
16257
16410
  renderer.setFrameCallback(() => runPromise(this.applying()));
16258
16411
  const resume = options.resume;
16259
16412
  const opensOn = options.opensOn;
@@ -16412,6 +16565,10 @@ var init_app = __esmMin((() => {
16412
16565
  const moved = down === 0 ? this.measured() : scrolled(this.standing(), down);
16413
16566
  this.commit(across === 0 ? moved : panBy(moved, across));
16414
16567
  }
16568
+ resized() {
16569
+ runSync(this.display.paint(this.state));
16570
+ this.syncGeometry();
16571
+ }
16415
16572
  syncGeometry() {
16416
16573
  const rows = runSync(this.display.rows);
16417
16574
  if (rows !== this.state.viewport) {
@@ -17012,6 +17169,10 @@ var init_app = __esmMin((() => {
17012
17169
  const branch = selectedBranch(this.state);
17013
17170
  const patch = selectedPatch(this.state);
17014
17171
  if (branch === void 0 || patch === void 0) return;
17172
+ if (advance && isReviewed(this.state, this.state.patchIndex)) {
17173
+ this.commit(alongFrom(this.state));
17174
+ return;
17175
+ }
17015
17176
  const report = yield* this.vouching(branch.branch, patch.path);
17016
17177
  const marked = report.vouched.includes(patch.path);
17017
17178
  const next = withVouched(this.state, report.vouched);
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.105",
26
+ "version": "0.1.0-alpha.107",
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": {
@@ -231,8 +231,9 @@ was written for, and adiff reports it as `stale` once the branch moves past that
231
231
  reviewer has a reading order, keep it true: write it again after you address their comments.
232
232
 
233
233
  When you have published one, tell them the sidebar now holds it: `s` swaps between the layers and
234
- the files, `j` and `k` move between layers with the diff following, and `]` and `[` walk the files
235
- inside a layer.
234
+ the files, each layer shows the files it covers with the ones already reviewed ticked off, and `]`
235
+ and `[` walk those files in the order you put them in — from the last file of one layer into the
236
+ first of the next.
236
237
 
237
238
  ## Discovering the rest
238
239