@eliya-oss/agent-diff 0.1.0-alpha.210 → 0.1.0-alpha.212

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 (34) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/main.js +1123 -695
  3. package/dist/web/nitro.json +1 -1
  4. package/dist/web/public/assets/{_deck-bHyYGFMC.js → _deck-CyoyHMyL.js} +1 -1
  5. package/dist/web/public/assets/{_point-Df5RE6M6.js → _point-CYZXMbyL.js} +1 -1
  6. package/dist/web/public/assets/index-CUagVLhR.css +2 -0
  7. package/dist/web/public/assets/{index-Dv2OX9bH.js → index-D3quZsre.js} +2 -2
  8. package/dist/web/public/assets/{review-Bu_bWLB8.js → review-Cu9qERg1.js} +1 -1
  9. package/dist/web/public/assets/{review-block-CSU8TP-U.js → review-block-Bng1Lrgg.js} +12 -12
  10. package/dist/web/public/assets/{routes-uxQf-w7c.js → routes-BnF0AJkz.js} +1 -1
  11. package/dist/web/public/assets/{viewed-store-B-45NTVY.js → viewed-store-DsqSJn2J.js} +1 -1
  12. package/dist/web/server/{_deck-BrcrkCE2.mjs → _deck-CxY-KSJu.mjs} +3 -3
  13. package/dist/web/server/{_point-BsiN7JGn.mjs → _point-Bl3MEO09.mjs} +4 -4
  14. package/dist/web/server/_ssr/{adhoc.functions-B39jjvi1.mjs → adhoc.functions-PKrFaWO1.mjs} +2 -2
  15. package/dist/web/server/_ssr/{decks.functions-0wQ-UZLQ.mjs → decks.functions-DPok33k1.mjs} +4 -4
  16. package/dist/web/server/_ssr/{listener.functions-Bsap7m-C.mjs → listener.functions-DeWc_4uW.mjs} +4 -4
  17. package/dist/web/server/_ssr/{listener.server-DtMUmNCb.mjs → listener.server-DzZGa8GT.mjs} +2 -2
  18. package/dist/web/server/_ssr/{live-schema-rwIqSfXd.mjs → live-schema-BYm_IvNp.mjs} +4 -3
  19. package/dist/web/server/_ssr/{review-CwlsS5m4.mjs → review-Bj0xIgoW.mjs} +3 -3
  20. package/dist/web/server/_ssr/{review-block-BkiLFX6y.mjs → review-block-BCVuzSG_.mjs} +1481 -998
  21. package/dist/web/server/_ssr/{review-parts.server-BvMVQd9C.mjs → review-parts.server-B2XqQUAB.mjs} +5 -4
  22. package/dist/web/server/_ssr/{review-target.server-BTCBlGFL.mjs → review-target.server-rsHUeYW_.mjs} +69 -10
  23. package/dist/web/server/_ssr/{review.functions-CifSVeZt.mjs → review.functions-eAVBYvOS.mjs} +4 -4
  24. package/dist/web/server/_ssr/{router-sHH4eQWZ.mjs → router-BLRO6kTw.mjs} +14 -14
  25. package/dist/web/server/_ssr/{routes-V4kZPRI3.mjs → routes-BovmU9kO.mjs} +2 -2
  26. package/dist/web/server/_ssr/shortcuts-B7llaLLc.mjs +1 -1
  27. package/dist/web/server/_ssr/ssr.mjs +33 -33
  28. package/dist/web/server/_ssr/{type-hover.functions-Cf2CfVvS.mjs → type-hover.functions-DPCO8VcS.mjs} +2 -2
  29. package/dist/web/server/_ssr/{viewed-store-auFKz1vA.mjs → viewed-store-xn13Ju6x.mjs} +2 -2
  30. package/dist/web/server/{_tanstack-start-manifest_v-emcOJdhD.mjs → _tanstack-start-manifest_v-CZLPm-IJ.mjs} +8 -8
  31. package/dist/web/server/index.mjs +48 -48
  32. package/package.json +1 -1
  33. package/skills/adiff/SKILL.md +46 -3
  34. package/dist/web/public/assets/index-Cog4a4vB.css +0 -2
package/dist/main.js CHANGED
@@ -10119,7 +10119,7 @@ var init_config = __esmMin((() => {
10119
10119
  //#region package.json
10120
10120
  init_pane();
10121
10121
  init_config();
10122
- var version$2 = "0.1.0-alpha.210";
10122
+ var version$2 = "0.1.0-alpha.212";
10123
10123
  //#endregion
10124
10124
  //#region src/cli/error.ts
10125
10125
  var UnknownCommand, MissingOption, UnknownField, UnknownOption, RemovedOption, UnexpectedArgument, SeveralIds, IdGivenTwice, BadOption, RegistryUnanswered, NotServed, BadRequest, PageNotShipped, PageStopped;
@@ -10580,8 +10580,8 @@ var init_catalog = __esmMin((() => {
10580
10580
  {
10581
10581
  name: "layer",
10582
10582
  required: false,
10583
- value: "number",
10584
- about: "Mark the file read in this layer only, counting from 1, when more than one layer claims it"
10583
+ value: "address",
10584
+ about: "Mark the file read in this layer only, when more than one layer claims it: a layer's number counting from 1, or a sublayer's address such as 2.2"
10585
10585
  },
10586
10586
  {
10587
10587
  name: "blob",
@@ -10761,7 +10761,7 @@ var init_catalog = __esmMin((() => {
10761
10761
  name: "file",
10762
10762
  required: true,
10763
10763
  value: "path|-",
10764
- about: "The document, as a file path or - to read stdin: {\"summary\":\"…\",\"layers\":[{\"title\":\"…\",\"note\":\"…\",\"spans\":[{\"path\":\"…\",\"start\":1,\"end\":9}]}]}. A layer may carry blocks instead of spans, interleaving {\"kind\":\"prose\",\"markdown\":\"…\"} with {\"kind\":\"code\",\"path\":\"…\",\"start\":1,\"end\":9}"
10764
+ about: "The document, as a file path or - to read stdin: {\"summary\":\"…\",\"layers\":[{\"title\":\"…\",\"note\":\"…\",\"spans\":[{\"path\":\"…\",\"start\":1,\"end\":9}]}]}. A layer may carry blocks instead of spans, interleaving {\"kind\":\"prose\",\"markdown\":\"…\"} with {\"kind\":\"code\",\"path\":\"…\",\"start\":1,\"end\":9}. A layer may hold sublayers instead of code: {\"title\":\"…\",\"note\":\"…\",\"layers\":[…]} with two or more layers inside, each with its own spans or blocks and no layers of its own"
10765
10765
  }],
10766
10766
  dataKey: "layers",
10767
10767
  example: "adiff layers set --file -"
@@ -11331,7 +11331,7 @@ var init_catalog = __esmMin((() => {
11331
11331
  }));
11332
11332
  //#endregion
11333
11333
  //#region src/cli/parse.ts
11334
- var Piped, fromStdin, FLAG, REPEATED, repeats, MANY, withValue, flagOn, tokenOn, takenFrom, optionsFrom, bareIn, onlyKnown, oneOf, required$1, STDIN, text$1, numeric, SPOT, spot, WHOLE$1, around$1, seconds, many, CHOICES_FEWEST, CHOICES_MOST, choices, oneLine;
11334
+ var Piped, fromStdin, FLAG, REPEATED, repeats, MANY, withValue, flagOn, tokenOn, takenFrom, optionsFrom, bareIn, onlyKnown, oneOf, required$1, STDIN, text$1, numeric, LAYER_ADDRESS, layerAddress, SPOT, spot, WHOLE$2, around$1, seconds, many, CHOICES_FEWEST, CHOICES_MOST, choices, oneLine;
11335
11335
  var init_parse$1 = __esmMin((() => {
11336
11336
  init_dist();
11337
11337
  init_catalog();
@@ -11438,6 +11438,15 @@ var init_parse$1 = __esmMin((() => {
11438
11438
  allowed: ["a whole number of 1 or more"]
11439
11439
  });
11440
11440
  });
11441
+ LAYER_ADDRESS = /^[1-9]\d*(?:\.[1-9]\d*)?$/;
11442
+ layerAddress = fn("Cli.layerAddress")(function* (options, name) {
11443
+ const raw = yield* required$1(options, name);
11444
+ return yield* LAYER_ADDRESS.test(raw) ? succeed$1(raw) : new BadOption({
11445
+ option: name,
11446
+ given: raw,
11447
+ allowed: ["a layer's number, such as 2", "a sublayer's address, such as 2.2"]
11448
+ });
11449
+ });
11441
11450
  SPOT = /^(?<side>new|old):(?<line>[1-9]\d*)$/;
11442
11451
  spot = fn("Cli.spot")(function* (options, name) {
11443
11452
  const raw = yield* required$1(options, name);
@@ -11452,16 +11461,16 @@ var init_parse$1 = __esmMin((() => {
11452
11461
  line: Number(found["line"])
11453
11462
  });
11454
11463
  });
11455
- WHOLE$1 = "all";
11464
+ WHOLE$2 = "all";
11456
11465
  around$1 = fn("Cli.around")(function* (options, name) {
11457
11466
  const raw = options[name];
11458
11467
  if (raw === void 0) return void 0;
11459
- if (raw === WHOLE$1) return WHOLE$1;
11468
+ if (raw === WHOLE$2) return WHOLE$2;
11460
11469
  const parsed = Number(raw);
11461
11470
  return yield* Number.isInteger(parsed) && parsed >= 0 ? succeed$1(parsed) : new BadOption({
11462
11471
  option: name,
11463
11472
  given: raw,
11464
- allowed: ["a whole number of 0 or more", WHOLE$1]
11473
+ allowed: ["a whole number of 0 or more", WHOLE$2]
11465
11474
  });
11466
11475
  });
11467
11476
  seconds = fn("Cli.seconds")(function* (options, name) {
@@ -11542,7 +11551,7 @@ var init_report$1 = __esmMin((() => {
11542
11551
  },
11543
11552
  MalformedLayers: {
11544
11553
  exit: 2,
11545
- suggestion: "A layers is {\"summary\":\"…\",\"layers\":[{\"title\":\"…\",\"spans\":[{\"path\":\"…\",\"start\":1,\"end\":9}]}]}.",
11554
+ suggestion: "A layers is {\"summary\":\"…\",\"layers\":[{\"title\":\"…\",\"spans\":[{\"path\":\"…\",\"start\":1,\"end\":9}]}]}. A layer may hold two or more sublayers in \"layers\" in place of its spans.",
11546
11555
  retriable: false
11547
11556
  },
11548
11557
  NoLayers: {
@@ -11552,7 +11561,12 @@ var init_report$1 = __esmMin((() => {
11552
11561
  },
11553
11562
  UnknownLayer: {
11554
11563
  exit: 3,
11555
- suggestion: "No layer carries that number. `adiff layers show` lists them, counting from 1.",
11564
+ suggestion: "No layer carries that address. `adiff layers show` gives every layer its `address`: a number counting from 1, or 2.1 for the first sublayer of layer 2.",
11565
+ retriable: false
11566
+ },
11567
+ LayerIsTicket: {
11568
+ exit: 2,
11569
+ suggestion: "That number names a layer that holds sublayers, and a file is marked read in one of them. Pass the address of a sublayer the error lists.",
11556
11570
  retriable: false
11557
11571
  },
11558
11572
  NoPull: {
@@ -11952,7 +11966,7 @@ var init_serve = __esmMin((() => {
11952
11966
  }));
11953
11967
  //#endregion
11954
11968
  //#region src/cli/web.ts
11955
- var DEFAULT_PORT, HIGHEST_PORT, LOCAL, EVERY_ADDRESS, KNOCK_MS, START_MS, KILL_MS, WHOLE, portOf, entryIn, foldersBeside, entryOf, spaced, compiled$3, thisAdiff, withDefault, envFor, knockedAt, lastLineOf, listening, free, interruptible, startPage, pageEnded;
11969
+ var DEFAULT_PORT, HIGHEST_PORT, LOCAL, EVERY_ADDRESS, KNOCK_MS, START_MS, KILL_MS, WHOLE$1, portOf, entryIn, foldersBeside, entryOf, spaced, compiled$3, thisAdiff, withDefault, envFor, knockedAt, lastLineOf, listening, free, interruptible, startPage, pageEnded;
11956
11970
  var init_web = __esmMin((() => {
11957
11971
  init_dist();
11958
11972
  init_config();
@@ -11965,11 +11979,11 @@ var init_web = __esmMin((() => {
11965
11979
  KNOCK_MS = 100;
11966
11980
  START_MS = 3e4;
11967
11981
  KILL_MS = 3e3;
11968
- WHOLE = /^\d+$/;
11982
+ WHOLE$1 = /^\d+$/;
11969
11983
  portOf = (named) => {
11970
11984
  const given = getOrElse(named, () => String(DEFAULT_PORT));
11971
11985
  const port = Number(given);
11972
- return WHOLE.test(given) && port >= 1 && port <= HIGHEST_PORT ? succeed$1(port) : fail(new BadOption({
11986
+ return WHOLE$1.test(given) && port >= 1 && port <= HIGHEST_PORT ? succeed$1(port) : fail(new BadOption({
11973
11987
  option: "PORT",
11974
11988
  given,
11975
11989
  allowed: ["a whole number from 1 to 65535"]
@@ -13116,7 +13130,7 @@ var init_model$4 = __esmMin((() => {
13116
13130
  }));
13117
13131
  //#endregion
13118
13132
  //#region src/service/store/schema.ts
13119
- var Side, Anchor, StoredComment, StoredDraft, Drafts, StoredAnswer, Batch, Stamps, Counts, Doing, noStamps, BranchState, StoredSaid, StoredRemark, StoredRemarks, Settings, Watching, Listening, UpgradeCheck, Prose, Code$1, Split, StoredLayer, StoredLayers;
13133
+ var Side, Anchor, StoredComment, StoredDraft, Drafts, StoredAnswer, Batch, Stamps, Counts, Doing, noStamps, BranchState, StoredSaid, StoredRemark, StoredRemarks, Settings, Watching, Listening, UpgradeCheck, Prose, Code$1, Split, StoredLayer, StoredTicket, StoredLayers;
13120
13134
  var init_schema = __esmMin((() => {
13121
13135
  init_dist();
13122
13136
  Side = Literals(["old", "new"]);
@@ -13254,6 +13268,12 @@ var init_schema = __esmMin((() => {
13254
13268
  title: String$1,
13255
13269
  blocks: ArraySchema(Union([Prose, Code$1]))
13256
13270
  });
13271
+ StoredTicket = Struct({
13272
+ title: String$1,
13273
+ note: String$1,
13274
+ first: Int,
13275
+ count: Int
13276
+ });
13257
13277
  StoredLayers = Struct({
13258
13278
  version: Int,
13259
13279
  head: String$1,
@@ -13262,6 +13282,7 @@ var init_schema = __esmMin((() => {
13262
13282
  written: String$1,
13263
13283
  summary: String$1,
13264
13284
  layers: ArraySchema(StoredLayer),
13285
+ tickets: optionalKey(ArraySchema(StoredTicket)),
13265
13286
  blobs: optionalKey(Record(String$1, String$1)),
13266
13287
  split: optionalKey(ArraySchema(Split))
13267
13288
  });
@@ -13780,7 +13801,7 @@ var init_store = __esmMin((() => {
13780
13801
  }));
13781
13802
  //#endregion
13782
13803
  //#region src/review/error.ts
13783
- var UnknownBranch, BranchMoved, UnknownBase, UnknownFile, NotVouched, VouchedVersionGone, UnknownComment, AmbiguousId, UnknownRemark, NothingSaid, ThreadOpen, RemarkTaken, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownWorktree, MalformedLayers, UnknownDraft, NothingDrafted, PartlySent, PullMoved, NoLayers, NoPull, UnknownLayer;
13804
+ var UnknownBranch, BranchMoved, UnknownBase, UnknownFile, NotVouched, VouchedVersionGone, UnknownComment, AmbiguousId, UnknownRemark, NothingSaid, ThreadOpen, RemarkTaken, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownWorktree, MalformedLayers, UnknownDraft, NothingDrafted, PartlySent, PullMoved, NoLayers, NoPull, UnknownLayer, LayerIsTicket;
13784
13805
  var init_error$3 = __esmMin((() => {
13785
13806
  init_dist();
13786
13807
  UnknownBranch = class extends TaggedError("UnknownBranch") {};
@@ -13807,6 +13828,397 @@ var init_error$3 = __esmMin((() => {
13807
13828
  NoLayers = class extends TaggedError("NoLayers") {};
13808
13829
  NoPull = class extends TaggedError("NoPull") {};
13809
13830
  UnknownLayer = class extends TaggedError("UnknownLayer") {};
13831
+ LayerIsTicket = class extends TaggedError("LayerIsTicket") {};
13832
+ }));
13833
+ //#endregion
13834
+ //#region src/domain/layers/model.ts
13835
+ var REMAINDER_TITLE;
13836
+ var init_model$3 = __esmMin((() => {
13837
+ REMAINDER_TITLE = "not in any layer";
13838
+ }));
13839
+ //#endregion
13840
+ //#region src/domain/layers/coverage.ts
13841
+ var codeBlockOf$1, codeBlocks, noteOf$1, spansOf$1, changedLines, NOTHING, reachesOf, claimsOf, reaching, claimedBy, claimedRow, claimedRows, linesClaimed, runsOf, tallyOf, changedHunks, coverage, sharedIn, sharedHunks, runsSaid, filesSaid, leftSaid, unordered, withFullCoverage, proseAnchors;
13842
+ var init_coverage = __esmMin((() => {
13843
+ init_dist();
13844
+ init_model$3();
13845
+ codeBlockOf$1 = (span) => ({
13846
+ kind: "code",
13847
+ path: span.path,
13848
+ start: span.start,
13849
+ end: span.end
13850
+ });
13851
+ codeBlocks = (layer) => layer.blocks.filter((block) => block.kind === "code");
13852
+ noteOf$1 = (layer) => layer.blocks.filter((block) => block.kind === "prose").map((block) => block.markdown.trim()).filter((markdown) => markdown.length > 0).join(" ");
13853
+ spansOf$1 = (layers) => layers.flatMap((layer) => codeBlocks(layer).map(({ path, start, end }) => ({
13854
+ path,
13855
+ start,
13856
+ end
13857
+ })));
13858
+ changedLines = (hunk) => hunk.rows.filter((row) => row.kind !== "context").flatMap((row) => match$3(orElse(row.newLine, () => row.oldLine), {
13859
+ onNone: () => [],
13860
+ onSome: (line) => [line]
13861
+ }));
13862
+ NOTHING = [];
13863
+ reachesOf = (spans) => {
13864
+ const reaches = [];
13865
+ const ordered = spans.filter((span) => span.start <= span.end).toSorted((a, b) => a.start - b.start);
13866
+ for (const span of ordered) {
13867
+ const open = reaches.at(-1);
13868
+ if (open !== void 0 && span.start <= open.end) open.end = Math.max(open.end, span.end);
13869
+ else reaches.push({
13870
+ start: span.start,
13871
+ end: span.end
13872
+ });
13873
+ }
13874
+ return reaches;
13875
+ };
13876
+ claimsOf = (spans) => {
13877
+ const byPath = /* @__PURE__ */ new Map();
13878
+ for (const span of spans) {
13879
+ const held = byPath.get(span.path);
13880
+ if (held === void 0) byPath.set(span.path, [span]);
13881
+ else held.push(span);
13882
+ }
13883
+ return new Map([...byPath].map(([path, held]) => [path, reachesOf(held)]));
13884
+ };
13885
+ reaching = (reaches, line) => {
13886
+ let low = 0;
13887
+ let high = reaches.length;
13888
+ while (low < high) {
13889
+ const middle = low + high >>> 1;
13890
+ const reach = reaches[middle];
13891
+ if (reach === void 0 || reach.start > line) high = middle;
13892
+ else low = middle + 1;
13893
+ }
13894
+ const last = reaches[low - 1];
13895
+ return last !== void 0 && last.end >= line;
13896
+ };
13897
+ claimedBy = (reaches, changed) => changed.some((line) => reaching(reaches, line));
13898
+ claimedRow = (reaches, row) => row.kind !== "context" && match$3(orElse(row.newLine, () => row.oldLine), {
13899
+ onNone: () => false,
13900
+ onSome: (line) => reaching(reaches, line)
13901
+ });
13902
+ claimedRows = (claims, patch) => {
13903
+ const reaches = claims.get(patch.path) ?? NOTHING;
13904
+ if (reaches.length === 0) return [];
13905
+ return patch.hunks.flatMap((hunk) => hunk.rows).filter((row) => claimedRow(reaches, row));
13906
+ };
13907
+ linesClaimed = (patches, layer) => {
13908
+ const claims = claimsOf(spansOf$1([layer]));
13909
+ const rows = patches.flatMap((patch) => claimedRows(claims, patch));
13910
+ return {
13911
+ added: rows.filter((row) => row.kind === "added").length,
13912
+ removed: rows.filter((row) => row.kind === "removed").length
13913
+ };
13914
+ };
13915
+ runsOf = (path, lines) => {
13916
+ const runs = [];
13917
+ for (const line of lines.toSorted((a, b) => a - b)) {
13918
+ const open = runs.at(-1);
13919
+ if (open !== void 0 && line <= open.end + 1) open.end = Math.max(open.end, line);
13920
+ else runs.push({
13921
+ path,
13922
+ start: line,
13923
+ end: line
13924
+ });
13925
+ }
13926
+ return runs;
13927
+ };
13928
+ tallyOf = (path, changed, reaches) => {
13929
+ const loose = changed.filter((line) => !reaching(reaches, line));
13930
+ const whole = changed.length > 0 && loose.length === 0;
13931
+ const some = loose.length > 0 && loose.length < changed.length;
13932
+ return {
13933
+ covered: whole ? 1 : 0,
13934
+ partial: some ? 1 : 0,
13935
+ missing: runsOf(path, loose)
13936
+ };
13937
+ };
13938
+ changedHunks = (patch) => patch.hunks.map(changedLines).filter((changed) => changed.length > 0);
13939
+ coverage = (patches, layers) => {
13940
+ const claims = claimsOf(spansOf$1(layers));
13941
+ const tallies = patches.flatMap((patch) => {
13942
+ const reaches = claims.get(patch.path) ?? NOTHING;
13943
+ return changedHunks(patch).map((changed) => tallyOf(patch.path, changed, reaches));
13944
+ });
13945
+ return {
13946
+ total: tallies.length,
13947
+ covered: tallies.reduce((sum, tally) => sum + tally.covered, 0),
13948
+ partial: tallies.reduce((sum, tally) => sum + tally.partial, 0),
13949
+ missing: tallies.flatMap((tally) => tally.missing)
13950
+ };
13951
+ };
13952
+ sharedIn = (patch, claims) => {
13953
+ const held = claims.flatMap((claim) => {
13954
+ const reaches = claim.get(patch.path);
13955
+ return reaches === void 0 ? [] : [reaches];
13956
+ });
13957
+ if (held.length < 2) return 0;
13958
+ return changedHunks(patch).filter((changed) => held.filter((reaches) => claimedBy(reaches, changed)).length > 1).length;
13959
+ };
13960
+ sharedHunks = (patches, layers) => {
13961
+ const claims = layers.map((layer) => claimsOf(spansOf$1([layer])));
13962
+ return patches.reduce((sum, patch) => sum + sharedIn(patch, claims), 0);
13963
+ };
13964
+ runsSaid = (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.`;
13965
+ filesSaid = (count) => count === 1 ? "One file the layers had no lines to order." : `${count} files the layers had no lines to order.`;
13966
+ leftSaid = (runs, files) => {
13967
+ if (runs > 0 && files > 0) return `${runsSaid(runs)} ${filesSaid(files)}`;
13968
+ if (runs > 0) return runsSaid(runs);
13969
+ return files > 0 ? filesSaid(files) : "";
13970
+ };
13971
+ unordered = (patches, layers, missing) => {
13972
+ const named = /* @__PURE__ */ new Set([...spansOf$1(layers).map((span) => span.path), ...missing.map((span) => span.path)]);
13973
+ return patches.filter((patch) => !named.has(patch.path)).map((patch) => ({
13974
+ path: patch.path,
13975
+ start: 1,
13976
+ end: 1
13977
+ }));
13978
+ };
13979
+ withFullCoverage = (patches, layers) => {
13980
+ const gap = coverage(patches, layers.layers);
13981
+ const left = unordered(patches, layers.layers, gap.missing);
13982
+ const spans = [...gap.missing, ...left];
13983
+ if (spans.length === 0) return layers;
13984
+ const said = leftSaid(gap.missing.length, left.length);
13985
+ const remainder = {
13986
+ title: REMAINDER_TITLE,
13987
+ blocks: [...said.length === 0 ? [] : [{
13988
+ kind: "prose",
13989
+ markdown: said
13990
+ }], ...spans.map((span) => codeBlockOf$1(span))]
13991
+ };
13992
+ return {
13993
+ ...layers,
13994
+ layers: [...layers.layers, remainder]
13995
+ };
13996
+ };
13997
+ proseAnchors = (layer) => {
13998
+ const anchors = [];
13999
+ let pending = [];
14000
+ let last;
14001
+ for (const block of layer.blocks) {
14002
+ if (block.kind === "prose") {
14003
+ const markdown = block.markdown.trim();
14004
+ if (markdown.length > 0) pending.push(markdown);
14005
+ continue;
14006
+ }
14007
+ for (const markdown of pending) anchors.push({
14008
+ path: block.path,
14009
+ line: block.start,
14010
+ markdown,
14011
+ after: false
14012
+ });
14013
+ pending = [];
14014
+ last = block;
14015
+ }
14016
+ if (last === void 0) return anchors;
14017
+ return [...anchors, ...pending.map((markdown) => ({
14018
+ path: last.path,
14019
+ line: last.end,
14020
+ markdown,
14021
+ after: true
14022
+ }))];
14023
+ };
14024
+ }));
14025
+ //#endregion
14026
+ //#region src/domain/layers/version.ts
14027
+ var statusOf;
14028
+ var init_version = __esmMin((() => {
14029
+ init_coverage();
14030
+ statusOf = (patches, layers, branchHead) => {
14031
+ const gap = coverage(patches, layers.layers);
14032
+ const present = new Set(patches.map((patch) => patch.path));
14033
+ const mentioned = new Set(spansOf$1(layers.layers).map((span) => span.path));
14034
+ return {
14035
+ version: layers.version,
14036
+ parent: layers.parent,
14037
+ stale: layers.head !== branchHead,
14038
+ layersHead: layers.head,
14039
+ branchHead,
14040
+ uncovered: gap.missing,
14041
+ vanished: [...mentioned].filter((path) => !present.has(path)),
14042
+ covered: gap.covered,
14043
+ partial: gap.partial,
14044
+ total: gap.total
14045
+ };
14046
+ };
14047
+ })), lineOf$3, quietRows, quietKey, holds, quietFor, quietLayers;
14048
+ var init_quiet = __esmMin((() => {
14049
+ init_dist();
14050
+ lineOf$3 = (row) => getOrUndefined$1(orElse(row.newLine, () => row.oldLine));
14051
+ quietRows = (hunk, mine) => {
14052
+ const quiet = /* @__PURE__ */ new Set();
14053
+ if (!hunk.rows.some((row) => row.kind !== "context" && mine(row))) return quiet;
14054
+ let run = [];
14055
+ const flush = () => {
14056
+ if (run.length < 8) for (const row of run) quiet.add(row);
14057
+ run = [];
14058
+ };
14059
+ for (const row of hunk.rows) if (row.kind === "context" || mine(row)) flush();
14060
+ else run.push(row);
14061
+ flush();
14062
+ return quiet;
14063
+ };
14064
+ quietKey = (kind, line) => `${kind}:${line}`;
14065
+ holds = (spans, path, row) => {
14066
+ const line = lineOf$3(row);
14067
+ return line !== void 0 && spans.some((span) => span.path === path && span.start <= line && span.end >= line);
14068
+ };
14069
+ quietFor = (patch, spans) => patch.hunks.flatMap((hunk) => [...quietRows(hunk, (row) => holds(spans, patch.path, row))]);
14070
+ quietLayers = (patch, layers) => {
14071
+ const found = /* @__PURE__ */ new Map();
14072
+ for (const [at, spans] of layers.entries()) for (const row of quietFor(patch, spans)) {
14073
+ const line = lineOf$3(row);
14074
+ if (line === void 0) continue;
14075
+ const key = quietKey(row.kind, line);
14076
+ found.set(key, [...found.get(key) ?? [], at + 1]);
14077
+ }
14078
+ return found;
14079
+ };
14080
+ }));
14081
+ //#endregion
14082
+ //#region src/domain/layers/text.ts
14083
+ var OFFSET, PRIME, hashOf, textOf, stamped, outdatedSpans;
14084
+ var init_text = __esmMin((() => {
14085
+ OFFSET = 2166136261;
14086
+ PRIME = 16777619;
14087
+ hashOf = (text) => {
14088
+ let hash = OFFSET;
14089
+ for (const unit of text) hash = Math.imul(hash ^ (unit.codePointAt(0) ?? 0), PRIME);
14090
+ return (hash >>> 0).toString(16).padStart(8, "0");
14091
+ };
14092
+ textOf = (lines, start, end) => hashOf(lines.slice(start - 1, end).join("\n"));
14093
+ stamped = (layers, sources) => layers.map((layer) => ({
14094
+ ...layer,
14095
+ blocks: layer.blocks.map((block) => block.kind === "code" ? {
14096
+ ...block,
14097
+ text: textOf(sources.get(block.path) ?? [], block.start, block.end)
14098
+ } : block)
14099
+ }));
14100
+ outdatedSpans = (layers, sources) => layers.flatMap((layer, at) => layer.blocks.flatMap((block) => {
14101
+ if (block.kind !== "code" || block.text === void 0) return [];
14102
+ const lines = sources.get(block.path);
14103
+ if (lines === void 0 || textOf(lines, block.start, block.end) === block.text) return [];
14104
+ return [{
14105
+ layer: at + 1,
14106
+ path: block.path,
14107
+ start: block.start,
14108
+ end: block.end
14109
+ }];
14110
+ }));
14111
+ }));
14112
+ //#endregion
14113
+ //#region src/domain/layers/split.ts
14114
+ var addedLines, claimsAny, sharedPaths, splitsIn;
14115
+ var init_split = __esmMin((() => {
14116
+ init_dist();
14117
+ init_coverage();
14118
+ addedLines = (patch) => patch.rows.filter((row) => row.kind === "added").flatMap((row) => toArray(row.newLine));
14119
+ claimsAny = (layer, path, lines) => codeBlocks(layer).some((block) => block.path === path && lines.some((line) => line >= block.start && line <= block.end));
14120
+ sharedPaths = (layers) => {
14121
+ const claimed = layers.flatMap((layer) => [...new Set(codeBlocks(layer).map((block) => block.path))]);
14122
+ return [...new Set(claimed.filter((path, at) => claimed.indexOf(path) !== at))];
14123
+ };
14124
+ splitsIn = (layers, patch, declarations) => {
14125
+ const added = addedLines(patch);
14126
+ return declarations.flatMap((declaration) => {
14127
+ const inside = added.filter((line) => line >= declaration.start && line <= declaration.end);
14128
+ const holding = layers.flatMap((layer, at) => claimsAny(layer, patch.path, inside) ? [at + 1] : []);
14129
+ return holding.length > 1 ? [{
14130
+ path: patch.path,
14131
+ ...declaration,
14132
+ layers: holding
14133
+ }] : [];
14134
+ });
14135
+ };
14136
+ }));
14137
+ //#endregion
14138
+ //#region src/domain/layers/nesting.ts
14139
+ var under$2, placesOf, ticketNumber;
14140
+ var init_nesting = __esmMin((() => {
14141
+ under$2 = (number, ticket) => Array.from({ length: ticket.count }, (_, at) => ({
14142
+ address: `${number}.${at + 1}`,
14143
+ number,
14144
+ sublayer: at + 1
14145
+ }));
14146
+ placesOf = (count, tickets) => {
14147
+ const places = [];
14148
+ let number = 0;
14149
+ while (places.length < count) {
14150
+ number += 1;
14151
+ const ticket = tickets.find((one) => one.first === places.length && one.count > 0);
14152
+ if (ticket === void 0) places.push({
14153
+ address: String(number),
14154
+ number
14155
+ });
14156
+ else places.push(...under$2(number, ticket));
14157
+ }
14158
+ return places.slice(0, count);
14159
+ };
14160
+ ticketNumber = (places, ticket) => places[ticket.first]?.number ?? 0;
14161
+ }));
14162
+ //#endregion
14163
+ //#region src/domain/layers/index.ts
14164
+ var init_layers$1 = __esmMin((() => {
14165
+ init_coverage();
14166
+ init_version();
14167
+ init_quiet();
14168
+ init_model$3();
14169
+ init_text();
14170
+ init_split();
14171
+ init_nesting();
14172
+ }));
14173
+ //#endregion
14174
+ //#region src/review/tickets.ts
14175
+ var unique$2, positionsOf, under$1, holdsAny$1, sum, rolled$1, ticketsOf, topLevelOf, readThroughout, ticketsRead;
14176
+ var init_tickets$1 = __esmMin((() => {
14177
+ init_layers$1();
14178
+ unique$2 = (paths) => [...new Set(paths)];
14179
+ positionsOf = (ticket) => Array.from({ length: ticket.count }, (_, at) => ticket.first + at + 1);
14180
+ under$1 = (positions, layers) => layers.filter((_, at) => positions.includes(at + 1));
14181
+ holdsAny$1 = (positions, layers) => layers.some((layer) => positions.includes(layer));
14182
+ sum = (counts) => counts.reduce((total, count) => total + count, 0);
14183
+ rolled$1 = (told, ticket, number) => {
14184
+ const positions = positionsOf(ticket);
14185
+ const held = under$1(positions, told.reported);
14186
+ const gap = coverage(told.patches, under$1(positions, told.layers.layers));
14187
+ const outdated = told.outdated.filter((span) => positions.includes(span.layer));
14188
+ return {
14189
+ number,
14190
+ address: String(number),
14191
+ title: ticket.title,
14192
+ note: ticket.note,
14193
+ layers: positions,
14194
+ sublayers: positions.length,
14195
+ files: unique$2(held.flatMap((one) => one.files)),
14196
+ added: sum(held.map((one) => one.added)),
14197
+ removed: sum(held.map((one) => one.removed)),
14198
+ covered: gap.covered,
14199
+ partial: gap.partial,
14200
+ vanished: unique$2(held.flatMap((one) => one.vanished)),
14201
+ outdated,
14202
+ split: (told.layers.split ?? []).filter((one) => holdsAny$1(positions, one.layers)),
14203
+ stale: outdated.length > 0
14204
+ };
14205
+ };
14206
+ ticketsOf = (told) => {
14207
+ const tickets = told.layers.tickets ?? [];
14208
+ const places = placesOf(told.layers.layers.length, tickets);
14209
+ return tickets.map((ticket) => rolled$1(told, ticket, ticketNumber(places, ticket)));
14210
+ };
14211
+ topLevelOf = (layers) => placesOf(layers.layers.length, layers.tickets ?? []).at(-1)?.number ?? 0;
14212
+ readThroughout = (held, path) => held.every((one) => !one.files.includes(path) || one.read?.includes(path) === true);
14213
+ ticketsRead = (tickets, layers) => tickets.map((ticket) => {
14214
+ const held = under$1(ticket.layers, layers);
14215
+ const done = held.filter((one) => one.done === true).length;
14216
+ return Object.assign({}, ticket, {
14217
+ read: ticket.files.filter((path) => readThroughout(held, path)),
14218
+ done: done === held.length,
14219
+ sublayersDone: done
14220
+ });
14221
+ });
13810
14222
  })), realOf, AUTO, askedFor$1, basedOn, named$3, SHORT, onNow, stillOn, find, basedAt, worktreeAt, patches, reading, waitingOn, summaryOf, summary, list$5, markOpened, lastOpened, repoOf, nameAt, saveReport, refs, forOne, recentBases, setBase, clearBase;
13811
14223
  var init_branches$1 = __esmMin((() => {
13812
14224
  init_dist();
@@ -13814,6 +14226,7 @@ var init_branches$1 = __esmMin((() => {
13814
14226
  init_git();
13815
14227
  init_store();
13816
14228
  init_error$3();
14229
+ init_tickets$1();
13817
14230
  realOf = (worktree) => tryPromise({
13818
14231
  try: () => realpath(worktree),
13819
14232
  catch: () => new UnknownWorktree({
@@ -13936,7 +14349,7 @@ var init_branches$1 = __esmMin((() => {
13936
14349
  unanswered: owed.reduce((total, batch) => total + batch.comments.length, 0),
13937
14350
  layers: match$3(told, {
13938
14351
  onNone: () => 0,
13939
- onSome: (layers) => layers.layers.length
14352
+ onSome: topLevelOf
13940
14353
  }),
13941
14354
  stale: match$3(told, {
13942
14355
  onNone: () => false,
@@ -14043,7 +14456,7 @@ var init_branches$1 = __esmMin((() => {
14043
14456
  }));
14044
14457
  //#endregion
14045
14458
  //#region src/review/patches.ts
14046
- var findPatch, blobOf, wholeFile, rowAt, picked, anchorWith, anchor$1, list$4, source, before, linesAround, GENERATED_NAME, lineOf$3, isNote$1, shownRow, shownHunk, scopesOf, shownFile, sourceShown, fileShown$1, shownAs, onDisk$2, show$3;
14459
+ var findPatch, blobOf, wholeFile, rowAt, picked, anchorWith, anchor$1, list$4, source, before, linesAround, GENERATED_NAME, lineOf$2, isNote$1, shownRow, shownHunk, scopesOf, shownFile, sourceShown, fileShown$1, shownAs, onDisk$2, show$3;
14047
14460
  var init_patches = __esmMin((() => {
14048
14461
  init_dist();
14049
14462
  init_patch();
@@ -14116,7 +14529,7 @@ var init_patches = __esmMin((() => {
14116
14529
  return context ?? 3;
14117
14530
  };
14118
14531
  GENERATED_NAME = /\.generated\./;
14119
- lineOf$3 = (side, line) => match$3(line, {
14532
+ lineOf$2 = (side, line) => match$3(line, {
14120
14533
  onNone: () => ({}),
14121
14534
  onSome: (at) => ({ [side]: at })
14122
14535
  });
@@ -14126,8 +14539,8 @@ var init_patches = __esmMin((() => {
14126
14539
  text: row.text
14127
14540
  } : {
14128
14541
  kind: row.kind,
14129
- ...lineOf$3("old", row.oldLine),
14130
- ...lineOf$3("new", row.newLine),
14542
+ ...lineOf$2("old", row.oldLine),
14543
+ ...lineOf$2("new", row.newLine),
14131
14544
  text: row.text
14132
14545
  };
14133
14546
  shownHunk = (hunk) => ({
@@ -14176,320 +14589,6 @@ var init_patches = __esmMin((() => {
14176
14589
  });
14177
14590
  }));
14178
14591
  //#endregion
14179
- //#region src/domain/layers/model.ts
14180
- var REMAINDER_TITLE;
14181
- var init_model$3 = __esmMin((() => {
14182
- REMAINDER_TITLE = "not in any layer";
14183
- }));
14184
- //#endregion
14185
- //#region src/domain/layers/coverage.ts
14186
- var codeBlockOf$1, codeBlocks, noteOf, spansOf$1, changedLines, NOTHING, reachesOf, claimsOf, reaching, claimedBy, claimedRow, claimedRows, linesClaimed, runsOf, tallyOf, changedHunks, coverage, sharedIn, sharedHunks, runsSaid, filesSaid, leftSaid, unordered, withFullCoverage, proseAnchors;
14187
- var init_coverage = __esmMin((() => {
14188
- init_dist();
14189
- init_model$3();
14190
- codeBlockOf$1 = (span) => ({
14191
- kind: "code",
14192
- path: span.path,
14193
- start: span.start,
14194
- end: span.end
14195
- });
14196
- codeBlocks = (layer) => layer.blocks.filter((block) => block.kind === "code");
14197
- noteOf = (layer) => layer.blocks.filter((block) => block.kind === "prose").map((block) => block.markdown.trim()).filter((markdown) => markdown.length > 0).join(" ");
14198
- spansOf$1 = (layers) => layers.flatMap((layer) => codeBlocks(layer).map(({ path, start, end }) => ({
14199
- path,
14200
- start,
14201
- end
14202
- })));
14203
- changedLines = (hunk) => hunk.rows.filter((row) => row.kind !== "context").flatMap((row) => match$3(orElse(row.newLine, () => row.oldLine), {
14204
- onNone: () => [],
14205
- onSome: (line) => [line]
14206
- }));
14207
- NOTHING = [];
14208
- reachesOf = (spans) => {
14209
- const reaches = [];
14210
- const ordered = spans.filter((span) => span.start <= span.end).toSorted((a, b) => a.start - b.start);
14211
- for (const span of ordered) {
14212
- const open = reaches.at(-1);
14213
- if (open !== void 0 && span.start <= open.end) open.end = Math.max(open.end, span.end);
14214
- else reaches.push({
14215
- start: span.start,
14216
- end: span.end
14217
- });
14218
- }
14219
- return reaches;
14220
- };
14221
- claimsOf = (spans) => {
14222
- const byPath = /* @__PURE__ */ new Map();
14223
- for (const span of spans) {
14224
- const held = byPath.get(span.path);
14225
- if (held === void 0) byPath.set(span.path, [span]);
14226
- else held.push(span);
14227
- }
14228
- return new Map([...byPath].map(([path, held]) => [path, reachesOf(held)]));
14229
- };
14230
- reaching = (reaches, line) => {
14231
- let low = 0;
14232
- let high = reaches.length;
14233
- while (low < high) {
14234
- const middle = low + high >>> 1;
14235
- const reach = reaches[middle];
14236
- if (reach === void 0 || reach.start > line) high = middle;
14237
- else low = middle + 1;
14238
- }
14239
- const last = reaches[low - 1];
14240
- return last !== void 0 && last.end >= line;
14241
- };
14242
- claimedBy = (reaches, changed) => changed.some((line) => reaching(reaches, line));
14243
- claimedRow = (reaches, row) => row.kind !== "context" && match$3(orElse(row.newLine, () => row.oldLine), {
14244
- onNone: () => false,
14245
- onSome: (line) => reaching(reaches, line)
14246
- });
14247
- claimedRows = (claims, patch) => {
14248
- const reaches = claims.get(patch.path) ?? NOTHING;
14249
- if (reaches.length === 0) return [];
14250
- return patch.hunks.flatMap((hunk) => hunk.rows).filter((row) => claimedRow(reaches, row));
14251
- };
14252
- linesClaimed = (patches, layer) => {
14253
- const claims = claimsOf(spansOf$1([layer]));
14254
- const rows = patches.flatMap((patch) => claimedRows(claims, patch));
14255
- return {
14256
- added: rows.filter((row) => row.kind === "added").length,
14257
- removed: rows.filter((row) => row.kind === "removed").length
14258
- };
14259
- };
14260
- runsOf = (path, lines) => {
14261
- const runs = [];
14262
- for (const line of lines.toSorted((a, b) => a - b)) {
14263
- const open = runs.at(-1);
14264
- if (open !== void 0 && line <= open.end + 1) open.end = Math.max(open.end, line);
14265
- else runs.push({
14266
- path,
14267
- start: line,
14268
- end: line
14269
- });
14270
- }
14271
- return runs;
14272
- };
14273
- tallyOf = (path, changed, reaches) => {
14274
- const loose = changed.filter((line) => !reaching(reaches, line));
14275
- const whole = changed.length > 0 && loose.length === 0;
14276
- const some = loose.length > 0 && loose.length < changed.length;
14277
- return {
14278
- covered: whole ? 1 : 0,
14279
- partial: some ? 1 : 0,
14280
- missing: runsOf(path, loose)
14281
- };
14282
- };
14283
- changedHunks = (patch) => patch.hunks.map(changedLines).filter((changed) => changed.length > 0);
14284
- coverage = (patches, layers) => {
14285
- const claims = claimsOf(spansOf$1(layers));
14286
- const tallies = patches.flatMap((patch) => {
14287
- const reaches = claims.get(patch.path) ?? NOTHING;
14288
- return changedHunks(patch).map((changed) => tallyOf(patch.path, changed, reaches));
14289
- });
14290
- return {
14291
- total: tallies.length,
14292
- covered: tallies.reduce((sum, tally) => sum + tally.covered, 0),
14293
- partial: tallies.reduce((sum, tally) => sum + tally.partial, 0),
14294
- missing: tallies.flatMap((tally) => tally.missing)
14295
- };
14296
- };
14297
- sharedIn = (patch, claims) => {
14298
- const held = claims.flatMap((claim) => {
14299
- const reaches = claim.get(patch.path);
14300
- return reaches === void 0 ? [] : [reaches];
14301
- });
14302
- if (held.length < 2) return 0;
14303
- return changedHunks(patch).filter((changed) => held.filter((reaches) => claimedBy(reaches, changed)).length > 1).length;
14304
- };
14305
- sharedHunks = (patches, layers) => {
14306
- const claims = layers.map((layer) => claimsOf(spansOf$1([layer])));
14307
- return patches.reduce((sum, patch) => sum + sharedIn(patch, claims), 0);
14308
- };
14309
- runsSaid = (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.`;
14310
- filesSaid = (count) => count === 1 ? "One file the layers had no lines to order." : `${count} files the layers had no lines to order.`;
14311
- leftSaid = (runs, files) => {
14312
- if (runs > 0 && files > 0) return `${runsSaid(runs)} ${filesSaid(files)}`;
14313
- if (runs > 0) return runsSaid(runs);
14314
- return files > 0 ? filesSaid(files) : "";
14315
- };
14316
- unordered = (patches, layers, missing) => {
14317
- const named = /* @__PURE__ */ new Set([...spansOf$1(layers).map((span) => span.path), ...missing.map((span) => span.path)]);
14318
- return patches.filter((patch) => !named.has(patch.path)).map((patch) => ({
14319
- path: patch.path,
14320
- start: 1,
14321
- end: 1
14322
- }));
14323
- };
14324
- withFullCoverage = (patches, layers) => {
14325
- const gap = coverage(patches, layers.layers);
14326
- const left = unordered(patches, layers.layers, gap.missing);
14327
- const spans = [...gap.missing, ...left];
14328
- if (spans.length === 0) return layers;
14329
- const said = leftSaid(gap.missing.length, left.length);
14330
- const remainder = {
14331
- title: REMAINDER_TITLE,
14332
- blocks: [...said.length === 0 ? [] : [{
14333
- kind: "prose",
14334
- markdown: said
14335
- }], ...spans.map((span) => codeBlockOf$1(span))]
14336
- };
14337
- return {
14338
- ...layers,
14339
- layers: [...layers.layers, remainder]
14340
- };
14341
- };
14342
- proseAnchors = (layer) => {
14343
- const anchors = [];
14344
- let pending = [];
14345
- let last;
14346
- for (const block of layer.blocks) {
14347
- if (block.kind === "prose") {
14348
- const markdown = block.markdown.trim();
14349
- if (markdown.length > 0) pending.push(markdown);
14350
- continue;
14351
- }
14352
- for (const markdown of pending) anchors.push({
14353
- path: block.path,
14354
- line: block.start,
14355
- markdown,
14356
- after: false
14357
- });
14358
- pending = [];
14359
- last = block;
14360
- }
14361
- if (last === void 0) return anchors;
14362
- return [...anchors, ...pending.map((markdown) => ({
14363
- path: last.path,
14364
- line: last.end,
14365
- markdown,
14366
- after: true
14367
- }))];
14368
- };
14369
- }));
14370
- //#endregion
14371
- //#region src/domain/layers/version.ts
14372
- var statusOf;
14373
- var init_version = __esmMin((() => {
14374
- init_coverage();
14375
- statusOf = (patches, layers, branchHead) => {
14376
- const gap = coverage(patches, layers.layers);
14377
- const present = new Set(patches.map((patch) => patch.path));
14378
- const mentioned = new Set(spansOf$1(layers.layers).map((span) => span.path));
14379
- return {
14380
- version: layers.version,
14381
- parent: layers.parent,
14382
- stale: layers.head !== branchHead,
14383
- layersHead: layers.head,
14384
- branchHead,
14385
- uncovered: gap.missing,
14386
- vanished: [...mentioned].filter((path) => !present.has(path)),
14387
- covered: gap.covered,
14388
- partial: gap.partial,
14389
- total: gap.total
14390
- };
14391
- };
14392
- })), lineOf$2, quietRows, quietKey, holds, quietFor, quietLayers;
14393
- var init_quiet = __esmMin((() => {
14394
- init_dist();
14395
- lineOf$2 = (row) => getOrUndefined$1(orElse(row.newLine, () => row.oldLine));
14396
- quietRows = (hunk, mine) => {
14397
- const quiet = /* @__PURE__ */ new Set();
14398
- if (!hunk.rows.some((row) => row.kind !== "context" && mine(row))) return quiet;
14399
- let run = [];
14400
- const flush = () => {
14401
- if (run.length < 8) for (const row of run) quiet.add(row);
14402
- run = [];
14403
- };
14404
- for (const row of hunk.rows) if (row.kind === "context" || mine(row)) flush();
14405
- else run.push(row);
14406
- flush();
14407
- return quiet;
14408
- };
14409
- quietKey = (kind, line) => `${kind}:${line}`;
14410
- holds = (spans, path, row) => {
14411
- const line = lineOf$2(row);
14412
- return line !== void 0 && spans.some((span) => span.path === path && span.start <= line && span.end >= line);
14413
- };
14414
- quietFor = (patch, spans) => patch.hunks.flatMap((hunk) => [...quietRows(hunk, (row) => holds(spans, patch.path, row))]);
14415
- quietLayers = (patch, layers) => {
14416
- const found = /* @__PURE__ */ new Map();
14417
- for (const [at, spans] of layers.entries()) for (const row of quietFor(patch, spans)) {
14418
- const line = lineOf$2(row);
14419
- if (line === void 0) continue;
14420
- const key = quietKey(row.kind, line);
14421
- found.set(key, [...found.get(key) ?? [], at + 1]);
14422
- }
14423
- return found;
14424
- };
14425
- }));
14426
- //#endregion
14427
- //#region src/domain/layers/text.ts
14428
- var OFFSET, PRIME, hashOf, textOf, stamped, outdatedSpans;
14429
- var init_text = __esmMin((() => {
14430
- OFFSET = 2166136261;
14431
- PRIME = 16777619;
14432
- hashOf = (text) => {
14433
- let hash = OFFSET;
14434
- for (const unit of text) hash = Math.imul(hash ^ (unit.codePointAt(0) ?? 0), PRIME);
14435
- return (hash >>> 0).toString(16).padStart(8, "0");
14436
- };
14437
- textOf = (lines, start, end) => hashOf(lines.slice(start - 1, end).join("\n"));
14438
- stamped = (layers, sources) => layers.map((layer) => ({
14439
- ...layer,
14440
- blocks: layer.blocks.map((block) => block.kind === "code" ? {
14441
- ...block,
14442
- text: textOf(sources.get(block.path) ?? [], block.start, block.end)
14443
- } : block)
14444
- }));
14445
- outdatedSpans = (layers, sources) => layers.flatMap((layer, at) => layer.blocks.flatMap((block) => {
14446
- if (block.kind !== "code" || block.text === void 0) return [];
14447
- const lines = sources.get(block.path);
14448
- if (lines === void 0 || textOf(lines, block.start, block.end) === block.text) return [];
14449
- return [{
14450
- layer: at + 1,
14451
- path: block.path,
14452
- start: block.start,
14453
- end: block.end
14454
- }];
14455
- }));
14456
- }));
14457
- //#endregion
14458
- //#region src/domain/layers/split.ts
14459
- var addedLines, claimsAny, sharedPaths, splitsIn;
14460
- var init_split = __esmMin((() => {
14461
- init_dist();
14462
- init_coverage();
14463
- addedLines = (patch) => patch.rows.filter((row) => row.kind === "added").flatMap((row) => toArray(row.newLine));
14464
- claimsAny = (layer, path, lines) => codeBlocks(layer).some((block) => block.path === path && lines.some((line) => line >= block.start && line <= block.end));
14465
- sharedPaths = (layers) => {
14466
- const claimed = layers.flatMap((layer) => [...new Set(codeBlocks(layer).map((block) => block.path))]);
14467
- return [...new Set(claimed.filter((path, at) => claimed.indexOf(path) !== at))];
14468
- };
14469
- splitsIn = (layers, patch, declarations) => {
14470
- const added = addedLines(patch);
14471
- return declarations.flatMap((declaration) => {
14472
- const inside = added.filter((line) => line >= declaration.start && line <= declaration.end);
14473
- const holding = layers.flatMap((layer, at) => claimsAny(layer, patch.path, inside) ? [at + 1] : []);
14474
- return holding.length > 1 ? [{
14475
- path: patch.path,
14476
- ...declaration,
14477
- layers: holding
14478
- }] : [];
14479
- });
14480
- };
14481
- }));
14482
- //#endregion
14483
- //#region src/domain/layers/index.ts
14484
- var init_layers$1 = __esmMin((() => {
14485
- init_coverage();
14486
- init_version();
14487
- init_quiet();
14488
- init_model$3();
14489
- init_text();
14490
- init_split();
14491
- }));
14492
- //#endregion
14493
14592
  //#region src/review/placing.ts
14494
14593
  var keptOf$1, baseOf, nowOnNew, nowOnOld, writtenName, unplaced, rewordedAt, standing, searched, keyOf$3, pairOf, unique$1, nowFor, placedWithout, placedThrough, placedFrom, placeOne, nowsOf, writtenOf, pairsOf, diffsOf, placedAll, versionOf;
14495
14594
  var init_placing = __esmMin((() => {
@@ -14633,7 +14732,7 @@ var init_placing = __esmMin((() => {
14633
14732
  }));
14634
14733
  //#endregion
14635
14734
  //#region src/review/comments.ts
14636
- var POLL, bodyOf, saidTo, spunOf, sentOf, placedNow$1, linesIn, trimmedLines, NAMES_SOMETHING, worthMatching, blockAt, wholeSnippetIn, stillInFile, foundOutsideTheHunks, flatten, listSent, submitMany, submit, without$2, reply, threadBefore, layerOver, layersOn, dressed, take, REPLACED, listened, awaitTaken, WAIT_ALIVE_MS, standingOf, pushed, markRead;
14735
+ var POLL, bodyOf, saidTo, spunOf, sentOf, placedNow$1, linesIn, trimmedLines, NAMES_SOMETHING, worthMatching, blockAt, wholeSnippetIn, stillInFile, foundOutsideTheHunks, flatten, listSent, submitMany, submit, without$2, reply, threadBefore, layerOver, layersOn, namedBy, dressed, take, REPLACED, listened, awaitTaken, WAIT_ALIVE_MS, standingOf, pushed, markRead;
14637
14736
  var init_comments$1 = __esmMin((() => {
14638
14737
  init_dist();
14639
14738
  init_patch();
@@ -14859,31 +14958,48 @@ var init_comments$1 = __esmMin((() => {
14859
14958
  }));
14860
14959
  };
14861
14960
  layerOver = (layers, comment) => {
14862
- return layers.flatMap((layer) => codeBlocks(layer).filter((block) => block.path === comment.file && comment.start <= block.end && comment.end >= block.start).map((block) => ({
14863
- title: layer.title,
14961
+ return layers.flatMap((layer, at) => codeBlocks(layer).filter((block) => block.path === comment.file && comment.start <= block.end && comment.end >= block.start).map((block) => ({
14962
+ at,
14864
14963
  room: block.end - block.start
14865
- }))).reduce((tightest, one) => tightest === void 0 || one.room < tightest.room ? one : tightest, void 0)?.title;
14964
+ }))).reduce((tightest, one) => tightest === void 0 || one.room < tightest.room ? one : tightest, void 0)?.at;
14866
14965
  };
14867
14966
  layersOn = fn("Review.Comment.layersOn")(function* (worktree) {
14868
14967
  const found = yield* (yield* Store).layers(worktree);
14869
14968
  return match$3(found, {
14870
- onNone: () => [],
14871
- onSome: (held) => held.layers
14969
+ onNone: () => ({
14970
+ layers: [],
14971
+ tickets: []
14972
+ }),
14973
+ onSome: (held) => ({
14974
+ layers: held.layers,
14975
+ tickets: held.tickets ?? []
14976
+ })
14872
14977
  });
14873
14978
  });
14979
+ namedBy = (held, at) => {
14980
+ const layer = held.layers[at];
14981
+ const place = placesOf(held.layers.length, held.tickets)[at];
14982
+ if (layer === void 0 || place === void 0) return {};
14983
+ const ticket = held.tickets.find((one) => at >= one.first && at < one.first + one.count);
14984
+ return {
14985
+ layer: layer.title,
14986
+ layerAddress: place.address,
14987
+ ...ticket === void 0 ? {} : { ticket: ticket.title }
14988
+ };
14989
+ };
14874
14990
  dressed = fn("Review.Comment.dressed")(function* (resolved, batches) {
14875
14991
  const store = yield* Store;
14876
14992
  const owed = flatten(batches);
14877
14993
  if (owed.length === 0) return owed;
14878
- const layers = yield* layersOn(resolved);
14994
+ const held = yield* layersOn(resolved);
14879
14995
  const under = (one) => {
14880
- const title = layerOver(layers, one);
14881
- return title === void 0 ? one : Object.assign({}, one, { layer: title });
14996
+ const at = layerOver(held.layers, one);
14997
+ return at === void 0 ? one : Object.assign({}, one, namedBy(held, at));
14882
14998
  };
14883
14999
  if (owed.every((one) => one.replyTo === void 0)) return owed.map(under);
14884
- const held = flatten(yield* store.inbox(resolved));
15000
+ const inbox = flatten(yield* store.inbox(resolved));
14885
15001
  const spoken = yield* store.answers(resolved);
14886
- const carried = (one) => one.replyTo === void 0 ? one : Object.assign({}, one, { thread: threadBefore(one, held, spoken) });
15002
+ const carried = (one) => one.replyTo === void 0 ? one : Object.assign({}, one, { thread: threadBefore(one, inbox, spoken) });
14887
15003
  return owed.map(carried).map(under);
14888
15004
  });
14889
15005
  take = fn("Review.Comment.take")(function* (worktreePath) {
@@ -16614,28 +16730,11 @@ var init_syntax = __esmMin((() => {
16614
16730
  init_service();
16615
16731
  }));
16616
16732
  //#endregion
16617
- //#region src/review/layers.ts
16618
- var STALE_ADVICE, OUTDATED_ADVICE, unique, spansOfLayer, tidyPath, spanFault, blockFault, codeBlockOf, tidyBlock, blocksOf, layerFault, layerOf, parsed, readLayers, fromStored, toStored, partIn, reportedLayers, adviceOf, reportOf, pathsOfLayer, sourcesOf, changedSinceWritten, outdatedIn, splitsFound, storedLayers, set, readInLayer, withRead, coversThread, readsFile, lastHolding, layersHolding$1, loudest, partWithThreads, withThreads, readReport, view, show$1, placeThreads, spansIn, layersAt, taggedRow, nearestNew, lineNow, taggedHunk, taggedFile, tagSince, quietRow, quietFile, tagRows, read, partsOfFile, vouchPart, carriedStamps, unmarkedPart, markedPart, askingFor, openAskOf, askIn, seenOf, ask, claims, vouchIn;
16619
- var init_layers = __esmMin((() => {
16733
+ //#region src/review/document.ts
16734
+ var tidyPath, spanFault, blockFault, codeBlockOf, tidyBlock, blocksOf, titleOf, layerFault, inputOf, sublayersOf$1, carries, holdsCode, nests, nestingFault, sublayerFault, ticketFault, entryFault, layerOf, noteOf, flattened, parsed, readLayers;
16735
+ var init_document = __esmMin((() => {
16620
16736
  init_dist();
16621
- init_layers$1();
16622
- init_git();
16623
- init_syntax();
16624
- init_store();
16625
- init_review$1();
16626
16737
  init_error$3();
16627
- init_comments$1();
16628
- init_threads$1();
16629
- init_branches$1();
16630
- init_vouching$1();
16631
- STALE_ADVICE = "These layers describe an older commit. Read the diff again and write a new revision with layers set.";
16632
- OUTDATED_ADVICE = "The code under the outdated spans changed after these layers were written. Read those lines again and write a new revision with layers set.";
16633
- unique = (paths) => [...new Set(paths)];
16634
- spansOfLayer = (layer) => codeBlocks(layer).map(({ path, start, end }) => ({
16635
- path,
16636
- start,
16637
- end
16638
- }));
16639
16738
  tidyPath = (path) => path.replace(/^\.\/+/, "").replace(/^\/+/, "");
16640
16739
  spanFault = (value) => {
16641
16740
  const span = value;
@@ -16675,23 +16774,71 @@ var init_layers = __esmMin((() => {
16675
16774
  ...spans.map(codeBlockOf)
16676
16775
  ];
16677
16776
  };
16678
- layerFault = (layer, at) => {
16679
- const named = `layer ${at + 1}`;
16680
- if (typeof layer.title !== "string" || layer.title.trim().length === 0) return `${named} needs a title`;
16681
- const said = `${named}, "${layer.title.trim()}",`;
16777
+ titleOf = (layer) => typeof layer.title === "string" && layer.title.trim().length > 0 ? layer.title.trim() : void 0;
16778
+ layerFault = (layer, address) => {
16779
+ const named = `layer ${address}`;
16780
+ const title = titleOf(layer);
16781
+ if (title === void 0) return `${named} needs a title`;
16782
+ const said = `${named}, "${title}",`;
16682
16783
  const blocks = Array.isArray(layer.blocks) ? layer.blocks : [];
16683
16784
  const spans = Array.isArray(layer.spans) ? layer.spans : [];
16684
16785
  const fault = [...blocks.map(blockFault), ...spans.map(spanFault)].find((one) => one !== void 0);
16685
16786
  if (fault !== void 0) return `${said} ${fault}`;
16686
16787
  if (blocks.length === 0 && spans.length === 0) return `${said} needs at least one span or block`;
16687
16788
  };
16688
- layerOf = (value, at) => {
16689
- const layer = value ?? {};
16690
- if (layerFault(layer, at) !== void 0) return none();
16691
- return some({
16692
- title: String(layer.title).trim(),
16693
- blocks: blocksOf(layer)
16694
- });
16789
+ inputOf = (value) => value ?? {};
16790
+ sublayersOf$1 = (ticket) => Array.isArray(ticket.layers) ? ticket.layers : [];
16791
+ carries = (value) => Array.isArray(value) && value.length > 0;
16792
+ holdsCode = (entry) => carries(entry.spans) || carries(entry.blocks);
16793
+ nests = (entry) => {
16794
+ if (entry.layers === void 0) return false;
16795
+ return carries(entry.layers) || !holdsCode(entry);
16796
+ };
16797
+ nestingFault = (ticket, said) => {
16798
+ if (holdsCode(ticket)) return `${said} holds sublayers and code of its own, and a layer that holds sublayers keeps its code in them. Move its spans and blocks into a sublayer.`;
16799
+ const held = sublayersOf$1(ticket).length;
16800
+ if (held > 1) return void 0;
16801
+ return `${said} ${held === 0 ? "holds no sublayers" : "holds one sublayer"}, and a layer that holds sublayers needs two or more. Give it a second sublayer, or write it as a plain layer with its own spans.`;
16802
+ };
16803
+ sublayerFault = (sublayer, address, above) => {
16804
+ if (!nests(sublayer)) return layerFault(sublayer, address);
16805
+ const title = titleOf(sublayer);
16806
+ return `${title === void 0 ? `layer ${address}` : `layer ${address}, "${title}",`} holds layers of its own, and sublayers nest one level deep. List them under layer ${above}, beside it.`;
16807
+ };
16808
+ ticketFault = (ticket, number) => {
16809
+ const title = titleOf(ticket);
16810
+ if (title === void 0) return `layer ${number} needs a title`;
16811
+ const fault = nestingFault(ticket, `layer ${number}, "${title}",`);
16812
+ if (fault !== void 0) return fault;
16813
+ return sublayersOf$1(ticket).map((one, at) => sublayerFault(inputOf(one), `${number}.${at + 1}`, number)).find((said) => said !== void 0);
16814
+ };
16815
+ entryFault = (entry, at) => nests(entry) ? ticketFault(entry, at + 1) : layerFault(entry, String(at + 1));
16816
+ layerOf = (layer) => ({
16817
+ title: titleOf(layer) ?? "",
16818
+ blocks: blocksOf(layer)
16819
+ });
16820
+ noteOf = (ticket) => typeof ticket.note === "string" ? ticket.note.trim() : "";
16821
+ flattened = (entries) => {
16822
+ const layers = [];
16823
+ const tickets = [];
16824
+ for (const entry of entries) {
16825
+ if (!nests(entry)) {
16826
+ layers.push(layerOf(entry));
16827
+ continue;
16828
+ }
16829
+ const held = sublayersOf$1(entry).map((one) => layerOf(inputOf(one)));
16830
+ tickets.push({
16831
+ title: titleOf(entry) ?? "",
16832
+ note: noteOf(entry),
16833
+ first: layers.length,
16834
+ count: held.length
16835
+ });
16836
+ layers.push(...held);
16837
+ }
16838
+ return {
16839
+ layers,
16840
+ tickets
16841
+ };
16695
16842
  };
16696
16843
  parsed = (text) => {
16697
16844
  try {
@@ -16708,18 +16855,41 @@ var init_layers = __esmMin((() => {
16708
16855
  });
16709
16856
  const raw = document["layers"];
16710
16857
  if (!Array.isArray(raw) || raw.length === 0) return yield* new MalformedLayers({ reason: "the document needs a layers array" });
16711
- const fault = raw.map((entry, at) => layerFault(entry ?? {}, at)).find((said) => said !== void 0);
16858
+ const entries = raw.map(inputOf);
16859
+ const fault = entries.map(entryFault).find((said) => said !== void 0);
16712
16860
  if (fault !== void 0) return yield* new MalformedLayers({ reason: fault });
16713
- const layers = raw.flatMap((entry, at) => match$3(layerOf(entry, at), {
16714
- onNone: () => [],
16715
- onSome: (layer) => [layer]
16716
- }));
16717
16861
  const summary = document["summary"];
16718
16862
  return {
16719
16863
  summary: typeof summary === "string" ? summary : "",
16720
- layers
16864
+ ...flattened(entries)
16721
16865
  };
16722
16866
  });
16867
+ }));
16868
+ //#endregion
16869
+ //#region src/review/layers.ts
16870
+ var STALE_ADVICE, OUTDATED_ADVICE, unique, spansOfLayer, fromStored, toStored, partIn, placedAt, reportedLayers, adviceOf, reportOf, pathsOfLayer, sourcesOf, changedSinceWritten, outdatedIn, splitsFound, storedLayers, set, readInLayer, withRead, coversThread, readsFile, lastHolding, layersHolding$1, loudest, partWithThreads, withThreads, readReport, view, show$1, placeThreads, spansIn, layersAt, taggedRow, nearestNew, lineNow, taggedHunk, taggedFile, tagSince, quietRow, quietFile, tagRows, read, partsOfFile, vouchPart, carriedStamps, unmarkedPart, markedPart, askingFor, openAskOf, askIn, seenOf, ask, claims, vouchIn, WHOLE, vouchAt;
16871
+ var init_layers = __esmMin((() => {
16872
+ init_dist();
16873
+ init_layers$1();
16874
+ init_git();
16875
+ init_syntax();
16876
+ init_store();
16877
+ init_review$1();
16878
+ init_error$3();
16879
+ init_comments$1();
16880
+ init_document();
16881
+ init_tickets$1();
16882
+ init_threads$1();
16883
+ init_branches$1();
16884
+ init_vouching$1();
16885
+ STALE_ADVICE = "These layers describe an older commit. Read the diff again and write a new revision with layers set.";
16886
+ OUTDATED_ADVICE = "The code under the outdated spans changed after these layers were written. Read those lines again and write a new revision with layers set.";
16887
+ unique = (paths) => [...new Set(paths)];
16888
+ spansOfLayer = (layer) => codeBlocks(layer).map(({ path, start, end }) => ({
16889
+ path,
16890
+ start,
16891
+ end
16892
+ }));
16723
16893
  fromStored = (stored) => ({
16724
16894
  ...stored,
16725
16895
  parent: fromNullishOr(stored.parent)
@@ -16729,16 +16899,28 @@ var init_layers = __esmMin((() => {
16729
16899
  parent: getOrUndefined$1(layers.parent)
16730
16900
  });
16731
16901
  partIn = (patches, layer, path) => Object.assign({ path }, linesClaimed(patches.filter((patch) => patch.path === path), layer));
16902
+ placedAt = (places, at) => {
16903
+ const place = places[at];
16904
+ if (place === void 0) return { address: String(at + 1) };
16905
+ if (place.sublayer === void 0) return { address: place.address };
16906
+ return {
16907
+ address: place.address,
16908
+ ticket: place.number,
16909
+ sublayer: place.sublayer
16910
+ };
16911
+ };
16732
16912
  reportedLayers = (patches, layers) => {
16733
16913
  const present = new Set(patches.map((patch) => patch.path));
16734
- return withFullCoverage(patches, layers).layers.map((layer, at) => {
16914
+ const full = withFullCoverage(patches, layers).layers;
16915
+ const places = placesOf(full.length, layers.tickets ?? []);
16916
+ return full.map((layer, at) => {
16735
16917
  const named = unique(spansOfLayer(layer).map((span) => span.path));
16736
16918
  const gap = coverage(patches, [layer]);
16737
16919
  const lines = linesClaimed(patches, layer);
16738
16920
  const files = named.filter((path) => present.has(path));
16739
- return {
16921
+ return Object.assign(placedAt(places, at), {
16740
16922
  title: layer.title,
16741
- note: noteOf(layer),
16923
+ note: noteOf$1(layer),
16742
16924
  files,
16743
16925
  spans: spansOfLayer(layer),
16744
16926
  prose: proseAnchors(layer).filter((anchor) => present.has(anchor.path)),
@@ -16749,7 +16931,7 @@ var init_layers = __esmMin((() => {
16749
16931
  vanished: named.filter((path) => !present.has(path)),
16750
16932
  unclaimed: at >= layers.layers.length,
16751
16933
  parts: files.map((path) => partIn(patches, layer, path))
16752
- };
16934
+ });
16753
16935
  });
16754
16936
  };
16755
16937
  adviceOf = (moved, outdated) => {
@@ -16758,6 +16940,7 @@ var init_layers = __esmMin((() => {
16758
16940
  };
16759
16941
  reportOf = (patches, layers, branchHead, outdated = []) => {
16760
16942
  const status = statusOf(patches, layers, branchHead);
16943
+ const reported = reportedLayers(patches, layers);
16761
16944
  return {
16762
16945
  version: status.version,
16763
16946
  parent: getOrUndefined$1(status.parent),
@@ -16775,7 +16958,14 @@ var init_layers = __esmMin((() => {
16775
16958
  split: layers.split ?? [],
16776
16959
  vanished: status.vanished,
16777
16960
  outdated,
16778
- layers: reportedLayers(patches, layers)
16961
+ layers: reported,
16962
+ topLevel: topLevelOf(layers),
16963
+ tickets: ticketsOf({
16964
+ patches,
16965
+ layers,
16966
+ reported,
16967
+ outdated
16968
+ })
16779
16969
  };
16780
16970
  };
16781
16971
  pathsOfLayer = (layer) => codeBlocks(layer).map((block) => block.path);
@@ -16825,7 +17015,8 @@ var init_layers = __esmMin((() => {
16825
17015
  summary: input.summary,
16826
17016
  layers: stamped(input.layers, sources),
16827
17017
  blobs: Object.fromEntries(patches$1.filter((patch) => sources.has(patch.path)).map((patch) => [patch.path, patch.blob])),
16828
- split: yield* splitsFound(patches$1, input.layers, sources)
17018
+ split: yield* splitsFound(patches$1, input.layers, sources),
17019
+ ...input.tickets.length === 0 ? {} : { tickets: input.tickets }
16829
17020
  };
16830
17021
  yield* store.saveLayers(worktree.path, toStored(layers));
16831
17022
  return reportOf(patches$1, layers, worktree.head);
@@ -16836,9 +17027,8 @@ var init_layers = __esmMin((() => {
16836
17027
  const spans = layer.spans.filter((span) => span.path === path);
16837
17028
  return reading.parts.includes(partOf(path, spans));
16838
17029
  });
16839
- withRead = (report, reading) => ({
16840
- ...report,
16841
- layers: report.layers.map((layer) => {
17030
+ withRead = (report, reading) => {
17031
+ const layers = report.layers.map((layer) => {
16842
17032
  const read = readInLayer(layer, reading);
16843
17033
  return Object.assign({}, layer, {
16844
17034
  read,
@@ -16848,8 +17038,13 @@ var init_layers = __esmMin((() => {
16848
17038
  read: read.includes(part.path)
16849
17039
  }))
16850
17040
  });
16851
- })
16852
- });
17041
+ });
17042
+ return {
17043
+ ...report,
17044
+ layers,
17045
+ tickets: ticketsRead(report.tickets, layers)
17046
+ };
17047
+ };
16853
17048
  coversThread = (layer, thread) => thread.side === "new" && layer.spans.some((span) => span.path === thread.file && thread.start <= span.end && thread.end >= span.start);
16854
17049
  readsFile = (layer, file) => layer.read?.includes(file) === true;
16855
17050
  lastHolding = (layers, file, at) => layers.every((other, index) => index === at || !claims(other, file) || readsFile(other, file));
@@ -16881,6 +17076,13 @@ var init_layers = __esmMin((() => {
16881
17076
  stand: loudest(mine),
16882
17077
  parts: layer.parts.map((part) => partWithThreads(part, mine))
16883
17078
  });
17079
+ }),
17080
+ tickets: report.tickets.map((ticket) => {
17081
+ const mine = open.filter((one) => holdsAny$1(ticket.layers, one.layers)).map((one) => one.thread);
17082
+ return Object.assign({}, ticket, {
17083
+ open: mine.length,
17084
+ stand: loudest(mine)
17085
+ });
16884
17086
  })
16885
17087
  };
16886
17088
  };
@@ -16986,12 +17188,22 @@ var init_layers = __esmMin((() => {
16986
17188
  const found = yield* storedLayers(worktree);
16987
17189
  if (isNone(found)) return {
16988
17190
  layers: [],
17191
+ tickets: [],
17192
+ topLevel: 0,
16989
17193
  stale: false,
16990
17194
  summary: ""
16991
17195
  };
16992
17196
  const outdated = yield* outdatedIn(worktree, reading.patches, found.value);
17197
+ const reported = reportedLayers(reading.patches, found.value);
16993
17198
  return {
16994
- layers: reportedLayers(reading.patches, found.value),
17199
+ layers: reported,
17200
+ tickets: ticketsOf({
17201
+ patches: reading.patches,
17202
+ layers: found.value,
17203
+ reported,
17204
+ outdated
17205
+ }),
17206
+ topLevel: topLevelOf(found.value),
16995
17207
  stale: found.value.head !== worktree.head || outdated.length > 0,
16996
17208
  rebased: found.value.base !== worktree.base,
16997
17209
  summary: found.value.summary
@@ -17141,6 +17353,26 @@ var init_layers = __esmMin((() => {
17141
17353
  if (holding < 2 || spans.length === 0) return yield* toggle(reading, file, marking);
17142
17354
  return yield* vouchPart(reading, file, partOf(file, spans), marking);
17143
17355
  });
17356
+ WHOLE = /^\d+$/;
17357
+ vouchAt = fn("Review.Layers.vouchAt")(function* (reading, file, address, marking = {}) {
17358
+ const held = yield* read(reading);
17359
+ const position = held.layers.findIndex((layer) => layer.address === address);
17360
+ if (position !== -1) return yield* vouchIn(reading, file, position + 1, marking);
17361
+ const ticket = held.tickets.find((one) => one.address === address);
17362
+ if (ticket === void 0) return yield* new UnknownLayer({
17363
+ layer: WHOLE.test(address) ? Number(address) : address,
17364
+ known: held.layers.length,
17365
+ addresses: held.layers.map((layer) => layer.address)
17366
+ });
17367
+ return yield* new LayerIsTicket({
17368
+ layer: address,
17369
+ title: ticket.title,
17370
+ sublayers: held.layers.filter((layer) => layer.ticket === ticket.number).map((layer) => ({
17371
+ address: layer.address,
17372
+ title: layer.title
17373
+ }))
17374
+ });
17375
+ });
17144
17376
  }));
17145
17377
  //#endregion
17146
17378
  //#region src/review/drafts.ts
@@ -45187,7 +45419,7 @@ var init_gaps = __esmMin((() => {
45187
45419
  if (at === -1) return "no layer claims them";
45188
45420
  const layer = state.layers[at];
45189
45421
  if (layer === void 0 || layer.title === "not in any layer") return "no layer claims them";
45190
- return `layer ${at + 1} explains them`;
45422
+ return `layer ${layer.address} explains them`;
45191
45423
  };
45192
45424
  lineOf$1 = (row) => getOrUndefined$1(orElse(row.newLine, () => row.oldLine));
45193
45425
  inSpans = (spans, path, line) => spans.some((span) => span.path === path && span.start <= line && span.end >= line);
@@ -45277,7 +45509,7 @@ var init_match = __esmMin((() => {
45277
45509
  }));
45278
45510
  //#endregion
45279
45511
  //#region src/tui/state.ts
45280
- var HOLDS$1, chosenNow, withChosen, EDITOR_ROW, editorRow, preferenceRows, nothingReviewed, nothingFound, initialState, selectedBranch, selectedPatch, pullHere, authorHere, theirPull, heldWhere, noteEditing, hasNoPull, onLayers, selectedLayer, movedPast;
45512
+ var HOLDS$1, chosenNow, withChosen, EDITOR_ROW, editorRow, preferenceRows, nothingReviewed, nothingFound, noLayers, initialState, selectedBranch, selectedPatch, pullHere, authorHere, theirPull, heldWhere, noteEditing, hasNoPull, onLayers, selectedLayer, movedPast;
45281
45513
  var init_state = __esmMin((() => {
45282
45514
  init_preferences$1();
45283
45515
  init_review$1();
@@ -45363,6 +45595,16 @@ var init_state = __esmMin((() => {
45363
45595
  query: "",
45364
45596
  paletteIndex: 0
45365
45597
  };
45598
+ noLayers = {
45599
+ layers: [],
45600
+ tickets: [],
45601
+ topLevel: 0,
45602
+ shutTickets: [],
45603
+ layersStale: false,
45604
+ summary: "",
45605
+ layerIndex: 0,
45606
+ openLayers: []
45607
+ };
45366
45608
  initialState = (branches) => ({
45367
45609
  ...nothingReviewed,
45368
45610
  screen: "branches",
@@ -45399,13 +45641,9 @@ var init_state = __esmMin((() => {
45399
45641
  wrap: false,
45400
45642
  sticky: true,
45401
45643
  pan: 0,
45402
- layers: [],
45403
- layersStale: false,
45404
- summary: "",
45644
+ ...noLayers,
45405
45645
  pulls: {},
45406
45646
  forge: "asking",
45407
- layerIndex: 0,
45408
- openLayers: [],
45409
45647
  ...nothingFound,
45410
45648
  counted: {
45411
45649
  file: 0,
@@ -45858,210 +46096,80 @@ var init_layout = __esmMin((() => {
45858
46096
  const lines = selectedRows(state).length;
45859
46097
  return `${patch.path} ${lines} ${lines === 1 ? "line" : "lines"} selected`;
45860
46098
  };
45861
- }));
45862
- //#endregion
45863
- //#region src/tui/words.ts
45864
- var counted, chunked, packed, shortened, wordWrapped, wrapped, clip;
45865
- var init_words = __esmMin((() => {
45866
- counted = (many, one) => `${many} ${one}${many === 1 ? "" : "s"}`;
45867
- chunked = (word, room) => word.length <= room ? [word] : [word.slice(0, room), ...chunked(word.slice(room), room)];
45868
- packed = (lines, word, room) => {
45869
- const last = lines.at(-1);
45870
- if (last === void 0 || last.length + 1 + word.length > room) return [...lines, word];
45871
- return [...lines.slice(0, -1), `${last} ${word}`];
45872
- };
45873
- shortened = (word, room) => word.length <= room ? word : `${word.slice(0, Math.max(1, room - 1))}\u2026`;
45874
- wordWrapped = (text, room) => {
45875
- const width = Math.max(1, room);
45876
- return text.split(/\s+/).filter((word) => word.length > 0).map((word) => shortened(word, width)).reduce((lines, word) => packed(lines, word, width), []);
45877
- };
45878
- wrapped = (text, room) => {
45879
- const width = Math.max(1, room);
45880
- return text.split(/\s+/).filter((word) => word.length > 0).flatMap((word) => chunked(word, width)).reduce((lines, word) => packed(lines, word, width), []);
45881
- };
45882
- clip = (label, room) => label.length > room ? `${label.slice(0, Math.max(0, room - 1))}…` : label;
45883
- })), proseFor, layerHolding, layerOpen, TITLE_ROWS, titleRows, shortDir, fileRow$1, shownFiles, dirOf, fileRows, layerRead, layerDone, NOTHING_LEFT, textRows, linesSaid, countRow, emptyRows, layerBody, holdsCursor, layerCard, layerRows, nearFirst, layerFitted, restingAt, railTop, PANE_CHROME, layerRoomIn, railWindow, layerContext;
45884
- var init_layerview = __esmMin((() => {
45885
- init_files();
45886
- init_layout();
45887
- init_state();
45888
- init_words();
45889
- proseFor = (state, path) => {
45890
- if (!onLayers(state)) return [];
45891
- const layer = selectedLayer(state);
45892
- if (layer === void 0) return [];
45893
- return layer.prose.filter((anchor) => anchor.path === path);
45894
- };
45895
- layerHolding = (state, fileIndex) => {
45896
- const path = state.patches[fileIndex]?.path;
45897
- const at = state.layers.findIndex((layer) => layer.files.includes(path ?? ""));
45898
- return at === -1 ? state.layerIndex : at;
45899
- };
45900
- layerOpen = (state, layerIndex) => state.openLayers.includes(layerIndex);
45901
- TITLE_ROWS = 2;
45902
- titleRows = (state, layerIndex, room, marked) => {
45903
- const lines = wordWrapped(state.layers[layerIndex]?.title ?? "", room);
45904
- const heldLines = lines.slice(0, TITLE_ROWS);
45905
- const last = heldLines.at(-1) ?? "";
45906
- return (lines.length > TITLE_ROWS ? [...heldLines.slice(0, -1), clip(`${last} …`, room)] : heldLines).map((text, at) => ({
45907
- index: layerIndex,
45908
- kind: "title",
45909
- text,
45910
- lead: at === 0,
45911
- here: at === 0 && marked
45912
- }));
45913
- };
45914
- shortDir = (dir, room) => {
45915
- const whole = `${dir}/`;
45916
- if (whole.length <= room) return whole;
45917
- const parts = dir.split("/");
45918
- const last = parts.at(-1) ?? "";
45919
- const shrunk = parts.length < 3 ? "" : `${parts[0] ?? ""}/…/${last}/`;
45920
- if (shrunk.length > 0 && shrunk.length <= room) return shrunk;
45921
- const tail = `…/${last}/`;
45922
- if (tail.length <= room) return tail;
45923
- return `${clip(last, Math.max(1, room - 1))}/`;
45924
- };
45925
- fileRow$1 = (state, layerIndex, at, room) => {
45926
- const path = state.patches[at]?.path ?? "";
45927
- const name = path.split("/").at(-1) ?? path;
45928
- return {
45929
- index: layerIndex,
45930
- kind: "file",
45931
- text: clip(name, room),
45932
- lead: false,
45933
- fileIndex: at,
45934
- reviewed: readIn(state, layerIndex, at),
45935
- here: at === state.patchIndex && layerIndex === state.layerIndex
45936
- };
45937
- };
45938
- shownFiles = (state, layerIndex) => layerFiles(state, layerIndex).filter((at) => !(state.hideReviewed && isReviewed(state, at) && at !== state.patchIndex));
45939
- dirOf = (state, at) => {
45940
- return (state.patches[at]?.path ?? "").split("/").slice(0, -1).join("/");
45941
- };
45942
- fileRows = (state, layerIndex, room) => {
45943
- const rows = [];
45944
- let held;
45945
- for (const at of shownFiles(state, layerIndex)) {
45946
- const dir = dirOf(state, at);
45947
- if (dir !== held && dir.length > 0) rows.push({
45948
- index: layerIndex,
45949
- kind: "dir",
45950
- text: shortDir(dir, room.dir),
45951
- lead: false
45952
- });
45953
- held = dir;
45954
- rows.push(fileRow$1(state, layerIndex, at, room.file));
45955
- }
45956
- return rows;
45957
- };
45958
- layerRead = (state, layerIndex) => {
45959
- const files = layerHolds(state, layerIndex);
45960
- return {
45961
- done: files.filter((at) => readIn(state, layerIndex, at)).length,
45962
- all: files.length
45963
- };
45964
- };
45965
- layerDone = (state, layerIndex) => {
45966
- const read = layerRead(state, layerIndex);
45967
- return read.all > 0 && read.done === read.all;
45968
- };
45969
- NOTHING_LEFT = "nothing in this diff";
45970
- textRows = (index, text, room, kind) => wrapped(text, room).map((line) => ({
45971
- index,
45972
- kind,
45973
- text: line,
45974
- lead: false
45975
- }));
45976
- linesSaid = (layer) => {
45977
- if (layer === void 0) return "";
45978
- const signs = [...layer.added > 0 ? [`+${layer.added}`] : [], ...layer.removed > 0 ? [`−${layer.removed}`] : []];
45979
- return signs.length === 0 ? "" : ` · ${signs.join(" ")}`;
45980
- };
45981
- countRow = (state, index, room) => {
45982
- const read = layerRead(state, index);
45983
- if (read.all === 0) return [];
45984
- const one = read.all === 1 ? "file" : "files";
45985
- const said = `${read.done} of ${read.all} ${one} read${linesSaid(state.layers[index])}`;
45986
- return textRows(index, said, room, "count");
45987
- };
45988
- emptyRows = (state, index, room) => {
45989
- const layer = state.layers[index];
45990
- if (layer === void 0) return [];
45991
- const gone = layer.vanished;
45992
- const said = gone.length === 0 ? NOTHING_LEFT : `${NOTHING_LEFT}: ${gone.join(", ")}`;
45993
- return [...textRows(index, said, room, "count"), ...textRows(index, layer.note, room, "note")];
45994
- };
45995
- layerBody = (state, index, room, shown) => {
45996
- if (layerRead(state, index).all === 0) return emptyRows(state, index, room.file);
45997
- if (!layerOpen(state, index) || !shown.has(index)) return countRow(state, index, room.file);
45998
- const rows = fileRows(state, index, room);
45999
- return rows.length > 0 ? rows : countRow(state, index, room.file);
46099
+ })), shared, ring, sets, chosen, useMarks, marks, STAND_KEY, standMark;
46100
+ var init_marks = __esmMin((() => {
46101
+ shared = {
46102
+ done: "✓",
46103
+ sent: "→",
46104
+ cursor: "▎",
46105
+ shut: "▸",
46106
+ open: "▾",
46107
+ space: "·",
46108
+ tab: "→"
46000
46109
  };
46001
- holdsCursor = (state, index) => index === state.layerIndex && layerFiles(state, index).includes(state.patchIndex);
46002
- layerCard = (state, index, room, shown) => {
46003
- const body = layerBody(state, index, room, shown);
46004
- const marked = holdsCursor(state, index) && !body.some((row) => row.here === true);
46005
- return [...titleRows(state, index, room.title, marked), ...body];
46110
+ ring = {
46111
+ ...shared,
46112
+ filed: "○",
46113
+ waiting: "◎",
46114
+ answered: "●",
46115
+ asked: "◉",
46116
+ rule: "│"
46006
46117
  };
46007
- layerRows = (state, room, shown) => state.layers.flatMap((_, index) => [...index > 0 ? [{
46008
- index,
46009
- kind: "gap",
46010
- text: "",
46011
- lead: false
46012
- }] : [], ...layerCard(state, index, room, shown)]);
46013
- 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));
46014
- layerFitted = (state, room, height) => {
46015
- const every = new Set(state.layers.map((_, at) => at));
46016
- const whole = layerRows(state, room, every);
46017
- if (whole.length <= height) return whole;
46018
- const shown = /* @__PURE__ */ new Set([state.layerIndex]);
46019
- for (const at of nearFirst(state)) {
46020
- shown.add(at);
46021
- if (layerRows(state, room, shown).length > height) shown.delete(at);
46118
+ sets = {
46119
+ ring,
46120
+ bubble: {
46121
+ ...shared,
46122
+ filed: "◌",
46123
+ waiting: "◎",
46124
+ answered: "●",
46125
+ asked: "◉",
46126
+ rule: "┃",
46127
+ cursor: "▌"
46128
+ },
46129
+ quote: {
46130
+ ...shared,
46131
+ filed: "❞",
46132
+ waiting: "❟",
46133
+ answered: "❠",
46134
+ asked: "❝",
46135
+ rule: "┊"
46136
+ },
46137
+ diamond: {
46138
+ ...shared,
46139
+ filed: "◇",
46140
+ waiting: "◈",
46141
+ answered: "◆",
46142
+ asked: "❖",
46143
+ rule: "╎"
46144
+ },
46145
+ dot: {
46146
+ ...shared,
46147
+ filed: "·",
46148
+ waiting: "◎",
46149
+ answered: "●",
46150
+ asked: "◉",
46151
+ rule: "▏"
46022
46152
  }
46023
- shown.add(state.layerIndex);
46024
- return layerRows(state, room, shown);
46025
- };
46026
- restingAt = (rows, height, layerIndex) => {
46027
- const first = Math.max(0, rows.findIndex((row) => row.index === layerIndex));
46028
- const block = rows.findLastIndex((row) => row.index === layerIndex) - first + 1;
46029
- return block >= height ? first : first - Math.floor((height - block) / 2);
46030
46153
  };
46031
- railTop = (rows, height, layerIndex, scroll) => {
46032
- const wanted = scroll >= 0 ? scroll : restingAt(rows, height, layerIndex);
46033
- return Math.max(0, Math.min(Math.max(0, rows.length - height), wanted));
46034
- };
46035
- PANE_CHROME = 3;
46036
- layerRoomIn = (state) => {
46037
- const whole = Math.max(8, treeWidth(state.columns) - PANE_CHROME);
46038
- return {
46039
- title: Math.max(4, whole - 4),
46040
- dir: Math.max(4, whole - 6),
46041
- file: Math.max(4, whole - 8)
46042
- };
46154
+ Object.keys(sets);
46155
+ chosen = ring;
46156
+ useMarks = (name) => {
46157
+ chosen = sets[name] ?? ring;
46043
46158
  };
46044
- railWindow = (rows, height, layerIndex, scroll = -1) => {
46045
- if (rows.length <= height) return {
46046
- rows,
46047
- more: 0,
46048
- above: 0
46049
- };
46050
- const start = railTop(rows, height, layerIndex, scroll);
46051
- const shown = rows.slice(start, start + height);
46052
- const here = new Set(shown.map((row) => row.index));
46053
- const seen = (from) => new Set(from.filter((row) => !here.has(row.index)).map((row) => row.index)).size;
46054
- return {
46055
- rows: shown,
46056
- more: seen(rows.slice(start + height)),
46057
- above: seen(rows.slice(0, start))
46058
- };
46159
+ marks = () => chosen;
46160
+ STAND_KEY = {
46161
+ filed: "filed",
46162
+ waiting: "waiting",
46163
+ answered: "answered",
46164
+ asked: "asked",
46165
+ settled: "done",
46166
+ gone: void 0
46059
46167
  };
46060
- layerContext = (current, delta) => {
46061
- const at = CONTEXT_STEPS.indexOf(current);
46062
- const next = Math.max(0, Math.min(CONTEXT_STEPS.length - 1, (at === -1 ? 0 : at) + delta));
46063
- return CONTEXT_STEPS[next] ?? current;
46168
+ standMark = (stand) => {
46169
+ const key = STAND_KEY[stand];
46170
+ return key === void 0 ? " " : chosen[key];
46064
46171
  };
46172
+ useMarks(process.env["ADIFF_MARKS"] ?? "ring");
46065
46173
  }));
46066
46174
  //#endregion
46067
46175
  //#region src/tui/panel.ts
@@ -46163,8 +46271,30 @@ var init_panel = __esmMin((() => {
46163
46271
  });
46164
46272
  }));
46165
46273
  //#endregion
46274
+ //#region src/tui/words.ts
46275
+ var counted, chunked, packed, shortened, wordWrapped, wrapped, clip;
46276
+ var init_words = __esmMin((() => {
46277
+ counted = (many, one) => `${many} ${one}${many === 1 ? "" : "s"}`;
46278
+ chunked = (word, room) => word.length <= room ? [word] : [word.slice(0, room), ...chunked(word.slice(room), room)];
46279
+ packed = (lines, word, room) => {
46280
+ const last = lines.at(-1);
46281
+ if (last === void 0 || last.length + 1 + word.length > room) return [...lines, word];
46282
+ return [...lines.slice(0, -1), `${last} ${word}`];
46283
+ };
46284
+ shortened = (word, room) => word.length <= room ? word : `${word.slice(0, Math.max(1, room - 1))}\u2026`;
46285
+ wordWrapped = (text, room) => {
46286
+ const width = Math.max(1, room);
46287
+ return text.split(/\s+/).filter((word) => word.length > 0).map((word) => shortened(word, width)).reduce((lines, word) => packed(lines, word, width), []);
46288
+ };
46289
+ wrapped = (text, room) => {
46290
+ const width = Math.max(1, room);
46291
+ return text.split(/\s+/).filter((word) => word.length > 0).flatMap((word) => chunked(word, width)).reduce((lines, word) => packed(lines, word, width), []);
46292
+ };
46293
+ clip = (label, room) => label.length > room ? `${label.slice(0, Math.max(0, room - 1))}…` : label;
46294
+ }));
46295
+ //#endregion
46166
46296
  //#region src/tui/notes.ts
46167
- var threadsOn, threadsOpenOn, askedRows, withAsking, firstLineOf, askedThreads, askingWords, markedStands, settledShown, settledInFile, settledAtRow, foldedAtRow, snippetOf, remarkAnswering, answerTarget, replyTarget, threadReplying, VOICES, remarkQuote, threadQuote, needingRowsIn, commentRowsIn, draftPlace, notesShown, threadsAtRow, remarkShown, remarksAtRow, remarkRowsIn, stopsIn, stopsAtRow, remarkAtStop, remarkAtRow, remarkInPanel, remarkInDiff, remarkUnderCursor, remarkHere, cursorOnThread, threadHere, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersSince, coveredBy, lastLayerOf, threadsInLayer, rewordTarget, composeTarget, anchoredTarget;
46297
+ var openOn, threadsOnFiles, threadsOn, threadsOpenOn, askedRows, withAsking, firstLineOf, askedThreads, askingWords, markedStands, settledShown, settledInFile, settledAtRow, foldedAtRow, snippetOf, remarkAnswering, answerTarget, replyTarget, threadReplying, VOICES, remarkQuote, threadQuote, needingRowsIn, commentRowsIn, draftPlace, notesShown, threadsAtRow, remarkShown, remarksAtRow, remarkRowsIn, stopsIn, stopsAtRow, remarkAtStop, remarkAtRow, remarkInPanel, remarkInDiff, remarkUnderCursor, remarkHere, cursorOnThread, threadHere, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersSince, coveredBy, lastLayerOf, threadsInLayer, rewordTarget, composeTarget, anchoredTarget;
46168
46298
  var init_notes = __esmMin((() => {
46169
46299
  init_dist();
46170
46300
  init_patch();
@@ -46173,14 +46303,15 @@ var init_notes = __esmMin((() => {
46173
46303
  init_panel();
46174
46304
  init_state();
46175
46305
  init_words();
46176
- threadsOn = (state, fileIndex) => {
46177
- const patch = state.patches[fileIndex];
46178
- const stands = patch === void 0 ? [] : state.sent.filter((entry) => entry.file === patch.path && entry.removed !== true && entry.settled !== true && !movedPast(entry)).map((entry) => threadStand(entry));
46306
+ openOn = (state, paths) => {
46307
+ const stands = state.sent.filter((entry) => paths.has(entry.file) && entry.removed !== true && entry.settled !== true && !movedPast(entry)).map((entry) => threadStand(entry));
46179
46308
  return {
46180
46309
  open: stands.length,
46181
46310
  stand: stands.reduce(louderOf, "gone")
46182
46311
  };
46183
46312
  };
46313
+ threadsOnFiles = (state, fileIndexes) => openOn(state, new Set(fileIndexes.flatMap((at) => state.patches[at]?.path ?? [])));
46314
+ threadsOn = (state, fileIndex) => threadsOnFiles(state, [fileIndex]);
46184
46315
  threadsOpenOn = (state, fileIndex, layerIndex) => {
46185
46316
  const patch = state.patches[fileIndex];
46186
46317
  if (patch === void 0) return [];
@@ -46455,8 +46586,303 @@ var init_notes = __esmMin((() => {
46455
46586
  };
46456
46587
  }));
46457
46588
  //#endregion
46589
+ //#region src/tui/tickets.ts
46590
+ var ticketOf, sublayersOf, firstSublayer, lastSublayer, ticketShut, addressOf$1, SUBLAYER_MARK_MIN, sublayerInset, layerPlaceSaid, fileInLayerSaid, nextLayerSaid;
46591
+ var init_tickets = __esmMin((() => {
46592
+ init_layers$1();
46593
+ init_files();
46594
+ init_state();
46595
+ ticketOf = (state, layerIndex) => {
46596
+ const number = state.layers[layerIndex]?.ticket;
46597
+ return number === void 0 ? void 0 : state.tickets.find((ticket) => ticket.number === number);
46598
+ };
46599
+ sublayersOf = (ticket) => ticket.layers.map((position) => position - 1);
46600
+ firstSublayer = (ticket) => (ticket.layers[0] ?? 1) - 1;
46601
+ lastSublayer = (ticket) => (ticket.layers.at(-1) ?? 1) - 1;
46602
+ ticketShut = (state, ticket) => state.shutTickets.includes(ticket.number);
46603
+ addressOf$1 = (state, layerIndex) => state.layers[layerIndex]?.address ?? String(layerIndex + 1);
46604
+ SUBLAYER_MARK_MIN = 3;
46605
+ sublayerInset = (state) => 1 + Math.max(SUBLAYER_MARK_MIN, ...state.layers.filter((layer) => layer.sublayer !== void 0).map((layer) => layer.address.length));
46606
+ layerPlaceSaid = (state) => {
46607
+ const layer = onLayers(state) ? selectedLayer(state) : void 0;
46608
+ if (layer === void 0 || layer.unclaimed) return "";
46609
+ const top = `layer ${layer.ticket ?? layer.address} of ${state.topLevel}`;
46610
+ const ticket = ticketOf(state, state.layerIndex);
46611
+ return ticket === void 0 ? top : `${top} · part ${layer.sublayer ?? 1} of ${ticket.sublayers}`;
46612
+ };
46613
+ fileInLayerSaid = (state) => {
46614
+ const layer = onLayers(state) ? selectedLayer(state) : void 0;
46615
+ if (layer === void 0) return "";
46616
+ const files = layerFiles(state, state.layerIndex);
46617
+ const at = files.indexOf(state.patchIndex);
46618
+ if (at === -1) return "";
46619
+ const which = layer.unclaimed ? REMAINDER_TITLE : `in layer ${layer.address}`;
46620
+ return `${at + 1} of ${files.length} ${which}`;
46621
+ };
46622
+ nextLayerSaid = (state, layerIndex) => {
46623
+ const next = state.layers[layerIndex];
46624
+ if (next === void 0) return "";
46625
+ if (next.unclaimed) return ` · next ${REMAINDER_TITLE}`;
46626
+ return ` · next ${next.address} ${next.title}`;
46627
+ };
46628
+ })), proseFor, layerHolding, layerOpen, TITLE_ROWS, heldLines, titleRows, shortDir, fileRow$1, shownFiles, dirOf, fileRows, layerRead, layerDone, NOTHING_LEFT, textRows, linesSaid, countRow, emptyRows, layerBody, holdsCursor, layerCard, NOTE_ROWS, ticketRead, ticketDone, setIn, sublayerCard, openSaid, ticketCount, ticketHead, ticketNote, ticketCard, cardAt, layerRows, nearFirst, layerFitted, restingAt, railTop, PANE_CHROME, layerRoomIn, railWindow, layerContext;
46629
+ var init_layerview = __esmMin((() => {
46630
+ init_files();
46631
+ init_layout();
46632
+ init_marks();
46633
+ init_notes();
46634
+ init_state();
46635
+ init_tickets();
46636
+ init_words();
46637
+ proseFor = (state, path) => {
46638
+ if (!onLayers(state)) return [];
46639
+ const layer = selectedLayer(state);
46640
+ if (layer === void 0) return [];
46641
+ return layer.prose.filter((anchor) => anchor.path === path);
46642
+ };
46643
+ layerHolding = (state, fileIndex) => {
46644
+ const path = state.patches[fileIndex]?.path;
46645
+ const at = state.layers.findIndex((layer) => layer.files.includes(path ?? ""));
46646
+ return at === -1 ? state.layerIndex : at;
46647
+ };
46648
+ layerOpen = (state, layerIndex) => state.openLayers.includes(layerIndex);
46649
+ TITLE_ROWS = 2;
46650
+ heldLines = (text, room, most) => {
46651
+ const lines = wordWrapped(text, room);
46652
+ const held = lines.slice(0, most);
46653
+ const last = held.at(-1) ?? "";
46654
+ return lines.length > most ? [...held.slice(0, -1), clip(`${last} …`, room)] : held;
46655
+ };
46656
+ titleRows = (state, layerIndex, room, marked) => heldLines(state.layers[layerIndex]?.title ?? "", room, TITLE_ROWS).map((text, at) => ({
46657
+ index: layerIndex,
46658
+ kind: "title",
46659
+ text,
46660
+ lead: at === 0,
46661
+ here: at === 0 && marked
46662
+ }));
46663
+ shortDir = (dir, room) => {
46664
+ const whole = `${dir}/`;
46665
+ if (whole.length <= room) return whole;
46666
+ const parts = dir.split("/");
46667
+ const last = parts.at(-1) ?? "";
46668
+ const shrunk = parts.length < 3 ? "" : `${parts[0] ?? ""}/…/${last}/`;
46669
+ if (shrunk.length > 0 && shrunk.length <= room) return shrunk;
46670
+ const tail = `…/${last}/`;
46671
+ if (tail.length <= room) return tail;
46672
+ return `${clip(last, Math.max(1, room - 1))}/`;
46673
+ };
46674
+ fileRow$1 = (state, layerIndex, at, room) => {
46675
+ const path = state.patches[at]?.path ?? "";
46676
+ const name = path.split("/").at(-1) ?? path;
46677
+ return {
46678
+ index: layerIndex,
46679
+ kind: "file",
46680
+ text: clip(name, room),
46681
+ lead: false,
46682
+ fileIndex: at,
46683
+ reviewed: readIn(state, layerIndex, at),
46684
+ here: at === state.patchIndex && layerIndex === state.layerIndex
46685
+ };
46686
+ };
46687
+ shownFiles = (state, layerIndex) => layerFiles(state, layerIndex).filter((at) => !(state.hideReviewed && isReviewed(state, at) && at !== state.patchIndex));
46688
+ dirOf = (state, at) => {
46689
+ return (state.patches[at]?.path ?? "").split("/").slice(0, -1).join("/");
46690
+ };
46691
+ fileRows = (state, layerIndex, room) => {
46692
+ const rows = [];
46693
+ let held;
46694
+ for (const at of shownFiles(state, layerIndex)) {
46695
+ const dir = dirOf(state, at);
46696
+ if (dir !== held && dir.length > 0) rows.push({
46697
+ index: layerIndex,
46698
+ kind: "dir",
46699
+ text: shortDir(dir, room.dir),
46700
+ lead: false
46701
+ });
46702
+ held = dir;
46703
+ rows.push(fileRow$1(state, layerIndex, at, room.file));
46704
+ }
46705
+ return rows;
46706
+ };
46707
+ layerRead = (state, layerIndex) => {
46708
+ const files = layerHolds(state, layerIndex);
46709
+ return {
46710
+ done: files.filter((at) => readIn(state, layerIndex, at)).length,
46711
+ all: files.length
46712
+ };
46713
+ };
46714
+ layerDone = (state, layerIndex) => {
46715
+ const read = layerRead(state, layerIndex);
46716
+ return read.all > 0 && read.done === read.all;
46717
+ };
46718
+ NOTHING_LEFT = "nothing in this diff";
46719
+ textRows = (index, text, room, kind) => wrapped(text, room).map((line) => ({
46720
+ index,
46721
+ kind,
46722
+ text: line,
46723
+ lead: false
46724
+ }));
46725
+ linesSaid = (layer) => {
46726
+ if (layer === void 0) return "";
46727
+ const signs = [...layer.added > 0 ? [`+${layer.added}`] : [], ...layer.removed > 0 ? [`−${layer.removed}`] : []];
46728
+ return signs.length === 0 ? "" : ` · ${signs.join(" ")}`;
46729
+ };
46730
+ countRow = (state, index, room) => {
46731
+ const read = layerRead(state, index);
46732
+ if (read.all === 0) return [];
46733
+ const one = read.all === 1 ? "file" : "files";
46734
+ const said = `${read.done} of ${read.all} ${one} read${linesSaid(state.layers[index])}`;
46735
+ return textRows(index, said, room, "count");
46736
+ };
46737
+ emptyRows = (state, index, room) => {
46738
+ const layer = state.layers[index];
46739
+ if (layer === void 0) return [];
46740
+ const gone = layer.vanished;
46741
+ const said = gone.length === 0 ? NOTHING_LEFT : `${NOTHING_LEFT}: ${gone.join(", ")}`;
46742
+ return [...textRows(index, said, room, "count"), ...textRows(index, layer.note, room, "note")];
46743
+ };
46744
+ layerBody = (state, index, room, shown) => {
46745
+ if (layerRead(state, index).all === 0) return emptyRows(state, index, room.file);
46746
+ if (!layerOpen(state, index) || !shown.has(index)) return countRow(state, index, room.file);
46747
+ const rows = fileRows(state, index, room);
46748
+ return rows.length > 0 ? rows : countRow(state, index, room.file);
46749
+ };
46750
+ holdsCursor = (state, index) => index === state.layerIndex && layerFiles(state, index).includes(state.patchIndex);
46751
+ layerCard = (state, index, room, shown) => {
46752
+ const body = layerBody(state, index, room, shown);
46753
+ const marked = holdsCursor(state, index) && !body.some((row) => row.here === true);
46754
+ return [...titleRows(state, index, room.title, marked), ...body];
46755
+ };
46756
+ NOTE_ROWS = 2;
46757
+ ticketRead = (state, ticket) => {
46758
+ const sublayers = sublayersOf(ticket);
46759
+ return {
46760
+ done: sublayers.filter((at) => layerDone(state, at)).length,
46761
+ all: sublayers.length
46762
+ };
46763
+ };
46764
+ ticketDone = (state, ticket) => {
46765
+ const read = ticketRead(state, ticket);
46766
+ return read.all > 0 && read.done === read.all;
46767
+ };
46768
+ setIn = (room, inset) => ({
46769
+ title: Math.max(4, room.title - inset),
46770
+ dir: Math.max(4, room.dir - inset),
46771
+ file: Math.max(4, room.file - inset)
46772
+ });
46773
+ sublayerCard = (state, index, room, shown) => {
46774
+ const inset = sublayerInset(state);
46775
+ return layerCard(state, index, setIn(room, inset), shown).map((row) => Object.assign({}, row, { inset }));
46776
+ };
46777
+ openSaid = (state, ticket) => {
46778
+ if (!ticketShut(state, ticket)) return "";
46779
+ const threads = threadsOnFiles(state, sublayersOf(ticket).flatMap((at) => layerFiles(state, at)));
46780
+ return threads.open > 0 ? ` · ${threads.open}${standMark(threads.stand)}` : "";
46781
+ };
46782
+ ticketCount = (state, ticket, room) => {
46783
+ const read = ticketRead(state, ticket);
46784
+ const said = `${counted(ticket.files.length, "file")}${linesSaid(ticket)} · ${read.done}/${read.all} parts${openSaid(state, ticket)}`;
46785
+ return textRows(firstSublayer(ticket), said, room, "count");
46786
+ };
46787
+ ticketHead = (state, ticket, room) => {
46788
+ const index = firstSublayer(ticket);
46789
+ const marked = ticketShut(state, ticket) && sublayersOf(ticket).some((at) => holdsCursor(state, at));
46790
+ return [...heldLines(ticket.title, room.title, TITLE_ROWS).map((text, at) => ({
46791
+ index,
46792
+ kind: "ticket",
46793
+ text,
46794
+ lead: at === 0,
46795
+ here: at === 0 && marked
46796
+ })), ...ticketCount(state, ticket, room.dir)];
46797
+ };
46798
+ ticketNote = (ticket, room) => ticket.note.trim().length === 0 ? [] : heldLines(ticket.note, room, NOTE_ROWS).map((text) => ({
46799
+ index: firstSublayer(ticket),
46800
+ kind: "note",
46801
+ text,
46802
+ lead: false
46803
+ }));
46804
+ ticketCard = (state, ticket, room, shown) => {
46805
+ const head = ticketHead(state, ticket, room);
46806
+ if (ticketShut(state, ticket)) return head;
46807
+ const sublayers = sublayersOf(ticket).flatMap((at) => sublayerCard(state, at, room, shown));
46808
+ return [
46809
+ ...head,
46810
+ ...ticketNote(ticket, room.file),
46811
+ ...sublayers
46812
+ ];
46813
+ };
46814
+ cardAt = (state, index, room, shown) => {
46815
+ const ticket = ticketOf(state, index);
46816
+ if (ticket === void 0) return layerCard(state, index, room, shown);
46817
+ return firstSublayer(ticket) === index ? ticketCard(state, ticket, room, shown) : [];
46818
+ };
46819
+ layerRows = (state, room, shown) => state.layers.flatMap((_, index) => {
46820
+ const card = cardAt(state, index, room, shown);
46821
+ if (card.length === 0) return [];
46822
+ return [...index > 0 ? [{
46823
+ index,
46824
+ kind: "gap",
46825
+ text: "",
46826
+ lead: false
46827
+ }] : [], ...card];
46828
+ });
46829
+ 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));
46830
+ layerFitted = (state, room, height) => {
46831
+ const every = new Set(state.layers.map((_, at) => at));
46832
+ const whole = layerRows(state, room, every);
46833
+ if (whole.length <= height) return whole;
46834
+ const shown = /* @__PURE__ */ new Set([state.layerIndex]);
46835
+ for (const at of nearFirst(state)) {
46836
+ shown.add(at);
46837
+ if (layerRows(state, room, shown).length > height) shown.delete(at);
46838
+ }
46839
+ shown.add(state.layerIndex);
46840
+ return layerRows(state, room, shown);
46841
+ };
46842
+ restingAt = (rows, height, layerIndex) => {
46843
+ const first = rows.findIndex((row) => row.index === layerIndex);
46844
+ if (first === -1) return rows.findIndex((row) => row.here === true) - Math.floor(height / 2);
46845
+ const block = rows.findLastIndex((row) => row.index === layerIndex) - first + 1;
46846
+ return block >= height ? first : first - Math.floor((height - block) / 2);
46847
+ };
46848
+ railTop = (rows, height, layerIndex, scroll) => {
46849
+ const wanted = scroll >= 0 ? scroll : restingAt(rows, height, layerIndex);
46850
+ return Math.max(0, Math.min(Math.max(0, rows.length - height), wanted));
46851
+ };
46852
+ PANE_CHROME = 3;
46853
+ layerRoomIn = (state) => {
46854
+ const whole = Math.max(8, treeWidth(state.columns) - PANE_CHROME);
46855
+ return {
46856
+ title: Math.max(4, whole - 4),
46857
+ dir: Math.max(4, whole - 6),
46858
+ file: Math.max(4, whole - 8)
46859
+ };
46860
+ };
46861
+ railWindow = (rows, height, layerIndex, scroll = -1) => {
46862
+ if (rows.length <= height) return {
46863
+ rows,
46864
+ more: 0,
46865
+ above: 0
46866
+ };
46867
+ const start = railTop(rows, height, layerIndex, scroll);
46868
+ const shown = rows.slice(start, start + height);
46869
+ const here = new Set(shown.map((row) => row.index));
46870
+ const seen = (from) => new Set(from.filter((row) => !here.has(row.index)).map((row) => row.index)).size;
46871
+ return {
46872
+ rows: shown,
46873
+ more: seen(rows.slice(start + height)),
46874
+ above: seen(rows.slice(0, start))
46875
+ };
46876
+ };
46877
+ layerContext = (current, delta) => {
46878
+ const at = CONTEXT_STEPS.indexOf(current);
46879
+ const next = Math.max(0, Math.min(CONTEXT_STEPS.length - 1, (at === -1 ? 0 : at) + delta));
46880
+ return CONTEXT_STEPS[next] ?? current;
46881
+ };
46882
+ }));
46883
+ //#endregion
46458
46884
  //#region src/tui/reduce.ts
46459
- var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, restingOn, draggedTo, pickedIn, atRow, noneLeft, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, atLayer, moveLayer, inRail, railScrolled, movePanel, layerDown, stepsToEnd, toTop, farOff, byHalf, boundedStep, PANEL_FAR, PANES, paneShown, panesShown, focusStepped, togglePanel, toggleNav, packedAway, zoom, toggleRail, foldDirectory, foldLayer, foldThreads, foldMoved, overFold, readingThread, overThread, settledOnLine, fold, moveBranch, landingOn, revealing, atTheEnd, aroundTheEnd, CAME_AROUND, moveFile$1, selectHunk, swapEnds, atBranch, grownBy, startSelection, draftMark, openCompose, outOfDiff, BACK_FROM, movedInList$1, goBack$1, walkMatches$1, openPalette, openKeys, openSettings, moveSettings, onTheEditorRow, flipSetting, moveAsk, moveRef, withChoices, withRefs, movePalette, groupedByCategory, paletteMatches, keyMatches, offered, paletteChoice, transitions, reduce, resumedAt, atFile, withContext, withFull, allRevealed, revealsAfter, gapShown, gapOpened, panBy, withRemarks, withSent, withArrived, withColumns, laidOver, onLayerHolding, 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, withAround, withNoticeHere, withNotice;
46885
+ var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, restingOn, draggedTo, pickedIn, atRow, noneLeft, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, openedOn$1, atLayer, moveLayer, inRail, railScrolled, movePanel, layerDown, stepsToEnd, toTop, farOff, byHalf, boundedStep, PANEL_FAR, PANES, paneShown, panesShown, focusStepped, togglePanel, toggleNav, packedAway, zoom, toggleRail, foldDirectory, foldSublayer, foldTicket, foldLayer, foldThreads, foldMoved, overFold, readingThread, overThread, settledOnLine, fold, moveBranch, landingOn, revealing, atTheEnd, aroundTheEnd, CAME_AROUND, moveFile$1, selectHunk, swapEnds, atBranch, grownBy, startSelection, draftMark, openCompose, outOfDiff, BACK_FROM, movedInList$1, goBack$1, walkMatches$1, openPalette, openKeys, openSettings, moveSettings, onTheEditorRow, flipSetting, moveAsk, moveRef, withChoices, withRefs, movePalette, groupedByCategory, paletteMatches, keyMatches, offered, paletteChoice, transitions, reduce, resumedAt, atFile, withContext, withFull, allRevealed, revealsAfter, gapShown, gapOpened, panBy, withRemarks, withSent, withArrived, withColumns, ticketsKept, laidOver, onLayerHolding, 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, withAround, withNoticeHere, withNotice;
46460
46886
  var init_reduce = __esmMin((() => {
46461
46887
  init_dist();
46462
46888
  init_patch();
@@ -46602,6 +47028,10 @@ var init_reduce = __esmMin((() => {
46602
47028
  pan: Math.max(0, state.pan + delta)
46603
47029
  };
46604
47030
  };
47031
+ openedOn$1 = (state, layer) => ({
47032
+ openLayers: state.openLayers.includes(layer) ? state.openLayers : [...state.openLayers, layer],
47033
+ shutTickets: state.shutTickets.filter((number) => number !== state.layers[layer]?.ticket)
47034
+ });
46605
47035
  atLayer = (state, layer) => {
46606
47036
  const landed = readingOrder(state).find((one) => one.layer === layer);
46607
47037
  if (landed === void 0) return {
@@ -46611,7 +47041,7 @@ var init_reduce = __esmMin((() => {
46611
47041
  return {
46612
47042
  ...state,
46613
47043
  layerIndex: layer,
46614
- openLayers: state.openLayers.includes(layer) ? state.openLayers : [...state.openLayers, layer],
47044
+ ...openedOn$1(state, layer),
46615
47045
  patchIndex: landed.file,
46616
47046
  top: 0,
46617
47047
  cursor: landingOn({
@@ -46631,7 +47061,7 @@ var init_reduce = __esmMin((() => {
46631
47061
  return {
46632
47062
  ...state,
46633
47063
  layerIndex: landed.layer,
46634
- openLayers: state.openLayers.includes(landed.layer) ? state.openLayers : [...state.openLayers, landed.layer],
47064
+ ...openedOn$1(state, landed.layer),
46635
47065
  patchIndex: landed.file,
46636
47066
  railScroll: -1,
46637
47067
  top: 0,
@@ -46776,13 +47206,27 @@ var init_reduce = __esmMin((() => {
46776
47206
  closed: shut ? [...closed, target] : closed
46777
47207
  };
46778
47208
  };
46779
- foldLayer = (state, shut) => {
47209
+ foldSublayer = (state, shut) => {
46780
47210
  const open = state.openLayers.filter((index) => index !== state.layerIndex);
46781
47211
  return {
46782
47212
  ...state,
46783
47213
  openLayers: shut ? open : [...open, state.layerIndex]
46784
47214
  };
46785
47215
  };
47216
+ foldTicket = (state, ticket, shut) => {
47217
+ const others = state.shutTickets.filter((number) => number !== ticket);
47218
+ return {
47219
+ ...state,
47220
+ shutTickets: shut ? [...others, ticket] : others
47221
+ };
47222
+ };
47223
+ foldLayer = (state, shut) => {
47224
+ const ticket = state.layers[state.layerIndex]?.ticket;
47225
+ if (ticket === void 0) return foldSublayer(state, shut);
47226
+ if (state.shutTickets.includes(ticket)) return shut ? state : foldTicket(state, ticket, false);
47227
+ if (shut && !state.openLayers.includes(state.layerIndex)) return foldTicket(state, ticket, true);
47228
+ return foldSublayer(state, shut);
47229
+ };
46786
47230
  foldThreads = (state, shut, ids) => {
46787
47231
  const rest = state.opened.filter((held) => !ids.includes(held));
46788
47232
  return shut ? {
@@ -46864,7 +47308,7 @@ var init_reduce = __esmMin((() => {
46864
47308
  ...state,
46865
47309
  notice: around ? CAME_AROUND[delta > 0 ? "forward" : "back"] : "",
46866
47310
  layerIndex: layer,
46867
- openLayers: state.openLayers.includes(layer) ? state.openLayers : [...state.openLayers, layer],
47311
+ ...openedOn$1(state, layer),
46868
47312
  closed: revealing(state, next),
46869
47313
  patchIndex: next,
46870
47314
  top: 0,
@@ -47293,9 +47737,13 @@ var init_reduce = __esmMin((() => {
47293
47737
  ...state,
47294
47738
  columns
47295
47739
  });
47740
+ ticketsKept = (state, told) => state.shutTickets.filter((number) => (told.tickets ?? []).some((one) => one.number === number));
47296
47741
  laidOver = (state, told, anew) => ({
47297
47742
  ...state,
47298
47743
  layers: told.layers,
47744
+ tickets: told.tickets ?? [],
47745
+ topLevel: told.topLevel,
47746
+ shutTickets: anew ? [] : ticketsKept(state, told),
47299
47747
  layersStale: told.stale,
47300
47748
  summary: told.summary ?? "",
47301
47749
  layerIndex: anew ? 0 : Math.min(state.layerIndex, Math.max(0, told.layers.length - 1)),
@@ -47308,7 +47756,7 @@ var init_reduce = __esmMin((() => {
47308
47756
  return {
47309
47757
  ...state,
47310
47758
  layerIndex: layer,
47311
- openLayers: state.openLayers.includes(layer) ? state.openLayers : [...state.openLayers, layer]
47759
+ ...openedOn$1(state, layer)
47312
47760
  };
47313
47761
  };
47314
47762
  withLayers = (state, told) => {
@@ -47475,80 +47923,6 @@ var Intent;
47475
47923
  var init_intent = __esmMin((() => {
47476
47924
  init_dist();
47477
47925
  Intent = taggedEnum();
47478
- })), shared, ring, sets, chosen, useMarks, marks, STAND_KEY, standMark;
47479
- var init_marks = __esmMin((() => {
47480
- shared = {
47481
- done: "✓",
47482
- sent: "→",
47483
- cursor: "▎",
47484
- shut: "▸",
47485
- open: "▾",
47486
- space: "·",
47487
- tab: "→"
47488
- };
47489
- ring = {
47490
- ...shared,
47491
- filed: "○",
47492
- waiting: "◎",
47493
- answered: "●",
47494
- asked: "◉",
47495
- rule: "│"
47496
- };
47497
- sets = {
47498
- ring,
47499
- bubble: {
47500
- ...shared,
47501
- filed: "◌",
47502
- waiting: "◎",
47503
- answered: "●",
47504
- asked: "◉",
47505
- rule: "┃",
47506
- cursor: "▌"
47507
- },
47508
- quote: {
47509
- ...shared,
47510
- filed: "❞",
47511
- waiting: "❟",
47512
- answered: "❠",
47513
- asked: "❝",
47514
- rule: "┊"
47515
- },
47516
- diamond: {
47517
- ...shared,
47518
- filed: "◇",
47519
- waiting: "◈",
47520
- answered: "◆",
47521
- asked: "❖",
47522
- rule: "╎"
47523
- },
47524
- dot: {
47525
- ...shared,
47526
- filed: "·",
47527
- waiting: "◎",
47528
- answered: "●",
47529
- asked: "◉",
47530
- rule: "▏"
47531
- }
47532
- };
47533
- Object.keys(sets);
47534
- chosen = ring;
47535
- useMarks = (name) => {
47536
- chosen = sets[name] ?? ring;
47537
- };
47538
- marks = () => chosen;
47539
- STAND_KEY = {
47540
- filed: "filed",
47541
- waiting: "waiting",
47542
- answered: "answered",
47543
- asked: "asked",
47544
- settled: "done",
47545
- gone: void 0
47546
- };
47547
- standMark = (stand) => {
47548
- const key = STAND_KEY[stand];
47549
- return key === void 0 ? " " : chosen[key];
47550
- };
47551
- useMarks(process.env["ADIFF_MARKS"] ?? "ring");
47552
47926
  }));
47553
47927
  //#endregion
47554
47928
  //#region src/tui/theme.ts
@@ -48761,7 +49135,7 @@ var init_chrome = __esmMin((() => {
48761
49135
  }));
48762
49136
  //#endregion
48763
49137
  //#region src/tui/treepane.ts
48764
- var INDENT_MAX, treeLabel, waitingLabel, inRange, treeMarks, treeTail, treeLine, GUTTER, DIR_LEAD, TITLE_LEAD, FILE_LEAD, STALE_ROOM, STALE_ASKING, STALE_LONG, STALE_MIDDLE, STALE_SHORT, staleSaid, staleBanner, litRow, leftOver, titlePaint, titleMark, titleLook, fileMark, fileLook, layerLook, layerGutter, layerText;
49138
+ var INDENT_MAX, treeLabel, waitingLabel, inRange, treeMarks, treeTail, treeLine, GUTTER, DIR_LEAD, TITLE_LEAD, FILE_LEAD, STALE_ROOM, STALE_ASKING, STALE_LONG, STALE_MIDDLE, STALE_SHORT, staleSaid, staleBanner, litRow, leftOver, titlePaint, titleMark, titleLook, sublayerTitleLook, ticketPaint, ticketMark, ticketLook, fileMark, fileLook, layerLook, plainLook, layerGutter, layerText;
48765
49139
  var init_treepane = __esmMin((() => {
48766
49140
  init_dist();
48767
49141
  init_layers$1();
@@ -48772,6 +49146,7 @@ var init_treepane = __esmMin((() => {
48772
49146
  init_notespane();
48773
49147
  init_panelpane();
48774
49148
  init_theme();
49149
+ init_tickets();
48775
49150
  init_words();
48776
49151
  init_chrome();
48777
49152
  INDENT_MAX = 3;
@@ -48826,13 +49201,38 @@ var init_treepane = __esmMin((() => {
48826
49201
  if (!row.lead) return " ";
48827
49202
  if (layerDone(state, row.index)) return marks().done;
48828
49203
  if (leftOver(state, row.index)) return "0";
48829
- return `${row.index + 1}`;
49204
+ return addressOf$1(state, row.index);
48830
49205
  };
48831
49206
  titleLook = (state, row) => ({
48832
49207
  lead: TITLE_LEAD,
48833
49208
  mark: titleMark(state, row),
48834
49209
  paint: titlePaint(state, row.index)
48835
49210
  });
49211
+ sublayerTitleLook = (state, row, inset) => {
49212
+ const mark = row.lead ? titleMark(state, row) : "";
49213
+ return {
49214
+ lead: TITLE_LEAD,
49215
+ mark: " ",
49216
+ paint: titlePaint(state, row.index),
49217
+ prefix: `${mark.padEnd(inset - 1)} `
49218
+ };
49219
+ };
49220
+ ticketPaint = (state, row) => {
49221
+ const ticket = ticketOf(state, row.index);
49222
+ if (ticket === void 0) return palette.muted;
49223
+ if (sublayersOf(ticket).includes(state.layerIndex)) return palette.ink;
49224
+ return ticketDone(state, ticket) ? palette.faint : palette.muted;
49225
+ };
49226
+ ticketMark = (state, row) => {
49227
+ const ticket = ticketOf(state, row.index);
49228
+ if (!row.lead || ticket === void 0) return " ";
49229
+ return ticketDone(state, ticket) ? marks().done : ticket.address;
49230
+ };
49231
+ ticketLook = (state, row) => ({
49232
+ lead: TITLE_LEAD,
49233
+ mark: ticketMark(state, row),
49234
+ paint: ticketPaint(state, row)
49235
+ });
48836
49236
  fileMark = (state, row) => {
48837
49237
  const threads = row.fileIndex === void 0 ? void 0 : threadsOn(state, row.fileIndex);
48838
49238
  if (threads !== void 0 && threads.open > 0) return standMark(threads.stand);
@@ -48844,6 +49244,15 @@ var init_treepane = __esmMin((() => {
48844
49244
  paint: row.reviewed === true ? palette.added : palette.ink
48845
49245
  });
48846
49246
  layerLook = (state, row) => {
49247
+ const look = plainLook(state, row);
49248
+ const inset = row.inset ?? 0;
49249
+ if (inset === 0) return look;
49250
+ return row.kind === "title" ? sublayerTitleLook(state, row, inset) : {
49251
+ ...look,
49252
+ lead: look.lead + inset
49253
+ };
49254
+ };
49255
+ plainLook = (state, row) => {
48847
49256
  switch (row.kind) {
48848
49257
  case "file": return fileLook(state, row);
48849
49258
  case "dir": return {
@@ -48867,13 +49276,14 @@ var init_treepane = __esmMin((() => {
48867
49276
  paint: palette.muted
48868
49277
  };
48869
49278
  case "title": return titleLook(state, row);
49279
+ case "ticket": return ticketLook(state, row);
48870
49280
  default: return absurd(row.kind);
48871
49281
  }
48872
49282
  };
48873
49283
  layerGutter = (row, look) => {
48874
49284
  return `${row.here === true ? marks().cursor : " "}${look.mark.padStart(GUTTER - 1)}`;
48875
49285
  };
48876
- layerText = (row, look, room) => row.kind === "gap" ? "" : `${layerGutter(row, look)}${" ".repeat(look.lead - GUTTER)}${row.text}`.padEnd(room.title + TITLE_LEAD);
49286
+ layerText = (row, look, room) => row.kind === "gap" ? "" : `${layerGutter(row, look)}${" ".repeat(look.lead - GUTTER)}${look.prefix ?? ""}${row.text}`.padEnd(room.title + TITLE_LEAD);
48877
49287
  })), BRANCH_NAME_MIN, BRANCH_FIXED, STATE_MIN, EMPTY_LIST, homeWidth, longestName, longestState, shortPath, elide, SUMMARY_LINES, summaryLines, contextLabel, nameRoom, stateRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, whosePull, stateCell, branchCells, placeLabel, pullLabel, headerParts, panLabel, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope;
48878
49288
  var init_home = __esmMin((() => {
48879
49289
  init_cursor();
@@ -48884,6 +49294,7 @@ var init_home = __esmMin((() => {
48884
49294
  init_notespane();
48885
49295
  init_state();
48886
49296
  init_theme();
49297
+ init_tickets();
48887
49298
  init_treepane();
48888
49299
  init_words();
48889
49300
  init_chrome();
@@ -48964,6 +49375,8 @@ var init_home = __esmMin((() => {
48964
49375
  state: ""
48965
49376
  });
48966
49377
  placeLabel = (state) => {
49378
+ const inLayer = fileInLayerSaid(state);
49379
+ if (inLayer.length > 0) return inLayer;
48967
49380
  const place = filePlace(state);
48968
49381
  return `file ${place.at} of ${place.of}`;
48969
49382
  };
@@ -48974,6 +49387,7 @@ var init_home = __esmMin((() => {
48974
49387
  headerParts = (state, branch, path, across) => [
48975
49388
  branch,
48976
49389
  path,
49390
+ layerPlaceSaid(state),
48977
49391
  state.patches.length === 0 ? "nothing to read" : placeLabel(state),
48978
49392
  pullLabel(state),
48979
49393
  state.vouched.length === 0 ? "" : reviewedCount(state),
@@ -52227,13 +52641,13 @@ var init_report = __esmMin((() => {
52227
52641
  return away.length === 0 ? "every preference at its default" : away.map((one) => one.name).join(", ");
52228
52642
  };
52229
52643
  standingOn = (state) => {
52230
- if (!state.reportFull) return `standing on layer ${state.layerIndex + 1}`;
52644
+ if (!state.reportFull) return `standing on layer ${state.layers[state.layerIndex]?.address ?? "none"}`;
52231
52645
  return `standing on \`${state.layers[state.layerIndex]?.title ?? "none"}\``;
52232
52646
  };
52233
52647
  layersLine = (state) => {
52234
52648
  if (state.layers.length === 0) return "- no reading order on this branch";
52235
52649
  const spans = state.layers.reduce((sum, layer) => sum + layer.spans.length, 0);
52236
- return `- reading order: ${counted(state.layers.length, "layer")} over ${counted(spans, "span")}, rail on ${state.rail}, ${state.layersStale ? "stale" : "current"}, ${standingOn(state)}`;
52650
+ return `- reading order: ${counted(state.topLevel, "layer")} over ${counted(spans, "span")}, rail on ${state.rail}, ${state.layersStale ? "stale" : "current"}, ${standingOn(state)}`;
52237
52651
  };
52238
52652
  remarksLine = (state) => {
52239
52653
  if (!state.remarksOn) return "- the pull request's remarks are off";
@@ -52664,7 +53078,7 @@ var init_threads = __esmMin((() => {
52664
53078
  }));
52665
53079
  //#endregion
52666
53080
  //#region src/tui/vouching.ts
52667
- var alongFrom, markedIs, vouch, layerAsked, threadsToAsk, tookTheAnswer, settleThese, marking, markedSaid, movedOn, readHere, partHereNow, vouching;
53081
+ var alongFrom, markedIs, vouch, layerAsked, threadsToAsk, tookTheAnswer, settleThese, marking, markedSaid, finishedSaid, movedOn, readHere, partHereNow, vouching;
52668
53082
  var init_vouching = __esmMin((() => {
52669
53083
  init_dist();
52670
53084
  init_reduce();
@@ -52672,6 +53086,8 @@ var init_vouching = __esmMin((() => {
52672
53086
  init_notes();
52673
53087
  init_state();
52674
53088
  init_words();
53089
+ init_layerview();
53090
+ init_tickets();
52675
53091
  init_review();
52676
53092
  init_reading();
52677
53093
  alongFrom = (state) => {
@@ -52748,26 +53164,38 @@ var init_vouching = __esmMin((() => {
52748
53164
  if (branch === void 0) return;
52749
53165
  const report = yield* vouching(app, branch.branch, asked.path);
52750
53166
  const next = withVouched(app.state, report.vouched, report.parts);
53167
+ const finished = finishedSaid(app.state, next);
52751
53168
  if (!asked.advance) {
52752
- app.commit(withNotice(next, markedSaid(app, report, asked)));
53169
+ app.commit(withNotice(next, `${markedSaid(app, report, asked)}${finished}`));
52753
53170
  return;
52754
53171
  }
52755
- movedOn(app, next, asked.named, asked.settled);
53172
+ movedOn(app, next, {
53173
+ ...asked,
53174
+ finished
53175
+ });
52756
53176
  });
52757
53177
  };
52758
53178
  markedSaid = (app, report, asked) => {
52759
53179
  const part = partHereNow(app);
52760
53180
  return (part === void 0 ? report.vouched.includes(asked.path) : report.parts.includes(part)) ? markedIs(asked.named, asked.settled) : `unmarked ${asked.named}`;
52761
53181
  };
52762
- movedOn = (app, next, path, settled) => {
52763
- const said = markedIs(path, settled);
53182
+ finishedSaid = (before, after) => {
53183
+ const at = after.layerIndex;
53184
+ if (!onLayers(after) || layerDone(before, at) || !layerDone(after, at)) return "";
53185
+ if (after.layers[at]?.unclaimed === true) return "";
53186
+ const ticket = ticketOf(after, at);
53187
+ if (ticket !== void 0 && ticketDone(after, ticket)) return ` · Layer ${ticket.address} read${nextLayerSaid(after, lastSublayer(ticket) + 1)}`;
53188
+ return ` · Layer ${addressOf$1(after, at)} read${nextLayerSaid(after, at + 1)}`;
53189
+ };
53190
+ movedOn = (app, next, moved) => {
53191
+ const said = markedIs(moved.named, moved.settled);
52764
53192
  const target = nextUnreviewed(next, next.patchIndex);
52765
53193
  if (target === void 0) {
52766
- const done = settled === 0 ? "every file reviewed" : `${said}, and every file reviewed`;
53194
+ const done = moved.settled === 0 ? "every file reviewed" : `${said}, and every file reviewed`;
52767
53195
  app.commit(withNotice(next, done));
52768
53196
  return;
52769
53197
  }
52770
- app.commit(withNotice(atFile(next, target), said));
53198
+ app.commit(withNotice(atFile(next, target), `${said}${moved.finished}`));
52771
53199
  };
52772
53200
  readHere = (app) => {
52773
53201
  return onLayers(app.state) ? readIn(app.state, app.state.layerIndex, app.state.patchIndex) : isReviewed(app.state, app.state.patchIndex);
@@ -53769,7 +54197,7 @@ const vouched = fn("Main.vouched")(function* (options) {
53769
54197
  at: options["at"]
53770
54198
  };
53771
54199
  if (options["layer"] === void 0) return yield* toggle(reading, file, marking);
53772
- return yield* vouchIn(reading, file, yield* numeric(options, "layer"), marking);
54200
+ return yield* vouchAt(reading, file, yield* layerAddress(options, "layer"), marking);
53773
54201
  });
53774
54202
  const fileReview = fn("Main.fileReview")(function* (options) {
53775
54203
  const report = yield* vouched(options);