Fix configs not loading when configs folder contains subdirectories (#1392)#1539
Merged
Merged
Conversation
…1392) loadConfigsFromDirectory did a flat readdir and called readFile on every entry. A subdirectory in the configs folder (e.g. a .git folder when the folder is under source control, or a .claude folder) made readFile throw EISDIR. The unguarded await aborted the whole load, so the renderer received zero configs instead of just skipping the directory. - Read with withFileTypes and only process .json files, skipping subdirectories and other non-config entries. - Wrap each read in try/catch so one bad file can't abort the rest. - Wrap the watcher's sendLocalConfigs() in try/catch so a load failure is logged instead of becoming a silent unhandled main-process rejection (the original reason no error surfaced in the renderer console). - Drop the custom %c coloring on [ELECTRON] forwarded logs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Visit the preview URL for this PR (updated for commit ee46c21): https://grid-editor-web--pr1539-fix-1392-configs-mis-paulrtdp.web.app (expires Thu, 23 Jul 2026 13:35:46 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 2b65ba6ef19c55d367eaffd04e46bcde25305d6f |
|
Visit the preview URL for this PR (updated for commit ee46c21): https://grid-playwright-result--pr1539-fix-1392-configs-mis-9hdogmhb.web.app (expires Fri, 26 Jun 2026 13:44:07 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 0f764ceb264072188bf1a5dee10613d8f10b4ca2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #1392. When the
grid-userdata/configsfolder contains a subdirectory — most commonly a.gitfolder when the user puts the configs under source control — all or some configs disappear from the editor due to a runtime error during directory read. Deleting the subdirectory makes them reappear after restarting the App.Root cause
loadConfigsFromDirectory(src/electron/src/profiles.ts) did a flatreaddirand calledfs.promises.readFile()on every entry with no type check and no error handling:The moment it hit a directory entry,
readFilerejected withEISDIR, the unguardedawaitthrew, and the entire function rejected — so the renderer got zero (or some but not all) configs instead of just skipping the directory.Reproduced against a real configs folder: the original loop threw
EISDIR; the fixed loop loads all configs.Why no error showed in the console
The initial load runs in the main process via the watcher's fire-and-forget
sendLocalConfigs()(noawait, no.catch). The rejection became an unhandled main-process rejection, invisible to the renderer DevTools console, andwebContents.send("sendConfigsToRenderer", ...)simply never ran — a silent empty state.Changes
profiles.ts: read withwithFileTypesand only process.jsonfiles, skipping subdirectories and other entries. Each read is wrapped intry/catchso one bad/corrupt file can't abort the rest.main.ts: wrap the watcher'ssendLocalConfigs()body intry/catchso a load failure is logged vialog.errorinstead of becoming a silent unhandled rejection.main.ts: drop the custom%ccoloring on[ELECTRON]forwarded logs (plain prefix now).Testing
tsc --noEmit).EISDIR→ 0 configs; fixed → all configs load.🤖 Generated with Claude Code