@eliya-oss/agent-diff 0.1.0-alpha.165 → 0.1.0-alpha.167

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/main.js +260 -44
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.167
4
+
5
+ ### Patch Changes
6
+
7
+ - fix(review): A comment the hunks cannot place is matched against every line of the code it quoted, so a comment about a deleted doc comment is no longer hung on the next `*/` in the file.
8
+
9
+ - feat(cli): `adiff resume` opens the review left last in the repository it is run from, and `adiff resume --check` names that branch without opening anything.
10
+
11
+ ## 0.1.0-alpha.166
12
+
13
+ ### Patch Changes
14
+
15
+ - feat(diff): A click moves the keys into the pane it landed in, opens the file or layer it landed on in the rail, and stands the cursor on the thread it landed on in the review panel.
16
+
17
+ - feat(review): `l` on a thread in the review panel reads it in full over the diff — the whole path, every message and the code it was written on, wrapped rather than cut — and a section counts the threads it holds whether its fold is open or shut.
18
+
3
19
  ## 0.1.0-alpha.165
4
20
 
5
21
  ### Patch Changes
package/dist/main.js CHANGED
@@ -9245,6 +9245,7 @@ var init_model$6 = __esmMin((() => {
9245
9245
  taken: {},
9246
9246
  vouches: {},
9247
9247
  parts: {},
9248
+ openedAt: "",
9248
9249
  consumed: 0,
9249
9250
  settled: {},
9250
9251
  removed: {},
@@ -9305,6 +9306,7 @@ var init_schema = __esmMin((() => {
9305
9306
  taken: optionalKey(Record(String$1, String$1)),
9306
9307
  vouches: Stamps.pipe(noStamps),
9307
9308
  parts: Stamps.pipe(noStamps),
9309
+ openedAt: String$1.pipe(withDecodingDefaultKey(succeed$1(""))),
9308
9310
  consumed: Int.pipe(withDecodingDefaultKey(succeed$1(0))),
9309
9311
  settled: Stamps.pipe(noStamps),
9310
9312
  removed: Stamps.pipe(noStamps),
@@ -10577,7 +10579,7 @@ var init_error = __esmMin((() => {
10577
10579
  }));
10578
10580
  //#endregion
10579
10581
  //#region src/cli/commands.ts
10580
- var realOf, CONTEXT, POLL, AUTO, askedFor$1, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, waitingOn, summaryOf, summaryFor, listBranches, readParts, blobOf, vouchIn, toggleVouch, readingOf, progressIn, reviewProgress, bodyOf, saidTo, spunOf, sentOf, whereItSitsNow$1, linesIn, lastLineOf, nearestLine, stillInFile, foundOutsideTheHunks, sentIn, listSent, anchorIn, commentsIn, commentIn, submitComment, submitComments, without$2, submitReply, listPatches, patchIn, flatten, threadBefore, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, readPreferences, readPreference, ON, OFF, preferenceValue, savePreference, listRefs, setBase, clearBase, markRead;
10582
+ var realOf, CONTEXT, POLL, AUTO, askedFor$1, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, waitingOn, summaryOf, summaryFor, listBranches, readParts, blobOf, vouchIn, toggleVouch, readingOf, markOpened, lastOpenedIn, progressIn, reviewProgress, bodyOf, saidTo, spunOf, sentOf, whereItSitsNow$1, linesIn, trimmedLines, NAMES_SOMETHING, worthMatching, blockAt, wholeSnippetIn, stillInFile, foundOutsideTheHunks, sentIn, listSent, anchorIn, commentsIn, commentIn, submitComment, submitComments, without$2, submitReply, listPatches, patchIn, flatten, threadBefore, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, readPreferences, readPreference, ON, OFF, preferenceValue, savePreference, listRefs, setBase, clearBase, markRead;
10581
10583
  var init_commands = __esmMin((() => {
10582
10584
  init_dist();
10583
10585
  init_patch();
@@ -10758,6 +10760,21 @@ var init_commands = __esmMin((() => {
10758
10760
  patches: yield* patchesOf(worktree)
10759
10761
  };
10760
10762
  });
10763
+ markOpened = fn("Cli.markOpened")(function* (worktreePath, at) {
10764
+ yield* (yield* Store).changeState(worktreePath, (was) => ({
10765
+ ...was,
10766
+ openedAt: at
10767
+ }));
10768
+ });
10769
+ lastOpenedIn = fn("Cli.lastOpenedIn")(function* (repo) {
10770
+ const store = yield* Store;
10771
+ const trees = yield* (yield* Git).worktrees(repo);
10772
+ const openedOf = (tree) => map(store.state(tree.path), (held) => ({
10773
+ branch: tree.branch,
10774
+ at: held.openedAt
10775
+ }));
10776
+ return (yield* forEach(trees, openedOf)).filter((one) => one.at.length > 0).toSorted((left, right) => right.at.localeCompare(left.at))[0];
10777
+ });
10761
10778
  progressIn = fn("Cli.progressIn")(function* (reading) {
10762
10779
  const current = yield* (yield* Store).state(reading.worktree.path);
10763
10780
  const files = reading.patches.map((patch) => ({
@@ -10845,14 +10862,19 @@ var init_commands = __esmMin((() => {
10845
10862
  });
10846
10863
  };
10847
10864
  linesIn = (found) => getOrElse$1(found, () => []);
10848
- lastLineOf = (snippet) => snippet.split("\n").map((line) => line.trim()).findLast((line) => line.length > 0) ?? "";
10849
- nearestLine = (source, wanted, was) => {
10850
- const found = source.flatMap((line, at) => line.trim() === wanted ? [at + 1] : []);
10865
+ trimmedLines = (snippet) => snippet.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
10866
+ NAMES_SOMETHING = /[A-Za-z0-9_$]{3}/;
10867
+ worthMatching = (wanted) => wanted.length > 1 || wanted[0] !== void 0 && NAMES_SOMETHING.test(wanted[0]);
10868
+ blockAt = (source, wanted, at) => wanted.every((line, step) => (source[at + step] ?? "").trim() === line);
10869
+ wholeSnippetIn = (source, wanted, was) => {
10870
+ const found = source.flatMap((_, at) => blockAt(source, wanted, at) ? [at + wanted.length] : []);
10851
10871
  if (found.length === 0) return void 0;
10852
10872
  return found.reduce((best, line) => Math.abs(line - was) < Math.abs(best - was) ? line : best);
10853
10873
  };
10854
10874
  stillInFile = (comment, source) => {
10855
- const line = nearestLine(source, lastLineOf(comment.snippet), comment.end);
10875
+ const wanted = trimmedLines(comment.snippet);
10876
+ if (!worthMatching(wanted)) return comment;
10877
+ const line = wholeSnippetIn(source, wanted, comment.end);
10856
10878
  if (line === void 0) return comment;
10857
10879
  const span = Math.max(0, comment.end - comment.start);
10858
10880
  return {
@@ -11373,7 +11395,7 @@ var init_pane = __esmMin((() => {
11373
11395
  //#region package.json
11374
11396
  init_drafts();
11375
11397
  init_pane();
11376
- var version$1 = "0.1.0-alpha.165";
11398
+ var version$1 = "0.1.0-alpha.167";
11377
11399
  //#endregion
11378
11400
  //#region src/cli/upgrade.ts
11379
11401
  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$1, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, ranChild, runUpgrade, statusOf$1, sayFound, sayDone, attempted, SAY_SKILL_TOO, upgradeReport;
@@ -12930,6 +12952,26 @@ var init_catalog = __esmMin((() => {
12930
12952
  dataKey: "upgrade",
12931
12953
  example: "adiff upgrade --check --json --fields route,latest,current"
12932
12954
  },
12955
+ {
12956
+ name: "resume",
12957
+ about: "Open the review you left last in this repository. Opens the terminal, like `review open`, on the branch it was opened on most recently",
12958
+ group: SET_UP,
12959
+ addresses: "none",
12960
+ safety: "read",
12961
+ options: [{
12962
+ name: "repo",
12963
+ required: false,
12964
+ value: "path",
12965
+ about: "The repository, defaulting to where you are"
12966
+ }, {
12967
+ name: "check",
12968
+ required: false,
12969
+ value: "flag",
12970
+ about: "Name the branch that would open, without opening anything. Always exits 0"
12971
+ }],
12972
+ dataKey: "resume",
12973
+ example: "adiff resume"
12974
+ },
12933
12975
  {
12934
12976
  name: "describe",
12935
12977
  about: "This catalog, as JSON",
@@ -15707,7 +15749,7 @@ var init_command = __esmMin((() => {
15707
15749
  "hide",
15708
15750
  "shrink"
15709
15751
  ],
15710
- title: "Close the folder, layer, gap, or settled thread",
15752
+ title: "Close the folder, layer, gap, or the thread in the panel",
15711
15753
  category: "Files",
15712
15754
  keys: ["h"],
15713
15755
  screens: ["review"]
@@ -15720,7 +15762,7 @@ var init_command = __esmMin((() => {
15720
15762
  "show more",
15721
15763
  "open"
15722
15764
  ],
15723
- title: "Open the folder, layer, gap, or settled thread",
15765
+ title: "Open the folder, layer, gap, or the thread in the panel",
15724
15766
  category: "Files",
15725
15767
  keys: ["l"],
15726
15768
  screens: ["review"]
@@ -15947,7 +15989,8 @@ var init_command = __esmMin((() => {
15947
15989
  "palette",
15948
15990
  "report",
15949
15991
  "search",
15950
- "keys"
15992
+ "keys",
15993
+ "thread"
15951
15994
  ],
15952
15995
  hint: "back",
15953
15996
  listed: false,
@@ -16057,7 +16100,7 @@ var init_match = __esmMin((() => {
16057
16100
  }));
16058
16101
  //#endregion
16059
16102
  //#region src/tui/reduce.ts
16060
- var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, restingOn, draggedTo, pickedIn, atRow, noneLeft, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, moveLayer, inRail, railScrolled, movePanel, layerDown, stepsToEnd, toTop, farOff, byHalf, boundedStep, PANEL_FAR, PANES, paneShown, panesShown, focusStepped, togglePanel, toggleNav, packedAway, zoom, toggleRail, foldDirectory, foldLayer, foldThread, foldMoved, overFold, fold, moveBranch, landingOn, revealing, atTheEnd, moveFile, selectHunk, swapEnds, atBranch, grownBy, startSelection, draftMark, openCompose, outOfDiff, BACK_FROM, goBack, walkMatches, openPalette, openKeys, openSettings, moveSettings, flipSetting, 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;
16103
+ 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, moveFile, selectHunk, swapEnds, atBranch, grownBy, startSelection, draftMark, openCompose, outOfDiff, BACK_FROM, goBack, walkMatches, openPalette, openKeys, openSettings, moveSettings, flipSetting, 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;
16061
16104
  var init_reduce = __esmMin((() => {
16062
16105
  init_dist();
16063
16106
  init_patch();
@@ -16197,6 +16240,26 @@ var init_reduce = __esmMin((() => {
16197
16240
  pan: Math.max(0, state.pan + delta)
16198
16241
  };
16199
16242
  };
16243
+ atLayer = (state, layer) => {
16244
+ const landed = readingOrder(state).find((one) => one.layer === layer);
16245
+ if (landed === void 0) return {
16246
+ ...state,
16247
+ layerIndex: layer
16248
+ };
16249
+ return {
16250
+ ...state,
16251
+ layerIndex: layer,
16252
+ openLayers: state.openLayers.includes(layer) ? state.openLayers : [...state.openLayers, layer],
16253
+ patchIndex: landed.file,
16254
+ top: 0,
16255
+ cursor: landingOn({
16256
+ ...state,
16257
+ layerIndex: layer
16258
+ }, landed.file),
16259
+ anchorRow: 0,
16260
+ selecting: false
16261
+ };
16262
+ };
16200
16263
  moveLayer = (state, delta) => {
16201
16264
  const order = readingOrder(state);
16202
16265
  if (order.length === 0) return state;
@@ -16374,8 +16437,15 @@ var init_reduce = __esmMin((() => {
16374
16437
  panelIndex: state.panelIndex + 1
16375
16438
  };
16376
16439
  overFold = (state) => state.focus === "review" && panelEntry(state)?.kind === "fold";
16440
+ readingThread = (state) => ({
16441
+ ...state,
16442
+ screen: "thread",
16443
+ returnTo: state.screen
16444
+ });
16445
+ overThread = (state) => state.focus === "review" && panelEntry(state) !== void 0;
16377
16446
  fold = (state, shut) => {
16378
16447
  if (overFold(state)) return foldMoved(state, shut);
16448
+ if (!shut && overThread(state)) return readingThread(state);
16379
16449
  const thread = threadAtStop(state);
16380
16450
  if (thread?.id !== void 0 && thread.settled === true) return foldThread(state, shut, thread.id);
16381
16451
  return onLayers(state) ? foldLayer(state, shut) : foldDirectory(state, shut);
@@ -16521,6 +16591,10 @@ var init_reduce = __esmMin((() => {
16521
16591
  ...state,
16522
16592
  screen: state.returnTo
16523
16593
  }),
16594
+ thread: (state) => ({
16595
+ ...state,
16596
+ screen: state.returnTo
16597
+ }),
16524
16598
  compose: (state) => ({
16525
16599
  ...state,
16526
16600
  screen: "review",
@@ -17849,7 +17923,7 @@ var init_diffview = __esmMin((() => {
17849
17923
  }));
17850
17924
  //#endregion
17851
17925
  //#region src/tui/render.ts
17852
- var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, reportActions, SENDS, REPLIES, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, LEGEND_ROWS, LEGEND, legendText, keysTitle, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, DIFF_FLOOR, COMPOSE_EDGE, CRAMPED, CRAMPED_ROWS, DIFF_CHROME_MOST, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_FIXED, STATE_MIN, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, longestState, keysOf, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, PLAIN_PICKED, PICKED, PLAIN_CURSOR, UNDER_CURSOR, GAP_PAINT, frameRoot, crampedBar, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, asking, makePaletteParts, makeChoices, LIST_LEAD, windowed, listText, SHEET_GAP, sheetRow, groupedBy, sheetBlock, splitInTwo, sheetPaint, sheetDeep, sheetText, SETTING_LEAD, settingsText, stack, makeBody, makeHome, makeModals, makeBaseParts, makeSettingsParts, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, MAC_KEYS, makeComposeParts, makeCompose, stillThere, quotedFor, clipHead, clipMiddle, clipPath, INDENT_MAX, treeLabel, waitingLabel, inRange, notesOf, remarksOf, notesFor, paired, chipWidth, WAYS_OUT, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, SUMMARY_LINES, summaryLines, contextLabel, nameRoom, stateRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, placeLabel, headerParts, panLabel, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, GUTTER, DIR_LEAD, TITLE_LEAD, FILE_LEAD, STALE_ROOM, STALE_ASKING, STALE_LONG, STALE_MIDDLE, STALE_SHORT, staleSaid, staleBanner, litRow, leftOver, titlePaint, titleMark, titleLook, fileMark, fileLook, layerLook, layerGutter, layerText, standingOnThread, standingOnRemark, standingOnDismissed, offeredIn, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, restingOrHere, FOUND_LEAST, nothingYet, counting, foundBlocks, JOIN, foundTitle, CHANGED_MARK, DECLARED, fileRow, leftRow, placeRow, blockOf, aroundRow, windowedBlocks, pickingTitle, YOURS, YOUR_REF, pickedTail, REMARK_MARK, remarkWhere, wherePart, panelFile, panelWhere, panelBody, panelMark, lostCode, lostEntry, writtenOn, foldLine, panelPair, panelSection, PULL_HINT, panelWindow, moreLine, panelText, Screen;
17926
+ var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, reportActions, SENDS, REPLIES, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, LEGEND_ROWS, LEGEND, legendText, keysTitle, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, DIFF_FLOOR, COMPOSE_EDGE, CRAMPED, CRAMPED_ROWS, DIFF_CHROME_MOST, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_FIXED, STATE_MIN, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, longestState, keysOf, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, PLAIN_PICKED, PICKED, PLAIN_CURSOR, UNDER_CURSOR, GAP_PAINT, frameRoot, crampedBar, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, asking, makePaletteParts, makeChoices, LIST_LEAD, windowed, listText, SHEET_GAP, sheetRow, groupedBy, sheetBlock, splitInTwo, sheetPaint, sheetDeep, sheetText, SETTING_LEAD, settingsText, stack, makeBody, makeHome, makeModals, makeBaseParts, makeReaderParts, makeSettingsParts, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, MAC_KEYS, makeComposeParts, makeCompose, stillThere, quotedFor, clipHead, clipMiddle, clipPath, INDENT_MAX, treeLabel, waitingLabel, inRange, notesOf, remarksOf, notesFor, paired, chipWidth, WAYS_OUT, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, SUMMARY_LINES, summaryLines, contextLabel, nameRoom, stateRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, placeLabel, headerParts, panLabel, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, GUTTER, DIR_LEAD, TITLE_LEAD, FILE_LEAD, STALE_ROOM, STALE_ASKING, STALE_LONG, STALE_MIDDLE, STALE_SHORT, staleSaid, staleBanner, litRow, leftOver, titlePaint, titleMark, titleLook, fileMark, fileLook, layerLook, layerGutter, layerText, standingOnThread, standingOnRemark, standingOnDismissed, offeredIn, readerTitle, voicesOf, readerText, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, restingOrHere, FOUND_LEAST, nothingYet, counting, foundBlocks, JOIN, foundTitle, CHANGED_MARK, DECLARED, fileRow, leftRow, placeRow, blockOf, aroundRow, windowedBlocks, pickingTitle, YOURS, YOUR_REF, pickedTail, REMARK_MARK, remarkWhere, wherePart, panelFile, panelWhere, panelBody, panelMark, lostCode, lostEntry, writtenOn, foldLine, panelPair, panelSection, PULL_HINT, panelWindow, moreLine, panelPicked, panelText, Screen;
17853
17927
  var init_render = __esmMin((() => {
17854
17928
  init_dist();
17855
17929
  init_command();
@@ -18266,6 +18340,7 @@ var init_render = __esmMin((() => {
18266
18340
  found: makeFoundParts(renderer),
18267
18341
  keys: makeKeysParts(renderer),
18268
18342
  settings: makeSettingsParts(renderer),
18343
+ reader: makeReaderParts(renderer),
18269
18344
  bases: makeBaseParts(renderer)
18270
18345
  });
18271
18346
  makeBaseParts = (renderer) => {
@@ -18284,6 +18359,19 @@ var init_render = __esmMin((() => {
18284
18359
  choices
18285
18360
  };
18286
18361
  };
18362
+ makeReaderParts = (renderer) => {
18363
+ const box = makePalette(renderer);
18364
+ const title = bar(renderer, "reader-title", palette.faint);
18365
+ const choices = makeChoices(renderer);
18366
+ box.id = "reader";
18367
+ box.add(title);
18368
+ box.add(choices);
18369
+ return {
18370
+ box,
18371
+ title,
18372
+ choices
18373
+ };
18374
+ };
18287
18375
  makeSettingsParts = (renderer) => {
18288
18376
  const box = makePalette(renderer);
18289
18377
  const title = bar(renderer, "settings-title", palette.faint);
@@ -18772,6 +18860,34 @@ var init_render = __esmMin((() => {
18772
18860
  onRemoved: threadHere(state)?.removed === true,
18773
18861
  onHeld: state.focus === "review" && panelEntry(state)?.section === "held"
18774
18862
  });
18863
+ readerTitle = (state, entry) => {
18864
+ if (entry.kind === "fold") return "The branch moved past these";
18865
+ const where = wherePart(state, entry).replace(" · ", "").trim();
18866
+ return where.length === 0 ? "This thread" : `This thread · ${where}`;
18867
+ };
18868
+ voicesOf = (entry) => {
18869
+ if (entry.kind === "fold") return [];
18870
+ if (entry.kind === "remark") return [`@${entry.remark.by} ${entry.remark.body}`, ...entry.remark.replies.map((reply) => `@${reply.by} ${reply.body}`)];
18871
+ const turns = entry.comment.turns;
18872
+ if (turns === void 0 || turns.length === 0) return [entry.comment.body];
18873
+ return turns.map((turn) => `${turn.voice === "agent" ? "↳" : "»"} ${turn.body}`);
18874
+ };
18875
+ readerText = (entry, room) => {
18876
+ const named = entry.kind === "fold" ? [] : [...wrapped(panelFile(entry), room), ""];
18877
+ const said = voicesOf(entry).flatMap((line) => wrapped(line, room));
18878
+ const code = lostCode(entry);
18879
+ const quoted = code.length === 0 ? [] : [
18880
+ "",
18881
+ "the code it was written on",
18882
+ ...code.map((line) => `│ ${line.trim()}`)
18883
+ ];
18884
+ const rows = [
18885
+ ...named,
18886
+ ...said,
18887
+ ...quoted
18888
+ ].flatMap((line) => wrapped(line, room));
18889
+ return new StyledText(rows.map((line) => fg(line.startsWith("│") ? palette.faint : palette.ink)(`${line.padEnd(room)}\n`)));
18890
+ };
18775
18891
  PANEL_TITLES = {
18776
18892
  remarks: "Remarks",
18777
18893
  dismissed: "Dismissed",
@@ -18963,7 +19079,8 @@ var init_render = __esmMin((() => {
18963
19079
  return [{
18964
19080
  text: clip(text, room),
18965
19081
  tone: palette.faint,
18966
- here
19082
+ here,
19083
+ at: placed.at
18967
19084
  }];
18968
19085
  };
18969
19086
  panelPair = (state, placed, room) => {
@@ -18975,12 +19092,14 @@ var init_render = __esmMin((() => {
18975
19092
  {
18976
19093
  text: `${lead}${panelWhere(state, entry, room - PANEL_LEAD)}`,
18977
19094
  tone: palette.ink,
18978
- here
19095
+ here,
19096
+ at: placed.at
18979
19097
  },
18980
19098
  {
18981
19099
  text: ` ${clip(panelBody(entry), Math.max(4, room - PANEL_LEAD))}`,
18982
19100
  tone: palette.muted,
18983
- here
19101
+ here,
19102
+ at: placed.at
18984
19103
  },
18985
19104
  ...writtenOn(state, placed, room)
18986
19105
  ];
@@ -18988,13 +19107,14 @@ var init_render = __esmMin((() => {
18988
19107
  panelSection = (state, placed, section, room) => {
18989
19108
  const here = placed.filter((one) => one.entry.section === section);
18990
19109
  if (here.length === 0) return [];
19110
+ const counted = panelHolds(state).filter((entry) => entry.section === section).length;
18991
19111
  return [
18992
19112
  {
18993
19113
  text: "",
18994
19114
  tone: palette.faint
18995
19115
  },
18996
19116
  {
18997
- text: `${PANEL_TITLES[section]} ${here.length}`,
19117
+ text: `${PANEL_TITLES[section]} ${counted}`,
18998
19118
  tone: palette.faint
18999
19119
  },
19000
19120
  ...here.flatMap((one) => panelPair(state, one, room))
@@ -19020,7 +19140,11 @@ var init_render = __esmMin((() => {
19020
19140
  text: clip(` ${mark} ${count} more`, room),
19021
19141
  tone: palette.faint
19022
19142
  }];
19023
- panelText = (state, room, rows) => {
19143
+ panelPicked = (banner, above, lines) => [...Array.from({ length: banner + (above > 0 ? 1 : 0) }, () => ({ pane: "review" })), ...lines.map((line) => ({
19144
+ pane: "review",
19145
+ entry: line.at
19146
+ }))];
19147
+ panelText = (state, room, rows, picked) => {
19024
19148
  const placed = panelEntries(state).map((entry, at) => ({
19025
19149
  entry,
19026
19150
  at
@@ -19046,6 +19170,7 @@ var init_render = __esmMin((() => {
19046
19170
  ...window.lines,
19047
19171
  ...moreLine(window.below, "▼", room)
19048
19172
  ];
19173
+ picked?.(panelPicked(banner.length, window.above, shown.slice(banner.length)));
19049
19174
  return new StyledText(shown.map((line) => {
19050
19175
  const drawn = fg(line.tone)(`${line.text.padEnd(room)}\n`);
19051
19176
  return line.here === true ? bg(restingOrHere(state.focus === "review"))(drawn) : drawn;
@@ -19090,15 +19215,14 @@ var init_render = __esmMin((() => {
19090
19215
  settingsTitle;
19091
19216
  settingsChoices;
19092
19217
  keysQuery;
19093
- foundQuery;
19094
19218
  keysChoices;
19095
19219
  keysLegend;
19096
- found;
19097
- foundTitle;
19098
- foundPeek;
19099
- foundChoices;
19220
+ reader;
19221
+ foundBox;
19100
19222
  renderer;
19101
19223
  mouse;
19224
+ listPicks = [];
19225
+ panelPicks = [];
19102
19226
  dragFrom;
19103
19227
  lastTop = 0;
19104
19228
  constructor(renderer, repo = "") {
@@ -19144,11 +19268,8 @@ var init_render = __esmMin((() => {
19144
19268
  this.keysChoices = modals.keys.choices;
19145
19269
  this.keysLegend = modals.keys.legend;
19146
19270
  this.baseBox = modals.bases;
19147
- this.found = modals.found.box;
19148
- this.foundTitle = modals.found.title;
19149
- this.foundQuery = modals.found.query;
19150
- this.foundPeek = modals.found.peek;
19151
- this.foundChoices = modals.found.choices;
19271
+ this.reader = modals.reader;
19272
+ this.foundBox = modals.found;
19152
19273
  this.assemble(renderer);
19153
19274
  }
19154
19275
  wheelOnRail(box) {
@@ -19165,8 +19286,16 @@ var init_render = __esmMin((() => {
19165
19286
  this.mouse?.onScroll(way === "down" ? 1 : -1);
19166
19287
  };
19167
19288
  }
19289
+ clickIn(box, picks, pane) {
19290
+ return (event) => {
19291
+ const found = picks()[Math.max(0, event.y - box.y)];
19292
+ this.mouse?.onClick(found ?? { pane });
19293
+ };
19294
+ }
19168
19295
  listen(mouse) {
19169
19296
  this.mouse = mouse;
19297
+ this.list.onMouseDown = this.clickIn(this.list, () => this.listPicks, "tree");
19298
+ this.panel.onMouseDown = this.clickIn(this.panel, () => this.panelPicks, "review");
19170
19299
  this.wheelOnSheet(this.keys);
19171
19300
  this.wheelOnSheet(this.palette);
19172
19301
  this.wheelOnRail(this.listPane);
@@ -19220,7 +19349,7 @@ var init_render = __esmMin((() => {
19220
19349
  asking(screen) {
19221
19350
  switch (screen) {
19222
19351
  case "palette": return this.paletteQuery;
19223
- case "search": return this.foundQuery;
19352
+ case "search": return this.foundBox.query;
19224
19353
  case "keys": return this.keysQuery;
19225
19354
  case "base":
19226
19355
  case "editor": return this.baseBox.query;
@@ -19267,6 +19396,7 @@ var init_render = __esmMin((() => {
19267
19396
  this.paintKeys(state);
19268
19397
  this.paintSettings(state);
19269
19398
  this.paintBases(state);
19399
+ this.paintReader(state);
19270
19400
  this.paintFound(state);
19271
19401
  this.paintReport(state);
19272
19402
  this.scrim.visible = state.screen !== "branches" && state.screen !== "review";
@@ -19333,6 +19463,22 @@ var init_render = __esmMin((() => {
19333
19463
  this.settings.left = Math.max(1, Math.floor((this.renderer.width - room) / 2));
19334
19464
  this.settings.top = panelTop(this.renderer.height, PANEL_QUARTER);
19335
19465
  }
19466
+ paintReader(state) {
19467
+ const entry = panelEntry(state);
19468
+ this.reader.box.visible = state.screen === "thread" && entry !== void 0;
19469
+ if (state.screen !== "thread" || entry === void 0) {
19470
+ this.reader.title.content = "";
19471
+ this.reader.choices.content = "";
19472
+ return;
19473
+ }
19474
+ const room = panelWidth(this.renderer.width);
19475
+ this.reader.title.content = clip(readerTitle(state, entry), room - MODAL_ROOM);
19476
+ this.reader.choices.content = readerText(entry, room - MODAL_ROOM);
19477
+ this.reader.box.height = Math.min(panelRows(this.renderer.height, PANEL_QUARTER), voicesOf(entry).length + lostCode(entry).length + PALETTE_CHROME + 8);
19478
+ this.reader.box.width = room;
19479
+ this.reader.box.left = Math.max(1, Math.floor((this.renderer.width - room) / 2));
19480
+ this.reader.box.top = panelTop(this.renderer.height, PANEL_QUARTER);
19481
+ }
19336
19482
  paintKeys(state) {
19337
19483
  this.keys.visible = state.screen === "keys";
19338
19484
  if (state.screen !== "keys") {
@@ -19406,7 +19552,7 @@ var init_render = __esmMin((() => {
19406
19552
  this.panelPane.paddingLeft = shown ? 1 : 0;
19407
19553
  this.panelPane.paddingTop = 0;
19408
19554
  const rows = Math.max(1, this.panelPane.height - PANE_EDGES);
19409
- this.panel.content = shown ? panelText(state, reviewWidth() - PANE_CHROME, rows) : "";
19555
+ this.panel.content = shown ? panelText(state, reviewWidth() - PANE_CHROME, rows, (found) => this.panelPicks = found) : "";
19410
19556
  }
19411
19557
  listText(state) {
19412
19558
  if (atHome(state)) return this.branchTable(state);
@@ -19415,6 +19561,10 @@ var init_render = __esmMin((() => {
19415
19561
  const pane = this.paneRoom();
19416
19562
  const whole = treeWindow(state, room);
19417
19563
  const window = whole.more === 0 ? whole : treeWindow(state, Math.max(1, room - 1));
19564
+ this.listPicks = window.rows.map((row) => ({
19565
+ pane: "tree",
19566
+ file: row.fileIndex
19567
+ }));
19418
19568
  const rows = window.rows.flatMap((row) => {
19419
19569
  const drawn = fg(row.kind === "file" ? palette.ink : palette.muted)(`${treeLine(state, row, pane)}\n`);
19420
19570
  return [row.fileIndex === state.patchIndex ? bg(restingOrHere(state.focus === "tree"))(drawn) : drawn];
@@ -19433,6 +19583,12 @@ var init_render = __esmMin((() => {
19433
19583
  const height = Math.max(1, this.listRoom() - banner);
19434
19584
  const all = layerFitted(state, room, height);
19435
19585
  const window = this.railFitted(state, all, height);
19586
+ const lead = said.length + (state.layersStale ? 1 : 0) + (window.above > 0 ? 1 : 0);
19587
+ this.listPicks = [...Array.from({ length: lead }, () => ({ pane: "tree" })), ...window.rows.map((row) => ({
19588
+ pane: "tree",
19589
+ file: row.fileIndex,
19590
+ layer: row.index
19591
+ }))];
19436
19592
  const rows = window.rows.flatMap((row) => this.layerLine(state, row, room));
19437
19593
  const above = window.above > 0 ? [fg(palette.faint)(` ▲ ${window.above} more\n`)] : [];
19438
19594
  const more = window.more > 0 ? [fg(palette.faint)(` ▼ ${window.more} more`)] : [];
@@ -19502,9 +19658,10 @@ var init_render = __esmMin((() => {
19502
19658
  this.scrim,
19503
19659
  this.compose,
19504
19660
  this.palette,
19505
- this.found,
19661
+ this.foundBox.box,
19506
19662
  this.keys,
19507
19663
  this.settings,
19664
+ this.reader.box,
19508
19665
  this.baseBox.box
19509
19666
  ]);
19510
19667
  }
@@ -19617,28 +19774,28 @@ var init_render = __esmMin((() => {
19617
19774
  this.listPane.justifyContent = place;
19618
19775
  }
19619
19776
  paintFound(state) {
19620
- this.found.visible = state.screen === "search";
19777
+ this.foundBox.box.visible = state.screen === "search";
19621
19778
  if (state.screen !== "search") {
19622
- this.foundTitle.content = "";
19623
- this.foundPeek.content = "";
19624
- this.foundChoices.content = "";
19779
+ this.foundBox.title.content = "";
19780
+ this.foundBox.peek.content = "";
19781
+ this.foundBox.choices.content = "";
19625
19782
  return;
19626
19783
  }
19627
19784
  const room = panelWidth(this.renderer.width);
19628
19785
  const wide = Math.max(1, room - MODAL_ROOM);
19629
- this.foundTitle.content = foundTitle(state, wide);
19786
+ this.foundBox.title.content = foundTitle(state, wide);
19630
19787
  const shown = shownMatches(state);
19631
19788
  const most = panelRows(this.renderer.height, PANEL_FIFTH);
19632
19789
  const { blocks, chosen } = foundBlocks(state, shown, wide);
19633
19790
  const tall = Math.max(FOUND_LEAST, most - PALETTE_CHROME);
19634
19791
  const window = windowedBlocks(blocks, chosen, tall);
19635
- this.foundChoices.content = blocks.length === 0 ? new StyledText([fg(palette.faint)(nothingYet(state, wide))]) : new StyledText([...window.chunks]);
19636
- this.foundPeek.content = "";
19637
- this.foundPeek.height = 0;
19638
- this.found.height = Math.min(most, Math.max(FOUND_LEAST, window.rows) + PALETTE_CHROME);
19639
- this.found.width = room;
19640
- this.found.left = Math.max(1, Math.floor((this.renderer.width - room) / 2));
19641
- this.found.top = panelTop(this.renderer.height, PANEL_FIFTH);
19792
+ this.foundBox.choices.content = blocks.length === 0 ? new StyledText([fg(palette.faint)(nothingYet(state, wide))]) : new StyledText([...window.chunks]);
19793
+ this.foundBox.peek.content = "";
19794
+ this.foundBox.peek.height = 0;
19795
+ this.foundBox.box.height = Math.min(most, Math.max(FOUND_LEAST, window.rows) + PALETTE_CHROME);
19796
+ this.foundBox.box.width = room;
19797
+ this.foundBox.box.left = Math.max(1, Math.floor((this.renderer.width - room) / 2));
19798
+ this.foundBox.box.top = panelTop(this.renderer.height, PANEL_FIFTH);
19642
19799
  }
19643
19800
  paintReport(state) {
19644
19801
  this.compose.visible = state.screen === "compose" || state.screen === "report";
@@ -20034,7 +20191,8 @@ var init_app = __esmMin((() => {
20034
20191
  "search",
20035
20192
  "settings",
20036
20193
  "base",
20037
- "editor"
20194
+ "editor",
20195
+ "thread"
20038
20196
  ]);
20039
20197
  overReview = (screen) => OVER.has(screen);
20040
20198
  writesInto = (screen) => WRITES.has(screen);
@@ -20132,6 +20290,7 @@ var init_app = __esmMin((() => {
20132
20290
  this.intents = options.intents;
20133
20291
  const { renderer } = options;
20134
20292
  runSync(this.display.listen({
20293
+ onClick: (what) => this.dispatchTask(this.clicked(what)),
20135
20294
  onScroll: (delta) => this.onWheel(delta),
20136
20295
  onPan: (delta) => this.onPanWheel(delta),
20137
20296
  onDrag: (from, to, done) => this.dragged(from, to, done),
@@ -20307,6 +20466,34 @@ var init_app = __esmMin((() => {
20307
20466
  const fiber = this.lighting;
20308
20467
  return fiber === void 0 ? void_ : asVoid(await_(fiber));
20309
20468
  }
20469
+ clicked(what) {
20470
+ return gen({ self: this }, function* () {
20471
+ const held = {
20472
+ ...this.measured(),
20473
+ focus: what.pane
20474
+ };
20475
+ if (what.entry !== void 0) {
20476
+ this.commit({
20477
+ ...held,
20478
+ panelIndex: what.entry
20479
+ });
20480
+ return;
20481
+ }
20482
+ if (what.layer !== void 0 && onLayers(held)) {
20483
+ const was = held.patchIndex;
20484
+ const moved = atLayer(held, what.layer);
20485
+ this.commit(what.file === void 0 ? moved : atFile(moved, what.file));
20486
+ if (this.state.patchIndex !== was) yield* this.turnedTo();
20487
+ return;
20488
+ }
20489
+ if (what.file === void 0 || what.file === held.patchIndex) {
20490
+ this.commit(held);
20491
+ return;
20492
+ }
20493
+ this.commit(atFile(held, what.file));
20494
+ yield* this.turnedTo();
20495
+ });
20496
+ }
20310
20497
  onWheel(delta) {
20311
20498
  this.wheel += delta;
20312
20499
  this.renderer.requestRender();
@@ -20666,6 +20853,7 @@ var init_app = __esmMin((() => {
20666
20853
  return gen({ self: this }, function* () {
20667
20854
  const reading = yield* readingOf(this.repo, name, this.base);
20668
20855
  this.reading = reading;
20856
+ yield* markOpened(reading.worktree.path, (/* @__PURE__ */ new Date()).toISOString());
20669
20857
  const [progress, layers, sent, remarks] = yield* all([
20670
20858
  progressIn(reading),
20671
20859
  layersIn(reading),
@@ -20716,7 +20904,10 @@ var init_app = __esmMin((() => {
20716
20904
  });
20717
20905
  }
20718
20906
  dragged(from, to, done) {
20719
- const held = this.measured();
20907
+ const held = {
20908
+ ...this.measured(),
20909
+ focus: "diff"
20910
+ };
20720
20911
  if (restsWhereItLanded(from, to) && !this.selectingNow) {
20721
20912
  this.commit(restingOn(held, from.row));
20722
20913
  return;
@@ -20916,7 +21107,12 @@ var init_app = __esmMin((() => {
20916
21107
  const shown = selectedPatch(wide);
20917
21108
  if (shown === void 0 || rowShowing(shown, entry.comment.end) === void 0) {
20918
21109
  yield* this.readAnswers(entry.comment.id);
20919
- this.commit(withNoticeHere(this.state, "the diff no longer has that line · the panel shows the code it was written on"));
21110
+ const said = withNoticeHere(this.state, "the diff no longer has that line");
21111
+ this.commit({
21112
+ ...said,
21113
+ screen: "thread",
21114
+ returnTo: said.screen
21115
+ });
20920
21116
  return;
20921
21117
  }
20922
21118
  this.commit(openedAt({
@@ -22126,11 +22322,31 @@ const addressOf = fn("Main.addressOf")(function* (name, options) {
22126
22322
  if (worktree !== void 0) return yield* byWorktree(options, worktree);
22127
22323
  return yield* new MissingOption({ option: addressing[0]?.name ?? "worktree" });
22128
22324
  });
22325
+ const RESUME_ADVICE = "Nothing has been opened here yet. Run `adiff review open --repo .` and pick a branch.";
22326
+ const resume = fn("Main.resume")(function* (options) {
22327
+ const repo = options["repo"] ?? process.cwd();
22328
+ const found = yield* lastOpenedIn(repo);
22329
+ if (options["check"] !== void 0) return yield* answer(options, {
22330
+ resume: found === void 0 ? {} : found,
22331
+ advice: found === void 0 ? RESUME_ADVICE : ""
22332
+ });
22333
+ if (found === void 0) {
22334
+ process.stderr.write(`${RESUME_ADVICE}\n`);
22335
+ return yield* sync(() => process.exit(3));
22336
+ }
22337
+ const { runTui } = yield* promise(() => Promise.resolve().then(() => (init_tui(), tui_exports)));
22338
+ return yield* runTui(repo, {
22339
+ sessionPath: process.env["ADIFF_SESSION"],
22340
+ branch: found.branch,
22341
+ base: options["base"]
22342
+ });
22343
+ });
22129
22344
  const dispatch = fn("Main.dispatch")(function* (name, given) {
22130
22345
  const options = yield* addressOf(name, given);
22131
22346
  const route = Object.hasOwn(routes, name) ? routes[name] : void 0;
22132
22347
  if (route !== void 0) return yield* route(options);
22133
22348
  if (name === "file review") return yield* fileReview(options);
22349
+ if (name === "resume") return yield* resume(options);
22134
22350
  if (name === "review open") {
22135
22351
  const { runTui } = yield* promise(() => Promise.resolve().then(() => (init_tui(), tui_exports)));
22136
22352
  return yield* runTui(yield* required(options, "repo"), {
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "bin": {
24
24
  "adiff": "./bin/adiff.js"
25
25
  },
26
- "version": "0.1.0-alpha.165",
26
+ "version": "0.1.0-alpha.167",
27
27
  "description": "Review the work an agent left you without losing the thread: comments live on the lines, the agent answers them, and each point stays open until you settle it.",
28
28
  "license": "MIT",
29
29
  "repository": {