perf: migrate chat rendering to virtua (#1651)
* refactor: migrate chat history virtualization to virtua * refactor: render loaded chat history directly * refactor: finish virtua migration * perf: defer tool body rendering * perf: queue deferred tool body mounts * perf: quiet and defer markdown file probes * perf: defer markdown code highlighting * perf: stabilize markdown plugin lists * perf: defer mermaid markdown rendering * perf: delay markdown file reference annotation * perf: attach markdown table listeners on demand * perf: trim markdown render overhead
This commit is contained in:
committed by
GitHub
parent
e372c8d8cb
commit
a45376d585
@@ -0,0 +1,59 @@
|
||||
import { describe, expect, it, mock } from 'bun:test';
|
||||
|
||||
mock.module('fs', () => ({
|
||||
promises: {
|
||||
realpath: mock(async () => {
|
||||
const error = new Error('missing');
|
||||
error.code = 'ENOENT';
|
||||
throw error;
|
||||
}),
|
||||
stat: mock(async () => {
|
||||
const error = new Error('missing');
|
||||
error.code = 'ENOENT';
|
||||
throw error;
|
||||
}),
|
||||
},
|
||||
default: {
|
||||
promises: {
|
||||
realpath: mock(async () => {
|
||||
const error = new Error('missing');
|
||||
error.code = 'ENOENT';
|
||||
throw error;
|
||||
}),
|
||||
stat: mock(async () => {
|
||||
const error = new Error('missing');
|
||||
error.code = 'ENOENT';
|
||||
throw error;
|
||||
}),
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
mock.module('vscode', () => ({
|
||||
Uri: {
|
||||
file: (fsPath) => ({ fsPath }),
|
||||
},
|
||||
workspace: {
|
||||
workspaceFolders: [{ uri: { fsPath: '/workspace' } }],
|
||||
},
|
||||
}));
|
||||
|
||||
const { tryHandleLocalFsProxy } = await import('./bridge-localfs-proxy-runtime');
|
||||
|
||||
describe('bridge local fs proxy', () => {
|
||||
it('returns a quiet optional stat miss for missing files', async () => {
|
||||
const response = await tryHandleLocalFsProxy('GET', '/api/fs/stat?path=%2Fmissing.ts&optional=true');
|
||||
|
||||
expect(response?.status).toBe(200);
|
||||
expect(JSON.parse(Buffer.from(response?.bodyBase64 ?? '', 'base64').toString('utf8'))).toEqual({
|
||||
path: '/missing.ts',
|
||||
exists: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps regular stat miss behavior without optional flag', async () => {
|
||||
const response = await tryHandleLocalFsProxy('GET', '/api/fs/stat?path=%2Fmissing.ts');
|
||||
|
||||
expect(response?.status).toBe(404);
|
||||
});
|
||||
});
|
||||
@@ -65,8 +65,19 @@ export const tryHandleLocalFsProxy = async (method: string, requestPath: string)
|
||||
}
|
||||
|
||||
const targetPath = parsed.searchParams.get('path') || '';
|
||||
const optional = parsed.searchParams.get('optional') === 'true';
|
||||
const resolution: FsReadPathResolution = await resolveFileReadPath(targetPath);
|
||||
if (!resolution.ok) {
|
||||
if (fsProxyPath === '/api/fs/stat' && optional && resolution.status === 404) {
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'cache-control': 'no-store',
|
||||
},
|
||||
bodyBase64: base64EncodeUtf8(JSON.stringify({ path: targetPath, exists: false })),
|
||||
};
|
||||
}
|
||||
return buildProxyJsonError(resolution.status, resolution.error);
|
||||
}
|
||||
|
||||
@@ -116,6 +127,16 @@ export const tryHandleLocalFsProxy = async (method: string, requestPath: string)
|
||||
} catch (error) {
|
||||
const err = error as NodeJS.ErrnoException;
|
||||
if (err?.code === 'ENOENT') {
|
||||
if (fsProxyPath === '/api/fs/stat' && optional) {
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'cache-control': 'no-store',
|
||||
},
|
||||
bodyBase64: base64EncodeUtf8(JSON.stringify({ path: targetPath, exists: false })),
|
||||
};
|
||||
}
|
||||
return buildProxyJsonError(404, 'File not found');
|
||||
}
|
||||
if (fsProxyPath === '/api/fs/stat') {
|
||||
|
||||
Reference in New Issue
Block a user