feat(f9): AttributionController.spansFor — authorship spans for the preview

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ben Stull
2026-06-11 14:36:36 -07:00
parent 95eaf78891
commit a84d72e69b
+14
View File
@@ -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;
}