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

Conversation

nishu-murmu
Copy link
Contributor

Overview

I noticed that keyboard shortcuts weren't working after files were being saved or HMR was triggered.
Hope this fixes it.

Copy link

netlify bot commented Feb 28, 2025

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit abc7f15
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/68412b29909b4200089167a5
😎 Deploy Preview https://deploy-preview-1465--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nishu-murmu nishu-murmu changed the title fix: restarting keyboardShortcuts listener on file changes. fix: recreating keyboardShortcuts interface on file changes. Feb 28, 2025
Copy link
Member

@Timeraa Timeraa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was noticing this too but wouldn't this potentially be a memory leak since we keep creating it?

@nishu-murmu
Copy link
Contributor Author

Was noticing this too but wouldn't this potentially be a memory leak since we keep creating it?

Yeah, now that I think about it, it really can be. as such there are already existing issues for windows.
We can just close the listeners instead of the interface. That way only one interface will be used.

Copy link

pkg-pr-new bot commented Mar 23, 2025

Open in StackBlitz

@wxt-dev/analytics

npm i https://pkg.pr.new/@wxt-dev/analytics@1465

@wxt-dev/auto-icons

npm i https://pkg.pr.new/@wxt-dev/auto-icons@1465

@wxt-dev/browser

npm i https://pkg.pr.new/@wxt-dev/browser@1465

@wxt-dev/i18n

npm i https://pkg.pr.new/@wxt-dev/i18n@1465

@wxt-dev/module-react

npm i https://pkg.pr.new/@wxt-dev/module-react@1465

@wxt-dev/module-solid

npm i https://pkg.pr.new/@wxt-dev/module-solid@1465

@wxt-dev/module-svelte

npm i https://pkg.pr.new/@wxt-dev/module-svelte@1465

@wxt-dev/module-vue

npm i https://pkg.pr.new/@wxt-dev/module-vue@1465

@wxt-dev/runner

npm i https://pkg.pr.new/@wxt-dev/runner@1465

@wxt-dev/storage

npm i https://pkg.pr.new/@wxt-dev/storage@1465

@wxt-dev/unocss

npm i https://pkg.pr.new/@wxt-dev/unocss@1465

@wxt-dev/webextension-polyfill

npm i https://pkg.pr.new/@wxt-dev/webextension-polyfill@1465

wxt

npm i https://pkg.pr.new/wxt@1465

commit: abc7f15

Comment on lines 114 to 118
const reloadOnChange = createFileReloader(server);
const reloadOnChange = () => {
keyboardShortcuts.start();
keyboardShortcuts.printHelp({
canReopenBrowser:
!wxt.config.runnerConfig.config.disabled && !!runner.canOpen?.(),
});
return createFileReloader(server);
};
server.watcher.on('all', reloadOnChange);
keyboardShortcuts.start();
keyboardShortcuts.printHelp({
canReopenBrowser:
!wxt.config.runnerConfig.config.disabled && !!runner.canOpen?.(),
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One side-effect to this change is that the help message is printed after every file is saved, right? Should we leave the printHelp call outside the reloadOnChange where it was before so we only print the message when the server is started/restarted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can keep it outside, users can see it once when they restart the server.
Vite is also doing the same.

Copy link
Collaborator

@aklinker1 aklinker1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know why the readline interface stops working when a file is saved? Or are we just making a change in hopes that it fixes the problem?

Copy link
Collaborator

@aklinker1 aklinker1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge this and give it a go.

Edit: hmm, for some reason checks aren't running. I'll get the going when I get home.

Copy link

codecov bot commented Jun 5, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 80.90%. Comparing base (240bbb3) to head (abc7f15).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
packages/wxt/src/core/create-server.ts 50.00% 2 Missing ⚠️
packages/wxt/src/core/keyboard-shortcuts.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1465      +/-   ##
==========================================
- Coverage   81.27%   80.90%   -0.37%     
==========================================
  Files         130      130              
  Lines        6642     6642              
  Branches     1087     1086       -1     
==========================================
- Hits         5398     5374      -24     
- Misses       1233     1257      +24     
  Partials       11       11              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aklinker1 aklinker1 merged commit 6be9a4e into wxt-dev:main Jun 5, 2025
18 checks passed
Copy link
Contributor

github-actions bot commented Jun 5, 2025

Thanks for helping make WXT better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants