Skip to content

fix(extension): sync-first user-script evaluate so CSP-strict pages work in Search - #34

Merged
jack-arturo merged 1 commit into
mainfrom
fix/userscripts-sync-first
Nov 8, 2026
Merged

jack-arturo merged 1 commit into
mainfrom
fix/userscripts-sync-first

Conversation

@jack-arturo

Copy link
Copy Markdown
Member

Search's userScripts.execute doesn't await a promise returned by the injected script, so on CSP-strict pages (e.g. Todoist) evaluate/snapshot failed with userScripts.execute returned no result.

This runs a synchronous wrapper first and only falls back to the async wrapper when the expression itself returns a thenable.

Verified: live in Search on app.todoist.com, evaluate and snapshot now return content. npx vitest run in extension/: 87 passed (updated the userScripts test, added an async-fallback test).

Known gap: type still fails in Search on these pages because its injected helper is async; follow-up could make it synchronous too.

…rks in Search

Search's userScripts.execute does not await a promise returned by the injected
script, so the async wrapper came back with no result on CSP-strict pages
(e.g. Todoist). Try a synchronous wrapper first and only fall back to the
async one when the expression itself returns a thenable.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T02:16:41.303412Z 7154ad0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7154ad0e7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 697 to +698
const [first] = await api.execute<EvalOutcome>({
js: [{ code }],
js: [{ code: asyncCode }],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Await the original promise instead of executing the expression again

On CSP-strict pages using the user-script fallback, any promise-returning expression now executes twice: syncCode starts the operation and discards its promise, then this fallback evaluates the same expression again. This affects the async fill/type helpers in cli-js/src/tool.js as well as user evaluations containing mutating requests, potentially duplicating input or server-side changes. Running the two generated wrappers with an async counter increment confirms two increments for one evaluation. Preserve the original promise and retrieve its outcome rather than rerunning the expression; the new test mocks both results without executing the injected code, so it misses this regression.

Useful? React with 👍 / 👎.

@jack-arturo
jack-arturo merged commit 3263e65 into main Nov 8, 2026
6 checks passed
@jack-arturo
jack-arturo deleted the fix/userscripts-sync-first branch November 8, 2026 04:01
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.

1 participant