Skip to content

fix: recreating keyboardShortcuts interface on file changes. #1465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/wxt/src/core/create-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,13 @@

// Listen for file changes and reload different parts of the extension accordingly
const reloadOnChange = createFileReloader(server);
server.watcher.on('all', reloadOnChange);
keyboardShortcuts.start();
server.watcher.on('all', async (...args) => {
await reloadOnChange(args[0], args[1]);

Check warning on line 114 in packages/wxt/src/core/create-server.ts

View check run for this annotation

Codecov / codecov/patch

packages/wxt/src/core/create-server.ts#L114

Added line #L114 was not covered by tests

// Restart keyboard shortcuts after file is changed - for some reason they stop working.
keyboardShortcuts.start();

Check warning on line 117 in packages/wxt/src/core/create-server.ts

View check run for this annotation

Codecov / codecov/patch

packages/wxt/src/core/create-server.ts#L117

Added line #L117 was not covered by tests
});

keyboardShortcuts.printHelp({
canReopenBrowser:
!wxt.config.runnerConfig.config.disabled && !!runner.canOpen?.(),
Expand Down
7 changes: 2 additions & 5 deletions packages/wxt/src/core/keyboard-shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

return {
start() {
if (rl) return;

rl = readline.createInterface({
rl ??= readline.createInterface({

Check warning on line 29 in packages/wxt/src/core/keyboard-shortcuts.ts

View check run for this annotation

Codecov / codecov/patch

packages/wxt/src/core/keyboard-shortcuts.ts#L29

Added line #L29 was not covered by tests
input: process.stdin,
terminal: false, // Don't intercept ctrl+C, ctrl+Z, etc
});
Expand All @@ -37,8 +35,7 @@
},

stop() {
rl?.close();
rl = undefined;
rl?.removeListener('line', handleInput);
},

printHelp(flags) {
Expand Down