Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

[Zen Browser] Fix New Tab search on Windows - #32787

Merged
raycastbot merged 3 commits into
raycast:mainfrom
candygoogy:zen-browser-windows-search
Nov 6, 2026
Merged

raycastbot merged 3 commits into
raycast:mainfrom
candygoogy:zen-browser-windows-search

Conversation

@candygoogy

@candygoogy candygoogy commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #24362.

On Windows, New Tab starts Zen through PowerShell's Start-Process, which joins its arguments with spaces and passes them to Zen without quoting them. This breaks both search paths:

Search engine Script before Result
Google, DuckDuckGo, ... Start-Process "zen" 'https://google.com/search?q=two words' Zen gets https://google.com/search?q=two and words, so it opens a search for "two" plus a tab for http://words/ (#24362)
Browser Default (the default since the last update) Start-Process "zen" "-search" 'two words' Start-Process only takes two positional arguments, so every search fails with "A positional parameter cannot be found that accepts argument ...", even a single word

Changes in src/actions/powershell.ts:

  • A new windowsArg helper quotes each argument for the Windows command line ("...", with " escaped as \" and the backslashes before a quote doubled), and the scripts pass it with -ArgumentList. The whole string is still a single-quoted PowerShell literal, so $(...) in a query is not evaluated.
  • With Browser Default, Zen reads a -search value that starts with - or / as an option, even when it's quoted, and nothing opens. Such a query gets a leading space, which search engines ignore.

After review, two older issues in src/components/ZenActions.tsx are fixed too:

  • With a chosen search engine, the query is now passed through encodeURIComponent, so &, # and + stay part of the search (before, tom & jerry searched for tom ). This applies on macOS and Windows.
  • On Windows, opening a history entry used Start-Process "zen" "${url}", where PowerShell expands $ inside double quotes. It now goes through the same quoting as search (openUrlPowerShellScript, which replaces searchPowerShellScript).

The tests in tests/powershell.test.cjs are updated for the new scripts. A new Windows-only test passes windowsArg values through a real command line to a child process and checks that each one arrives as a single, unchanged argument.

Testing

On Windows 11 with Zen 1.23.4b:

  • npm run build and npm run lint pass, and node --test tests/powershell.test.cjs passes (11/11). With the old powershell.ts, 9 of the 11 tests fail.
  • I ran the scripts the same way runPowerShellScript does (powershell.exe -Command - with the script on stdin), with a local test search engine set as Zen's default, and logged the queries it received. Before: two words arrived as two plus an http://words/ tab, and Browser Default failed on every query. After: two words, say "hi" now, dir\sub\ "x", trailing\, it's $(calc) $env:USERNAME, caffè 日本, -foo bar, /r/rust and --help each arrive as one search, through both paths, whether Zen is already running or not.
  • The review fixes, run the same way: with the old code, tom & jerry, c++ #1 and a+b=c arrived as tom , c and a b=c, and a history URL containing $env:USERNAME and $(Get-Date -Format yyyy) arrived with both expanded (the command ran). With the fix, all of them arrive unchanged. npx tsc --noEmit also passes.
  • I didn't test it inside Raycast itself.

Checklist

@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: zen-browser Issues related to the zen-browser extension AI Extension platform: macOS platform: Windows labels Oct 26, 2026
@raycastbot

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! 🎉

🔔 @Keyruu @theherk @walker-tx @Jimmy-b36 @sdaza @elliothco @ridemountainpig @Davidferl @sjasct @pernielsentikaer @Zheckan @Diwanshumidha @vmrjnvc @MrGHPrice @Caffeine19 you might want to have a look.

You can use this guide to learn how to check out the Pull Request locally in order to test it.

📋 Quick checkout commands
BRANCH="zen-browser-windows-search"
FORK_URL="https://github.com/candygoogy/extensions.git"
EXTENSION_NAME="zen-browser"
REPO_NAME="extensions"

git clone -n --depth=1 --filter=tree:0 -b $BRANCH $FORK_URL
cd $REPO_NAME
git sparse-checkout set --no-cone "extensions/$EXTENSION_NAME"
git checkout
cd "extensions/$EXTENSION_NAME"
npm install && npm run dev

We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 15 business days.

@greptile-apps

greptile-apps Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Fixes Windows searches and history links in Zen Browser.

  • Windows New Tab searches reach Zen as one complete query.
  • Chosen-engine searches keep special characters in the search term.
  • Windows history links open without expanding $ expressions.

Reviews (3) · Last reviewed commit: "Update CHANGELOG.md" · Reviewed by Greptile

@0xdhrv 0xdhrv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey @candygoogy 👋

Thanks for your contribution 🔥 The windowsArg helper follows the Windows command-line quoting rules carefully (escaped quotes, doubled backslashes before a quote and at the end), and the Windows-only test that sends real values through a child process is a really solid way to prove each query arrives as one argument.

Here's everything I found in this pass:

Blocking

No issues found.

Optional (no action needed to merge)

  • In src/components/ZenActions.tsx, the explicit-engine path appends the raw query to the search URL (${searchUrlPrefix}${query}) on both platforms. A query with &, # or + could be cut short or changed by the search engine. Wrapping it in encodeURIComponent would keep it intact. This predates your PR, so it's fine as a follow-up.
  • Also in src/components/ZenActions.tsx, opening a history entry on Windows builds Start-Process "zen" "${url}". The URL sits in a double-quoted PowerShell string, so $ sequences in it can be expanded. Passing it through your new psLiteral(windowsArg(url)) would make it as safe as the search path. This also predates your PR.

Feel free to reach me here or on Slack if anything is unclear.

@0xdhrv
0xdhrv marked this pull request as draft November 4, 2026 06:47
@0xdhrv 0xdhrv self-assigned this Nov 4, 2026
@candygoogy

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I fixed both in this PR: the search query is now URL-encoded, and history entries on Windows go through the same quoting as search. Tested the same way against Zen on Windows; the PR description has the details.

@candygoogy
candygoogy marked this pull request as ready for review November 4, 2026 13:38

@0xdhrv 0xdhrv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, approved ✅

@raycastbot
raycastbot merged commit e86911a into raycast:main Nov 6, 2026
2 checks passed
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Published to the Raycast Store:
https://raycast.com/Keyruu/zen-browser

@raycastbot

Copy link
Copy Markdown
Collaborator

🎉 🎉 🎉

We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Extension extension fix / improvement Label for PRs with extension's fix improvements extension: zen-browser Issues related to the zen-browser extension platform: macOS platform: Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Zen Browser] Windows multi-word search opens multiple tabs

3 participants