From 38aae62e56b1ffc48da626544bb512f03c19e8fe Mon Sep 17 00:00:00 2001 From: shanevcantwell <153727980+shanevcantwell@users.noreply.github.com> Date: Sat, 31 Jan 2026 16:19:25 -0700 Subject: [PATCH] fix: pass pre-read content to RegistryClient for WSL compatibility (#9739) Fixes #6242, #7810 When Windows VS Code connects to WSL, workspace files are accessed via vscode-remote:// URIs. Previously, getAllDotContinueDefinitionFiles() correctly read content via ide.readFile(), but loadYaml.ts discarded the content and passed only the URI path to RegistryClient, which then tried to re-read using fs.readFileSync() - failing for remote URIs. Changes: - Add optional content field to FileIdentifier (non-breaking) - RegistryClient.getContent() returns pre-read content when present - loadYaml.ts passes content along with file identifiers Co-authored-by: Claude Opus 4.5 --- core/config/yaml/loadYaml.ts | 3 +++ packages/config-yaml/src/interfaces/slugs.ts | 2 ++ packages/config-yaml/src/registryClient.test.ts | 14 ++++++++++++++ packages/config-yaml/src/registryClient.ts | 5 +++++ 4 files changed, 24 insertions(+) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 3c0f2d220..cd684db17 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -64,6 +64,8 @@ async function loadConfigYaml(options: { } = options; // Add local .continue blocks + // Use "content" field to pass pre-read content directly, avoiding + // fs.readFileSync which fails for vscode-remote:// URIs in WSL (#6242, #7810) const localBlockPromises = BLOCK_TYPES.map(async (blockType) => { const localBlocks = await getAllDotContinueDefinitionFiles( ide, @@ -73,6 +75,7 @@ async function loadConfigYaml(options: { return localBlocks.map((b) => ({ uriType: "file" as const, fileUri: b.path, + content: b.content, })); }); const localPackageIdentifiers: PackageIdentifier[] = ( diff --git a/packages/config-yaml/src/interfaces/slugs.ts b/packages/config-yaml/src/interfaces/slugs.ts index 30197d059..3ff57068b 100644 --- a/packages/config-yaml/src/interfaces/slugs.ts +++ b/packages/config-yaml/src/interfaces/slugs.ts @@ -68,6 +68,8 @@ interface FullSlugIdentifier extends BasePackageIdentifier { interface FileIdentifier extends BasePackageIdentifier { uriType: "file"; fileUri: string; + /** Pre-read content - bypasses fs.readFileSync for vscode-remote:// URIs in WSL */ + content?: string; } export type PackageIdentifier = FullSlugIdentifier | FileIdentifier; diff --git a/packages/config-yaml/src/registryClient.test.ts b/packages/config-yaml/src/registryClient.test.ts index d5875771a..618007d1c 100644 --- a/packages/config-yaml/src/registryClient.test.ts +++ b/packages/config-yaml/src/registryClient.test.ts @@ -131,6 +131,20 @@ describe("RegistryClient", () => { "Unknown package identifier type: unknown", ); }); + + it("should return pre-read content directly for file with content field", async () => { + const client = new RegistryClient(); + + const id: PackageIdentifier = { + uriType: "file", + fileUri: "/nonexistent/path.yaml", + content: "pre-read yaml content", + }; + + // Should return content without trying to read the nonexistent file + const result = await client.getContent(id); + expect(result).toBe("pre-read yaml content"); + }); }); describe("getContentFromFilePath", () => { diff --git a/packages/config-yaml/src/registryClient.ts b/packages/config-yaml/src/registryClient.ts index c027b31e8..e889f76d7 100644 --- a/packages/config-yaml/src/registryClient.ts +++ b/packages/config-yaml/src/registryClient.ts @@ -24,6 +24,11 @@ export class RegistryClient implements Registry { } async getContent(id: PackageIdentifier): Promise { + // Return pre-read content if available (for vscode-remote:// URIs in WSL) + if (id.uriType === "file" && id.content !== undefined) { + return id.content; + } + switch (id.uriType) { case "file": return this.getContentFromFilePath(id.fileUri);