From a84d72e69b8d3d88b95be351afde3fe040ac6522 Mon Sep 17 00:00:00 2001 From: Ben Stull Date: Thu, 11 Jun 2026 14:36:36 -0700 Subject: [PATCH] =?UTF-8?q?feat(f9):=20AttributionController.spansFor=20?= =?UTF-8?q?=E2=80=94=20authorship=20spans=20for=20the=20preview?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- src/attributionController.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/attributionController.ts b/src/attributionController.ts index e62b310..8353fe8 100644 --- a/src/attributionController.ts +++ b/src/attributionController.ts @@ -18,6 +18,7 @@ import { applyChange, coalesce, type LiveSpan } from "./attributionTracker"; import { minimizeReplace, PendingEditRegistry } from "./pendingEdits"; import type { VersionGuard } from "./versionGuard"; import { isAuthorable } from "./workspacePath"; +import type { AuthorSpan } from "./trackChangesModel"; /** Test-facing snapshot of live attribution state for a document. */ export interface RenderedSpan { @@ -400,6 +401,19 @@ export class AttributionController implements vscode.Disposable { getOrphanCount(docPath: string): number { return this.docs.get(docPath)?.orphans.length ?? 0; } + + /** + * F9: the document's live attribution as authorship spans for the preview — + * current-buffer char ranges mapped to author kind (agent→claude). Computes + * the document key internally, so callers pass a TextDocument, not the key. + */ + spansFor(document: vscode.TextDocument): AuthorSpan[] { + return this.getSpans(this.keyOf(document)).map((s) => ({ + start: s.range.start, + end: s.range.end, + author: s.authorKind === "agent" ? "claude" : "human", + })); + } isVisible(): boolean { return this.visible; }