Files
vscode-cowriting-plugin/test/e2e/suite-no-workspace/noWorkspace.test.ts
T
Ben Stull 3520397e41 F6 #34: delete the dead two-pane diff-view UI, keep the baseline data layer
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>
2026-06-12 02:10:14 -07:00

100 lines
4.9 KiB
TypeScript

import * as assert from "assert";
import * as vscode from "vscode";
import type { CowritingApi } from "../../../src/extension";
// F8: with NO workspace folder open, authoring used to be stubbed (#8 registered
// warning stubs and activate() returned undefined). F8 makes the authoring
// commands REAL folder-less (the F6 #19 precedent), routing every doc to global
// storage — so activate() returns a real API and propose→accept works on an
// untitled buffer with no folder. This suite runs in a second EDH pass launched
// WITHOUT a folder (see runTest.ts).
suite("no-workspace authoring (F8 — real folder-less, #8 lineage)", () => {
test("EDH really has no workspace folder", () => {
assert.strictEqual(vscode.workspace.workspaceFolders, undefined);
});
test("activate returns a real API even with no workspace folder (F8)", async () => {
const ext = vscode.extensions.getExtension("benstull.vscode-cowriting-plugin")!;
const api = (await ext.activate()) as CowritingApi;
assert.ok(api?.proposalController, "no-folder activation returns the authoring API (F8)");
assert.ok(api?.sidecarRouter, "router exposed");
});
test("all contributed coauthoring commands are registered (real, not stubs)", async () => {
const all = await vscode.commands.getCommands(true);
for (const command of [
"cowriting.createThread",
"cowriting.reply",
"cowriting.resolveThread",
"cowriting.reopenThread",
"cowriting.editSelection",
"cowriting.applyAgentEdit",
"cowriting.proposeAgentEdit",
]) {
assert.ok(all.includes(command), `${command} is registered`);
}
// F10 (INV-32): proposals are preview-only — the in-editor accept/reject
// commands and the attribution toggle were retired (no editor decorations).
for (const retired of [
"cowriting.toggleAttribution",
"cowriting.acceptProposal",
"cowriting.rejectProposal",
// #34: the F6 two-pane diff VIEW was removed (F10 preview is the single
// review surface); its toggle command is gone (the baseline store stays).
"cowriting.toggleDiffView",
]) {
assert.ok(!all.includes(retired), `${retired} is retired`);
}
});
test("authoring works folder-less: propose→accept on an untitled buffer routes to global storage (F8)", async () => {
const ext = vscode.extensions.getExtension("benstull.vscode-cowriting-plugin")!;
const api = (await ext.activate()) as CowritingApi;
const untitled = await vscode.workspace.openTextDocument({
content: "Edit this scratch sentence please.\n",
language: "markdown",
});
await vscode.window.showTextDocument(untitled);
await new Promise((r) => setTimeout(r, 300));
const key = untitled.uri.toString();
const target = "Edit this scratch sentence please.";
const start = untitled.getText().indexOf(target);
const id = await vscode.commands.executeCommand<string>("cowriting.proposeAgentEdit", {
uri: key,
start,
end: start + target.length,
newText: "REPLACED scratch sentence.",
model: "sonnet",
sessionId: "e2e-nf",
turnId: "turn-nf",
});
assert.ok(id, "propose returns an id for an untitled buffer with no folder");
assert.ok(await api.proposalController.acceptById(key, id!), "accept applies");
await new Promise((r) => setTimeout(r, 300));
assert.ok(untitled.getText().includes("REPLACED scratch sentence."), "replacement landed in the untitled buffer");
assert.strictEqual(api.sidecarRouter.sidecarPath(key), undefined, "untitled artifact is in-memory only (no disk)");
});
// F6 (#19) baseline data layer is workspace-INDEPENDENT: it captures a baseline
// for an untitled buffer even with no folder open (the two-pane VIEW was
// removed in #34; only the data layer remains). pinDiffBaseline stays real.
test("F6 baseline data layer works with no folder open (untitled buffer)", async () => {
const all = await vscode.commands.getCommands(true);
assert.ok(all.includes("cowriting.pinDiffBaseline"), "pinDiffBaseline registered");
const ext = vscode.extensions.getExtension("benstull.vscode-cowriting-plugin")!;
const api = (await ext.activate()) as CowritingApi;
const untitled = await vscode.workspace.openTextDocument({ content: "no-folder scratch\n", language: "markdown" });
await vscode.window.showTextDocument(untitled);
await new Promise((r) => setTimeout(r, 300));
const key = untitled.uri.toString();
const baseline = api.diffViewController.getBaseline(key);
assert.ok(baseline, "baseline captured for the untitled buffer with no folder");
assert.strictEqual(baseline!.reason, "opened");
// pin resets the baseline to now — works folder-less.
await vscode.commands.executeCommand("cowriting.pinDiffBaseline");
await new Promise((r) => setTimeout(r, 300));
assert.strictEqual(api.diffViewController.getBaseline(key)!.reason, "pinned", "pin works with no folder");
});
});