Skip to content

feat: add default_state option to popup actions#2010

Merged
aklinker1 merged 6 commits intowxt-dev:mainfrom
kairi003:fix/add-action-default-state
Apr 26, 2026
Merged

feat: add default_state option to popup actions#2010
aklinker1 merged 6 commits intowxt-dev:mainfrom
kairi003:fix/add-action-default-state

Conversation

@kairi003
Copy link
Copy Markdown
Contributor

@kairi003 kairi003 commented Dec 19, 2025

Overview

This PR adds support for the default_state option in popup actions (browser_action/page_action for MV2, action for MV3). This option controls the initial enabled/disabled state of the extension's action button, as documented in the Chrome Extension Action API.

Previously, WXT did not support configuring this property in the manifest, making it impossible to set the action button to a disabled state before any runtime methods are called. This PR allows setting the initial state declaratively in the entrypoint options, following the same pattern as the existing options.

Changes

  • Added defaultState property to PopupEntrypointOptions type
  • Updated manifest generation logic to include default_state when specified
  • Updated browser API type definitions to support the property
  • Added comprehensive tests for MV2 and MV3 manifest generation

Manual Testing

Verified in wxt-demo:

  • Added default_state: "disabled" to wxt.config.ts manifest configuration
  • Confirmed TypeScript type checking passes without errors
  • Built the extension and verified default_state property is correctly included in the generated manifest.json

Related Issue

No related issue - this is a standalone enhancement to improve manifest configuration options.

@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 19, 2025

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 29495ad
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/69ee8a94cc01830008930587
😎 Deploy Preview https://deploy-preview-2010--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.

@kairi003 kairi003 force-pushed the fix/add-action-default-state branch 2 times, most recently from e7727f5 to a22fe24 Compare December 25, 2025 08:07
@kairi003 kairi003 force-pushed the fix/add-action-default-state branch from a22fe24 to f6c380e Compare January 20, 2026 10:18
Copy link
Copy Markdown
Member

@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.

Just undo your change to the browser package and add a @ts-expect-error like mentioned in the comemnt. Then I'll approve!

Sorry for the delay, and thanks for opening a PR 😄

Comment thread packages/browser/src/gen/index.d.ts
@PatrykKuniczak
Copy link
Copy Markdown
Collaborator

@kairi003 Are you want to go on?

@PatrykKuniczak
Copy link
Copy Markdown
Collaborator

@kairi003 One more poke :)

@kairi003 kairi003 force-pushed the fix/add-action-default-state branch 3 times, most recently from 63ceef1 to b2239f4 Compare April 24, 2026 13:40
@kairi003 kairi003 requested a review from aklinker1 April 24, 2026 13:53
@kairi003
Copy link
Copy Markdown
Contributor Author

@aklinker1 @PatrykKuniczak
Sorry for the delay. I’ve made the requested changes based on your comments.
Could you please confirm whether this looks good?

Comment thread packages/wxt/src/types.ts
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 24, 2026

Open in StackBlitz

@wxt-dev/analytics

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

@wxt-dev/auto-icons

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

@wxt-dev/browser

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

@wxt-dev/i18n

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

@wxt-dev/is-background

npm i https://pkg.pr.new/@wxt-dev/is-background@2010

@wxt-dev/module-react

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

@wxt-dev/module-solid

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

@wxt-dev/module-svelte

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

@wxt-dev/module-vue

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

@wxt-dev/runner

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

@wxt-dev/storage

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

@wxt-dev/unocss

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

@wxt-dev/webextension-polyfill

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

wxt

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

commit: 29495ad

@kairi003 kairi003 requested a review from PatrykKuniczak April 24, 2026 15:34
Copy link
Copy Markdown
Collaborator

@PatrykKuniczak PatrykKuniczak left a comment

Choose a reason for hiding this comment

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

LGTM

@PatrykKuniczak
Copy link
Copy Markdown
Collaborator

@kairi003

@PatrykKuniczak
Copy link
Copy Markdown
Collaborator

@kairi003 WAIT, tests issue.
Let's adjust it

@kairi003
Copy link
Copy Markdown
Contributor Author

@kairi003 WAIT, tests issue. Let's adjust it

@PatrykKuniczak
I fixed a test failure by making default_state only emitted for non-Firefox builds. Does this look good?

@PatrykKuniczak
Copy link
Copy Markdown
Collaborator

@kairi003 Let's see details of this error, fix from previous commit doesn't work.
Let's revert this commit, because we'll handle removing props in other way someday #2301

@kairi003 kairi003 force-pushed the fix/add-action-default-state branch from 737ced9 to 4101aea Compare April 26, 2026 14:29
Comment thread packages/wxt/src/core/utils/__tests__/manifest.test.ts
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.67%. Comparing base (1dbdf4e) to head (29495ad).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2010      +/-   ##
==========================================
+ Coverage   79.58%   79.67%   +0.08%     
==========================================
  Files         130      130              
  Lines        3802     3804       +2     
  Branches      860      861       +1     
==========================================
+ Hits         3026     3031       +5     
+ Misses        691      689       -2     
+ Partials       85       84       -1     

☔ 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 e613b54 into wxt-dev:main Apr 26, 2026
18 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

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.

3 participants