@eliya-oss/agent-diff 0.1.0-alpha.179 → 0.1.0-alpha.180

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
@@ -2684,7 +2684,7 @@ var init_references = __esmMin((() => {
2684
2684
  };
2685
2685
  };
2686
2686
  spanCleaner = /*#__PURE__*/ makeStackCleaner(3);
2687
- })), Interrupt, causeInterrupt, findFail, findError$1, findDefect, hasInterrupts, causeFilterInterruptors, hasInterruptsOnly$1, causeCombine, causeMap, causePartition, causeSquash, causePrettyErrors, causePrettyError, causePrettyMessage, locationRegExp, cleanErrorStack, addStackAnnotations, interruptCauseStack, currentStackTrace, causePretty, renderPrettyError, renderErrorCause, FiberTypeId, fiberVariance, fiberIdStore, getCurrentFiber, FiberImpl, deferredInterruptCont, fiberMiddleware, fiberStackAnnotations, fiberAwait, fiberAwaitAll, fiberJoin, fiberInterrupt, fiberInterruptAs, fiberInterruptAll, succeed$5, failCause$3, fail$2, sync$1, suspend$1, yieldNowWith, yieldNow, succeedNone$1, failCauseSync$1, die$1, failSync, void_$2, try_$1, promise$1, tryPromise$1, withFiberId, callbackOptions, asyncFinalizer, callback$2, never, gen$1, fnUntraced$1, defineFunctionLength, fnStackCleaner, fn$1, makeFn, fnUntracedEager$1, fromIteratorEagerUnsafe, fromIteratorUnsafe, as$1, asSome, andThen$1, tap$1, asVoid$1, raceAllFirst, raceFirst$1, flatMap$1, OnSuccessProto, effectIsExit, flatMapEager$1, map$3, mapEager$1, mapErrorEager$1, catchEager$1, exitInterrupt$1, exitIsSuccess, exitIsFailure, exitFilterCause, exitHasInterrupts, exitVoid, exitMap, exitMapError, exitAsVoidAll, updateContext, updateService, context$1, getContext, contextWith$1, provideContext, provideService, provideServiceImpl, when$1, forever$2, catchCause$1, OnFailureProto, catchCauseFilter, catch_, catchDefect$1, catchIf, catchTag$1, mapError$1, orDie$1, orElseSucceed$1, ignore$1, option$3, result$1, matchCauseEffect, OnSuccessAndFailureProto, matchEffect$1, match, matchEager, exit$1, exitPrimitive, ScopeTypeId, ScopeCloseableTypeId, scopeTag, scopeClose, scopeCloseUnsafe, scopeCloseFinalizers, scopeForkUnsafe, scopeAddFinalizerExit, scopeAddFinalizer, scopeAddFinalizerUnsafe, scopeRemoveFinalizerUnsafe, scopeMakeUnsafe, constScopeEmpty, scope, provideScope, scoped$1, scopedWith, acquireRelease$1, addFinalizer$2, onExitPrimitive, onExit$1, ensuring$1, onExitFilter, onError$1, onErrorFilter, onInterrupt$1, acquireUseRelease$1, interrupt$1, uninterruptible$1, setInterruptible, setInterruptibleTrue, setInterruptibleFalse, setFiberInterruptible, interruptible, uninterruptibleMask$1, all$1, whileLoop$1, forEach$1, forEachSequential, iterateEagerImpl, iterateEager, forEachConcurrent, forkUnsafe$1, forkIn$1, forkScoped$1, runForkWith$1, runFork$1, runPromiseExitWith, runPromiseWith, runPromise$1, runSyncExitWith, runSyncExit$1, runSyncWith, runSync$1, succeedTrue, succeedFalse, Latch, makeLatchUnsafe, bigint0, NoopSpanProto, noopSpan, filterDisablePropagation, makeSpanUnsafe, provideSpanStackFrame, endSpan, useSpan, provideParentSpan, withParentSpan, withSpan$1, ClockRef, MAX_TIMER_MILLIS, ClockImpl, nanosPerMilli, monotonicNowNanos, wallTimeNanos, clockWith, sleep$1, AsyncFiberErrorTypeId, AsyncFiberError, UnknownErrorTypeId, UnknownError, ConsoleRef, logLevelToOrder, LogLevelOrder, isLogLevelGreaterThan, CurrentLoggers, LogToStderr, LoggerTypeId, LoggerProto, loggerMake, formatLabel, formatLogSpan, logWithLevel, colors, defaultDateFormat, defaultLogger, tracerLogger, init_effect = __esmMin((() => {
2687
+ })), Interrupt, causeInterrupt, findFail, findError$1, findDefect, hasInterrupts, causeFilterInterruptors, hasInterruptsOnly$1, causeCombine, causeMap, causePartition, causeSquash, causePrettyErrors, causePrettyError, causePrettyMessage, locationRegExp, cleanErrorStack, addStackAnnotations, interruptCauseStack, currentStackTrace, causePretty, renderPrettyError, renderErrorCause, FiberTypeId, fiberVariance, fiberIdStore, getCurrentFiber, FiberImpl, deferredInterruptCont, fiberMiddleware, fiberStackAnnotations, fiberAwait, fiberAwaitAll, fiberJoin, fiberInterrupt, fiberInterruptAs, fiberInterruptAll, succeed$5, failCause$3, fail$2, sync$1, suspend$1, yieldNowWith, yieldNow, succeedNone$1, failCauseSync$1, die$1, failSync, void_$2, try_$1, promise$1, tryPromise$1, withFiberId, callbackOptions, asyncFinalizer, callback$2, never, gen$1, fnUntraced$1, defineFunctionLength, fnStackCleaner, fn$1, makeFn, fnUntracedEager$1, fromIteratorEagerUnsafe, fromIteratorUnsafe, as$1, asSome, andThen$1, tap$1, asVoid$1, raceAllFirst, raceFirst$1, flatMap$1, OnSuccessProto, effectIsExit, flatMapEager$1, map$3, mapEager$1, mapErrorEager$1, catchEager$1, exitInterrupt$1, exitIsSuccess, exitIsFailure, exitFilterCause, exitHasInterrupts, exitVoid, exitMap, exitMapError, exitAsVoidAll, updateContext, updateService, context$1, getContext, contextWith$1, provideContext, provideService, provideServiceImpl, when$1, forever$2, catchCause$1, OnFailureProto, catchCauseFilter, catch_, catchDefect$1, catchIf, catchFilter, catchTag$1, catchTags$1, mapError$1, orDie$1, orElseSucceed$1, ignore$1, option$3, result$1, matchCauseEffect, OnSuccessAndFailureProto, matchEffect$1, match, matchEager, exit$1, exitPrimitive, ScopeTypeId, ScopeCloseableTypeId, scopeTag, scopeClose, scopeCloseUnsafe, scopeCloseFinalizers, scopeForkUnsafe, scopeAddFinalizerExit, scopeAddFinalizer, scopeAddFinalizerUnsafe, scopeRemoveFinalizerUnsafe, scopeMakeUnsafe, constScopeEmpty, scope, provideScope, scoped$1, scopedWith, acquireRelease$1, addFinalizer$2, onExitPrimitive, onExit$1, ensuring$1, onExitFilter, onError$1, onErrorFilter, onInterrupt$1, acquireUseRelease$1, interrupt$1, uninterruptible$1, setInterruptible, setInterruptibleTrue, setInterruptibleFalse, setFiberInterruptible, interruptible, uninterruptibleMask$1, all$1, whileLoop$1, forEach$1, forEachSequential, iterateEagerImpl, iterateEager, forEachConcurrent, forkUnsafe$1, forkIn$1, forkScoped$1, runForkWith$1, runFork$1, runPromiseExitWith, runPromiseWith, runPromise$1, runSyncExitWith, runSyncExit$1, runSyncWith, runSync$1, succeedTrue, succeedFalse, Latch, makeLatchUnsafe, bigint0, NoopSpanProto, noopSpan, filterDisablePropagation, makeSpanUnsafe, provideSpanStackFrame, endSpan, useSpan, provideParentSpan, withParentSpan, withSpan$1, ClockRef, MAX_TIMER_MILLIS, ClockImpl, nanosPerMilli, monotonicNowNanos, wallTimeNanos, clockWith, sleep$1, AsyncFiberErrorTypeId, AsyncFiberError, UnknownErrorTypeId, UnknownError, ConsoleRef, logLevelToOrder, LogLevelOrder, isLogLevelGreaterThan, CurrentLoggers, LogToStderr, LoggerTypeId, LoggerProto, loggerMake, formatLabel, formatLogSpan, logWithLevel, colors, defaultDateFormat, defaultLogger, tracerLogger, init_effect = __esmMin((() => {
2688
2688
  init_Array();
2689
2689
  init_Context();
2690
2690
  init_Duration();
@@ -3506,10 +3506,24 @@ var init_references = __esmMin((() => {
3506
3506
  if (!predicate(error.success)) return orElse ? internalCall(() => orElse(error.success)) : failCause$3(cause);
3507
3507
  return internalCall(() => f(error.success));
3508
3508
  }));
3509
+ catchFilter = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, filter, f, orElse) => catchCause$1(self, (cause) => {
3510
+ const error = findError$1(cause);
3511
+ if (isFailure$1(error)) return failCause$3(error.failure);
3512
+ const result = filter(error.success);
3513
+ if (isFailure$1(result)) return orElse ? internalCall(() => orElse(result.failure)) : failCause$3(cause);
3514
+ return internalCall(() => f(result.success));
3515
+ }));
3509
3516
  catchTag$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, k, f, orElse) => {
3510
3517
  const pred = Array.isArray(k) ? (e) => hasProperty(e, "_tag") && k.includes(e._tag) : isTagged(k);
3511
3518
  return catchIf(self, pred, f, orElse);
3512
3519
  });
3520
+ catchTags$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, cases, orElse) => {
3521
+ let keys;
3522
+ return catchFilter(self, (e) => {
3523
+ keys ??= Object.keys(cases);
3524
+ return hasProperty(e, "_tag") && isString(e["_tag"]) && keys.includes(e["_tag"]) ? succeed$6(e) : fail$3(e);
3525
+ }, (e) => internalCall(() => cases[e["_tag"]](e)), orElse);
3526
+ });
3513
3527
  mapError$1 = /*#__PURE__*/ dual(2, (self, f) => catch_(self, (error) => failSync(() => f(error))));
3514
3528
  orDie$1 = (self) => catch_(self, die$1);
3515
3529
  orElseSucceed$1 = /*#__PURE__*/ dual(2, (self, f) => catch_(self, (_) => sync$1(f)));
@@ -4775,7 +4789,7 @@ var repeatOrElse, retryOrElse, repeat$1, retry$1, passthroughForever, buildFromO
4775
4789
  if (options.times !== void 0) schedule = while_(schedule, ({ attempt }) => succeed$5(attempt <= options.times));
4776
4790
  return schedule;
4777
4791
  };
4778
- })), isEffect, all, forEach, whileLoop, promise, tryPromise, succeed$1, succeedNone, suspend, sync, void_, callback$1, gen, fail, failCause, failCauseSync, die, try_, withFiber, flatMap, andThen, tap, result, option$2, exit, map$1, as, asVoid, catchTag, catchCause, catchDefect, mapError, orDie, retry, ignore, orElseSucceed, sleep, raceFirst, when, context, contextWith, provide, scoped, acquireRelease, acquireUseRelease, addFinalizer, ensuring, onError, onExit, interrupt, onInterrupt, uninterruptible, uninterruptibleMask, forever, repeat, withSpan, forkIn, forkScoped, runFork, runForkWith, runPromise, runSync, runSyncExit, fnUntraced, fn, mapEager, mapErrorEager, flatMapEager, catchEager, fnUntracedEager;
4792
+ })), isEffect, all, forEach, whileLoop, promise, tryPromise, succeed$1, succeedNone, suspend, sync, void_, callback$1, gen, fail, failCause, failCauseSync, die, try_, withFiber, flatMap, andThen, tap, result, option$2, exit, map$1, as, asVoid, catchTag, catchTags, catchCause, catchDefect, mapError, orDie, retry, ignore, orElseSucceed, sleep, raceFirst, when, context, contextWith, provide, scoped, acquireRelease, acquireUseRelease, addFinalizer, ensuring, onError, onExit, interrupt, onInterrupt, uninterruptible, uninterruptibleMask, forever, repeat, withSpan, forkIn, forkScoped, runFork, runForkWith, runPromise, runSync, runSyncExit, fnUntraced, fn, mapEager, mapErrorEager, flatMapEager, catchEager, fnUntracedEager;
4779
4793
  var init_Effect = __esmMin((() => {
4780
4794
  init_Context();
4781
4795
  init_core();
@@ -4811,6 +4825,7 @@ var init_Effect = __esmMin((() => {
4811
4825
  as = as$1;
4812
4826
  asVoid = asVoid$1;
4813
4827
  catchTag = catchTag$1;
4828
+ catchTags = catchTags$1;
4814
4829
  catchCause = catchCause$1;
4815
4830
  catchDefect = catchDefect$1;
4816
4831
  mapError = mapError$1;
@@ -10027,7 +10042,7 @@ var init_config = __esmMin((() => {
10027
10042
  //#region package.json
10028
10043
  init_pane();
10029
10044
  init_config();
10030
- var version$1 = "0.1.0-alpha.179";
10045
+ var version$1 = "0.1.0-alpha.180";
10031
10046
  //#endregion
10032
10047
  //#region src/cli/error.ts
10033
10048
  var UnknownCommand, MissingOption, UnknownField, UnknownOption, BadOption, RegistryUnanswered;
@@ -12001,7 +12016,8 @@ var init_model$4 = __esmMin((() => {
12001
12016
  removed: {},
12002
12017
  base: "",
12003
12018
  read: {},
12004
- dismissed: {}
12019
+ dismissed: {},
12020
+ seen: {}
12005
12021
  };
12006
12022
  }));
12007
12023
  //#endregion
@@ -12023,7 +12039,9 @@ var init_schema = __esmMin((() => {
12023
12039
  anchor: Anchor,
12024
12040
  body: String$1,
12025
12041
  replyTo: optionalKey(String$1),
12026
- remark: optionalKey(String$1)
12042
+ remark: optionalKey(String$1),
12043
+ theirs: optionalKey(Boolean),
12044
+ draft: optionalKey(String$1)
12027
12045
  });
12028
12046
  StoredDraft = Struct({
12029
12047
  id: String$1,
@@ -12062,7 +12080,8 @@ var init_schema = __esmMin((() => {
12062
12080
  removed: Stamps.pipe(noStamps),
12063
12081
  base: String$1.pipe(withDecodingDefaultKey(succeed$1(""))),
12064
12082
  read: Counts.pipe(withDecodingDefaultKey(succeed$1({}))),
12065
- dismissed: Stamps.pipe(noStamps)
12083
+ dismissed: Stamps.pipe(noStamps),
12084
+ seen: Stamps.pipe(noStamps)
12066
12085
  });
12067
12086
  StoredSaid = Struct({
12068
12087
  by: String$1,
@@ -13087,6 +13106,7 @@ var init_comments$1 = __esmMin((() => {
13087
13106
  unread: Math.max(0, said.length - seen),
13088
13107
  asks: last?.voice === "agent" && last.asks,
13089
13108
  ...takenAt === void 0 ? {} : { takenAt },
13109
+ ...comment.draft === void 0 ? {} : { draft: comment.draft },
13090
13110
  answers: said.map(bodyOf),
13091
13111
  turns: spun.map((turn) => ({
13092
13112
  voice: turn.voice,
@@ -13165,7 +13185,9 @@ var init_comments$1 = __esmMin((() => {
13165
13185
  end: comment.anchor.end,
13166
13186
  snippet: comment.anchor.snippet,
13167
13187
  body: comment.body,
13168
- replyTo: comment.replyTo
13188
+ replyTo: comment.replyTo,
13189
+ ...comment.theirs === true ? { theirs: true } : {},
13190
+ ...comment.draft === void 0 ? {} : { draft: comment.draft }
13169
13191
  })));
13170
13192
  listSent = fn("Review.Comment.listSent")(function* (reading) {
13171
13193
  const store = yield* Store;
@@ -13196,7 +13218,9 @@ var init_comments$1 = __esmMin((() => {
13196
13218
  id: request.id,
13197
13219
  anchor: anchored,
13198
13220
  body: request.body,
13199
- ...request.remark === void 0 ? {} : { remark: request.remark }
13221
+ ...request.remark === void 0 ? {} : { remark: request.remark },
13222
+ ...request.theirs === true ? { theirs: true } : {},
13223
+ ...request.draft === void 0 ? {} : { draft: request.draft }
13200
13224
  };
13201
13225
  });
13202
13226
  const anchored = yield* forEach(requests, anchoring);
@@ -13509,7 +13533,7 @@ var init_error$1 = __esmMin((() => {
13509
13533
  }));
13510
13534
  //#endregion
13511
13535
  //#region src/service/forge/service.ts
13512
- var Forge, LIMIT, TIMEOUT_MS, SEND_TIMEOUT_MS, MOST_OUTPUT, FIELDS$1, Row, decode$1, SAID, stateOf$1, ended, ask, show$1, read$2, pulls, openPull, NUMBER_FIELDS, Named, readNamed, gh, named$2, head, sideName, commentBody, bodyFor, Landed, readLanded, jsonOf$1, keyOf$2, counted$1, acknowledged, landedIn, THREADS, Said, Thread, Page, Held$1, Threads, readThreads, ANONYMOUS, heardFrom$1, someLine, hasNoLine, quotedIn, spanIn, remarkOf, ownerOf, HERE, asked, whereOf, threadsIn, unresolved, PAGES, everyThread, answer$2, remarks, review, ForgeLive;
13536
+ var Forge, LIMIT, TIMEOUT_MS, SEND_TIMEOUT_MS, MOST_OUTPUT, FIELDS$1, Author, Row, Viewer, readViewer, decode$1, SAID, stateOf$1, ended, ask, show$1, whoseOf, pullOf, read$2, viewerOf, pulls, openPull, NUMBER_FIELDS, Named, readNamed, gh, named$2, head, sideName, commentBody, bodyFor, Landed, readLanded, jsonOf$1, keyOf$2, counted$1, acknowledged, landedIn, THREADS, Said, Thread, Page, Held$1, Threads, readThreads, ANONYMOUS, heardFrom$1, someLine, hasNoLine, quotedIn, spanIn, remarkOf, ownerOf, HERE, asked, whereOf, threadsIn, unresolved, PAGES, everyThread, answer$2, remarks, review, ForgeLive;
13513
13537
  var init_service = __esmMin((() => {
13514
13538
  init_dist();
13515
13539
  init_error$1();
@@ -13518,12 +13542,19 @@ var init_service = __esmMin((() => {
13518
13542
  TIMEOUT_MS = 4e3;
13519
13543
  SEND_TIMEOUT_MS = 2e4;
13520
13544
  MOST_OUTPUT = 4194304;
13521
- FIELDS$1 = "headRefName,state,isDraft";
13545
+ FIELDS$1 = "headRefName,state,isDraft,author";
13546
+ Author = Struct({
13547
+ login: String$1,
13548
+ is_bot: optionalKey(Boolean)
13549
+ });
13522
13550
  Row = Struct({
13523
13551
  headRefName: String$1,
13524
13552
  state: String$1,
13525
- isDraft: Boolean
13553
+ isDraft: Boolean,
13554
+ author: optionalKey(Author)
13526
13555
  });
13556
+ Viewer = Struct({ login: String$1 });
13557
+ readViewer = decodeUnknownEffect(Viewer);
13527
13558
  decode$1 = decodeUnknownEffect(ArraySchema(Row));
13528
13559
  SAID = [
13529
13560
  "OPEN",
@@ -13583,7 +13614,23 @@ var init_service = __esmMin((() => {
13583
13614
  });
13584
13615
  return ended(child);
13585
13616
  });
13586
- read$2 = fn("Forge.read")(function* (repo, raw) {
13617
+ whoseOf = (row, viewer) => {
13618
+ const author = row.author?.login ?? "";
13619
+ return {
13620
+ author,
13621
+ theirs: row.author?.is_bot === true || author.length > 0 && author !== viewer
13622
+ };
13623
+ };
13624
+ pullOf = (row, viewer) => {
13625
+ const whose = whoseOf(row, viewer);
13626
+ return {
13627
+ branch: row.headRefName,
13628
+ state: stateOf$1(row),
13629
+ author: whose.author,
13630
+ theirs: whose.theirs
13631
+ };
13632
+ };
13633
+ read$2 = fn("Forge.read")(function* (repo, raw, viewer) {
13587
13634
  const parsed = yield* try_({
13588
13635
  try: () => JSON.parse(raw),
13589
13636
  catch: (cause) => new ForgeUnavailable({
@@ -13594,14 +13641,25 @@ var init_service = __esmMin((() => {
13594
13641
  return (yield* mapError(decode$1(parsed), (cause) => new ForgeUnavailable({
13595
13642
  repo,
13596
13643
  reason: String(cause)
13597
- }))).map((row) => ({
13598
- branch: row.headRefName,
13599
- state: stateOf$1(row)
13600
- }));
13644
+ }))).map((row) => pullOf(row, viewer));
13645
+ });
13646
+ viewerOf = fn("Forge.viewer")(function* (repo) {
13647
+ const raw = yield* gh(repo, ["api", "user"]);
13648
+ const parsed = yield* try_({
13649
+ try: () => JSON.parse(raw),
13650
+ catch: (cause) => new ForgeUnavailable({
13651
+ repo,
13652
+ reason: String(cause)
13653
+ })
13654
+ });
13655
+ return (yield* mapError(readViewer(parsed), (cause) => new ForgeUnavailable({
13656
+ repo,
13657
+ reason: String(cause)
13658
+ }))).login;
13601
13659
  });
13602
13660
  pulls = fn("Forge.pulls")(function* (repo) {
13603
- const raw = yield* ask(repo);
13604
- return yield* read$2(repo, raw);
13661
+ const [raw, viewer] = yield* all([ask(repo), viewerOf(repo)], { concurrency: 2 });
13662
+ return yield* read$2(repo, raw, viewer);
13605
13663
  });
13606
13664
  openPull = fn("Forge.openPull")(function* (repo, branch) {
13607
13665
  yield* show$1(repo, branch);
@@ -13627,7 +13685,9 @@ var init_service = __esmMin((() => {
13627
13685
  reason: said
13628
13686
  })));
13629
13687
  });
13630
- if (input !== void 0) child.stdin?.end(input);
13688
+ child.stdin?.on("error", () => void 0);
13689
+ if (input === void 0) child.stdin?.end();
13690
+ else child.stdin?.end(input);
13631
13691
  return ended(child);
13632
13692
  });
13633
13693
  named$2 = fn("Forge.named")(function* (repo, branch) {
@@ -13916,7 +13976,7 @@ var init_service = __esmMin((() => {
13916
13976
  var init_forge = __esmMin((() => {
13917
13977
  init_service();
13918
13978
  init_error$1();
13919
- })), VERSION, OPENING, CLOSING, heldOf, bared, dropped, quotedCode, snippetOf$1, spokenWithout, spanOf, showsLine, placedNow, stateOf, heldPair, accepted, shownOf$1, fetch$1, held$1, against, list$2, named$1, without, notTaken, dismiss, restore, quoted, anchorFrom, takingOn, accept, answer$1;
13979
+ })), VERSION, OPENING, CLOSING, heldOf$1, bared, dropped, quotedCode, snippetOf$1, spokenWithout, spanOf, showsLine, placedNow, stateOf, heldPair, accepted, shownOf$1, fetch$1, held$1, against, list$2, named$1, without, notTaken, dismiss, restore, quoted, anchorFrom, takingOn, accept, answer$1;
13920
13980
  var init_remarks$1 = __esmMin((() => {
13921
13981
  init_dist();
13922
13982
  init_patch();
@@ -13926,7 +13986,7 @@ var init_remarks$1 = __esmMin((() => {
13926
13986
  VERSION = 1;
13927
13987
  OPENING = /^```suggestion[^\n]*\n?/gm;
13928
13988
  CLOSING = /^```[ \t]*$/gm;
13929
- heldOf = (one) => ({
13989
+ heldOf$1 = (one) => ({
13930
13990
  id: one.id,
13931
13991
  answerTo: one.answerTo,
13932
13992
  moreReplies: one.moreReplies,
@@ -14018,7 +14078,7 @@ var init_remarks$1 = __esmMin((() => {
14018
14078
  const forge = yield* Forge;
14019
14079
  const worktree = reading.worktree;
14020
14080
  const found = yield* forge.remarks(repo, worktree.branch);
14021
- const held = [...new Map(found.map((one) => [one.id, one])).values()].map(heldOf);
14081
+ const held = [...new Map(found.map((one) => [one.id, one])).values()].map(heldOf$1);
14022
14082
  yield* store.saveRemarks(worktree.path, {
14023
14083
  version: VERSION,
14024
14084
  head: worktree.head,
@@ -14591,25 +14651,43 @@ var init_layers = __esmMin((() => {
14591
14651
  }));
14592
14652
  //#endregion
14593
14653
  //#region src/review/drafts.ts
14594
- var reported, list, add$1, edit, drop, sameCommit, commentOf, sending, dispatch$1;
14654
+ var unreadIn, reported, list, markSeen, add$1, edit, drop, sameCommit, commentOf, sending, dispatch$1;
14595
14655
  var init_drafts$1 = __esmMin((() => {
14596
14656
  init_dist();
14597
14657
  init_forge();
14598
14658
  init_store();
14599
14659
  init_error$2();
14600
14660
  init_patches();
14601
- reported = (draft) => ({
14661
+ unreadIn = (draft, seen) => {
14662
+ if (draft.wroteBy !== "agent") return false;
14663
+ const last = seen[draft.id];
14664
+ return last === void 0 || last < draft.at;
14665
+ };
14666
+ reported = (draft, seen) => ({
14602
14667
  id: draft.id,
14603
14668
  file: draft.anchor.path,
14604
14669
  side: draft.anchor.side,
14605
14670
  start: draft.anchor.start,
14606
14671
  end: draft.anchor.end,
14607
14672
  body: draft.body,
14673
+ snippet: draft.anchor.snippet,
14608
14674
  at: draft.at,
14609
- wroteBy: draft.wroteBy
14675
+ wroteBy: draft.wroteBy,
14676
+ unread: unreadIn(draft, seen)
14610
14677
  });
14611
14678
  list = fn("Review.Draft.list")(function* (worktree) {
14612
- return (yield* (yield* Store).drafts(worktree.path)).map(reported);
14679
+ const store = yield* Store;
14680
+ const seen = (yield* store.state(worktree.path)).seen;
14681
+ return (yield* store.drafts(worktree.path)).map((one) => reported(one, seen));
14682
+ });
14683
+ markSeen = fn("Review.Draft.markSeen")(function* (worktree, id, at) {
14684
+ yield* (yield* Store).changeState(worktree.path, (current) => ({
14685
+ ...current,
14686
+ seen: {
14687
+ ...current.seen,
14688
+ [id]: at
14689
+ }
14690
+ }));
14613
14691
  });
14614
14692
  add$1 = fn("Review.Draft.add")(function* (worktree, request) {
14615
14693
  const store = yield* Store;
@@ -14623,20 +14701,22 @@ var init_drafts$1 = __esmMin((() => {
14623
14701
  wroteBy: request.wroteBy
14624
14702
  };
14625
14703
  yield* store.saveDrafts(worktree.path, [...held, one]);
14626
- return reported(one);
14704
+ return reported(one, {});
14627
14705
  });
14628
- edit = fn("Review.Draft.edit")(function* (worktree, id, body) {
14706
+ edit = fn("Review.Draft.edit")(function* (worktree, rewrite) {
14629
14707
  const store = yield* Store;
14630
14708
  const held = yield* store.drafts(worktree.path);
14631
- const found = held.find((one) => one.id === id);
14632
- if (found === void 0) return yield* new UnknownDraft({ id });
14709
+ const found = held.find((one) => one.id === rewrite.id);
14710
+ if (found === void 0) return yield* new UnknownDraft({ id: rewrite.id });
14633
14711
  const said = {
14634
14712
  ...found,
14635
- body
14713
+ body: rewrite.body,
14714
+ at: rewrite.at,
14715
+ wroteBy: rewrite.by
14636
14716
  };
14637
- const next = held.map((one) => one.id === id ? said : one);
14717
+ const next = held.map((one) => one.id === rewrite.id ? said : one);
14638
14718
  yield* store.saveDrafts(worktree.path, next);
14639
- return reported(said);
14719
+ return reported(said, (yield* store.state(worktree.path)).seen);
14640
14720
  });
14641
14721
  drop = fn("Review.Draft.drop")(function* (worktree, id) {
14642
14722
  const store = yield* Store;
@@ -15086,6 +15166,7 @@ var init_command = __esmMin((() => {
15086
15166
  whenReviewed: false,
15087
15167
  whenPull: false,
15088
15168
  whenHeld: false,
15169
+ whenTheirs: false,
15089
15170
  panes: EVERY_PANE,
15090
15171
  rank: 0,
15091
15172
  ...input
@@ -15786,6 +15867,23 @@ var init_command = __esmMin((() => {
15786
15867
  hint: "comment",
15787
15868
  rank: 3
15788
15869
  }),
15870
+ command({
15871
+ action: "agent.ask",
15872
+ also: [
15873
+ "ask",
15874
+ "agent",
15875
+ "question",
15876
+ "redraft"
15877
+ ],
15878
+ panes: ["diff", "review"],
15879
+ category: "Comments",
15880
+ title: "Ask the agent about the selection, or to redraft the note here",
15881
+ keys: ["i"],
15882
+ screens: ["review"],
15883
+ hint: "ask your agent",
15884
+ whenTheirs: true,
15885
+ rank: 3
15886
+ }),
15789
15887
  command({
15790
15888
  action: "held.send",
15791
15889
  also: [
@@ -15807,6 +15905,63 @@ var init_command = __esmMin((() => {
15807
15905
  whenHeld: true,
15808
15906
  rank: 1
15809
15907
  }),
15908
+ command({
15909
+ action: "send.next",
15910
+ title: "Next note",
15911
+ category: "Comments",
15912
+ keys: ["down", "j"],
15913
+ screens: ["sending"],
15914
+ hint: "move",
15915
+ listed: false
15916
+ }),
15917
+ command({
15918
+ action: "send.prev",
15919
+ title: "Previous note",
15920
+ category: "Comments",
15921
+ keys: ["up", "k"],
15922
+ screens: ["sending"],
15923
+ listed: false
15924
+ }),
15925
+ command({
15926
+ action: "send.reword",
15927
+ title: "Reword the note under the cursor",
15928
+ category: "Comments",
15929
+ keys: ["e"],
15930
+ screens: ["sending"],
15931
+ hint: "reword",
15932
+ rank: 1,
15933
+ listed: false
15934
+ }),
15935
+ command({
15936
+ action: "thread.remove",
15937
+ title: "Drop the note under the cursor",
15938
+ category: "Comments",
15939
+ keys: ["X"],
15940
+ screens: ["sending"],
15941
+ hint: "drop",
15942
+ rank: 2,
15943
+ listed: false
15944
+ }),
15945
+ command({
15946
+ action: "agent.ask",
15947
+ title: "Ask the agent to redraft the note under the cursor",
15948
+ category: "Comments",
15949
+ keys: ["i"],
15950
+ screens: ["sending"],
15951
+ hint: "ask your agent",
15952
+ rank: 3,
15953
+ listed: false
15954
+ }),
15955
+ command({
15956
+ action: "send.go",
15957
+ title: "Send every note as one review",
15958
+ category: "Comments",
15959
+ keys: ["ctrl+s"],
15960
+ screens: ["sending"],
15961
+ hint: "send",
15962
+ rank: 4,
15963
+ listed: false
15964
+ }),
15810
15965
  command({
15811
15966
  action: "report.open",
15812
15967
  title: "Report a bug",
@@ -15841,7 +15996,7 @@ var init_command = __esmMin((() => {
15841
15996
  title: "Find a command",
15842
15997
  category: "App",
15843
15998
  keys: ["ctrl+p"],
15844
- screens: ["review"],
15999
+ screens: ["review", "sending"],
15845
16000
  listed: false
15846
16001
  }),
15847
16002
  command({
@@ -15926,7 +16081,8 @@ var init_command = __esmMin((() => {
15926
16081
  screens: [
15927
16082
  "branches",
15928
16083
  "review",
15929
- "search"
16084
+ "search",
16085
+ "sending"
15930
16086
  ],
15931
16087
  hint: "keys",
15932
16088
  rank: 5,
@@ -15960,7 +16116,8 @@ var init_command = __esmMin((() => {
15960
16116
  "report",
15961
16117
  "search",
15962
16118
  "keys",
15963
- "thread"
16119
+ "thread",
16120
+ "sending"
15964
16121
  ],
15965
16122
  hint: "back",
15966
16123
  listed: false,
@@ -16020,14 +16177,18 @@ var init_command = __esmMin((() => {
16020
16177
  "panel.winnow": (offered) => offered.hidingSettled ? "show settled" : "hide settled",
16021
16178
  "thread.remove": (offered) => heldOrRemoved(offered),
16022
16179
  "thread.settle": (offered) => offered.onSettled ? "unsettle" : "settle",
16023
- "held.send": (offered) => `send ${offered.held}`
16180
+ "held.send": (offered) => offered.theirs ? `send ${offered.held} to the pull request` : `send ${offered.held}`,
16181
+ "send.go": (offered) => `send ${offered.held} to the pull request`,
16182
+ "compose.submit": (offered) => offered.rewording ? "save the note" : "send",
16183
+ "compose.open": (offered) => offered.theirs ? "note to the author" : "comment",
16184
+ "agent.ask": (offered) => offered.onHeld ? "ask your agent to redraft" : "ask your agent"
16024
16185
  };
16025
16186
  hintOf = (entry, offered) => {
16026
16187
  const swapped = SWAPPED[entry.action];
16027
16188
  if (swapped !== void 0) return swapped(offered);
16028
16189
  return entry.counted ? `${entry.hint} ${offered.comments}` : entry.hint;
16029
16190
  };
16030
- 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.whenStale || offered.stale).filter((entry) => !entry.whenThread || offered.onThread).filter((entry) => !entry.whenRemark || offered.onRemark || offered.onDismissed).filter((entry) => !entry.whenAnswerable || offered.onThread || offered.onRemark).filter((entry) => !entry.whenSelecting || offered.selecting).filter((entry) => !entry.whenReviewed || offered.reviewed > 0).filter((entry) => !entry.whenPull || offered.pull).filter((entry) => !entry.whenHeld || offered.held > 0).filter((entry) => entry.panes.includes(offered.pane)).toSorted((left, right) => left.rank - right.rank).map((entry) => ({
16191
+ 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.whenStale || offered.stale).filter((entry) => !entry.whenThread || offered.onThread).filter((entry) => !entry.whenRemark || offered.onRemark || offered.onDismissed).filter((entry) => !entry.whenAnswerable || offered.onThread || offered.onRemark).filter((entry) => !entry.whenSelecting || offered.selecting).filter((entry) => !entry.whenReviewed || offered.reviewed > 0).filter((entry) => !entry.whenPull || offered.pull).filter((entry) => !entry.whenHeld || offered.held > 0).filter((entry) => !entry.whenTheirs || offered.theirs).filter((entry) => entry.panes.includes(offered.pane)).toSorted((left, right) => left.rank - right.rank).map((entry) => ({
16031
16192
  key: displayKey(entry.keys[0] ?? ""),
16032
16193
  hint: hintOf(entry, offered),
16033
16194
  press: entry.keys[0] ?? ""
@@ -16353,11 +16514,11 @@ var init_match = __esmMin((() => {
16353
16514
  }));
16354
16515
  //#endregion
16355
16516
  //#region src/tui/state.ts
16356
- var HOLDS, chosenNow, withChosen, preferenceRows, nothingReviewed, nothingFound, initialState, selectedBranch, selectedPatch, pullHere, hasNoPull, onLayers, selectedLayer;
16517
+ var HOLDS$1, chosenNow, withChosen, preferenceRows, nothingReviewed, nothingFound, initialState, selectedBranch, selectedPatch, pullHere, authorHere, theirPull, heldWhere, noteEditing, hasNoPull, onLayers, selectedLayer;
16357
16518
  var init_state = __esmMin((() => {
16358
16519
  init_preferences$1();
16359
16520
  init_gaps();
16360
- HOLDS = {
16521
+ HOLDS$1 = {
16361
16522
  wrap: "wrap",
16362
16523
  sticky: "sticky",
16363
16524
  panel: "panelOpen",
@@ -16367,9 +16528,9 @@ var init_state = __esmMin((() => {
16367
16528
  remarks: "remarksOn",
16368
16529
  hold: "hold"
16369
16530
  };
16370
- chosenNow = (state) => Object.fromEntries(Object.entries(HOLDS).map(([name, held]) => [name, state[held] === true]));
16531
+ chosenNow = (state) => Object.fromEntries(Object.entries(HOLDS$1).map(([name, held]) => [name, state[held] === true]));
16371
16532
  withChosen = (state, name, value) => {
16372
- const held = HOLDS[name];
16533
+ const held = HOLDS$1[name];
16373
16534
  return held === void 0 ? state : {
16374
16535
  ...state,
16375
16536
  [held]: value
@@ -16386,6 +16547,11 @@ var init_state = __esmMin((() => {
16386
16547
  }));
16387
16548
  };
16388
16549
  nothingReviewed = {
16550
+ theirs: {},
16551
+ reader: "agent",
16552
+ about: void 0,
16553
+ editing: void 0,
16554
+ sendIndex: 0,
16389
16555
  held: [],
16390
16556
  arrived: [],
16391
16557
  panelOpen: true,
@@ -16475,6 +16641,10 @@ var init_state = __esmMin((() => {
16475
16641
  selectedBranch = (state) => state.branches[state.branchIndex];
16476
16642
  selectedPatch = (state) => shownOf(state)?.patch;
16477
16643
  pullHere = (state) => state.pulls[selectedBranch(state)?.branch ?? ""] ?? "";
16644
+ authorHere = (state) => state.theirs[selectedBranch(state)?.branch ?? ""] ?? "";
16645
+ theirPull = (state) => authorHere(state).length > 0;
16646
+ heldWhere = (note) => note.start === note.end ? `${note.file}:${note.end}` : `${note.file}:${note.start}-${note.end}`;
16647
+ noteEditing = (state) => state.editing === void 0 ? void 0 : state.held.find((one) => one.id === state.editing);
16478
16648
  hasNoPull = (state) => state.forge === "answered" && pullHere(state).length === 0;
16479
16649
  onLayers = (state) => state.rail === "layers" && state.layers.length > 0;
16480
16650
  selectedLayer = (state) => state.layers[state.layerIndex];
@@ -17227,7 +17397,7 @@ var init_panel = __esmMin((() => {
17227
17397
  }));
17228
17398
  //#endregion
17229
17399
  //#region src/tui/notes.ts
17230
- var threadsOn, threadsOpenOn, askedRows, withAsking, firstLineOf, askedThreads, askingWords, markedStands, 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, composeTarget;
17400
+ var threadsOn, threadsOpenOn, askedRows, withAsking, firstLineOf, askedThreads, askingWords, markedStands, 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;
17231
17401
  var init_notes = __esmMin((() => {
17232
17402
  init_dist();
17233
17403
  init_patch();
@@ -17483,7 +17653,12 @@ var init_notes = __esmMin((() => {
17483
17653
  if (patch === void 0 || layer === void 0) return [];
17484
17654
  return threadsOpenOn(state, fileIndex).filter((entry) => coveredBy(layer, patch.path, entry));
17485
17655
  };
17486
- composeTarget = (state) => {
17656
+ rewordTarget = (state) => {
17657
+ const note = noteEditing(state);
17658
+ return note === void 0 ? "Reword the note" : `Reword the note on ${heldWhere(note)}`;
17659
+ };
17660
+ composeTarget = (state) => state.editing === void 0 ? anchoredTarget(state) : rewordTarget(state);
17661
+ anchoredTarget = (state) => {
17487
17662
  const patch = selectedPatch(state);
17488
17663
  if (state.answerTo !== void 0) return answerTarget(state);
17489
17664
  if (state.replyTo !== void 0) return replyTarget(state);
@@ -17494,12 +17669,15 @@ var init_notes = __esmMin((() => {
17494
17669
  onNone: () => "",
17495
17670
  onSome: (found) => found.start === found.end ? `${found.start}` : `${found.start}-${found.end}`
17496
17671
  });
17497
- return span === "" ? `Comment on ${patch.path}` : `Comment on ${patch.path}:${span}`;
17672
+ const where = span === "" ? patch.path : `${patch.path}:${span}`;
17673
+ if (state.about !== void 0) return "Ask the agent to redraft the note";
17674
+ if (!theirPull(state)) return `Comment on ${where}`;
17675
+ return state.reader === "author" ? `Note to the author on ${where}` : `Ask the agent about ${where}`;
17498
17676
  };
17499
17677
  }));
17500
17678
  //#endregion
17501
17679
  //#region src/tui/reduce.ts
17502
- 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, foldThread, foldMoved, overFold, readingThread, overThread, fold, moveBranch, landingOn, revealing, atTheEnd, aroundTheEnd, CAME_AROUND, moveFile$1, selectHunk, swapEnds, atBranch, grownBy, startSelection, draftMark, openCompose, outOfDiff, BACK_FROM, goBack$1, walkMatches$1, openPalette, openKeys, openSettings, moveSettings, flipSetting, moveAsk, moveRef, withChoices, withRefs, movePalette, 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;
17680
+ 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, foldThread, foldMoved, overFold, readingThread, overThread, 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, flipSetting, moveAsk, moveRef, withChoices, withRefs, movePalette, 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;
17503
17681
  var init_reduce = __esmMin((() => {
17504
17682
  init_dist();
17505
17683
  init_patch();
@@ -17966,6 +18144,8 @@ var init_reduce = __esmMin((() => {
17966
18144
  draft: kept,
17967
18145
  draftAt: mark,
17968
18146
  replyTo: void 0,
18147
+ about: void 0,
18148
+ reader: theirPull(state) ? "author" : "agent",
17969
18149
  anchorRow: state.selecting ? state.anchorRow : state.cursor
17970
18150
  };
17971
18151
  };
@@ -18010,9 +18190,16 @@ var init_reduce = __esmMin((() => {
18010
18190
  screen: state.returnTo
18011
18191
  }),
18012
18192
  compose: (state) => ({
18193
+ ...state,
18194
+ screen: state.returnTo === "sending" ? "sending" : "review",
18195
+ replyTo: void 0,
18196
+ about: void 0,
18197
+ editing: void 0
18198
+ }),
18199
+ sending: (state) => ({
18013
18200
  ...state,
18014
18201
  screen: "review",
18015
- replyTo: void 0
18202
+ returnTo: "review"
18016
18203
  }),
18017
18204
  base: (state) => ({
18018
18205
  ...state,
@@ -18030,6 +18217,10 @@ var init_reduce = __esmMin((() => {
18030
18217
  asking: void 0
18031
18218
  })
18032
18219
  };
18220
+ movedInList$1 = (state, delta) => ({
18221
+ ...state,
18222
+ sendIndex: clamp(state.sendIndex + delta, 0, Math.max(0, state.held.length - 1))
18223
+ });
18033
18224
  goBack$1 = (state) => BACK_FROM[state.screen]?.(state) ?? outOfDiff(state);
18034
18225
  walkMatches$1 = (state, delta) => ({
18035
18226
  ...state,
@@ -18124,6 +18315,11 @@ var init_reduce = __esmMin((() => {
18124
18315
  "compose.open": openCompose,
18125
18316
  "compose.submit": (state) => state,
18126
18317
  "held.send": (state) => state,
18318
+ "send.next": (state) => movedInList$1(state, 1),
18319
+ "send.prev": (state) => movedInList$1(state, -1),
18320
+ "send.reword": (state) => state,
18321
+ "send.go": (state) => state,
18322
+ "agent.ask": (state) => state,
18127
18323
  "thread.reply": (state) => state,
18128
18324
  "remark.accept": (state) => state,
18129
18325
  "focus.toggle": (state) => ({
@@ -18344,9 +18540,10 @@ var init_reduce = __esmMin((() => {
18344
18540
  top: 0
18345
18541
  };
18346
18542
  };
18347
- withPulls = (state, pulls) => ({
18543
+ withPulls = (state, pulls, theirs) => ({
18348
18544
  ...state,
18349
18545
  pulls,
18546
+ theirs,
18350
18547
  forge: "answered"
18351
18548
  });
18352
18549
  withSilentForge = (state) => ({
@@ -18644,7 +18841,7 @@ var init_theme = __esmMin((() => {
18644
18841
  "note.label": { fg: "#7aa2f7" },
18645
18842
  default: { fg: ink }
18646
18843
  };
18647
- })), Code, Gap, Comment, Label, DraftLine, ProseLine, $is, $match, isCode, isDraft, isProse, isSaid, isNote, isChrome, WASH, NOTE_MIN, OVERSCAN, SIGN_WIDTH, SCROLL_ROWS, PAN_COLUMNS, WAYS, wheelTo, SIGNS, numberFor, DiffView, startsOf, numbered, bareOf, noteKey, keyOf, groupOf, alike, heldAt, sameLine, NO_SPANS, lineStarts, overLine, shifted, acrossLines, firstOfEach, spansByLine, textAt, noteSpans, NOTE_PAINT, wrap, SAID_INDENT, REMARK_MARK$1, remarkHead, HELD_HEAD, commentHead, headOf, spokenLines, heardFrom, answerLines, REMARK_LINES, capped, bodyLines, saidLines, noteLines, REMARK_RULE, noteRows, proseRows, freshLines, proseAt, apart, notesAt, TRAILING, shownText, codeRow, DRAFT_STOP, draftText, draftRows, rowsFor, replacedBy, layout, lineNumbers, BARE_SIGN, signFor, lineSigns, sideLineOf;
18844
+ })), Code, Gap, Comment, Label, DraftLine, ProseLine, $is, $match, isCode, isDraft, isProse, isSaid, isNote, isChrome, WASH, NOTE_MIN, OVERSCAN, SIGN_WIDTH, SCROLL_ROWS, PAN_COLUMNS, WAYS, wheelTo, SIGNS, numberFor, DiffView, startsOf, numbered, bareOf, noteKey, keyOf, groupOf, alike, heldAt, sameLine, NO_SPANS, lineStarts, overLine, shifted, acrossLines, firstOfEach, spansByLine, textAt, noteSpans, NOTE_PAINT, wrap, SAID_INDENT, REMARK_MARK$1, remarkHead, HELD_HEAD, redraftAsked, openHead, commentHead, heldHead, headOf, spokenLines, heardFrom, answerLines, REMARK_LINES, capped, bodyLines, saidLines, noteLines, REMARK_RULE, noteRows, proseRows, freshLines, proseAt, apart, notesAt, TRAILING, shownText, codeRow, DRAFT_STOP, draftText, draftRows, rowsFor, replacedBy, layout, lineNumbers, BARE_SIGN, signFor, lineSigns, sideLineOf;
18648
18845
  var init_diffview = __esmMin((() => {
18649
18846
  init_dist();
18650
18847
  init_patch();
@@ -19266,18 +19463,26 @@ var init_diffview = __esmMin((() => {
19266
19463
  REMARK_MARK$1 = "◇";
19267
19464
  remarkHead = (note, from) => `${REMARK_MARK$1} @${from}${note.stale ? " · outdated" : ""}`;
19268
19465
  HELD_HEAD = "waiting to be sent";
19466
+ redraftAsked = (note) => note.redrafts === true && note.answers.length === 0 && !note.settled;
19467
+ openHead = (note) => {
19468
+ if (redraftAsked(note)) return `${marks().sent} sent · asks the agent to redraft the note held here`;
19469
+ return note.takenAt === void 0 ? `${marks().sent} sent` : `${marks().waiting} picked up ${agoText(note.takenAt, note.now)}`;
19470
+ };
19269
19471
  commentHead = (note) => {
19270
19472
  const moved = note.stale ? ", the branch moved on" : "";
19271
19473
  if (note.settled) return `${marks().done} settled${moved}`;
19272
19474
  if (note.asks) return `${marks().asked} asked back${moved}`;
19273
19475
  if (note.turns.at(-1)?.voice === "reviewer") return `${marks().waiting} replied${moved}`;
19274
19476
  if (note.answers.length > 0) return `${marks().answered} answered${moved}`;
19275
- if (note.takenAt === void 0) return `${marks().sent} sent${moved}`;
19276
- return `${marks().waiting} picked up ${agoText(note.takenAt, note.now)}${moved}`;
19477
+ return `${openHead(note)}${moved}`;
19478
+ };
19479
+ heldHead = (note) => {
19480
+ if (note.waiting === "rewritten") return "rewritten by the agent, unread";
19481
+ return note.waiting === "author" ? "held for the author" : HELD_HEAD;
19277
19482
  };
19278
19483
  headOf = (note) => {
19279
19484
  if (note.from !== void 0) return remarkHead(note, note.from);
19280
- return note.sent ? commentHead(note) : `${marks().filed} ${HELD_HEAD}`;
19485
+ return note.sent ? commentHead(note) : `${marks().filed} ${heldHead(note)}`;
19281
19486
  };
19282
19487
  spokenLines = (body, room, mark) => {
19283
19488
  return body.split("\n").flatMap((line) => wrap(line, Math.max(NOTE_MIN, room - 2))).map((text, at) => at === 0 ? `${mark} ${text}` : ` ${text}`);
@@ -19417,16 +19622,26 @@ var init_diffview = __esmMin((() => {
19417
19622
  }));
19418
19623
  //#endregion
19419
19624
  //#region src/tui/notespane.ts
19420
- var reportActions, SENDS, REPLIES, actionsText, composeRoom, laidOut, stillThere, quotedFor, clipHead, clipMiddle, clipPath, notesOf, remarksOf, notesFor, standingOnRemark, standingOnDismissed;
19625
+ var reportActions, SENDS, REPLIES, HOLDS, ASKS$1, SAVES, composeSaid, actionsText, composeRoom, laidOut, stillThere, draftQuote, editQuote, quotedFor, clipHead, clipMiddle, clipPath, waitingOf, notesOf, remarksOf, notesFor, standingOnRemark, standingOnDismissed;
19421
19626
  var init_notespane = __esmMin((() => {
19422
19627
  init_layout();
19423
19628
  init_cursor();
19424
19629
  init_notes();
19630
+ init_state();
19425
19631
  init_theme();
19426
19632
  init_words();
19427
19633
  reportActions = (full) => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^t")} ${fg(palette.muted)(full ? "sending everything" : "sending the least")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("copy and save")}`;
19428
19634
  SENDS = "send it";
19429
19635
  REPLIES = "reply on the pull request";
19636
+ HOLDS = "hold it for the author";
19637
+ ASKS$1 = "send it to the agent";
19638
+ SAVES = "save the note";
19639
+ composeSaid = (state) => {
19640
+ if (state.editing !== void 0) return SAVES;
19641
+ if (state.answerTo !== void 0) return REPLIES;
19642
+ if (!theirPull(state)) return SENDS;
19643
+ return state.reader === "author" ? HOLDS : ASKS$1;
19644
+ };
19430
19645
  actionsText = (said) => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^s")} ${fg(palette.muted)(said)}`;
19431
19646
  composeRoom = (width) => ({
19432
19647
  box: composeBox(width),
@@ -19437,7 +19652,16 @@ var init_notespane = __esmMin((() => {
19437
19652
  return parts.length === 0 ? [""] : parts;
19438
19653
  });
19439
19654
  stillThere = (sent) => sent.filter((one) => one.removed !== true);
19655
+ draftQuote = (state, room) => {
19656
+ const held = state.held.find((one) => one.id === state.about);
19657
+ if (held === void 0) return [];
19658
+ return [" the note held for the author:", ...held.body.split("\n").map((line) => ` ${line}`)].map((line) => clip(line, room));
19659
+ };
19660
+ editQuote = (state, room) => (noteEditing(state)?.snippet ?? "").split("\n").filter((line) => line.trim().length > 0).map((line) => clip(` ${line}`, room));
19440
19661
  quotedFor = (state, shownLines, room) => {
19662
+ if (state.editing !== void 0) return editQuote(state, room).slice(0, shownLines * 2);
19663
+ const redrafting = draftQuote(state, room);
19664
+ if (redrafting.length > 0) return redrafting.slice(0, shownLines * 2);
19441
19665
  const answering = remarkQuote(state, room);
19442
19666
  if (answering.length > 0) return answering.slice(0, shownLines * 2).map((line) => clip(line, room));
19443
19667
  const said = threadQuote(state, room);
@@ -19464,6 +19688,10 @@ var init_notespane = __esmMin((() => {
19464
19688
  }, []);
19465
19689
  return kept.length === 0 ? clipHead(label, room) : `…/${kept.join("/")}`;
19466
19690
  };
19691
+ waitingOf = (entry, author) => {
19692
+ if (entry.rewritten === true) return "rewritten";
19693
+ return author ? "author" : void 0;
19694
+ };
19467
19695
  notesOf = (comments, path, sent, shown = {
19468
19696
  opened: [],
19469
19697
  now: Date.now()
@@ -19480,7 +19708,9 @@ var init_notespane = __esmMin((() => {
19480
19708
  answers: entry.answers ?? [],
19481
19709
  turns: entry.turns ?? [],
19482
19710
  takenAt: entry.takenAt,
19483
- now: shown.now
19711
+ now: shown.now,
19712
+ waiting: waitingOf(entry, shown.author === true),
19713
+ redrafts: entry.draft !== void 0
19484
19714
  }));
19485
19715
  remarksOf = (state, path) => state.remarks.filter((one) => one.file === path && remarkShown(one)).map((one) => ({
19486
19716
  id: one.id,
@@ -19509,17 +19739,19 @@ var init_notespane = __esmMin((() => {
19509
19739
  }),
19510
19740
  ...notesOf(state.held, path, false, {
19511
19741
  opened: state.opened,
19512
- now: state.now
19742
+ now: state.now,
19743
+ author: theirPull(state)
19513
19744
  }),
19514
19745
  ...remarksOf(state, path)
19515
19746
  ];
19516
19747
  standingOnRemark = (state) => remarkHere(state) !== void 0;
19517
19748
  standingOnDismissed = (state) => remarkUnderCursor(state)?.dismissed === true;
19518
- })), PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, restingOrHere, remarkWhere, wherePart, panelFile, panelWhere, panelBody, panelMark, lostCode, lostEntry, writtenOn, foldLine, panelPair, panelSection, PULL_HINT, panelWindow, moreLine, panelPicked, panelText;
19749
+ })), PANEL_TITLES, panelTitle, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, restingOrHere, remarkWhere, wherePart, panelFile, panelWhere, panelBody, panelMark, lostCode, lostEntry, writtenOn, foldLine, panelPair, panelSection, PULL_HINT, panelWindow, moreLine, panelPicked, panelText;
19519
19750
  var init_panelpane = __esmMin((() => {
19520
19751
  init_marks();
19521
19752
  init_notespane();
19522
19753
  init_panel();
19754
+ init_state();
19523
19755
  init_theme();
19524
19756
  init_words();
19525
19757
  PANEL_TITLES = {
@@ -19534,6 +19766,7 @@ var init_panelpane = __esmMin((() => {
19534
19766
  settled: "Settled",
19535
19767
  removed: "Removed"
19536
19768
  };
19769
+ panelTitle = (state, section) => section === "held" && theirPull(state) ? "Held for the author" : PANEL_TITLES[section];
19537
19770
  PANEL_ORDER = PANEL_SECTIONS;
19538
19771
  PANEL_LEAD = 3;
19539
19772
  PANEL_EMPTY = "No comment on this branch yet.";
@@ -19549,7 +19782,8 @@ var init_panelpane = __esmMin((() => {
19549
19782
  const known = state.patches.some((patch) => patch.path === entry.remark.file);
19550
19783
  return remarkWhere(entry.remark, known);
19551
19784
  }
19552
- return entry.comment.outside === true ? " · not in the diff" : `:${entry.comment.end}`;
19785
+ const tail = entry.comment.rewritten === true ? " · rewritten by the agent" : entry.comment.draft === void 0 ? "" : " · asks to redraft";
19786
+ return entry.comment.outside === true ? " · not in the diff" : `:${entry.comment.end}${tail}`;
19553
19787
  };
19554
19788
  panelFile = (entry) => {
19555
19789
  if (entry.kind === "fold") return "";
@@ -19640,7 +19874,7 @@ var init_panelpane = __esmMin((() => {
19640
19874
  tone: palette.faint
19641
19875
  },
19642
19876
  {
19643
- text: `${PANEL_TITLES[section]} ${counted}`,
19877
+ text: `${panelTitle(state, section)} ${counted}`,
19644
19878
  tone: palette.faint
19645
19879
  },
19646
19880
  ...here.flatMap((one) => panelPair(state, one, room))
@@ -19839,7 +20073,7 @@ var init_treepane = __esmMin((() => {
19839
20073
  return `${row.here === true ? marks().cursor : " "}${look.mark.padStart(GUTTER - 1)}`;
19840
20074
  };
19841
20075
  layerText = (row, look, room) => row.kind === "gap" ? "" : `${layerGutter(row, look)}${" ".repeat(look.lead - GUTTER)}${row.text}`.padEnd(room.title + TITLE_LEAD);
19842
- })), 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, stateCell, branchCells, placeLabel, headerParts, panLabel, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope;
20076
+ })), 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;
19843
20077
  var init_home = __esmMin((() => {
19844
20078
  init_cursor();
19845
20079
  init_files();
@@ -19907,10 +20141,15 @@ var init_home = __esmMin((() => {
19907
20141
  return branch.stale ? `${branch.layers} stale` : `${branch.layers} layers`;
19908
20142
  };
19909
20143
  baseLabel = (branch) => branch.basis === "default" ? "" : `on ${branch.base}`;
20144
+ whosePull = (state, branch) => {
20145
+ const pull = state.pulls[branch] ?? "";
20146
+ const author = state.theirs[branch];
20147
+ return author === void 0 || pull.length === 0 ? pull : `@${author}'s ${pull}`;
20148
+ };
19910
20149
  stateCell = (state, branch) => [
19911
20150
  branch.own ? "here" : "",
19912
20151
  baseLabel(branch),
19913
- state.pulls[branch.branch] ?? "",
20152
+ whosePull(state, branch.branch),
19914
20153
  waitingLabel(branch).trim()
19915
20154
  ].filter((part) => part.length > 0).join(" ");
19916
20155
  branchCells = (branch, here, room) => ({
@@ -19926,11 +20165,15 @@ var init_home = __esmMin((() => {
19926
20165
  const place = filePlace(state);
19927
20166
  return `file ${place.at} of ${place.of}`;
19928
20167
  };
20168
+ pullLabel = (state) => {
20169
+ if (pullHere(state).length === 0) return "";
20170
+ return `${authorHere(state).length === 0 ? "" : `@${authorHere(state)}'s `}${pullHere(state)} pull request`;
20171
+ };
19929
20172
  headerParts = (state, branch, path, across) => [
19930
20173
  branch,
19931
20174
  path,
19932
20175
  state.patches.length === 0 ? "nothing to read" : placeLabel(state),
19933
- pullHere(state).length === 0 ? "" : `${pullHere(state)} pull request`,
20176
+ pullLabel(state),
19934
20177
  state.vouched.length === 0 ? "" : reviewedCount(state),
19935
20178
  contextLabel(state.context),
19936
20179
  state.layersStale ? "layers stale · L for a new one" : "",
@@ -20134,7 +20377,7 @@ var init_paint = __esmMin((() => {
20134
20377
  }));
20135
20378
  //#endregion
20136
20379
  //#region src/tui/parts.ts
20137
- var COMPOSE_WIDTH, frameRoot, crampedBar, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, asking, makePaletteParts, makeChoices, makeBody, makeHome, makeModals, makeBaseParts, makeAskParts, makeReaderParts, makeSettingsParts, makeKeysParts, makeFoundParts, isFont, logoFont, makeLanding, makeLogo, MAC_KEYS, makeComposeParts, makeCompose;
20380
+ var COMPOSE_WIDTH, frameRoot, crampedBar, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, asking, makePaletteParts, makeChoices, makeBody, makeHome, makeModals, makeBaseParts, makeAskParts, makeSendingParts, makeReaderParts, makeSettingsParts, makeKeysParts, makeFoundParts, isFont, logoFont, makeLanding, makeLogo, MAC_KEYS, makeComposeParts, makeCompose;
20138
20381
  var init_parts = __esmMin((() => {
20139
20382
  init_home();
20140
20383
  init_layout();
@@ -20321,6 +20564,7 @@ var init_parts = __esmMin((() => {
20321
20564
  });
20322
20565
  makeModals = (renderer) => ({
20323
20566
  palette: makePaletteParts(renderer),
20567
+ sending: makeSendingParts(renderer),
20324
20568
  found: makeFoundParts(renderer),
20325
20569
  keys: makeKeysParts(renderer),
20326
20570
  settings: makeSettingsParts(renderer),
@@ -20357,6 +20601,19 @@ var init_parts = __esmMin((() => {
20357
20601
  choices
20358
20602
  };
20359
20603
  };
20604
+ makeSendingParts = (renderer) => {
20605
+ const box = makePalette(renderer);
20606
+ const title = bar(renderer, "sending-title", palette.faint);
20607
+ const choices = makeChoices(renderer);
20608
+ box.id = "sending";
20609
+ box.add(title);
20610
+ box.add(choices);
20611
+ return {
20612
+ box,
20613
+ title,
20614
+ choices
20615
+ };
20616
+ };
20360
20617
  makeReaderParts = (renderer) => {
20361
20618
  const box = makePalette(renderer);
20362
20619
  const title = bar(renderer, "reader-title", palette.faint);
@@ -20541,7 +20798,7 @@ var init_parts = __esmMin((() => {
20541
20798
  }));
20542
20799
  //#endregion
20543
20800
  //#region src/tui/sheets.ts
20544
- var PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, LEGEND, legendText, keysTitle, keysOf, commandRow, LIST_LEAD, windowed, listText, SHEET_GAP, sheetRow, groupedBy, sheetBlock, splitInTwo, sheetPaint, sheetDeep, sheetText, askText, SETTING_LEAD, settingsText, offeredIn, readerTitle, voicesOf, readerText, pickingTitle, YOURS, YOUR_REF, pickedTail;
20801
+ var PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, LEGEND, legendText, keysTitle, keysOf, commandRow, LIST_LEAD, windowed, listText, SHEET_GAP, sheetRow, groupedBy, sheetBlock, splitInTwo, sheetPaint, sheetDeep, sheetText, REWRITTEN_TAIL, NOTHING_HELD, sendingTitle, noteBlock, sendingRows, sendingTop, TONES, notePaint, sendingText, askText, SETTING_LEAD, settingsText, offeredIn, onHeldEntry, readerTitle, voicesOf, readerText, pickingTitle, YOURS, YOUR_REF, pickedTail;
20545
20802
  var init_sheets = __esmMin((() => {
20546
20803
  init_command();
20547
20804
  init_diffview();
@@ -20672,6 +20929,62 @@ var init_sheets = __esmMin((() => {
20672
20929
  }
20673
20930
  return new StyledText(drawn);
20674
20931
  };
20932
+ REWRITTEN_TAIL = " · rewritten by the agent";
20933
+ NOTHING_HELD = "Before you send — nothing held for the author";
20934
+ sendingTitle = (state) => {
20935
+ const many = state.held.length;
20936
+ if (many === 0) return NOTHING_HELD;
20937
+ return `Before you send — ${counted(many, "note")} to @${authorHere(state)}'s pull request`;
20938
+ };
20939
+ noteBlock = (note, at, room) => {
20940
+ const tail = note.rewritten === true ? REWRITTEN_TAIL : "";
20941
+ const code = (note.snippet ?? "").split("\n").filter((line) => line.trim().length > 0);
20942
+ return [
20943
+ {
20944
+ text: clip(`${heldWhere(note)}${tail}`, room),
20945
+ note: at,
20946
+ tone: "heading"
20947
+ },
20948
+ ...code.map((line) => ({
20949
+ text: clip(`│ ${line}`, room),
20950
+ note: at,
20951
+ tone: "code"
20952
+ })),
20953
+ ...note.body.split("\n").flatMap((line) => wrapped(line, room)).map((text) => ({
20954
+ text,
20955
+ note: at,
20956
+ tone: "body"
20957
+ })),
20958
+ {
20959
+ text: "",
20960
+ note: at,
20961
+ tone: "gap"
20962
+ }
20963
+ ];
20964
+ };
20965
+ sendingRows = (state, room) => state.held.flatMap((note, at) => noteBlock(note, at, room));
20966
+ sendingTop = (rows, at, height) => {
20967
+ const first = rows.findIndex((row) => row.note === at);
20968
+ const last = rows.findLastIndex((row) => row.note === at);
20969
+ const wanted = Math.max(0, Math.min(first, last - height + 1));
20970
+ return Math.max(0, Math.min(rows.length - height, wanted));
20971
+ };
20972
+ TONES = {
20973
+ heading: palette.accent,
20974
+ code: palette.faint,
20975
+ body: palette.ink,
20976
+ gap: palette.ink
20977
+ };
20978
+ notePaint = (row, here, room) => {
20979
+ const text = `${here ? marks().cursor : " "} ${row.text}`.padEnd(room);
20980
+ return here ? bg(palette.selection)(fg(palette.ink)(`${text}\n`)) : fg(TONES[row.tone])(`${text}\n`);
20981
+ };
20982
+ sendingText = (state, shown) => {
20983
+ const rows = sendingRows(state, Math.max(1, shown.room - LIST_LEAD));
20984
+ const top = sendingTop(rows, state.sendIndex, shown.height);
20985
+ const drawn = rows.slice(top, top + shown.height).map((row) => notePaint(row, row.tone === "heading" && row.note === state.sendIndex, shown.room));
20986
+ return new StyledText(drawn);
20987
+ };
20675
20988
  askText = (state, room) => {
20676
20989
  const listed = askedThreads(state).map((line) => fg(palette.faint)(`${clip(` ${line}`, room).padEnd(room)}\n`));
20677
20990
  const drawn = askedRows(state).map((row) => {
@@ -20695,7 +21008,7 @@ var init_sheets = __esmMin((() => {
20695
21008
  comments: state.sent.length,
20696
21009
  held: state.held.length,
20697
21010
  layers: state.layers.length,
20698
- onThread: cursorOnThread(state),
21011
+ onThread: cursorOnThread(state) && !onHeldEntry(state),
20699
21012
  onRemark: standingOnRemark(state),
20700
21013
  onDismissed: standingOnDismissed(state),
20701
21014
  selecting: state.selecting,
@@ -20708,8 +21021,11 @@ var init_sheets = __esmMin((() => {
20708
21021
  hidingSettled: state.hideSettled,
20709
21022
  onRemoved: threadHere(state)?.removed === true,
20710
21023
  onSettled: threadHere(state)?.settled === true,
20711
- onHeld: state.focus === "review" && panelEntry(state)?.section === "held"
21024
+ onHeld: onHeldEntry(state),
21025
+ theirs: theirPull(state),
21026
+ rewording: state.editing !== void 0
20712
21027
  });
21028
+ onHeldEntry = (state) => state.screen === "sending" || state.focus === "review" && panelEntry(state)?.section === "held";
20713
21029
  readerTitle = (state, entry) => {
20714
21030
  if (entry.kind === "fold") return "The branch moved past these";
20715
21031
  const where = wherePart(state, entry).replace(" · ", "").trim();
@@ -20826,6 +21142,7 @@ var init_render = __esmMin((() => {
20826
21142
  keysLegend;
20827
21143
  ask;
20828
21144
  reader;
21145
+ sending;
20829
21146
  foundBox;
20830
21147
  renderer;
20831
21148
  mouse;
@@ -20879,6 +21196,7 @@ var init_render = __esmMin((() => {
20879
21196
  this.keysLegend = modals.keys.legend;
20880
21197
  this.baseBox = modals.bases;
20881
21198
  this.reader = modals.reader;
21199
+ this.sending = modals.sending;
20882
21200
  this.ask = modals.ask;
20883
21201
  this.foundBox = modals.found;
20884
21202
  this.assemble(renderer);
@@ -20973,6 +21291,7 @@ var init_render = __esmMin((() => {
20973
21291
  }
20974
21292
  write(text) {
20975
21293
  this.composeBody.setText(text);
21294
+ this.composeBody.gotoBufferEnd();
20976
21295
  }
20977
21296
  writeOn(on) {
20978
21297
  if (on) this.composeBody.focus();
@@ -21035,6 +21354,7 @@ var init_render = __esmMin((() => {
21035
21354
  this.paintSettings(state);
21036
21355
  this.paintBases(state);
21037
21356
  this.paintReader(state);
21357
+ this.paintSending(state);
21038
21358
  this.paintAsk(state);
21039
21359
  this.paintFound(state);
21040
21360
  this.paintReport(state);
@@ -21136,6 +21456,25 @@ var init_render = __esmMin((() => {
21136
21456
  this.reader.box.left = Math.max(1, Math.floor((this.renderer.width - room) / 2));
21137
21457
  this.reader.box.top = panelTop(this.renderer.height, 4);
21138
21458
  }
21459
+ paintSending(state) {
21460
+ this.sending.box.visible = state.screen === "sending";
21461
+ if (state.screen !== "sending") {
21462
+ this.sending.title.content = "";
21463
+ this.sending.choices.content = "";
21464
+ return;
21465
+ }
21466
+ const room = this.renderer.width;
21467
+ const tall = Math.max(4, this.renderer.height - 1);
21468
+ this.sending.title.content = clip(sendingTitle(state), room - 8);
21469
+ this.sending.choices.content = sendingText(state, {
21470
+ height: Math.max(1, tall - 4),
21471
+ room: room - 8
21472
+ });
21473
+ this.sending.box.height = tall;
21474
+ this.sending.box.width = room;
21475
+ this.sending.box.left = 0;
21476
+ this.sending.box.top = 0;
21477
+ }
21139
21478
  paintKeys(state) {
21140
21479
  this.keys.visible = state.screen === "keys";
21141
21480
  if (state.screen !== "keys") {
@@ -21330,6 +21669,7 @@ var init_render = __esmMin((() => {
21330
21669
  this.keys,
21331
21670
  this.settings,
21332
21671
  this.reader.box,
21672
+ this.sending.box,
21333
21673
  this.ask.box,
21334
21674
  this.baseBox.box
21335
21675
  ]);
@@ -21522,7 +21862,7 @@ var init_render = __esmMin((() => {
21522
21862
  };
21523
21863
  }
21524
21864
  draftFor(state) {
21525
- if (state.screen !== "compose") return void 0;
21865
+ if (state.screen !== "compose" || state.returnTo === "sending") return void 0;
21526
21866
  if (this.diffRows() < 6) return void 0;
21527
21867
  const place = draftPlace(state);
21528
21868
  if (place === void 0 || this.view.screenRowOf(place.row) === void 0) return void 0;
@@ -21550,7 +21890,7 @@ var init_render = __esmMin((() => {
21550
21890
  this.composeQuoted.content = "";
21551
21891
  this.composeQuoted.height = 0;
21552
21892
  this.fitBody(state, this.draftRoom(), draft.rows - 1 - 2);
21553
- this.composeActions.content = actionsText(state.answerTo === void 0 ? SENDS : REPLIES);
21893
+ this.composeActions.content = actionsText(composeSaid(state));
21554
21894
  this.compose.height = draft.rows - 1;
21555
21895
  this.compose.width = this.draftRoom();
21556
21896
  this.compose.left = this.view.saidLeft();
@@ -21605,7 +21945,7 @@ var init_render = __esmMin((() => {
21605
21945
  this.composeQuoted.height = quoted.length + 1;
21606
21946
  const spare = this.renderer.height - quoted.length - 1 - 2 - 3 - 4;
21607
21947
  const written = this.fitBody(state, room.text, Math.max(1, spare));
21608
- this.composeActions.content = actionsText(state.answerTo === void 0 ? SENDS : REPLIES);
21948
+ this.composeActions.content = actionsText(composeSaid(state));
21609
21949
  const height = quoted.length + 1 + written + 2 + 3;
21610
21950
  this.compose.height = height;
21611
21951
  this.compose.width = room.box;
@@ -21836,14 +22176,27 @@ var init_source = __esmMin((() => {
21836
22176
  }));
21837
22177
  //#endregion
21838
22178
  //#region src/tui/drafts.ts
21839
- var NOTHING_WRITTEN, sentAway, holding;
22179
+ var heldOf, HELD_FOR_AUTHOR, NOTHING_WRITTEN, sentAway, holding;
21840
22180
  var init_drafts = __esmMin((() => {
21841
22181
  init_reduce();
21842
22182
  init_words();
22183
+ heldOf = (drafts) => drafts.map((draft) => ({
22184
+ id: draft.id,
22185
+ at: draft.at,
22186
+ file: draft.file,
22187
+ side: draft.side,
22188
+ start: draft.start,
22189
+ end: draft.end,
22190
+ body: draft.body,
22191
+ snippet: draft.snippet,
22192
+ rewritten: draft.unread
22193
+ }));
22194
+ HELD_FOR_AUTHOR = "held for the author";
21843
22195
  NOTHING_WRITTEN = "nothing written yet";
21844
22196
  sentAway = (state) => ({
21845
22197
  ...state,
21846
- screen: "review",
22198
+ screen: state.returnTo === "sending" ? "sending" : "review",
22199
+ selecting: false,
21847
22200
  draft: "",
21848
22201
  draftAt: "",
21849
22202
  replyTo: void 0
@@ -21983,7 +22336,7 @@ var init_remarks = __esmMin((() => {
21983
22336
  }));
21984
22337
  //#endregion
21985
22338
  //#region src/tui/branches.ts
21986
- var openedPull, openedOn, resumeAt, openBranch, readBranch, fillBranches, reloadList, reloadBranch, goBack, loadPulls, showPull, openBases, basedOnRef, clearBaseHere, afterBase, setBaseHere, noticeAnswers, noticeOnList;
22339
+ var openedPull, openedOn, resumeAt, openBranch, readBranch, fillBranches, reloadList, reloadBranch, goBack, loadPulls, loadHeld, showPull, openBases, basedOnRef, clearBaseHere, afterBase, setBaseHere, noticeAnswers, noticeOnList;
21987
22340
  var init_branches = __esmMin((() => {
21988
22341
  init_dist();
21989
22342
  init_forge();
@@ -21994,6 +22347,7 @@ var init_branches = __esmMin((() => {
21994
22347
  init_notes();
21995
22348
  init_state();
21996
22349
  init_review();
22350
+ init_drafts();
21997
22351
  init_reading();
21998
22352
  openedPull = (state, opened) => {
21999
22353
  if (!opened) return "could not reach the pull request";
@@ -22038,14 +22392,19 @@ var init_branches = __esmMin((() => {
22038
22392
  const reading$1 = yield* reading(app.repo, name, app.base);
22039
22393
  app.reading = reading$1;
22040
22394
  yield* markOpened(reading$1.worktree, (/* @__PURE__ */ new Date()).toISOString());
22041
- const [progress$1, layers, sent, remarks] = yield* all([
22395
+ const [progress$1, layers, sent, remarks, drafts] = yield* all([
22042
22396
  progress(reading$1),
22043
22397
  read(reading$1),
22044
22398
  listSent(reading$1),
22045
- app.state.remarksOn ? list$2(reading$1) : succeed$1([])
22399
+ app.state.remarksOn ? list$2(reading$1) : succeed$1([]),
22400
+ list(reading$1.worktree)
22046
22401
  ], { concurrency: "unbounded" });
22047
22402
  const opened = withVouched(withPatches(app.state, reading$1.patches), progress$1.vouched);
22048
- return withRemarks(withLayers(withSent(opened, sent), layers), remarks);
22403
+ const held = drafts.length > 0 || theirPull(app.state) ? heldOf(drafts) : app.state.held;
22404
+ return withRemarks(withLayers(withSent({
22405
+ ...opened,
22406
+ held
22407
+ }, sent), layers), remarks);
22049
22408
  });
22050
22409
  };
22051
22410
  fillBranches = (app) => {
@@ -22102,8 +22461,20 @@ var init_branches = __esmMin((() => {
22102
22461
  const answered = yield* (yield* Forge).pulls(app.repo).pipe(map$1(some), catchTag("ForgeUnavailable", () => succeed$1(none())));
22103
22462
  app.commit(match$3(answered, {
22104
22463
  onNone: () => withSilentForge(app.state),
22105
- onSome: (pulls) => withPulls(app.state, Object.fromEntries(pulls.map((pull) => [pull.branch, pull.state])))
22464
+ onSome: (pulls) => withPulls(app.state, Object.fromEntries(pulls.map((pull) => [pull.branch, pull.state])), Object.fromEntries(pulls.filter((pull) => pull.theirs).map((pull) => [pull.branch, pull.author])))
22106
22465
  }));
22466
+ if (app.state.screen !== "branches" && theirPull(app.state)) yield* loadHeld(app);
22467
+ });
22468
+ };
22469
+ loadHeld = (app) => {
22470
+ return gen(function* () {
22471
+ const branch = selectedBranch(app.state);
22472
+ if (branch === void 0) return;
22473
+ const drafts = yield* list(yield* worktreeOf(app, branch.branch));
22474
+ app.commit({
22475
+ ...app.state,
22476
+ held: heldOf(drafts)
22477
+ });
22107
22478
  });
22108
22479
  };
22109
22480
  showPull = (app) => {
@@ -22193,7 +22564,7 @@ var init_branches = __esmMin((() => {
22193
22564
  }));
22194
22565
  //#endregion
22195
22566
  //#region src/tui/comments.ts
22196
- var LAYERS_ASK_LEAD, layersAsk, askedFor, compose, openPanelEntry, openThreadInFull, jumpingPastGaps, readAnswers, send, sendReply, sendComment, dropHeld, sendHeld, askForLayers, replyHere;
22567
+ var LAYERS_ASK_LEAD, layersAsk, askedFor, compose, openOther, openPanelEntry, openAway, openThreadInFull, jumpingPastGaps, readRewrite, readAnswers, send, toAgent, sendRedraftAsk, toAuthor, sendReply, sendComment, stillListing, dropHeld, unreadSaid, keptSaid, dispatchDrafts, sendHeld, askForLayers, heldChosen, askAgent, replyHere;
22197
22568
  var init_comments = __esmMin((() => {
22198
22569
  init_dist();
22199
22570
  init_patch();
@@ -22201,6 +22572,7 @@ var init_comments = __esmMin((() => {
22201
22572
  init_remarks();
22202
22573
  init_source();
22203
22574
  init_drafts();
22575
+ init_branches();
22204
22576
  init_cursor();
22205
22577
  init_notes();
22206
22578
  init_panel();
@@ -22224,32 +22596,25 @@ var init_comments = __esmMin((() => {
22224
22596
  yield* openPanelEntry(app);
22225
22597
  });
22226
22598
  };
22599
+ openOther = (app, entry) => {
22600
+ if (entry === void 0) return sync(() => app.commit(withNoticeHere(app.state, "nothing in the review yet")));
22601
+ if (entry.kind === "fold") return sync(() => app.commit({
22602
+ ...app.state,
22603
+ openMoved: !entry.open
22604
+ }));
22605
+ return entry.kind === "remark" ? openRemark(app, entry.remark) : void_;
22606
+ };
22227
22607
  openPanelEntry = (app) => {
22228
22608
  return gen(function* () {
22229
22609
  const entry = panelEntry(app.state);
22230
- if (entry === void 0) {
22231
- app.commit(withNoticeHere(app.state, "nothing in the review yet"));
22232
- return;
22233
- }
22234
- if (entry.kind === "fold") {
22235
- app.commit({
22236
- ...app.state,
22237
- openMoved: !entry.open
22238
- });
22239
- return;
22240
- }
22241
- if (entry.kind === "remark") {
22242
- yield* openRemark(app, entry.remark);
22610
+ if (entry?.kind !== "comment") {
22611
+ yield* openOther(app, entry);
22243
22612
  return;
22244
22613
  }
22614
+ yield* readRewrite(app, entry);
22245
22615
  const at = app.state.patches.findIndex((patch) => patch.path === entry.comment.file);
22246
- if (app.state.patches[at] === void 0) {
22247
- yield* readAnswers(app, entry.comment.id);
22248
- app.commit(withNoticeHere(app.state, `${entry.comment.file} is not on this branch`));
22249
- return;
22250
- }
22251
- if (entry.comment.outside === true) {
22252
- yield* openThreadInFull(app, entry);
22616
+ if (at === -1 || entry.comment.outside === true) {
22617
+ yield* openAway(app, entry, at);
22253
22618
  return;
22254
22619
  }
22255
22620
  const opened = {
@@ -22266,6 +22631,14 @@ var init_comments = __esmMin((() => {
22266
22631
  yield* readAnswers(app, entry.comment.id);
22267
22632
  });
22268
22633
  };
22634
+ openAway = (app, entry, at) => gen(function* () {
22635
+ if (at !== -1) {
22636
+ yield* openThreadInFull(app, entry);
22637
+ return;
22638
+ }
22639
+ yield* readAnswers(app, entry.comment.id);
22640
+ app.commit(withNoticeHere(app.state, `${entry.comment.file} is not on this branch`));
22641
+ });
22269
22642
  openThreadInFull = (app, entry) => gen(function* () {
22270
22643
  yield* readAnswers(app, entry.comment.id);
22271
22644
  const said = withNoticeHere(app.state, "the diff no longer has that line");
@@ -22294,6 +22667,21 @@ var init_comments = __esmMin((() => {
22294
22667
  yield* readAnswers(app, entry.comment.id);
22295
22668
  });
22296
22669
  };
22670
+ readRewrite = (app, entry) => {
22671
+ return gen(function* () {
22672
+ const branch = selectedBranch(app.state);
22673
+ const id = entry.comment.id;
22674
+ if (entry.section !== "held" || entry.comment.rewritten !== true) return;
22675
+ if (id === void 0 || branch === void 0) return;
22676
+ const was = app.state.panelIndex;
22677
+ yield* markSeen(yield* worktreeOf(app, branch.branch), id, (/* @__PURE__ */ new Date()).toISOString());
22678
+ yield* loadHeld(app);
22679
+ app.commit({
22680
+ ...app.state,
22681
+ panelIndex: was
22682
+ });
22683
+ });
22684
+ };
22297
22685
  readAnswers = (app, id) => {
22298
22686
  return gen(function* () {
22299
22687
  const branch = selectedBranch(app.state);
@@ -22309,8 +22697,53 @@ var init_comments = __esmMin((() => {
22309
22697
  };
22310
22698
  send = (app) => {
22311
22699
  if (app.state.answerTo !== void 0) return sendRemarkAnswer(app, app.state.answerTo);
22700
+ if (app.state.about !== void 0) return sendRedraftAsk(app, app.state.about);
22312
22701
  return app.state.replyTo === void 0 ? sendComment(app) : sendReply(app, app.state.replyTo);
22313
22702
  };
22703
+ toAgent = (app, where, body, about) => {
22704
+ return gen(function* () {
22705
+ const branch = selectedBranch(app.state);
22706
+ if (branch === void 0) return;
22707
+ yield* submit(yield* worktreeOf(app, branch.branch), {
22708
+ ...where,
22709
+ body,
22710
+ id: randomUUID(),
22711
+ at: (/* @__PURE__ */ new Date()).toISOString(),
22712
+ theirs: true,
22713
+ ...about === void 0 ? {} : { draft: about }
22714
+ });
22715
+ const sent = yield* loadSent(app, branch.branch);
22716
+ app.commit(withNoticeHere(sentAway({
22717
+ ...withSent(app.state, sent),
22718
+ about: void 0
22719
+ }), "sent to the agent"));
22720
+ });
22721
+ };
22722
+ sendRedraftAsk = (app, about) => {
22723
+ const held = app.state.held.find((one) => one.id === about);
22724
+ if (held === void 0) return sync(() => app.commit(withNotice(sentAway(app.state), "that note is gone")));
22725
+ if (app.state.draft.trim().length === 0) return sync(() => app.commit(withNotice(app.state, NOTHING_WRITTEN)));
22726
+ return toAgent(app, held, app.screen.written(), about);
22727
+ };
22728
+ toAuthor = (app, file, anchor, body) => {
22729
+ return gen(function* () {
22730
+ const branch = selectedBranch(app.state);
22731
+ if (branch === void 0) return;
22732
+ yield* add$1(yield* worktreeOf(app, branch.branch), {
22733
+ file,
22734
+ side: anchor.side,
22735
+ start: anchor.start,
22736
+ end: anchor.end,
22737
+ body,
22738
+ id: randomUUID(),
22739
+ at: (/* @__PURE__ */ new Date()).toISOString(),
22740
+ wroteBy: "reviewer"
22741
+ });
22742
+ yield* loadHeld(app);
22743
+ const many = app.state.held.length;
22744
+ app.commit(withNotice(sentAway(app.state), `${HELD_FOR_AUTHOR} — ${counted(many, "note")} waiting, press C to send`));
22745
+ });
22746
+ };
22314
22747
  sendReply = (app, to) => {
22315
22748
  return gen(function* () {
22316
22749
  const branch = selectedBranch(app.state);
@@ -22345,6 +22778,16 @@ var init_comments = __esmMin((() => {
22345
22778
  return;
22346
22779
  }
22347
22780
  const body = app.screen.written();
22781
+ if (theirPull(app.state)) {
22782
+ const where = {
22783
+ file: patch.path,
22784
+ side: anchor.value.side,
22785
+ start: anchor.value.start,
22786
+ end: anchor.value.end
22787
+ };
22788
+ yield* app.state.reader === "author" ? toAuthor(app, patch.path, anchor.value, body) : toAgent(app, where, body);
22789
+ return;
22790
+ }
22348
22791
  if (app.state.hold) {
22349
22792
  holding(app, {
22350
22793
  file: patch.path,
@@ -22368,9 +22811,31 @@ var init_comments = __esmMin((() => {
22368
22811
  app.commit(withNotice(sentAway(withSent(app.state, sent)), "sent to the agent"));
22369
22812
  });
22370
22813
  };
22814
+ stillListing = (state) => {
22815
+ if (state.screen !== "sending") return state;
22816
+ if (state.held.length === 0) return {
22817
+ ...state,
22818
+ screen: "review",
22819
+ returnTo: "review"
22820
+ };
22821
+ return {
22822
+ ...state,
22823
+ sendIndex: Math.min(state.sendIndex, state.held.length - 1)
22824
+ };
22825
+ };
22371
22826
  dropHeld = (app, at) => {
22372
- return sync(() => {
22827
+ return gen(function* () {
22373
22828
  const was = app.state.panelIndex;
22829
+ const branch = selectedBranch(app.state);
22830
+ const draft = app.state.held[at]?.id;
22831
+ if (theirPull(app.state) && branch !== void 0 && draft !== void 0) {
22832
+ yield* ignore(drop(yield* worktreeOf(app, branch.branch), draft));
22833
+ yield* loadHeld(app);
22834
+ const listed = stillListing(app.state);
22835
+ const said = "dropped, the author never saw it";
22836
+ app.commit(listed.screen === "sending" ? withNoticeHere(listed, said) : withNotice(staying(listed, was), said));
22837
+ return;
22838
+ }
22374
22839
  const held = app.state.held.filter((_, index) => index !== at);
22375
22840
  app.commit(withNotice(staying({
22376
22841
  ...app.state,
@@ -22378,6 +22843,34 @@ var init_comments = __esmMin((() => {
22378
22843
  }, was), "dropped, it was never sent"));
22379
22844
  });
22380
22845
  };
22846
+ unreadSaid = (unread) => unread === 1 ? "1 note rewritten by the agent is unread — stand on it to read it" : `${unread} notes rewritten by the agent are unread — stand on each to read them`;
22847
+ keptSaid = (kept) => `${counted(kept, "note")} kept`;
22848
+ dispatchDrafts = (app) => {
22849
+ return gen(function* () {
22850
+ const branch = selectedBranch(app.state);
22851
+ if (branch === void 0) return;
22852
+ yield* loadHeld(app);
22853
+ const unread = app.state.held.filter((one) => one.rewritten === true).length;
22854
+ if (unread > 0) {
22855
+ const said = unreadSaid(unread);
22856
+ app.commit(app.state.screen === "sending" ? withNoticeHere(app.state, said) : withNotice(app.state, said));
22857
+ return;
22858
+ }
22859
+ const worktree = yield* worktreeOf(app, branch.branch);
22860
+ const said = yield* dispatch$1(app.repo, worktree).pipe(map$1((sent) => `sent ${counted(sent.sent, "note")} to the pull request — press p to read them there`), catchTags({
22861
+ PullMoved: () => succeed$1(`the pull request moved — read it again; ${keptSaid(app.state.held.length)}`),
22862
+ NothingDrafted: () => succeed$1("nothing held for the author"),
22863
+ PartlySent: (part) => succeed$1(part.sent === 0 ? `the forge confirmed none of the notes; ${keptSaid(part.held)}` : `sent ${part.sent} to the pull request, ${keptSaid(part.held)}`),
22864
+ ForgeUnavailable: () => succeed$1(`could not reach the forge; ${keptSaid(app.state.held.length)}`)
22865
+ }));
22866
+ yield* loadHeld(app);
22867
+ app.commit(withNotice({
22868
+ ...app.state,
22869
+ returnTo: "review"
22870
+ }, said));
22871
+ yield* fetchRemarks(app);
22872
+ });
22873
+ };
22381
22874
  sendHeld = (app) => {
22382
22875
  return gen(function* () {
22383
22876
  const branch = selectedBranch(app.state);
@@ -22421,6 +22914,34 @@ var init_comments = __esmMin((() => {
22421
22914
  app.commit(withNotice(withSent(app.state, sent), askedFor(app.state)));
22422
22915
  });
22423
22916
  };
22917
+ heldChosen = (state) => {
22918
+ if (state.screen === "sending") return state.held[state.sendIndex];
22919
+ const entry = state.focus === "review" ? panelEntry(state) : void 0;
22920
+ return entry?.kind === "comment" && entry.section === "held" ? entry.comment : void 0;
22921
+ };
22922
+ askAgent = (app) => {
22923
+ return sync(() => {
22924
+ const chosen = heldChosen(app.state);
22925
+ if (chosen?.id !== void 0) {
22926
+ app.commit({
22927
+ ...app.state,
22928
+ screen: "compose",
22929
+ returnTo: app.state.screen,
22930
+ draft: "",
22931
+ draftAt: "",
22932
+ replyTo: void 0,
22933
+ reader: "agent",
22934
+ about: chosen.id
22935
+ });
22936
+ return;
22937
+ }
22938
+ const opened = reduce(app.measured(), "compose.open");
22939
+ app.commit(opened.screen === "compose" ? {
22940
+ ...opened,
22941
+ reader: "agent"
22942
+ } : opened);
22943
+ });
22944
+ };
22424
22945
  replyHere = (app) => {
22425
22946
  return sync(() => {
22426
22947
  const thread = threadHere(app.state);
@@ -23036,6 +23557,92 @@ var init_selection = __esmMin((() => {
23036
23557
  };
23037
23558
  }));
23038
23559
  //#endregion
23560
+ //#region src/tui/sending.ts
23561
+ var readUnderCursor, openSending, movedInList, rewordHeld, REWORDED, backInList, rewordDraft, sendFromList;
23562
+ var init_sending = __esmMin((() => {
23563
+ init_dist();
23564
+ init_branches();
23565
+ init_comments();
23566
+ init_drafts();
23567
+ init_reading();
23568
+ init_reduce();
23569
+ init_state();
23570
+ init_review();
23571
+ readUnderCursor = (app) => {
23572
+ return gen(function* () {
23573
+ const branch = selectedBranch(app.state);
23574
+ if (branch === void 0) return;
23575
+ yield* loadHeld(app);
23576
+ const under = app.state.held[app.state.sendIndex];
23577
+ if (under?.id === void 0 || under.rewritten !== true) return;
23578
+ yield* markSeen(yield* worktreeOf(app, branch.branch), under.id, (/* @__PURE__ */ new Date()).toISOString());
23579
+ yield* loadHeld(app);
23580
+ });
23581
+ };
23582
+ openSending = (app) => {
23583
+ return gen(function* () {
23584
+ app.commit({
23585
+ ...app.state,
23586
+ screen: "sending",
23587
+ returnTo: "review",
23588
+ sendIndex: 0,
23589
+ notice: ""
23590
+ });
23591
+ yield* readUnderCursor(app);
23592
+ });
23593
+ };
23594
+ movedInList = (app, delta) => {
23595
+ return gen(function* () {
23596
+ app.commit(reduce(app.measured(), delta > 0 ? "send.next" : "send.prev"));
23597
+ yield* readUnderCursor(app);
23598
+ });
23599
+ };
23600
+ rewordHeld = (app) => {
23601
+ return sync(() => {
23602
+ const under = app.state.held[app.state.sendIndex];
23603
+ if (under?.id === void 0) return;
23604
+ app.commit({
23605
+ ...app.state,
23606
+ screen: "compose",
23607
+ returnTo: "sending",
23608
+ draft: under.body,
23609
+ draftAt: `reword:${under.id}`,
23610
+ replyTo: void 0,
23611
+ answerTo: void 0,
23612
+ about: void 0,
23613
+ reader: "author",
23614
+ editing: under.id
23615
+ });
23616
+ });
23617
+ };
23618
+ REWORDED = "reworded";
23619
+ backInList = (state) => ({
23620
+ ...sentAway(state),
23621
+ editing: void 0
23622
+ });
23623
+ rewordDraft = (app, editing) => {
23624
+ return gen(function* () {
23625
+ const branch = selectedBranch(app.state);
23626
+ if (branch === void 0) return;
23627
+ const body = app.screen.written();
23628
+ if (body.trim().length === 0) {
23629
+ app.commit(withNoticeHere(app.state, NOTHING_WRITTEN));
23630
+ return;
23631
+ }
23632
+ const worktree = yield* worktreeOf(app, branch.branch);
23633
+ yield* ignore(edit(worktree, {
23634
+ id: editing,
23635
+ body,
23636
+ at: (/* @__PURE__ */ new Date()).toISOString(),
23637
+ by: "reviewer"
23638
+ }));
23639
+ yield* loadHeld(app);
23640
+ app.commit(withNoticeHere(backInList(app.state), REWORDED));
23641
+ });
23642
+ };
23643
+ sendFromList = (app) => dispatchDrafts(app);
23644
+ }));
23645
+ //#endregion
23039
23646
  //#region src/tui/threads.ts
23040
23647
  var settleWhatIsRead, settleHere, changeSettled, removeHere, turningOver, heldUnderCursor;
23041
23648
  var init_threads = __esmMin((() => {
@@ -23127,6 +23734,7 @@ var init_threads = __esmMin((() => {
23127
23734
  });
23128
23735
  };
23129
23736
  heldUnderCursor = (app) => {
23737
+ if (app.state.screen === "sending") return Math.min(app.state.sendIndex, app.state.held.length - 1);
23130
23738
  if (app.state.focus !== "review") return -1;
23131
23739
  const entry = panelEntry(app.state);
23132
23740
  if (entry === void 0 || entry.kind !== "comment" || entry.section !== "held") return -1;
@@ -23278,6 +23886,7 @@ var init_app = __esmMin((() => {
23278
23886
  init_search();
23279
23887
  init_selection();
23280
23888
  init_source();
23889
+ init_sending();
23281
23890
  init_threads();
23282
23891
  init_vouching();
23283
23892
  init_files();
@@ -23295,7 +23904,11 @@ var init_app = __esmMin((() => {
23295
23904
  TRAIL_HISTORY = 20;
23296
23905
  DRAIN_PASSES = 8;
23297
23906
  LEAVING_SAID = "press ctrl+c again to leave";
23298
- leavingSaid = (state) => state.held.length === 0 ? LEAVING_SAID : `${counted(state.held.length, "comment")} never sent — press ctrl+c again to leave without them`;
23907
+ leavingSaid = (state) => {
23908
+ if (state.held.length === 0) return LEAVING_SAID;
23909
+ if (theirPull(state)) return `${counted(state.held.length, "note")} to the author not sent — they are kept; press ctrl+c again to leave`;
23910
+ return `${counted(state.held.length, "comment")} never sent — press ctrl+c again to leave without them`;
23911
+ };
23299
23912
  clockOf = (elapsed) => {
23300
23913
  const seconds = Math.floor(elapsed / 1e3);
23301
23914
  return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`.padStart(6);
@@ -23330,8 +23943,13 @@ var init_app = __esmMin((() => {
23330
23943
  "branch.open": openBranch,
23331
23944
  "branch.pull": showPull,
23332
23945
  "compose.open": compose,
23333
- "compose.submit": send,
23334
- "held.send": sendHeld,
23946
+ "compose.submit": (app) => app.state.editing === void 0 ? send(app) : rewordDraft(app, app.state.editing),
23947
+ "held.send": (app) => theirPull(app.state) ? openSending(app) : sendHeld(app),
23948
+ "send.next": (app) => movedInList(app, 1),
23949
+ "send.prev": (app) => movedInList(app, -1),
23950
+ "send.reword": rewordHeld,
23951
+ "send.go": sendFromList,
23952
+ "agent.ask": askAgent,
23335
23953
  "palette.run": (app) => app.runChoice(),
23336
23954
  "comment.next": (app) => walkComments(app, 1),
23337
23955
  "comment.prev": (app) => walkComments(app, -1),
@@ -24020,7 +24638,12 @@ const draftAdd = fn("Main.draftAdd")(function* (options) {
24020
24638
  yield* answer(options, { draft });
24021
24639
  });
24022
24640
  const draftEdit = fn("Main.draftEdit")(function* (options) {
24023
- const draft = yield* edit(yield* worktreeIn(options), yield* required(options, "id"), yield* required(options, "body"));
24641
+ const draft = yield* edit(yield* worktreeIn(options), {
24642
+ id: yield* required(options, "id"),
24643
+ body: yield* required(options, "body"),
24644
+ at: stamp(options),
24645
+ by: "agent"
24646
+ });
24024
24647
  yield* answer(options, { draft });
24025
24648
  });
24026
24649
  const draftDrop = fn("Main.draftDrop")(function* (options) {