@eliya-oss/agent-diff 0.1.0-alpha.71 → 0.1.0-alpha.73

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.73
4
+
5
+ ### Patch Changes
6
+
7
+ - The README is short: install, `adiff init --write --skill`, and ask your agent to onboard you. The full handover with layers and coverage moved to `docs/handover.md`. The compose panel no longer offers a key that was removed.
8
+
9
+ - Everything drawn on the screen can be selected and copied, including the palette, the sheet of keys and the search results, which were drawn by a widget that hid its text. A selection clears on the next key. The row the cursor is on is washed rather than dotted, and the arrows walk between files.
10
+
11
+ ## 0.1.0-alpha.72
12
+
13
+ ### Patch Changes
14
+
15
+ - Dragging inside one line copies the characters it covered. The wheel belongs to the review again, so scrolling and then pressing an arrow no longer throws the view back. `S` turns the pinned scope off. Settling from the panel keeps the cursor on the thread it settled.
16
+
3
17
  ## 0.1.0-alpha.71
4
18
 
5
19
  ### Patch Changes
package/README.md CHANGED
@@ -2,18 +2,11 @@
2
2
 
3
3
  # adiff
4
4
 
5
- An agent finishes a piece of work and leaves you a diff. You read it without knowing why any of it
6
- was written that way, and asking means describing a line back in prose and reading the reply
7
- somewhere far from the code it concerns. On a large change you carry the whole review in your head,
8
- and it ends when your patience does.
5
+ An agent finishes a piece of work and leaves you a diff. adiff puts the conversation on the code:
6
+ you comment on the lines in a terminal, the agent that wrote them answers under your words, and a
7
+ point stays open until you settle it.
9
8
 
10
- adiff puts the conversation on the code. You comment on the lines in a terminal, the agent that
11
- wrote them answers under your words, and a point stays open until you settle it.
12
-
13
- The agent can also hand you a reading order: its own diff in layers, a note on each, and a coverage
14
- check so nothing is quietly left out of the story.
15
-
16
- <pre align="center">npm i -g @eliya-oss/agent-diff@alpha</pre>
9
+ <pre align="center">brew install Newbie012/tap/adiff</pre>
17
10
 
18
11
  <p align="center"><a href="docs/install.md">Other ways to install</a></p>
19
12
 
@@ -21,174 +14,58 @@ check so nothing is quietly left out of the story.
21
14
 
22
15
  </div>
23
16
 
24
- ## The loop
17
+ ## Getting started
25
18
 
26
- You comment on a line:
19
+ Install adiff, then teach the repository what it is:
27
20
 
28
21
  ```bash
29
- adiff comment send --repo . --branch add-teammate-invitations \
30
- --file src/api/invitations.ts --start 12 --end 13 \
31
- --body "Three status checks in a row. One error shape would do."
22
+ brew install Newbie012/tap/adiff
23
+ adiff init --write --skill
32
24
  ```
33
25
 
34
- The agent in that worktree collects it, carrying the code it was written against:
35
-
36
- ```bash
37
- adiff comment take --worktree .
38
- {"ok":true,"comments":[{"id":"1c43cb55-6a09-406d-95ad-f048c43e05f5","file":"src/api/invitations.ts",
39
- "side":"new","start":12,"end":13,"head":"63c11ce3",
40
- "snippet":" if (res.status === 409) throw new AlreadyInvited(email)\n ...",
41
- "body":"Three status checks in a row. One error shape would do."}]}
42
- ```
43
-
44
- It does the work, then answers the comment it was handed:
45
-
46
- ```bash
47
- adiff comment answer --worktree . --id 1c43cb55-6a09-406d-95ad-f048c43e05f5 \
48
- --body "Folded them into one InviteRejected carrying the reason."
49
- {"ok":true,"answered":1}
50
- ```
51
-
52
- You see that answer under your own words the next time you read the branch, and the thread waits
53
- there until you settle it with `d`:
54
-
55
- ```bash
56
- adiff comment list --repo . --branch add-teammate-invitations
57
- {"ok":true,"comments":[{"id":"1c43cb55-6a09-406d-95ad-f048c43e05f5","state":"answered",
58
- "stale":false,"answers":[{"body":"Folded them into one InviteRejected carrying the reason.",
59
- "asks":false}]}]}
60
- ```
26
+ `init` writes a short passage into `AGENTS.md` and a `CLAUDE.md` that imports it, and `--skill`
27
+ writes the full skill into `.claude/skills/adiff/`. Then ask your agent to walk you through it:
61
28
 
62
- `--question` on an answer marks the thread as waiting on you, for a decision the agent needs before
63
- it can carry on. Settling is yours alone: the agent that raised the answer cannot close the point.
64
-
65
- Every command that acts on a review takes either `--worktree <path>` or `--repo <path>` with
66
- `--branch <name>`, so the same command works from your checkout and from the agent's worktree.
67
-
68
- A comment is handed over exactly once, so a second `take` returns only what was written since. Add
69
- `--wait 300` and it blocks until something arrives, which costs nothing while it waits.
70
-
71
- ## The reading order
72
-
73
- An agent knows the order it built a change in. Rebuilding that order by reading forty files is the
74
- expensive way to learn something it already has, so it can publish the reading itself when you ask
75
- for one:
76
-
77
- ```bash
78
- adiff layers set --worktree . --json -
79
- ```
80
-
81
- Each layer is a claim over spans of the diff, with a note saying what the layer is for. The terminal
82
- lists them in the sidebar and scopes the diff to the layer you are on, with the prose sitting above
83
- the code it describes.
84
-
85
- adiff computes the coverage itself, so the reading cannot hide code:
86
-
87
- ```bash
88
- adiff layers show --worktree . --fields covered,total,uncovered
89
- {"ok":true,"layers":{"covered":3,"total":3,"uncovered":[]}}
90
- ```
29
+ > Read the adiff skill and onboard me: hand your current work over for review, and tell me what to
30
+ > press.
91
31
 
92
- Any hunk no layer claims is reported here and shown to you under "not in any layer". The layers
93
- record the commit they were written for, and adiff marks them stale once the branch moves past it.
32
+ From then on the loop is: the agent hands work over, you read it, and it answers what you wrote.
94
33
 
95
34
  ## Reviewing
96
35
 
97
- `adiff review open --repo .` lists the worktrees with something to review, including the checkout
98
- you are standing in. Enter opens one.
99
-
100
- `j` and `k` move down the diff, `[` and `]` between files, `v` starts a selection and `c` writes a
101
- comment, which `ctrl+s` sends. `y` copies the line you are on, and dragging over lines copies them. `m`
102
- marks a file reviewed, `d` settles the thread you are on, `s` swaps the sidebar between layers and
103
- files, `w` wraps long lines, `/` searches for what you selected, `r` reads the branch again, and
104
- `ctrl+p` finds any command by name. The footer lists the keys for wherever you are.
105
-
106
- Where the diff leaves lines out, a row says how many. Put the cursor on it and `l` brings ten of them
107
- back where you stand, `h` puts them away, and the rest of the file stays as small as it was. Opened
108
- lines are ordinary lines: select them and comment on them.
109
-
110
- ## Setting up a repository
111
-
112
36
  ```bash
113
- adiff init # shows what it would write
114
- adiff init --write # writes it
37
+ adiff review open --repo .
115
38
  ```
116
39
 
117
- Writes a short passage into `AGENTS.md` and a `CLAUDE.md` that imports it, telling any agent working
118
- in that repository how the handover runs. It sits between `<!-- adiff:begin -->` and
119
- `<!-- adiff:end -->`, so a second run changes nothing and removing it is deleting a block you can
120
- see. `--skill` also writes the full skill into `.claude/skills/adiff/`.
40
+ `j` and `k` move down the diff, `[` and `]` between files, `v` starts a selection and `c` writes a
41
+ comment that `ctrl+s` sends. `d` settles the thread you are on, `m` marks a file reviewed, `y`
42
+ copies the line you are on, and dragging over lines copies them. `?` lists every key and filters as
43
+ you type. The footer carries the keys of whichever pane you are in.
121
44
 
122
- For a per-machine install instead:
45
+ ## For agents
123
46
 
124
- ```bash
125
- npx skills add Newbie012/agent-diff --skill adiff
126
- ```
127
-
128
- When someone asks for a review, the agent can put it in front of them:
47
+ Three commands are the whole loop:
129
48
 
130
49
  ```bash
131
- adiff review pane --repo .
132
- {"ok":true,"opened":true,"pane":"tmux","command":"adiff review open --repo /work/api"}
50
+ adiff comment take --worktree . --wait 300 # what the reviewer wrote, with the code it was on
51
+ adiff comment answer --worktree . --id <id> --body "what you did about it"
52
+ adiff review pane --repo . # put the review in front of them, split in tmux
133
53
  ```
134
54
 
135
- It splits tmux, Zellij, WezTerm or kitty. Anywhere else it answers `opened:false` and carries the
136
- command to run, so the agent quotes one line rather than a paragraph.
55
+ Everything answers JSON on stdout and `{"ok":false,"error":{...}}` on stderr, with a `suggestion`
56
+ naming the command that resolves it. `adiff describe` returns the whole catalog, so nothing here has
57
+ to be memorised. [The handover in detail](docs/handover.md) covers layers, coverage and the rest.
137
58
 
138
59
  ## Requirements
139
60
 
140
- Either install gives you an `adiff` on your PATH. Brew brings a Node 26 along with it, so everything
141
- works the moment it finishes.
142
-
143
- The commands run on Node 22 or newer. The terminal is the one part that wants Node 26: it draws
144
- through opentui, which reaches its native renderer over `node:ffi`, a module Node exposes behind
145
- `--experimental-ffi` from 26 onward. When you open the terminal on an older Node, adiff looks for a
146
- Node 26 among your fnm, nvm, asdf, volta and Homebrew installs and runs the terminal on that, so a
147
- global npm install keeps working across a version switch.
148
-
149
- ## Trying it
150
-
151
- pnpm 12 is a Rust rewrite and still in beta, so
152
- [corepack cannot install it](https://pnpm.io/installation):
153
-
154
- ```bash
155
- corepack disable pnpm
156
- npm install -g --allow-scripts=pnpm pnpm@next-12
157
- pnpm install
158
- ```
159
-
160
- `pnpm simulate` builds a throwaway repository with seven branches an agent has already worked on,
161
- from a three-file error type up to a 42-file migration of just over a thousand lines each way, and
162
- opens the terminal on it. Your real repos and `~/.adiff` are untouched, and the workspace goes when
163
- you quit. `pnpm simulate --probe` runs the whole round trip headless and prints it:
164
-
165
- ```
166
- branches {"ok":true,"branches":[{"branch":"add-teammate-invitations","files":3,"added":27,"removed":2,"layers":2,...
167
- reviewed {"ok":true,"reviewed":["src/api/invitations.ts"],"total":3}
168
- agent takes {"ok":true,"comments":[{"id":"a83fc98c-8397-44f5-9c37-731a1cf3cb4c","file":"src/api/invitations.ts",
169
- "side":"new","start":12,"end":13,"snippet":" if (res.status === 409) throw new AlreadyInvited(email)...",
170
- "body":"Three status checks in a row. One error shape would do."}]}
171
- ```
61
+ The commands run on Node 22 or newer. The terminal wants Node 26, which Homebrew brings along; on a
62
+ global npm install adiff finds a Node 26 among your fnm, nvm, asdf, volta and Homebrew installs and
63
+ runs the terminal on that.
172
64
 
173
65
  ## Notes
174
66
 
175
- adiff is alpha, and one person's tool. Every release goes out under the `alpha` tag.
176
-
177
- Everything the terminal does is also a command, so nothing is trapped in the UI. Each command prints
178
- one compact JSON line on stdout and exits 0, and `--fields` trims the answer to what you read:
179
-
180
- ```bash
181
- adiff branch list --repo . --fields branch,files
182
- {"ok":true,"branches":[{"branch":"add-teammate-invitations","files":3}]}
183
- ```
184
-
185
- Failures go to stderr as `{"ok":false,"error":{...}}`, so stdout is always parseable, with an exit
186
- code saying what to do about it: `2` malformed request, `3` not found, `1` unexpected. Every error
187
- carries a `suggestion` naming the command that resolves it, and `adiff describe` returns the whole
188
- catalog as JSON so a caller can discover the rest.
189
-
190
- Project docs live in `.agents/`. `AGENTS.md` covers making a change, `ARCHITECTURE.md` how the code
191
- is laid out.
67
+ adiff is alpha, and one person's tool. Every release goes out under the `alpha` tag. Project docs
68
+ live in `.agents/`: `AGENTS.md` covers making a change, `ARCHITECTURE.md` how the code is laid out.
192
69
 
193
70
  ## License
194
71
 
package/dist/main.js CHANGED
@@ -5,9 +5,9 @@ import { text } from "node:stream/consumers";
5
5
  import { dirname, join, resolve } from "node:path";
6
6
  import { execFile, spawn } from "node:child_process";
7
7
  import { promisify } from "node:util";
8
- import { existsSync, mkdirSync, readFileSync, realpathSync, watch } from "node:fs";
8
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, realpathSync, watch } from "node:fs";
9
9
  import { fileURLToPath } from "node:url";
10
- import { ASCIIFontRenderable, BoxRenderable, CodeRenderable, LineNumberRenderable, RGBA, SelectRenderable, StyledText, SyntaxStyle, TextRenderable, bg, createCliRenderer, decodePasteBytes, fg, getTreeSitterClient, pathToFiletype, stripAnsiSequences, t } from "@opentui/core";
10
+ import { ASCIIFontRenderable, BoxRenderable, CodeRenderable, LineNumberRenderable, RGBA, StyledText, SyntaxStyle, TextRenderable, bg, createCliRenderer, decodePasteBytes, fg, getTreeSitterClient, pathToFiletype, stripAnsiSequences, t } from "@opentui/core";
11
11
  //#region \0rolldown/runtime.js
12
12
  var __defProp = Object.defineProperty;
13
13
  var __esmMin = (fn, res, err) => () => {
@@ -8674,7 +8674,10 @@ var init_schema = __esmMin((() => {
8674
8674
  base: optionalKey(String$1),
8675
8675
  read: optionalKey(Record(String$1, Int))
8676
8676
  });
8677
- Settings = Struct({ wrap: optionalKey(Boolean) });
8677
+ Settings = Struct({
8678
+ wrap: optionalKey(Boolean),
8679
+ sticky: optionalKey(Boolean)
8680
+ });
8678
8681
  UpgradeCheck = Struct({
8679
8682
  note: optionalKey(String$1),
8680
8683
  checkedAt: optionalKey(String$1),
@@ -9046,7 +9049,7 @@ var init_error$1 = __esmMin((() => {
9046
9049
  }));
9047
9050
  //#endregion
9048
9051
  //#region src/cli/commands.ts
9049
- var CONTEXT, WHOLE_FILE$1, POLL, AUTO, askedFor, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, rowsCovering, waitingOn, listBranches, blobOf, toggleVouch, reviewProgress, bodyOf, sentOf, listSent, submitComment, listPatches, flatten, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, saveWrap, setBase, clearBase, markRead;
9052
+ var CONTEXT, WHOLE_FILE$1, POLL, AUTO, askedFor, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, rowsCovering, waitingOn, listBranches, blobOf, toggleVouch, reviewProgress, bodyOf, sentOf, listSent, submitComment, listPatches, flatten, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, saveWrap, saveSticky, setBase, clearBase, markRead;
9050
9053
  var init_commands = __esmMin((() => {
9051
9054
  init_dist();
9052
9055
  init_patch();
@@ -9345,6 +9348,14 @@ var init_commands = __esmMin((() => {
9345
9348
  wrap
9346
9349
  });
9347
9350
  });
9351
+ saveSticky = fn("Cli.saveSticky")(function* (sticky) {
9352
+ const store = yield* Store;
9353
+ const current = yield* store.settings;
9354
+ yield* store.saveSettings({
9355
+ ...current,
9356
+ sticky
9357
+ });
9358
+ });
9348
9359
  setBase = fn("Cli.setBase")(function* (repo, branch, base) {
9349
9360
  const store = yield* Store;
9350
9361
  const based = yield* baseFor(repo, branch, base);
@@ -9650,7 +9661,7 @@ var init_pane = __esmMin((() => {
9650
9661
  init_commands();
9651
9662
  init_init();
9652
9663
  init_pane();
9653
- var version$1 = "0.1.0-alpha.71";
9664
+ var version$1 = "0.1.0-alpha.73";
9654
9665
  //#endregion
9655
9666
  //#region src/cli/upgrade.ts
9656
9667
  var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, runUpgrade, statusOf$1, sayFound, sayDone, attempted, REFRESH_MS, refreshSkills, updatedIn, sayRefreshed, upgradeReport;
@@ -11383,7 +11394,7 @@ var init_tree = __esmMin((() => {
11383
11394
  return node.children.reduce((total, child) => total + filesUnder(tree, child), 0);
11384
11395
  };
11385
11396
  crowdedDirectories = (tree, limit) => tree.nodes.filter((node) => node.kind === "directory" && directFiles(tree, node.id) > limit).map((node) => node.path);
11386
- })), nothingReviewed, initialState, TREE_MAX, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, NO_NOTE, noteRows$1, proseRow, proseRows$1, titleRows, clipEnd, FILE_LEAD, fileRows, layerRows, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, kept, treeOf, reviewedCountIn, treeRows, crowdedOf, foldersOfFile, isReviewed, treeStart, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, caretAt, drafted, WORD, wordLeft, wordRight, caretByWord, lineStart, lineEnd, caretToEdge, composeTarget, selectedLines, KEYWORDS, NAME, longestName$1, searchTerm, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersIn, newerOf, sectionOf, sentEntry, panelEntries, panelEntry, threadChosen, spokenSince, hunkStarts, changeAround, nextUnreviewed, reviewedCount, fileOrder, layerFile, selectionRange;
11397
+ })), nothingReviewed, initialState, TREE_MAX, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, NO_NOTE, noteRows$1, proseRow, proseRows$1, titleRows, clipEnd, FILE_LEAD, fileRows, layerRows, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, kept, treeOf, reviewedCountIn, treeRows, crowdedOf, foldersOfFile, isReviewed, treeStart, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, caretAt, drafted, WORD, wordLeft, wordRight, caretByWord, lineStart, lineEnd, caretToEdge, composeTarget, pickedText, selectedLines, KEYWORDS, NAME, longestName$1, searchTerm, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersIn, newerOf, sectionOf, sentEntry, panelEntries, panelIndexOf, panelEntry, threadChosen, spokenSince, hunkStarts, changeAround, nextUnreviewed, reviewedCount, fileOrder, layerFile, selectionRange;
11387
11398
  var init_model = __esmMin((() => {
11388
11399
  init_dist();
11389
11400
  init_patch();
@@ -11398,6 +11409,7 @@ var init_model = __esmMin((() => {
11398
11409
  reportFull: true,
11399
11410
  hideReviewed: false,
11400
11411
  hideSettled: false,
11412
+ picked: void 0,
11401
11413
  newestFirst: true,
11402
11414
  tallest: 0,
11403
11415
  scroll: -1,
@@ -11436,6 +11448,7 @@ var init_model = __esmMin((() => {
11436
11448
  focus: "diff",
11437
11449
  navOpen: true,
11438
11450
  wrap: false,
11451
+ sticky: true,
11439
11452
  pan: 0,
11440
11453
  layers: [],
11441
11454
  layersStale: false,
@@ -11675,6 +11688,15 @@ var init_model = __esmMin((() => {
11675
11688
  });
11676
11689
  return span === "" ? `Comment on ${patch.path}` : `Comment on ${patch.path}:${span}`;
11677
11690
  };
11691
+ pickedText = (state) => {
11692
+ const picked = state.picked;
11693
+ const patch = selectedPatch(state);
11694
+ if (picked === void 0 || patch === void 0) return void 0;
11695
+ const text = patch.rows[picked.row]?.text;
11696
+ if (text === void 0) return void 0;
11697
+ const taken = text.slice(picked.from, picked.to);
11698
+ return taken.length === 0 ? void 0 : taken;
11699
+ };
11678
11700
  selectedLines = (state) => {
11679
11701
  const patch = selectedPatch(state);
11680
11702
  if (patch === void 0) return [];
@@ -11834,6 +11856,11 @@ var init_model = __esmMin((() => {
11834
11856
  };
11835
11857
  return [...ordered("with"), ...ordered("answered")];
11836
11858
  };
11859
+ panelIndexOf = (state, id) => {
11860
+ if (id === void 0) return state.panelIndex;
11861
+ const at = panelEntries(state).findIndex((entry) => entry.comment.id === id);
11862
+ return at === -1 ? state.panelIndex : at;
11863
+ };
11837
11864
  panelEntry = (state) => panelEntries(state)[state.panelIndex];
11838
11865
  threadChosen = (state) => {
11839
11866
  if (state.focus !== "review") return void 0;
@@ -12131,7 +12158,7 @@ var init_command = __esmMin((() => {
12131
12158
  panes: ["tree", "diff"],
12132
12159
  title: "Next file",
12133
12160
  category: "Files",
12134
- keys: ["]"],
12161
+ keys: ["]", "right"],
12135
12162
  screens: ["review"],
12136
12163
  hint: "file",
12137
12164
  rank: 1
@@ -12140,7 +12167,7 @@ var init_command = __esmMin((() => {
12140
12167
  action: "file.prev",
12141
12168
  title: "Previous file",
12142
12169
  category: "Files",
12143
- keys: ["["],
12170
+ keys: ["[", "left"],
12144
12171
  screens: ["review"]
12145
12172
  }),
12146
12173
  command({
@@ -12242,6 +12269,14 @@ var init_command = __esmMin((() => {
12242
12269
  keys: ["o"],
12243
12270
  screens: ["review"]
12244
12271
  }),
12272
+ command({
12273
+ action: "sticky.toggle",
12274
+ panes: ["diff"],
12275
+ title: "Show or hide the scope above the diff",
12276
+ category: "Reading",
12277
+ keys: ["S"],
12278
+ screens: ["review"]
12279
+ }),
12245
12280
  command({
12246
12281
  action: "wrap.toggle",
12247
12282
  title: "Wrap long lines",
@@ -12582,7 +12617,7 @@ var init_match = __esmMin((() => {
12582
12617
  }));
12583
12618
  //#endregion
12584
12619
  //#region src/tui/reduce.ts
12585
- var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, draggedTo, atRow, noneLeft, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, moveLayer, inRail, railScrolled, movePanel, layerDown, PANES, panesShown, focusStepped, togglePanel, packedAway, zoom, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, moveFile, selectHunk, swapEnds, atBranch, startSelection, openCompose, goBack, walkMatches, openPalette, openKeys, movePalette, paletteMatches, keyMatches, offered, paletteChoice, transitions, reduce, atFile, withContext, withFull, revealsAfter, gapOpened, panBy, withSent, withArrived, withColumns, withLayers, withPulls, withSilentForge, withBranches, withSource, withVouched, restoredTo, openedAt, withPatches, inserted, asksAQuery, typed, TAB_WIDTH, SPACE_CODE, ERASED_FROM, ERASED_TO, readable, legible, pasted, backspaced, cutBackTo, wordBackspaced, lineBackspaced, deleted, caretMoved, caretJumped, caretHomed, paletteMoved, paletteClosed, withWaiting, withMatches, withNoticeHere, withNotice;
12620
+ var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, draggedTo, pickedIn, atRow, noneLeft, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, moveLayer, inRail, railScrolled, movePanel, layerDown, PANES, panesShown, focusStepped, togglePanel, packedAway, zoom, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, moveFile, selectHunk, swapEnds, atBranch, startSelection, openCompose, goBack, walkMatches, openPalette, openKeys, movePalette, paletteMatches, keyMatches, offered, paletteChoice, transitions, reduce, atFile, withContext, withFull, revealsAfter, gapOpened, panBy, withSent, withArrived, withColumns, withLayers, withPulls, withSilentForge, withBranches, withSource, withVouched, restoredTo, openedAt, withPatches, inserted, asksAQuery, typed, TAB_WIDTH, SPACE_CODE, ERASED_FROM, ERASED_TO, readable, legible, pasted, backspaced, cutBackTo, wordBackspaced, lineBackspaced, deleted, caretMoved, caretJumped, caretHomed, paletteMoved, paletteClosed, withWaiting, withMatches, withNoticeHere, withNotice;
12586
12621
  var init_reduce = __esmMin((() => {
12587
12622
  init_dist();
12588
12623
  init_patch();
@@ -12593,7 +12628,11 @@ var init_reduce = __esmMin((() => {
12593
12628
  clamp = (value, low, high) => Math.max(low, Math.min(high, value));
12594
12629
  lastRow = (patch) => Math.max(0, (patch?.rows.length ?? 1) - 1);
12595
12630
  rowsIn = (state) => selectedPatch(state)?.rows.length ?? 0;
12596
- withCursorVisible = (state) => {
12631
+ withCursorVisible = (given) => {
12632
+ const state = given.picked === void 0 ? given : {
12633
+ ...given,
12634
+ picked: void 0
12635
+ };
12597
12636
  const height = Math.max(1, state.viewport);
12598
12637
  const highest = Math.max(0, rowsIn(state) - height);
12599
12638
  const top = state.cursor < state.top ? state.cursor : state.cursor >= state.top + height ? state.cursor - height + 1 : state.top;
@@ -12641,10 +12680,22 @@ var init_reduce = __esmMin((() => {
12641
12680
  };
12642
12681
  draggedTo = (state, from, to) => ({
12643
12682
  ...state,
12683
+ picked: void 0,
12644
12684
  selecting: true,
12645
12685
  anchorRow: clamp(from, 0, lastRow(selectedPatch(state))),
12646
12686
  cursor: clamp(to, 0, lastRow(selectedPatch(state)))
12647
12687
  });
12688
+ pickedIn = (state, row, from, to) => ({
12689
+ ...state,
12690
+ selecting: false,
12691
+ anchorRow: clamp(row, 0, lastRow(selectedPatch(state))),
12692
+ cursor: clamp(row, 0, lastRow(selectedPatch(state))),
12693
+ picked: {
12694
+ row,
12695
+ from: Math.min(from, to),
12696
+ to: Math.max(from, to)
12697
+ }
12698
+ });
12648
12699
  atRow = (state, row) => withCursorVisible({
12649
12700
  ...state,
12650
12701
  stop: 0,
@@ -12969,6 +13020,10 @@ var init_reduce = __esmMin((() => {
12969
13020
  wrap: !state.wrap,
12970
13021
  pan: 0
12971
13022
  }),
13023
+ "sticky.toggle": (state) => ({
13024
+ ...state,
13025
+ sticky: !state.sticky
13026
+ }),
12972
13027
  "pan.right": (state) => panned(state, PAN_STEP),
12973
13028
  "pan.left": (state) => panned(state, -8),
12974
13029
  "review.reload": (state) => state,
@@ -13423,6 +13478,7 @@ var init_theme = __esmMin((() => {
13423
13478
  "punctuation.bracket": { fg: inkFaint },
13424
13479
  "punctuation.delimiter": { fg: inkFaint },
13425
13480
  gap: { fg: inkFaint },
13481
+ picked: { bg: "#2b3854" },
13426
13482
  note: {
13427
13483
  fg: "#9aa7c7",
13428
13484
  italic: true
@@ -13438,7 +13494,7 @@ var init_theme = __esmMin((() => {
13438
13494
  }));
13439
13495
  //#endregion
13440
13496
  //#region src/tui/diffview.ts
13441
- var WASH, NOTE_MIN, ANSWER_MARK, OVERSCAN, SIGN_WIDTH, SCROLL_ROWS, PAN_COLUMNS, WAYS, notchesIn, wheelTo, SIGNS, numberFor, DiffView, startsOf, bareOf, keyOf, groupOf, isChrome, heldAt, sameLine, NO_SPANS, lineStarts, overLine, shifted, acrossLines, spansByLine, textAt, noteSpans, NOTE_PAINT, wrap, headOf, spokenLines, answerLines, noteLines, noteRows, proseRows, proseAt, notesAt, codeRow, rowsFor, layout, lineNumbers, BARE_SIGN, signFor, lineSigns, sideLineOf;
13497
+ var WASH, NOTE_MIN, ANSWER_MARK, OVERSCAN, SIGN_WIDTH, SCROLL_ROWS, PAN_COLUMNS, WAYS, notchesIn, takenOver, wheelTo, SIGNS, numberFor, DiffView, startsOf, bareOf, keyOf, groupOf, isChrome, alike, heldAt, sameLine, NO_SPANS, lineStarts, overLine, shifted, acrossLines, spansByLine, textAt, noteSpans, NOTE_PAINT, wrap, headOf, spokenLines, answerLines, noteLines, noteRows, proseRows, proseAt, notesAt, codeRow, rowsFor, layout, lineNumbers, BARE_SIGN, signFor, lineSigns, sideLineOf;
13442
13498
  var init_diffview = __esmMin((() => {
13443
13499
  init_dist();
13444
13500
  init_patch();
@@ -13479,9 +13535,14 @@ var init_diffview = __esmMin((() => {
13479
13535
  }
13480
13536
  };
13481
13537
  notchesIn = (event) => Math.max(1, event.scroll?.delta ?? 1);
13538
+ takenOver = (event) => {
13539
+ event.preventDefault?.();
13540
+ event.stopPropagation?.();
13541
+ };
13482
13542
  wheelTo = (event, handlers) => {
13483
13543
  const way = WAYS[event.scroll?.direction ?? ""];
13484
13544
  if (way === void 0) return;
13545
+ takenOver(event);
13485
13546
  const step = way.step * notchesIn(event);
13486
13547
  if (way.across || event.modifiers?.shift === true) handlers.pan(step * PAN_COLUMNS);
13487
13548
  else handlers.scroll(step * SCROLL_ROWS);
@@ -13520,6 +13581,7 @@ var init_diffview = __esmMin((() => {
13520
13581
  fitted = 1;
13521
13582
  wrapped = false;
13522
13583
  held = 0;
13584
+ picked;
13523
13585
  constructor(renderer) {
13524
13586
  this.code = new CodeRenderable(renderer, {
13525
13587
  id: "diff-code",
@@ -13598,12 +13660,12 @@ var init_diffview = __esmMin((() => {
13598
13660
  return this.numbers;
13599
13661
  }
13600
13662
  listenTo(handlers) {
13601
- this.numbers.onMouseScroll = (event) => wheelTo(event, handlers);
13602
13663
  for (const target of [this.numbers, this.code]) {
13603
- target.onMouseDown = (event) => handlers.down(event.y);
13604
- target.onMouseDrag = (event) => handlers.drag(event.y);
13605
- target.onMouseDragEnd = (event) => handlers.dragEnd(event.y);
13606
- target.onMouseUp = (event) => handlers.dragEnd(event.y);
13664
+ target.onMouseScroll = (event) => wheelTo(event, handlers);
13665
+ target.onMouseDown = (event) => handlers.down(event.y, event.x);
13666
+ target.onMouseDrag = (event) => handlers.drag(event.y, event.x);
13667
+ target.onMouseDragEnd = (event) => handlers.dragEnd(event.y, event.x);
13668
+ target.onMouseUp = (event) => handlers.dragEnd(event.y, event.x);
13607
13669
  }
13608
13670
  }
13609
13671
  refresh() {
@@ -13694,8 +13756,27 @@ var init_diffview = __esmMin((() => {
13694
13756
  hidden() {
13695
13757
  return Math.max(0, this.code.x - this.numbers.x) + SIGN_WIDTH;
13696
13758
  }
13759
+ pickedSpans() {
13760
+ const picked = this.picked;
13761
+ if (picked === void 0) return NO_SPANS;
13762
+ let at = 0;
13763
+ for (const entry of this.display) {
13764
+ const width = heldAt(entry, this.held).length;
13765
+ if (entry.row === picked.row && entry.stop === 0 && !isChrome(entry)) {
13766
+ const from = Math.min(picked.from, width);
13767
+ const to = Math.min(picked.to, width);
13768
+ return from >= to ? NO_SPANS : [[
13769
+ at + from,
13770
+ at + to,
13771
+ "picked"
13772
+ ]];
13773
+ }
13774
+ at += width + 1;
13775
+ }
13776
+ return NO_SPANS;
13777
+ }
13697
13778
  feed() {
13698
- const spans = noteSpans(this.display, this.held);
13779
+ const spans = [...noteSpans(this.display, this.held), ...this.pickedSpans()];
13699
13780
  this.code.content = textAt(this.display, this.held, this.hidden());
13700
13781
  this.code.onHighlight = (highlights) => {
13701
13782
  return [...(this.ownSpans() ?? highlights).filter((highlight) => !spans.some(([from, to]) => highlight[0] < to && highlight[1] > from)), ...spans];
@@ -13795,6 +13876,15 @@ var init_diffview = __esmMin((() => {
13795
13876
  screenRowOf(row) {
13796
13877
  return this.visualOfRow(row);
13797
13878
  }
13879
+ pick(picked) {
13880
+ if (alike(this.picked, picked)) return;
13881
+ this.picked = picked;
13882
+ this.feed();
13883
+ this.code.requestRender();
13884
+ }
13885
+ columnAt(x) {
13886
+ return Math.max(0, x - this.code.x + this.held);
13887
+ }
13798
13888
  blockAt(row, stop) {
13799
13889
  const first = this.display.findIndex((entry) => entry.row === row && entry.stop === stop);
13800
13890
  if (first === -1) return {
@@ -13857,6 +13947,7 @@ var init_diffview = __esmMin((() => {
13857
13947
  return entry.sent ? "note.sent" : "note";
13858
13948
  };
13859
13949
  isChrome = (entry) => entry.comment || entry.gap || entry.prose;
13950
+ alike = (left, right) => left === right || left !== void 0 && right !== void 0 && left.row === right.row && left.from === right.from && left.to === right.to;
13860
13951
  heldAt = (entry, pan) => isChrome(entry) && pan > 0 ? `${" ".repeat(pan)}${entry.text}` : entry.text;
13861
13952
  sameLine = (source, row) => source !== void 0 && source.trimEnd() === row.trimEnd();
13862
13953
  NO_SPANS = [];
@@ -14038,7 +14129,7 @@ var init_diffview = __esmMin((() => {
14038
14129
  }));
14039
14130
  //#endregion
14040
14131
  //#region src/tui/render.ts
14041
- var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, COMPOSE_PAD, COMPOSE_MIN_TEXT, reportActions, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_TAIL, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, SELECTION, CURSOR, ACCENT, GAP_PAINT, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, makePaletteParts, makeChoices, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, makeComposeParts, makeCompose, clip, clipHead, clipMiddle, clipPath, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, contextLabel, nameRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, headerParts, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, STEP_NUMBER, STEP_LEAD, NOTE_LEAD, STEP_GAP, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerFold, layerHead, layerText, layerPaint, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, panelMark, panelWhere, panelBody, panelPair, panelSection, PULL_HINT, panelText, Screen;
14132
+ var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, COMPOSE_PAD, COMPOSE_MIN_TEXT, reportActions, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_TAIL, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, SELECTION, CURSOR, ACCENT, GAP_PAINT, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, makePaletteParts, makeChoices, LIST_LEAD, windowed, listText, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, makeComposeParts, makeCompose, clip, clipHead, clipMiddle, clipPath, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, contextLabel, nameRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, headerParts, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, STEP_NUMBER, STEP_LEAD, NOTE_LEAD, STEP_GAP, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerFold, layerHead, layerText, layerPaint, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, panelMark, panelWhere, panelBody, panelPair, panelSection, PULL_HINT, panelText, Screen;
14042
14133
  var init_render = __esmMin((() => {
14043
14134
  init_command();
14044
14135
  init_patch();
@@ -14059,7 +14150,7 @@ var init_render = __esmMin((() => {
14059
14150
  COMPOSE_PAD = 5;
14060
14151
  COMPOSE_MIN_TEXT = 8;
14061
14152
  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")}`;
14062
- actionsText = () => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^a")} ${fg(palette.muted)("add to review")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("comment now")}`;
14153
+ actionsText = () => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("send it")}`;
14063
14154
  SNIPPET_LINES = 4;
14064
14155
  PALETTE_KEY = 7;
14065
14156
  PALETTE_TITLE = 60;
@@ -14253,21 +14344,35 @@ var init_render = __esmMin((() => {
14253
14344
  choices
14254
14345
  };
14255
14346
  };
14256
- makeChoices = (renderer) => new SelectRenderable(renderer, {
14347
+ makeChoices = (renderer) => new TextRenderable(renderer, {
14257
14348
  id: "palette-choices",
14349
+ content: "",
14258
14350
  flexGrow: 1,
14259
- options: [],
14260
- showDescription: false,
14261
- showScrollIndicator: true,
14262
- showSelectionIndicator: true,
14263
- wrapSelection: false,
14264
- backgroundColor: palette.panel,
14265
- textColor: palette.ink,
14266
- descriptionColor: palette.faint,
14267
- selectedBackgroundColor: palette.selection,
14268
- selectedTextColor: palette.ink,
14269
- selectedDescriptionColor: palette.ink
14351
+ fg: palette.ink,
14352
+ selectable: true
14270
14353
  });
14354
+ LIST_LEAD = 2;
14355
+ windowed = (rows, at, height) => {
14356
+ if (rows.length <= height) return {
14357
+ rows,
14358
+ from: 0
14359
+ };
14360
+ const last = rows.length - height;
14361
+ const from = Math.max(0, Math.min(last, at - Math.floor(height / 2)));
14362
+ return {
14363
+ rows: rows.slice(from, from + height),
14364
+ from
14365
+ };
14366
+ };
14367
+ listText = (rows, at, height) => {
14368
+ const shown = windowed(rows, at, Math.max(1, height));
14369
+ const drawn = shown.rows.map((row, index) => {
14370
+ const here = shown.from + index === at;
14371
+ const text = `${here ? "▶ " : " "}${row}`.padEnd(LIST_LEAD);
14372
+ return here ? bg(palette.selection)(fg(palette.ink)(`${text}\n`)) : fg(palette.ink)(`${text}\n`);
14373
+ });
14374
+ return new StyledText(drawn);
14375
+ };
14271
14376
  stack = (parent, children) => {
14272
14377
  for (const child of children) parent.add(child);
14273
14378
  };
@@ -14583,12 +14688,16 @@ var init_render = __esmMin((() => {
14583
14688
  panelBody = (entry) => entry.comment.body.split("\n").find((line) => line.trim().length > 0) ?? "";
14584
14689
  panelPair = (state, placed, room) => {
14585
14690
  const { entry } = placed;
14691
+ const lead = `${panelMark(state, placed.at)}${entry.fresh || entry.unread > 0 ? marks().comment : " "} `;
14692
+ const here = placed.at === state.panelIndex;
14586
14693
  return [{
14587
- text: `${`${panelMark(state, placed.at)}${entry.fresh || entry.unread > 0 ? marks().comment : " "} `}${panelWhere(entry, room - PANEL_LEAD)}`,
14588
- tone: palette.ink
14694
+ text: `${lead}${panelWhere(entry, room - PANEL_LEAD)}`,
14695
+ tone: palette.ink,
14696
+ here
14589
14697
  }, {
14590
14698
  text: ` ${clip(panelBody(entry), Math.max(4, room - PANEL_LEAD))}`,
14591
- tone: palette.muted
14699
+ tone: palette.muted,
14700
+ here
14592
14701
  }];
14593
14702
  };
14594
14703
  panelSection = (state, placed, section, room) => {
@@ -14625,7 +14734,10 @@ var init_render = __esmMin((() => {
14625
14734
  text: PANEL_EMPTY,
14626
14735
  tone: palette.muted
14627
14736
  }] : body;
14628
- return new StyledText([...banner, ...lines].map((line) => fg(line.tone)(`${line.text}\n`)));
14737
+ return new StyledText([...banner, ...lines].map((line) => {
14738
+ const drawn = fg(line.tone)(`${line.text.padEnd(room)}\n`);
14739
+ return line.here === true ? bg(palette.selection)(drawn) : drawn;
14740
+ }));
14629
14741
  };
14630
14742
  Screen = class {
14631
14743
  header;
@@ -14735,19 +14847,22 @@ var init_render = __esmMin((() => {
14735
14847
  this.wheelOnRail(this.listPane);
14736
14848
  this.wheelOnRail(this.list);
14737
14849
  this.view.listenTo({
14738
- scroll: (delta) => this.mouse?.onScroll(delta),
14850
+ scroll: (delta) => {
14851
+ this.dragFrom = void 0;
14852
+ this.mouse?.onScroll(delta);
14853
+ },
14739
14854
  pan: (delta) => this.mouse?.onPan(delta),
14740
- down: (y) => {
14741
- this.dragFrom = this.rowAtY(y);
14855
+ down: (y, x) => {
14856
+ this.dragFrom = this.spotAt(y, x);
14742
14857
  this.mouse?.onDrag(this.dragFrom, this.dragFrom, false);
14743
14858
  },
14744
- drag: (y) => {
14859
+ drag: (y, x) => {
14745
14860
  if (this.dragFrom === void 0) return;
14746
- this.mouse?.onDrag(this.dragFrom, this.rowAtY(y), false);
14861
+ this.mouse?.onDrag(this.dragFrom, this.spotAt(y, x), false);
14747
14862
  },
14748
- dragEnd: (y) => {
14863
+ dragEnd: (y, x) => {
14749
14864
  if (this.dragFrom === void 0) return;
14750
- this.mouse?.onDrag(this.dragFrom, this.rowAtY(y), true);
14865
+ this.mouse?.onDrag(this.dragFrom, this.spotAt(y, x), true);
14751
14866
  this.dragFrom = void 0;
14752
14867
  }
14753
14868
  });
@@ -14755,6 +14870,12 @@ var init_render = __esmMin((() => {
14755
14870
  rowAtY(y) {
14756
14871
  return this.view.rowAt(Math.max(0, y - this.view.screenTop() + this.lastTop));
14757
14872
  }
14873
+ spotAt(y, x) {
14874
+ return {
14875
+ row: this.rowAtY(y),
14876
+ column: this.view.columnAt(x)
14877
+ };
14878
+ }
14758
14879
  viewportRows() {
14759
14880
  const edges = this.diffPane.border === true ? PANE_EDGES : 0;
14760
14881
  const pane = this.diffPane.height - edges - STICKY_MAX;
@@ -14824,20 +14945,16 @@ var init_render = __esmMin((() => {
14824
14945
  if (state.screen !== "palette") {
14825
14946
  this.paletteQuery.content = "";
14826
14947
  this.paletteTitle.content = "";
14827
- this.paletteChoices.options = [];
14948
+ this.paletteChoices.content = "";
14828
14949
  return;
14829
14950
  }
14830
14951
  const matches = paletteMatches(state);
14831
14952
  this.paletteTitle.content = matches.length === 0 ? "No command matches" : "Commands";
14832
14953
  this.paletteQuery.content = state.query.length === 0 ? "Type to filter…" : `${state.query}▏`;
14833
14954
  const room = panelWidth(this.renderer.width);
14834
- this.paletteChoices.options = matches.map((entry) => ({
14835
- name: commandRow(entry, room - MODAL_ROOM),
14836
- description: "",
14837
- value: entry.action
14838
- }));
14839
- this.paletteChoices.selectedIndex = Math.min(state.paletteIndex, Math.max(0, matches.length - 1));
14840
- this.palette.height = Math.min(panelRows(this.renderer.height, PANEL_QUARTER), matches.length + PALETTE_CHROME);
14955
+ const paletteRoom = Math.min(panelRows(this.renderer.height, PANEL_QUARTER), matches.length + PALETTE_CHROME);
14956
+ this.paletteChoices.content = listText(matches.map((entry) => commandRow(entry, room - MODAL_ROOM)), Math.min(state.paletteIndex, Math.max(0, matches.length - 1)), paletteRoom - PALETTE_CHROME);
14957
+ this.palette.height = paletteRoom;
14841
14958
  this.palette.width = room;
14842
14959
  this.palette.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room) / 2));
14843
14960
  this.palette.top = panelTop(this.renderer.height, PANEL_QUARTER);
@@ -14847,20 +14964,16 @@ var init_render = __esmMin((() => {
14847
14964
  if (state.screen !== "keys") {
14848
14965
  this.keysTitle.content = "";
14849
14966
  this.keysQuery.content = "";
14850
- this.keysChoices.options = [];
14967
+ this.keysChoices.content = "";
14851
14968
  return;
14852
14969
  }
14853
14970
  const rows = keyMatches(state);
14854
14971
  const room = panelWidth(this.renderer.width);
14855
14972
  this.keysTitle.content = rows.length === 0 ? "No key matches" : `Keys here, ${rows.length} of them`;
14856
14973
  this.keysQuery.content = state.query.length === 0 ? "Type to filter…" : `${state.query}▏`;
14857
- this.keysChoices.options = rows.map((entry) => ({
14858
- name: commandRow(entry, room - MODAL_ROOM),
14859
- description: "",
14860
- value: entry.action
14861
- }));
14862
- this.keysChoices.selectedIndex = Math.min(state.paletteIndex, Math.max(0, rows.length - 1));
14863
- this.keys.height = Math.min(panelRows(this.renderer.height, PANEL_QUARTER), rows.length + PENDING_CHROME);
14974
+ const keysRoom = Math.min(panelRows(this.renderer.height, PANEL_QUARTER), rows.length + PENDING_CHROME);
14975
+ this.keysChoices.content = listText(rows.map((entry) => commandRow(entry, room - MODAL_ROOM)), Math.min(state.paletteIndex, Math.max(0, rows.length - 1)), keysRoom - PENDING_CHROME);
14976
+ this.keys.height = keysRoom;
14864
14977
  this.keys.width = room;
14865
14978
  this.keys.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room) / 2));
14866
14979
  this.keys.top = panelTop(this.renderer.height, PANEL_QUARTER);
@@ -14911,7 +15024,10 @@ var init_render = __esmMin((() => {
14911
15024
  const pane = this.paneRoom();
14912
15025
  const whole = treeWindow(state, room);
14913
15026
  const window = whole.more === 0 ? whole : treeWindow(state, Math.max(1, room - 1));
14914
- const rows = window.rows.flatMap((row) => [fg(row.kind === "file" ? palette.ink : palette.muted)(`${treeLine(state, row, pane)}\n`)]);
15027
+ const rows = window.rows.flatMap((row) => {
15028
+ const drawn = fg(row.kind === "file" ? palette.ink : palette.muted)(`${treeLine(state, row, pane)}\n`);
15029
+ return [row.fileIndex === state.patchIndex ? bg(palette.selection)(drawn) : drawn];
15030
+ });
14915
15031
  const more = window.more > 0 ? [fg(palette.faint)(` … ${window.more} more`)] : [];
14916
15032
  return new StyledText([...rows, ...more]);
14917
15033
  }
@@ -14942,13 +15058,16 @@ var init_render = __esmMin((() => {
14942
15058
  this.view.setWrap(state.wrap);
14943
15059
  this.view.setPan(state.pan);
14944
15060
  this.view.show(patch, notesFor(state, patch.path), gapRowSet(shown), proseFor(state, patch.path));
14945
- this.view.fit(this.diffRows());
14946
- const height = this.view.rows();
14947
- const top = this.view.scrollTo(state.top, state.cursor, state.scroll);
14948
- this.lastTop = top;
14949
- this.paintSticky(state, this.view.rowAt(top));
14950
- this.view.paint(this.linePaint(state), top, height);
14951
- this.paintGutter(state, top, height);
15061
+ this.view.pick(state.picked);
15062
+ if (!takesText(state.screen)) {
15063
+ this.view.fit(this.diffRows());
15064
+ this.lastTop = this.view.scrollTo(state.top, state.cursor, state.scroll);
15065
+ if (state.sticky) this.paintSticky(state, this.view.rowAt(this.lastTop));
15066
+ else this.view.pin([]);
15067
+ }
15068
+ const top = this.lastTop;
15069
+ this.view.paint(this.linePaint(state), top, this.view.rows());
15070
+ this.paintGutter(state, top, this.view.rows());
14952
15071
  }
14953
15072
  assemble(renderer) {
14954
15073
  this.diffScroll.add(this.view.node());
@@ -15099,18 +15218,15 @@ var init_render = __esmMin((() => {
15099
15218
  if (state.screen !== "search") {
15100
15219
  this.foundTitle.content = "";
15101
15220
  this.foundPeek.content = "";
15102
- this.foundChoices.options = [];
15221
+ this.foundChoices.content = "";
15103
15222
  return;
15104
15223
  }
15105
15224
  const room = panelWidth(this.renderer.width);
15106
15225
  const here = matchHere(state);
15107
15226
  this.foundTitle.content = `${state.term} · ${state.matches.length} elsewhere`;
15108
- this.foundChoices.options = state.matches.map((match) => ({
15109
- name: clip(`${match.changed ? marks().comment : " "} ${match.path}:${match.line} ${match.text}`, Math.max(1, room - MODAL_ROOM)),
15110
- description: "",
15111
- value: match.path
15112
- }));
15113
- this.foundChoices.selectedIndex = state.matchIndex;
15227
+ const peekHigh = here?.around.length ?? 0;
15228
+ const foundRoom = Math.min(panelRows(this.renderer.height, PANEL_FIFTH), state.matches.length + peekHigh + PALETTE_CHROME);
15229
+ this.foundChoices.content = listText(state.matches.map((match) => clip(`${match.changed ? marks().comment : " "} ${match.path}:${match.line} ${match.text}`, Math.max(1, room - MODAL_ROOM))), state.matchIndex, Math.max(1, foundRoom - peekHigh - PALETTE_CHROME));
15114
15230
  this.foundPeek.content = (here?.around ?? []).map((line) => clip(line, Math.max(1, room - MODAL_ROOM))).join("\n");
15115
15231
  const peekRows = here?.around.length ?? 0;
15116
15232
  this.foundPeek.height = peekRows;
@@ -15421,6 +15537,7 @@ var init_app = __esmMin((() => {
15421
15537
  sessionPath;
15422
15538
  remembered = "";
15423
15539
  wrapKept = false;
15540
+ stickyKept = true;
15424
15541
  keys = [];
15425
15542
  trail = [];
15426
15543
  began = Date.now();
@@ -15435,6 +15552,7 @@ var init_app = __esmMin((() => {
15435
15552
  this.noticeMs = options.noticeMs ?? 2200;
15436
15553
  this.sessionPath = options.sessionPath;
15437
15554
  this.wrapKept = options.wrap === true;
15555
+ this.stickyKept = options.sticky !== false;
15438
15556
  this.held = options.state;
15439
15557
  this.display = options.display;
15440
15558
  this.painting = options.painting;
@@ -15447,6 +15565,7 @@ var init_app = __esmMin((() => {
15447
15565
  onChip: (key) => this.dispatchTask(this.onKey(asKey(key))),
15448
15566
  onRail: (delta) => this.dispatchTask(this.rolled(delta))
15449
15567
  }));
15568
+ renderer.on("selection", () => this.copyDragged());
15450
15569
  renderer.keyInput.on("keypress", (key) => this.dispatch(key));
15451
15570
  renderer.keyInput.on("paste", (event) => this.dispatchPaste(event));
15452
15571
  renderer.on("destroy", () => this.stopWatching());
@@ -15528,6 +15647,11 @@ var init_app = __esmMin((() => {
15528
15647
  this.wrapKept = next.wrap;
15529
15648
  this.dispatchTask(asVoid(saveWrap(next.wrap)));
15530
15649
  }
15650
+ rememberSticky(next) {
15651
+ if (next.sticky === this.stickyKept) return;
15652
+ this.stickyKept = next.sticky;
15653
+ this.dispatchTask(asVoid(saveSticky(next.sticky)));
15654
+ }
15531
15655
  rememberPlace(next) {
15532
15656
  if (this.sessionPath === void 0 || next.screen !== "review") return;
15533
15657
  const session = sessionOf(next);
@@ -15537,6 +15661,7 @@ var init_app = __esmMin((() => {
15537
15661
  runFork(writeSession(this.sessionPath, session));
15538
15662
  }
15539
15663
  dispatch(key) {
15664
+ if (this.renderer.hasSelection) this.renderer.clearSelection();
15540
15665
  offerUnsafe(this.intents, Intent.Key({ key }));
15541
15666
  }
15542
15667
  dispatchPaste(event) {
@@ -15649,6 +15774,7 @@ var init_app = __esmMin((() => {
15649
15774
  if (appeared) this.recordNotice(next.notice);
15650
15775
  this.rememberPlace(next);
15651
15776
  this.rememberWrap(next);
15777
+ this.rememberSticky(next);
15652
15778
  this.write(next);
15653
15779
  if (appeared) this.fade();
15654
15780
  }
@@ -15820,8 +15946,23 @@ var init_app = __esmMin((() => {
15820
15946
  });
15821
15947
  }
15822
15948
  dragged(from, to, done) {
15823
- this.commit(draggedTo(this.measured(), from, to));
15824
- if (done && from !== to) this.copySelection(true);
15949
+ const along = from.row === to.row && from.column !== to.column;
15950
+ const held = this.measured();
15951
+ this.commit(along ? pickedIn(held, from.row, from.column, to.column) : draggedTo(held, from.row, to.row));
15952
+ if (done && (along || from.row !== to.row)) this.copySelection(true);
15953
+ }
15954
+ copyDragged() {
15955
+ const taken = this.renderer.getSelection()?.getSelectedText() ?? "";
15956
+ const where = process.env["ADIFF_TRACE"];
15957
+ if (where !== void 0) {
15958
+ const holder = this.renderer.getSelectionContainer()?.id ?? "none";
15959
+ appendFileSync(where, `${this.state.screen} in=${holder} ${JSON.stringify(taken).slice(0, 70)}\n`);
15960
+ }
15961
+ if (taken.trim().length === 0) return;
15962
+ copyToClipboard(taken);
15963
+ const lines = taken.split("\n").length;
15964
+ const said = lines === 1 ? `${taken.length} characters copied` : `${lines} lines copied`;
15965
+ this.commit(withNoticeHere(this.state, said));
15825
15966
  }
15826
15967
  copySelection(keep) {
15827
15968
  const said = keep ? withNoticeHere : withNotice;
@@ -15831,6 +15972,12 @@ var init_app = __esmMin((() => {
15831
15972
  this.commit(said(this.state, "comment copied"));
15832
15973
  return;
15833
15974
  }
15975
+ const taken = pickedText(this.state);
15976
+ if (taken !== void 0) {
15977
+ copyToClipboard(taken);
15978
+ this.commit(said(this.state, `${taken.length} characters copied`));
15979
+ return;
15980
+ }
15834
15981
  const lines = this.state.selecting ? selectedLines(this.state) : lineUnder(this.state);
15835
15982
  if (lines.length === 0) {
15836
15983
  this.commit(withNoticeHere(this.state, "nothing to copy"));
@@ -15961,9 +16108,17 @@ var init_app = __esmMin((() => {
15961
16108
  ...this.state,
15962
16109
  opened: this.state.opened.filter((was) => was !== id)
15963
16110
  }, sent);
15964
- this.commit(withNotice(held, "settled"));
16111
+ this.commit(withNotice(this.staying(held, id), "settled"));
15965
16112
  });
15966
16113
  }
16114
+ staying(state, id) {
16115
+ const at = panelIndexOf(state, id);
16116
+ const last = Math.max(0, panelEntries(state).length - 1);
16117
+ return {
16118
+ ...state,
16119
+ panelIndex: Math.min(at, last)
16120
+ };
16121
+ }
15967
16122
  removeHere() {
15968
16123
  return gen({ self: this }, function* () {
15969
16124
  const branch = selectedBranch(this.state);
@@ -16226,6 +16381,7 @@ var init_app = __esmMin((() => {
16226
16381
  };
16227
16382
  turnedOver = (state) => ({
16228
16383
  ...state,
16384
+ picked: void 0,
16229
16385
  railScroll: -1,
16230
16386
  scroll: -1,
16231
16387
  selecting: false,
@@ -16249,12 +16405,15 @@ var init_app = __esmMin((() => {
16249
16405
  const asOpened = openingOn(branches, options.branch);
16250
16406
  const resume = isSome(asOpened) ? asOpened : sessionPath === void 0 ? none() : yield* readSession(sessionPath);
16251
16407
  const store = yield* Store;
16252
- const wrap = (yield* store.settings).wrap === true;
16408
+ const settings = yield* store.settings;
16409
+ const wrap = settings.wrap === true;
16410
+ const sticky = settings.sticky !== false;
16253
16411
  const display = yield* Display.pipe(provide(displayOn(renderer, repo)));
16254
16412
  const waiting = yield* upgradeHint;
16255
16413
  const state = yield* make({
16256
16414
  ...initialState(branches),
16257
16415
  wrap,
16416
+ sticky,
16258
16417
  waiting
16259
16418
  });
16260
16419
  const painting = yield* forkDetach(runForEach(changes(state), display.paint));
@@ -16269,6 +16428,7 @@ var init_app = __esmMin((() => {
16269
16428
  sessionPath,
16270
16429
  resume: getOrUndefined$1(resume),
16271
16430
  wrap,
16431
+ sticky,
16272
16432
  intents
16273
16433
  });
16274
16434
  app.watch(yield* forkDetach(app.consume()));
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.71",
26
+ "version": "0.1.0-alpha.73",
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": {