@eliya-oss/agent-diff 0.1.0-alpha.72 → 0.1.0-alpha.74

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.74
4
+
5
+ ### Patch Changes
6
+
7
+ - The box a comment is written in behaves like one: the caret is the cell it stands on rather than a character shifting the words, and the arrows move a line at a time through the wrap. `shift` with an arrow grows the selection to comment on.
8
+
9
+ ## 0.1.0-alpha.73
10
+
11
+ ### Patch Changes
12
+
13
+ - 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.
14
+
15
+ - 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.
16
+
3
17
  ## 0.1.0-alpha.72
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) => () => {
@@ -9661,7 +9661,7 @@ var init_pane = __esmMin((() => {
9661
9661
  init_commands();
9662
9662
  init_init();
9663
9663
  init_pane();
9664
- var version$1 = "0.1.0-alpha.72";
9664
+ var version$1 = "0.1.0-alpha.74";
9665
9665
  //#endregion
9666
9666
  //#region src/cli/upgrade.ts
9667
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;
@@ -11394,7 +11394,7 @@ var init_tree = __esmMin((() => {
11394
11394
  return node.children.reduce((total, child) => total + filesUnder(tree, child), 0);
11395
11395
  };
11396
11396
  crowdedDirectories = (tree, limit) => tree.nodes.filter((node) => node.kind === "directory" && directFiles(tree, node.id) > limit).map((node) => node.path);
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;
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, brokenAt, laidLine, laidDraft, caretRow, caretColumn, caretOn, caretAt, WORD, wordLeft, wordRight, caretByWord, lineStart, lineEnd, COMPOSE_BOX, COMPOSE_MARGIN, COMPOSE_PAD, COMPOSE_LEAST, composeBox, composeRoom$1, caretByRow, 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;
11398
11398
  var init_model = __esmMin((() => {
11399
11399
  init_dist();
11400
11400
  init_patch();
@@ -11652,11 +11652,49 @@ var init_model = __esmMin((() => {
11652
11652
  onNone: () => "-",
11653
11653
  onSome: (line) => String(line)
11654
11654
  });
11655
- caretAt = (state) => Math.max(0, Math.min(state.draft.length, state.caret));
11656
- drafted = (state) => {
11657
- const at = caretAt(state);
11658
- return `${state.draft.slice(0, at)}▌${state.draft.slice(at)}`;
11655
+ brokenAt = (text, room) => {
11656
+ const space = text.lastIndexOf(" ", room);
11657
+ return space > 0 ? space + 1 : room;
11658
+ };
11659
+ laidLine = (line, from, room) => {
11660
+ const rows = [];
11661
+ let at = 0;
11662
+ while (line.length - at > room) {
11663
+ const width = brokenAt(line.slice(at), room);
11664
+ rows.push({
11665
+ text: line.slice(at, at + width),
11666
+ from: from + at
11667
+ });
11668
+ at += width;
11669
+ }
11670
+ rows.push({
11671
+ text: line.slice(at),
11672
+ from: from + at
11673
+ });
11674
+ return rows;
11659
11675
  };
11676
+ laidDraft = (draft, room) => {
11677
+ const width = Math.max(1, room);
11678
+ const rows = [];
11679
+ let from = 0;
11680
+ for (const line of draft.split("\n")) {
11681
+ rows.push(...laidLine(line, from, width));
11682
+ from += line.length + 1;
11683
+ }
11684
+ return rows;
11685
+ };
11686
+ caretRow = (rows, caret) => {
11687
+ const at = rows.findIndex((row) => caret >= row.from && caret <= row.from + row.text.length);
11688
+ return at === -1 ? Math.max(0, rows.length - 1) : at;
11689
+ };
11690
+ caretColumn = (rows, caret) => caret - (rows[caretRow(rows, caret)]?.from ?? 0);
11691
+ caretOn = (rows, row, column) => {
11692
+ const held = rows[Math.max(0, Math.min(rows.length - 1, row))];
11693
+ if (held === void 0) return 0;
11694
+ const last = held.text.endsWith(" ") ? held.text.length - 1 : held.text.length;
11695
+ return held.from + Math.min(column, Math.max(0, last));
11696
+ };
11697
+ caretAt = (state) => Math.max(0, Math.min(state.draft.length, state.caret));
11660
11698
  WORD = /[\p{L}\p{N}_]/u;
11661
11699
  wordLeft = (draft, from) => {
11662
11700
  let at = from;
@@ -11676,6 +11714,20 @@ var init_model = __esmMin((() => {
11676
11714
  const found = draft.indexOf("\n", at);
11677
11715
  return found === -1 ? draft.length : found;
11678
11716
  };
11717
+ COMPOSE_BOX = 72;
11718
+ COMPOSE_MARGIN = 4;
11719
+ COMPOSE_PAD = 5;
11720
+ COMPOSE_LEAST = 8;
11721
+ composeBox = (columns) => Math.max(0, Math.min(COMPOSE_BOX, columns - COMPOSE_MARGIN));
11722
+ composeRoom$1 = (columns) => Math.max(COMPOSE_LEAST, composeBox(columns) - COMPOSE_PAD);
11723
+ caretByRow = (state, delta) => {
11724
+ const rows = laidDraft(state.draft, composeRoom$1(state.columns));
11725
+ const at = caretAt(state);
11726
+ const wanted = caretRow(rows, at) + delta;
11727
+ if (wanted < 0) return 0;
11728
+ if (wanted >= rows.length) return state.draft.length;
11729
+ return caretOn(rows, wanted, caretColumn(rows, at));
11730
+ };
11679
11731
  caretToEdge = (state, edge) => edge === "start" ? lineStart(state.draft, caretAt(state)) : lineEnd(state.draft, caretAt(state));
11680
11732
  composeTarget = (state) => {
11681
11733
  const patch = selectedPatch(state);
@@ -12158,7 +12210,7 @@ var init_command = __esmMin((() => {
12158
12210
  panes: ["tree", "diff"],
12159
12211
  title: "Next file",
12160
12212
  category: "Files",
12161
- keys: ["]"],
12213
+ keys: ["]", "right"],
12162
12214
  screens: ["review"],
12163
12215
  hint: "file",
12164
12216
  rank: 1
@@ -12167,7 +12219,7 @@ var init_command = __esmMin((() => {
12167
12219
  action: "file.prev",
12168
12220
  title: "Previous file",
12169
12221
  category: "Files",
12170
- keys: ["["],
12222
+ keys: ["[", "left"],
12171
12223
  screens: ["review"]
12172
12224
  }),
12173
12225
  command({
@@ -12214,6 +12266,24 @@ var init_command = __esmMin((() => {
12214
12266
  keys: ["G"],
12215
12267
  screens: ["branches"]
12216
12268
  }),
12269
+ command({
12270
+ action: "select.grow",
12271
+ panes: ["diff"],
12272
+ title: "Take the line below into the selection",
12273
+ category: "Selecting",
12274
+ keys: ["shift+down"],
12275
+ screens: ["review"],
12276
+ listed: false
12277
+ }),
12278
+ command({
12279
+ action: "select.shrink",
12280
+ panes: ["diff"],
12281
+ title: "Take the line above into the selection",
12282
+ category: "Selecting",
12283
+ keys: ["shift+up"],
12284
+ screens: ["review"],
12285
+ listed: false
12286
+ }),
12217
12287
  command({
12218
12288
  action: "select.hunk",
12219
12289
  category: "Selecting",
@@ -12617,7 +12687,7 @@ var init_match = __esmMin((() => {
12617
12687
  }));
12618
12688
  //#endregion
12619
12689
  //#region src/tui/reduce.ts
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;
12690
+ 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, grownBy, 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, caretRowed, caretEnded, caretHomed, paletteMoved, paletteClosed, withWaiting, withMatches, withNoticeHere, withNotice;
12621
12691
  var init_reduce = __esmMin((() => {
12622
12692
  init_dist();
12623
12693
  init_patch();
@@ -12892,6 +12962,18 @@ var init_reduce = __esmMin((() => {
12892
12962
  ...state,
12893
12963
  branchIndex: clamp(at, 0, Math.max(0, state.branches.length - 1))
12894
12964
  });
12965
+ grownBy = (state, delta) => {
12966
+ const held = state.selecting ? state : {
12967
+ ...state,
12968
+ selecting: true,
12969
+ anchorRow: state.cursor
12970
+ };
12971
+ return withCursorVisible({
12972
+ ...held,
12973
+ stop: 0,
12974
+ cursor: clamp(held.cursor + delta, 0, lastRow(selectedPatch(state)))
12975
+ });
12976
+ };
12895
12977
  startSelection = (state) => ({
12896
12978
  ...state,
12897
12979
  selecting: true,
@@ -12998,6 +13080,8 @@ var init_reduce = __esmMin((() => {
12998
13080
  "file.next": (state) => moveFile(state, 1),
12999
13081
  "file.prev": (state) => moveFile(state, -1),
13000
13082
  "select.start": startSelection,
13083
+ "select.grow": (state) => grownBy(state, 1),
13084
+ "select.shrink": (state) => grownBy(state, -1),
13001
13085
  "select.hunk": selectHunk,
13002
13086
  "select.swap": swapEnds,
13003
13087
  "compose.open": openCompose,
@@ -13302,6 +13386,14 @@ var init_reduce = __esmMin((() => {
13302
13386
  ...state,
13303
13387
  caret: caretByWord(state, delta)
13304
13388
  });
13389
+ caretRowed = (state, delta) => ({
13390
+ ...state,
13391
+ caret: caretByRow(state, delta)
13392
+ });
13393
+ caretEnded = (state, edge) => ({
13394
+ ...state,
13395
+ caret: edge === "start" ? 0 : state.draft.length
13396
+ });
13305
13397
  caretHomed = (state, edge) => ({
13306
13398
  ...state,
13307
13399
  caret: caretToEdge(state, edge)
@@ -14129,7 +14221,7 @@ var init_diffview = __esmMin((() => {
14129
14221
  }));
14130
14222
  //#endregion
14131
14223
  //#region src/tui/render.ts
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, 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;
14224
+ var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, 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, CARET_ROOM, draftText, 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;
14133
14225
  var init_render = __esmMin((() => {
14134
14226
  init_command();
14135
14227
  init_patch();
@@ -14147,10 +14239,8 @@ var init_render = __esmMin((() => {
14147
14239
  MODAL_ROOM = 8;
14148
14240
  COMPOSE_CHROME = 3;
14149
14241
  COMPOSE_ACTION_ROWS = 2;
14150
- COMPOSE_PAD = 5;
14151
- COMPOSE_MIN_TEXT = 8;
14152
14242
  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")}`;
14153
- 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")}`;
14243
+ actionsText = () => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("send it")}`;
14154
14244
  SNIPPET_LINES = 4;
14155
14245
  PALETTE_KEY = 7;
14156
14246
  PALETTE_TITLE = 60;
@@ -14184,11 +14274,30 @@ var init_render = __esmMin((() => {
14184
14274
  panelWidth = (width) => modalWidth(width, shareOf(width, PALETTE_WIDTH));
14185
14275
  panelTop = (height, part) => Math.max(2, Math.floor(height / part));
14186
14276
  panelRows = (height, part) => Math.max(PANEL_FLOOR, height - panelTop(height, part) - PANEL_FOOT);
14187
- composeRoom = (width) => {
14188
- const box = modalWidth(width, COMPOSE_WIDTH);
14277
+ composeRoom = (width) => ({
14278
+ box: composeBox(width),
14279
+ text: composeRoom$1(width)
14280
+ });
14281
+ CARET_ROOM = 1;
14282
+ draftText = (state, room) => {
14283
+ const rows = laidDraft(state.draft, room);
14284
+ const at = caretAt(state);
14285
+ const here = caretRow(rows, at);
14286
+ const column = caretColumn(rows, at);
14189
14287
  return {
14190
- box,
14191
- text: Math.max(COMPOSE_MIN_TEXT, box - COMPOSE_PAD)
14288
+ rows: rows.flatMap((row, index) => {
14289
+ const tail = index === rows.length - 1 ? "" : "\n";
14290
+ if (index !== here) return [fg(palette.ink)(`${row.text}${tail}`)];
14291
+ const before = row.text.slice(0, column);
14292
+ const under = row.text.slice(column, column + CARET_ROOM);
14293
+ const after = row.text.slice(column + CARET_ROOM);
14294
+ return [
14295
+ fg(palette.ink)(before),
14296
+ bg(palette.ink)(fg(palette.panel)(under.length === 0 ? " " : under)),
14297
+ fg(palette.ink)(`${after}${tail}`)
14298
+ ];
14299
+ }),
14300
+ height: rows.length
14192
14301
  };
14193
14302
  };
14194
14303
  laidOut$1 = (lines, room) => lines.flatMap((line) => {
@@ -14344,21 +14453,35 @@ var init_render = __esmMin((() => {
14344
14453
  choices
14345
14454
  };
14346
14455
  };
14347
- makeChoices = (renderer) => new SelectRenderable(renderer, {
14456
+ makeChoices = (renderer) => new TextRenderable(renderer, {
14348
14457
  id: "palette-choices",
14458
+ content: "",
14349
14459
  flexGrow: 1,
14350
- options: [],
14351
- showDescription: false,
14352
- showScrollIndicator: true,
14353
- showSelectionIndicator: true,
14354
- wrapSelection: false,
14355
- backgroundColor: palette.panel,
14356
- textColor: palette.ink,
14357
- descriptionColor: palette.faint,
14358
- selectedBackgroundColor: palette.selection,
14359
- selectedTextColor: palette.ink,
14360
- selectedDescriptionColor: palette.ink
14460
+ fg: palette.ink,
14461
+ selectable: true
14361
14462
  });
14463
+ LIST_LEAD = 2;
14464
+ windowed = (rows, at, height) => {
14465
+ if (rows.length <= height) return {
14466
+ rows,
14467
+ from: 0
14468
+ };
14469
+ const last = rows.length - height;
14470
+ const from = Math.max(0, Math.min(last, at - Math.floor(height / 2)));
14471
+ return {
14472
+ rows: rows.slice(from, from + height),
14473
+ from
14474
+ };
14475
+ };
14476
+ listText = (rows, at, height) => {
14477
+ const shown = windowed(rows, at, Math.max(1, height));
14478
+ const drawn = shown.rows.map((row, index) => {
14479
+ const here = shown.from + index === at;
14480
+ const text = `${here ? "▶ " : " "}${row}`.padEnd(LIST_LEAD);
14481
+ return here ? bg(palette.selection)(fg(palette.ink)(`${text}\n`)) : fg(palette.ink)(`${text}\n`);
14482
+ });
14483
+ return new StyledText(drawn);
14484
+ };
14362
14485
  stack = (parent, children) => {
14363
14486
  for (const child of children) parent.add(child);
14364
14487
  };
@@ -14674,12 +14797,16 @@ var init_render = __esmMin((() => {
14674
14797
  panelBody = (entry) => entry.comment.body.split("\n").find((line) => line.trim().length > 0) ?? "";
14675
14798
  panelPair = (state, placed, room) => {
14676
14799
  const { entry } = placed;
14800
+ const lead = `${panelMark(state, placed.at)}${entry.fresh || entry.unread > 0 ? marks().comment : " "} `;
14801
+ const here = placed.at === state.panelIndex;
14677
14802
  return [{
14678
- text: `${`${panelMark(state, placed.at)}${entry.fresh || entry.unread > 0 ? marks().comment : " "} `}${panelWhere(entry, room - PANEL_LEAD)}`,
14679
- tone: palette.ink
14803
+ text: `${lead}${panelWhere(entry, room - PANEL_LEAD)}`,
14804
+ tone: palette.ink,
14805
+ here
14680
14806
  }, {
14681
14807
  text: ` ${clip(panelBody(entry), Math.max(4, room - PANEL_LEAD))}`,
14682
- tone: palette.muted
14808
+ tone: palette.muted,
14809
+ here
14683
14810
  }];
14684
14811
  };
14685
14812
  panelSection = (state, placed, section, room) => {
@@ -14716,7 +14843,10 @@ var init_render = __esmMin((() => {
14716
14843
  text: PANEL_EMPTY,
14717
14844
  tone: palette.muted
14718
14845
  }] : body;
14719
- return new StyledText([...banner, ...lines].map((line) => fg(line.tone)(`${line.text}\n`)));
14846
+ return new StyledText([...banner, ...lines].map((line) => {
14847
+ const drawn = fg(line.tone)(`${line.text.padEnd(room)}\n`);
14848
+ return line.here === true ? bg(palette.selection)(drawn) : drawn;
14849
+ }));
14720
14850
  };
14721
14851
  Screen = class {
14722
14852
  header;
@@ -14924,20 +15054,16 @@ var init_render = __esmMin((() => {
14924
15054
  if (state.screen !== "palette") {
14925
15055
  this.paletteQuery.content = "";
14926
15056
  this.paletteTitle.content = "";
14927
- this.paletteChoices.options = [];
15057
+ this.paletteChoices.content = "";
14928
15058
  return;
14929
15059
  }
14930
15060
  const matches = paletteMatches(state);
14931
15061
  this.paletteTitle.content = matches.length === 0 ? "No command matches" : "Commands";
14932
15062
  this.paletteQuery.content = state.query.length === 0 ? "Type to filter…" : `${state.query}▏`;
14933
15063
  const room = panelWidth(this.renderer.width);
14934
- this.paletteChoices.options = matches.map((entry) => ({
14935
- name: commandRow(entry, room - MODAL_ROOM),
14936
- description: "",
14937
- value: entry.action
14938
- }));
14939
- this.paletteChoices.selectedIndex = Math.min(state.paletteIndex, Math.max(0, matches.length - 1));
14940
- this.palette.height = Math.min(panelRows(this.renderer.height, PANEL_QUARTER), matches.length + PALETTE_CHROME);
15064
+ const paletteRoom = Math.min(panelRows(this.renderer.height, PANEL_QUARTER), matches.length + PALETTE_CHROME);
15065
+ 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);
15066
+ this.palette.height = paletteRoom;
14941
15067
  this.palette.width = room;
14942
15068
  this.palette.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room) / 2));
14943
15069
  this.palette.top = panelTop(this.renderer.height, PANEL_QUARTER);
@@ -14947,20 +15073,16 @@ var init_render = __esmMin((() => {
14947
15073
  if (state.screen !== "keys") {
14948
15074
  this.keysTitle.content = "";
14949
15075
  this.keysQuery.content = "";
14950
- this.keysChoices.options = [];
15076
+ this.keysChoices.content = "";
14951
15077
  return;
14952
15078
  }
14953
15079
  const rows = keyMatches(state);
14954
15080
  const room = panelWidth(this.renderer.width);
14955
15081
  this.keysTitle.content = rows.length === 0 ? "No key matches" : `Keys here, ${rows.length} of them`;
14956
15082
  this.keysQuery.content = state.query.length === 0 ? "Type to filter…" : `${state.query}▏`;
14957
- this.keysChoices.options = rows.map((entry) => ({
14958
- name: commandRow(entry, room - MODAL_ROOM),
14959
- description: "",
14960
- value: entry.action
14961
- }));
14962
- this.keysChoices.selectedIndex = Math.min(state.paletteIndex, Math.max(0, rows.length - 1));
14963
- this.keys.height = Math.min(panelRows(this.renderer.height, PANEL_QUARTER), rows.length + PENDING_CHROME);
15083
+ const keysRoom = Math.min(panelRows(this.renderer.height, PANEL_QUARTER), rows.length + PENDING_CHROME);
15084
+ 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);
15085
+ this.keys.height = keysRoom;
14964
15086
  this.keys.width = room;
14965
15087
  this.keys.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room) / 2));
14966
15088
  this.keys.top = panelTop(this.renderer.height, PANEL_QUARTER);
@@ -15011,7 +15133,10 @@ var init_render = __esmMin((() => {
15011
15133
  const pane = this.paneRoom();
15012
15134
  const whole = treeWindow(state, room);
15013
15135
  const window = whole.more === 0 ? whole : treeWindow(state, Math.max(1, room - 1));
15014
- const rows = window.rows.flatMap((row) => [fg(row.kind === "file" ? palette.ink : palette.muted)(`${treeLine(state, row, pane)}\n`)]);
15136
+ const rows = window.rows.flatMap((row) => {
15137
+ const drawn = fg(row.kind === "file" ? palette.ink : palette.muted)(`${treeLine(state, row, pane)}\n`);
15138
+ return [row.fileIndex === state.patchIndex ? bg(palette.selection)(drawn) : drawn];
15139
+ });
15015
15140
  const more = window.more > 0 ? [fg(palette.faint)(` … ${window.more} more`)] : [];
15016
15141
  return new StyledText([...rows, ...more]);
15017
15142
  }
@@ -15202,18 +15327,15 @@ var init_render = __esmMin((() => {
15202
15327
  if (state.screen !== "search") {
15203
15328
  this.foundTitle.content = "";
15204
15329
  this.foundPeek.content = "";
15205
- this.foundChoices.options = [];
15330
+ this.foundChoices.content = "";
15206
15331
  return;
15207
15332
  }
15208
15333
  const room = panelWidth(this.renderer.width);
15209
15334
  const here = matchHere(state);
15210
15335
  this.foundTitle.content = `${state.term} · ${state.matches.length} elsewhere`;
15211
- this.foundChoices.options = state.matches.map((match) => ({
15212
- name: clip(`${match.changed ? marks().comment : " "} ${match.path}:${match.line} ${match.text}`, Math.max(1, room - MODAL_ROOM)),
15213
- description: "",
15214
- value: match.path
15215
- }));
15216
- this.foundChoices.selectedIndex = state.matchIndex;
15336
+ const peekHigh = here?.around.length ?? 0;
15337
+ const foundRoom = Math.min(panelRows(this.renderer.height, PANEL_FIFTH), state.matches.length + peekHigh + PALETTE_CHROME);
15338
+ 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));
15217
15339
  this.foundPeek.content = (here?.around ?? []).map((line) => clip(line, Math.max(1, room - MODAL_ROOM))).join("\n");
15218
15340
  const peekRows = here?.around.length ?? 0;
15219
15341
  this.foundPeek.height = peekRows;
@@ -15226,15 +15348,13 @@ var init_render = __esmMin((() => {
15226
15348
  this.compose.visible = state.screen === "compose" || state.screen === "report";
15227
15349
  if (state.screen !== "report") return;
15228
15350
  const room = composeRoom(this.renderer.width);
15229
- const lines = laidOut$1([
15230
- state.reportFull ? "What went wrong? Everything on screen is attached for you." : "What went wrong? Only what you type is sent.",
15231
- "",
15232
- drafted(state)
15233
- ], room.text);
15351
+ const asked = state.reportFull ? "What went wrong? Everything on screen is attached for you." : "What went wrong? Only what you type is sent.";
15352
+ const written = draftText(state, room.text);
15353
+ const lead = laidOut$1([asked, ""], room.text);
15234
15354
  this.composeTitle.content = "Report a bug";
15235
- this.composeBody.content = lines.join("\n");
15355
+ this.composeBody.content = new StyledText([...lead.map((line) => fg(palette.muted)(`${line}\n`)), ...written.rows]);
15236
15356
  this.composeActions.content = reportActions(state.reportFull);
15237
- this.compose.height = lines.length + COMPOSE_ACTION_ROWS + COMPOSE_CHROME;
15357
+ this.compose.height = lead.length + written.height + COMPOSE_ACTION_ROWS + COMPOSE_CHROME;
15238
15358
  this.compose.width = room.box;
15239
15359
  this.compose.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room.box) / 2));
15240
15360
  this.compose.top = Math.max(2, Math.floor(this.renderer.height / 4));
@@ -15286,16 +15406,11 @@ var init_render = __esmMin((() => {
15286
15406
  const more = selectedLineCount(state) - snippet.length;
15287
15407
  const tail = more > 0 ? [` … ${more} more lines`] : [];
15288
15408
  const quoted = [...snippet, ...tail].map((line) => clip(line, room.text));
15289
- const written = laidOut$1(drafted(state).split("\n"), room.text);
15290
- const lines = [
15291
- ...quoted,
15292
- "",
15293
- ...written
15294
- ];
15409
+ const written = draftText(state, room.text);
15295
15410
  this.composeTitle.content = clip(composeTarget(state), room.text);
15296
- this.composeBody.content = lines.join("\n");
15411
+ this.composeBody.content = new StyledText([...[...quoted, ""].map((line) => fg(palette.muted)(`${line}\n`)), ...written.rows]);
15297
15412
  this.composeActions.content = actionsText();
15298
- const height = lines.length + COMPOSE_ACTION_ROWS + COMPOSE_CHROME;
15413
+ const height = quoted.length + 1 + written.height + COMPOSE_ACTION_ROWS + COMPOSE_CHROME;
15299
15414
  this.compose.height = height;
15300
15415
  this.compose.width = room.box;
15301
15416
  this.compose.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room.box) / 2));
@@ -15413,7 +15528,7 @@ var init_upgrade = __esmMin((() => {
15413
15528
  return due ? `adiff ${latest} is out · adiff upgrade` : "";
15414
15529
  }).pipe(withSpan("Tui.upgradeHint"));
15415
15530
  upgradeHint = worded.pipe(orElseSucceed(() => ""));
15416
- })), PRINTABLE, KEY_HISTORY, TRAIL_HISTORY, clockOf, momentOf, noticeOf, handOver, copyToClipboard, lineUnder, asKey, openedPull, byWord, WORD_STEP, caretSideways, caretFor, erasedBy, LISTENS, listens, laidOut, keyName, App, turnedOver, settledPath, openingOn, launch, told, untilDestroyed, runOn, runTui;
15531
+ })), PRINTABLE, KEY_HISTORY, TRAIL_HISTORY, clockOf, momentOf, noticeOf, handOver, copyToClipboard, lineUnder, asKey, openedPull, byWord, WORD_STEP, caretSideways, caretFor, erasedBy, LISTENS, listens, laidOut, ARROWS, keyName, App, turnedOver, settledPath, openingOn, launch, told, untilDestroyed, runOn, runTui;
15417
15532
  var init_app = __esmMin((() => {
15418
15533
  init_dist();
15419
15534
  init_report();
@@ -15478,7 +15593,7 @@ var init_app = __esmMin((() => {
15478
15593
  if (!opened) return "could not reach the pull request";
15479
15594
  return state.length === 0 ? "opened the pull request" : `opened the ${state} pull request`;
15480
15595
  };
15481
- byWord = (key) => key.option || key.meta || key.ctrl;
15596
+ byWord = (key) => key.option || key.ctrl;
15482
15597
  WORD_STEP = {
15483
15598
  b: -1,
15484
15599
  f: 1
@@ -15486,7 +15601,8 @@ var init_app = __esmMin((() => {
15486
15601
  caretSideways = (state, key) => {
15487
15602
  const step = key.name === "left" ? -1 : key.name === "right" ? 1 : 0;
15488
15603
  if (step === 0) return void 0;
15489
- return byWord(key) ? caretJumped(state, step) : caretMoved(state, step);
15604
+ if (key.meta) return caretHomed(state, step > 0 ? "end" : "start");
15605
+ return key.option || key.ctrl ? caretJumped(state, step) : caretMoved(state, step);
15490
15606
  };
15491
15607
  caretFor = (state, key) => {
15492
15608
  const sideways = caretSideways(state, key);
@@ -15504,8 +15620,14 @@ var init_app = __esmMin((() => {
15504
15620
  LISTENS = /* @__PURE__ */ new Set(["keys", "palette"]);
15505
15621
  listens = (screen) => LISTENS.has(screen);
15506
15622
  laidOut = (key) => key.baseCode === void 0 || key.name.length !== 1 ? key.name : String.fromCodePoint(key.baseCode);
15623
+ ARROWS = /* @__PURE__ */ new Set([
15624
+ "up",
15625
+ "down",
15626
+ "left",
15627
+ "right"
15628
+ ]);
15507
15629
  keyName = (key) => {
15508
- if (key.shift && key.name === "tab") return "shift+tab";
15630
+ if (key.shift && (key.name === "tab" || ARROWS.has(key.name))) return `shift+${key.name}`;
15509
15631
  const named = laidOut(key);
15510
15632
  const base = key.shift && named.length === 1 ? named.toUpperCase() : named;
15511
15633
  return key.ctrl ? `ctrl+${base}` : base;
@@ -15648,6 +15770,7 @@ var init_app = __esmMin((() => {
15648
15770
  runFork(writeSession(this.sessionPath, session));
15649
15771
  }
15650
15772
  dispatch(key) {
15773
+ if (this.renderer.hasSelection) this.renderer.clearSelection();
15651
15774
  offerUnsafe(this.intents, Intent.Key({ key }));
15652
15775
  }
15653
15776
  dispatchPaste(event) {
@@ -15879,17 +16002,19 @@ var init_app = __esmMin((() => {
15879
16002
  this.commit(erasedBy(this.state, key));
15880
16003
  return;
15881
16004
  }
15882
- if (key.name === "down") {
15883
- this.commit(paletteMoved(this.state, 1));
15884
- return;
15885
- }
15886
- if (key.name === "up") {
15887
- this.commit(paletteMoved(this.state, -1));
16005
+ if (key.name === "down" || key.name === "up") {
16006
+ this.commit(this.steppedText(key));
15888
16007
  return;
15889
16008
  }
15890
16009
  if (this.onCaret(key)) return;
15891
16010
  if (PRINTABLE.test(key.sequence)) this.commit(typed(this.state, key.sequence));
15892
16011
  }
16012
+ steppedText(key) {
16013
+ const delta = key.name === "down" ? 1 : -1;
16014
+ if (listens(this.state.screen)) return paletteMoved(this.state, delta);
16015
+ if (key.meta) return caretEnded(this.state, delta > 0 ? "end" : "start");
16016
+ return caretRowed(this.measured(), delta);
16017
+ }
15893
16018
  onCaret(key) {
15894
16019
  if (this.state.screen === "palette" || this.state.screen === "keys") return false;
15895
16020
  const moved = caretFor(this.state, key);
@@ -15939,6 +16064,11 @@ var init_app = __esmMin((() => {
15939
16064
  }
15940
16065
  copyDragged() {
15941
16066
  const taken = this.renderer.getSelection()?.getSelectedText() ?? "";
16067
+ const where = process.env["ADIFF_TRACE"];
16068
+ if (where !== void 0) {
16069
+ const holder = this.renderer.getSelectionContainer()?.id ?? "none";
16070
+ appendFileSync(where, `${this.state.screen} in=${holder} ${JSON.stringify(taken).slice(0, 70)}\n`);
16071
+ }
15942
16072
  if (taken.trim().length === 0) return;
15943
16073
  copyToClipboard(taken);
15944
16074
  const lines = taken.split("\n").length;
@@ -16439,10 +16569,14 @@ var tui_exports = /* @__PURE__ */ __exportAll({
16439
16569
  App: () => App,
16440
16570
  Screen: () => Screen,
16441
16571
  actionFor: () => actionFor,
16572
+ caretColumn: () => caretColumn,
16573
+ caretOn: () => caretOn,
16574
+ caretRow: () => caretRow,
16442
16575
  commands: () => commands,
16443
16576
  commandsFor: () => commandsFor,
16444
16577
  hintsFor: () => hintsFor,
16445
16578
  initialState: () => initialState,
16579
+ laidDraft: () => laidDraft,
16446
16580
  launch: () => launch,
16447
16581
  listableFor: () => listableFor,
16448
16582
  palette: () => palette,
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.72",
26
+ "version": "0.1.0-alpha.74",
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": {