@eliya-oss/agent-diff 0.1.0-alpha.67 → 0.1.0-alpha.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -6473,9 +6473,10 @@ var init_SchemaAST = __esmMin((() => {
6473
6473
  }));
6474
6474
  //#endregion
6475
6475
  //#region node_modules/.pnpm/effect@4.0.0-rc.110/node_modules/effect/dist/Fiber.js
6476
- var interrupt;
6476
+ var await_, interrupt;
6477
6477
  var init_Fiber = __esmMin((() => {
6478
6478
  init_effect();
6479
+ await_ = fiberAwait;
6479
6480
  interrupt = fiberInterrupt;
6480
6481
  }));
6481
6482
  //#endregion
@@ -8586,24 +8587,6 @@ var init_git = __esmMin((() => {
8586
8587
  init_error$3();
8587
8588
  }));
8588
8589
  //#endregion
8589
- //#region src/domain/review/lifecycle.ts
8590
- var commentOn, stage, submitAll;
8591
- var init_lifecycle = __esmMin((() => {
8592
- init_dist();
8593
- commentOn = (id, anchor, body) => ({
8594
- id,
8595
- anchor,
8596
- body,
8597
- state: "draft",
8598
- reply: none()
8599
- });
8600
- stage = (staged, comment) => [...staged, comment];
8601
- submitAll = (staged) => staged.map((comment) => ({
8602
- ...comment,
8603
- state: "submitted"
8604
- }));
8605
- }));
8606
- //#endregion
8607
8590
  //#region src/domain/review/vouch.ts
8608
8591
  var isVouched, vouch;
8609
8592
  var init_vouch = __esmMin((() => {
@@ -8626,7 +8609,7 @@ var init_model$3 = __esmMin((() => {
8626
8609
  //#endregion
8627
8610
  //#region src/domain/review/index.ts
8628
8611
  var init_review = __esmMin((() => {
8629
- init_lifecycle();
8612
+ init_dist();
8630
8613
  init_vouch();
8631
8614
  init_model$3();
8632
8615
  }));
@@ -8645,7 +8628,6 @@ var init_model$2 = __esmMin((() => {
8645
8628
  emptyBranchState = {
8646
8629
  vouches: {},
8647
8630
  consumed: 0,
8648
- pending: [],
8649
8631
  settled: {},
8650
8632
  removed: {},
8651
8633
  base: "",
@@ -8687,7 +8669,6 @@ var init_schema = __esmMin((() => {
8687
8669
  BranchState = Struct({
8688
8670
  vouches: optionalKey(Record(String$1, String$1)),
8689
8671
  consumed: optionalKey(Int),
8690
- pending: optionalKey(ArraySchema(StoredComment)),
8691
8672
  settled: optionalKey(Record(String$1, String$1)),
8692
8673
  removed: optionalKey(Record(String$1, String$1)),
8693
8674
  base: optionalKey(String$1),
@@ -8811,53 +8792,22 @@ var init_service$1 = __esmMin((() => {
8811
8792
  parent: held.parent
8812
8793
  };
8813
8794
  });
8814
- cursorOps = (state, saveState, inbox, spoken) => {
8815
- return {
8816
- stage: fn("Store.stage")(function* (worktreePath, comment) {
8817
- const current = yield* state(worktreePath);
8818
- const pending = [...current.pending, comment];
8819
- yield* saveState(worktreePath, {
8820
- ...current,
8821
- pending
8822
- });
8823
- return pending;
8824
- }),
8825
- restage: fn("Store.restage")(function* (worktreePath, comment) {
8826
- const current = yield* state(worktreePath);
8827
- if (!current.pending.some((entry) => entry.id === comment.id)) return none();
8828
- const pending = current.pending.map((entry) => entry.id === comment.id ? comment : entry);
8829
- yield* saveState(worktreePath, {
8830
- ...current,
8831
- pending
8832
- });
8833
- return some(pending);
8834
- }),
8835
- unstage: fn("Store.unstage")(function* (worktreePath, id) {
8836
- const current = yield* state(worktreePath);
8837
- if (!current.pending.some((entry) => entry.id === id)) return none();
8838
- const pending = current.pending.filter((entry) => entry.id !== id);
8839
- yield* saveState(worktreePath, {
8840
- ...current,
8841
- pending
8842
- });
8843
- return some(pending);
8844
- }),
8845
- take: fn("Store.take")(function* (worktreePath) {
8846
- const batches = yield* inbox(worktreePath);
8847
- const current = yield* state(worktreePath);
8848
- const answered = new Set((yield* spoken(worktreePath)).map((entry) => entry.comment));
8849
- const owed = (comment) => !answered.has(comment.id) && !Object.hasOwn(current.settled, comment.id) && !Object.hasOwn(current.removed, comment.id);
8850
- return batches.flatMap((batch) => {
8851
- const comments = batch.comments.filter(owed);
8852
- return comments.length === 0 ? [] : [{
8853
- id: batch.id,
8854
- at: batch.at,
8855
- head: batch.head,
8856
- comments
8857
- }];
8858
- });
8859
- })
8860
- };
8795
+ cursorOps = (state, inbox, spoken) => {
8796
+ return { take: fn("Store.take")(function* (worktreePath) {
8797
+ const batches = yield* inbox(worktreePath);
8798
+ const current = yield* state(worktreePath);
8799
+ const answered = new Set((yield* spoken(worktreePath)).map((entry) => entry.comment));
8800
+ const owed = (comment) => !answered.has(comment.id) && !Object.hasOwn(current.settled, comment.id) && !Object.hasOwn(current.removed, comment.id);
8801
+ return batches.flatMap((batch) => {
8802
+ const comments = batch.comments.filter(owed);
8803
+ return comments.length === 0 ? [] : [{
8804
+ id: batch.id,
8805
+ at: batch.at,
8806
+ head: batch.head,
8807
+ comments
8808
+ }];
8809
+ });
8810
+ }) };
8861
8811
  };
8862
8812
  settingsOps = (root) => {
8863
8813
  return {
@@ -9050,7 +9000,7 @@ var init_service$1 = __esmMin((() => {
9050
9000
  const { submit, inbox } = inboxOps(root);
9051
9001
  const { state, saveState } = stateOps(root);
9052
9002
  const talk = answerOps(root);
9053
- const cursors = cursorOps(state, saveState, inbox, talk.answers);
9003
+ const cursors = cursorOps(state, inbox, talk.answers);
9054
9004
  return {
9055
9005
  root,
9056
9006
  branchAt: (worktreePath) => promise(() => headOf$1(worktreePath)),
@@ -9079,7 +9029,7 @@ var init_store = __esmMin((() => {
9079
9029
  }));
9080
9030
  //#endregion
9081
9031
  //#region src/cli/error.ts
9082
- var UnknownBranch, UnknownBase, UnknownFile, UnknownComment, UnselectableRange, UnknownCommand, MissingOption, EmptyReview, UnknownWorktree, MalformedLayers, NoLayers, InitUnwritable;
9032
+ var UnknownBranch, UnknownBase, UnknownFile, UnknownComment, UnselectableRange, UnknownCommand, MissingOption, UnknownWorktree, MalformedLayers, NoLayers, InitUnwritable;
9083
9033
  var init_error$1 = __esmMin((() => {
9084
9034
  init_dist();
9085
9035
  UnknownBranch = class extends TaggedError("UnknownBranch") {};
@@ -9089,7 +9039,6 @@ var init_error$1 = __esmMin((() => {
9089
9039
  UnselectableRange = class extends TaggedError("UnselectableRange") {};
9090
9040
  UnknownCommand = class extends TaggedError("UnknownCommand") {};
9091
9041
  MissingOption = class extends TaggedError("MissingOption") {};
9092
- EmptyReview = class extends TaggedError("EmptyReview") {};
9093
9042
  UnknownWorktree = class extends TaggedError("UnknownWorktree") {};
9094
9043
  MalformedLayers = class extends TaggedError("MalformedLayers") {};
9095
9044
  NoLayers = class extends TaggedError("NoLayers") {};
@@ -9097,7 +9046,7 @@ var init_error$1 = __esmMin((() => {
9097
9046
  }));
9098
9047
  //#endregion
9099
9048
  //#region src/cli/commands.ts
9100
- var CONTEXT, WHOLE_FILE$1, POLL, AUTO, askedFor, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, rowsCovering, waitingOn, listBranches, blobOf, toggleVouch, reviewProgress, anchorRequest, stageComment, editStaged, dropStaged, listPending, bodyOf, sentOf, listSent, submitReview, submitComment, listPatches, flatten, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, saveWrap, setBase, clearBase, markRead;
9049
+ var CONTEXT, WHOLE_FILE$1, POLL, AUTO, askedFor, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, rowsCovering, waitingOn, listBranches, blobOf, toggleVouch, reviewProgress, bodyOf, sentOf, listSent, submitComment, listPatches, flatten, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, saveWrap, setBase, clearBase, markRead;
9101
9050
  var init_commands = __esmMin((() => {
9102
9051
  init_dist();
9103
9052
  init_patch();
@@ -9191,11 +9140,9 @@ var init_commands = __esmMin((() => {
9191
9140
  })).map((row) => row.index);
9192
9141
  waitingOn = fn("Cli.waitingOn")(function* (worktree) {
9193
9142
  const store = yield* Store;
9194
- const state = yield* store.state(worktree.path);
9195
9143
  const owed = yield* store.take(worktree.path);
9196
9144
  const told = yield* store.layers(worktree.path);
9197
9145
  return {
9198
- staged: state.pending.length,
9199
9146
  unread: owed.reduce((total, batch) => total + batch.comments.length, 0),
9200
9147
  layers: match$3(told, {
9201
9148
  onNone: () => 0,
@@ -9223,7 +9170,6 @@ var init_commands = __esmMin((() => {
9223
9170
  files: stat.files,
9224
9171
  added: stat.added,
9225
9172
  removed: stat.removed,
9226
- staged: waiting.staged,
9227
9173
  unread: waiting.unread,
9228
9174
  layers: waiting.layers,
9229
9175
  stale: waiting.stale,
@@ -9270,77 +9216,8 @@ var init_commands = __esmMin((() => {
9270
9216
  path: patch.path,
9271
9217
  blob: patch.blob
9272
9218
  })).filter((file) => isVouched(current.vouches, file.path, file.blob)).map((f) => f.path),
9273
- total: patches.length,
9274
- pending: current.pending.length
9275
- };
9276
- });
9277
- anchorRequest = fn("Cli.anchorRequest")(function* (request) {
9278
- const worktree = yield* findBranch(request.repo, request.branch);
9279
- const patches = yield* patchesOf(worktree, WHOLE_FILE$1);
9280
- const resolved = yield* match$3(findPatch(patches, request.file), {
9281
- onNone: () => new UnknownFile({
9282
- file: request.file,
9283
- known: patches.map((candidate) => candidate.path)
9284
- }),
9285
- onSome: succeed$1
9286
- });
9287
- const rows = rowsCovering(resolved, request.side, request.start, request.end);
9288
- const first = rows[0];
9289
- const last = rows.at(-1);
9290
- const found = first === void 0 || last === void 0 ? none() : anchorFor(resolved, first, last);
9291
- return {
9292
- worktree,
9293
- anchor: yield* match$3(found, {
9294
- onNone: () => new UnselectableRange({
9295
- file: request.file,
9296
- start: request.start,
9297
- end: request.end
9298
- }),
9299
- onSome: succeed$1
9300
- })
9301
- };
9302
- });
9303
- stageComment = fn("Cli.stageComment")(function* (request) {
9304
- const store = yield* Store;
9305
- const { worktree, anchor } = yield* anchorRequest(request);
9306
- const first = stage([], commentOn(request.id, anchor, request.body))[0];
9307
- const entry = {
9308
- id: request.id,
9309
- anchor,
9310
- body: first === void 0 ? request.body : first.body
9219
+ total: patches.length
9311
9220
  };
9312
- return { pending: (yield* store.stage(worktree.path, entry)).length };
9313
- });
9314
- editStaged = fn("Cli.editStaged")(function* (request) {
9315
- const store = yield* Store;
9316
- const worktree = yield* findBranch(request.repo, request.branch);
9317
- const current = yield* store.state(worktree.path);
9318
- const found = current.pending.find((entry) => entry.id === request.id);
9319
- if (found === void 0) return yield* new UnknownComment({ id: request.id });
9320
- const pending = yield* store.restage(worktree.path, {
9321
- ...found,
9322
- body: request.body
9323
- });
9324
- return { pending: getOrElse(pending, () => current.pending).length };
9325
- });
9326
- dropStaged = fn("Cli.dropStaged")(function* (repo, branch, id) {
9327
- const store = yield* Store;
9328
- const worktree = yield* findBranch(repo, branch);
9329
- const pending = yield* store.unstage(worktree.path, id);
9330
- if (isNone(pending)) return yield* new UnknownComment({ id });
9331
- return { pending: pending.value.length };
9332
- });
9333
- listPending = fn("Cli.listPending")(function* (repo, branch) {
9334
- const store = yield* Store;
9335
- const worktree = yield* findBranch(repo, branch);
9336
- return (yield* store.state(worktree.path)).pending.map((entry) => ({
9337
- id: entry.id,
9338
- file: entry.anchor.path,
9339
- side: entry.anchor.side,
9340
- start: entry.anchor.start,
9341
- end: entry.anchor.end,
9342
- body: entry.body
9343
- }));
9344
9221
  });
9345
9222
  bodyOf = (entry) => entry.body;
9346
9223
  sentOf = (comment, reading) => {
@@ -9375,29 +9252,6 @@ var init_commands = __esmMin((() => {
9375
9252
  read: current.read
9376
9253
  }));
9377
9254
  });
9378
- submitReview = fn("Cli.submitReview")(function* (repo, branch, id, at) {
9379
- const store = yield* Store;
9380
- const worktree = yield* findBranch(repo, branch);
9381
- const current = yield* store.state(worktree.path);
9382
- if (current.pending.length === 0) return yield* new EmptyReview({ branch });
9383
- const comments = submitAll(current.pending.map((entry) => commentOn(entry.id, entry.anchor, entry.body))).map((comment) => ({
9384
- id: comment.id,
9385
- anchor: comment.anchor,
9386
- body: comment.body
9387
- }));
9388
- const batch = {
9389
- id,
9390
- at,
9391
- head: worktree.head,
9392
- comments
9393
- };
9394
- yield* store.submit(worktree.path, batch);
9395
- yield* store.saveState(worktree.path, {
9396
- ...current,
9397
- pending: []
9398
- });
9399
- return { submitted: comments.length };
9400
- });
9401
9255
  submitComment = fn("Cli.submitComment")(function* (request) {
9402
9256
  const store = yield* Store;
9403
9257
  const worktree = yield* findBranch(request.repo, request.branch);
@@ -9796,7 +9650,7 @@ var init_pane = __esmMin((() => {
9796
9650
  init_commands();
9797
9651
  init_init();
9798
9652
  init_pane();
9799
- var version$1 = "0.1.0-alpha.67";
9653
+ var version$1 = "0.1.0-alpha.68";
9800
9654
  //#endregion
9801
9655
  //#region src/cli/upgrade.ts
9802
9656
  var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, runUpgrade, statusOf$1, sayFound, sayDone, attempted, REFRESH_MS, refreshSkills, updatedIn, sayRefreshed, upgradeReport;
@@ -10365,7 +10219,7 @@ var init_layers = __esmMin((() => {
10365
10219
  }));
10366
10220
  //#endregion
10367
10221
  //#region src/cli/threads.ts
10368
- var stateOf$1, spoken$1, threadOf, threadsIn, idsIn, isKnown, stagedOf, listThreads, answerComment, settleThread, removeComment, without, restoreComment, settleRead;
10222
+ var stateOf$1, spoken$1, threadOf, threadsIn, idsIn, isKnown, listThreads, answerComment, settleThread, removeComment, without, restoreComment, settleRead;
10369
10223
  var init_threads = __esmMin((() => {
10370
10224
  init_dist();
10371
10225
  init_store();
@@ -10406,31 +10260,18 @@ var init_threads = __esmMin((() => {
10406
10260
  const store = yield* Store;
10407
10261
  return idsIn(yield* store.inbox(worktreePath)).includes(id);
10408
10262
  });
10409
- stagedOf = (entry) => ({
10410
- id: entry.id,
10411
- file: entry.anchor.path,
10412
- side: entry.anchor.side,
10413
- start: entry.anchor.start,
10414
- end: entry.anchor.end,
10415
- body: entry.body,
10416
- state: "staged",
10417
- stale: false,
10418
- outside: false,
10419
- unread: 0,
10420
- answers: []
10421
- });
10422
10263
  listThreads = fn("Cli.listThreads")(function* (repo, branch, base) {
10423
10264
  const store = yield* Store;
10424
10265
  const worktree = yield* findBranch(repo, branch, base);
10425
10266
  const current = yield* store.state(worktree.path);
10426
- return [...threadsIn(yield* store.inbox(worktree.path), {
10267
+ return threadsIn(yield* store.inbox(worktree.path), {
10427
10268
  answers: yield* store.answers(worktree.path),
10428
10269
  settled: current.settled,
10429
10270
  removed: current.removed,
10430
10271
  head: worktree.head,
10431
10272
  shown: new Set((yield* patchesOf(worktree)).map((patch) => patch.path)),
10432
10273
  read: current.read
10433
- }), ...current.pending.map(stagedOf)];
10274
+ });
10434
10275
  });
10435
10276
  answerComment = fn("Cli.answerComment")(function* (request) {
10436
10277
  const store = yield* Store;
@@ -10463,14 +10304,6 @@ var init_threads = __esmMin((() => {
10463
10304
  const store = yield* Store;
10464
10305
  const worktree = yield* findBranch(repo, branch);
10465
10306
  const current = yield* store.state(worktree.path);
10466
- if (current.pending.some((entry) => entry.id === id)) {
10467
- const pending = yield* store.unstage(worktree.path, id);
10468
- if (isNone(pending)) return yield* new UnknownComment({ id });
10469
- return {
10470
- removed: id,
10471
- staged: true
10472
- };
10473
- }
10474
10307
  if (!(yield* isKnown(worktree.path, id))) return yield* new UnknownComment({ id });
10475
10308
  yield* store.saveState(worktree.path, {
10476
10309
  ...current,
@@ -10479,10 +10312,7 @@ var init_threads = __esmMin((() => {
10479
10312
  [id]: at
10480
10313
  }
10481
10314
  });
10482
- return {
10483
- removed: id,
10484
- staged: false
10485
- };
10315
+ return { removed: id };
10486
10316
  });
10487
10317
  without = (entries, id) => Object.fromEntries(Object.entries(entries).filter(([key]) => key !== id));
10488
10318
  restoreComment = fn("Cli.restoreComment")(function* (repo, branch, id) {
@@ -10714,53 +10544,9 @@ var init_catalog = __esmMin((() => {
10714
10544
  dataKey: "reviewed",
10715
10545
  example: "adiff review progress --repo . --branch cdr-1"
10716
10546
  },
10717
- {
10718
- name: "comment stage",
10719
- about: "Put a comment in the review, to go out when `review send` sends it",
10720
- group: WRITE_COMMENTS,
10721
- addresses: "review",
10722
- safety: "write",
10723
- options: [...addressing, ...range],
10724
- dataKey: "pending",
10725
- example: "adiff comment stage --repo . --branch cdr-1 --file src/api.ts --start 4 --end 4 --body \"why\""
10726
- },
10727
- {
10728
- name: "comment edit",
10729
- about: "Reword a staged comment. It keeps its id and the lines it was written against",
10730
- group: WRITE_COMMENTS,
10731
- addresses: "review",
10732
- safety: "write",
10733
- options: [
10734
- ...addressing,
10735
- {
10736
- name: "id",
10737
- required: true,
10738
- value: "id",
10739
- about: "The staged comment, as `review progress` reported it"
10740
- },
10741
- {
10742
- name: "body",
10743
- required: true,
10744
- value: "text",
10745
- about: "What it should say instead"
10746
- }
10747
- ],
10748
- dataKey: "pending",
10749
- example: "adiff comment edit --repo . --branch cdr-1 --id c1 --body \"why is this unused\""
10750
- },
10751
- {
10752
- name: "review send",
10753
- about: "Send the staged comments as one review, so the agent wakes once",
10754
- group: WRITE_COMMENTS,
10755
- addresses: "review",
10756
- safety: "write",
10757
- options: [...addressing],
10758
- dataKey: "sent",
10759
- example: "adiff review send --repo . --branch cdr-1"
10760
- },
10761
10547
  {
10762
10548
  name: "comment send",
10763
- about: "Send one comment against a line range now, without staging it first",
10549
+ about: "Send one comment against a line range, straight to the agent",
10764
10550
  group: WRITE_COMMENTS,
10765
10551
  addresses: "review",
10766
10552
  safety: "write",
@@ -10865,7 +10651,7 @@ var init_catalog = __esmMin((() => {
10865
10651
  },
10866
10652
  {
10867
10653
  name: "comment remove",
10868
- about: "Take a comment out of the review, whether it was staged or already sent",
10654
+ about: "Take a comment out of the review, leaving what was already delivered on the record",
10869
10655
  group: FOLLOW_UP,
10870
10656
  addresses: "review",
10871
10657
  safety: "write",
@@ -11027,11 +10813,6 @@ var init_report$1 = __esmMin((() => {
11027
10813
  suggestion: "The error lists the files this branch changed. Use one of those paths.",
11028
10814
  retriable: false
11029
10815
  },
11030
- EmptyReview: {
11031
- exit: 2,
11032
- suggestion: "Stage a comment with `adiff comment stage` before submitting the review.",
11033
- retriable: false
11034
- },
11035
10816
  UnknownWorktree: {
11036
10817
  exit: 3,
11037
10818
  suggestion: "--worktree takes the path of a worktree of the repository under review. The error lists the ones that exist; pass one of those, or run the command from inside it with `--worktree .`.",
@@ -11592,7 +11373,7 @@ var init_tree = __esmMin((() => {
11592
11373
  return node.children.reduce((total, child) => total + filesUnder(tree, child), 0);
11593
11374
  };
11594
11375
  crowdedDirectories = (tree, limit) => tree.nodes.filter((node) => node.kind === "directory" && directFiles(tree, node.id) > limit).map((node) => node.path);
11595
- })), nothingReviewed, initialState, TREE_MAX, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, NO_NOTE, noteRows$1, proseRow, proseRows$1, titleRows, clipEnd, FILE_LEAD, fileRows, layerRows, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, kept, treeOf, reviewedCountIn, treeRows, crowdedOf, foldersOfFile, isReviewed, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, caretAt, drafted, WORD, wordLeft, wordRight, caretByWord, lineStart, lineEnd, caretToEdge, editedComment, composeTarget, selectedLines, KEYWORDS, NAME, longestName$1, searchTerm, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersIn, newerOf, sectionOf, sentEntry, panelEntries, panelEntry, threadChosen, spokenSince, hunkStarts, changeAround, nextUnreviewed, reviewedCount, fileOrder, layerFile, selectionRange;
11376
+ })), nothingReviewed, initialState, TREE_MAX, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, NO_NOTE, noteRows$1, proseRow, proseRows$1, titleRows, clipEnd, FILE_LEAD, fileRows, layerRows, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, kept, treeOf, reviewedCountIn, treeRows, crowdedOf, foldersOfFile, isReviewed, treeStart, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, caretAt, drafted, WORD, wordLeft, wordRight, caretByWord, lineStart, lineEnd, caretToEdge, composeTarget, selectedLines, KEYWORDS, NAME, longestName$1, searchTerm, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersIn, newerOf, sectionOf, sentEntry, panelEntries, panelEntry, threadChosen, spokenSince, hunkStarts, changeAround, nextUnreviewed, reviewedCount, fileOrder, layerFile, selectionRange;
11596
11377
  var init_model = __esmMin((() => {
11597
11378
  init_dist();
11598
11379
  init_patch();
@@ -11608,7 +11389,9 @@ var init_model = __esmMin((() => {
11608
11389
  hideReviewed: false,
11609
11390
  newestFirst: true,
11610
11391
  tallest: 0,
11611
- scroll: -1
11392
+ scroll: -1,
11393
+ railRows: 12,
11394
+ railScroll: -1
11612
11395
  };
11613
11396
  initialState = (branches) => ({
11614
11397
  ...nothingReviewed,
@@ -11631,11 +11414,7 @@ var init_model = __esmMin((() => {
11631
11414
  returnTo: "branches",
11632
11415
  closed: [],
11633
11416
  vouched: [],
11634
- staged: 0,
11635
- pending: [],
11636
11417
  sent: [],
11637
- pendingIndex: 0,
11638
- editing: void 0,
11639
11418
  viewport: 20,
11640
11419
  context: 3,
11641
11420
  contextWas: 3,
@@ -11801,15 +11580,21 @@ var init_model = __esmMin((() => {
11801
11580
  const patch = state.patches[fileIndex];
11802
11581
  return patch !== void 0 && state.vouched.includes(patch.path);
11803
11582
  };
11583
+ treeStart = (state, height) => {
11584
+ const rows = treeRows(state);
11585
+ if (rows.length <= height) return 0;
11586
+ const last = rows.length - height;
11587
+ if (state.railScroll >= 0) return Math.min(state.railScroll, last);
11588
+ const here = rows.findIndex((row) => row.fileIndex === state.patchIndex);
11589
+ return Math.max(0, Math.min(last, (here === -1 ? 0 : here) - Math.floor(height / 2)));
11590
+ };
11804
11591
  treeWindow = (state, height) => {
11805
11592
  const rows = treeRows(state);
11806
11593
  if (rows.length <= height) return {
11807
11594
  rows,
11808
11595
  more: 0
11809
11596
  };
11810
- const here = rows.findIndex((row) => row.fileIndex === state.patchIndex);
11811
- const anchor = here === -1 ? 0 : here;
11812
- const start = Math.max(0, Math.min(rows.length - height, anchor - Math.floor(height / 2)));
11597
+ const start = treeStart(state, height);
11813
11598
  return {
11814
11599
  rows: rows.slice(start, start + height),
11815
11600
  more: rows.length - (start + height)
@@ -11818,13 +11603,13 @@ var init_model = __esmMin((() => {
11818
11603
  commentsOn = (state, fileIndex) => {
11819
11604
  const patch = state.patches[fileIndex];
11820
11605
  if (patch === void 0) return 0;
11821
- return state.pending.filter((entry) => entry.file === patch.path).length;
11606
+ return state.sent.filter((entry) => entry.file === patch.path).length;
11822
11607
  };
11823
11608
  hiddenLines = (state) => shownOf(state)?.gaps.reduce((total, gap) => total + gap.hidden, 0) ?? 0;
11824
11609
  markedRows = (state) => {
11825
11610
  const patch = selectedPatch(state);
11826
11611
  if (patch === void 0) return /* @__PURE__ */ new Set();
11827
- const rows = state.pending.filter((entry) => entry.file === patch.path).flatMap((entry) => patch.rows.filter((row) => match$3(row.newLine, {
11612
+ const rows = state.sent.filter((entry) => entry.file === patch.path).flatMap((entry) => patch.rows.filter((row) => match$3(row.newLine, {
11828
11613
  onNone: () => false,
11829
11614
  onSome: (line) => line >= entry.start && line <= entry.end
11830
11615
  })).map((row) => row.index));
@@ -11868,13 +11653,7 @@ var init_model = __esmMin((() => {
11868
11653
  return found === -1 ? draft.length : found;
11869
11654
  };
11870
11655
  caretToEdge = (state, edge) => edge === "start" ? lineStart(state.draft, caretAt(state)) : lineEnd(state.draft, caretAt(state));
11871
- editedComment = (state) => state.editing === void 0 ? void 0 : state.pending.find((entry) => entry.id === state.editing);
11872
11656
  composeTarget = (state) => {
11873
- const edited = editedComment(state);
11874
- if (edited !== void 0) {
11875
- const span = edited.start === edited.end ? `${edited.start}` : `${edited.start}-${edited.end}`;
11876
- return `Comment on ${edited.file}:${span}`;
11877
- }
11878
11657
  const patch = selectedPatch(state);
11879
11658
  if (patch === void 0) return "";
11880
11659
  const [from, to] = selectionRange(state);
@@ -11994,7 +11773,7 @@ var init_model = __esmMin((() => {
11994
11773
  commentRowsIn = (state, fileIndex) => {
11995
11774
  const patch = fileIndex === state.patchIndex ? selectedPatch(state) : state.patches[fileIndex];
11996
11775
  if (patch === void 0) return [];
11997
- const notes = [...state.pending, ...state.sent].filter((entry) => entry.file === patch.path);
11776
+ const notes = state.sent.filter((entry) => entry.file === patch.path);
11998
11777
  return patch.rows.filter((row) => notes.some((note) => lineOnSide(row, note.side) === note.end)).map((row) => row.index).toSorted((left, right) => left - right);
11999
11778
  };
12000
11779
  threadsAtRow = (state, row) => {
@@ -12014,10 +11793,10 @@ var init_model = __esmMin((() => {
12014
11793
  openCommentRows = (state) => {
12015
11794
  const patch = selectedPatch(state);
12016
11795
  if (patch === void 0) return [];
12017
- const open = [...state.pending, ...state.sent].filter((entry) => entry.file === patch.path && entry.settled !== true);
11796
+ const open = state.sent.filter((entry) => entry.file === patch.path && entry.settled !== true);
12018
11797
  return patch.rows.filter((row) => open.some((note) => lineOnSide(row, note.side) === note.end)).map((row) => row.index);
12019
11798
  };
12020
- filesWithComments = (state) => state.patches.flatMap((patch, index) => [...state.pending, ...state.sent].some((entry) => entry.file === patch.path) ? [index] : []);
11799
+ filesWithComments = (state) => state.patches.flatMap((patch, index) => state.sent.some((entry) => entry.file === patch.path) ? [index] : []);
12021
11800
  answerCount = (comments) => comments.reduce((total, entry) => total + (entry.answers?.length ?? 0), 0);
12022
11801
  answersIn = (comment) => comment.answers?.length ?? 0;
12023
11802
  newerOf = (state, comment) => {
@@ -12037,28 +11816,17 @@ var init_model = __esmMin((() => {
12037
11816
  };
12038
11817
  };
12039
11818
  panelEntries = (state) => {
12040
- const staged = state.pending.map((comment) => ({
12041
- section: "staged",
12042
- comment,
12043
- fresh: false,
12044
- unread: 0
12045
- }));
12046
11819
  const delivered = state.sent.map((comment) => sentEntry(state, comment));
12047
11820
  const ordered = (section) => {
12048
11821
  const found = delivered.filter((entry) => entry.section === section);
12049
11822
  return state.newestFirst ? found.toReversed() : found;
12050
11823
  };
12051
- return [
12052
- ...staged,
12053
- ...ordered("with"),
12054
- ...ordered("answered")
12055
- ];
11824
+ return [...ordered("with"), ...ordered("answered")];
12056
11825
  };
12057
11826
  panelEntry = (state) => panelEntries(state)[state.panelIndex];
12058
11827
  threadChosen = (state) => {
12059
11828
  if (state.focus !== "review") return void 0;
12060
- const entry = panelEntry(state);
12061
- return entry === void 0 || entry.section === "staged" ? void 0 : entry.comment;
11829
+ return panelEntry(state)?.comment;
12062
11830
  };
12063
11831
  spokenSince = (seen, now) => Math.max(0, answerCount(now) - answerCount(seen));
12064
11832
  hunkStarts = (state) => {
@@ -12126,7 +11894,7 @@ var init_report = __esmMin((() => {
12126
11894
  `- branch \`${selectedBranch(state)?.branch ?? "none"}\``,
12127
11895
  `- file \`${selectedPatch(state)?.path ?? "none"}\`, row ${state.cursor + 1}`,
12128
11896
  `- screen \`${state.screen}\`, focus \`${state.focus}\`, selecting ${String(state.selecting)}`,
12129
- `- ${state.staged} staged, ${state.vouched.length} of ${state.patches.length} reviewed`
11897
+ `- ${state.vouched.length} of ${state.patches.length} reviewed`
12130
11898
  ];
12131
11899
  fenced = (title, lines) => [
12132
11900
  `## ${title}`,
@@ -12193,7 +11961,7 @@ var init_command = __esmMin((() => {
12193
11961
  category: "Review",
12194
11962
  hint: "",
12195
11963
  listed: true,
12196
- whenStaged: false,
11964
+ whenComments: false,
12197
11965
  counted: false,
12198
11966
  whenLayers: false,
12199
11967
  whenThread: false,
@@ -12308,7 +12076,7 @@ var init_command = __esmMin((() => {
12308
12076
  title: "Next comment",
12309
12077
  keys: ["n"],
12310
12078
  screens: ["review"],
12311
- whenStaged: true
12079
+ whenComments: true
12312
12080
  }),
12313
12081
  command({
12314
12082
  action: "comment.prev",
@@ -12396,7 +12164,7 @@ var init_command = __esmMin((() => {
12396
12164
  }),
12397
12165
  command({
12398
12166
  action: "selection.copy",
12399
- title: "Copy the selection",
12167
+ title: "Copy the selection, or the line the cursor is on",
12400
12168
  keys: ["y"],
12401
12169
  screens: ["review"],
12402
12170
  hint: "copy",
@@ -12597,7 +12365,7 @@ var init_command = __esmMin((() => {
12597
12365
  title: "Find a command",
12598
12366
  category: "General",
12599
12367
  keys: ["ctrl+p"],
12600
- screens: ["review", "pending"],
12368
+ screens: ["review"],
12601
12369
  listed: false
12602
12370
  }),
12603
12371
  command({
@@ -12608,65 +12376,6 @@ var init_command = __esmMin((() => {
12608
12376
  hint: "send",
12609
12377
  listed: false
12610
12378
  }),
12611
- command({
12612
- action: "pending.open",
12613
- title: "Send what is staged",
12614
- keys: ["S"],
12615
- screens: ["review"],
12616
- hint: "send",
12617
- whenStaged: true,
12618
- counted: true,
12619
- rank: 6
12620
- }),
12621
- command({
12622
- action: "pending.submit",
12623
- title: "Send the review",
12624
- keys: ["ctrl+s"],
12625
- screens: ["pending"],
12626
- hint: "send",
12627
- listed: false,
12628
- rank: 2
12629
- }),
12630
- command({
12631
- action: "pending.edit",
12632
- title: "Reword this comment",
12633
- category: "Review",
12634
- keys: ["e"],
12635
- screens: ["pending"],
12636
- hint: "reword",
12637
- rank: 3
12638
- }),
12639
- command({
12640
- action: "pending.drop",
12641
- title: "Withdraw this comment",
12642
- category: "Review",
12643
- keys: ["X"],
12644
- screens: ["pending"],
12645
- hint: "withdraw",
12646
- rank: 4
12647
- }),
12648
- command({
12649
- action: "pending.next",
12650
- title: "Next staged comment",
12651
- keys: ["down", "j"],
12652
- screens: ["pending"],
12653
- listed: false
12654
- }),
12655
- command({
12656
- action: "pending.prev",
12657
- title: "Previous staged comment",
12658
- keys: ["up", "k"],
12659
- screens: ["pending"],
12660
- listed: false
12661
- }),
12662
- command({
12663
- action: "compose.stage",
12664
- title: "Add to review",
12665
- keys: ["ctrl+a"],
12666
- screens: ["compose"],
12667
- hint: "stage",
12668
- listed: false
12669
- }),
12670
12379
  command({
12671
12380
  action: "compose.newline",
12672
12381
  title: "New line",
@@ -12690,7 +12399,6 @@ var init_command = __esmMin((() => {
12690
12399
  screens: [
12691
12400
  "branches",
12692
12401
  "review",
12693
- "pending",
12694
12402
  "search"
12695
12403
  ],
12696
12404
  hint: "keys",
@@ -12722,7 +12430,6 @@ var init_command = __esmMin((() => {
12722
12430
  "review",
12723
12431
  "compose",
12724
12432
  "palette",
12725
- "pending",
12726
12433
  "report",
12727
12434
  "search",
12728
12435
  "keys"
@@ -12770,9 +12477,9 @@ var init_command = __esmMin((() => {
12770
12477
  if (key.startsWith("ctrl+")) return `^${key.slice(5)}`;
12771
12478
  return GLYPHS[key] ?? key;
12772
12479
  };
12773
- hintsFor = (screen, offered) => commandsFor(screen).filter((entry) => entry.hint.length > 0).filter((entry) => !entry.whenStaged || offered.staged > 0).filter((entry) => !entry.whenLayers || offered.layers > 0).filter((entry) => !entry.whenThread || offered.onThread).filter((entry) => !entry.whenSelecting || offered.selecting).filter((entry) => !entry.whenReviewed || offered.reviewed > 0).filter((entry) => !entry.whenPull || offered.pull).toSorted((left, right) => left.rank - right.rank).map((entry) => ({
12480
+ hintsFor = (screen, offered) => commandsFor(screen).filter((entry) => entry.hint.length > 0).filter((entry) => !entry.whenComments || offered.comments > 0).filter((entry) => !entry.whenLayers || offered.layers > 0).filter((entry) => !entry.whenThread || offered.onThread).filter((entry) => !entry.whenSelecting || offered.selecting).filter((entry) => !entry.whenReviewed || offered.reviewed > 0).filter((entry) => !entry.whenPull || offered.pull).toSorted((left, right) => left.rank - right.rank).map((entry) => ({
12774
12481
  key: displayKey(entry.keys[0] ?? ""),
12775
- hint: entry.counted ? `${entry.hint} ${offered.staged}` : entry.hint,
12482
+ hint: entry.counted ? `${entry.hint} ${offered.comments}` : entry.hint,
12776
12483
  press: entry.keys[0] ?? ""
12777
12484
  }));
12778
12485
  }));
@@ -12803,7 +12510,7 @@ var init_match = __esmMin((() => {
12803
12510
  }));
12804
12511
  //#endregion
12805
12512
  //#region src/tui/reduce.ts
12806
- var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, draggedTo, atRow, noneLeft, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, movePending, moveLayer, inRail, railMoved, movePanel, layerDown, PANES, panesShown, focusStepped, togglePanel, packedAway, zoom, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, moveFile, selectHunk, swapEnds, atBranch, startSelection, openCompose, goBack, walkMatches, openPalette, openKeys, movePalette, paletteMatches, offered, paletteChoice, transitions, reduce, atFile, withContext, withFull, revealsAfter, gapOpened, withPending, panBy, withSent, withArrived, withColumns, withLayers, withPulls, withSilentForge, withBranches, withSource, withVouched, restoredTo, openedAt, withPatches, inserted, typed, TAB_WIDTH, SPACE_CODE, ERASED_FROM, ERASED_TO, readable, legible, pasted, backspaced, cutBackTo, wordBackspaced, lineBackspaced, deleted, caretMoved, caretJumped, caretHomed, withDraft, paletteMoved, paletteClosed, withWaiting, withMatches, withNoticeHere, withNotice;
12513
+ var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, draggedTo, atRow, noneLeft, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, moveLayer, inRail, railScrolled, movePanel, layerDown, PANES, panesShown, focusStepped, togglePanel, packedAway, zoom, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, moveFile, selectHunk, swapEnds, atBranch, startSelection, openCompose, goBack, walkMatches, openPalette, openKeys, movePalette, paletteMatches, offered, paletteChoice, transitions, reduce, atFile, withContext, withFull, revealsAfter, gapOpened, panBy, withSent, withArrived, withColumns, withLayers, withPulls, withSilentForge, withBranches, withSource, withVouched, restoredTo, openedAt, withPatches, inserted, typed, TAB_WIDTH, SPACE_CODE, ERASED_FROM, ERASED_TO, readable, legible, pasted, backspaced, cutBackTo, wordBackspaced, lineBackspaced, deleted, caretMoved, caretJumped, caretHomed, paletteMoved, paletteClosed, withWaiting, withMatches, withNoticeHere, withNotice;
12807
12514
  var init_reduce = __esmMin((() => {
12808
12515
  init_dist();
12809
12516
  init_patch();
@@ -12918,10 +12625,6 @@ var init_reduce = __esmMin((() => {
12918
12625
  pan: Math.max(0, state.pan + delta)
12919
12626
  };
12920
12627
  };
12921
- movePending = (state, delta) => ({
12922
- ...state,
12923
- pendingIndex: clamp(state.pendingIndex + delta, 0, Math.max(0, state.pending.length - 1))
12924
- });
12925
12628
  moveLayer = (state, delta) => {
12926
12629
  const layerIndex = clamp(state.layerIndex + delta, 0, Math.max(0, state.layers.length - 1));
12927
12630
  const landed = {
@@ -12939,7 +12642,17 @@ var init_reduce = __esmMin((() => {
12939
12642
  };
12940
12643
  };
12941
12644
  inRail = (state, delta) => onLayers(state) ? moveLayer(state, delta) : moveFile(state, delta);
12942
- railMoved = (state, delta) => inRail(state, delta);
12645
+ railScrolled = (state, delta) => {
12646
+ if (onLayers(state)) return inRail(state, delta);
12647
+ const height = Math.max(1, state.railRows);
12648
+ const rows = treeRows(state).length;
12649
+ if (rows <= height) return state;
12650
+ const start = treeStart(state, height);
12651
+ return {
12652
+ ...state,
12653
+ railScroll: clamp(start + delta, 0, rows - height)
12654
+ };
12655
+ };
12943
12656
  movePanel = (state, delta) => ({
12944
12657
  ...state,
12945
12658
  panelIndex: clamp(state.panelIndex + delta, 0, Math.max(0, panelEntries(state).length - 1))
@@ -13080,10 +12793,6 @@ var init_reduce = __esmMin((() => {
13080
12793
  matches: [],
13081
12794
  term: ""
13082
12795
  };
13083
- if (state.screen === "pending") return {
13084
- ...state,
13085
- screen: "review"
13086
- };
13087
12796
  if (state.screen === "report") return {
13088
12797
  ...state,
13089
12798
  screen: state.returnTo,
@@ -13168,13 +12877,6 @@ var init_reduce = __esmMin((() => {
13168
12877
  "select.swap": swapEnds,
13169
12878
  "compose.open": openCompose,
13170
12879
  "compose.submit": (state) => state,
13171
- "compose.stage": (state) => state,
13172
- "pending.open": (state) => state,
13173
- "pending.submit": (state) => state,
13174
- "pending.edit": (state) => state,
13175
- "pending.drop": (state) => state,
13176
- "pending.next": (state) => movePending(state, 1),
13177
- "pending.prev": (state) => movePending(state, -1),
13178
12880
  "compose.newline": (state) => inserted(state, "\n"),
13179
12881
  "focus.toggle": (state) => ({
13180
12882
  ...state,
@@ -13285,13 +12987,6 @@ var init_reduce = __esmMin((() => {
13285
12987
  selecting: false
13286
12988
  });
13287
12989
  };
13288
- withPending = (state, pending, screen) => ({
13289
- ...state,
13290
- pending,
13291
- pendingIndex: 0,
13292
- staged: pending.length,
13293
- screen
13294
- });
13295
12990
  panBy = (state, delta) => state.wrap ? state : {
13296
12991
  ...state,
13297
12992
  pan: Math.max(0, state.pan + delta)
@@ -13476,11 +13171,6 @@ var init_reduce = __esmMin((() => {
13476
13171
  ...state,
13477
13172
  caret: caretToEdge(state, edge)
13478
13173
  });
13479
- withDraft = (state, draft) => ({
13480
- ...state,
13481
- draft,
13482
- caret: draft.length
13483
- });
13484
13174
  paletteMoved = (state, delta) => movePalette(state, delta);
13485
13175
  paletteClosed = (state) => ({
13486
13176
  ...state,
@@ -13516,7 +13206,6 @@ var init_marks = __esmMin((() => {
13516
13206
  sets = {
13517
13207
  ring: {
13518
13208
  comment: "○",
13519
- staged: "○",
13520
13209
  sent: "✓",
13521
13210
  rule: "│",
13522
13211
  cursor: "▎",
@@ -13528,7 +13217,6 @@ var init_marks = __esmMin((() => {
13528
13217
  },
13529
13218
  bubble: {
13530
13219
  comment: "◗",
13531
- staged: "◗",
13532
13220
  sent: "◖",
13533
13221
  rule: "┃",
13534
13222
  cursor: "▌",
@@ -13540,7 +13228,6 @@ var init_marks = __esmMin((() => {
13540
13228
  },
13541
13229
  quote: {
13542
13230
  comment: "❞",
13543
- staged: "❝",
13544
13231
  sent: "✓",
13545
13232
  rule: "┊",
13546
13233
  cursor: "▎",
@@ -13552,7 +13239,6 @@ var init_marks = __esmMin((() => {
13552
13239
  },
13553
13240
  diamond: {
13554
13241
  comment: "◆",
13555
- staged: "◇",
13556
13242
  sent: "◈",
13557
13243
  rule: "╎",
13558
13244
  cursor: "▎",
@@ -13564,7 +13250,6 @@ var init_marks = __esmMin((() => {
13564
13250
  },
13565
13251
  dot: {
13566
13252
  comment: "●",
13567
- staged: "●",
13568
13253
  sent: "✓",
13569
13254
  rule: "▏",
13570
13255
  cursor: "▎",
@@ -13581,7 +13266,6 @@ var init_marks = __esmMin((() => {
13581
13266
  folderOpen: "",
13582
13267
  file: "",
13583
13268
  comment: "○",
13584
- staged: "○",
13585
13269
  sent: "✓",
13586
13270
  rule: "│",
13587
13271
  cursor: "▎",
@@ -13674,7 +13358,7 @@ var init_theme = __esmMin((() => {
13674
13358
  }));
13675
13359
  //#endregion
13676
13360
  //#region src/tui/diffview.ts
13677
- var WASH, NOTE_MIN, ANSWER_MARK, OVERSCAN, SIGN_WIDTH, SCROLL_ROWS, PAN_COLUMNS, WAYS, notchesIn, wheelTo, SIGNS, numberFor, DiffView, startsOf, bareOf, keyOf, groupOf, isChrome, heldAt, NO_SPANS, lineStarts, overLine, shifted, acrossLines, spansByLine, textAt, noteSpans, NOTE_PAINT, wrap, headOf, spokenLines, answerLines, noteLines, noteRows, proseRows, proseAt, notesAt, codeRow, rowsFor, layout, lineNumbers, BARE_SIGN, signFor, lineSigns, sideLineOf;
13361
+ var WASH, NOTE_MIN, ANSWER_MARK, OVERSCAN, SIGN_WIDTH, SCROLL_ROWS, PAN_COLUMNS, WAYS, notchesIn, wheelTo, SIGNS, numberFor, DiffView, startsOf, bareOf, keyOf, groupOf, isChrome, heldAt, sameLine, NO_SPANS, lineStarts, overLine, shifted, acrossLines, spansByLine, textAt, noteSpans, NOTE_PAINT, wrap, headOf, spokenLines, answerLines, noteLines, noteRows, proseRows, proseAt, notesAt, codeRow, rowsFor, layout, lineNumbers, BARE_SIGN, signFor, lineSigns, sideLineOf;
13678
13362
  var init_diffview = __esmMin((() => {
13679
13363
  init_dist();
13680
13364
  init_patch();
@@ -13745,7 +13429,10 @@ var init_diffview = __esmMin((() => {
13745
13429
  pinnedText = "";
13746
13430
  newLit = [];
13747
13431
  oldLit = [];
13748
- litFor = "";
13432
+ newFor = "";
13433
+ oldFor = "";
13434
+ newText = [];
13435
+ oldText = [];
13749
13436
  shown;
13750
13437
  noted = "";
13751
13438
  display = [];
@@ -13835,6 +13522,7 @@ var init_diffview = __esmMin((() => {
13835
13522
  this.numbers.onMouseDown = (event) => handlers.down(event.y);
13836
13523
  this.numbers.onMouseDrag = (event) => handlers.drag(event.y);
13837
13524
  this.numbers.onMouseDragEnd = (event) => handlers.dragEnd(event.y);
13525
+ this.numbers.onMouseUp = (event) => handlers.dragEnd(event.y);
13838
13526
  }
13839
13527
  refresh() {
13840
13528
  this.shown = void 0;
@@ -13881,23 +13569,36 @@ var init_diffview = __esmMin((() => {
13881
13569
  }
13882
13570
  lit(path, side, lines, found) {
13883
13571
  const held = spansByLine(lines, found);
13884
- if (side === "new") this.newLit = held;
13885
- else this.oldLit = held;
13886
- this.litFor = path;
13572
+ if (side === "new") {
13573
+ this.newLit = held;
13574
+ this.newText = lines;
13575
+ this.newFor = path;
13576
+ } else {
13577
+ this.oldLit = held;
13578
+ this.oldText = lines;
13579
+ this.oldFor = path;
13580
+ }
13887
13581
  this.feed();
13888
13582
  this.code.requestRender();
13889
13583
  }
13890
13584
  litRow(entry) {
13891
- if (this.shown === void 0 || this.shown.path !== this.litFor) return NO_SPANS;
13892
- const row = this.shown.rows[entry.row];
13585
+ const row = this.shown?.rows[entry.row];
13893
13586
  if (row === void 0) return NO_SPANS;
13894
13587
  const fresh = getOrUndefined$1(row.newLine);
13895
- if (fresh !== void 0) return this.newLit[fresh - 1] ?? NO_SPANS;
13588
+ if (fresh !== void 0) return this.sideRow(row.text, fresh, "new");
13896
13589
  const gone = getOrUndefined$1(row.oldLine);
13897
- return gone === void 0 ? NO_SPANS : this.oldLit[gone - 1] ?? NO_SPANS;
13590
+ return gone === void 0 ? NO_SPANS : this.sideRow(row.text, gone, "old");
13591
+ }
13592
+ sideRow(text, line, side) {
13593
+ const path = side === "new" ? this.newFor : this.oldFor;
13594
+ if (this.shown?.path !== path) return NO_SPANS;
13595
+ const source = side === "new" ? this.newText : this.oldText;
13596
+ if (!sameLine(source[line - 1], text)) return NO_SPANS;
13597
+ return (side === "new" ? this.newLit : this.oldLit)[line - 1] ?? NO_SPANS;
13898
13598
  }
13899
13599
  ownSpans() {
13900
- if (this.shown === void 0 || this.shown.path !== this.litFor) return void 0;
13600
+ if (this.shown === void 0) return void 0;
13601
+ if (this.shown.path !== this.newFor && this.shown.path !== this.oldFor) return void 0;
13901
13602
  const spans = [];
13902
13603
  let at = 0;
13903
13604
  for (const entry of this.display) {
@@ -14009,6 +13710,19 @@ var init_diffview = __esmMin((() => {
14009
13710
  tallestRows() {
14010
13711
  return this.tallest();
14011
13712
  }
13713
+ blockAt(row, stop) {
13714
+ const first = this.display.findIndex((entry) => entry.row === row && entry.stop === stop);
13715
+ if (first === -1) return {
13716
+ start: 0,
13717
+ rows: 0
13718
+ };
13719
+ let last = first;
13720
+ while (this.display[last + 1]?.row === row && this.display[last + 1]?.stop === stop) last += 1;
13721
+ return {
13722
+ start: first,
13723
+ rows: last - first + 1
13724
+ };
13725
+ }
14012
13726
  scrollTo(row, cursor, held = -1) {
14013
13727
  const highest = Math.max(0, this.tallest() - this.rows());
14014
13728
  if (held >= 0) {
@@ -14059,6 +13773,7 @@ var init_diffview = __esmMin((() => {
14059
13773
  };
14060
13774
  isChrome = (entry) => entry.comment || entry.gap || entry.prose;
14061
13775
  heldAt = (entry, pan) => isChrome(entry) && pan > 0 ? `${" ".repeat(pan)}${entry.text}` : entry.text;
13776
+ sameLine = (source, row) => source !== void 0 && source.trimEnd() === row.trimEnd();
14062
13777
  NO_SPANS = [];
14063
13778
  lineStarts = (lines) => {
14064
13779
  const starts = [];
@@ -14151,10 +13866,9 @@ var init_diffview = __esmMin((() => {
14151
13866
  headOf = (note) => {
14152
13867
  const moved = note.stale ? ", the branch moved on" : "";
14153
13868
  if (note.settled) return `${marks().sent} settled${moved}`;
14154
- if (note.asks) return `${marks().staged} asked back${moved}`;
13869
+ if (note.asks) return `${marks().comment} asked back${moved}`;
14155
13870
  if (note.answers.length > 0) return `${marks().sent} answered${moved}`;
14156
- if (note.sent) return `${marks().sent} sent${moved}`;
14157
- return `${marks().staged} staged`;
13871
+ return `${marks().sent} sent${moved}`;
14158
13872
  };
14159
13873
  spokenLines = (body, room) => {
14160
13874
  return wrap(body.replaceAll("\n", " "), Math.max(NOTE_MIN, room - 2)).map((text, at) => at === 0 ? `${ANSWER_MARK} ${text}` : ` ${text}`);
@@ -14239,7 +13953,7 @@ var init_diffview = __esmMin((() => {
14239
13953
  }));
14240
13954
  //#endregion
14241
13955
  //#region src/tui/render.ts
14242
- var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, COMPOSE_PAD, COMPOSE_MIN_TEXT, reportActions, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_TAIL, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, SELECTION, CURSOR, ACCENT, GAP_PAINT, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, makePaletteParts, makePendingParts, makeChoices, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, makeComposeParts, makeCompose, clip, clipHead, clipMiddle, clipPath, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, contextLabel, nameRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, headerParts, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, STEP_NUMBER, STEP_LEAD, NOTE_LEAD, STEP_GAP, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerFold, layerHead, layerText, layerPaint, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, panelMark, panelWhere, panelBody, panelPair, panelSection, PULL_HINT, panelText, Screen;
13956
+ var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, COMPOSE_PAD, COMPOSE_MIN_TEXT, reportActions, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_TAIL, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, SELECTION, CURSOR, ACCENT, GAP_PAINT, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, makePaletteParts, makeChoices, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, makeComposeParts, makeCompose, clip, clipHead, clipMiddle, clipPath, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, contextLabel, nameRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, headerParts, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, STEP_NUMBER, STEP_LEAD, NOTE_LEAD, STEP_GAP, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerFold, layerHead, layerText, layerPaint, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, panelMark, panelWhere, panelBody, panelPair, panelSection, PULL_HINT, panelText, Screen;
14243
13957
  var init_render = __esmMin((() => {
14244
13958
  init_command();
14245
13959
  init_patch();
@@ -14454,12 +14168,6 @@ var init_render = __esmMin((() => {
14454
14168
  choices
14455
14169
  };
14456
14170
  };
14457
- makePendingParts = (renderer) => {
14458
- const parts = makePaletteParts(renderer);
14459
- parts.box.id = "pending";
14460
- parts.query.height = 0;
14461
- return parts;
14462
- };
14463
14171
  makeChoices = (renderer) => new SelectRenderable(renderer, {
14464
14172
  id: "palette-choices",
14465
14173
  flexGrow: 1,
@@ -14493,7 +14201,6 @@ var init_render = __esmMin((() => {
14493
14201
  });
14494
14202
  makeModals = (renderer) => ({
14495
14203
  palette: makePaletteParts(renderer),
14496
- staged: makePendingParts(renderer),
14497
14204
  found: makeFoundParts(renderer),
14498
14205
  keys: makeKeysParts(renderer)
14499
14206
  });
@@ -14615,10 +14322,7 @@ var init_render = __esmMin((() => {
14615
14322
  const lead = `${indent}${shut ? "▸" : "▾"} ${shut ? marks().folder : marks().folderOpen} `;
14616
14323
  return `${lead}${clipPath(row.name, Math.max(4, room - lead.length))}`;
14617
14324
  };
14618
- waitingLabel = (branch) => {
14619
- if (branch.staged > 0) return `${branch.staged} staged`;
14620
- return branch.unread > 0 ? `${branch.unread} unanswered` : "";
14621
- };
14325
+ waitingLabel = (branch) => branch.unread > 0 ? `${branch.unread} unanswered` : "";
14622
14326
  inRange = (state, row, from, to) => state.selecting && row >= from && row <= to;
14623
14327
  notesOf = (comments, path, sent, opened = []) => comments.filter((entry) => entry.file === path).map((entry) => ({
14624
14328
  id: entry.id ?? "",
@@ -14632,7 +14336,7 @@ var init_render = __esmMin((() => {
14632
14336
  asks: entry.asks === true,
14633
14337
  answers: entry.answers ?? []
14634
14338
  }));
14635
- notesFor = (state, path) => [...notesOf(state.sent, path, true, state.opened), ...notesOf(state.pending, path, false)];
14339
+ notesFor = (state, path) => notesOf(state.sent, path, true, state.opened);
14636
14340
  paired = (chunks) => {
14637
14341
  const chips = [];
14638
14342
  for (let at = 0; at < chunks.length; at += CHIP_CHUNKS) chips.push(chunks.slice(at, at + CHIP_CHUNKS));
@@ -14711,7 +14415,6 @@ var init_render = __esmMin((() => {
14711
14415
  state.patches.length === 0 ? "nothing to read" : `${state.patchIndex + 1}/${state.patches.length}`,
14712
14416
  pullHere(state).length === 0 ? "" : `${pullHere(state)} pull request`,
14713
14417
  state.vouched.length === 0 ? "" : reviewedCount(state),
14714
- state.staged === 0 ? "" : `${state.staged} staged`,
14715
14418
  contextLabel(state.context),
14716
14419
  hiddenLines(state) === 0 ? "" : `⋯ ${hiddenLines(state)} lines hidden`,
14717
14420
  pan === 0 ? "" : `→ ${pan} columns`
@@ -14779,15 +14482,10 @@ var init_render = __esmMin((() => {
14779
14482
  return row.index === state.layerIndex ? palette.ink : palette.muted;
14780
14483
  };
14781
14484
  PANEL_TITLES = {
14782
- staged: "Staged",
14783
14485
  with: "With the agent",
14784
14486
  answered: "Answered"
14785
14487
  };
14786
- PANEL_ORDER = [
14787
- "staged",
14788
- "with",
14789
- "answered"
14790
- ];
14488
+ PANEL_ORDER = ["with", "answered"];
14791
14489
  PANEL_LEAD = 3;
14792
14490
  PANEL_EMPTY = "No comment on this branch yet.";
14793
14491
  panelMark = (state, at) => {
@@ -14874,12 +14572,9 @@ var init_render = __esmMin((() => {
14874
14572
  paletteTitle;
14875
14573
  paletteQuery;
14876
14574
  paletteChoices;
14877
- pending;
14878
14575
  keys;
14879
14576
  keysTitle;
14880
14577
  keysChoices;
14881
- pendingTitle;
14882
- pendingChoices;
14883
14578
  found;
14884
14579
  foundTitle;
14885
14580
  foundPeek;
@@ -14927,9 +14622,6 @@ var init_render = __esmMin((() => {
14927
14622
  this.keys = modals.keys.box;
14928
14623
  this.keysTitle = modals.keys.title;
14929
14624
  this.keysChoices = modals.keys.choices;
14930
- this.pending = modals.staged.box;
14931
- this.pendingTitle = modals.staged.title;
14932
- this.pendingChoices = modals.staged.choices;
14933
14625
  this.found = modals.found.box;
14934
14626
  this.foundTitle = modals.found.title;
14935
14627
  this.foundPeek = modals.found.query;
@@ -14991,6 +14683,15 @@ var init_render = __esmMin((() => {
14991
14683
  tallestRows() {
14992
14684
  return this.view.tallestRows();
14993
14685
  }
14686
+ railRows() {
14687
+ return this.listRoom();
14688
+ }
14689
+ scrolledAt() {
14690
+ return this.lastTop;
14691
+ }
14692
+ blockAt(row, stop) {
14693
+ return this.view.blockAt(row, stop);
14694
+ }
14994
14695
  diffRows() {
14995
14696
  const edges = this.diffPane.border === true ? PANE_EDGES : 0;
14996
14697
  const pane = this.diffPane.height - edges - this.view.pinRows();
@@ -14999,7 +14700,7 @@ var init_render = __esmMin((() => {
14999
14700
  update(state) {
15000
14701
  this.shown = state;
15001
14702
  this.chips = hintsFor(state.screen, {
15002
- staged: state.staged,
14703
+ comments: state.sent.length,
15003
14704
  layers: state.layers.length,
15004
14705
  onThread: state.stop > 0 || threadChosen(state) !== void 0,
15005
14706
  selecting: state.selecting,
@@ -15021,7 +14722,6 @@ var init_render = __esmMin((() => {
15021
14722
  this.paintCompose(state);
15022
14723
  this.paintPalette(state);
15023
14724
  this.paintKeys(state);
15024
- this.paintPending(state);
15025
14725
  this.paintFound(state);
15026
14726
  this.paintReport(state);
15027
14727
  this.scrim.visible = state.screen !== "branches" && state.screen !== "review";
@@ -15155,27 +14855,6 @@ var init_render = __esmMin((() => {
15155
14855
  this.view.paint(this.linePaint(state), top, height);
15156
14856
  this.paintGutter(state, top, height);
15157
14857
  }
15158
- paintPending(state) {
15159
- this.pending.visible = state.screen === "pending";
15160
- if (state.screen !== "pending") {
15161
- this.pendingTitle.content = "";
15162
- this.pendingChoices.options = [];
15163
- return;
15164
- }
15165
- const count = state.pending.length;
15166
- const room = panelWidth(this.renderer.width);
15167
- this.pendingTitle.content = `Send ${count} comment${count === 1 ? "" : "s"} as one review, waking the agent once`;
15168
- this.pendingChoices.options = state.pending.map((entry) => ({
15169
- name: clip(`${entry.file}:${entry.start}-${entry.end} ${entry.body.split("\n")[0] ?? ""}`, Math.max(1, room - MODAL_ROOM)),
15170
- description: "",
15171
- value: entry.file
15172
- }));
15173
- this.pendingChoices.selectedIndex = state.pendingIndex;
15174
- this.pending.height = Math.min(panelRows(this.renderer.height, PANEL_QUARTER), state.pending.length + PENDING_CHROME);
15175
- this.pending.width = room;
15176
- this.pending.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room) / 2));
15177
- this.pending.top = panelTop(this.renderer.height, PANEL_QUARTER);
15178
- }
15179
14858
  assemble(renderer) {
15180
14859
  this.diffScroll.add(this.view.node());
15181
14860
  this.diffPane.add(this.view.pinNode());
@@ -15199,7 +14878,6 @@ var init_render = __esmMin((() => {
15199
14878
  this.scrim,
15200
14879
  this.compose,
15201
14880
  this.palette,
15202
- this.pending,
15203
14881
  this.found,
15204
14882
  this.keys
15205
14883
  ]);
@@ -15451,6 +15129,9 @@ var init_display = __esmMin((() => {
15451
15129
  rows: sync(() => screen.viewportRows()),
15452
15130
  room: sync(() => screen.noteRoom()),
15453
15131
  tallest: sync(() => screen.tallestRows()),
15132
+ rail: sync(() => screen.railRows()),
15133
+ at: sync(() => screen.scrolledAt()),
15134
+ block: (row, stop) => sync(() => screen.blockAt(row, stop)),
15454
15135
  columns: sync(() => screen.columns()),
15455
15136
  listen: listenWith(screen),
15456
15137
  light: (path, side, lines) => lightWith(screen, path, side, lines)
@@ -15532,7 +15213,7 @@ var init_upgrade = __esmMin((() => {
15532
15213
  return due ? `adiff ${latest} is out · adiff upgrade` : "";
15533
15214
  }).pipe(withSpan("Tui.upgradeHint"));
15534
15215
  upgradeHint = worded.pipe(orElseSucceed(() => ""));
15535
- })), PRINTABLE, KEY_HISTORY, TRAIL_HISTORY, clockOf, momentOf, noticeOf, copyToClipboard, asKey, openedPull, byWord, WORD_STEP, caretSideways, caretFor, erasedBy, LISTENS, listens, laidOut, keyName, App, settledPath, openingOn, launch, told, untilDestroyed, runOn, runTui;
15216
+ })), PRINTABLE, KEY_HISTORY, TRAIL_HISTORY, clockOf, momentOf, noticeOf, handOver, copyToClipboard, lineUnder, asKey, openedPull, byWord, WORD_STEP, caretSideways, caretFor, erasedBy, LISTENS, listens, laidOut, keyName, App, settledPath, openingOn, launch, told, untilDestroyed, runOn, runTui;
15536
15217
  var init_app = __esmMin((() => {
15537
15218
  init_dist();
15538
15219
  init_report();
@@ -15562,9 +15243,25 @@ var init_app = __esmMin((() => {
15562
15243
  return `${clockOf(elapsed)} ${named.padEnd(16)} ${place.padEnd(16)} row ${String(state.cursor + 1).padStart(5)} ${file}`;
15563
15244
  };
15564
15245
  noticeOf = (notice, elapsed) => `${clockOf(elapsed)} ${"said".padEnd(16)} ${notice}`;
15246
+ handOver = (text) => {
15247
+ if (platform() !== "darwin" || !process.stdout.isTTY) return;
15248
+ const pipe = spawn("pbcopy", { stdio: [
15249
+ "pipe",
15250
+ "ignore",
15251
+ "ignore"
15252
+ ] });
15253
+ pipe.on("error", () => void 0);
15254
+ pipe.stdin.on("error", () => void 0);
15255
+ pipe.stdin.end(text);
15256
+ };
15565
15257
  copyToClipboard = (text) => {
15566
15258
  const encoded = Buffer.from(text, "utf8").toString("base64");
15567
15259
  process.stdout.write(`\u001B]52;c;${encoded}\u0007`);
15260
+ handOver(text);
15261
+ };
15262
+ lineUnder = (state) => {
15263
+ const row = selectedPatch(state)?.rows[state.cursor];
15264
+ return row === void 0 ? [] : [row.text];
15568
15265
  };
15569
15266
  asKey = (name) => name.startsWith("ctrl+") ? {
15570
15267
  name: name.slice(5),
@@ -15634,6 +15331,7 @@ var init_app = __esmMin((() => {
15634
15331
  wheel = 0;
15635
15332
  sideways = 0;
15636
15333
  listening;
15334
+ lighting;
15637
15335
  constructor(options) {
15638
15336
  this.renderer = options.renderer;
15639
15337
  this.repo = options.repo;
@@ -15648,7 +15346,7 @@ var init_app = __esmMin((() => {
15648
15346
  runSync(this.display.listen({
15649
15347
  onScroll: (delta) => this.onWheel(delta),
15650
15348
  onPan: (delta) => this.onPanWheel(delta),
15651
- onDrag: (from, to) => this.commit(draggedTo(this.measured(), from, to)),
15349
+ onDrag: (from, to, done) => this.dragged(from, to, done),
15652
15350
  onChip: (key) => this.dispatchTask(this.onKey(asKey(key))),
15653
15351
  onRail: (delta) => this.dispatchTask(this.rolled(delta))
15654
15352
  }));
@@ -15656,6 +15354,7 @@ var init_app = __esmMin((() => {
15656
15354
  renderer.keyInput.on("paste", (event) => this.dispatchPaste(event));
15657
15355
  renderer.on("destroy", () => this.stopWatching());
15658
15356
  renderer.on("destroy", () => this.stopFading());
15357
+ renderer.on("destroy", () => this.stopLighting());
15659
15358
  renderer.on("destroy", () => this.stopPainting());
15660
15359
  renderer.on("destroy", () => this.stopConsuming());
15661
15360
  renderer.on("frame", () => this.syncGeometry());
@@ -15760,7 +15459,11 @@ var init_app = __esmMin((() => {
15760
15459
  if (this.consuming === void 0) return Promise.resolve();
15761
15460
  const done = makeUnsafe$4();
15762
15461
  offerUnsafe(this.intents, Intent.Ping({ done }));
15763
- return runPromise(_await(done));
15462
+ return runPromise(andThen(_await(done), this.stillLighting()));
15463
+ }
15464
+ stillLighting() {
15465
+ const fiber = this.lighting;
15466
+ return fiber === void 0 ? void_ : asVoid(await_(fiber));
15764
15467
  }
15765
15468
  onWheel(delta) {
15766
15469
  this.wheel += delta;
@@ -15783,7 +15486,7 @@ var init_app = __esmMin((() => {
15783
15486
  if (down !== 0) this.commit(paletteMoved(this.state, down));
15784
15487
  return;
15785
15488
  }
15786
- const moved = down === 0 ? this.measured() : scrolled(this.measured(), down);
15489
+ const moved = down === 0 ? this.measured() : scrolled(this.standing(), down);
15787
15490
  this.commit(across === 0 ? moved : panBy(moved, across));
15788
15491
  }
15789
15492
  syncGeometry() {
@@ -15808,11 +15511,26 @@ var init_app = __esmMin((() => {
15808
15511
  });
15809
15512
  return;
15810
15513
  }
15514
+ const railRows = runSync(this.display.rail);
15515
+ if (railRows !== this.state.railRows) {
15516
+ this.commit({
15517
+ ...this.state,
15518
+ railRows
15519
+ });
15520
+ return;
15521
+ }
15811
15522
  const room = runSync(this.display.room);
15812
15523
  if (room === this.roomed) return;
15813
15524
  this.roomed = room;
15814
15525
  runSync(this.display.paint(this.state));
15815
15526
  }
15527
+ standing() {
15528
+ const held = this.measured();
15529
+ return held.scroll >= 0 ? held : {
15530
+ ...held,
15531
+ scroll: runSync(this.display.at)
15532
+ };
15533
+ }
15816
15534
  measured() {
15817
15535
  return {
15818
15536
  ...this.state,
@@ -15828,7 +15546,11 @@ var init_app = __esmMin((() => {
15828
15546
  since() {
15829
15547
  return Date.now() - this.began;
15830
15548
  }
15831
- commit(next) {
15549
+ commit(given) {
15550
+ const next = given.patchIndex === this.state.patchIndex ? given : {
15551
+ ...given,
15552
+ railScroll: -1
15553
+ };
15832
15554
  const appeared = next.notice.length > 0 && next.notice !== this.state.notice;
15833
15555
  if (appeared) this.recordNotice(next.notice);
15834
15556
  this.rememberPlace(next);
@@ -15851,6 +15573,11 @@ var init_app = __esmMin((() => {
15851
15573
  watch(fiber) {
15852
15574
  this.consuming = fiber;
15853
15575
  }
15576
+ stopLighting() {
15577
+ const fiber = this.lighting;
15578
+ this.lighting = void 0;
15579
+ if (fiber !== void 0) runFork(interrupt(fiber));
15580
+ }
15854
15581
  stopFading() {
15855
15582
  const fiber = this.fading;
15856
15583
  this.fading = void 0;
@@ -15877,28 +15604,23 @@ var init_app = __esmMin((() => {
15877
15604
  "branch.pull": () => this.showPull(),
15878
15605
  "compose.open": () => this.compose(),
15879
15606
  "compose.submit": () => this.send(),
15880
- "compose.stage": () => this.stage(),
15881
15607
  "palette.run": () => this.runChoice(),
15882
15608
  "comment.next": () => this.walkComments(1),
15883
15609
  "comment.prev": () => this.walkComments(-1),
15884
15610
  "file.next": () => this.moveFile(1),
15885
15611
  "file.prev": () => this.moveFile(-1),
15886
- "cursor.next": () => this.commitSynced("cursor.next"),
15887
- "cursor.prev": () => this.commitSynced("cursor.prev"),
15612
+ "cursor.next": () => this.stepped(1),
15613
+ "cursor.prev": () => this.stepped(-1),
15888
15614
  "rail.toggle": () => this.commitSynced("rail.toggle"),
15889
15615
  "file.vouch": () => this.vouch(false),
15890
15616
  "file.vouch.next": () => this.vouch(true),
15891
15617
  "thread.settle": () => this.settleHere(),
15892
15618
  "thread.settleRead": () => this.settleWhatIsRead(),
15893
15619
  "thread.remove": () => this.removeHere(),
15894
- "selection.copy": () => sync(() => this.copySelection()),
15620
+ "selection.copy": () => sync(() => this.copySelection(false)),
15895
15621
  "search.open": () => this.findSelection(),
15896
15622
  "search.jump": () => this.openMatch(),
15897
15623
  "review.reload": () => this.state.screen === "branches" ? this.reloadList() : this.reloadBranch(),
15898
- "pending.open": () => this.openPending(),
15899
- "pending.edit": () => sync(() => this.editStagedComment()),
15900
- "pending.drop": () => this.dropStagedComment(),
15901
- "pending.submit": () => this.sendReview(),
15902
15624
  "report.open": () => sync(() => this.commit(reduce(this.measured(), "report.open"))),
15903
15625
  back: () => this.goBack(),
15904
15626
  "report.send": () => this.sendReport(),
@@ -15989,11 +15711,10 @@ var init_app = __esmMin((() => {
15989
15711
  return gen({ self: this }, function* () {
15990
15712
  const patches = yield* listPatches(this.repo, name);
15991
15713
  const progress = yield* reviewProgress(this.repo, name);
15992
- const pending = yield* listPending(this.repo, name);
15993
15714
  const layers = yield* listLayers(this.repo, name);
15994
15715
  const sent = yield* this.loadSent(name);
15995
15716
  const opened = withVouched(withPatches(this.state, patches), progress.vouched);
15996
- return withLayers(withSent(withPending(opened, pending, "review"), sent), layers);
15717
+ return withLayers(withSent(opened, sent), layers);
15997
15718
  });
15998
15719
  }
15999
15720
  openBranch() {
@@ -16004,15 +15725,26 @@ var init_app = __esmMin((() => {
16004
15725
  yield* this.loadSource();
16005
15726
  });
16006
15727
  }
16007
- copySelection() {
16008
- const lines = selectedLines(this.state);
15728
+ dragged(from, to, done) {
15729
+ this.commit(draggedTo(this.measured(), from, to));
15730
+ if (done && from !== to) this.copySelection(true);
15731
+ }
15732
+ copySelection(keep) {
15733
+ const said = keep ? withNoticeHere : withNotice;
15734
+ const thread = threadAtStop(this.state);
15735
+ if (thread !== void 0) {
15736
+ copyToClipboard(`${thread.body}\n`);
15737
+ this.commit(said(this.state, "comment copied"));
15738
+ return;
15739
+ }
15740
+ const lines = this.state.selecting ? selectedLines(this.state) : lineUnder(this.state);
16009
15741
  if (lines.length === 0) {
16010
- this.commit(withNoticeHere(this.state, "nothing selected"));
15742
+ this.commit(withNoticeHere(this.state, "nothing to copy"));
16011
15743
  return;
16012
15744
  }
16013
15745
  copyToClipboard(`${lines.join("\n")}\n`);
16014
15746
  const many = lines.length === 1 ? "1 line copied" : `${lines.length} lines copied`;
16015
- this.commit(withNotice(this.state, many));
15747
+ this.commit(said(this.state, many));
16016
15748
  }
16017
15749
  findSelection() {
16018
15750
  return gen({ self: this }, function* () {
@@ -16195,6 +15927,23 @@ var init_app = __esmMin((() => {
16195
15927
  if (this.state.patchIndex !== was) yield* this.turnedTo();
16196
15928
  });
16197
15929
  }
15930
+ stepped(delta) {
15931
+ return gen({ self: this }, function* () {
15932
+ if (this.paged(delta)) return;
15933
+ yield* this.commitSynced(delta > 0 ? "cursor.next" : "cursor.prev");
15934
+ });
15935
+ }
15936
+ paged(delta) {
15937
+ if (this.state.screen !== "review" || this.state.focus !== "diff") return false;
15938
+ const state = this.standing();
15939
+ const span = runSync(this.display.block(state.cursor, state.stop));
15940
+ const height = Math.max(1, state.viewport);
15941
+ if (span.rows <= height) return false;
15942
+ const room = delta > 0 ? span.start + span.rows - height : span.start;
15943
+ if (delta > 0 ? state.scroll >= room : state.scroll <= room) return false;
15944
+ this.commit(scrolled(state, delta * Math.max(1, height - 2)));
15945
+ return true;
15946
+ }
16198
15947
  commitSynced(action) {
16199
15948
  return gen({ self: this }, function* () {
16200
15949
  const was = this.state.patchIndex;
@@ -16205,7 +15954,7 @@ var init_app = __esmMin((() => {
16205
15954
  rolled(delta) {
16206
15955
  return gen({ self: this }, function* () {
16207
15956
  const was = this.state.patchIndex;
16208
- this.commit(railMoved(this.measured(), delta));
15957
+ this.commit(railScrolled(this.measured(), delta));
16209
15958
  if (this.state.patchIndex !== was) yield* this.turnedTo();
16210
15959
  });
16211
15960
  }
@@ -16236,64 +15985,6 @@ var init_app = __esmMin((() => {
16236
15985
  this.commit(withNotice(atFile(next, target), `marked ${patch.path}`));
16237
15986
  });
16238
15987
  }
16239
- request() {
16240
- const patch = selectedPatch(this.state);
16241
- const branch = selectedBranch(this.state);
16242
- const [from, to] = selectionRange(this.state);
16243
- if (patch === void 0 || branch === void 0 || this.state.draft.length === 0) return void 0;
16244
- const anchor = anchorFor(patch, from, to);
16245
- if (isNone(anchor)) return void 0;
16246
- return {
16247
- repo: this.repo,
16248
- branch: branch.branch,
16249
- file: patch.path,
16250
- side: anchor.value.side,
16251
- start: anchor.value.start,
16252
- end: anchor.value.end,
16253
- body: this.state.draft,
16254
- id: randomUUID(),
16255
- at: (/* @__PURE__ */ new Date()).toISOString()
16256
- };
16257
- }
16258
- stage() {
16259
- return gen({ self: this }, function* () {
16260
- const editing = this.state.editing;
16261
- if (editing !== void 0) {
16262
- yield* this.restage(editing);
16263
- return;
16264
- }
16265
- const request = this.request();
16266
- if (request === void 0) {
16267
- this.commit(withNotice(this.state, "nothing to stage"));
16268
- return;
16269
- }
16270
- yield* stageComment(request);
16271
- const branch = selectedBranch(this.state);
16272
- const pending = branch === void 0 ? [] : yield* listPending(this.repo, branch.branch);
16273
- const next = withPending(this.state, pending, "review");
16274
- this.commit(withNotice(next, `${pending.length} staged, press S to send`));
16275
- });
16276
- }
16277
- restage(id) {
16278
- return gen({ self: this }, function* () {
16279
- const branch = selectedBranch(this.state);
16280
- if (branch === void 0) return;
16281
- yield* editStaged({
16282
- repo: this.repo,
16283
- branch: branch.branch,
16284
- id,
16285
- body: this.state.draft
16286
- });
16287
- const pending = yield* listPending(this.repo, branch.branch);
16288
- const next = withPending({
16289
- ...this.state,
16290
- editing: void 0,
16291
- draft: "",
16292
- caret: 0
16293
- }, pending, "pending");
16294
- this.commit(withNoticeHere(next, "reworded"));
16295
- });
16296
- }
16297
15988
  loadSent(branch) {
16298
15989
  return listSent(this.repo, branch);
16299
15990
  }
@@ -16333,9 +16024,16 @@ var init_app = __esmMin((() => {
16333
16024
  const source = yield* fileSource(this.repo, branch.branch, asked);
16334
16025
  if (selectedPatch(this.state)?.path !== asked) return;
16335
16026
  this.commit(withSource(this.state, source));
16336
- yield* this.display.light(asked, "new", source);
16337
16027
  const before = yield* fileBefore(this.repo, branch.branch, asked);
16338
- if (before.length > 0) yield* this.display.light(asked, "old", before);
16028
+ if (selectedPatch(this.state)?.path !== asked) return;
16029
+ this.stopLighting();
16030
+ this.lighting = yield* forkDetach(this.lightUp(asked, source, before));
16031
+ });
16032
+ }
16033
+ lightUp(path, source, before) {
16034
+ return gen({ self: this }, function* () {
16035
+ yield* this.display.light(path, "new", source);
16036
+ if (before.length > 0) yield* this.display.light(path, "old", before);
16339
16037
  });
16340
16038
  }
16341
16039
  expand(delta) {
@@ -16353,52 +16051,6 @@ var init_app = __esmMin((() => {
16353
16051
  this.commit(withContext(this.state, next, patches, cursor));
16354
16052
  });
16355
16053
  }
16356
- openPending() {
16357
- return gen({ self: this }, function* () {
16358
- const branch = selectedBranch(this.state);
16359
- if (branch === void 0) return;
16360
- const pending = yield* listPending(this.repo, branch.branch);
16361
- if (pending.length === 0) {
16362
- this.commit(withNotice(this.state, "nothing staged"));
16363
- return;
16364
- }
16365
- this.commit(withPending(this.state, pending, "pending"));
16366
- });
16367
- }
16368
- editStagedComment() {
16369
- const entry = this.state.pending[this.state.pendingIndex];
16370
- if (entry?.id === void 0) return;
16371
- this.commit(withDraft({
16372
- ...this.state,
16373
- screen: "compose",
16374
- editing: entry.id
16375
- }, entry.body));
16376
- }
16377
- dropStagedComment() {
16378
- return gen({ self: this }, function* () {
16379
- const branch = selectedBranch(this.state);
16380
- const entry = this.state.pending[this.state.pendingIndex];
16381
- if (branch === void 0 || entry?.id === void 0) return;
16382
- yield* dropStaged(this.repo, branch.branch, entry.id);
16383
- const pending = yield* listPending(this.repo, branch.branch);
16384
- const kept = withPending(this.state, pending, pending.length === 0 ? "review" : "pending");
16385
- const at = Math.min(this.state.pendingIndex, Math.max(0, pending.length - 1));
16386
- const said = pending.length === 0 ? "nothing staged" : `withdrawn — ${pending.length} left`;
16387
- this.commit(withNoticeHere({
16388
- ...kept,
16389
- pendingIndex: at
16390
- }, said));
16391
- });
16392
- }
16393
- sendReview() {
16394
- return gen({ self: this }, function* () {
16395
- const branch = selectedBranch(this.state);
16396
- if (branch === void 0) return;
16397
- const report = yield* submitReview(this.repo, branch.branch, randomUUID(), (/* @__PURE__ */ new Date()).toISOString());
16398
- const cleared = withSent(withPending(this.state, [], "review"), yield* this.loadSent(branch.branch));
16399
- this.commit(withNotice(cleared, `review sent — ${report.submitted} comment${report.submitted === 1 ? "" : "s"}, one wake-up`));
16400
- });
16401
- }
16402
16054
  remember(action, key) {
16403
16055
  if (takesText(this.state.screen) && action === void 0) return;
16404
16056
  const named = action ?? keyName(key);
@@ -16536,7 +16188,8 @@ var tui_exports = /* @__PURE__ */ __exportAll({
16536
16188
  palette: () => palette,
16537
16189
  runOn: () => runOn,
16538
16190
  runTui: () => runTui,
16539
- searchCommands: () => searchCommands
16191
+ searchCommands: () => searchCommands,
16192
+ syntaxTheme: () => syntaxTheme
16540
16193
  });
16541
16194
  var init_tui = __esmMin((() => {
16542
16195
  init_app();
@@ -16620,42 +16273,12 @@ const commentResolve = fn("Main.commentResolve")(function* (options) {
16620
16273
  });
16621
16274
  const commentRemove = fn("Main.commentRemove")(function* (options) {
16622
16275
  const report = yield* removeComment(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"), options["at"] ?? (/* @__PURE__ */ new Date()).toISOString());
16623
- yield* answer(options, {
16624
- removed: report.removed,
16625
- staged: report.staged
16626
- });
16276
+ yield* answer(options, { removed: report.removed });
16627
16277
  });
16628
16278
  const commentRestore = fn("Main.commentRestore")(function* (options) {
16629
16279
  const report = yield* restoreComment(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"));
16630
16280
  yield* answer(options, { restored: report.restored });
16631
16281
  });
16632
- const commentStage = fn("Main.commentStage")(function* (options) {
16633
- const report = yield* stageComment({
16634
- repo: yield* required(options, "repo"),
16635
- branch: yield* required(options, "branch"),
16636
- file: yield* required(options, "file"),
16637
- start: yield* numeric(options, "start"),
16638
- end: yield* numeric(options, "end"),
16639
- body: yield* required(options, "body"),
16640
- side: options["side"] === "old" ? "old" : "new",
16641
- id: options["id"] ?? randomUUID(),
16642
- at: options["at"] ?? (/* @__PURE__ */ new Date()).toISOString()
16643
- });
16644
- yield* answer(options, { pending: report.pending });
16645
- });
16646
- const commentEdit = fn("Main.commentEdit")(function* (options) {
16647
- const report = yield* editStaged({
16648
- repo: yield* required(options, "repo"),
16649
- branch: yield* required(options, "branch"),
16650
- id: yield* required(options, "id"),
16651
- body: yield* required(options, "body")
16652
- });
16653
- yield* answer(options, { pending: report.pending });
16654
- });
16655
- const reviewSend = fn("Main.reviewSend")(function* (options) {
16656
- const report = yield* submitReview(yield* required(options, "repo"), yield* required(options, "branch"), options["id"] ?? randomUUID(), options["at"] ?? (/* @__PURE__ */ new Date()).toISOString());
16657
- yield* answer(options, { sent: report.submitted });
16658
- });
16659
16282
  const fileReview = fn("Main.fileReview")(function* (options) {
16660
16283
  const report = yield* toggleVouch({
16661
16284
  repo: yield* required(options, "repo"),
@@ -16671,8 +16294,7 @@ const reviewStatus = fn("Main.reviewStatus")(function* (options) {
16671
16294
  const report = yield* reviewProgress(yield* required(options, "repo"), yield* required(options, "branch"), options["base"]);
16672
16295
  yield* answer(options, {
16673
16296
  reviewed: report.vouched,
16674
- total: report.total,
16675
- pending: report.pending
16297
+ total: report.total
16676
16298
  });
16677
16299
  });
16678
16300
  const documentAt = fn("Main.documentAt")(function* (source) {
@@ -16728,15 +16350,12 @@ const routes = {
16728
16350
  "base set": baseSet,
16729
16351
  "base clear": baseClear,
16730
16352
  "comment send": commentSend,
16731
- "comment stage": commentStage,
16732
- "comment edit": commentEdit,
16733
16353
  "comment take": commentTake,
16734
16354
  "comment answer": commentAnswer,
16735
16355
  "comment list": commentList,
16736
16356
  "comment resolve": commentResolve,
16737
16357
  "comment remove": commentRemove,
16738
16358
  "comment restore": commentRestore,
16739
- "review send": reviewSend,
16740
16359
  "review pane": reviewPane,
16741
16360
  "review progress": reviewStatus,
16742
16361
  "layers set": layersSet,