Skip to content

Commit 6eaa7b6

Browse files
authored
🤖 fix: restore React DevTools by reverting to dynamic import (#707)
The refactor in a55417a changed from using dynamic import() inside app.whenReady() to using require() at module load time. This broke React DevTools because electron-devtools-installer accesses Electron APIs that aren't available until the app is ready. Reverted to the working approach from commit 1e08943 that uses await import() inside the app.whenReady() handler. _Generated with `mux`_
1 parent 9003a8a commit 6eaa7b6

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

docs/AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ gh pr view <number> --json mergeable,mergeStateStatus | jq '.'
1818
./scripts/wait_pr_checks.sh <pr_number>
1919
```
2020

21+
- Generally run `wait_pr_checks` after submitting a PR to ensure CI passes.
2122
- Status decoding: `mergeable=MERGEABLE` clean; `CONFLICTING` needs resolution. `mergeStateStatus=CLEAN` ready, `BLOCKED` waiting for CI, `BEHIND` rebase, `DIRTY` conflicts.
2223
- If behind: `git fetch origin && git rebase origin/main && git push --force-with-lease`.
2324
- Never enable auto-merge or merge at all unless the user explicitly says "merge it".

src/desktop/main.ts

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,7 @@ import assert from "@/common/utils/assert";
2525
import { loadTokenizerModules } from "@/node/utils/main/tokenizer";
2626

2727
// React DevTools for development profiling
28-
// Using require() instead of import since it's dev-only and conditionally loaded
29-
interface Extension {
30-
name: string;
31-
id: string;
32-
}
33-
34-
type ExtensionInstaller = (
35-
ext: { id: string },
36-
options?: { loadExtensionOptions?: { allowFileAccess?: boolean } }
37-
) => Promise<Extension>;
38-
39-
let installExtension: ExtensionInstaller | null = null;
40-
let REACT_DEVELOPER_TOOLS: { id: string } | null = null;
41-
42-
if (!app.isPackaged) {
43-
try {
44-
// eslint-disable-next-line @typescript-eslint/no-require-imports
45-
const devtools = require("electron-devtools-installer") as {
46-
default: ExtensionInstaller;
47-
REACT_DEVELOPER_TOOLS: { id: string };
48-
};
49-
installExtension = devtools.default;
50-
REACT_DEVELOPER_TOOLS = devtools.REACT_DEVELOPER_TOOLS;
51-
} catch (error) {
52-
console.log("React DevTools not available:", error);
53-
}
54-
}
28+
// Using dynamic import() to avoid loading electron-devtools-installer at module init time
5529

5630
// IMPORTANT: Lazy-load heavy dependencies to maintain fast startup time
5731
//
@@ -509,8 +483,12 @@ if (gotTheLock) {
509483
migrateLegacyMuxHome();
510484

511485
// Install React DevTools in development
512-
if (!app.isPackaged && installExtension && REACT_DEVELOPER_TOOLS) {
486+
if (!app.isPackaged) {
513487
try {
488+
// eslint-disable-next-line no-restricted-syntax
489+
const { default: installExtension, REACT_DEVELOPER_TOOLS } = await import(
490+
"electron-devtools-installer"
491+
);
514492
const extension = await installExtension(REACT_DEVELOPER_TOOLS, {
515493
loadExtensionOptions: { allowFileAccess: true },
516494
});

0 commit comments

Comments
 (0)