From 53ff4d652f001bb980b2cff4d1234c0f5d72c500 Mon Sep 17 00:00:00 2001 From: Paul Dejardin Date: Tue, 14 Oct 2025 04:44:13 -0400 Subject: [PATCH 1/4] webview-ui watches too many files to the point my OS ran out of file watchers. this should reduce it to only src files whose modification might necessitate rebuilding --- webview-ui/vite.config.ts | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/webview-ui/vite.config.ts b/webview-ui/vite.config.ts index e8b267ba238..750f2481624 100644 --- a/webview-ui/vite.config.ts +++ b/webview-ui/vite.config.ts @@ -165,6 +165,57 @@ export default defineConfig(({ mode }) => { }, server: { host: "0.0.0.0", // kilocode_change + watch: { + // Use polling to reduce file watcher usage + usePolling: true, + interval: 1000, + ignored: [ + "**/node_modules/**", + "**/dist/**", + "**/.git/**", + "**/logs/**", + "**/.turbo/**", + "**/coverage/**", + "**/.nyc_output/**", + // Exclude asset directories (static files don't need watching) + "../src/assets/**", + "../src/i18n/locales/**", + // Exclude test utilities and build artifacts + "../src/test-llm-autocompletion/**", + "../src/walkthrough/**", + "../src/__tests__/**", + "../src/__mocks__/**", + // Exclude all non-TS/JS files + "../**/*.md", + "../**/*.json", + "../**/*.yml", + "../**/*.yaml", + "../**/*.txt", + "../**/*.log", + "../**/*.png", + "../**/*.jpg", + "../**/*.jpeg", + "../**/*.gif", + "../**/*.svg", + "../**/*.ico", + "../**/*.woff", + "../**/*.woff2", + "../**/*.ttf", + "../**/*.eot", + // Exclude packages directory (build artifacts) + "../packages/**/dist/**", + "../packages/**/build/**", + // Exclude apps directory + "../apps/**", + // Exclude other non-essential directories + "../benchmark/**", + "../jetbrains/**", + "../launch/**", + "../releases/**", + "../run/**", + "../scripts/**", + ], + }, hmr: { // host: "localhost", kilocode_change protocol: "ws", From 73dce4f30539baccddd0a4ec7672f2a2d5becf98 Mon Sep 17 00:00:00 2001 From: Paul Dejardin Date: Tue, 14 Oct 2025 13:04:21 -0400 Subject: [PATCH 2/4] watchers don't need to be set up in the esbuild because the server already handles rebuilding when watched files are changed, so we should just need to remove the i18n locales folder from the ignored list. the setupLocaleWatcher was the thing making the dev process consume all the file watchers, but having too many files not ignored definately contributed. can tell because if you look in the web tools console the first file it fails to watch is a vscode config file from outside the entire project folder, which means that it ran out of file watchers before the extension started, but did so gracefully. then the extension tried to setup more watchers (actually necessary ones for config files and settings files and that's when it fails and dev process exits --- packages/build/src/esbuild.ts | 10 ++++------ webview-ui/vite.config.ts | 10 ++++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/build/src/esbuild.ts b/packages/build/src/esbuild.ts index 3b793c2cc93..ec5d6e0ab37 100644 --- a/packages/build/src/esbuild.ts +++ b/packages/build/src/esbuild.ts @@ -192,12 +192,10 @@ export function setupLocaleWatcher(srcDir: string, distDir: string) { } try { - fs.watch(localesDir, { recursive: true }, (_eventType, filename) => { - if (filename && filename.endsWith(".json")) { - console.log(`Locale file ${filename} changed, triggering copy...`) - debouncedCopy() - } - }) + // it isn't necessary to watch i18n files here because it's handled much more robustly in the vite watch, just need to configure it + // to actually do so + debouncedCopy() + console.log("Watcher for locale files is set up") } catch (error) { console.error( diff --git a/webview-ui/vite.config.ts b/webview-ui/vite.config.ts index 750f2481624..c98661f5266 100644 --- a/webview-ui/vite.config.ts +++ b/webview-ui/vite.config.ts @@ -166,9 +166,7 @@ export default defineConfig(({ mode }) => { server: { host: "0.0.0.0", // kilocode_change watch: { - // Use polling to reduce file watcher usage - usePolling: true, - interval: 1000, + usePolling: false, ignored: [ "**/node_modules/**", "**/dist/**", @@ -179,12 +177,13 @@ export default defineConfig(({ mode }) => { "**/.nyc_output/**", // Exclude asset directories (static files don't need watching) "../src/assets/**", - "../src/i18n/locales/**", // Exclude test utilities and build artifacts "../src/test-llm-autocompletion/**", "../src/walkthrough/**", "../src/__tests__/**", "../src/__mocks__/**", + "src/**/__tests__/**", + "src/**/__mocks__/**", // Exclude all non-TS/JS files "../**/*.md", "../**/*.json", @@ -202,6 +201,9 @@ export default defineConfig(({ mode }) => { "../**/*.woff2", "../**/*.ttf", "../**/*.eot", + "src/**/*.css", + "src/**/*.scss", + "src/**/*.less", // Exclude packages directory (build artifacts) "../packages/**/dist/**", "../packages/**/build/**", From 81108858e209086f7bfbc0db47df8f413ae76f45 Mon Sep 17 00:00:00 2001 From: Paul Dejardin Date: Tue, 14 Oct 2025 14:51:42 -0400 Subject: [PATCH 3/4] allow accessing files from vite outside of its project root but still in the workspace --- webview-ui/vite.config.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/webview-ui/vite.config.ts b/webview-ui/vite.config.ts index c98661f5266..ecbf858dc7e 100644 --- a/webview-ui/vite.config.ts +++ b/webview-ui/vite.config.ts @@ -165,6 +165,10 @@ export default defineConfig(({ mode }) => { }, server: { host: "0.0.0.0", // kilocode_change + fs: { + // Allow serving files from parent directories for locale watching + allow: ["..", "../src/i18n/locales"], + }, watch: { usePolling: false, ignored: [ @@ -184,9 +188,8 @@ export default defineConfig(({ mode }) => { "../src/__mocks__/**", "src/**/__tests__/**", "src/**/__mocks__/**", - // Exclude all non-TS/JS files + // Exclude all non-TS/JS files EXCEPT locale JSON files "../**/*.md", - "../**/*.json", "../**/*.yml", "../**/*.yaml", "../**/*.txt", @@ -204,6 +207,8 @@ export default defineConfig(({ mode }) => { "src/**/*.css", "src/**/*.scss", "src/**/*.less", + "src/i18n/locales/**", + "!../src/i18n/locales", // Exclude packages directory (build artifacts) "../packages/**/dist/**", "../packages/**/build/**", From 3c212e0705c2d308a28cb73ecbd77854f02abf87 Mon Sep 17 00:00:00 2001 From: Paul Dejardin Date: Tue, 14 Oct 2025 14:57:50 -0400 Subject: [PATCH 4/4] this is a revert to the prior removal of fs.watch from esbuild.ts. we just needed to allow vite to access files outside of its root dir, which includes locales in the src package --- packages/build/src/esbuild.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/build/src/esbuild.ts b/packages/build/src/esbuild.ts index ec5d6e0ab37..3b793c2cc93 100644 --- a/packages/build/src/esbuild.ts +++ b/packages/build/src/esbuild.ts @@ -192,10 +192,12 @@ export function setupLocaleWatcher(srcDir: string, distDir: string) { } try { - // it isn't necessary to watch i18n files here because it's handled much more robustly in the vite watch, just need to configure it - // to actually do so - debouncedCopy() - + fs.watch(localesDir, { recursive: true }, (_eventType, filename) => { + if (filename && filename.endsWith(".json")) { + console.log(`Locale file ${filename} changed, triggering copy...`) + debouncedCopy() + } + }) console.log("Watcher for locale files is set up") } catch (error) { console.error(