Fix #8: register warning stubs when no workspace folder; F5 opens the repo. Add selection context menus (#9)
- extension.ts: with no folder open, every contributed coauthoring command now
registers a warning stub ('open a folder first') instead of being absent —
the palette no longer errors 'command not found'. Opening a folder reloads
the window and re-activates with a real root.
- .vscode/launch.json: the EDH now opens the repo as its workspace, so plain
F5 lands in a working state.
- package.json: editor/context menu entries for 'Ask Claude to Edit
Selection' and 'Add Coauthoring Thread on Selection', shown only when text
is highlighted in a file-scheme editor (editorHasSelection).
- E2E: second no-workspace pass (suite-no-workspace) pins the #8 regression.
Fixes #8. Fixes #9.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+22
-1
@@ -38,7 +38,28 @@ export function activate(context: vscode.ExtensionContext): CowritingApi | undef
|
||||
|
||||
// --- F2: region-anchored threads (Feature #4) ---
|
||||
const root = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
|
||||
if (!root) return undefined; // no workspace → nothing to anchor against
|
||||
if (!root) {
|
||||
// No folder open → nothing to anchor against, but every contributed
|
||||
// command must still exist: leave them unregistered and the palette
|
||||
// errors with "command not found" (#8). Register warning stubs instead;
|
||||
// opening a folder reloads the window, re-running activate with a root.
|
||||
const stub = () =>
|
||||
void vscode.window.showWarningMessage(
|
||||
"Cowriting: open a folder first — coauthoring anchors threads and attribution to workspace files.",
|
||||
);
|
||||
for (const command of [
|
||||
"cowriting.createThread",
|
||||
"cowriting.reply",
|
||||
"cowriting.resolveThread",
|
||||
"cowriting.reopenThread",
|
||||
"cowriting.editSelection",
|
||||
"cowriting.toggleAttribution",
|
||||
"cowriting.applyAgentEdit",
|
||||
]) {
|
||||
context.subscriptions.push(vscode.commands.registerCommand(command, stub));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
const store = new CoauthorStore(root);
|
||||
const threadController = new ThreadController(store, root);
|
||||
context.subscriptions.push(threadController);
|
||||
|
||||
Reference in New Issue
Block a user