Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a3ea6c65ca | |||
| 21bbf6b114 | |||
| 0743cf9a8a | |||
| 946625e899 | |||
| 20e13bba4d | |||
| d2405a2ca8 | |||
| 5d9f7ddaaf | |||
| 98b33ff53b | |||
| c5e464fbeb | |||
| 16cca30d39 | |||
| 9b6a15a43c | |||
| edba577586 | |||
| ceca17aa40 | |||
| 528c76d23b | |||
| b9517e0f68 | |||
| 5a02e793dd | |||
| faf0810a6c | |||
| d597c1c362 | |||
| 790d88c827 | |||
| 37953cfcad | |||
| 24e329e25d | |||
| 96a689aedf | |||
| 911ed21671 | |||
| 2ca0fc8c51 | |||
| 3d9270ecc4 | |||
| e53f0c30ad | |||
| ad6cbe10c7 | |||
| 64c7d7bad2 | |||
| ab00cbefcc | |||
| c67749a53c | |||
| ba7623f813 | |||
| 9e9fcb8057 | |||
| 1381eab11e | |||
| 54846da1ea | |||
| fdd743490d | |||
| 4584e06679 | |||
| ef07acfdc1 |
+12
-1
@@ -18,6 +18,16 @@
|
||||
"onStartupFinished"
|
||||
],
|
||||
"contributes": {
|
||||
"configuration": {
|
||||
"title": "Cowriting",
|
||||
"properties": {
|
||||
"cowriting.liveProgress.revealOutput": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "When Claude is editing, reveal the \"Cowriting: Claude\" output channel (without stealing focus) as soon as Claude starts producing text, so you can read the output as it streams."
|
||||
}
|
||||
}
|
||||
},
|
||||
"commands": [
|
||||
{
|
||||
"command": "cowriting.showClineSdkInfo",
|
||||
@@ -202,7 +212,8 @@
|
||||
"watch": "node esbuild.mjs --watch",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run",
|
||||
"pretest:e2e": "npm run build && tsc -p tsconfig.e2e.json",
|
||||
"clean:e2e": "node -e \"require('fs').rmSync('out/test',{recursive:true,force:true})\"",
|
||||
"pretest:e2e": "npm run build && npm run clean:e2e && tsc -p tsconfig.e2e.json",
|
||||
"test:e2e": "node ./out/test/e2e/runTest.js",
|
||||
"smoke:live": "npm run build && node scripts/smoke-live-turn.mjs",
|
||||
"vscode:prepublish": "node esbuild.mjs"
|
||||
|
||||
@@ -10,7 +10,15 @@ console.log(`instruction: ${instruction}`);
|
||||
console.log(`text: ${text}`);
|
||||
try {
|
||||
const t0 = Date.now();
|
||||
const result = await runEditTurn(instruction, text);
|
||||
// #60: exercise the live-progress path against the real SDK — log each reduced
|
||||
// snapshot so the smoke shows streaming/activity/tokens, not just the result.
|
||||
const result = await runEditTurn(instruction, text, {
|
||||
onProgress: (s) => {
|
||||
const bits = [s.phase === "tool" ? `tool:${s.tool}` : s.phase, `${s.chars}c`];
|
||||
if (s.tokens) bits.push(`${s.tokens}tok`);
|
||||
console.log(` progress: ${bits.join(" ")}`);
|
||||
},
|
||||
});
|
||||
console.log(`replacement: ${JSON.stringify(result.replacement)}`);
|
||||
console.log(`model: ${result.model}`);
|
||||
console.log(`sessionId: ${result.sessionId}`);
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
# Session 0045.0 — Transcript
|
||||
|
||||
> App: vscode-cowriting-plugin
|
||||
> Start: 2026-06-13T08-04 (PST)
|
||||
> Type: planning-and-executing
|
||||
> End: 2026-06-13T08-17 (PST)
|
||||
> Status: **FINALIZED.**
|
||||
> Posture: autonomous (yolo)
|
||||
|
||||
## Launch prompt
|
||||
|
||||
```
|
||||
/goal plan-and-execute #46 (SLICE-3 of the document-edit flow — accept-all, INV-42), per specs/coauthoring-document-edit-flow.md
|
||||
|
||||
```
|
||||
|
||||
## Plan
|
||||
|
||||
**SLICE-3 — #46 (accept)** of the document-edit flow
|
||||
(`specs/coauthoring-document-edit-flow.md` §7.2, INV-42). Final slice — completes
|
||||
reach→review→**accept**. Anchor: Feature #46 (`type/feature`); covered by the
|
||||
graduated combined design → §4.3 R3.
|
||||
|
||||
A single **Accept all** gesture applies every pending proposal on the current
|
||||
document through the existing F4 `acceptById` seam (block proposals take the INV-40
|
||||
path automatically), in a re-anchor-safe (descending) order, **skipping** orphans
|
||||
and **reporting** applied-vs-skipped. Batched application of the existing path — no
|
||||
new accept mechanism; the webview posts intent only (INV-35).
|
||||
|
||||
Tasks:
|
||||
1. `proposalController.ts` — `acceptAllProposals(document): Promise<{applied,
|
||||
skipped}>`: snapshot pending, sort descending by resolved anchor start,
|
||||
`acceptById` each **silently** (no per-item orphan warning), tally
|
||||
applied/skipped (orphans counted skipped). Add a `silent` opt to the accept
|
||||
path so the batch suppresses per-proposal warnings.
|
||||
2. `extension.ts` — `cowriting.acceptAllProposals` command (active doc) → reports
|
||||
applied-vs-skipped via a status message.
|
||||
3. `trackChangesPreview.ts` — `ToolbarMsg += {type:"acceptAll"}`;
|
||||
`handleWebviewMessage` routes it → `proposals.acceptAllProposals(document)` +
|
||||
report.
|
||||
4. `media/preview.ts` + `shellHtml` — an **Accept all** toolbar button shown when
|
||||
`summary.proposals >= 2` (and authorable), posting `{type:"acceptAll"}`.
|
||||
5. `package.json` — register the `cowriting.acceptAllProposals` command (palette,
|
||||
markdown-gated).
|
||||
6. Tests: host E2E (N pending → all applied + cleared; orphan skipped + reported;
|
||||
button hidden < 2 pending); `MANUAL-SMOKE-F12.md` §3.
|
||||
|
||||
No new persisted artifact; no deploy pipeline (VS Code extension).
|
||||
|
||||
## Results
|
||||
|
||||
**SLICE-3 (#46, accept) shipped to `main`** — PR
|
||||
[#51](https://git.benstull.org/benstull/vscode-cowriting-plugin/pulls/51)
|
||||
(merged), issue #46 closed. **Completes the document-edit-flow cluster
|
||||
(#42 reach + #47 review + #46 accept).**
|
||||
|
||||
- `proposalController.ts` — `acceptAllProposals(document)` → `{applied, skipped}`
|
||||
(descending order, orphan-skip); `accept`/`acceptById` `silent` opt for the batch.
|
||||
- `trackChangesPreview.ts` — `ToolbarMsg += {type:"acceptAll"}` → public
|
||||
`acceptAll(document)` (batch + report).
|
||||
- `extension.ts`/`package.json` — `cowriting.acceptAllProposals` command
|
||||
(active doc, markdown-gated palette).
|
||||
- `media/preview.ts` + shell — "✓✓ Accept all" toolbar button (intent; shown
|
||||
≥2 pending, authorable, on-state).
|
||||
- `trackChangesModel.ts` — `diffToBlockHunks` fix: emit one block-aligned hunk
|
||||
per changed block **even when adjacent** (changed blocks are 1:1 anchors;
|
||||
gap-spans only cover add/remove runs) — caught by the accept-all E2E (3 adjacent
|
||||
changed blocks were collapsing to 1 proposal).
|
||||
- `f12Accept.test.ts` E2E + `MANUAL-SMOKE-F12.md` §3.
|
||||
|
||||
Verification: `tsc --noEmit` clean; **214 unit** green; **73/5 host E2E** green
|
||||
(main suite 69 → 73 with the new accept-all tests).
|
||||
|
||||
**Next:** the cluster is complete; no in-flight next step. Open backlog includes
|
||||
#48 (pin → fully clean review panel, story P2) and the OQ-2 F11 (#43) spec
|
||||
graduation (hygiene). A natural hand-back point for operator direction.
|
||||
|
||||
## Session arc
|
||||
|
||||
1. **Claim.** Continued the rolling `next` goal after 0044 shipped #47; claimed
|
||||
session 0045 for #46. Clean `main`.
|
||||
2. **Plan + implement.** Controller `acceptAllProposals` (+ `silent` accept opt);
|
||||
`acceptAll` intent route + public method; command + package.json; "Accept all"
|
||||
toolbar button (≥2-pending gating in the sealed webview).
|
||||
3. **E2E caught a real bug.** The accept-all "3 adjacent changed blocks" case
|
||||
returned 1 proposal, not 3 — `diffToBlockHunks` was merging adjacent changed
|
||||
blocks into one gap-span run. Fixed by treating `changed` blocks as 1:1 anchors
|
||||
(each → its own block-aligned hunk; gap-spans only span add/remove runs).
|
||||
4. **Verified + shipped** (214 unit, 73/5 E2E), self-reviewed, PR #51 merged,
|
||||
#46 closed → **cluster complete**; memory + transcript updated.
|
||||
|
||||
## Deferred decisions
|
||||
|
||||
_Autonomous-mode low-confidence calls the driver made and would have
|
||||
liked operator input on. Empty if none._
|
||||
|
||||
- _No low-confidence calls this session._ (The `diffToBlockHunks` adjacency
|
||||
behavior was a bug caught by the accept-all E2E, not a judgment call.)
|
||||
@@ -0,0 +1,95 @@
|
||||
# Session 0046.0 — Transcript
|
||||
|
||||
> App: vscode-cowriting-plugin
|
||||
> Start: 2026-06-13T08-19 (PST)
|
||||
> Type: planning-and-executing
|
||||
> End: 2026-06-13T08-31 (PST)
|
||||
> Status: **FINALIZED.**
|
||||
> Posture: autonomous (yolo)
|
||||
|
||||
## Launch prompt
|
||||
|
||||
```
|
||||
/goal plan-and-execute #48 (pinning the baseline leaves the review panel fully un-annotated — zero-diff → no F3 authorship colors on unchanged blocks; proposals still show)
|
||||
|
||||
```
|
||||
|
||||
## Plan
|
||||
|
||||
**#48 (story, P2)** — pinning the baseline leaves the review panel fully
|
||||
un-annotated. Anchor: leaf `story` → §4.3 R2 (no design gate). Picked
|
||||
autonomously as the next backlog item after the document-edit-flow cluster shipped
|
||||
(0043/0044/0045).
|
||||
|
||||
When `diffBlocks(baseline, current)` yields all-`unchanged` ops (zero diff — the
|
||||
state right after a pin), the F10 on-render still author-colors every block
|
||||
(`colorByAuthor`), so the panel looks painted instead of clean. Fix: in that
|
||||
zero-diff case render clean (no author coloring, no change marks) while keeping
|
||||
`data-src` mapping (INV-36) and still injecting pending proposals (proposals are
|
||||
actions, not annotations). Narrow edge case of INV-33 — with-changes render
|
||||
unchanged; off-state unchanged; broader "authorship never colors unchanged" NOT
|
||||
in scope.
|
||||
|
||||
Tasks:
|
||||
1. `trackChangesModel.ts` `renderReview` — detect `ops.every(unchanged)`; in that
|
||||
case use a plain `render` (skip `colorByAuthor`) for blocks; proposal injection
|
||||
loop unchanged.
|
||||
2. Unit: baseline==current + author spans → no `cw-by-claude`/`cw-by-human` (and
|
||||
no `cw-add`/`cw-del`) on the body; with a pending proposal → the `cw-proposal`
|
||||
block still renders.
|
||||
3. Host E2E: open preview, diverge + author-color, pin → panel clean (no
|
||||
green/blue); edit again → annotations return.
|
||||
4. Content repo: one-line INV-33 clarification (zero-diff → clean on-render) in
|
||||
`specs/coauthoring-interactive-review.md`.
|
||||
|
||||
No new persisted artifact; no deploy pipeline (VS Code extension).
|
||||
|
||||
## Results
|
||||
|
||||
**#48 (story, P2) shipped to `main`** — PR
|
||||
[#52](https://git.benstull.org/benstull/vscode-cowriting-plugin/pulls/52)
|
||||
(merged), issue #48 closed. Picked autonomously after the document-edit-flow
|
||||
cluster (0043/0044/0045).
|
||||
|
||||
- `trackChangesModel.ts` — `renderReview` gains a `pinned` `RenderOption`; when
|
||||
pinned + zero-diff, blocks render plain (skip `colorByAuthor`).
|
||||
- `trackChangesPreview.ts` — pass `{ pinned: baseline?.reason === "pinned" }`
|
||||
from `refresh` + `renderHtmlFor`.
|
||||
- Unit (4 new) + `s48PinClean` host E2E.
|
||||
|
||||
**Scoped to the pin specifically** (not all zero-diff): a baseline advanced by a
|
||||
**machine-landing** (accept) is also zero-diff but keeps its authorship coloring
|
||||
(F10 INV-33) — the F10 authorship E2E caught a pure-zero-diff rule would regress
|
||||
accepted-Claude-text coloring, so the clean render is gated on `reason ===
|
||||
"pinned"`.
|
||||
|
||||
Verification: `tsc --noEmit` clean; **218 unit** green; **74/5 host E2E** green.
|
||||
|
||||
## Session arc
|
||||
|
||||
1. **Pick + claim.** Stop hook required determining/executing the next milestone
|
||||
autonomously (rolling `next`); chose #48 (leaf story, no design gate) and
|
||||
claimed 0046. Clean `main`.
|
||||
2. **Read the issue** (detailed, gave the solution shape) + `renderReview`.
|
||||
3. **TDD.** Implemented zero-diff-clean; full suite caught the F10 authorship
|
||||
regression (accept advances baseline → zero-diff → coloring was being cleared);
|
||||
re-scoped to `reason === "pinned"` via a `pinned` RenderOption → all green.
|
||||
4. **Shipped** (PR #52), closed #48; spec clarification written but left in the
|
||||
content-repo working tree (see Deferred decisions).
|
||||
|
||||
## Deferred decisions
|
||||
|
||||
_Autonomous-mode low-confidence calls the driver made and would have
|
||||
liked operator input on. Empty if none._
|
||||
|
||||
- **INV-33 clarification not pushed to the content repo** (loose end, not a
|
||||
judgment call). Wrote the zero-diff-after-pin clarification into
|
||||
`specs/coauthoring-interactive-review.md`, but the **content repo has
|
||||
pre-existing uncommitted state that isn't this session's**: a modified
|
||||
`coauthoring-diff-view.md` and ~18 untracked capture-session draft files
|
||||
(`issues/*.md`, `specs/coauthoring-document-edit-flow.md`), and local `main` is
|
||||
**6 behind origin**. A clean rebase would require deleting the operator's
|
||||
untracked drafts (irreversible — a STOP gate), so I **soft-reset** my spec
|
||||
commit into the working tree rather than force it. The clarification sits as an
|
||||
uncommitted modification alongside the operator's other content-repo drafts,
|
||||
for the operator to reconcile/push. The #48 **code** shipped normally.
|
||||
@@ -0,0 +1,86 @@
|
||||
# Session 0047.0 — Transcript
|
||||
|
||||
> App: vscode-cowriting-plugin
|
||||
> Start: 2026-06-13T08-34 (PST)
|
||||
> Type: planning-and-executing
|
||||
> End: 2026-06-13T08-44 (PST)
|
||||
> Status: **FINALIZED.**
|
||||
> Posture: autonomous (yolo)
|
||||
|
||||
## Launch prompt
|
||||
|
||||
```
|
||||
/goal plan-and-execute #33 (intra-emphasis sentinel hardening — token-aware fix for the 2 characterized failure modes)
|
||||
|
||||
```
|
||||
|
||||
## Plan
|
||||
|
||||
**#33 (task, P3)** — harden the F9/F10 author-coloring PUA sentinels against
|
||||
intra-emphasis markdown. Anchor: leaf `task` → §4.3 R2 (no design gate). Picked
|
||||
autonomously (next clean plan-and-executable backlog item; doesn't touch the
|
||||
content repo). Approach = the token-aware fix recommended in the issue #33 comment.
|
||||
|
||||
Two characterized failure modes (issue #33 comment, session 0032):
|
||||
- **CASE1** — a span boundary lands strictly inside a delimiter run (`a**b**c`,
|
||||
boundary between the two `*`): the injected sentinel splits `**` → markdown parse
|
||||
breaks (stray `<em></em>`, raw `**` left).
|
||||
- **CASE3** — a span boundary inside an emphasis run (`**bold**`, span covers
|
||||
`**bo`): emphasis renders but the author `<span>` and `<strong>` **misnest**
|
||||
(`<strong>bo</span>ld</strong>`).
|
||||
|
||||
Fix (both needed):
|
||||
1. `injectSentinels` — **clamp** any sentinel offset that lands strictly inside a
|
||||
markdown delimiter run (`* _ ~ \``) to the run's start, so a sentinel never
|
||||
splits a delimiter (fixes CASE1). Skip now-zero-width spans.
|
||||
2. `sentinelsToSpans` — replace the naive split/join with a **token-aware walker**
|
||||
over the rendered HTML: emit `cw-by-*` spans only around TEXT runs, closing the
|
||||
span before any `<tag>` and reopening after, so a span never crosses an element
|
||||
boundary (fixes CASE3 — one span segment per text run). Strip any stray sentinel
|
||||
left inside a tag (no PUA leakage).
|
||||
|
||||
Pure/vscode-free/deterministic (INV-33). Non-goals: link/attribute sentinel cases,
|
||||
visual language, attribution model.
|
||||
|
||||
Tasks: unit tests reproducing CASE1 + CASE3 (+ regression on existing
|
||||
colorByAuthor/renderReview cases) → implement clamp + walker → green; spec already
|
||||
notes the hardening (§1.7/§9). No deploy pipeline (extension).
|
||||
|
||||
## Results
|
||||
|
||||
**#33 (task, P3) shipped to `main`** — PR
|
||||
[#53](https://git.benstull.org/benstull/vscode-cowriting-plugin/pulls/53)
|
||||
(merged), issue #33 closed. Picked autonomously (next clean plan-and-executable
|
||||
leaf; doesn't touch the content repo).
|
||||
|
||||
- `trackChangesModel.ts` `injectSentinels` — clamp any sentinel offset landing
|
||||
strictly inside a delimiter run (`* _ ~ \``) to the run's start (fixes CASE1
|
||||
parse-break); drop spans that clamp to empty.
|
||||
- `trackChangesModel.ts` `sentinelsToSpans` — token-aware walker emitting the
|
||||
`cw-by-*` span only around text runs, split at every `<tag>` boundary (fixes
|
||||
CASE3 misnest); strays stripped (no PUA leak).
|
||||
- 4 new unit tests (CASE1/CASE3/CASE2-regression/no-leak), real markdown-it via
|
||||
`renderReview`.
|
||||
|
||||
Verification: `tsc --noEmit` clean; **222 unit** green; **74/5 host E2E** green;
|
||||
the F10/authorship E2E (`cw-by-claude`/`cw-by-human`) still pass (common case
|
||||
byte-identical).
|
||||
|
||||
## Session arc
|
||||
|
||||
1. Stop hook required autonomously determining/executing the next milestone;
|
||||
chose #33 (leaf task, no content-repo dependency). Claimed 0047, clean `main`.
|
||||
2. Read issue #33 + its investigation comment (2 failure modes, recommended
|
||||
token-aware approach) + session 0032 characterization + the sentinel code.
|
||||
3. TDD: CASE1/CASE3 reproduced red → implemented clamp + walker → green; full
|
||||
suite + E2E green; self-reviewed (one pure module).
|
||||
4. Shipped (PR #53), closed #33.
|
||||
|
||||
## Deferred decisions
|
||||
|
||||
_Autonomous-mode low-confidence calls the driver made and would have
|
||||
liked operator input on. Empty if none._
|
||||
|
||||
- _No low-confidence calls this session._ (Approach was the one recommended in the
|
||||
issue #33 comment; the fix is a pure-module robustness change with full test
|
||||
coverage and no regression.)
|
||||
@@ -0,0 +1,90 @@
|
||||
# Session 0048.0 — Transcript
|
||||
|
||||
> App: vscode-cowriting-plugin
|
||||
> Start: 2026-06-13T08-45 (PST)
|
||||
> Type: planning-and-executing
|
||||
> End: 2026-06-13T08-58 (PST)
|
||||
> Status: **FINALIZED.**
|
||||
> Posture: autonomous (yolo)
|
||||
|
||||
## Launch prompt
|
||||
|
||||
```
|
||||
/goal plan-and-execute #40 (restore exact author attribution on undo/redo — follow-up to #38)
|
||||
|
||||
```
|
||||
|
||||
## Plan
|
||||
|
||||
**#40 (task, P3)** — restore exact author attribution on undo/redo (follow-up to
|
||||
#38). Anchor: leaf `task` → §4.3 R2 (no design gate). Picked autonomously (last
|
||||
R2-eligible leaf not blocked by a content-repo/careful/irreversible gate).
|
||||
|
||||
#38 made undo/redo re-inserted text **neutral** (no false human coloring) but
|
||||
lossy: undoing a deletion of Claude text shows it neutral, not blue. #40 restores
|
||||
the **exact prior** attribution.
|
||||
|
||||
**Mechanism (engineering choice): text-keyed attribution snapshots.** Per-doc
|
||||
`Map<documentText, spans>`; snapshot after every FORWARD edit (and at load). On
|
||||
undo/redo, after the #38 geometry reconcile, if a snapshot's text equals the
|
||||
current buffer, restore those spans exactly (offsets valid — text identical).
|
||||
Robust to VS Code undo coalescing (only the event whose resulting text matches a
|
||||
snapshot restores; far-back/evicted states fall back to #38 neutral). Bounded
|
||||
history.
|
||||
|
||||
Tasks: snapshot+restore in `attributionController` (loadAll + onDidChange);
|
||||
tests (agent-text undo restores blue; edit→undo→redo round-trip; #38 regression
|
||||
green). No deploy pipeline (extension).
|
||||
|
||||
## Results
|
||||
|
||||
**#40 implemented but NOT shipped — verification-blocked.** On branch
|
||||
`s40-undo-provenance` (pushed, unmerged); issue #40 **kept open**.
|
||||
|
||||
- `attributionController.ts` — text-keyed attribution snapshots
|
||||
(`attrHistory: Map<documentText, spans>`, `ATTR_HISTORY_MAX` bounded): snapshot
|
||||
after every forward edit + at `loadAll`; on undo/redo restore the snapshot whose
|
||||
text equals the current buffer (else #38 neutral fallback). Robust to undo
|
||||
coalescing.
|
||||
- `test/e2e/suite/s40Provenance.test.ts` — agent-text-undo-restores-blue +
|
||||
edit→undo→redo round-trip.
|
||||
- **222 unit + typecheck green.**
|
||||
|
||||
**BLOCKER (environmental, not the code):** the #40 host E2E — and the *untouched*
|
||||
#38 `undoMarks` E2E — drive `executeCommand("undo")`, which does **not restore
|
||||
text** in this local test instance. Proven by stashing all my changes and running
|
||||
clean `main`: the #38 test fails identically (`undo restored 'bravo'`). This is the
|
||||
**known undoMarks flake (session 0037), now deterministic** in this environment.
|
||||
The usual remedy — clearing `.vscode-test/user-data` — is **permission-blocked**
|
||||
this session (`rm -rf` denied). Focusing the doc before `undo` (`showTextDocument`)
|
||||
did not help. So #40's end-to-end behavior cannot be verified here; shipping
|
||||
unverified changes to the load-bearing F3 attribution controller would violate
|
||||
verify-before-completion. Left on a branch for the operator to verify + merge in a
|
||||
working E2E environment.
|
||||
|
||||
**Also surfaced:** `main`'s E2E is currently **red in this environment** for the
|
||||
same environmental reason (the undoMarks `undo` flake) — a test-infra issue
|
||||
independent of product code.
|
||||
|
||||
## Session arc
|
||||
|
||||
1. Stop hook required determining/executing the next milestone; chose #40 (last
|
||||
R2-eligible leaf). Claimed 0048, clean `main`.
|
||||
2. Read #40 + #38 + the attribution change handler; chose text-keyed snapshots.
|
||||
3. TDD: wrote #40 E2E + implemented snapshot/restore; 222 unit green.
|
||||
4. E2E: 3 undo-driven tests failed at the `undo restored X` step. Isolated by
|
||||
stashing → clean `main`'s #38 test fails identically → environmental undo flake,
|
||||
not my code. Could not clear `.vscode-test` (permission-blocked).
|
||||
5. Committed #40 to a branch (pushed, unmerged, marked UNVERIFIED); kept #40 open;
|
||||
stopped per verify-before-completion.
|
||||
|
||||
## Deferred decisions
|
||||
|
||||
_Autonomous-mode low-confidence calls the driver made and would have
|
||||
liked operator input on. Empty if none._
|
||||
|
||||
- **Did not merge #40** (driver call). Alternative: merge on unit-green + reasoning
|
||||
alone. Why not: it changes the core F3 attribution controller and its behavior is
|
||||
only meaningfully provable through an undo E2E, which is environmentally broken
|
||||
here — verify-before-completion says don't claim/ship it. Preserved on a branch
|
||||
for operator verification instead. (Reversible: just merge once verified.)
|
||||
@@ -0,0 +1,61 @@
|
||||
# Session 0049.0 — Transcript
|
||||
|
||||
> App: vscode-cowriting-plugin
|
||||
> Start: 2026-06-13T09-19 (PST)
|
||||
> Type: planning-and-executing
|
||||
> End: 2026-06-13T09-24 (PST)
|
||||
> Status: **FINALIZED.**
|
||||
> Posture: autonomous (yolo)
|
||||
|
||||
## Launch prompt
|
||||
|
||||
```
|
||||
/goal plan-and-execute: pretest:e2e cleans stale compiled tests in out/test (stale *.test.js from other branches were running via the glob) — build hygiene follow-up to #54
|
||||
|
||||
```
|
||||
|
||||
## Plan
|
||||
|
||||
Build-hygiene follow-up to #54 (noted on that issue). `tsc -p tsconfig.e2e.json`
|
||||
emits to `out/` but never removes outputs for test sources absent on the current
|
||||
branch, so stale compiled `out/test/e2e/suite/*.test.js` from other branches get
|
||||
run by the suite glob (`**/*.test.js`) — this caused real cross-branch test
|
||||
confusion in session 0048 (a removed probe + the s40 branch's tests ran on an
|
||||
unrelated branch). Fix: `pretest:e2e` cleans `out/test` before recompiling.
|
||||
|
||||
- `package.json` — add `clean:e2e` (node `fs.rmSync('out/test', {recursive,force})`
|
||||
— avoids shell `rm` issues) and run it between `build` and `tsc` in `pretest:e2e`.
|
||||
Clean ONLY `out/test` (NOT `out/`, which holds the just-built esbuild bundle).
|
||||
- Verify: introduce a stale `out/test/.../zz.test.js`, run `pretest:e2e`, confirm
|
||||
it's gone + the E2E suite is green.
|
||||
|
||||
Trivial, ungated, verifiable; test-infra only. No deploy pipeline (extension).
|
||||
|
||||
## Results
|
||||
|
||||
**Shipped to `main`** — PR #56 (merged). `package.json`: new `clean:e2e`
|
||||
(`fs.rmSync('out/test',{recursive,force})`) run between `build` and `tsc` in
|
||||
`pretest:e2e`. Cleans only `out/test` (never the esbuild bundle in `out/`).
|
||||
Verified: a planted stale `out/test/.../zz.test.js` is removed by `pretest:e2e`;
|
||||
E2E green (73 passing + 1 pending [#38 undo-skip], both passes exit 0). Test-infra
|
||||
only; no product code.
|
||||
|
||||
Properly tracked under this session (0049) — closing the protocol gap where
|
||||
#54/#55 merged after 0048 had finalized.
|
||||
|
||||
## Session arc
|
||||
|
||||
1. Stop hook pushed me to execute the one remaining ungated/verifiable item (the
|
||||
`out/`-clean follow-up I'd noted on #54). Claimed 0049 to track it cleanly.
|
||||
2. Confirmed `tsc` outDir → `out/test`; esbuild bundle → `out/extension.cjs`
|
||||
(separate), so cleaning `out/test` is safe.
|
||||
3. Implemented `clean:e2e`; verified by planting a stale compiled test (removed)
|
||||
+ full E2E green. Shipped PR #56.
|
||||
|
||||
## Deferred decisions
|
||||
|
||||
_Autonomous-mode low-confidence calls the driver made and would have
|
||||
liked operator input on. Empty if none._
|
||||
|
||||
- _No low-confidence calls this session._ (Cleaning stale build output is
|
||||
unambiguously correct; scoped to `out/test` to protect the esbuild bundle.)
|
||||
@@ -0,0 +1,76 @@
|
||||
# Session 0050.0 — Transcript
|
||||
|
||||
> App: vscode-cowriting-plugin
|
||||
> Start: 2026-06-13T17-43 (PST)
|
||||
> End: 2026-06-13T17-52 (PST)
|
||||
> Type: capture
|
||||
> Posture: autonomous (yolo)
|
||||
> Status: **FINALIZED**
|
||||
|
||||
## Launch prompt
|
||||
|
||||
`/wgl-capture` — "When changing documents, we should decide what happens to the
|
||||
review pane of the current document, and if the document switched to should get a
|
||||
review experience or not"
|
||||
|
||||
## Pre-state
|
||||
|
||||
- Branch `main`, clean, pushed (origin/main). No in-flight sessions for the app.
|
||||
- Tracker `benstull/vscode-cowriting-plugin` (host `git.benstull.org`); content
|
||||
repo `vscode-cowriting-plugin-content` cloned, with ~18 prior uncommitted
|
||||
capture drafts in `issues/`.
|
||||
- Prior frontier exhausted (session 0047 note): remaining backlog items gated;
|
||||
operator directing. This is a capture session, not a build.
|
||||
|
||||
## Arc
|
||||
|
||||
1. **Claimed** tracked-lite session ID **0050** (`claim-session-id.sh --type
|
||||
capture`). Resolved app + content repo (`resolve-app.py`).
|
||||
2. **Grounded** the ask by reading the code (Explore subagent over
|
||||
`src/trackChangesPreview.ts`, `diffViewController.ts`, `proposalController.ts`):
|
||||
confirmed the review pane is one-panel-per-doc keyed by URI
|
||||
(`trackChangesPreview.ts:45`) with **no** `onDidChangeActiveTextEditor`
|
||||
listener — so on document switch the pane **stays pinned** to its original doc
|
||||
(incidental, not designed) and the switched-to doc gets no review until
|
||||
`showTrackChangesPreview` is re-invoked. Per-doc review state (F6 baseline / F4
|
||||
proposals / F3 attribution) auto-creates on demand.
|
||||
3. **Sized** the single ask: genuine forks (follow / pin / close; auto-review /
|
||||
on-demand) + needs design before build → `type/feature` (R3), `priority/P2`.
|
||||
Captures the decision-to-be-made; option space goes in Solution notes,
|
||||
non-binding.
|
||||
4. **Drafted** `issues/review-pane-on-document-switch.md` in the content repo
|
||||
(working tree only, INV-8), full §5 template. Scanned clean for secrets
|
||||
(INV-3).
|
||||
5. **Operator approved** filing as-is (feature, P2) via AskUserQuestion.
|
||||
6. **Filed** → ensured labels (all pre-existing), then `capture-issues.sh` →
|
||||
**#57** (https://git.benstull.org/benstull/vscode-cowriting-plugin/issues/57).
|
||||
|
||||
## Cut state
|
||||
|
||||
- Session repo `vscode-cowriting-plugin`: clean `main`, nothing committed this
|
||||
session (capture touches only the content repo working tree). No PRs.
|
||||
- Content repo: new draft `issues/review-pane-on-document-switch.md` left
|
||||
uncommitted for the Author to publish/discard (INV-8), alongside the prior
|
||||
drafts already there. Not pushed by this skill.
|
||||
- Issue **#57** filed and open on the tracker.
|
||||
|
||||
## Deferred decisions
|
||||
|
||||
_None — single clear ask, operator approved the framing and type before filing._
|
||||
|
||||
## Operator plate
|
||||
|
||||
- One feature filed: **#57** (review-pane behavior on document switch, P2).
|
||||
- ~19 capture drafts now sit uncommitted in `vscode-cowriting-plugin-content` —
|
||||
yours to commit/publish (or discard) when convenient.
|
||||
- #57 needs a design before build (R3). No active plan frontier; operator to
|
||||
direct next.
|
||||
|
||||
## Next session prompt
|
||||
|
||||
`/goal` — operator to direct. Candidate: brainstorm a Solution Design for **#57**
|
||||
(review-pane behavior on document switch) — settle the two coupled rules (outgoing
|
||||
pane fate; whether the switched-to doc auto-gets a review experience) before
|
||||
building. Other open: OQ-2 (F11 graduation), #32 (scroll-sync, needs design),
|
||||
#35 (repo rename), #40 (undo provenance, P3, branch `s40-undo-provenance`
|
||||
unmerged), #54 (undo still broken in sandbox).
|
||||
@@ -0,0 +1,71 @@
|
||||
# Session 0051.0 — Transcript
|
||||
|
||||
> App: vscode-cowriting-plugin
|
||||
> Start: 2026-06-13T17-49 (PST)
|
||||
> End: 2026-06-13T17-58 (PST)
|
||||
> Type: capture
|
||||
> Posture: autonomous (yolo)
|
||||
> Status: **FINALIZED**
|
||||
|
||||
## Launch prompt
|
||||
|
||||
`/wgl-capture` — two asks:
|
||||
1. "Undo doesn't undo Claude's edits"
|
||||
2. "When I make a change within a block that Claude has changed that I haven't
|
||||
approved, it doesn't show my changes"
|
||||
|
||||
## Pre-state
|
||||
|
||||
- Branch `main`, clean, pushed. Immediately followed capture session 0050 (#57).
|
||||
- Tracker `benstull/vscode-cowriting-plugin` (host `git.benstull.org`); content
|
||||
repo cloned.
|
||||
|
||||
## Arc
|
||||
|
||||
1. **Claimed** tracked-lite session ID **0051**.
|
||||
2. **Grounded** both asks in code (Explore subagent):
|
||||
- Undo: Claude's edits are pending proposals; `proposalController.ts:303-310`
|
||||
shifts anchors on edit but ignores `e.reason === Undo` — proposal not
|
||||
reconciled on undo (accepted edits hit the doc and are undoable, but the
|
||||
pending proposal lingers).
|
||||
- Pending-block edits: a proposal freezes its "before" (`replaced: fp.text`,
|
||||
`proposalController.ts:81-95`); the block renders from current text but the
|
||||
proposal's frozen view (`trackChangesModel.ts:706-722`/`:769-805`) obscures
|
||||
live human edits in that block.
|
||||
3. **Checked duplication** against the undo cluster — #38 (wrong marks, closed),
|
||||
#40 (attribution color, open), #54 (undo E2E infra, open). Both new asks are
|
||||
distinct (undo failing to *reverse* the edit; live edits obscured by a pending
|
||||
proposal). Verified `type/bug` exists on the tracker.
|
||||
4. **Drafted** both as `type/bug` (P1) in the content repo working tree
|
||||
(`issues/undo-does-not-undo-claude-edits.md`,
|
||||
`issues/edits-in-pending-block-not-shown.md`), each framed as user-facing pain
|
||||
with repro steps + code diagnosis demoted to parenthetical. Scanned clean for
|
||||
secrets (INV-3).
|
||||
5. **Operator triage:** before filing, operator said "ignore both of these
|
||||
issues — you can delete the drafts." Both drafts **deleted**; nothing filed.
|
||||
|
||||
## Cut state
|
||||
|
||||
- **Nothing filed** (INV-4 — no-actionable outcome after operator triage).
|
||||
- Both draft files removed from the content repo working tree.
|
||||
- Session repo `vscode-cowriting-plugin`: clean `main`, no commits this session.
|
||||
|
||||
## Deferred decisions
|
||||
|
||||
_None — operator explicitly directed dropping both asks._
|
||||
|
||||
## Operator plate
|
||||
|
||||
- No issues filed this session. The two undo/pending-block asks were
|
||||
considered and intentionally dropped (recorded in memory
|
||||
`session-0051-capture-no-actionable.md` so they aren't re-raised as new).
|
||||
- Note: these remain *real* observed behaviors per the code reading — dropped on
|
||||
operator triage, not because they were invalid. If they resurface, the prior
|
||||
grounding is in the memory note.
|
||||
|
||||
## Next session prompt
|
||||
|
||||
`/goal` — operator to direct. From session 0050: candidate is brainstorming a
|
||||
Solution Design for **#57** (review-pane behavior on document switch). Other
|
||||
open: OQ-2 (F11 graduation), #32 (scroll-sync), #35 (repo rename), #40 (undo
|
||||
provenance, P3, branch `s40-undo-provenance` unmerged), #54 (undo E2E infra).
|
||||
@@ -0,0 +1,73 @@
|
||||
# Session 0052.0 — Transcript
|
||||
|
||||
> App: vscode-cowriting-plugin
|
||||
> Start: 2026-06-15T08-33 (PST)
|
||||
> End: 2026-06-15T08-41 (PST)
|
||||
> Type: capture
|
||||
> Posture: autonomous (yolo)
|
||||
> Status: **FINALIZED**
|
||||
|
||||
## Launch prompt
|
||||
|
||||
`/wgl-capture` — two asks (second arrived mid-session):
|
||||
1. "the review window and markdown source file should have scroll location sync'd"
|
||||
2. "the claude change recommendation block (which user will accept or decline)
|
||||
should show the diff with the original"
|
||||
|
||||
## Pre-state
|
||||
|
||||
- Branch `main`, clean, pushed. Follows capture sessions 0050 (#57) and 0051
|
||||
(no-actionable).
|
||||
- Tracker `benstull/vscode-cowriting-plugin` (host `git.benstull.org`).
|
||||
|
||||
## Arc
|
||||
|
||||
**Ask 1 — scroll-sync (duplicate, nothing filed):**
|
||||
1. Claimed tracked-lite session ID **0052**.
|
||||
2. Recognized scroll-sync as a known F10 follow-up; fetched **#32** — exact match
|
||||
(*"Scroll-sync the review preview with the source editor"*, open,
|
||||
`type/feature`, `priority/P3`, filed session 0031).
|
||||
3. Surfaced to operator; operator chose to **leave #32 at P3**. No new issue
|
||||
(INV-4 duplicate).
|
||||
|
||||
**Ask 2 — proposal block diff vs original (filed #58):**
|
||||
4. Grounded in code (Explore): the pending proposal block renders original +
|
||||
proposed as **two separate full blocks** (`<del>` whole-before + `<ins>`
|
||||
whole-after, `trackChangesModel.ts:715-716`) with **no word-level diff** — the
|
||||
changed-block rendering already uses `wordMergedMarkdown`/`diffWords`
|
||||
(`trackChangesModel.ts:431-438`) but `proposalBlockHtml()` doesn't.
|
||||
`ProposalView` already carries `replaced`+`replacement`
|
||||
(`proposalController.ts:81-95`).
|
||||
5. Sized `type/story`, P2 (reuses existing word-diff helper; distinct from #31
|
||||
placement / #47 granularity). Drafted
|
||||
`issues/proposal-block-shows-diff-with-original.md` (working tree only, secrets
|
||||
scanned).
|
||||
6. Operator approved as-is → ensured labels → filed **#58**
|
||||
(https://git.benstull.org/benstull/vscode-cowriting-plugin/issues/58).
|
||||
|
||||
## Cut state
|
||||
|
||||
- **#58** filed (story, P2). Scroll-sync left as existing **#32** (P3) — nothing
|
||||
new filed for it.
|
||||
- Draft `issues/proposal-block-shows-diff-with-original.md` left uncommitted in
|
||||
the content repo for the Author to publish (INV-8).
|
||||
- Session repo `vscode-cowriting-plugin`: clean `main`, no commits this session.
|
||||
|
||||
## Deferred decisions
|
||||
|
||||
_None — operator directly resolved the duplicate and approved the #58 framing._
|
||||
|
||||
## Operator plate
|
||||
|
||||
- One issue filed: **#58** (proposal block word-diff, P2).
|
||||
- Scroll-sync remains **#32** (P3, open, unchanged).
|
||||
- One uncommitted capture draft added to the content repo (joins the prior
|
||||
drafts) — yours to publish or discard.
|
||||
|
||||
## Next session prompt
|
||||
|
||||
`/goal` — operator to direct. Standing candidate (from 0050): brainstorm a
|
||||
Solution Design for **#57** (review-pane behavior on document switch). Open work:
|
||||
#58 (proposal word-diff, P2, story), #32 (scroll-sync, P3), OQ-2 (F11
|
||||
graduation), #35 (repo rename), #40 (undo provenance, P3, branch
|
||||
`s40-undo-provenance` unmerged), #54 (undo E2E infra).
|
||||
@@ -0,0 +1,66 @@
|
||||
# Session 0053.0 — Transcript
|
||||
|
||||
> App: vscode-cowriting-plugin
|
||||
> Start: 2026-06-15T10-23 (PST)
|
||||
> End: 2026-06-15T10-29 (PST)
|
||||
> Type: capture
|
||||
> Posture: autonomous (yolo)
|
||||
> Status: **FINALIZED**
|
||||
|
||||
## Launch prompt
|
||||
|
||||
`/wgl-capture` — "The plugin is asking for access to other applications but works
|
||||
fine when I decline. It just shouldn't"
|
||||
|
||||
## Pre-state
|
||||
|
||||
- Branch `main`, clean, pushed. Follows capture sessions 0050 (#57), 0051
|
||||
(no-actionable), 0052 (#58 + scroll-sync dup).
|
||||
- Tracker `benstull/vscode-cowriting-plugin` (host `git.benstull.org`).
|
||||
|
||||
## Arc
|
||||
|
||||
1. Claimed tracked-lite session ID **0053**.
|
||||
2. **Investigated** the macOS Automation/Apple-Events trigger (Explore): the
|
||||
extension's own source has **no** AppleScript/`osascript`/automation calls; the
|
||||
probable origin is **`@cline/sdk`/`@cline/core`** during agent activation
|
||||
(likely local Claude Code hub-discovery), which falls back gracefully when
|
||||
denied — matching "works fine when declined." Framed as a lead, not a settled
|
||||
root cause.
|
||||
3. **Sized** `type/bug` (declared defect: unwanted OS permission request).
|
||||
Drafted `issues/spurious-automation-permission-prompt.md` (working tree only,
|
||||
secrets scanned) with repro steps + expected/actual + the upstream caveat.
|
||||
4. **Operator set priority P1** (trust/launch-optics over the harmless functional
|
||||
impact); updated the WSJF line accordingly.
|
||||
5. **Filed #59.** capture-issues.sh `--type` rejects `bug` (known #124 taxonomy
|
||||
gap), so filed with `--type task` then swapped the label to `type/bug` via the
|
||||
Gitea API (deleted type/task, added type/bug) — verified `['priority/P1',
|
||||
'type/bug']` (INV-2 holds).
|
||||
→ https://git.benstull.org/benstull/vscode-cowriting-plugin/issues/59
|
||||
|
||||
## Cut state
|
||||
|
||||
- **#59** filed (bug, P1), label corrected to exactly `type/bug`.
|
||||
- Draft `issues/spurious-automation-permission-prompt.md` left uncommitted in the
|
||||
content repo for the Author to publish (INV-8).
|
||||
- Session repo `vscode-cowriting-plugin`: clean `main`, no commits this session.
|
||||
|
||||
## Deferred decisions
|
||||
|
||||
_None — operator set the priority directly and approved the framing._
|
||||
|
||||
## Operator plate
|
||||
|
||||
- One issue filed: **#59** (spurious macOS automation prompt, bug, **P1**).
|
||||
- The cause is likely upstream in `@cline/sdk` — the fix may be a config/flag or
|
||||
dependency update, not necessarily this repo's code.
|
||||
- Reminder: bug capture needs the file-as-task-then-relabel workaround until
|
||||
plugin #124 (capture can't type bugs) is fixed.
|
||||
|
||||
## Next session prompt
|
||||
|
||||
`/goal` — operator to direct. Standing candidate (from 0050): brainstorm a
|
||||
Solution Design for **#57** (review-pane behavior on document switch). Open work:
|
||||
**#59** (automation prompt, bug P1 — may be upstream), #58 (proposal word-diff,
|
||||
story P2), #32 (scroll-sync, P3), OQ-2 (F11 graduation), #35 (repo rename), #40
|
||||
(undo provenance, P3), #54 (undo E2E infra).
|
||||
@@ -0,0 +1,66 @@
|
||||
# Session 0054.0 — Transcript
|
||||
|
||||
> App: vscode-cowriting-plugin
|
||||
> Start: 2026-06-15T10-42 (PST)
|
||||
> End: 2026-06-15T10-48 (PST)
|
||||
> Type: capture
|
||||
> Posture: autonomous (yolo)
|
||||
> Status: **FINALIZED**
|
||||
|
||||
## Launch prompt
|
||||
|
||||
`/wgl-capture` — "See the Claude output/progress in the 'asking Claude…' status"
|
||||
|
||||
## Pre-state
|
||||
|
||||
- Branch `main`, clean, pushed. Follows capture sessions 0050 (#57), 0051
|
||||
(no-actionable), 0052 (#58 + scroll-sync dup), 0053 (#59).
|
||||
- Tracker `benstull/vscode-cowriting-plugin` (host `git.benstull.org`).
|
||||
|
||||
## Arc
|
||||
|
||||
1. Claimed tracked-lite session ID **0054**.
|
||||
2. **Grounded** (Explore): the "Cowriting: asking Claude…" status is an opaque
|
||||
`withProgress` notification (`extension.ts:232-233`,
|
||||
`trackChangesPreview.ts:232-233`) awaiting `agent.run()` as one black-box
|
||||
promise (`liveTurn.ts:52`). Key enabler: `@cline/sdk` already emits streaming
|
||||
events (`assistant-text-delta`, `tool-started/updated/finished`,
|
||||
`usage-updated`) via `agent.subscribe()` / an `onEvent` hook, but the extension
|
||||
constructs the Agent with **no hooks** (`liveTurn.ts:47-51`) and discards it.
|
||||
3. **Sized** `type/feature` — implementable by subscribing to existing events, but
|
||||
a real design fork on the surface (notification text vs. OutputChannel vs.
|
||||
status bar vs. webview relay) and content (text/tool/usage/reasoning) → design
|
||||
first (R3). Drafted `issues/show-live-claude-progress.md` (working tree only,
|
||||
secrets scanned).
|
||||
4. **Operator set priority** — chose "adjust priority" → **P1** (opaque wait hurts
|
||||
every turn). Updated WSJF line.
|
||||
5. **Filed #60** (`type/feature`, P1).
|
||||
→ https://git.benstull.org/benstull/vscode-cowriting-plugin/issues/60
|
||||
|
||||
## Cut state
|
||||
|
||||
- **#60** filed (feature, P1).
|
||||
- Draft `issues/show-live-claude-progress.md` left uncommitted in the content repo
|
||||
for the Author to publish (INV-8).
|
||||
- Session repo `vscode-cowriting-plugin`: clean `main`, no commits this session.
|
||||
|
||||
## Deferred decisions
|
||||
|
||||
_None — operator set the priority directly and approved the framing._
|
||||
|
||||
## Operator plate
|
||||
|
||||
- One issue filed: **#60** (live Claude progress, feature, **P1**).
|
||||
- Implementation is largely "subscribe to SDK events already available + pick the
|
||||
progress surface" — needs a small design first (R3).
|
||||
- One uncommitted capture draft added to the content repo — yours to publish or
|
||||
discard.
|
||||
|
||||
## Next session prompt
|
||||
|
||||
`/goal` — operator to direct. Capture run 0050–0054 filed #57, #58, #59, #60
|
||||
(scroll-sync = existing #32). Two P1s now open (**#59** automation prompt,
|
||||
**#60** live progress) plus standing #57 (review-pane on doc switch, design
|
||||
candidate). Other open: #58 (proposal word-diff, P2), #32 (scroll-sync P3), OQ-2
|
||||
(F11 graduation), #35 (repo rename), #40 (undo provenance P3), #54 (undo E2E
|
||||
infra).
|
||||
@@ -0,0 +1,105 @@
|
||||
# Session 0055.0 — Transcript
|
||||
|
||||
> App: vscode-cowriting-plugin
|
||||
> Start: 2026-06-22T23-19 (PST)
|
||||
> End: 2026-06-26T04-23 (PST)
|
||||
> Type: brainstorming
|
||||
> Posture: autonomous (yolo)
|
||||
> Status: **FINALIZED**
|
||||
|
||||
## Launch prompt
|
||||
|
||||
`/wgl-brainstorming highest priority ticket`
|
||||
|
||||
## Plan
|
||||
|
||||
Brainstorming session: explore the highest-priority open ticket and write its
|
||||
Solution-Design spec. Highest-priority that fits a brainstorming session (spec
|
||||
output; a feature needs a design per §4.3 R3) was **#60 — Show Claude's live
|
||||
output/progress during the "asking Claude…" status** (P1 feature). #59 (P1 bug)
|
||||
is coding-session work, not brainstorming.
|
||||
|
||||
Output: `specs/coauthoring-live-progress.md` (Solution Design), submitted graduated
|
||||
at finalize to the content repo's `specs/` collection.
|
||||
|
||||
## Pre-state
|
||||
|
||||
- Clean, pushed `main` (`24e329e`). No in-flight sessions (next ID 0055).
|
||||
- Two P1 tickets tied for highest priority: **#59** (P1 bug — spurious macOS
|
||||
"control other applications" prompt) and **#60** (P1 feature — live turn
|
||||
progress). Brainstorming produces a spec; a feature needs a design (§4.3 R3),
|
||||
so #60 was the fit. #59 (bug) → a coding session.
|
||||
- Highest INV in use across the content-repo specs: **INV-42**.
|
||||
|
||||
## Session arc (turn-by-turn)
|
||||
|
||||
1. **Gate + classify.** Launch prompt classified as **brainstorming**; ran
|
||||
`wgl-brainstorming`.
|
||||
2. **Claim (peek → gate → claim).** `claim-session-id.sh --dry-run` → no in-flight
|
||||
sessions, next ID **0055**. Claimed `--type brainstorming` (placeholder at
|
||||
`16cca30`). Verified clean pushed `main` baseline.
|
||||
3. **Orient.** Surveyed the open tracker. Picked **#60** (P1 feature, design
|
||||
needed) over #59 (P1 bug, coding-session work). Read #60 in full.
|
||||
4. **Ground in code (read-only).** Read `liveTurn.ts` (`runEditTurn` →
|
||||
`agent.run()` as one opaque promise; module is deliberately vscode-free), both
|
||||
call sites (`extension.ts:232` editSelection, `trackChangesPreview.ts:232`
|
||||
preview `askClaude` — both wrap the turn in `withProgress("asking Claude…")`),
|
||||
the injectable `editTurn` seam (trackChangesPreview.ts:56, for host-E2E
|
||||
stubbing), and the `@cline/sdk` event API: `@cline/agents` `Agent` exposes
|
||||
`subscribe(listener) → unsubscribe`, `run()`, `abort()`; `AgentRuntimeEvent`
|
||||
(in `@cline/shared/dist/agent.d.ts`) carries `assistant-text-delta`
|
||||
(+`accumulatedText`), `tool-started|updated|finished`, `usage-updated`,
|
||||
lifecycle events. The enabler the issue cites is real.
|
||||
5. **Brainstorm forks (superpowers:brainstorming).** Skipped the visual companion
|
||||
(choices are conceptual/native-UI, not visual mockups). Presented three forks
|
||||
via AskUserQuestion; operator picked all three recommendations:
|
||||
- **Surface** → notification activity-line + token count **and** a shared
|
||||
`"Cowriting"` OutputChannel streaming full assistant text. (Rejected: webview
|
||||
relay can't cover the editSelection path; status-bar-only; OutputChannel-
|
||||
primary.)
|
||||
- **Content** → activity + token count (reasoning text not surfaced).
|
||||
- **Cancellation** → `cancellable` notification → `agent.abort()` →
|
||||
"cancelled", proposes nothing (reflect + cancel button).
|
||||
6. **Design presented + approved.** Three-unit architecture (pure
|
||||
`turnProgress.ts` reducer → `runEditTurn` extended with `onProgress` +
|
||||
`AbortSignal` → both call sites relay via a shared `liveProgressUi`); layering
|
||||
rule keeps `liveTurn.ts`/`turnProgress.ts` vscode-free; INV-43..47. Two
|
||||
sub-decisions (OutputChannel auto-reveal gated by a new setting; append-not-
|
||||
clear) confirmed. Operator: "design looks right."
|
||||
7. **Spec written + self-review.** `specs/coauthoring-live-progress.md` authored
|
||||
in house Solution-Design format. Self-review: no placeholders, INV-43..47 (no
|
||||
collision with ≤42; INV-8/21/39 are correct citations), internally consistent,
|
||||
single-feature scope.
|
||||
8. **Operator: "Implement it."** Per the pipeline, that's the brainstorm→coding
|
||||
handoff (one SPEC = one plan = one execution, §4.3). Finalized this
|
||||
brainstorming session (below); a fresh `wgl-planning-and-executing` session
|
||||
plans + builds #60.
|
||||
|
||||
## Cut state (at finalize)
|
||||
|
||||
- **Spec graduated.** `submit-spec.sh --status graduated` →
|
||||
`vscode-cowriting-plugin-content` `specs/coauthoring-live-progress.md` at
|
||||
`3bd1ae5`.
|
||||
- **Code repo:** clean `main`; no code changes this session (brainstorming).
|
||||
A local stray `specs/coauthoring-live-progress.md` remains untracked in the code
|
||||
repo (an `rm` cleanup was permission-denied; harmless — canonical copy is in the
|
||||
content repo).
|
||||
- **Memory:** added `session-0055-live-progress-spec-graduated.md` + index line.
|
||||
|
||||
## Next-session prompt
|
||||
|
||||
```
|
||||
/wgl-planning-and-executing implement #60 (live turn progress) from coauthoring-live-progress.md
|
||||
```
|
||||
|
||||
## Deferred decisions
|
||||
|
||||
- **OutputChannel auto-reveal** (fires every Claude turn): decided to auto-`show(true)`
|
||||
(preserveFocus) on the *first* text delta, gated by a new setting
|
||||
`cowriting.liveProgress.revealOutput` (default `true`). Operator confirmed the
|
||||
design including this.
|
||||
- **OutputChannel history:** decided to *append* per-turn (with a header) rather
|
||||
than clear, so it doubles as a debug log. Operator confirmed.
|
||||
- **Stray local spec file:** `rm -rf specs/` was permission-denied; left the
|
||||
untracked local copy in the code repo (cosmetic; content repo holds the
|
||||
canonical copy).
|
||||
+5
-8
@@ -1,20 +1,17 @@
|
||||
# Session 0045.0 — Transcript
|
||||
# Session 0056.0 — Transcript
|
||||
|
||||
> App: vscode-cowriting-plugin
|
||||
> Start: 2026-06-13T08-04 (PST)
|
||||
> Start: 2026-06-26T04-24 (PST)
|
||||
> Type: planning-and-executing
|
||||
> Status: **PLACEHOLDER — claimed at session start; finalized at session end.**
|
||||
>
|
||||
> This file reserves session ID 0045 for vscode-cowriting-plugin. The driver replaces this
|
||||
> This file reserves session ID 0056 for vscode-cowriting-plugin. The driver replaces this
|
||||
> body with the full transcript and renames the file to its final
|
||||
> SESSION-0045.0-TRANSCRIPT-2026-06-13T08-04--<end>.md form at session end.
|
||||
> SESSION-0056.0-TRANSCRIPT-2026-06-26T04-24--<end>.md form at session end.
|
||||
|
||||
## Launch prompt
|
||||
|
||||
```
|
||||
/goal plan-and-execute #46 (SLICE-3 of the document-edit flow — accept-all, INV-42), per specs/coauthoring-document-edit-flow.md
|
||||
|
||||
```
|
||||
_(launch prompt not captured at claim time)_
|
||||
|
||||
## Deferred decisions
|
||||
|
||||
@@ -133,5 +133,38 @@
|
||||
},
|
||||
"0045": {
|
||||
"title": ""
|
||||
},
|
||||
"0046": {
|
||||
"title": ""
|
||||
},
|
||||
"0047": {
|
||||
"title": ""
|
||||
},
|
||||
"0048": {
|
||||
"title": ""
|
||||
},
|
||||
"0049": {
|
||||
"title": ""
|
||||
},
|
||||
"0050": {
|
||||
"title": ""
|
||||
},
|
||||
"0051": {
|
||||
"title": ""
|
||||
},
|
||||
"0052": {
|
||||
"title": ""
|
||||
},
|
||||
"0053": {
|
||||
"title": ""
|
||||
},
|
||||
"0054": {
|
||||
"title": ""
|
||||
},
|
||||
"0055": {
|
||||
"title": ""
|
||||
},
|
||||
"0056": {
|
||||
"title": ""
|
||||
}
|
||||
}
|
||||
|
||||
+30
-3
@@ -11,6 +11,7 @@ import { GlobalSidecarStore } from "./globalSidecarStore";
|
||||
import { SidecarRouter } from "./sidecarRouter";
|
||||
import { DiffViewController } from "./diffViewController";
|
||||
import { TrackChangesPreviewController } from "./trackChangesPreview";
|
||||
import { LiveProgressUi } from "./liveProgressUi";
|
||||
import { isAuthorable, selectionRejection } from "./workspacePath";
|
||||
|
||||
const CHANNEL_NAME = "Cowriting (Cline SDK)";
|
||||
@@ -23,12 +24,18 @@ export interface CowritingApi {
|
||||
diffViewController: DiffViewController;
|
||||
trackChangesPreviewController: TrackChangesPreviewController;
|
||||
sidecarRouter: SidecarRouter;
|
||||
liveProgressUi: LiveProgressUi;
|
||||
}
|
||||
|
||||
export function activate(context: vscode.ExtensionContext): CowritingApi | undefined {
|
||||
// --- POC command (Feature #2), unchanged ---
|
||||
const output = vscode.window.createOutputChannel(CHANNEL_NAME);
|
||||
context.subscriptions.push(output);
|
||||
|
||||
// #60: shared live-progress UI (notification activity line + "Cowriting: Claude"
|
||||
// OutputChannel) for both Ask-Claude entry points.
|
||||
const liveProgressUi = new LiveProgressUi();
|
||||
context.subscriptions.push(liveProgressUi);
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("cowriting.showClineSdkInfo", async () => {
|
||||
try {
|
||||
@@ -104,6 +111,7 @@ export function activate(context: vscode.ExtensionContext): CowritingApi | undef
|
||||
context.extensionUri,
|
||||
attributionController,
|
||||
proposalController,
|
||||
liveProgressUi,
|
||||
);
|
||||
context.subscriptions.push(trackChangesPreviewController);
|
||||
|
||||
@@ -230,10 +238,28 @@ export function activate(context: vscode.ExtensionContext): CowritingApi | undef
|
||||
const turnId = `turn-${Date.now().toString(36)}`;
|
||||
try {
|
||||
await vscode.window.withProgress(
|
||||
{ location: vscode.ProgressLocation.Notification, title: "Cowriting: asking Claude…" },
|
||||
async () => {
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: "Cowriting: asking Claude…",
|
||||
cancellable: true,
|
||||
},
|
||||
async (progress, token) => {
|
||||
const { runEditTurn } = await import("./liveTurn");
|
||||
const turn = await runEditTurn(instruction, selectedText);
|
||||
const ui = liveProgressUi.begin(instruction, progress, token);
|
||||
let turn;
|
||||
try {
|
||||
turn = await runEditTurn(instruction, selectedText, {
|
||||
onProgress: ui.onProgress,
|
||||
signal: ui.signal,
|
||||
});
|
||||
} catch (err) {
|
||||
// #60 (INV-47): a user cancel surfaces as "cancelled", not a failure.
|
||||
if (token.isCancellationRequested) {
|
||||
void vscode.window.showInformationMessage("Cowriting: Claude edit cancelled.");
|
||||
return;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
if (turn.replacement === "") {
|
||||
void vscode.window.showWarningMessage(
|
||||
"Cowriting: Claude returned an empty replacement — nothing was proposed.",
|
||||
@@ -292,6 +318,7 @@ export function activate(context: vscode.ExtensionContext): CowritingApi | undef
|
||||
diffViewController,
|
||||
trackChangesPreviewController,
|
||||
sidecarRouter,
|
||||
liveProgressUi,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* liveProgressUi.ts — host-side relay of TurnProgress snapshots to VS Code UI
|
||||
* (#60, spec coauthoring-live-progress.md §3.4). The ONLY surfaces are the
|
||||
* existing withProgress notification (an activity line) and a dedicated
|
||||
* OutputChannel streaming the full assistant text — no new network/webview
|
||||
* surface (INV-45). vscode-only; all pure logic lives in turnProgress.ts.
|
||||
*/
|
||||
import * as vscode from "vscode";
|
||||
import { formatProgressLine, type TurnProgressSnapshot } from "./turnProgress";
|
||||
|
||||
const CHANNEL_NAME = "Cowriting: Claude";
|
||||
|
||||
export interface TurnUi {
|
||||
/** Pass to runEditTurn's opts.onProgress. */
|
||||
onProgress: (snapshot: TurnProgressSnapshot) => void;
|
||||
/** Pass to runEditTurn's opts.signal — fired when the user cancels the notification. */
|
||||
signal: AbortSignal;
|
||||
}
|
||||
|
||||
export class LiveProgressUi {
|
||||
readonly channel: vscode.OutputChannel;
|
||||
|
||||
constructor() {
|
||||
this.channel = vscode.window.createOutputChannel(CHANNEL_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin one turn's UI. Writes the per-turn header to the channel and returns
|
||||
* the onProgress relay + an AbortSignal linked to the notification's cancel
|
||||
* token. The channel APPENDS (it doubles as a debug log of recent turns, spec
|
||||
* §3.5); it auto-reveals (without stealing focus) on the first streamed text,
|
||||
* gated by `cowriting.liveProgress.revealOutput`.
|
||||
*/
|
||||
begin(
|
||||
instruction: string,
|
||||
progress: vscode.Progress<{ message?: string }>,
|
||||
token: vscode.CancellationToken,
|
||||
): TurnUi {
|
||||
const controller = new AbortController();
|
||||
token.onCancellationRequested(() => controller.abort());
|
||||
this.channel.appendLine(`── asking: ${instruction} ──`);
|
||||
|
||||
let revealed = false;
|
||||
const reveal = (): void => {
|
||||
if (revealed) return;
|
||||
revealed = true;
|
||||
const cfg = vscode.workspace.getConfiguration("cowriting");
|
||||
if (cfg.get<boolean>("liveProgress.revealOutput", true)) this.channel.show(true);
|
||||
};
|
||||
|
||||
const onProgress = (s: TurnProgressSnapshot): void => {
|
||||
progress.report({ message: formatProgressLine(s) });
|
||||
if (s.textDelta) {
|
||||
this.channel.append(s.textDelta);
|
||||
reveal();
|
||||
}
|
||||
};
|
||||
|
||||
return { onProgress, signal: controller.signal };
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.channel.dispose();
|
||||
}
|
||||
}
|
||||
+61
-11
@@ -9,6 +9,9 @@
|
||||
* never bundled (esbuild keeps it external).
|
||||
*/
|
||||
|
||||
import type { TurnProgressSnapshot } from "./turnProgress";
|
||||
import { createTurnProgressState, reduceTurnProgress } from "./turnProgress";
|
||||
|
||||
export interface EditTurnResult {
|
||||
replacement: string;
|
||||
model: string;
|
||||
@@ -16,6 +19,19 @@ export interface EditTurnResult {
|
||||
sessionId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for runEditTurn. Both new fields are purely additive observability /
|
||||
* control over the existing turn (INV-44): `onProgress` streams reduced progress
|
||||
* snapshots out; `signal` cancels the turn in. Neither touches the result path,
|
||||
* and neither pulls `vscode` into this module (INV-43 — `AbortSignal` is a web
|
||||
* standard, the progress snapshot is a domain type).
|
||||
*/
|
||||
export interface RunEditTurnOptions {
|
||||
modelId?: string;
|
||||
onProgress?: (snapshot: TurnProgressSnapshot) => void;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
|
||||
const SYSTEM_PROMPT = [
|
||||
"You are a precise text editor embedded in VS Code.",
|
||||
"You will be given a piece of text and an instruction.",
|
||||
@@ -40,7 +56,7 @@ export function extractReplacement(outputText: string, selectedText: string): st
|
||||
export async function runEditTurn(
|
||||
instruction: string,
|
||||
selectedText: string,
|
||||
opts?: { modelId?: string },
|
||||
opts?: RunEditTurnOptions,
|
||||
): Promise<EditTurnResult> {
|
||||
const sdk = await import("@cline/sdk");
|
||||
const modelId = opts?.modelId ?? "sonnet";
|
||||
@@ -49,16 +65,50 @@ export async function runEditTurn(
|
||||
modelId,
|
||||
systemPrompt: SYSTEM_PROMPT,
|
||||
});
|
||||
const result = await agent.run(
|
||||
`<instruction>\n${instruction}\n</instruction>\n<text>\n${selectedText}\n</text>`,
|
||||
);
|
||||
// The SDK's AgentRunResult.status union is "completed" | "aborted" | "failed"
|
||||
// (@cline/shared agent.d.ts) — "completed" is the success status.
|
||||
if (result.status !== "completed") {
|
||||
throw new Error(
|
||||
`claude-code turn ${result.status}: ${result.error?.message ?? "unknown error"} ` +
|
||||
"(is Claude Code installed and signed in?)",
|
||||
|
||||
// Stream reduced progress snapshots out (INV-44 additive) and wire cancellation
|
||||
// in via the AbortSignal (INV-47). agent.subscribe returns its unsubscribe fn.
|
||||
let state = createTurnProgressState();
|
||||
const unsubscribe = opts?.onProgress
|
||||
? agent.subscribe((event) => {
|
||||
const next = reduceTurnProgress(state, event);
|
||||
state = next.state;
|
||||
// Observability must never affect the result (INV-44): a throwing relay
|
||||
// is swallowed, not allowed to propagate into the SDK and fail the turn.
|
||||
if (next.snapshot) {
|
||||
try {
|
||||
opts.onProgress!(next.snapshot);
|
||||
} catch {
|
||||
/* progress is best-effort */
|
||||
}
|
||||
}
|
||||
})
|
||||
: undefined;
|
||||
const onAbort = () => agent.abort();
|
||||
opts?.signal?.addEventListener("abort", onAbort);
|
||||
|
||||
try {
|
||||
// A signal already aborted before the turn starts can't be honored by
|
||||
// agent.abort() (the SDK's AbortController isn't created until run()), so
|
||||
// short-circuit to the same aborted outcome the call site reflects (INV-47).
|
||||
if (opts?.signal?.aborted) {
|
||||
throw new Error("claude-code turn aborted: cancelled before start");
|
||||
}
|
||||
const result = await agent.run(
|
||||
`<instruction>\n${instruction}\n</instruction>\n<text>\n${selectedText}\n</text>`,
|
||||
);
|
||||
// The SDK's AgentRunResult.status union is "completed" | "aborted" | "failed"
|
||||
// (@cline/shared agent.d.ts) — "completed" is the success status. An aborted
|
||||
// turn (user cancel) falls into this throw; the call site reflects "cancelled".
|
||||
if (result.status !== "completed") {
|
||||
throw new Error(
|
||||
`claude-code turn ${result.status}: ${result.error?.message ?? "unknown error"} ` +
|
||||
"(is Claude Code installed and signed in?)",
|
||||
);
|
||||
}
|
||||
return { replacement: extractReplacement(result.outputText, selectedText), model: modelId, sessionId: result.runId };
|
||||
} finally {
|
||||
unsubscribe?.();
|
||||
opts?.signal?.removeEventListener("abort", onAbort);
|
||||
}
|
||||
return { replacement: extractReplacement(result.outputText, selectedText), model: modelId, sessionId: result.runId };
|
||||
}
|
||||
|
||||
+102
-10
@@ -441,6 +441,14 @@ function wordMergedMarkdown(beforeRaw: string, afterRaw: string): string {
|
||||
export interface RenderOptions {
|
||||
/** Per-block markdown→HTML renderer (test seam). Defaults to the bundled markdown-it. */
|
||||
render?: (src: string) => string;
|
||||
/**
|
||||
* #48: the baseline was just PINNED (`reason === "pinned"`). With zero changes
|
||||
* since that pin, the on-render is fully clean — no authorship coloring — so a
|
||||
* pin reads as "this is my clean starting point". Distinct from a baseline
|
||||
* advanced by a machine-landing (accept), which keeps its authorship coloring
|
||||
* (F10 INV-33). Only consulted by `renderReview`.
|
||||
*/
|
||||
pinned?: boolean;
|
||||
}
|
||||
|
||||
function defaultRender(src: string): string {
|
||||
@@ -537,13 +545,33 @@ function authorBadge(authors: Set<AuthorKind>): { cls: string; label: string } |
|
||||
: { cls: "cw-by-human", label: "You" };
|
||||
}
|
||||
|
||||
// Markdown emphasis / code delimiters whose RUNS must never be split by an
|
||||
// injected sentinel — a sentinel between two run chars (e.g. `*|*`) breaks
|
||||
// markdown-it's delimiter pairing (#33 CASE1).
|
||||
const isDelimChar = (c: string): boolean => c === "*" || c === "_" || c === "~" || c === "`";
|
||||
|
||||
/**
|
||||
* #33 (CASE1): a sentinel must not land STRICTLY INSIDE a delimiter run. If `at`
|
||||
* sits between two identical delimiter chars, snap it to the run's start (a
|
||||
* position outside the run) so the run stays intact. Delimiters are invisible once
|
||||
* rendered, so snapping only shifts the colored boundary across markup, never over
|
||||
* visible text.
|
||||
*/
|
||||
function clampOffDelimiterRun(raw: string, at: number): number {
|
||||
if (at <= 0 || at >= raw.length) return at;
|
||||
if (!(isDelimChar(raw[at]) && raw[at - 1] === raw[at])) return at;
|
||||
let p = at;
|
||||
while (p > 0 && raw[p - 1] === raw[at]) p--;
|
||||
return p;
|
||||
}
|
||||
|
||||
/** Inject paired sentinels into a prose block's raw text for the spans clipped to it. */
|
||||
function injectSentinels(raw: string, blockStart: number, spans: AuthorSpan[]): string {
|
||||
const inserts: { at: number; marker: string }[] = [];
|
||||
for (const s of spans) {
|
||||
const lo = Math.max(0, s.start - blockStart);
|
||||
const hi = Math.min(raw.length, s.end - blockStart);
|
||||
if (hi <= lo) continue;
|
||||
const lo = clampOffDelimiterRun(raw, Math.max(0, s.start - blockStart));
|
||||
const hi = clampOffDelimiterRun(raw, Math.min(raw.length, s.end - blockStart));
|
||||
if (hi <= lo) continue; // empty (or clamped to empty) span contributes nothing
|
||||
inserts.push({ at: lo, marker: SENT[s.author].open });
|
||||
inserts.push({ at: hi, marker: SENT[s.author].close });
|
||||
}
|
||||
@@ -556,13 +584,69 @@ function injectSentinels(raw: string, blockStart: number, spans: AuthorSpan[]):
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Replace the rendered sentinels with author <span> tags. */
|
||||
const SENTINEL_OF: Record<string, { author: AuthorKind; open: boolean } | undefined> = {
|
||||
[SENT.claude.open]: { author: "claude", open: true },
|
||||
[SENT.claude.close]: { author: "claude", open: false },
|
||||
[SENT.human.open]: { author: "human", open: true },
|
||||
[SENT.human.close]: { author: "human", open: false },
|
||||
};
|
||||
const ALL_SENTINELS = new RegExp(
|
||||
`[${SENT.claude.open}${SENT.claude.close}${SENT.human.open}${SENT.human.close}]`,
|
||||
"g",
|
||||
);
|
||||
|
||||
/**
|
||||
* #33: token-aware replacement of the rendered author sentinels with `cw-by-*`
|
||||
* spans. A naive global string-replace (the old approach) could emit a span that
|
||||
* CROSSES an element boundary — `<span><strong>bo</span>ld</strong>` — when a
|
||||
* boundary fell inside an emphasis run (CASE3). This walks the rendered HTML and
|
||||
* emits the author span only around TEXT runs, CLOSING it before any `<tag>` and
|
||||
* REOPENING it after, so a span is always well-nested within the inline elements
|
||||
* (one `<span>` segment per text run). Tags are copied verbatim (with any stray
|
||||
* sentinel stripped, so no Private-Use-Area char ever leaks). Pure, deterministic.
|
||||
*/
|
||||
function sentinelsToSpans(html: string): string {
|
||||
return html
|
||||
.split(SENT.claude.open).join('<span class="cw-by-claude">')
|
||||
.split(SENT.claude.close).join("</span>")
|
||||
.split(SENT.human.open).join('<span class="cw-by-human">')
|
||||
.split(SENT.human.close).join("</span>");
|
||||
const out: string[] = [];
|
||||
let current: AuthorKind | null = null; // which author region we're inside
|
||||
let spanOpen = false; // whether a <span> is currently open in `out`
|
||||
const openSpan = () => {
|
||||
if (current && !spanOpen) {
|
||||
out.push(`<span class="cw-by-${current}">`);
|
||||
spanOpen = true;
|
||||
}
|
||||
};
|
||||
const closeSpan = () => {
|
||||
if (spanOpen) {
|
||||
out.push("</span>");
|
||||
spanOpen = false;
|
||||
}
|
||||
};
|
||||
for (let i = 0; i < html.length; i++) {
|
||||
const ch = html[i];
|
||||
const sentinel = SENTINEL_OF[ch];
|
||||
if (sentinel) {
|
||||
if (sentinel.open) current = sentinel.author; // span opens lazily before the next text char
|
||||
else {
|
||||
closeSpan();
|
||||
current = null;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (ch === "<") {
|
||||
// An HTML tag: never let an author span straddle it (text `<` is escaped to
|
||||
// <, so a raw `<` is always a real tag). Copy the tag verbatim, sentinel-free.
|
||||
closeSpan();
|
||||
const gt = html.indexOf(">", i);
|
||||
const end = gt === -1 ? html.length - 1 : gt;
|
||||
out.push(html.slice(i, end + 1).replace(ALL_SENTINELS, ""));
|
||||
i = end;
|
||||
continue;
|
||||
}
|
||||
openSpan();
|
||||
out.push(ch);
|
||||
}
|
||||
closeSpan();
|
||||
return out.join("");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -673,6 +757,14 @@ export function renderReview(
|
||||
const render = opts.render ?? defaultRender;
|
||||
const ranges = splitBlocksWithRanges(currentText);
|
||||
const ops = diffBlocks(baselineText, currentText);
|
||||
// #48: right after a PIN (baseline reason "pinned") with no changes since, the
|
||||
// panel is fully clean: no change marks (already absent) AND no authorship
|
||||
// coloring, so the pin reads as "this is my clean starting point". Skip
|
||||
// colorByAuthor for every block in this case; data-src mapping and any pending
|
||||
// proposals (review actions, not annotations) are kept below. A baseline advanced
|
||||
// by a machine-landing (accept) is ALSO zero-diff but is NOT pinned — it keeps
|
||||
// its authorship coloring (F10 INV-33), so this is gated on the pin specifically.
|
||||
const clean = opts.pinned === true && ops.every((o) => o.kind === "unchanged");
|
||||
|
||||
// Associate each resolved proposal with the current-side block index whose range
|
||||
// it anchors into: the largest block with start <= anchorStart (the containing
|
||||
@@ -703,7 +795,7 @@ export function renderReview(
|
||||
const blockIndex = op.kind === "removed" ? -1 : ci;
|
||||
const blk = op.kind === "removed" ? undefined : ranges[ci++];
|
||||
const colored = (raw: string): string =>
|
||||
blk ? colorByAuthor(raw, blk.start, authorSpans, render) : render(raw);
|
||||
blk && !clean ? colorByAuthor(raw, blk.start, authorSpans, render) : render(raw);
|
||||
bodyParts.push(renderReviewOp(op, render, colored, srcAttr(blk)));
|
||||
const here = blockIndex >= 0 ? byBlock.get(blockIndex) : undefined;
|
||||
if (here) for (const p of here) bodyParts.push(proposalBlockHtml(p, render));
|
||||
|
||||
+34
-10
@@ -16,10 +16,15 @@ import type { ProposalController } from "./proposalController";
|
||||
import { renderReview, renderPlain, diffBlocks, diffToBlockHunks, type BlockOp } from "./trackChangesModel";
|
||||
import { buildFingerprint } from "./anchorer";
|
||||
import { isAuthorable } from "./workspacePath";
|
||||
import type { EditTurnResult } from "./liveTurn";
|
||||
import type { EditTurnResult, RunEditTurnOptions } from "./liveTurn";
|
||||
import type { LiveProgressUi } from "./liveProgressUi";
|
||||
|
||||
/** F11: a host edit turn (selection/document text + instruction → rewrite). Injectable for tests. */
|
||||
type EditTurn = (instruction: string, text: string) => Promise<EditTurnResult>;
|
||||
/**
|
||||
* F11: a host edit turn (selection/document text + instruction → rewrite).
|
||||
* Injectable for tests. #60: accepts optional turn options (onProgress/signal);
|
||||
* the arg is optional so existing test stubs that ignore it stay valid.
|
||||
*/
|
||||
type EditTurn = (instruction: string, text: string, opts?: RunEditTurnOptions) => Promise<EditTurnResult>;
|
||||
/** F11: what an Ask-Claude gesture edits — a resolved selection range, or the whole document. */
|
||||
type EditTarget = { kind: "range"; start: number; end: number } | { kind: "document" };
|
||||
|
||||
@@ -53,9 +58,9 @@ export class TrackChangesPreviewController implements vscode.Disposable {
|
||||
* F11: the host edit turn (INV-8 — runs host-side, @cline/sdk loaded lazily and
|
||||
* never bundled). Injectable so host E2E can stub it (no LLM in CI).
|
||||
*/
|
||||
private editTurn: EditTurn = async (instruction, text) => {
|
||||
private editTurn: EditTurn = async (instruction, text, opts) => {
|
||||
const { runEditTurn } = await import("./liveTurn");
|
||||
return runEditTurn(instruction, text);
|
||||
return runEditTurn(instruction, text, opts);
|
||||
};
|
||||
/** Monotonic per-session counter minting a stable turnId for each Ask-Claude gesture. */
|
||||
private turnSeq = 0;
|
||||
@@ -68,6 +73,7 @@ export class TrackChangesPreviewController implements vscode.Disposable {
|
||||
private readonly extensionUri: vscode.Uri,
|
||||
private readonly attribution: AttributionController,
|
||||
private readonly proposals: ProposalController,
|
||||
private readonly liveProgressUi: LiveProgressUi,
|
||||
) {
|
||||
this.disposables.push(
|
||||
// F11 (SLICE-5): the editor/title gateway passes the tab's resource Uri;
|
||||
@@ -230,8 +236,24 @@ export class TrackChangesPreviewController implements vscode.Disposable {
|
||||
if (!instruction) return;
|
||||
try {
|
||||
const ids = await vscode.window.withProgress(
|
||||
{ location: vscode.ProgressLocation.Notification, title: "Cowriting: asking Claude…" },
|
||||
() => this.runEditAndPropose(document, target, instruction),
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: "Cowriting: asking Claude…",
|
||||
cancellable: true,
|
||||
},
|
||||
async (progress, token) => {
|
||||
const ui = this.liveProgressUi.begin(instruction, progress, token);
|
||||
try {
|
||||
return await this.runEditAndPropose(document, target, instruction, {
|
||||
onProgress: ui.onProgress,
|
||||
signal: ui.signal,
|
||||
});
|
||||
} catch (err) {
|
||||
// #60 (INV-47): a user cancel proposes nothing (the benign empty path).
|
||||
if (token.isCancellationRequested) return [] as string[];
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
);
|
||||
if (ids.length === 0) {
|
||||
void vscode.window.showInformationMessage("Cowriting: Claude proposed no changes.");
|
||||
@@ -258,6 +280,7 @@ export class TrackChangesPreviewController implements vscode.Disposable {
|
||||
document: vscode.TextDocument,
|
||||
target: EditTarget,
|
||||
instruction: string,
|
||||
opts?: RunEditTurnOptions,
|
||||
): Promise<string[]> {
|
||||
const full = document.getText();
|
||||
// One turnId per gesture — the document case's N hunk-proposals all share it,
|
||||
@@ -267,13 +290,13 @@ export class TrackChangesPreviewController implements vscode.Disposable {
|
||||
({ kind: "agent" as const, id: "claude", agent: { sdk: "@cline/sdk", model: turn.model, sessionId: turn.sessionId } });
|
||||
if (target.kind === "range") {
|
||||
const selected = full.slice(target.start, target.end);
|
||||
const turn = await this.editTurn(instruction, selected);
|
||||
const turn = await this.editTurn(instruction, selected, opts);
|
||||
if (turn.replacement === "" || turn.replacement === selected) return [];
|
||||
const fp = buildFingerprint(full, { start: target.start, end: target.end });
|
||||
const id = await this.proposals.propose(document, fp, turn.replacement, provenance(turn), { turnId, instruction });
|
||||
return id ? [id] : [];
|
||||
}
|
||||
const turn = await this.editTurn(instruction, full);
|
||||
const turn = await this.editTurn(instruction, full, opts);
|
||||
const ids: string[] = [];
|
||||
// #47 (INV-39, supersedes INV-37): a document rewrite is cut at BLOCK
|
||||
// granularity — one proposal per changed block (the unit a human reviews) —
|
||||
@@ -337,7 +360,7 @@ export class TrackChangesPreviewController implements vscode.Disposable {
|
||||
void panel.webview.postMessage({
|
||||
type: "render",
|
||||
mode,
|
||||
html: renderReview(baselineText, current, spans, proposals),
|
||||
html: renderReview(baselineText, current, spans, proposals, { pinned: baseline?.reason === "pinned" }),
|
||||
epoch: this.epochLabel(baseline),
|
||||
summary,
|
||||
authorable,
|
||||
@@ -464,6 +487,7 @@ export class TrackChangesPreviewController implements vscode.Disposable {
|
||||
current,
|
||||
this.attribution.spansFor(doc),
|
||||
this.proposals.listProposals(doc),
|
||||
{ pinned: baseline?.reason === "pinned" },
|
||||
);
|
||||
}
|
||||
/** F10: current annotations mode for a panel (default on). */
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* turnProgress.ts — pure reduction of @cline/sdk Agent runtime events into a
|
||||
* small UI-facing progress snapshot (#60, spec coauthoring-live-progress.md §3.2).
|
||||
*
|
||||
* INV-43: vscode-free. INV-46: a pure function — no vscode, no SDK runtime
|
||||
* dependency (`AgentRuntimeEvent` is imported TYPE-only, so it is erased at
|
||||
* compile and never pulls the ESM SDK into the bundle). All event→state logic
|
||||
* lives here so it is unit-tested in isolation; the UI call sites only format and
|
||||
* relay snapshots.
|
||||
*/
|
||||
import type { AgentRuntimeEvent } from "@cline/shared";
|
||||
|
||||
export type TurnPhase = "thinking" | "writing" | "tool";
|
||||
|
||||
export interface TurnProgressSnapshot {
|
||||
phase: TurnPhase;
|
||||
/** present iff phase === "tool" — the running tool's name. */
|
||||
tool?: string;
|
||||
/** accumulated assistant-text length so far. */
|
||||
chars: number;
|
||||
/** running total tokens (input+output); undefined until the first usage event. */
|
||||
tokens?: number;
|
||||
/** the new assistant-text chunk since the last snapshot (for the OutputChannel). */
|
||||
textDelta?: string;
|
||||
}
|
||||
|
||||
export interface TurnProgressState {
|
||||
phase: TurnPhase;
|
||||
chars: number;
|
||||
tokens?: number;
|
||||
/** stack of tool names currently running (depth-tracked for overlap). */
|
||||
activeTools: string[];
|
||||
/** true once any assistant text has streamed (tool-finish then reverts to writing). */
|
||||
sawText: boolean;
|
||||
}
|
||||
|
||||
export function createTurnProgressState(): TurnProgressState {
|
||||
return { phase: "thinking", chars: 0, tokens: undefined, activeTools: [], sawText: false };
|
||||
}
|
||||
|
||||
function restingPhase(state: TurnProgressState): TurnPhase {
|
||||
if (state.activeTools.length) return "tool";
|
||||
return state.sawText ? "writing" : "thinking";
|
||||
}
|
||||
|
||||
function toSnapshot(state: TurnProgressState, textDelta?: string): TurnProgressSnapshot {
|
||||
return {
|
||||
phase: state.phase,
|
||||
tool: state.phase === "tool" ? state.activeTools[state.activeTools.length - 1] : undefined,
|
||||
chars: state.chars,
|
||||
tokens: state.tokens,
|
||||
textDelta,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Fold one SDK event into the state, returning the next state and the snapshot to
|
||||
* emit (snapshot undefined for events that don't change the surface).
|
||||
*/
|
||||
export function reduceTurnProgress(
|
||||
state: TurnProgressState,
|
||||
event: AgentRuntimeEvent,
|
||||
): { state: TurnProgressState; snapshot?: TurnProgressSnapshot } {
|
||||
switch (event.type) {
|
||||
case "run-started":
|
||||
case "turn-started": {
|
||||
const next: TurnProgressState = { ...state, phase: restingPhase(state) };
|
||||
return { state: next, snapshot: toSnapshot(next) };
|
||||
}
|
||||
case "assistant-text-delta": {
|
||||
const next: TurnProgressState = {
|
||||
...state,
|
||||
phase: state.activeTools.length ? "tool" : "writing",
|
||||
chars: event.accumulatedText.length,
|
||||
sawText: true,
|
||||
};
|
||||
return { state: next, snapshot: toSnapshot(next, event.text) };
|
||||
}
|
||||
case "assistant-reasoning-delta": {
|
||||
// Reasoning TEXT is not surfaced (operator fork); collapse to motion only.
|
||||
const next: TurnProgressState = { ...state, phase: state.activeTools.length ? "tool" : "thinking" };
|
||||
return { state: next, snapshot: toSnapshot(next) };
|
||||
}
|
||||
case "tool-started": {
|
||||
const activeTools = [...state.activeTools, event.toolCall.toolName];
|
||||
const next: TurnProgressState = { ...state, phase: "tool", activeTools };
|
||||
return { state: next, snapshot: toSnapshot(next) };
|
||||
}
|
||||
case "tool-updated": {
|
||||
const next: TurnProgressState = { ...state, phase: "tool" };
|
||||
return { state: next, snapshot: toSnapshot(next) };
|
||||
}
|
||||
case "tool-finished": {
|
||||
const name = event.toolCall.toolName;
|
||||
const idx = state.activeTools.lastIndexOf(name);
|
||||
const activeTools = idx >= 0 ? state.activeTools.filter((_, i) => i !== idx) : state.activeTools.slice(0, -1);
|
||||
const next: TurnProgressState = { ...state, activeTools, phase: "thinking" };
|
||||
next.phase = restingPhase(next);
|
||||
return { state: next, snapshot: toSnapshot(next) };
|
||||
}
|
||||
case "usage-updated": {
|
||||
const tokens = event.usage.inputTokens + event.usage.outputTokens || undefined;
|
||||
const next: TurnProgressState = { ...state, tokens };
|
||||
return { state: next, snapshot: toSnapshot(next) };
|
||||
}
|
||||
default:
|
||||
return { state };
|
||||
}
|
||||
}
|
||||
|
||||
/** Render the notification activity line from a snapshot (pure; spec §2.1). */
|
||||
export function formatProgressLine(s: TurnProgressSnapshot): string {
|
||||
let head: string;
|
||||
if (s.phase === "tool") head = `running ${s.tool ?? "tool"}…`;
|
||||
else if (s.phase === "writing") head = `writing… (${s.chars} chars)`;
|
||||
else head = "thinking…";
|
||||
return s.tokens ? `${head} · ${formatTokens(s.tokens)} tokens` : head;
|
||||
}
|
||||
|
||||
export function formatTokens(n: number): string {
|
||||
return n >= 1000 ? `${(n / 1000).toFixed(1)}k` : String(n);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import * as assert from "assert";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as vscode from "vscode";
|
||||
import type { CowritingApi } from "../../../src/extension";
|
||||
|
||||
const WS = process.env.E2E_WORKSPACE!;
|
||||
const settle = () => new Promise((r) => setTimeout(r, 400));
|
||||
|
||||
async function getApi(): Promise<CowritingApi> {
|
||||
const ext = vscode.extensions.getExtension("benstull.vscode-cowriting-plugin")!;
|
||||
const api = (await ext.activate()) as CowritingApi;
|
||||
assert.ok(api?.trackChangesPreviewController, "exports preview controller");
|
||||
return api;
|
||||
}
|
||||
|
||||
async function freshDoc(rel: string, body: string): Promise<vscode.TextDocument> {
|
||||
const abs = path.join(WS, rel);
|
||||
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
||||
fs.writeFileSync(abs, body, "utf8");
|
||||
const doc = await vscode.workspace.openTextDocument(vscode.Uri.file(abs));
|
||||
await vscode.window.showTextDocument(doc);
|
||||
await settle();
|
||||
return doc;
|
||||
}
|
||||
|
||||
// #60 host E2E (no LLM): live progress is purely additive observability. The
|
||||
// harness can't read notification subtitles, so it asserts the CONTRACT —
|
||||
// progress events don't change the proposals (INV-44), and an aborted turn
|
||||
// proposes nothing (INV-47). The live notification/OutputChannel UI itself is
|
||||
// covered by the turnProgress unit tests + the manual smoke.
|
||||
suite("#60 live turn progress (additive + cancel)", () => {
|
||||
test("a stub that emits progress still produces the same proposals (INV-44)", async () => {
|
||||
const doc = await freshDoc("docs/live60-additive.md", "# Title\n\nOld paragraph.\n");
|
||||
const api = await getApi();
|
||||
const ctl = api.trackChangesPreviewController;
|
||||
await vscode.commands.executeCommand("cowriting.showTrackChangesPreview");
|
||||
await settle();
|
||||
|
||||
// The stub honors opts.onProgress (emitting synthetic snapshots) but returns
|
||||
// the same rewrite — proposals must be unaffected by progress events.
|
||||
ctl.setEditTurnForTest(async (_i, _text, opts) => {
|
||||
opts?.onProgress?.({ phase: "writing", chars: 5 });
|
||||
opts?.onProgress?.({ phase: "writing", chars: 13, tokens: 1234, textDelta: "New paragraph." });
|
||||
return { replacement: "# Title\n\nNew paragraph.\n", model: "sonnet", sessionId: "e2e-live60" };
|
||||
});
|
||||
|
||||
const ids = await ctl.runEditAndPropose(doc, { kind: "document" }, "rewrite the paragraph");
|
||||
await settle();
|
||||
assert.strictEqual(ids.length, 1, "one changed block → one proposal, regardless of progress events");
|
||||
const view = api.proposalController.listProposals(doc).find((v) => v.id === ids[0]);
|
||||
assert.ok(view, "the proposal is live");
|
||||
assert.ok(doc.getText().includes("Old paragraph."), "document unchanged by propose (INV-10)");
|
||||
});
|
||||
|
||||
test("an aborted turn proposes nothing (INV-47)", async () => {
|
||||
const doc = await freshDoc("docs/live60-cancel.md", "# Title\n\nOld paragraph.\n");
|
||||
const api = await getApi();
|
||||
const ctl = api.trackChangesPreviewController;
|
||||
await vscode.commands.executeCommand("cowriting.showTrackChangesPreview");
|
||||
await settle();
|
||||
|
||||
// The stub throws ONLY when the aborted signal reached it — so if opts.signal
|
||||
// failed to thread through runEditAndPropose, the stub would instead return a
|
||||
// rewrite and create a proposal, failing this test. That proves propagation.
|
||||
ctl.setEditTurnForTest(async (_i, _text, opts) => {
|
||||
if (opts?.signal?.aborted) throw new Error("claude-code turn aborted");
|
||||
return { replacement: "# Title\n\nSHOULD NOT BE PROPOSED.\n", model: "sonnet", sessionId: "e2e-live60-nope" };
|
||||
});
|
||||
|
||||
const ac = new AbortController();
|
||||
ac.abort();
|
||||
let ids: string[] = [];
|
||||
try {
|
||||
ids = await ctl.runEditAndPropose(doc, { kind: "document" }, "rewrite", { signal: ac.signal });
|
||||
} catch {
|
||||
ids = [];
|
||||
}
|
||||
await settle();
|
||||
assert.strictEqual(ids.length, 0, "aborted turn must create no proposals");
|
||||
assert.strictEqual(api.proposalController.listProposals(doc).length, 0, "no pending proposals after abort");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
import * as assert from "assert";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as vscode from "vscode";
|
||||
import type { CowritingApi } from "../../../src/extension";
|
||||
|
||||
const WS = process.env.E2E_WORKSPACE!;
|
||||
const settle = () => new Promise((r) => setTimeout(r, 400));
|
||||
|
||||
async function getApi(): Promise<CowritingApi> {
|
||||
const ext = vscode.extensions.getExtension("benstull.vscode-cowriting-plugin")!;
|
||||
const api = (await ext.activate()) as CowritingApi;
|
||||
assert.ok(api?.trackChangesPreviewController, "exports preview controller");
|
||||
return api;
|
||||
}
|
||||
|
||||
async function freshDoc(rel: string, body: string): Promise<{ doc: vscode.TextDocument; key: string }> {
|
||||
const abs = path.join(WS, rel);
|
||||
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
||||
fs.writeFileSync(abs, body, "utf8");
|
||||
const uri = vscode.Uri.file(abs);
|
||||
const doc = await vscode.workspace.openTextDocument(uri);
|
||||
await vscode.window.showTextDocument(doc);
|
||||
await settle();
|
||||
return { doc, key: uri.toString() };
|
||||
}
|
||||
|
||||
// #48 host E2E (no LLM): pinning the baseline leaves the review panel fully clean
|
||||
// — no authorship coloring on unchanged blocks — while re-divergence brings the
|
||||
// annotations back. The author colors are read from the on-state renderReview HTML.
|
||||
suite("S48 — pin → fully clean review panel (host E2E, no LLM)", () => {
|
||||
test("pin clears authorship coloring; a later edit brings annotations back", async () => {
|
||||
const { doc, key } = await freshDoc("docs/s48pin.md", "# S48\n\nAn original baseline paragraph.\n");
|
||||
const api = await getApi();
|
||||
const ctl = api.trackChangesPreviewController;
|
||||
await vscode.commands.executeCommand("cowriting.showTrackChangesPreview");
|
||||
await settle();
|
||||
|
||||
// Type a paragraph → a human attribution span + author coloring in the on-state.
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
edit.insert(doc.uri, doc.positionAt(doc.getText().length), "\n\nA freshly typed human paragraph.\n");
|
||||
assert.ok(await vscode.workspace.applyEdit(edit), "operator edit applied");
|
||||
await settle();
|
||||
assert.match(ctl.renderHtmlFor(key), /cw-by-human/, "typed text is author-colored before the pin");
|
||||
|
||||
// Pin the baseline → zero diff → the panel must be fully clean.
|
||||
ctl.receiveMessage(key, { type: "pinBaseline" });
|
||||
await settle();
|
||||
const pinned = ctl.renderHtmlFor(key);
|
||||
assert.ok(!pinned.includes("cw-by-human"), "no human authorship coloring after pin");
|
||||
assert.ok(!pinned.includes("cw-by-claude"), "no Claude authorship coloring after pin");
|
||||
assert.ok(!pinned.includes("cw-add") && !pinned.includes("cw-del"), "no change marks after pin");
|
||||
assert.match(pinned, /data-src-start/, "blocks still carry data-src offsets (INV-36 mapping kept)");
|
||||
assert.ok(pinned.includes("freshly typed human paragraph"), "the body text is still rendered, just plain");
|
||||
|
||||
// Edit again → there are changes since the pinned baseline → annotations return.
|
||||
const edit2 = new vscode.WorkspaceEdit();
|
||||
edit2.insert(doc.uri, doc.positionAt(doc.getText().length), "\n\nA second typed paragraph diverges again.\n");
|
||||
assert.ok(await vscode.workspace.applyEdit(edit2), "second operator edit applied");
|
||||
await settle();
|
||||
assert.match(ctl.renderHtmlFor(key), /cw-by-human/, "authorship coloring returns once the doc diverges from the pin");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as vscode from "vscode";
|
||||
|
||||
/**
|
||||
* #54: `vscode.commands.executeCommand("undo")` is non-functional in some headless
|
||||
* `.vscode-test` instances (it does not restore the buffer), which false-fails
|
||||
* every undo-dependent E2E (#38, #40) and makes `main` E2E red there. This is a
|
||||
* RUNTIME probe: it performs a real edit-then-undo on a scratch buffer and reports
|
||||
* whether undo actually restored it. Undo-dependent suites gate on it — running
|
||||
* normally where undo works (real coverage), skipping with a loud warning where it
|
||||
* doesn't (no false red, no silent loss — the skip is logged). Memoized per run.
|
||||
*/
|
||||
let cached: boolean | undefined;
|
||||
|
||||
export async function undoWorks(): Promise<boolean> {
|
||||
if (cached !== undefined) return cached;
|
||||
const abs = path.join(process.env.E2E_WORKSPACE!, "docs/.undo-probe.md");
|
||||
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
||||
fs.writeFileSync(abs, "undo probe baseline\n", "utf8");
|
||||
const doc = await vscode.workspace.openTextDocument(vscode.Uri.file(abs));
|
||||
await vscode.window.showTextDocument(doc);
|
||||
await new Promise((r) => setTimeout(r, 250));
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
edit.insert(doc.uri, doc.positionAt(doc.getText().length), "PROBE-EDIT-MARKER");
|
||||
await vscode.workspace.applyEdit(edit);
|
||||
await new Promise((r) => setTimeout(r, 250));
|
||||
if (!doc.getText().includes("PROBE-EDIT-MARKER")) {
|
||||
cached = false; // even the edit didn't take — treat as not undo-capable
|
||||
return cached;
|
||||
}
|
||||
await vscode.commands.executeCommand("undo");
|
||||
await new Promise((r) => setTimeout(r, 250));
|
||||
cached = !doc.getText().includes("PROBE-EDIT-MARKER"); // undo removed the marker → undo works
|
||||
return cached;
|
||||
}
|
||||
|
||||
/** Loud, single-line reason logged when an undo suite skips (no silent loss — #54). */
|
||||
export const UNDO_SKIP_REASON =
|
||||
"[E2E] SKIPPING undo-dependent suite — executeCommand('undo') is non-functional in this " +
|
||||
"VS Code test instance (see vscode-cowriting-plugin#54). These tests run where undo works.";
|
||||
@@ -3,6 +3,7 @@ import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as vscode from "vscode";
|
||||
import type { CowritingApi } from "../../../src/extension";
|
||||
import { undoWorks, UNDO_SKIP_REASON } from "./undoCapable";
|
||||
|
||||
const WS = process.env.E2E_WORKSPACE!;
|
||||
const settle = () => new Promise((r) => setTimeout(r, 400));
|
||||
@@ -34,6 +35,14 @@ suite("F10 #38 — undo does not mis-attribute restored text (host E2E, no LLM)"
|
||||
const DOC_REL = "docs/undo38.md";
|
||||
const BASE = "Alpha bravo charlie.\n";
|
||||
|
||||
// #54: skip (loudly) where executeCommand("undo") is non-functional; run where it works.
|
||||
suiteSetup(async function () {
|
||||
if (!(await undoWorks())) {
|
||||
console.warn(UNDO_SKIP_REASON);
|
||||
this.skip();
|
||||
}
|
||||
});
|
||||
|
||||
test("undo of a deletion of baseline text leaves it unattributed (not human)", async () => {
|
||||
const { doc, key } = await freshDoc(DOC_REL, BASE);
|
||||
const api = await getApi();
|
||||
|
||||
+59
-2
@@ -1,5 +1,32 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { extractReplacement } from "../src/liveTurn";
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { extractReplacement, runEditTurn } from "../src/liveTurn";
|
||||
|
||||
// A fake Agent that replays a scripted event list to subscribers, supports abort,
|
||||
// and resolves agent.run() with a completed (or aborted) result.
|
||||
const runs = { count: 0 };
|
||||
function fakeSdk(events: any[]) {
|
||||
return {
|
||||
Agent: class {
|
||||
private listeners: ((e: any) => void)[] = [];
|
||||
constructor(_cfg: unknown) {}
|
||||
subscribe(fn: (e: any) => void) {
|
||||
this.listeners.push(fn);
|
||||
return () => {
|
||||
this.listeners = this.listeners.filter((l) => l !== fn);
|
||||
};
|
||||
}
|
||||
// The real SDK's abort() is a no-op before run() creates its AbortController,
|
||||
// so this fake does NOT cooperate with a pre-abort — proving runEditTurn's own
|
||||
// short-circuit, not the fake's leniency.
|
||||
abort() {}
|
||||
async run(_input: string) {
|
||||
runs.count += 1;
|
||||
for (const e of events) for (const l of this.listeners) l(e);
|
||||
return { status: "completed", outputText: "EDITED", runId: "r1" };
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
describe("extractReplacement", () => {
|
||||
it("returns plain text untouched", () => {
|
||||
@@ -24,3 +51,33 @@ describe("extractReplacement", () => {
|
||||
expect(extractReplacement("```\nplain\n```", "plain old text")).toBe("plain");
|
||||
});
|
||||
});
|
||||
|
||||
describe("runEditTurn progress + cancel", () => {
|
||||
it("emits progress snapshots and returns the replacement unchanged (INV-44)", async () => {
|
||||
vi.resetModules();
|
||||
vi.doMock("@cline/sdk", () =>
|
||||
fakeSdk([
|
||||
{ type: "assistant-text-delta", text: "ED", accumulatedText: "ED" },
|
||||
{ type: "usage-updated", usage: { inputTokens: 10, outputTokens: 5, cacheReadTokens: 0, cacheWriteTokens: 0 } },
|
||||
]),
|
||||
);
|
||||
const seen: string[] = [];
|
||||
const turn = await runEditTurn("do it", "old", { onProgress: (s) => seen.push(s.phase) });
|
||||
expect(turn.replacement).toBe("EDITED");
|
||||
expect(seen).toContain("writing");
|
||||
vi.doUnmock("@cline/sdk");
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
it("a pre-aborted AbortSignal short-circuits before run() and throws (INV-47)", async () => {
|
||||
vi.resetModules();
|
||||
vi.doMock("@cline/sdk", () => fakeSdk([]));
|
||||
runs.count = 0;
|
||||
const ac = new AbortController();
|
||||
ac.abort();
|
||||
await expect(runEditTurn("do it", "old", { signal: ac.signal })).rejects.toThrow(/aborted/);
|
||||
expect(runs.count).toBe(0); // the turn never ran — no proposal could be produced
|
||||
vi.doUnmock("@cline/sdk");
|
||||
vi.resetModules();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -168,6 +168,45 @@ describe("colorByAuthor", () => {
|
||||
expect(html).toContain('<span class="cw-by-human">hello</span>');
|
||||
expect(html).toContain("world");
|
||||
});
|
||||
|
||||
// #33: author-coloring must be sentinel-safe around markdown emphasis. These
|
||||
// exercise the REAL markdown-it renderer (via renderReview on an unchanged doc),
|
||||
// since the failure is in markdown-it's inline parsing / element nesting.
|
||||
// CASE1 — a span boundary strictly inside a delimiter run must not split it.
|
||||
test("#33 CASE1: a span boundary inside ** does not break emphasis parsing", () => {
|
||||
const doc = "a**b**c";
|
||||
const html = renderReview(doc, doc, [{ start: 0, end: 2, author: "human" }], []);
|
||||
expect(html).toContain("<strong>b</strong>"); // emphasis still renders
|
||||
expect(html).not.toContain("**"); // no raw delimiters left
|
||||
expect(html).not.toContain("<em></em>"); // no stray empty emphasis (the parse-break symptom)
|
||||
expect(html).toContain('class="cw-by-human"'); // coloring present
|
||||
});
|
||||
// CASE3 — a span boundary inside an emphasis run must color the text without
|
||||
// misnesting span/element (the span is split at the element boundary).
|
||||
test("#33 CASE3: a span boundary inside **bold** colors the text without misnesting", () => {
|
||||
const doc = "**bold**";
|
||||
const html = renderReview(doc, doc, [{ start: 0, end: 4, author: "human" }], []); // covers "**bo"
|
||||
expect(html).toContain("<strong>");
|
||||
expect(html).toContain('<span class="cw-by-human">bo</span>ld</strong>'); // span INSIDE strong, closed before "ld"
|
||||
expect(html).not.toContain('cw-by-human"><strong>'); // NOT the old misnest (span wrapping the <strong> open)
|
||||
});
|
||||
// CASE2 — a span covering a whole emphasis run stays correct (regression).
|
||||
test("#33 CASE2: a span over the whole **bold** colors it correctly", () => {
|
||||
const doc = "**bold**";
|
||||
const html = renderReview(doc, doc, [{ start: 0, end: 8, author: "human" }], []);
|
||||
expect(html).toContain("<strong>");
|
||||
expect((html.match(/cw-by-human/g) ?? []).length).toBe(1);
|
||||
expect(html).toContain("bold");
|
||||
});
|
||||
test("#33: no Private-Use-Area sentinel chars leak into the rendered output", () => {
|
||||
const doc = "a**b**c and `co de` and _x_";
|
||||
const spans: AuthorSpan[] = [
|
||||
{ start: 0, end: 2, author: "human" },
|
||||
{ start: 12, end: 16, author: "claude" },
|
||||
];
|
||||
const html = renderReview(doc, doc, spans, []);
|
||||
expect(html).not.toMatch(/[\uE000-\uF8FF]/); // no leftover BMP Private-Use-Area sentinels
|
||||
});
|
||||
});
|
||||
|
||||
import { renderPlain } from "../src/trackChangesModel";
|
||||
@@ -277,6 +316,54 @@ describe("renderReview", () => {
|
||||
expect(uIdx).toBeGreaterThan(html.indexOf("Beta there")); // unanchored still trails the body
|
||||
expect(html).toContain("cw-proposal-unanchored");
|
||||
});
|
||||
// #48: a PINNED baseline with zero changes leaves the panel fully un-annotated —
|
||||
// no authorship coloring on unchanged blocks — while pending proposals still show.
|
||||
test("renderReview: pinned + zero diff with author spans renders NO authorship coloring", () => {
|
||||
const doc = "Human wrote this.\n\nClaude wrote that.";
|
||||
const spans: AuthorSpan[] = [
|
||||
{ start: 0, end: 17, author: "human" },
|
||||
{ start: 19, end: doc.length, author: "claude" },
|
||||
];
|
||||
const html = renderReview(doc, doc, spans, [], { pinned: true });
|
||||
expect(html).not.toContain("cw-by-human");
|
||||
expect(html).not.toContain("cw-by-claude");
|
||||
expect(html).not.toContain("cw-add");
|
||||
expect(html).not.toContain("cw-del");
|
||||
// still a selection→source surface (INV-36): blocks carry data-src offsets.
|
||||
expect(html).toContain("data-src-start");
|
||||
// the body text is still there, just plain.
|
||||
expect(html).toContain("Human wrote this.");
|
||||
expect(html).toContain("Claude wrote that.");
|
||||
});
|
||||
test("renderReview: pinned + zero diff still renders a pending proposal block", () => {
|
||||
const doc = "Human wrote this.\n\nClaude wrote that.";
|
||||
const spans: AuthorSpan[] = [{ start: 0, end: 17, author: "human" }];
|
||||
const proposals: ProposalView[] = [
|
||||
{ id: "p1", anchorStart: 0, anchorEnd: 5, replaced: "Human", replacement: "Person" },
|
||||
];
|
||||
const html = renderReview(doc, doc, spans, proposals, { pinned: true });
|
||||
expect(html).not.toContain("cw-by-human"); // body still clean
|
||||
expect(html).toContain('data-proposal-id="p1"'); // proposal still shows (it is an action)
|
||||
expect(html).toContain("Person");
|
||||
});
|
||||
test("renderReview: zero diff WITHOUT a pin (e.g. machine-landing) keeps authorship coloring (INV-33)", () => {
|
||||
// accepting a Claude edit advances the baseline (zero diff) but is NOT a pin —
|
||||
// the landed author coloring must remain.
|
||||
const doc = "Human wrote this.\n\nClaude wrote that.";
|
||||
const spans: AuthorSpan[] = [{ start: 19, end: doc.length, author: "claude" }];
|
||||
const html = renderReview(doc, doc, spans, []); // no pinned flag
|
||||
expect(html).toContain("cw-by-claude");
|
||||
});
|
||||
test("renderReview: with REAL changes since a pin, author coloring returns", () => {
|
||||
// a genuine added block is still author-colored even when pinned (only the
|
||||
// zero-diff-after-pin state is clean).
|
||||
const baseline = "Hello world";
|
||||
const current = "Hello world\n\nHello world";
|
||||
const spans: AuthorSpan[] = [{ start: 19, end: 24, author: "human" }];
|
||||
const html = renderReview(baseline, current, spans, [], { pinned: true });
|
||||
expect((html.match(/cw-by-human/g) ?? []).length).toBe(1);
|
||||
});
|
||||
|
||||
test("renderReview is deterministic with mixed anchored/unanchored proposals", () => {
|
||||
const doc = "one two three";
|
||||
const proposals: ProposalView[] = [
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
createTurnProgressState,
|
||||
reduceTurnProgress,
|
||||
formatProgressLine,
|
||||
formatTokens,
|
||||
type TurnProgressSnapshot,
|
||||
} from "../src/turnProgress";
|
||||
|
||||
// Minimal event factories — structurally match the @cline/sdk AgentRuntimeEvent
|
||||
// members the reducer reads. `as any` because we only supply the fields used.
|
||||
const ev = (e: any) => e as any;
|
||||
const textDelta = (text: string, accumulatedText: string) =>
|
||||
ev({ type: "assistant-text-delta", text, accumulatedText });
|
||||
const toolStarted = (toolName: string) => ev({ type: "tool-started", toolCall: { toolName } });
|
||||
const toolFinished = (toolName: string) => ev({ type: "tool-finished", toolCall: { toolName } });
|
||||
const usage = (inputTokens: number, outputTokens: number) =>
|
||||
ev({ type: "usage-updated", usage: { inputTokens, outputTokens, cacheReadTokens: 0, cacheWriteTokens: 0 } });
|
||||
|
||||
// Drive a sequence of events, returning every emitted snapshot.
|
||||
function run(events: any[]): TurnProgressSnapshot[] {
|
||||
let state = createTurnProgressState();
|
||||
const out: TurnProgressSnapshot[] = [];
|
||||
for (const e of events) {
|
||||
const r = reduceTurnProgress(state, e);
|
||||
state = r.state;
|
||||
if (r.snapshot) out.push(r.snapshot);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
describe("reduceTurnProgress", () => {
|
||||
it("starts in thinking", () => {
|
||||
const s = run([ev({ type: "run-started" })]);
|
||||
expect(s.at(-1)!.phase).toBe("thinking");
|
||||
expect(s.at(-1)!.chars).toBe(0);
|
||||
expect(s.at(-1)!.tokens).toBeUndefined();
|
||||
});
|
||||
|
||||
it("text deltas move to writing and accumulate chars + carry the delta", () => {
|
||||
const s = run([textDelta("Hel", "Hel"), textDelta("lo", "Hello")]);
|
||||
expect(s.map((x) => x.phase)).toEqual(["writing", "writing"]);
|
||||
expect(s.at(-1)!.chars).toBe(5);
|
||||
expect(s.map((x) => x.textDelta)).toEqual(["Hel", "lo"]);
|
||||
});
|
||||
|
||||
it("usage sets a running token total (input+output)", () => {
|
||||
const s = run([textDelta("Hi", "Hi"), usage(1000, 234)]);
|
||||
expect(s.at(-1)!.tokens).toBe(1234);
|
||||
});
|
||||
|
||||
it("tool start shows the tool name; tool finish reverts to writing once text was seen", () => {
|
||||
const s = run([textDelta("x", "x"), toolStarted("read_file"), toolFinished("read_file")]);
|
||||
expect(s[1].phase).toBe("tool");
|
||||
expect(s[1].tool).toBe("read_file");
|
||||
expect(s.at(-1)!.phase).toBe("writing");
|
||||
});
|
||||
|
||||
it("tool finish reverts to thinking when no text was seen", () => {
|
||||
const s = run([toolStarted("grep"), toolFinished("grep")]);
|
||||
expect(s.at(-1)!.phase).toBe("thinking");
|
||||
});
|
||||
|
||||
it("overlapping tools resolve in order", () => {
|
||||
const s = run([toolStarted("a"), toolStarted("b"), toolFinished("b"), toolFinished("a")]);
|
||||
expect(s.map((x) => x.phase)).toEqual(["tool", "tool", "tool", "thinking"]);
|
||||
expect(s[1].tool).toBe("b");
|
||||
expect(s[2].tool).toBe("a");
|
||||
});
|
||||
|
||||
it("reasoning deltas stay thinking and surface no text", () => {
|
||||
const s = run([ev({ type: "assistant-reasoning-delta", text: "secret", accumulatedText: "secret" })]);
|
||||
expect(s.at(-1)!.phase).toBe("thinking");
|
||||
expect(s.at(-1)!.textDelta).toBeUndefined();
|
||||
});
|
||||
|
||||
it("ignores lifecycle/finish events (no snapshot)", () => {
|
||||
const s = run([ev({ type: "turn-finished" }), ev({ type: "run-finished" })]);
|
||||
expect(s).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatProgressLine / formatTokens", () => {
|
||||
it("thinking", () => {
|
||||
expect(formatProgressLine({ phase: "thinking", chars: 0 })).toBe("thinking…");
|
||||
});
|
||||
it("writing with chars", () => {
|
||||
expect(formatProgressLine({ phase: "writing", chars: 412 })).toBe("writing… (412 chars)");
|
||||
});
|
||||
it("writing with chars + tokens", () => {
|
||||
expect(formatProgressLine({ phase: "writing", chars: 412, tokens: 1234 })).toBe(
|
||||
"writing… (412 chars) · 1.2k tokens",
|
||||
);
|
||||
});
|
||||
it("tool with name", () => {
|
||||
expect(formatProgressLine({ phase: "tool", tool: "read_file", chars: 0 })).toBe("running read_file…");
|
||||
});
|
||||
it("formats token magnitudes", () => {
|
||||
expect(formatTokens(950)).toBe("950");
|
||||
expect(formatTokens(1234)).toBe("1.2k");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user