F2 SLICE-3: ThreadController on the Comments API + thread mutations (#4)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+31
-15
@@ -1,40 +1,56 @@
|
||||
import * as vscode from "vscode";
|
||||
import { fetchSdkSummary } from "./cline";
|
||||
import { CoauthorStore } from "./store";
|
||||
import { ThreadController } from "./threadController";
|
||||
|
||||
const CHANNEL_NAME = "Cowriting (Cline SDK)";
|
||||
|
||||
export function activate(context: vscode.ExtensionContext): void {
|
||||
export interface CowritingApi {
|
||||
threadController: ThreadController;
|
||||
}
|
||||
|
||||
export function activate(context: vscode.ExtensionContext): CowritingApi | undefined {
|
||||
// --- POC command (Feature #2), unchanged ---
|
||||
const output = vscode.window.createOutputChannel(CHANNEL_NAME);
|
||||
context.subscriptions.push(output);
|
||||
|
||||
const command = vscode.commands.registerCommand(
|
||||
"cowriting.showClineSdkInfo",
|
||||
async () => {
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("cowriting.showClineSdkInfo", async () => {
|
||||
try {
|
||||
const summary = await fetchSdkSummary();
|
||||
output.clear();
|
||||
output.appendLine(`@cline/sdk version: ${summary.version}`);
|
||||
output.appendLine(`Builtin tools (${summary.tools.length}):`);
|
||||
for (const tool of summary.tools) {
|
||||
output.appendLine(` • ${tool.id} — ${tool.description}`);
|
||||
}
|
||||
for (const tool of summary.tools) output.appendLine(` • ${tool.id} — ${tool.description}`);
|
||||
output.show(true);
|
||||
await vscode.window.showInformationMessage(
|
||||
`Cline SDK ${summary.version} loaded — ${summary.tools.length} builtin tools. See the "${CHANNEL_NAME}" output channel.`
|
||||
`Cline SDK ${summary.version} loaded — ${summary.tools.length} builtin tools. See the "${CHANNEL_NAME}" output channel.`,
|
||||
);
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
output.appendLine(`Failed to drive @cline/sdk: ${message}`);
|
||||
output.show(true);
|
||||
await vscode.window.showErrorMessage(
|
||||
`Cowriting: failed to load @cline/sdk — ${message}`
|
||||
);
|
||||
await vscode.window.showErrorMessage(`Cowriting: failed to load @cline/sdk — ${message}`);
|
||||
}
|
||||
}
|
||||
}),
|
||||
);
|
||||
context.subscriptions.push(command);
|
||||
|
||||
// --- F2: region-anchored threads (Feature #4) ---
|
||||
const root = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
|
||||
if (!root) return undefined; // no workspace → nothing to anchor against
|
||||
const store = new CoauthorStore(root);
|
||||
const threadController = new ThreadController(store, root);
|
||||
context.subscriptions.push(threadController);
|
||||
|
||||
// Render threads for already-open editors, and on future opens.
|
||||
const renderIfOpen = (doc: vscode.TextDocument) => {
|
||||
if (doc.uri.scheme === "file" && doc.uri.fsPath.startsWith(root)) threadController.renderAll(doc);
|
||||
};
|
||||
vscode.workspace.textDocuments.forEach(renderIfOpen);
|
||||
context.subscriptions.push(vscode.workspace.onDidOpenTextDocument(renderIfOpen));
|
||||
|
||||
return { threadController };
|
||||
}
|
||||
|
||||
export function deactivate(): void {
|
||||
// Nothing to clean up beyond the disposables registered on the context.
|
||||
// Disposables registered on the context handle cleanup.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user