Skip to content

Fix configs not loading when configs folder contains subdirectories (#1392)#1539

Merged
SukuWc merged 1 commit into
stablefrom
fix/1392-configs-missing-when-source-controlled
Jun 26, 2026
Merged

Fix configs not loading when configs folder contains subdirectories (#1392)#1539
SukuWc merged 1 commit into
stablefrom
fix/1392-configs-missing-when-source-controlled

Conversation

@SukuWc

@SukuWc SukuWc commented Jun 23, 2026

Copy link
Copy Markdown
Member

Problem

Fixes #1392. When the grid-userdata/configs folder contains a subdirectory — most commonly a .git folder 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 flat readdir and called fs.promises.readFile() on every entry with no type check and no error handling:

const files = await fs.promises.readdir(`${path}/${rootDirectory}`);
for (const file of files) {
  await fs.promises.readFile(filepath, "utf-8").then(...); // EISDIR on a directory
}

The moment it hit a directory entry, readFile rejected with EISDIR, the unguarded await threw, 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() (no await, no .catch). The rejection became an unhandled main-process rejection, invisible to the renderer DevTools console, and webContents.send("sendConfigsToRenderer", ...) simply never ran — a silent empty state.

Changes

  • profiles.ts: read with withFileTypes and only process .json files, skipping subdirectories and other entries. Each read is wrapped in try/catch so one bad/corrupt file can't abort the rest.
  • main.ts: wrap the watcher's sendLocalConfigs() body in try/catch so a load failure is logged via log.error instead of becoming a silent unhandled rejection.
  • main.ts: drop the custom %c coloring on [ELECTRON] forwarded logs (plain prefix now).

Testing

  • Type-checks clean (tsc --noEmit).
  • Verified the load logic against a real configs folder containing a subdirectory: original throws EISDIR → 0 configs; fixed → all configs load.

🤖 Generated with Claude Code

…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>
@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

@Greg-Orca Greg-Orca moved this from Ready for QA to Done in Editor Roadmap Jun 24, 2026
@SukuWc SukuWc merged commit 7ed854f into stable Jun 26, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: configs not appearing in editor when configs folder is source controlled

2 participants