@eliya-oss/agent-diff 0.1.0-alpha.16 → 0.1.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +2 -0
- package/dist/main.js +216 -36
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @eliya-oss/agent-diff
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- The cursor stops on a thread so it can be settled directly, and a settled thread folds to one row.
|
|
8
|
+
|
|
9
|
+
## 0.1.0-alpha.17
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Say when an agent answers, settle a thread with d, and hold the comments still while the code pans.
|
|
14
|
+
|
|
3
15
|
## 0.1.0-alpha.16
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -9,6 +9,8 @@ comment, and the agent picks it up.
|
|
|
9
9
|
<pre align="center">brew install Newbie012/tap/adiff
|
|
10
10
|
npm i -g @eliya-oss/agent-diff@alpha</pre>
|
|
11
11
|
|
|
12
|
+
<img src="assets/terminal.webp" alt="The adiff worktree list, showing seven branches with their sizes, layers and review state" width="820">
|
|
13
|
+
|
|
12
14
|
</div>
|
|
13
15
|
|
|
14
16
|
## Usage
|
package/dist/main.js
CHANGED
|
@@ -5,7 +5,7 @@ import { dirname, join } from "node:path";
|
|
|
5
5
|
import { execFile } from "node:child_process";
|
|
6
6
|
import { promisify } from "node:util";
|
|
7
7
|
import { homedir, hostname, platform } from "node:os";
|
|
8
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
8
|
+
import { existsSync, mkdirSync, readFileSync, watch } from "node:fs";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
import { ASCIIFontRenderable, BoxRenderable, CodeRenderable, LineNumberRenderable, RGBA, SelectRenderable, StyledText, SyntaxStyle, TextRenderable, bg, createCliRenderer, fg, getTreeSitterClient, pathToFiletype, t } from "@opentui/core";
|
|
11
11
|
//#region node_modules/.pnpm/effect@4.0.0-beta.102/node_modules/effect/dist/Pipeable.js
|
|
@@ -11201,6 +11201,7 @@ const bodyOf = (entry) => entry.body;
|
|
|
11201
11201
|
const sentOf = (comment, spoken, settled, head) => {
|
|
11202
11202
|
const mine = spoken.filter((entry) => entry.comment === comment.id);
|
|
11203
11203
|
return {
|
|
11204
|
+
id: comment.id,
|
|
11204
11205
|
file: comment.file,
|
|
11205
11206
|
side: comment.side,
|
|
11206
11207
|
start: comment.start,
|
|
@@ -12428,10 +12429,13 @@ const initialState = (branches) => ({
|
|
|
12428
12429
|
patches: [],
|
|
12429
12430
|
patchIndex: 0,
|
|
12430
12431
|
cursor: 0,
|
|
12432
|
+
stop: 0,
|
|
12433
|
+
opened: [],
|
|
12431
12434
|
anchorRow: 0,
|
|
12432
12435
|
selecting: false,
|
|
12433
12436
|
draft: "",
|
|
12434
12437
|
notice: "",
|
|
12438
|
+
waiting: "",
|
|
12435
12439
|
query: "",
|
|
12436
12440
|
paletteIndex: 0,
|
|
12437
12441
|
returnTo: "branches",
|
|
@@ -12677,7 +12681,29 @@ const commentRowsIn = (state, fileIndex) => {
|
|
|
12677
12681
|
const notes = [...state.pending, ...state.sent].filter((entry) => entry.file === patch.path);
|
|
12678
12682
|
return patch.rows.filter((row) => notes.some((note) => lineOnSide(row, note.side) === note.end)).map((row) => row.index).toSorted((left, right) => left - right);
|
|
12679
12683
|
};
|
|
12684
|
+
const threadsAtRow = (state, row) => {
|
|
12685
|
+
const patch = selectedPatch(state);
|
|
12686
|
+
const here = patch?.rows[row];
|
|
12687
|
+
if (patch === void 0 || here === void 0) return [];
|
|
12688
|
+
return state.sent.filter((entry) => entry.file === patch.path && entry.id !== void 0 && lineOnSide(here, entry.side) === entry.end);
|
|
12689
|
+
};
|
|
12690
|
+
const stopsAtRow = (state, row) => 1 + threadsAtRow(state, row).length;
|
|
12691
|
+
const threadAtStop = (state) => state.stop === 0 ? void 0 : threadsAtRow(state, state.cursor)[state.stop - 1];
|
|
12692
|
+
const threadAtRow = (state, row) => {
|
|
12693
|
+
const patch = selectedPatch(state);
|
|
12694
|
+
const here = patch?.rows[row];
|
|
12695
|
+
if (patch === void 0 || here === void 0) return void 0;
|
|
12696
|
+
return state.sent.find((entry) => entry.file === patch.path && entry.id !== void 0 && lineOnSide(here, entry.side) === entry.end);
|
|
12697
|
+
};
|
|
12698
|
+
const openCommentRows = (state) => {
|
|
12699
|
+
const patch = selectedPatch(state);
|
|
12700
|
+
if (patch === void 0) return [];
|
|
12701
|
+
const open = [...state.pending, ...state.sent].filter((entry) => entry.file === patch.path && entry.settled !== true);
|
|
12702
|
+
return patch.rows.filter((row) => open.some((note) => lineOnSide(row, note.side) === note.end)).map((row) => row.index);
|
|
12703
|
+
};
|
|
12680
12704
|
const filesWithComments = (state) => state.patches.flatMap((patch, index) => [...state.pending, ...state.sent].some((entry) => entry.file === patch.path) ? [index] : []);
|
|
12705
|
+
const answerCount = (comments) => comments.reduce((total, entry) => total + (entry.answers?.length ?? 0), 0);
|
|
12706
|
+
const spokenSince = (seen, now) => Math.max(0, answerCount(now) - answerCount(seen));
|
|
12681
12707
|
const hunkStarts = (state) => {
|
|
12682
12708
|
const patch = selectedPatch(state);
|
|
12683
12709
|
return patch === void 0 ? [] : patch.hunks.map((hunk) => hunk.startRow);
|
|
@@ -12767,6 +12793,31 @@ const buildReport = (state, around) => {
|
|
|
12767
12793
|
].join("\n");
|
|
12768
12794
|
};
|
|
12769
12795
|
//#endregion
|
|
12796
|
+
//#region src/tui/watch.ts
|
|
12797
|
+
const OUTBOX = "outbox.jsonl";
|
|
12798
|
+
const SETTLE_MS = 120;
|
|
12799
|
+
const answered = (name) => name !== null && name.endsWith(OUTBOX);
|
|
12800
|
+
const watchAnswers = (root, arrived) => {
|
|
12801
|
+
const branches = join(root, "branches");
|
|
12802
|
+
let timer;
|
|
12803
|
+
let watcher;
|
|
12804
|
+
try {
|
|
12805
|
+
mkdirSync(branches, { recursive: true });
|
|
12806
|
+
watcher = watch(branches, { recursive: true }, (_event, name) => {
|
|
12807
|
+
if (!answered(name)) return;
|
|
12808
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
12809
|
+
timer = setTimeout(arrived, SETTLE_MS);
|
|
12810
|
+
});
|
|
12811
|
+
watcher.on("error", () => void 0);
|
|
12812
|
+
} catch {
|
|
12813
|
+
watcher = void 0;
|
|
12814
|
+
}
|
|
12815
|
+
return { stop: () => {
|
|
12816
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
12817
|
+
watcher?.close();
|
|
12818
|
+
} };
|
|
12819
|
+
};
|
|
12820
|
+
//#endregion
|
|
12770
12821
|
//#region src/tui/command.ts
|
|
12771
12822
|
const command = (input) => ({
|
|
12772
12823
|
category: "Review",
|
|
@@ -12959,6 +13010,14 @@ const commands = [
|
|
|
12959
13010
|
screens: ["branches", "review"],
|
|
12960
13011
|
hint: "reload"
|
|
12961
13012
|
}),
|
|
13013
|
+
command({
|
|
13014
|
+
action: "thread.settle",
|
|
13015
|
+
title: "Settle the thread here",
|
|
13016
|
+
category: "Review",
|
|
13017
|
+
keys: ["d"],
|
|
13018
|
+
screens: ["review"],
|
|
13019
|
+
hint: "settle"
|
|
13020
|
+
}),
|
|
12962
13021
|
command({
|
|
12963
13022
|
action: "rail.toggle",
|
|
12964
13023
|
title: "Switch between layers and files",
|
|
@@ -12970,14 +13029,14 @@ const commands = [
|
|
|
12970
13029
|
}),
|
|
12971
13030
|
command({
|
|
12972
13031
|
action: "tree.collapse",
|
|
12973
|
-
title: "Close the folder, layer, or
|
|
13032
|
+
title: "Close the folder, layer, gap, or settled thread",
|
|
12974
13033
|
category: "Files",
|
|
12975
13034
|
keys: ["h"],
|
|
12976
13035
|
screens: ["review"]
|
|
12977
13036
|
}),
|
|
12978
13037
|
command({
|
|
12979
13038
|
action: "tree.expand",
|
|
12980
|
-
title: "Open the folder, layer, or
|
|
13039
|
+
title: "Open the folder, layer, gap, or settled thread",
|
|
12981
13040
|
category: "Files",
|
|
12982
13041
|
keys: ["l"],
|
|
12983
13042
|
screens: ["review"]
|
|
@@ -13206,8 +13265,31 @@ const withCursorVisible = (state) => {
|
|
|
13206
13265
|
};
|
|
13207
13266
|
const moveCursor = (state, delta) => withCursorVisible({
|
|
13208
13267
|
...state,
|
|
13268
|
+
stop: 0,
|
|
13209
13269
|
cursor: clamp(state.cursor + delta, 0, lastRow(selectedPatch(state)))
|
|
13210
13270
|
});
|
|
13271
|
+
const stepStop = (state, delta) => {
|
|
13272
|
+
const here = stopsAtRow(state, state.cursor) - 1;
|
|
13273
|
+
if (delta > 0 && state.stop < here) return {
|
|
13274
|
+
...state,
|
|
13275
|
+
stop: state.stop + 1
|
|
13276
|
+
};
|
|
13277
|
+
if (delta < 0 && state.stop > 0) return {
|
|
13278
|
+
...state,
|
|
13279
|
+
stop: state.stop - 1
|
|
13280
|
+
};
|
|
13281
|
+
const row = clamp(state.cursor + delta, 0, lastRow(selectedPatch(state)));
|
|
13282
|
+
if (row === state.cursor) return state;
|
|
13283
|
+
const landing = delta < 0 ? stopsAtRow({
|
|
13284
|
+
...state,
|
|
13285
|
+
cursor: row
|
|
13286
|
+
}, row) - 1 : 0;
|
|
13287
|
+
return withCursorVisible({
|
|
13288
|
+
...state,
|
|
13289
|
+
cursor: row,
|
|
13290
|
+
stop: landing
|
|
13291
|
+
});
|
|
13292
|
+
};
|
|
13211
13293
|
const scrolled = (state, delta) => {
|
|
13212
13294
|
const highest = Math.max(0, rowsIn(state) - Math.max(1, state.viewport));
|
|
13213
13295
|
return {
|
|
@@ -13223,6 +13305,7 @@ const draggedTo = (state, from, to) => ({
|
|
|
13223
13305
|
});
|
|
13224
13306
|
const atRow = (state, row) => withCursorVisible({
|
|
13225
13307
|
...state,
|
|
13308
|
+
stop: 0,
|
|
13226
13309
|
cursor: clamp(row, 0, lastRow(selectedPatch(state)))
|
|
13227
13310
|
});
|
|
13228
13311
|
const layerHunk = (state, delta) => {
|
|
@@ -13248,13 +13331,17 @@ const atComment = (state, file, delta) => {
|
|
|
13248
13331
|
const landing = delta > 0 ? rows[0] : rows.at(-1);
|
|
13249
13332
|
return landing === void 0 ? moved : atRow(moved, landing);
|
|
13250
13333
|
};
|
|
13334
|
+
const nothingOpen = (state) => {
|
|
13335
|
+
const any = commentRowsIn(state, state.patchIndex).length > 0;
|
|
13336
|
+
return withNotice(state, any ? "no open comment" : "no comments yet");
|
|
13337
|
+
};
|
|
13251
13338
|
const layerComment = (state, delta) => {
|
|
13252
|
-
const here =
|
|
13339
|
+
const here = openCommentRows(state);
|
|
13253
13340
|
const target = delta > 0 ? here.find((row) => row > state.cursor) : here.findLast((row) => row < state.cursor);
|
|
13254
13341
|
if (target !== void 0) return atRow(state, target);
|
|
13255
13342
|
const file = nextFileWithComments(state, delta);
|
|
13256
13343
|
if (file !== void 0) return atComment(state, file, delta);
|
|
13257
|
-
return here.length > 0 ? state :
|
|
13344
|
+
return here.length > 0 ? state : nothingOpen(state);
|
|
13258
13345
|
};
|
|
13259
13346
|
const PAN_STEP = 8;
|
|
13260
13347
|
const panned = (state, delta) => {
|
|
@@ -13285,7 +13372,7 @@ const moveLayer = (state, delta) => {
|
|
|
13285
13372
|
};
|
|
13286
13373
|
};
|
|
13287
13374
|
const inRail = (state, delta) => onLayers(state) ? moveLayer(state, delta) : moveFile(state, delta);
|
|
13288
|
-
const layerDown = (state, delta) => state.focus === "tree" ? inRail(state, delta) :
|
|
13375
|
+
const layerDown = (state, delta) => state.focus === "tree" ? inRail(state, delta) : stepStop(state, delta);
|
|
13289
13376
|
const toggleRail = (state) => {
|
|
13290
13377
|
if (state.layers.length === 0) return withNotice(state, "no layers for this branch");
|
|
13291
13378
|
if (state.rail === "layers") return {
|
|
@@ -13314,7 +13401,18 @@ const foldLayer = (state, shut) => {
|
|
|
13314
13401
|
openLayers: shut ? open : [...open, state.layerIndex]
|
|
13315
13402
|
};
|
|
13316
13403
|
};
|
|
13317
|
-
const
|
|
13404
|
+
const foldThread = (state, shut, id) => {
|
|
13405
|
+
const rest = state.opened.filter((held) => held !== id);
|
|
13406
|
+
return {
|
|
13407
|
+
...state,
|
|
13408
|
+
opened: shut ? rest : [...rest, id]
|
|
13409
|
+
};
|
|
13410
|
+
};
|
|
13411
|
+
const fold = (state, shut) => {
|
|
13412
|
+
const thread = threadAtStop(state);
|
|
13413
|
+
if (thread?.id !== void 0 && thread.settled === true) return foldThread(state, shut, thread.id);
|
|
13414
|
+
return onLayers(state) ? foldLayer(state, shut) : foldDirectory(state, shut);
|
|
13415
|
+
};
|
|
13318
13416
|
const moveBranch = (state, delta) => ({
|
|
13319
13417
|
...state,
|
|
13320
13418
|
branchIndex: clamp(state.branchIndex + delta, 0, Math.max(0, state.branches.length - 1))
|
|
@@ -13455,6 +13553,7 @@ const transitions = {
|
|
|
13455
13553
|
"pan.right": (state) => panned(state, PAN_STEP),
|
|
13456
13554
|
"pan.left": (state) => panned(state, -8),
|
|
13457
13555
|
"review.reload": (state) => state,
|
|
13556
|
+
"thread.settle": (state) => state,
|
|
13458
13557
|
"rail.toggle": toggleRail,
|
|
13459
13558
|
"file.vouch": (state) => state,
|
|
13460
13559
|
"file.vouch.next": (state) => state,
|
|
@@ -13616,6 +13715,10 @@ const paletteClosed = (state) => ({
|
|
|
13616
13715
|
screen: state.returnTo,
|
|
13617
13716
|
query: ""
|
|
13618
13717
|
});
|
|
13718
|
+
const withWaiting = (state, waiting) => ({
|
|
13719
|
+
...state,
|
|
13720
|
+
waiting
|
|
13721
|
+
});
|
|
13619
13722
|
const withNoticeHere = (state, notice) => ({
|
|
13620
13723
|
...state,
|
|
13621
13724
|
notice
|
|
@@ -13855,6 +13958,7 @@ var DiffView = class {
|
|
|
13855
13958
|
starts = /* @__PURE__ */ new Map();
|
|
13856
13959
|
fitted = 1;
|
|
13857
13960
|
wrapped = false;
|
|
13961
|
+
held = 0;
|
|
13858
13962
|
constructor(renderer) {
|
|
13859
13963
|
this.code = new CodeRenderable(renderer, {
|
|
13860
13964
|
id: "diff-code",
|
|
@@ -13963,12 +14067,15 @@ var DiffView = class {
|
|
|
13963
14067
|
});
|
|
13964
14068
|
this.starts = startsOf(this.display);
|
|
13965
14069
|
this.code.filetype = pathToFiletype(patch.path) ?? "text";
|
|
13966
|
-
this.
|
|
14070
|
+
this.feed();
|
|
13967
14071
|
this.numbers.setLineNumbers(lineNumbers(patch, this.display));
|
|
13968
14072
|
this.numbers.setHideLineNumbers(bareOf(this.display));
|
|
13969
14073
|
this.numbers.setLineSigns(lineSigns(patch, this.display));
|
|
13970
14074
|
this.numbers.setLineColors(/* @__PURE__ */ new Map());
|
|
13971
|
-
|
|
14075
|
+
}
|
|
14076
|
+
feed() {
|
|
14077
|
+
const spans = noteSpans(this.display, this.held);
|
|
14078
|
+
this.code.content = textAt(this.display, this.held);
|
|
13972
14079
|
this.code.onHighlight = (highlights) => [...highlights.filter((highlight) => !spans.some(([from, to]) => highlight[0] < to && highlight[1] > from)), ...spans];
|
|
13973
14080
|
}
|
|
13974
14081
|
setWrap(on) {
|
|
@@ -13982,6 +14089,10 @@ var DiffView = class {
|
|
|
13982
14089
|
}
|
|
13983
14090
|
setPan(columns) {
|
|
13984
14091
|
const wanted = this.wrapped ? 0 : Math.max(0, Math.min(this.code.maxScrollX, columns));
|
|
14092
|
+
if (wanted !== this.held) {
|
|
14093
|
+
this.held = wanted;
|
|
14094
|
+
this.feed();
|
|
14095
|
+
}
|
|
13985
14096
|
if (this.code.scrollX !== wanted) this.code.scrollX = wanted;
|
|
13986
14097
|
if (this.pinned.scrollX !== wanted) this.pinned.scrollX = wanted;
|
|
13987
14098
|
}
|
|
@@ -14025,6 +14136,15 @@ var DiffView = class {
|
|
|
14025
14136
|
const at = Math.max(0, Math.min(this.display.length - 1, line));
|
|
14026
14137
|
return this.display[at]?.row ?? 0;
|
|
14027
14138
|
}
|
|
14139
|
+
stopAt(visual) {
|
|
14140
|
+
return this.display[this.lineAt(visual)]?.stop ?? 0;
|
|
14141
|
+
}
|
|
14142
|
+
carries(visual) {
|
|
14143
|
+
const entry = this.display[this.lineAt(visual)];
|
|
14144
|
+
if (entry === void 0) return false;
|
|
14145
|
+
if (entry.prose) return false;
|
|
14146
|
+
return true;
|
|
14147
|
+
}
|
|
14028
14148
|
isComment(visual) {
|
|
14029
14149
|
const entry = this.display[this.lineAt(visual)];
|
|
14030
14150
|
return entry?.comment === true || entry?.prose === true;
|
|
@@ -14068,7 +14188,7 @@ const startsOf = (display) => {
|
|
|
14068
14188
|
const bareOf = (display) => new Set(display.flatMap((entry, index) => entry.comment || entry.gap || entry.prose ? [index] : []));
|
|
14069
14189
|
const keyOf = (room, notes, prose) => [
|
|
14070
14190
|
room,
|
|
14071
|
-
...notes.map((note) => `${note.side}${note.line}:${note.body}`),
|
|
14191
|
+
...notes.map((note) => `${note.side}${note.line}:${note.folded ? "-" : "+"}${note.body}`),
|
|
14072
14192
|
...prose.map((entry) => `p${entry.line}${entry.after ? ">" : "<"}:${entry.markdown}`)
|
|
14073
14193
|
].join("\0");
|
|
14074
14194
|
const groupOf = (entry) => {
|
|
@@ -14078,17 +14198,21 @@ const groupOf = (entry) => {
|
|
|
14078
14198
|
if (entry.label) return "note.label";
|
|
14079
14199
|
return entry.sent ? "note.sent" : "note";
|
|
14080
14200
|
};
|
|
14081
|
-
const
|
|
14201
|
+
const isChrome = (entry) => entry.comment || entry.gap || entry.prose;
|
|
14202
|
+
const heldAt = (entry, pan) => isChrome(entry) && pan > 0 ? `${" ".repeat(pan)}${entry.text}` : entry.text;
|
|
14203
|
+
const textAt = (display, pan) => display.map((entry) => heldAt(entry, pan)).join("\n");
|
|
14204
|
+
const noteSpans = (display, pan) => {
|
|
14082
14205
|
const spans = [];
|
|
14083
14206
|
let at = 0;
|
|
14084
14207
|
for (const entry of display) {
|
|
14085
14208
|
const group = groupOf(entry);
|
|
14209
|
+
const width = heldAt(entry, pan).length;
|
|
14086
14210
|
if (group !== void 0) spans.push([
|
|
14087
14211
|
at,
|
|
14088
|
-
at +
|
|
14212
|
+
at + width,
|
|
14089
14213
|
group
|
|
14090
14214
|
]);
|
|
14091
|
-
at +=
|
|
14215
|
+
at += width + 1;
|
|
14092
14216
|
}
|
|
14093
14217
|
return spans;
|
|
14094
14218
|
};
|
|
@@ -14119,14 +14243,15 @@ const spokenLines = (body, room) => {
|
|
|
14119
14243
|
return wrap(body.replaceAll("\n", " "), Math.max(NOTE_MIN, room - 2)).map((text, at) => at === 0 ? `${ANSWER_MARK} ${text}` : ` ${text}`);
|
|
14120
14244
|
};
|
|
14121
14245
|
const answerLines = (note, room) => note.answers.flatMap((body) => spokenLines(body, room));
|
|
14122
|
-
const noteLines = (note, room) => [
|
|
14246
|
+
const noteLines = (note, room) => note.folded ? [`${headOf(note)} · press l`] : [
|
|
14123
14247
|
headOf(note),
|
|
14124
14248
|
...note.body.split("\n").flatMap((line) => wrap(line, room)),
|
|
14125
14249
|
...answerLines(note, room)
|
|
14126
14250
|
];
|
|
14127
|
-
const noteRows = (note, row, room) => noteLines(note, room).map((line, index) => ({
|
|
14251
|
+
const noteRows = (note, row, room, stop) => noteLines(note, room).map((line, index) => ({
|
|
14128
14252
|
text: `${marks().rule} ${line}`,
|
|
14129
14253
|
row,
|
|
14254
|
+
stop,
|
|
14130
14255
|
comment: true,
|
|
14131
14256
|
sent: note.sent,
|
|
14132
14257
|
label: index === 0,
|
|
@@ -14136,6 +14261,7 @@ const noteRows = (note, row, room) => noteLines(note, room).map((line, index) =>
|
|
|
14136
14261
|
const proseRows = (entry, row, room) => [...entry.markdown.split("\n").flatMap((line) => wrap(line, room - 2)), ""].map((line) => ({
|
|
14137
14262
|
text: line.length === 0 ? "" : ` ${line}`,
|
|
14138
14263
|
row,
|
|
14264
|
+
stop: 0,
|
|
14139
14265
|
comment: false,
|
|
14140
14266
|
sent: false,
|
|
14141
14267
|
label: false,
|
|
@@ -14147,10 +14273,11 @@ const proseAt = (plan, row, after) => {
|
|
|
14147
14273
|
if (line === void 0) return [];
|
|
14148
14274
|
return plan.prose.filter((entry) => entry.after === after && entry.line === line);
|
|
14149
14275
|
};
|
|
14150
|
-
const notesAt = (plan, row) => plan.notes.filter((note) => sideLineOf(row, note.side) === note.line).flatMap((note) => noteRows(note, row.index, plan.room));
|
|
14276
|
+
const notesAt = (plan, row) => plan.notes.filter((note) => sideLineOf(row, note.side) === note.line).flatMap((note, at) => noteRows(note, row.index, plan.room, at + 1));
|
|
14151
14277
|
const codeRow = (plan, row) => ({
|
|
14152
14278
|
text: row.text,
|
|
14153
14279
|
row: row.index,
|
|
14280
|
+
stop: 0,
|
|
14154
14281
|
comment: false,
|
|
14155
14282
|
sent: false,
|
|
14156
14283
|
label: false,
|
|
@@ -14488,7 +14615,10 @@ const waitingLabel = (branch) => {
|
|
|
14488
14615
|
if (branch.staged > 0) return `${branch.staged} staged`;
|
|
14489
14616
|
return branch.unread > 0 ? `${branch.unread} unread` : "";
|
|
14490
14617
|
};
|
|
14491
|
-
const
|
|
14618
|
+
const inRange = (state, row, from, to) => state.selecting && row >= from && row <= to;
|
|
14619
|
+
const notesOf = (comments, path, sent, opened = []) => comments.filter((entry) => entry.file === path).map((entry) => ({
|
|
14620
|
+
id: entry.id ?? "",
|
|
14621
|
+
folded: entry.settled === true && !(entry.id !== void 0 && opened.includes(entry.id)),
|
|
14492
14622
|
side: entry.side,
|
|
14493
14623
|
line: entry.end,
|
|
14494
14624
|
body: entry.body,
|
|
@@ -14498,18 +14628,24 @@ const notesOf = (comments, path, sent) => comments.filter((entry) => entry.file
|
|
|
14498
14628
|
asks: entry.asks === true,
|
|
14499
14629
|
answers: entry.answers ?? []
|
|
14500
14630
|
}));
|
|
14501
|
-
const notesFor = (state, path) => [...notesOf(state.sent, path, true), ...notesOf(state.pending, path, false)];
|
|
14631
|
+
const notesFor = (state, path) => [...notesOf(state.sent, path, true, state.opened), ...notesOf(state.pending, path, false)];
|
|
14632
|
+
const paired = (chunks) => {
|
|
14633
|
+
const chips = [];
|
|
14634
|
+
for (let at = 0; at < chunks.length; at += CHIP_CHUNKS) chips.push(chunks.slice(at, at + CHIP_CHUNKS));
|
|
14635
|
+
return chips;
|
|
14636
|
+
};
|
|
14502
14637
|
const keptWithin = (chunks, room) => {
|
|
14503
14638
|
const kept = [];
|
|
14504
14639
|
let used = 0;
|
|
14505
|
-
for (const
|
|
14506
|
-
const width = chunk.text.length;
|
|
14640
|
+
for (const chip of paired(chunks).toReversed()) {
|
|
14641
|
+
const width = chip.reduce((total, chunk) => total + chunk.text.length, 0);
|
|
14507
14642
|
if (used + width > room) break;
|
|
14508
|
-
kept.unshift(
|
|
14643
|
+
kept.unshift(chip);
|
|
14509
14644
|
used += width;
|
|
14510
14645
|
}
|
|
14511
|
-
return kept;
|
|
14646
|
+
return kept.flat();
|
|
14512
14647
|
};
|
|
14648
|
+
const CHIP_CHUNKS = 3;
|
|
14513
14649
|
const shortPath = (path) => {
|
|
14514
14650
|
const home = process.env["HOME"] ?? "";
|
|
14515
14651
|
return home.length > 0 && path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
@@ -14766,11 +14902,13 @@ var Screen = class {
|
|
|
14766
14902
|
const readout = selectionReadout(state);
|
|
14767
14903
|
this.lead = readout.length === 0 ? 0 : readout.length + 3;
|
|
14768
14904
|
const lead = readout.length === 0 ? [] : [fg(palette.muted)(`${readout} `)];
|
|
14769
|
-
const
|
|
14905
|
+
const said = state.notice.length === 0 ? state.waiting : state.notice;
|
|
14906
|
+
const tail = said.length === 0 ? "" : ` ${said}`;
|
|
14770
14907
|
const width = this.footer.width > 0 ? this.footer.width : this.renderer.width;
|
|
14771
14908
|
const room = Math.max(0, width - this.lead - tail.length);
|
|
14772
14909
|
const chips = keptWithin(this.chipRow().chunks, room);
|
|
14773
|
-
const
|
|
14910
|
+
const colour = state.notice.length === 0 ? palette.accent : palette.attention;
|
|
14911
|
+
const notice = tail.length === 0 ? [] : [fg(colour)(tail)];
|
|
14774
14912
|
return new StyledText([
|
|
14775
14913
|
...lead,
|
|
14776
14914
|
...chips,
|
|
@@ -14915,8 +15053,10 @@ var Screen = class {
|
|
|
14915
15053
|
}
|
|
14916
15054
|
homeKeys(state) {
|
|
14917
15055
|
const chips = this.chipRow().chunks;
|
|
14918
|
-
|
|
14919
|
-
return new StyledText(
|
|
15056
|
+
const said = state.notice.length === 0 ? state.waiting : state.notice;
|
|
15057
|
+
if (said.length === 0) return new StyledText(chips);
|
|
15058
|
+
const colour = state.notice.length === 0 ? palette.accent : palette.attention;
|
|
15059
|
+
return new StyledText([...chips, fg(colour)(` ${said}`)]);
|
|
14920
15060
|
}
|
|
14921
15061
|
chipRow() {
|
|
14922
15062
|
return new StyledText(this.chips.flatMap((chip, index) => {
|
|
@@ -14979,12 +15119,15 @@ var Screen = class {
|
|
|
14979
15119
|
const [from, to] = selectionRange(state);
|
|
14980
15120
|
const marked = markedRows(state);
|
|
14981
15121
|
const drawn = this.view.drawn();
|
|
14982
|
-
const bare = (visual) => visual >= drawn || this.view.
|
|
14983
|
-
const
|
|
14984
|
-
|
|
14985
|
-
const
|
|
14986
|
-
|
|
14987
|
-
|
|
15122
|
+
const bare = (visual) => visual >= drawn || !this.view.carries(visual) || this.view.isRunOn(visual);
|
|
15123
|
+
const held = (visual) => {
|
|
15124
|
+
const row = this.view.rowAt(visual);
|
|
15125
|
+
const onCode = this.view.stopAt(visual) === 0;
|
|
15126
|
+
const standing = row === state.cursor && this.view.stopAt(visual) === state.stop;
|
|
15127
|
+
const within = onCode && inRange(state, row, from, to);
|
|
15128
|
+
return `${standing || within ? marks().cursor : " "}${onCode && marked.has(row) ? marks().comment : " "}`;
|
|
15129
|
+
};
|
|
15130
|
+
const rows = Array.from({ length: height }, (_, index) => bare(top + index) ? " " : held(top + index));
|
|
14988
15131
|
this.gutter.content = rows.join("\n");
|
|
14989
15132
|
}
|
|
14990
15133
|
paintSticky(state, top) {
|
|
@@ -15093,6 +15236,7 @@ var App = class {
|
|
|
15093
15236
|
fading;
|
|
15094
15237
|
wheel = 0;
|
|
15095
15238
|
sideways = 0;
|
|
15239
|
+
watching;
|
|
15096
15240
|
constructor(options) {
|
|
15097
15241
|
this.renderer = options.renderer;
|
|
15098
15242
|
this.repo = options.repo;
|
|
@@ -15114,13 +15258,34 @@ var App = class {
|
|
|
15114
15258
|
onChip: (key) => this.dispatchTask(() => this.onKey(asKey(key)))
|
|
15115
15259
|
});
|
|
15116
15260
|
renderer.keyInput.on("keypress", (key) => this.dispatch(key));
|
|
15261
|
+
renderer.on("destroy", () => this.stopWatching());
|
|
15117
15262
|
renderer.on("destroy", () => this.stopFading());
|
|
15118
15263
|
renderer.on("frame", () => this.syncGeometry());
|
|
15119
15264
|
renderer.setFrameCallback(async () => this.applyWheel());
|
|
15120
15265
|
const resume = options.resume;
|
|
15266
|
+
this.startWatching(options.storeRoot);
|
|
15121
15267
|
this.dispatchTask(() => this.loadPulls());
|
|
15122
15268
|
if (resume !== void 0) this.dispatchTask(() => this.resume(resume));
|
|
15123
15269
|
}
|
|
15270
|
+
startWatching(root) {
|
|
15271
|
+
if (root === void 0) return;
|
|
15272
|
+
this.watching = watchAnswers(root, () => this.dispatchTask(() => this.noticeAnswers()));
|
|
15273
|
+
}
|
|
15274
|
+
stopWatching() {
|
|
15275
|
+
this.watching?.stop();
|
|
15276
|
+
this.watching = void 0;
|
|
15277
|
+
}
|
|
15278
|
+
async noticeAnswers() {
|
|
15279
|
+
const branch = selectedBranch(this.state);
|
|
15280
|
+
if (branch === void 0) return this.noticeOnList();
|
|
15281
|
+
const sent = await this.loadSent(branch.branch);
|
|
15282
|
+
const said = spokenSince(this.state.sent, sent);
|
|
15283
|
+
if (said === 0) return;
|
|
15284
|
+
this.commit(withWaiting(this.state, `${said} answered · press r`));
|
|
15285
|
+
}
|
|
15286
|
+
async noticeOnList() {
|
|
15287
|
+
this.commit(withWaiting(this.state, "the agent answered · press r"));
|
|
15288
|
+
}
|
|
15124
15289
|
dispatchTask(task) {
|
|
15125
15290
|
this.pending = this.pending.then(task).catch((cause) => this.fail(cause));
|
|
15126
15291
|
}
|
|
@@ -15236,6 +15401,7 @@ var App = class {
|
|
|
15236
15401
|
"rail.toggle": () => this.commitSynced("rail.toggle"),
|
|
15237
15402
|
"file.vouch": () => this.vouch(false),
|
|
15238
15403
|
"file.vouch.next": () => this.vouch(true),
|
|
15404
|
+
"thread.settle": () => this.settleHere(),
|
|
15239
15405
|
"review.reload": () => this.state.screen === "branches" ? this.reloadList() : this.reloadBranch(),
|
|
15240
15406
|
"pending.open": () => this.openPending(),
|
|
15241
15407
|
"pending.edit": () => this.editStagedComment(),
|
|
@@ -15304,6 +15470,18 @@ var App = class {
|
|
|
15304
15470
|
this.commit(await this.readBranch(branch.branch));
|
|
15305
15471
|
await this.loadSource();
|
|
15306
15472
|
}
|
|
15473
|
+
async settleHere() {
|
|
15474
|
+
const branch = selectedBranch(this.state);
|
|
15475
|
+
const id = (threadAtStop(this.state) ?? threadAtRow(this.state, this.state.cursor))?.id;
|
|
15476
|
+
if (branch === void 0 || id === void 0) return this.commit(withNotice(this.state, "no thread here"));
|
|
15477
|
+
await this.run(settleThread(this.repo, branch.branch, id, (/* @__PURE__ */ new Date()).toISOString()));
|
|
15478
|
+
const sent = await this.loadSent(branch.branch);
|
|
15479
|
+
const held = withSent({
|
|
15480
|
+
...this.state,
|
|
15481
|
+
opened: this.state.opened.filter((was) => was !== id)
|
|
15482
|
+
}, sent);
|
|
15483
|
+
this.commit(withNotice(held, "settled"));
|
|
15484
|
+
}
|
|
15307
15485
|
async reloadList() {
|
|
15308
15486
|
const here = selectedBranch(this.state)?.branch;
|
|
15309
15487
|
const branches = await this.run(listBranches(this.repo));
|
|
@@ -15313,7 +15491,7 @@ var App = class {
|
|
|
15313
15491
|
...read,
|
|
15314
15492
|
branchIndex: at
|
|
15315
15493
|
};
|
|
15316
|
-
this.commit(withNoticeHere(kept, "read the list again"));
|
|
15494
|
+
this.commit(withWaiting(withNoticeHere(kept, "read the list again"), ""));
|
|
15317
15495
|
this.dispatchTask(() => this.loadPulls());
|
|
15318
15496
|
}
|
|
15319
15497
|
async reloadBranch() {
|
|
@@ -15322,7 +15500,7 @@ var App = class {
|
|
|
15322
15500
|
const path = selectedPatch(this.state)?.path;
|
|
15323
15501
|
const line = sourceLineAt(this.state, this.state.cursor);
|
|
15324
15502
|
const read = await this.readBranch(branch.branch);
|
|
15325
|
-
this.commit(withNotice(restoredTo(read, path, line), "read the branch again"));
|
|
15503
|
+
this.commit(withWaiting(withNotice(restoredTo(read, path, line), "read the branch again"), ""));
|
|
15326
15504
|
await this.loadSource();
|
|
15327
15505
|
}
|
|
15328
15506
|
async goBack() {
|
|
@@ -15523,7 +15701,8 @@ const launch = fn("Tui.launch")(function* (repo, renderer, noticeMs, sessionPath
|
|
|
15523
15701
|
const context$2 = yield* context();
|
|
15524
15702
|
const branches = yield* listBranches(repo);
|
|
15525
15703
|
const resume = sessionPath === void 0 ? void 0 : yield* promise(() => readSession(sessionPath));
|
|
15526
|
-
const
|
|
15704
|
+
const store = yield* Store;
|
|
15705
|
+
const settings = yield* store.settings();
|
|
15527
15706
|
return new App({
|
|
15528
15707
|
renderer,
|
|
15529
15708
|
repo,
|
|
@@ -15532,7 +15711,8 @@ const launch = fn("Tui.launch")(function* (repo, renderer, noticeMs, sessionPath
|
|
|
15532
15711
|
noticeMs,
|
|
15533
15712
|
sessionPath,
|
|
15534
15713
|
resume,
|
|
15535
|
-
wrap: settings.wrap === true
|
|
15714
|
+
wrap: settings.wrap === true,
|
|
15715
|
+
storeRoot: store.root
|
|
15536
15716
|
});
|
|
15537
15717
|
});
|
|
15538
15718
|
const untilDestroyed = (renderer) => callback((resume) => {
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"bin": {
|
|
22
22
|
"adiff": "./bin/adiff.js"
|
|
23
23
|
},
|
|
24
|
-
"version": "0.1.0-alpha.
|
|
24
|
+
"version": "0.1.0-alpha.18",
|
|
25
25
|
"description": "Review agent work across git worktrees like a PR, and hand the comments back to the agent.",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"repository": {
|