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 <noreply@anthropic.com>
This commit is contained in:
shanevcantwell
2026-01-31 16:19:25 -07:00
committed by GitHub
parent 20adbdcc2f
commit 38aae62e56
4 changed files with 24 additions and 0 deletions

View File

@@ -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[] = (

View File

@@ -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;

View File

@@ -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", () => {

View File

@@ -24,6 +24,11 @@ export class RegistryClient implements Registry {
}
async getContent(id: PackageIdentifier): Promise<string> {
// 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);