Fix: normalize Windows drive letter in VS Code extension webview paths (#1052)
Extract normalizeWindowsDriveLetter to shared pathUtils module Normalize workspaceFolder to uppercase drive letter to match OpenCode server's path normalization. This fixes session visibility issues where VS Code extension sessions don't appear in CLI/desktop and vice versa due to case-sensitive directory comparison on Windows. Changes: - Create pathUtils.ts with shared normalizeWindowsDriveLetter function - Update opencode.ts to import from pathUtils instead of inline definition - Update ChatViewProvider.ts, AgentManagerPanelProvider.ts, SessionEditorPanelProvider.ts to import from pathUtils
This commit is contained in:
@@ -7,6 +7,7 @@ import { execSync } from 'child_process';
|
||||
import { spawnSync } from 'child_process';
|
||||
import { spawn } from 'child_process';
|
||||
import { randomBytes } from 'crypto';
|
||||
import { normalizeWindowsDriveLetter } from './pathUtils';
|
||||
|
||||
const READY_CHECK_TIMEOUT_MS = 30000;
|
||||
export type ConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
|
||||
@@ -626,11 +627,6 @@ export function createOpenCodeManager(_context: vscode.ExtensionContext): OpenCo
|
||||
let status: ConnectionStatus = 'disconnected';
|
||||
let lastError: string | undefined;
|
||||
const listeners = new Set<(status: ConnectionStatus, error?: string) => void>();
|
||||
/** On Windows, VS Code's uri.fsPath returns a lowercase drive letter (e.g. d:\...)
|
||||
* while process.cwd() (used by OpenCode server) returns uppercase (D:\...).
|
||||
* Normalize to uppercase so session directory queries match. */
|
||||
const normalizeWindowsDriveLetter = (p: string): string =>
|
||||
p.replace(/^([a-z]):/, (_, letter: string) => letter.toUpperCase() + ':');
|
||||
const workspaceDirectory = (): string =>
|
||||
normalizeWindowsDriveLetter(vscode.workspace.workspaceFolders?.[0]?.uri.fsPath || os.homedir());
|
||||
let workingDirectory: string = workspaceDirectory();
|
||||
|
||||
Reference in New Issue
Block a user