feat: add /print slash command - #2800
Conversation
|
@alectimison-maker is attempting to deploy a commit to the esokullu's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Adds a cross-browser /print slash command that opens the active page’s native print dialog.
Changes:
- Implements active-tab validation and browser-specific script injection.
- Adds selection-scope and active-run safeguards.
- Adds documentation, tests, and translations for all 23 locales.
Reviewed changes
Copilot reviewed 44 out of 50 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
docs/slash-commands.md |
Documents /print. |
test/run.js |
Adds parser and source-level regression checks. |
src/chrome/src/ui/sidepanel.js |
Implements Chrome print handling. |
src/firefox/src/ui/sidepanel.js |
Implements Firefox print handling. |
src/chrome/src/ui/locales/ar.js |
Adds Arabic copy. |
src/chrome/src/ui/locales/bn.js |
Adds Bengali copy. |
src/chrome/src/ui/locales/de.js |
Adds German copy. |
src/chrome/src/ui/locales/en.js |
Adds English copy. |
src/chrome/src/ui/locales/es.js |
Adds Spanish copy. |
src/chrome/src/ui/locales/fa.js |
Adds Persian copy. |
src/chrome/src/ui/locales/fr.js |
Adds French copy. |
src/chrome/src/ui/locales/he.js |
Adds Hebrew copy. |
src/chrome/src/ui/locales/hi.js |
Adds Hindi copy. |
src/chrome/src/ui/locales/id.js |
Adds Indonesian copy. |
src/chrome/src/ui/locales/ja.js |
Adds Japanese copy. |
src/chrome/src/ui/locales/ko.js |
Adds Korean copy. |
src/chrome/src/ui/locales/ms.js |
Adds Malay copy. |
src/chrome/src/ui/locales/nl.js |
Adds Dutch copy. |
src/chrome/src/ui/locales/pl.js |
Adds Polish copy. |
src/chrome/src/ui/locales/pt.js |
Adds Portuguese copy. |
src/chrome/src/ui/locales/ru.js |
Adds Russian copy. |
src/chrome/src/ui/locales/th.js |
Adds Thai copy. |
src/chrome/src/ui/locales/tl.js |
Adds Tagalog copy. |
src/chrome/src/ui/locales/tr.js |
Adds Turkish copy. |
src/chrome/src/ui/locales/uk.js |
Adds Ukrainian copy. |
src/chrome/src/ui/locales/vi.js |
Adds Vietnamese copy. |
src/chrome/src/ui/locales/zh.js |
Adds Chinese copy. |
src/firefox/src/ui/locales/ar.js |
Adds Arabic copy. |
src/firefox/src/ui/locales/bn.js |
Adds Bengali copy. |
src/firefox/src/ui/locales/de.js |
Adds German copy. |
src/firefox/src/ui/locales/en.js |
Adds English copy. |
src/firefox/src/ui/locales/es.js |
Adds Spanish copy. |
src/firefox/src/ui/locales/fa.js |
Adds Persian copy. |
src/firefox/src/ui/locales/fr.js |
Adds French copy. |
src/firefox/src/ui/locales/he.js |
Adds Hebrew copy. |
src/firefox/src/ui/locales/hi.js |
Adds Hindi copy. |
src/firefox/src/ui/locales/id.js |
Adds Indonesian copy. |
src/firefox/src/ui/locales/ja.js |
Adds Japanese copy. |
src/firefox/src/ui/locales/ko.js |
Adds Korean copy. |
src/firefox/src/ui/locales/ms.js |
Adds Malay copy. |
src/firefox/src/ui/locales/nl.js |
Adds Dutch copy. |
src/firefox/src/ui/locales/pl.js |
Adds Polish copy. |
src/firefox/src/ui/locales/pt.js |
Adds Portuguese copy. |
src/firefox/src/ui/locales/ru.js |
Adds Russian copy. |
src/firefox/src/ui/locales/th.js |
Adds Thai copy. |
src/firefox/src/ui/locales/tl.js |
Adds Tagalog copy. |
src/firefox/src/ui/locales/tr.js |
Adds Turkish copy. |
src/firefox/src/ui/locales/uk.js |
Adds Ukrainian copy. |
src/firefox/src/ui/locales/vi.js |
Adds Vietnamese copy. |
src/firefox/src/ui/locales/zh.js |
Adds Chinese copy. |
Files not reviewed (6)
- src/chrome/src/ui/locales/bn.js: Generated file
- src/chrome/src/ui/locales/hi.js: Generated file
- src/chrome/src/ui/locales/ru.js: Generated file
- src/chrome/src/ui/locales/th.js: Generated file
- src/chrome/src/ui/locales/uk.js: Generated file
- src/firefox/src/ui/locales/bn.js: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| assert.match(route, /tabs\.get\(tabId\)/, `${label}: /print should validate the initiating tab`); | ||
| assert.match(route, /currentTabId !== tabId \|\| !tab\?\.active/, `${label}: /print should not target a stale or background tab`); | ||
| assert.match(route, /sp\.print\.error/, `${label}: /print failures should be visible`); | ||
| if (label === 'chrome') { | ||
| assert.match(route, /chrome\.scripting\.executeScript\(\{[\s\S]*?target: \{ tabId \},[\s\S]*?func: \(\) => window\.print\(\)/, 'chrome: /print should invoke the page print dialog through MV3 scripting'); |
…ral tests Extract /print route logic into a testable executePrintSlashCommand helper in both Chrome and Firefox sidepanels. Add Node tests covering success, stale-tab, inactive-tab, and rejected-injection paths. Addresses review feedback in PR webbrain-one#2800.
|
Copilot review resolved — commit |
Summary
/printslash command that opens the active page's native print dialog in Chrome and Firefox.Motivation
Issue #2795 asks for a slash command that opens the native print dialog so users can choose PDF, a printer, or another browser-provided destination.
Design
/printis a no-argument command. The side panel verifies that the initiating tab is still the active tab, then invokes the page'swindow.print()through the browser-specific script injection API. Injection failures are surfaced as a localized composer message.The browser's native dialog owns output format and destination selection; WebBrain does not add format flags or implement its own PDF conversion. The command is also blocked by the existing selected-text conversation boundary because it accesses the full page/screen, not arbitrary selected content.
The command remains gated while an agent run is active so a modal print dialog cannot interrupt page automation.
Testing
npm test— passed (33 toolbar guard tests, 1752 main tests, 60 security checks)git diff --check upstream/main...HEAD— passed/priexposed the localized/printautocomplete entry, executing/printconsumed the command, and the extension reported no console or page errorsUnavailable browser checks:
Compatibility and risks
Chrome MV3 and Firefox MV2 use their existing scripting permissions and browser-specific injection APIs. Restricted browser pages can reject injection; users receive the localized error instead of a silent failure. Printed content and layout remain controlled by the page's print styles and the browser's native dialog.
Scope
/print pdf.Closes #2795