The one Ask-Claude toolbar button now adapts: its label flips on selectionchange
(Edit Selection when live text is selected in the preview, Edit Document
otherwise), and a click resolves the preview selection to a SOURCE range via the
nearest data-src ancestors (INV-36) — the webview's sole mapping duty. A
selection touching no live-source block falls back to document scope. Per spec
§6.5 PUC-2/3 / §7.2 SLICE-4.
- webview (media/preview.ts): nearestSrc() DOM walk + selectionSrcRange()
block-union; updateAskLabel() on selectionchange + after each render; the
adaptive click posts { askClaude, scope:"selection", start, end } or falls back
to document scope. Sealed (INV-21): reads data-src only, posts intent.
- host: runEditAndPropose's range branch (already shared from SLICE-3) records one
single-range F4 proposal over the resolved block-union.
- host E2E: stubbed selection turn → exactly one proposal over the resolved range
(turn receives exactly the selected source; replaced == the range; doc
untouched); an unchanged replacement proposes nothing. (The webview DOM
selection→data-src lookup is sealed-sandbox → manual smoke, spec §6.8.)
205 unit + 51 host E2E green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A whole-document Ask-Claude rewrite is diffed into hunks and surfaced as N
independent F4 proposals (one per changed hunk) — reusing the F4 single-range
model N times, no new model. Per spec §6.4/§7.2 SLICE-3.
- trackChangesModel: pure `diffToHunks(currentText, rewrittenText)` →
EditHunk[] (vscode-free, deterministic; diffWordsWithSpace, coalescing
adjacent add/remove runs; offsets index currentText).
- trackChangesPreview: `runEditAndPropose(document, target, instruction)` — the
shared host routine (selection → one single-range propose; document → diff →
one propose per hunk; never mutates the doc, INV-10); `askClaude` UI wrapper
(host showInputBox keeps LLM/secrets out of the sealed webview, INV-8/35);
injectable `editTurn` + `setEditTurnForTest` seam (no LLM in CI); the
`askClaude` inbound message branch; `cowriting.editDocument` command for #42
reuse.
- package.json: register cowriting.editDocument, palette-guarded on markdown.
- webview: ✦ Ask Claude to Edit Document button → { askClaude, scope:"document" }.
- unit: diffToHunks fixtures (zero/one/multi-hunk, wholesale, determinism).
- host E2E: stubbed multi-hunk rewrite → N matching proposals, doc untouched;
editDocument command registered + markdown-guarded.
205 unit + 49 host E2E green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The pure render layer now emits data-src-start/data-src-end (source char offsets
from BlockWithRange) on every LIVE-source rendered block, in BOTH modes — the
contract the webview's selection→source mapping (SLICE-4) walks the DOM for.
Per spec §6.1 INV-36 / §7.2 SLICE-2.
- trackChangesModel: shared `srcAttr(blk)` helper; threaded through renderOp +
renderReviewOp + the renderReview loop (removed blocks → "" / no data-src, as
they have no live source). renderPlain switches from a single whole-document
markdown pass to per-block `<div data-src-start/end>` wrappers — bare divs (no
cw- class) so the off/clean preview stays visually clean while becoming a
selection→source surface. Pure, vscode-free, deterministic (extends INV-22).
- unit (test/trackChangesModel.test.ts): data-src offsets equal
splitBlocksWithRanges in both modes; removed + proposal blocks carry none;
off-mode stays cw--free; determinism.
200 unit + 47 host E2E green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Homes the orphaned cowriting.pinDiffBaseline command and gives the writer a
reachable Pin control in the preview toolbar. Per spec §7.2 SLICE-1
(docs/superpowers/specs/2026-06-12-f11-preview-toolbar-interaction-surface.md).
- trackChangesPreview: extract onDidReceiveMessage into handleWebviewMessage;
add the F11 `pinBaseline` intent → DiffViewController.pin(previewedDoc) (the
bound doc, not activeTextEditor — §6.7); ToolbarMsg union; receiveMessage test
seam exercising the real message→seam wiring (INV-35).
- webview: ⌖ Pin baseline button in #cw-header posting { type: "pinBaseline" };
theme-aware toolbar-button CSS (light/dark/high-contrast, disabled state).
- package.json: unhide pinDiffBaseline — commandPalette `when` false →
editorLangId == markdown (resolves the #34 orphan from the command side).
- host E2E (test/e2e/suite/f11Toolbar.test.ts): pinBaseline message clears the
change-marks + advances the baseline to `pinned`; palette `when` is reachable.
Also archives the F11 implementation plan to docs/superpowers/plans/.
197 unit + 47 host E2E green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Undo in the editor rendered wrong marks in the F10 review preview: restored
baseline text (and reverted Claude text) was colored as human-authored. Root
cause — attributionController.onDidChange attributed every non-seam document
change to currentAuthor() (always human) and ignored e.reason, so an undo/redo
that re-inserts text created a fresh human span over it. renderReview is pure;
the wrong marks came from these false author spans.
Fix: on e.reason === Undo|Redo, reconcile span geometry but do NOT attribute the
re-inserted chars — an undo is history navigation, not authorship, so restored
text stays neutral (unattributed) rather than falsely claimed by the human.
applyChange gains an `attributeInserted` flag (default true; false on undo/redo);
seam matching is also skipped on undo/redo (the seam only applies forward edits).
Restored text becomes neutral rather than recovering its exact prior provenance
(e.g. undoing a deletion of Claude's text shows it unattributed, not blue) —
perfect restoration would need an attribution history stack synced to the editor
undo stack (fragile due to edit coalescing); filed mentally as a follow-up. The
neutral behavior removes the misleading marks, which is the reported defect.
Tests: E2E reproduces the mid-edit-undo case (buffer stays dirty so the disk-sync
guard doesn't mask it) and asserts restored text is unattributed; +3 unit tests
for the geometric-only applyChange path. 197 unit + 50 E2E green; typecheck clean.
Closes#38
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
F10 (#29) made the rendered preview the single review surface and hid the F6
two-pane vscode.diff view (command + ctrl+alt+d set when:false). This removes
that now-unreachable view code:
- DiffViewController: drop toggle/findDiffTab/epochLabel/isDiffOpen, the
`cowriting-baseline:` TextDocumentContentProvider + BASELINE_SCHEME + baselineUri
+ the content-provider change emitter, and the toggleDiffView command. The
baseline DATA layer is fully intact — ensureBaseline/advance/pin/capture,
getBaseline, baselineFilePath, onDidChangeBaseline, persistence (INV-19), and
the machine-landing auto-advance (INV-18) that F7/F10 consume.
- package.json: remove the toggleDiffView command, its commandPalette entry, and
the ctrl+alt+d keybinding.
- E2E: diffView suite keeps the baseline-data-layer tests, drops the two-pane
view tests; the F10 + no-workspace suites assert toggleDiffView is now absent
(was: declared-but-hidden).
Deliberate deviation from the issue's literal acceptance: pinDiffBaseline is
KEPT. The canonical Solution Design (coauthoring-interactive-review.md §6.7)
scopes the removal to the two-pane VIEW only ("keep the controller + baseline
store"); pin() lives in the baseline lifecycle (§6.4), never touches vscode.diff,
and is exercised by live F7 baseline-reset tests. Where the P3 capture draft and
the approved spec conflict, the spec wins (documentation-leads-automation).
194 unit + 49 E2E green; typecheck + build clean. No F7/F10 behavior change.
Closes#34
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
In the F10 review preview, renderReview now emits each pending proposal whose
anchor resolves as a cw-proposal block immediately after the current-side block
its anchorStart falls in — answering "what is Claude proposing, and where?" by
position — instead of appending all proposals as trailing blocks. Proposals in
the same block are ordered by anchorStart then id (deterministic, INV-33); a
proposal whose anchor doesn't resolve (or precedes all blocks) still trails as a
cw-proposal-unanchored block, never dropped (INV-34).
This implements the inline-at-anchor placement the graduated F10 Solution Design
already specified (coauthoring-interactive-review.md §2/§6.2); the trailing-block
behavior shipped in #29 was a recorded v1 deferral.
Unit: mid-document placement, two proposals in distinct blocks, same-block
ordering determinism, anchored-before-trailing, mixed-set determinism.
E2E: the F10 propose test now asserts the proposal renders before the following
block (in place); accept still lands + clears.
194 unit + 51 E2E green; typecheck clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds test/e2e/suite/f10Review.test.ts covering the F10 flow: open preview
(mode "on", fresh baseline all-unchanged), type → cw-by-human span, propose →
cw-proposal block with ✓/✗, accept → lands + baseline advances + block clears,
reject → vanishes + doc untouched, toggle off → renderPlain has no cw- marks,
status-bar PUC-6 (indicator with no panel, hidden once opened), and the
clean-editor INV-32 facts (retired toggleAttribution, F6 ctrl+alt+d hidden).
Rewrites the obsolete F9 authorship-mode test as an F10 review test
(cw-by-claude in the on-state render; getMode defaults to "on"). Updates
attribution.test.ts (drops the retired isVisible/toggleAttribution toggle,
asserts the toggle is gone) and noWorkspace.test.ts (toggleAttribution +
acceptProposal/rejectProposal are retired, preview-only — INV-32).
Honesty fix in the status-bar seam: hideStatus() clears statusItem.text so
statusText() reports undefined when the indicator is hidden (it previously
returned its stale last value after a panel opened).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PUA sentinel injection through markdown-it; adjacent-span ordering handled;
code/mermaid fences atomic with a block-level author badge.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Spec §6.4: replace the scheme!=file / !isUnderRoot rejections with a single
!isAuthorable branch. isUnderRoot retained as a routing input. Per-condition
messaging (#24) kept for no-editor / empty-selection / non-{file,untitled}.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
cowriting.editSelection collapsed four distinct failures (no editor / no
selection / unsaved / outside the workspace folder) into one misleading
"select some text in a workspace document first" warning — so editing a
selection in a file OUTSIDE the EDH workspace root (e.g. a content-repo file
while the EDH opens sandbox/) was rejected as if no text were selected.
- New pure, vscode-free src/workspacePath.ts: isUnderRoot() (separator-bounded
membership, fixing a latent startsWith() prefix collision where a sibling
whose name prefixes the root — e.g. vscode-cowriting-plugin-content vs
vscode-cowriting-plugin — falsely matched) + selectionRejection() (one
message per condition). Unit-tested (8 cases), incl. the reported bug.
- Wire isUnderRoot into all five membership checks: extension.ts (editSelection
guard + renderIfOpen) and the thread/attribution/proposal controllers.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Migrate test surface to URI-string keys; add out-of-workspace file (persisted
in global storage) + untitled-buffer (in-memory, not persisted) cases; assert
F6 toggle works with no folder open. No LLM.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
F6 no longer requires a workspace file. It gets its own diffable predicate
(any file: or untitled:) decoupled from F2 isTracked, keys baselines by a
sha256 of the document URI, and stores them in VS Code GLOBAL storage
(context.globalStorageUri) — always present, never the repo (INV-19). Untitled
buffers have no durable identity → in-memory baseline only (lost on reload).
DiffViewController is now constructed before the workspace-root check and its
commands are always live (never stubbed) — the machine-landing advance wiring
stays in the with-root branch since the seam only fires on workspace files.
BaselineStore generalized to key-by-hash (Baseline.docPath → uri).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
F6 §6.2/§6.3, INV-19. One JSON per docPath under VS Code workspace storage,
never the repo. Mirrors CoauthorStore; unit-tested round-trip/paths/overwrite.
Also lands the F6 implementation plan
(docs/superpowers/plans/2026-06-11-f6-diff-view-toggle.md).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Playing with F4, the operator hit VS Code's default "Reply…" box on a
proposal thread: no submit command is wired for cowriting.proposals, so
typed text had nowhere to go. Proposals are decide-only (accept/reject in
the title bar); discussion belongs in a coauthoring thread. Set
canReply=false so the dead input never renders, and expose canReply on the
test-facing RenderedProposal with an E2E assertion.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The accept E2E exposed a latent F3 limitation: VS Code word-diffs one
applied WorkspaceEdit into several minimal hunks when old/new share
interior tokens, so the registry's per-hunk exact match missed and seam
edits fell through as fragmented human spans. PendingEditRegistry.match
is replaced by matchEvent (all hunks inside the registered full range +
equal net delta — one applyEdit is one change event). Plan AMENDMENT 1.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>