perf: optimize app startup and background lifecycles
This commit is contained in:
18
electron/api/host-api-transport.ts
Normal file
18
electron/api/host-api-transport.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Transport-only path classification. Kept free of route imports so the
|
||||
* lightweight IPC registration path does not eagerly load every Host API
|
||||
* service before the first window is painted.
|
||||
*/
|
||||
export function shouldUseLoopbackHostApi(path: string, method = 'GET'): boolean {
|
||||
const normalizedMethod = method.toUpperCase();
|
||||
const pathname = path.split('?', 1)[0] || path;
|
||||
if (pathname === '/api/events' || pathname === '/api/opencode/events') return true;
|
||||
if (pathname.startsWith('/api/ai-proxy/')) return true;
|
||||
if (pathname.includes('/events') && pathname.startsWith('/api/image-workspace/')) return true;
|
||||
if (
|
||||
pathname.includes('/assets/')
|
||||
&& pathname.endsWith('/content')
|
||||
&& (normalizedMethod === 'GET' || normalizedMethod === 'HEAD')
|
||||
) return true;
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user