@zhuxixi/pi-agent-board 0.13.0 → 0.14.0
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 +65 -0
- package/README.md +37 -12
- package/docs/SECTION_FOLDING.md +53 -0
- package/docs/superpowers/plans/2026-10-23-issue-222-attach-ready.md +290 -0
- package/docs/superpowers/plans/2026-10-26-issue-245-key-hints-doc-sync.md +244 -0
- package/docs/superpowers/plans/2026-10-27-issue-172-fullscreen-selection-clear.md +344 -0
- package/docs/superpowers/plans/2026-10-27-issue-252-select-key-hints.md +209 -0
- package/docs/superpowers/plans/2026-10-28-issue-255-coordinator-endpoint-zombie.md +442 -0
- package/docs/superpowers/plans/2026-10-28-issue-257-legacy-pty-runner-endpoint-cleanup.md +256 -0
- package/docs/superpowers/plans/2026-11-03-cwd-favorites-full-pool.md +266 -0
- package/docs/superpowers/plans/2026-11-03-issue-266-alt-h-detach.md +467 -0
- package/docs/superpowers/plans/2026-11-04-issue-270-scenario-stdout-flush.md +584 -0
- package/docs/superpowers/plans/2026-11-05-issue-278-ctrl-g-external-editor.md +381 -0
- package/docs/superpowers/plans/2026-11-06-issue-280-frame-witness-delivery.md +430 -0
- package/docs/superpowers/plans/2026-11-07-issue-284-attach-recovery.md +115 -0
- package/docs/superpowers/plans/2026-11-07-issue-284-u1-u2-trial-guide.md +39 -0
- package/docs/superpowers/plans/2026-11-08-host-restart-model-override.md +894 -0
- package/docs/superpowers/plans/2026-11-08-issue-288-cap-floor.md +51 -0
- package/docs/superpowers/plans/2026-11-09-dashboard-fold-flake.md +166 -0
- package/docs/superpowers/plans/2026-11-09-issue-273-harness-console-log-exit.md +369 -0
- package/docs/superpowers/plans/2026-11-10-issue-258-board-selection-settle.md +760 -0
- package/docs/superpowers/plans/2026-11-13-issue-294-snapshot-resize-intent.md +590 -0
- package/docs/superpowers/plans/2026-11-16-greeting-title-poll.md +838 -0
- package/docs/superpowers/plans/2026-11-22-issue-297-compaction-mirror.md +797 -0
- package/docs/superpowers/plans/2026-11-23-issue-254-cursor-keep-position.md +663 -0
- package/docs/superpowers/plans/2026-11-23-issue-95-legacy-quarantine.md +320 -0
- package/docs/superpowers/specs/2026-10-23-issue-222-attach-ready-design.md +204 -0
- package/docs/superpowers/specs/2026-10-26-issue-245-key-hints-doc-sync-design.md +72 -0
- package/docs/superpowers/specs/2026-10-27-issue-172-fullscreen-selection-clear-design.md +248 -0
- package/docs/superpowers/specs/2026-10-27-issue-252-select-key-hints-design.md +95 -0
- package/docs/superpowers/specs/2026-10-28-issue-255-coordinator-endpoint-zombie-design.md +380 -0
- package/docs/superpowers/specs/2026-10-28-issue-257-legacy-pty-runner-endpoint-cleanup-design.md +197 -0
- package/docs/superpowers/specs/2026-11-03-cwd-favorites-full-pool-design.md +106 -0
- package/docs/superpowers/specs/2026-11-03-issue-266-alt-h-detach-design.md +185 -0
- package/docs/superpowers/specs/2026-11-04-issue-270-scenario-stdout-flush-design.md +176 -0
- package/docs/superpowers/specs/2026-11-05-issue-278-ctrl-g-external-editor-design.md +185 -0
- package/docs/superpowers/specs/2026-11-07-issue-284-attach-recovery-design.md +166 -0
- package/docs/superpowers/specs/2026-11-08-host-restart-model-override-design.md +115 -0
- package/docs/superpowers/specs/2026-11-08-issue-288-cap-floor-design.md +86 -0
- package/docs/superpowers/specs/2026-11-09-dashboard-fold-flake-design.md +109 -0
- package/docs/superpowers/specs/2026-11-09-issue-273-harness-console-log-exit-design.md +182 -0
- package/docs/superpowers/specs/2026-11-10-issue-258-board-selection-settle-design.md +109 -0
- package/docs/superpowers/specs/2026-11-13-issue-294-snapshot-resize-intent-design.md +141 -0
- package/docs/superpowers/specs/2026-11-16-greeting-title-poll-design.md +174 -0
- package/docs/superpowers/specs/2026-11-22-issue-297-compaction-mirror-design.md +158 -0
- package/docs/superpowers/specs/2026-11-22-issue-95-legacy-quarantine-design.md +209 -0
- package/docs/superpowers/specs/2026-11-23-issue-254-cursor-keep-position-design.md +201 -0
- package/package.json +1 -1
- package/runner/pty-runner.mjs +526 -63
- package/runner/state-coordinator.mjs +62 -5
- package/runner/title-runner.mjs +33 -24
- package/src/commands/agent-board.ts +5 -1
- package/src/core/attach-detach.mjs +27 -0
- package/src/core/attach-frame-proof.mjs +897 -0
- package/src/core/attach-frame-reporter.mjs +738 -0
- package/src/core/attach-frame-stream.mjs +266 -0
- package/src/core/attach-pr-label.mjs +12 -0
- package/src/core/attach-recovery.mjs +239 -0
- package/src/core/attach-screen-owner.mjs +55 -0
- package/src/core/attach-view-proof.mjs +709 -0
- package/src/core/auto-state.mjs +6 -1
- package/src/core/cwd-stats.mjs +3 -1
- package/src/core/dashboard-prefs.mjs +31 -0
- package/src/core/derive.mjs +8 -1
- package/src/core/events.mjs +127 -1
- package/src/core/foreground-projection-cache.mjs +1 -0
- package/src/core/frame-witness-update.mjs +35 -0
- package/src/core/fullscreen-selection.mjs +60 -0
- package/src/core/host-coordination.mjs +48 -0
- package/src/core/host-protocol.mjs +13 -2
- package/src/core/hosted-frame-witness.mjs +60 -0
- package/src/core/paths.mjs +10 -3
- package/src/core/pty-attach-render.mjs +239 -0
- package/src/core/pty-kitty-images.mjs +237 -0
- package/src/core/pty-scroll.mjs +8 -8
- package/src/core/rows.mjs +43 -7
- package/src/core/session-entries.mjs +82 -0
- package/src/core/session-launch-prefs.mjs +45 -0
- package/src/core/session-view.mjs +3 -63
- package/src/core/store.mjs +1 -0
- package/src/core/terminal-attach-client.mjs +199 -20
- package/src/core/terminal-attach-protocol.mjs +221 -7
- package/src/core/terminal-model.mjs +24 -3
- package/src/core/terminal-snapshot.mjs +10 -0
- package/src/core/title-flow.mjs +66 -0
- package/src/core/title.mjs +101 -0
- package/src/core/types.mjs +17 -0
- package/src/index.ts +85 -0
- package/src/runtime/service.mjs +87 -18
- package/src/ui/dashboard.ts +206 -49
- package/src/ui/pty-attach.ts +1472 -99
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
# Alt+H detach chord Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** Add `Alt+H` as a third unconditional detach chord in the attach view, reusing the exact code path of `Ctrl+←` / `Ctrl+\`.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Extract the "is this key a detach chord?" decision into a pure resolver (`src/core/attach-detach.mjs`) that the component calls once, replacing the two inline `matchesKey` branches. Encoding behaviour is pinned by a unit matrix; behaviour per editor/socket state is pinned by the existing `detach-gate-smoke` probe. No protocol, storage, or dashboard change.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** TypeScript (`src/ui/pty-attach.ts`), plain ESM resolver (`.mjs`), `node:test` + `assert/strict`, pi-tui `matchesKey`, existing c8 coverage gate.
|
|
10
|
+
|
|
11
|
+
**Spec:** `docs/superpowers/specs/2026-11-03-issue-266-alt-h-detach-design.md`
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Tabs for indentation; English comments and commit messages.
|
|
16
|
+
- Commit subjects: `feat`/`fix`/`perf`/`refactor`/`docs`/`test`/`chore`, with `(issue #266)` while the PR number does not exist yet.
|
|
17
|
+
- No new dependencies; the resolver imports only `@earendil-works/pi-tui`.
|
|
18
|
+
- `Alt+H` must reuse `detach()` verbatim — no new teardown path, no protocol change.
|
|
19
|
+
- Bare `h`, `Alt+Shift+H`, `Alt+←` stay unbound; the board's `h` = Hold is out of scope.
|
|
20
|
+
- Final gate is `npm run verify` (typecheck + perf gate + tests + coverage + `pack:dry`).
|
|
21
|
+
|
|
22
|
+
## Review Focus
|
|
23
|
+
|
|
24
|
+
Inputs/conditions the spec implies but no acceptance row names directly; each gets a test in the task that owns the code.
|
|
25
|
+
|
|
26
|
+
1. A chord coalesced with other bytes in one read must be forwarded unchanged, never half-applied (R8).
|
|
27
|
+
2. A bracketed paste containing `ESC h` must stay one segment and never detach (A4).
|
|
28
|
+
3. While the host is disconnected the chord must still end the surface with no `input` packet (R4).
|
|
29
|
+
4. With the `#147` delete confirm armed, the chord must cancel and detach, never archive (R5).
|
|
30
|
+
5. `h`, `Alt+Shift+H` and ordinary text must still reach the child (R6).
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
### Task 1: Pure chord resolver + encoding matrix
|
|
35
|
+
|
|
36
|
+
**Files:**
|
|
37
|
+
- Create: `src/core/attach-detach.mjs`
|
|
38
|
+
- Test: `test/attach-detach-chord.test.mjs`
|
|
39
|
+
|
|
40
|
+
**Interfaces:**
|
|
41
|
+
- Produces: `resolveAttachDetachChord(data: string): boolean` — `true` for `ctrl+\`, `ctrl+left`, `alt+h` in any real encoding; `false` for everything else. Task 2 imports it.
|
|
42
|
+
|
|
43
|
+
- [ ] **Step 1: Write the failing test**
|
|
44
|
+
|
|
45
|
+
Create `test/attach-detach-chord.test.mjs`:
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
import assert from "node:assert/strict";
|
|
49
|
+
import test from "node:test";
|
|
50
|
+
import { resolveAttachDetachChord } from "../src/core/attach-detach.mjs";
|
|
51
|
+
import { splitAttachInput } from "../src/core/pty-scroll.mjs";
|
|
52
|
+
|
|
53
|
+
// Issue #266 A1: the three unconditional detach chords, each in the encodings a
|
|
54
|
+
// real terminal can emit (legacy ESC-prefix / kitty CSI-u / modifyOtherKeys),
|
|
55
|
+
// plus the negative matrix that keeps ordinary typing out of the chord set.
|
|
56
|
+
const POSITIVE = [
|
|
57
|
+
["ctrl+\\ raw 0x1c", "\x1c"],
|
|
58
|
+
["ctrl+\\ kitty CSI-u", "\x1b[92;5u"],
|
|
59
|
+
["ctrl+\\ modifyOtherKeys", "\x1b[27;5;92~"],
|
|
60
|
+
["ctrl+left xterm", "\x1b[1;5D"],
|
|
61
|
+
["ctrl+left SS3", "\x1bOd"],
|
|
62
|
+
["ctrl+left kitty KP", "\x1b[57417;5u"],
|
|
63
|
+
["alt+h legacy ESC prefix", "\x1bh"],
|
|
64
|
+
["alt+h kitty CSI-u", "\x1b[104;3u"],
|
|
65
|
+
["alt+h kitty alternate key", "\x1b[104:104;3u"],
|
|
66
|
+
["alt+h kitty event type", "\x1b[104;3:1u"],
|
|
67
|
+
["alt+h modifyOtherKeys", "\x1b[27;3;104~"],
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
const NEGATIVE = [
|
|
71
|
+
["bare h", "h"],
|
|
72
|
+
["shifted legacy alt+H", "\x1bH"],
|
|
73
|
+
["ctrl+x", "\x18"],
|
|
74
|
+
["ctrl+alt+h kitty", "\x1b[104;7u"],
|
|
75
|
+
["shift+alt+h kitty", "\x1b[104;4u"],
|
|
76
|
+
["alt+h with text codepoint", "\x1b[104;3;104u"],
|
|
77
|
+
["plain text", "abc"],
|
|
78
|
+
["lone escape", "\x1b"],
|
|
79
|
+
["ctrl+] passthrough", "\x1d"],
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
test("resolveAttachDetachChord: encoding matrix (issue #266 A1)", () => {
|
|
83
|
+
for (const [label, data] of POSITIVE) {
|
|
84
|
+
assert.equal(resolveAttachDetachChord(data), true, `${label} must detach`);
|
|
85
|
+
}
|
|
86
|
+
for (const [label, data] of NEGATIVE) {
|
|
87
|
+
assert.equal(resolveAttachDetachChord(data), false, `${label} must not detach`);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// A4: a bracketed paste is one key segment; ESC h inside it must never resolve.
|
|
92
|
+
test("resolveAttachDetachChord: paste containing ESC h never detaches (issue #266 A4)", () => {
|
|
93
|
+
const segments = splitAttachInput("\x1b[200~a\x1bhb\x1b[201~");
|
|
94
|
+
assert.equal(segments.length, 1);
|
|
95
|
+
assert.equal(segments[0].kind, "key");
|
|
96
|
+
assert.equal(resolveAttachDetachChord(segments[0].data), false);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("resolveAttachDetachChord: ESC and h in separate reads are not the chord (issue #266 A4)", () => {
|
|
100
|
+
const escSegments = splitAttachInput("\x1b");
|
|
101
|
+
const hSegments = splitAttachInput("h");
|
|
102
|
+
assert.equal(resolveAttachDetachChord(escSegments[0].data), false);
|
|
103
|
+
assert.equal(resolveAttachDetachChord(hSegments[0].data), false);
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- [ ] **Step 2: Run the test to verify it fails**
|
|
108
|
+
|
|
109
|
+
Run: `node --test test/attach-detach-chord.test.mjs`
|
|
110
|
+
|
|
111
|
+
Expected: FAIL — `Cannot find module '../src/core/attach-detach.mjs'`.
|
|
112
|
+
|
|
113
|
+
- [ ] **Step 3: Write the minimal implementation**
|
|
114
|
+
|
|
115
|
+
Create `src/core/attach-detach.mjs`:
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
import { Key, matchesKey } from "@earendil-works/pi-tui";
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Issue #266: the attach view's unconditional detach chords. Pure — no
|
|
122
|
+
* component state, no socket, no editor cache: a chord is exit intent or it is
|
|
123
|
+
* forwarded. Callers must run the #147 delete-confirm resolver first, so an
|
|
124
|
+
* armed confirm still cancels before the chord closes the surface.
|
|
125
|
+
*
|
|
126
|
+
* - `ctrl+\` (raw 0x1c) — the terminal-independent escape (issue #126): one raw
|
|
127
|
+
* ASCII byte every terminal forwards unchanged in raw mode; the kitty CSI-u
|
|
128
|
+
* and modifyOtherKeys encodings of the same chord match too.
|
|
129
|
+
* - `ctrl+left` — unambiguous intent while a draft sits in the editor
|
|
130
|
+
* (issue #89); a single ← stays gated on the pushed editorEmpty channel.
|
|
131
|
+
* - `alt+h` — vim's h is "left" (issue #266). The bare letter must keep
|
|
132
|
+
* reaching the child editor, so the chord is the modified key; a segment
|
|
133
|
+
* that coalesces the chord with other bytes does not match and is forwarded
|
|
134
|
+
* unchanged.
|
|
135
|
+
* @param {string} data one key segment from splitAttachInput
|
|
136
|
+
* @returns {boolean}
|
|
137
|
+
*/
|
|
138
|
+
export function resolveAttachDetachChord(data) {
|
|
139
|
+
return (
|
|
140
|
+
matchesKey(data, "ctrl+\\") ||
|
|
141
|
+
matchesKey(data, Key.ctrl("left")) ||
|
|
142
|
+
matchesKey(data, Key.alt("h"))
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
- [ ] **Step 4: Run the test to verify it passes**
|
|
148
|
+
|
|
149
|
+
Run: `node --test test/attach-detach-chord.test.mjs`
|
|
150
|
+
|
|
151
|
+
Expected: PASS — 3 tests, 0 failures.
|
|
152
|
+
|
|
153
|
+
- [ ] **Step 5: Commit**
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
git add src/core/attach-detach.mjs test/attach-detach-chord.test.mjs
|
|
157
|
+
git commit -m "feat(attach): pure detach-chord resolver incl. Alt+H (issue #266)"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### Task 2: Wire the resolver into the attach view + state scenarios
|
|
163
|
+
|
|
164
|
+
**Files:**
|
|
165
|
+
- Modify: `src/ui/pty-attach.ts` (import block near line 8; replace old lines 434–455)
|
|
166
|
+
- Modify: `test-support/detach-gate-smoke.ts` (append `R1`–`R6`, `R8` before the final `console.log`)
|
|
167
|
+
- Modify: `test/pty-attach-detach-gate.test.mjs` (assertions for the new keys)
|
|
168
|
+
|
|
169
|
+
**Interfaces:**
|
|
170
|
+
- Consumes: `resolveAttachDetachChord(data)` from Task 1.
|
|
171
|
+
- Produces: new smoke-report keys `altHDetachesOnDraft`, `altHDetachesOnEmptyEditor`, `altHDetachesWithoutEditorState`, `altHDetachesWhileDisconnected`, `altHCancelsThenDetaches`, `altHLeavesOtherKeysToTheChild`, `altHCoalescedSegmentForwards`.
|
|
172
|
+
|
|
173
|
+
- [ ] **Step 1: Write the failing scenarios and assertions**
|
|
174
|
+
|
|
175
|
+
In `test-support/detach-gate-smoke.ts`, append these blocks immediately before the final `console.log(JSON.stringify(out))` line (the file currently ends with that print):
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
// R1. Issue #266: Alt+H detaches unconditionally while a draft sits in the
|
|
179
|
+
// editor — the same guarantee as Ctrl+← (#89), with no editor gate.
|
|
180
|
+
{
|
|
181
|
+
const { attach, sent, didDetach } = makeAttach();
|
|
182
|
+
await writeToTerm(attach, "chat content\r\n");
|
|
183
|
+
(fixtureInternals<{ onSocketData: (t: string) => void }>(attach)).onSocketData(JSON.stringify({ type: "editor_state", empty: false }) + "\n");
|
|
184
|
+
(fixtureInternals<{ connected: boolean }>(attach)).connected = true;
|
|
185
|
+
attach.handleInput("\x1bh");
|
|
186
|
+
out.altHDetachesOnDraft = didDetach() && sent.length === 1 && sent[0].type === "detach";
|
|
187
|
+
attach.dispose();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// R2. Issue #266: the chord also detaches from a genuinely empty editor —
|
|
191
|
+
// same unconditional guarantee on the other side of the gate.
|
|
192
|
+
{
|
|
193
|
+
const { attach, sent, didDetach } = makeAttach();
|
|
194
|
+
await writeToTerm(attach, "chat content\r\n> \x1b[7m \x1b[27m");
|
|
195
|
+
(fixtureInternals<{ onSocketData: (t: string) => void }>(attach)).onSocketData(JSON.stringify({ type: "editor_state", empty: true }) + "\n");
|
|
196
|
+
(fixtureInternals<{ connected: boolean }>(attach)).connected = true;
|
|
197
|
+
attach.handleInput("\x1bh");
|
|
198
|
+
out.altHDetachesOnEmptyEditor = didDetach() && sent.length === 1 && sent[0].type === "detach";
|
|
199
|
+
attach.dispose();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// R3. Issue #266: the null quadrant — no editor_state ever pushed — still
|
|
203
|
+
// detaches: the chord never consults the gate.
|
|
204
|
+
{
|
|
205
|
+
const { attach, sent, didDetach } = makeAttach();
|
|
206
|
+
await writeToTerm(attach, "chat content\r\n");
|
|
207
|
+
(fixtureInternals<{ connected: boolean }>(attach)).connected = true;
|
|
208
|
+
attach.handleInput("\x1bh");
|
|
209
|
+
out.altHDetachesWithoutEditorState = didDetach() && sent.length === 1 && sent[0].type === "detach";
|
|
210
|
+
attach.dispose();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// R4. Issue #266: while disconnected the chord still ends the surface and the
|
|
214
|
+
// key is never forwarded as input (same contract as Ctrl+\ on a dead socket).
|
|
215
|
+
{
|
|
216
|
+
const { attach, sent, resultAction } = makeAttach();
|
|
217
|
+
attach.handleInput("\x1bh");
|
|
218
|
+
out.altHDetachesWhileDisconnected = resultAction() === "detached" && !sent.some((m) => m.type === "input");
|
|
219
|
+
attach.dispose();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// R5. Issue #266 + #147: with the delete confirm armed the chord cancels the
|
|
223
|
+
// confirm and detaches — it never archives and never forwards the chord.
|
|
224
|
+
{
|
|
225
|
+
const { attach, sent, resultAction } = makeAttach();
|
|
226
|
+
attach.handleInput("\x18");
|
|
227
|
+
attach.handleInput("\x1bh");
|
|
228
|
+
out.altHCancelsThenDetaches = resultAction() === "detached"
|
|
229
|
+
&& !sent.some((m) => m.type === "input")
|
|
230
|
+
&& sent.filter((m) => m.type === "detach").length === 1;
|
|
231
|
+
attach.dispose();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// R6. Issue #266 isolation: keys that are NOT the chord still reach the child
|
|
235
|
+
// unchanged — bare h, shifted Alt+H and ordinary text.
|
|
236
|
+
{
|
|
237
|
+
let allForwarded = true;
|
|
238
|
+
for (const data of ["h", "\x1bH", "abc"]) {
|
|
239
|
+
const probe = makeAttach();
|
|
240
|
+
(fixtureInternals<{ connected: boolean }>(probe.attach)).connected = true;
|
|
241
|
+
probe.attach.handleInput(data);
|
|
242
|
+
allForwarded = allForwarded && !probe.didDetach()
|
|
243
|
+
&& probe.sent.length === 1 && probe.sent[0].type === "input" && probe.sent[0].data === data;
|
|
244
|
+
probe.attach.dispose();
|
|
245
|
+
}
|
|
246
|
+
out.altHLeavesOtherKeysToTheChild = allForwarded;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// R8. Issue #266 review focus: a chord coalesced with another chord in ONE read
|
|
250
|
+
// is not a match — the whole segment is forwarded unchanged, never half-applied.
|
|
251
|
+
{
|
|
252
|
+
const { attach, sent, didDetach } = makeAttach();
|
|
253
|
+
(fixtureInternals<{ connected: boolean }>(attach)).connected = true;
|
|
254
|
+
attach.handleInput("\x1bh\x1bh");
|
|
255
|
+
out.altHCoalescedSegmentForwards = !didDetach()
|
|
256
|
+
&& sent.length === 1 && sent[0].type === "input" && sent[0].data === "\x1bh\x1bh";
|
|
257
|
+
attach.dispose();
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Update the harness header comment block (the `// P1-P7 …` list near the top) by appending one line:
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
// R1-R6/R8. Issue #266: Alt+H detaches unconditionally in every
|
|
265
|
+
// editor/socket quadrant, cancels an armed delete confirm first, leaves
|
|
266
|
+
// other keys to the child, and never half-applies a coalesced segment.
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
In `test/pty-attach-detach-gate.test.mjs`, add these assertions at the end of the existing `test("attach detach gate: …")` body, right after the `printableQStillForwardsToChild` assertion:
|
|
270
|
+
|
|
271
|
+
```js
|
|
272
|
+
// Issue #266: Alt+H joins the unconditional detach set (vim h = left).
|
|
273
|
+
assert.equal(parsed.altHDetachesOnDraft, true, "Alt+H must detach with a pushed draft (issue #266)");
|
|
274
|
+
assert.equal(parsed.altHDetachesOnEmptyEditor, true, "Alt+H must detach from an empty editor (issue #266)");
|
|
275
|
+
assert.equal(parsed.altHDetachesWithoutEditorState, true, "Alt+H must detach with no editor_state at all (issue #266)");
|
|
276
|
+
assert.equal(parsed.altHDetachesWhileDisconnected, true, "Alt+H must end the surface while disconnected (issue #266)");
|
|
277
|
+
assert.equal(parsed.altHCancelsThenDetaches, true, "Alt+H must cancel an armed delete confirm and detach, never archive (issue #266)");
|
|
278
|
+
assert.equal(parsed.altHLeavesOtherKeysToTheChild, true, "h, Alt+Shift+H and text must still reach the child (issue #266)");
|
|
279
|
+
assert.equal(parsed.altHCoalescedSegmentForwards, true, "a coalesced chord segment must be forwarded unchanged (issue #266)");
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
- [ ] **Step 2: Run the test to verify it fails**
|
|
283
|
+
|
|
284
|
+
Run: `node --test test/pty-attach-detach-gate.test.mjs`
|
|
285
|
+
|
|
286
|
+
Expected: FAIL — `parsed.altHDetachesOnDraft` is `false` (the chord is forwarded as input today), and `parsed.altHCoalescedSegmentForwards` may already pass. The assertions for R1–R5 fail before the wiring.
|
|
287
|
+
|
|
288
|
+
- [ ] **Step 3: Wire the resolver**
|
|
289
|
+
|
|
290
|
+
In `src/ui/pty-attach.ts`, after the existing `import { resolveAttachDeleteKey } from "../core/attach-delete.mjs";` line add:
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
import { resolveAttachDetachChord } from "../core/attach-detach.mjs";
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Replace the two consecutive branches (old lines 434–455: `if (matchesKey(data, "ctrl+\\")) { … }` and `if (matchesKey(data, Key.ctrl("left"))) { … }`) with:
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
if (resolveAttachDetachChord(data)) {
|
|
300
|
+
// Issue #266: unconditional detach chords — Ctrl+\ (raw 0x1c, #126),
|
|
301
|
+
// Ctrl+← (#89) and Alt+H (vim h = left). Bare ← stays gated on the
|
|
302
|
+
// pushed editor_state; a chord needs no gate. Rationale and the
|
|
303
|
+
// encoding matrix live in src/core/attach-detach.mjs.
|
|
304
|
+
this.detach();
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Ordering must not change: the block stays after the `resolveAttachDeleteKey` section and before the `Key.left` branch.
|
|
310
|
+
|
|
311
|
+
- [ ] **Step 4: Run the tests to verify they pass**
|
|
312
|
+
|
|
313
|
+
Run: `node --test test/pty-attach-detach-gate.test.mjs`
|
|
314
|
+
|
|
315
|
+
Expected: PASS.
|
|
316
|
+
|
|
317
|
+
Then: `node --test test/attach-detach-chord.test.mjs` — PASS (Task 1 unaffected).
|
|
318
|
+
|
|
319
|
+
- [ ] **Step 5: Commit**
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
git add src/ui/pty-attach.ts test-support/detach-gate-smoke.ts test/pty-attach-detach-gate.test.mjs
|
|
323
|
+
git commit -m "feat(attach): Alt+H detaches via the shared chord resolver (issue #266)"
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
### Task 3: Advertise the chord in the view and the README
|
|
329
|
+
|
|
330
|
+
**Files:**
|
|
331
|
+
- Modify: `src/ui/pty-attach.ts:575` (header) and `:591` (loading hint)
|
|
332
|
+
- Modify: `README.md:96` and `:219`
|
|
333
|
+
- Modify: `test-support/detach-gate-smoke.ts` (append `R7`)
|
|
334
|
+
- Modify: `test/pty-attach-detach-gate.test.mjs`
|
|
335
|
+
|
|
336
|
+
**Interfaces:**
|
|
337
|
+
- Produces: smoke key `headerMentionsAltH`, plus a README that documents the chord and its terminal prerequisites. No new functions.
|
|
338
|
+
|
|
339
|
+
- [ ] **Step 1: Write the failing hint scenario**
|
|
340
|
+
|
|
341
|
+
Append to `test-support/detach-gate-smoke.ts` (before the final print, after `R8`):
|
|
342
|
+
|
|
343
|
+
```ts
|
|
344
|
+
// R7. Issue #266: the surface advertises the chord — the live header and the
|
|
345
|
+
// loading hint both name Alt+H next to the existing chords.
|
|
346
|
+
{
|
|
347
|
+
const loading = makeAttach();
|
|
348
|
+
const loadingLines = loading.attach.render(80).join("\n");
|
|
349
|
+
const loadingMentions = loadingLines.includes("Alt+H");
|
|
350
|
+
loading.attach.dispose();
|
|
351
|
+
const live = makeAttach();
|
|
352
|
+
await writeToTerm(live.attach, "chat content\r\n");
|
|
353
|
+
out.headerMentionsAltH = live.attach.render(80)[0].includes("Alt+H") && loadingMentions;
|
|
354
|
+
live.attach.dispose();
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Add the assertion in `test/pty-attach-detach-gate.test.mjs` right after the `headerMentionsCtrlBackslash` assertion:
|
|
359
|
+
|
|
360
|
+
```js
|
|
361
|
+
assert.equal(parsed.headerMentionsAltH, true, "the live header and loading hint must advertise the Alt+H chord (issue #266)");
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
- [ ] **Step 2: Run the test to verify it fails**
|
|
365
|
+
|
|
366
|
+
Run: `node --test test/pty-attach-detach-gate.test.mjs`
|
|
367
|
+
|
|
368
|
+
Expected: FAIL — `parsed.headerMentionsAltH` is `false`.
|
|
369
|
+
|
|
370
|
+
- [ ] **Step 3: Update the two hints**
|
|
371
|
+
|
|
372
|
+
In `src/ui/pty-attach.ts:575`, change the muted header text to:
|
|
373
|
+
|
|
374
|
+
```ts
|
|
375
|
+
this.theme.fg("muted", `${this.status} · opens links · drag selects+copies · Ctrl+←/Ctrl+\\/Alt+H detach`);
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
In `src/ui/pty-attach.ts:591`, change the centered loading hint to:
|
|
379
|
+
|
|
380
|
+
```ts
|
|
381
|
+
out.push(center(this.theme.fg("dim", "Ctrl+←/Ctrl+\\/Alt+H to detach"), width));
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
- [ ] **Step 4: Run the test to verify it passes**
|
|
385
|
+
|
|
386
|
+
Run: `node --test test/pty-attach-detach-gate.test.mjs`
|
|
387
|
+
|
|
388
|
+
Expected: PASS.
|
|
389
|
+
|
|
390
|
+
- [ ] **Step 5: Update the README**
|
|
391
|
+
|
|
392
|
+
In `README.md:96`, after the sentence fragment `or `Ctrl+\` — the unconditional escape: it detaches regardless of editor state on any terminal that forwards the raw 0x1c byte (raw, kitty, and modifyOtherKeys keyboard modes all work).` insert:
|
|
393
|
+
|
|
394
|
+
```text
|
|
395
|
+
`Alt+H` is the vim-style third escape (`h` = left) and detaches with the same unconditional contract — draft or empty editor, known or unknown editor state, live or dead host; the key is captured from the child while attached (the child Pi binds no `alt+h`). It needs a terminal that delivers Alt as Meta: macOS Terminal.app and iTerm2 require "Use Option as Meta key", and GNOME Terminal's `_Help` menu mnemonic takes Alt+H before the app sees it.
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
In `README.md:219`, after the fragment `and `Ctrl+\` is the unconditional escape — a single raw ASCII byte (0x1c) that terminals forward unchanged in raw mode (kitty CSI-u and modifyOtherKeys encodings included), honored no matter what the child editor reports.` insert:
|
|
399
|
+
|
|
400
|
+
```text
|
|
401
|
+
`Alt+H` (vim's `h` = left) is the third unconditional escape, with the same guarantee and the same capture-from-the-child trade-off; it needs Alt delivered as Meta (macOS Terminal.app / iTerm2: "Use Option as Meta key"; GNOME Terminal reserves Alt+H for its `_Help` menu).
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
- [ ] **Step 6: Verify the static acceptance check**
|
|
405
|
+
|
|
406
|
+
Run: `grep -n 'Alt+H' README.md` and `grep -n 'Option as Meta' README.md`
|
|
407
|
+
|
|
408
|
+
Expected: two `Alt+H` hits (one per paragraph) and at least two `Option as Meta` hits.
|
|
409
|
+
|
|
410
|
+
- [ ] **Step 7: Commit**
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
git add src/ui/pty-attach.ts README.md test-support/detach-gate-smoke.ts test/pty-attach-detach-gate.test.mjs
|
|
414
|
+
git commit -m "docs(attach): advertise the Alt+H detach chord in hints and README (issue #266)"
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
### Task 4: Full verification gate
|
|
420
|
+
|
|
421
|
+
**Files:** none (verification only).
|
|
422
|
+
|
|
423
|
+
**Interfaces:** none.
|
|
424
|
+
|
|
425
|
+
- [ ] **Step 1: Run the full gate**
|
|
426
|
+
|
|
427
|
+
Run: `npm run verify`
|
|
428
|
+
|
|
429
|
+
Expected: typecheck clean; perf gate passes; the whole `test/*.test.mjs` suite passes with no leaked coordinators; c8 thresholds (lines 85 / funcs 80 / branches 70) hold; `pack:dry` lists the same file set as before this branch (the new `src/core/attach-detach.mjs` is included by the `src` glob).
|
|
430
|
+
|
|
431
|
+
- [ ] **Step 2: Confirm the new files ship**
|
|
432
|
+
|
|
433
|
+
Run: `npm run pack:dry 2>&1 | grep -n 'attach-detach'`
|
|
434
|
+
|
|
435
|
+
Expected: `src/core/attach-detach.mjs` appears in the tarball listing.
|
|
436
|
+
|
|
437
|
+
- [ ] **Step 3: Fix or report**
|
|
438
|
+
|
|
439
|
+
If coverage drops below threshold, add the missing negative case to `test/attach-detach-chord.test.mjs` rather than raising thresholds. If anything else fails, fix it in this branch and commit with a `fix`/`test` subject referencing `(issue #266)`.
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
### Task 5: Manual verification (post-PR, blocks merge)
|
|
444
|
+
|
|
445
|
+
**Files:** none. Copied from spec §9 so the executor does not need to reopen the spec.
|
|
446
|
+
|
|
447
|
+
**Interfaces:** none.
|
|
448
|
+
|
|
449
|
+
- [ ] **Step 1: Launch the worktree build**
|
|
450
|
+
|
|
451
|
+
```bash
|
|
452
|
+
WT=/home/elling/work/git-repo/pi-agent-board/.pi/worktrees/issue-266-alt-h-detach
|
|
453
|
+
pi -ne -e "$WT/src/index.ts"
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
`-ne` disables extension discovery (so the installed copy at `~/.pi/agent/git/github.com/zhuxixi/pi-agent-board` cannot load alongside), `-e` loads the worktree entry.
|
|
457
|
+
|
|
458
|
+
- [ ] **Step 2: Four observations**
|
|
459
|
+
|
|
460
|
+
1. Attach a session, press `Alt+H` → back on the board; re-attach shows the child session still alive with its history.
|
|
461
|
+
2. Re-attach, type a draft into the child editor, press `Alt+H` → back on the board (bare `←` would have been forwarded instead).
|
|
462
|
+
3. Re-attach, press `Ctrl+X` (header shows `Delete "…"?`), then `Alt+H` → back on the board and the row is **not** archived.
|
|
463
|
+
4. Re-attach, press `Alt+Shift+H` → the child receives it as ordinary input; no detach.
|
|
464
|
+
|
|
465
|
+
- [ ] **Step 3: Record the result**
|
|
466
|
+
|
|
467
|
+
Post the four observations on the PR (or issue #266) as the U1 evidence line, including terminal name and version (this box: WezTerm). Any mismatch is a U1 failure: fix before merge, do not mark it `pending`.
|