feat(vscode): support multi-root workspaces (#1493)

Add proper VS Code multi-root workspace support. New sessions now start in the workspace folder the user chooses instead of always using the first folder.

The VS Code sidebar now shows one shared flat session list for the currently opened workspace folders, keeps that list synced when folders are added or removed, and excludes sessions from worktrees unless that worktree is opened as a workspace folder.

Also keep the OpenCode server process independent from a specific workspace folder so changing the selected folder does not restart or interrupt existing sessions.
This commit is contained in:
Maksym Mospanenko
2026-06-10 23:58:40 +03:00
committed by GitHub
parent 49a1424e5f
commit 7b33805ea0
15 changed files with 646 additions and 96 deletions
+26
View File
@@ -0,0 +1,26 @@
import { normalizeWindowsDriveLetter } from './pathUtils';
export interface WorkspaceFolderInput {
name: string;
uri: { fsPath: string };
}
export interface WorkspaceFolderCandidate {
name: string;
path: string;
}
export function resolveWorkspaceFolders(
folders: ReadonlyArray<WorkspaceFolderInput>
): WorkspaceFolderCandidate[] {
const seen = new Map<string, WorkspaceFolderCandidate>();
for (const folder of folders) {
const path = normalizeWindowsDriveLetter(folder.uri.fsPath).replace(/[\\/]+$/, '');
if (!seen.has(path)) {
seen.set(path, { name: folder.name, path });
}
}
return [...seen.values()].sort((a, b) =>
a.name.localeCompare(b.name, undefined, { sensitivity: 'base' })
);
}