Skip to content

feat: add /print slash command - #2800

Merged
esokullu merged 3 commits into
webbrain-one:mainfrom
alectimison-maker:feat/print-slash-command
Aug 16, 2026
Merged

feat: add /print slash command#2800
esokullu merged 3 commits into
webbrain-one:mainfrom
alectimison-maker:feat/print-slash-command

Conversation

@alectimison-maker

Copy link
Copy Markdown
Contributor

Summary

  • Add a /print slash command that opens the active page's native print dialog in Chrome and Firefox.
  • Add localized command and error copy for all 23 extension locales, documentation, and regression coverage.

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

/print is a no-argument command. The side panel verifies that the initiating tab is still the active tab, then invokes the page's window.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
  • Chrome unpacked extension — WebBrain was enabled and loaded from its real extension origin; /pri exposed the localized /print autocomplete entry, executing /print consumed the command, and the extension reported no console or page errors

Unavailable browser checks:

  • The system-level print preview could not be captured or directly observed through browser automation.
  • Firefox unpacked verification was not run.

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

  • No format arguments such as /print pdf.
  • No custom PDF renderer or file conversion.
  • No arbitrary selected-text printing.

Closes #2795

@vercel

vercel Bot commented Aug 15, 2026

Copy link
Copy Markdown

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread test/run.js Outdated
Comment on lines +23523 to +23527
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');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

…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.
@alectimison-maker

Copy link
Copy Markdown
Contributor Author

Copilot review resolved — commit cdb8c9ff extracts the /print route into executePrintSlashCommand and adds behavioral tests that run the helper with mocked tab/scripting APIs for both builds, covering the success path, stale tab, inactive/background tab, and rejected-injection (localized toast) cases. The previous test only matched source text; it now executes the actual route logic. Verified: node test/run.js green.

@esokullu
esokullu merged commit 9b1e7e8 into webbrain-one:main Aug 16, 2026
1 of 2 checks passed
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.

slashcommand print

3 participants