Skip to content

fix(plugins): restore ChatGPT formula copy in Edge - #910

Closed
shallowaria wants to merge 4 commits into
Nagi-ovo:mainfrom
shallowaria:codex/fix-edge-chatgpt-formula-copy
Closed

fix(plugins): restore ChatGPT formula copy in Edge#910
shallowaria wants to merge 4 commits into
Nagi-ovo:mainfrom
shallowaria:codex/fix-edge-chatgpt-formula-copy

Conversation

@shallowaria

@shallowaria shallowaria commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #909

Description / 描述

Formula Copy had two independent failures on ChatGPT/Edge:

  • Edge could grant the optional ChatGPT host permission without reconciling the dynamically registered plugin content script. The popup now asks the background service to run the existing serialized registration sync after a successful grant, while keeping permissions.onAdded as the Chrome popup-close fallback.
  • Current ChatGPT KaTeX markup can omit MathML annotations. Formula Copy now reads the nearest data-math-source value and recognizes .katex-display as block math, while preserving the legacy annotation paths used by Claude, older ChatGPT markup, Gemini, and AI Studio.

The PR adds realistic ChatGPT inline/block DOM regression coverage, permission-registration routing tests, and a regression note.

Related Issue / 相关 Issue

Fixes #909

Visual Proof / 可视化证据

The contributor manually verified the rebuilt dist_chrome_dev package on the real ChatGPT formula from #909: hover styling appeared and clicking the formula copied the expected LaTeX successfully.

visual-prove.mp4

Browser Testing / 浏览器测试

Tested commit / 测试提交: 0788f16181e33ca77346eef5787c0d204a4f8278

Browser / version Scenario and result / 场景与结果 Evidence / 证据
Chrome on Windows (exact version not captured) Loaded the freshly rebuilt dist_chrome_dev, refreshed the real ChatGPT conversation, and clicked current data-math-source KaTeX. Copy succeeded with the configured LaTeX delimiters. Contributor live verification in #909 reproduction conversation

Missing checks and owner, or N/A reason / 缺失检查与负责人,或不适用理由:

  • Needs Edge live verification of optional host grant, dynamic registration, and ChatGPT formula copy; owner: @shallowaria.
  • Needs Firefox live plugin lifecycle/formula-copy smoke; owner: @shallowaria or a maintainer with Firefox access.
  • Needs Safari live plugin lifecycle/formula-copy smoke; owner: @shallowaria or a maintainer with Safari access.
  • Chrome exact version and redacted visual proof were not captured; owner: @shallowaria.
  • These checks remain explicit because builtin plugin changes require Chrome, Edge, Firefox, and Safari live coverage before merge.

Commands run / 已运行命令:

  • bun run typecheck
  • bun run lint:check — 0 errors; 209 existing warnings
  • bun run i18n:check — all 10 locales
  • Focused plugin/formula regression suite — 6 files, 56 tests
  • bunx vitest run --exclude scripts/__tests__/verify-release-privacy.test.ts --testTimeout 20000 --hookTimeout 30000 --silent — 273 files, 2537 tests
  • bun run build:chrome
  • $env:__DEV__='true'; bunx vite build --config vite.config.chrome.ts --mode development
  • bun run build:firefox
  • bun run build:safari
  • bun run docs:build
  • Final Prettier check on all 9 changed paths
  • git diff --check origin/main...HEAD

Commands not run and reason / 未运行命令及原因:

  • bun run verify:pr cannot complete on this Windows checkout because Prettier treats the repository's AGENTS.md symlink representation as changed. Its individual applicable gates were run separately.
  • scripts/__tests__/verify-release-privacy.test.ts requires repository symlinks that are unavailable in this Windows checkout, so the full test run excluded only that file.
  • bun run build:edge completed the Edge code build, but its final zip step failed because the external zip executable is unavailable on Windows. CI's Edge build remains required.
  • gh auth status and CLI-side PR verification were unavailable because GitHub CLI is not installed. The branch was pushed with Git and this draft PR was created through the authenticated GitHub web UI as @shallowaria.

Checklist / 检查清单

  • If I used an agent, I discussed the requirement, affected scope, and verification plan clearly. / 如果使用了 Agent,我已讨论清楚需求、影响范围和验证方式。
  • I have manually verified that the feature works as intended. / 我已手动验证功能按预期工作。
  • For UI/behavior changes, I have tried the real workflow for about 15 minutes when possible. / 对于 UI/行为改动,条件允许时我已用真实流程体验约 15 分钟。
  • For UI/behavior changes, I have included visual proof after verification. / 对于 UI/行为改动,我已在验证后提供可视化证据。
  • I have confirmed that this PR does not break existing functionality. / 我已确认此 PR 不会破坏原有功能。
  • This PR focuses on one issue or one coherent change. / 此 PR 只聚焦一个问题或一个清晰完整的改动。
  • I ran bun run format, bun run lint, then the standard local bun run verify:pr, or listed every omitted command and reason above. / 我已依次运行格式化、自动修复及标准本地 bun run verify:pr 验证,或在上方逐项说明未运行命令及原因。
  • I added/updated regression tests for behavior changes, or explained why no test is useful. / 行为改动已添加或更新回归测试;若无需测试,我已说明理由。
  • I listed the affected browsers actually tested and identified any required follow-up owner. / 我已列出实际测试的受影响浏览器,并标明所有必需补测的负责人。

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes

    • Improved copying of inline and block LaTeX formulas from ChatGPT, including correct $...$ and $$...$$ formatting.
    • Preserved formula-copy compatibility across supported AI platforms.
    • Improved plugin setup reliability by synchronizing content scripts after permissions are granted or repaired.
    • Improved recovery when required plugin permissions are denied or need to be restored.
  • Documentation

    • Added troubleshooting guidance for formula-copy issues.

Fixes Nagi-ovo#909

Co-authored-by: Codex <codex@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e899c81-92d2-4382-a8ff-7e9f67cff5d5

📥 Commits

Reviewing files that changed from the base of the PR and between c8a3f99 and 08f0c36.

📒 Files selected for processing (1)
  • src/pages/popup/components/PluginManager.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/popup/components/PluginManager.tsx

📝 Walkthrough

Walkthrough

The formula-copy service now supports current ChatGPT KaTeX markup. Plugin permission flows now request explicit background content-script synchronization and verify the resulting runtime message handling.

Changes

Formula copy support

Layer / File(s) Summary
ChatGPT KaTeX extraction and validation
src/features/formulaCopy/FormulaCopyService.ts, src/features/formulaCopy/FormulaCopyService.test.ts, .github/docs/REGRESSION_NOTES.md
Formula extraction reads data-math-source, detects .katex-display, preserves legacy annotation handling, and tests inline and block delimiters.

Plugin content-script synchronization

Layer / File(s) Summary
Synchronization message and background handling
src/features/plugins/runtime/messages.ts, src/pages/background/runtimeMessageRouting.ts, src/pages/background/index.ts, src/pages/background/__tests__/runtimeMessageRouting.test.ts
The background runtime accepts gv.plugins.syncContentScripts, awaits synchronization, returns { ok: true }, and tests the routing and repair branch.
Permission reconciliation and popup tests
src/pages/popup/components/PluginManager.tsx, src/pages/popup/components/__tests__/PluginManager.test.tsx
Plugin permission grants and repairs request content-script synchronization. Tests verify the message and its ordering after permission approval.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PluginManager
  participant BackgroundRuntimeMessageListener
  participant syncPluginContentScripts
  PluginManager->>BackgroundRuntimeMessageListener: send gv.plugins.syncContentScripts
  BackgroundRuntimeMessageListener->>syncPluginContentScripts: await synchronization
  syncPluginContentScripts-->>BackgroundRuntimeMessageListener: synchronization complete
  BackgroundRuntimeMessageListener-->>PluginManager: return { ok: true }
Loading

Possibly related PRs

  • Nagi-ovo/voyager#865: The ChatGPT KaTeX extraction changes directly relate to the formula-copy support introduced here.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the ChatGPT formula-copy fix in Edge, which matches the primary pull request objective.
Description check ✅ Passed The description covers the goal, issue, implementation, testing, visual proof, outstanding browser checks, and command limitations.
Linked Issues check ✅ Passed The changes address issue #909 by restoring ChatGPT formula detection, copying, and plugin registration synchronization in Edge.
Out of Scope Changes check ✅ Passed The formula changes, plugin synchronization changes, regression tests, and regression note support the linked issue and stated pull request objectives.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Comment @coderabbitai help to get the list of available commands.

@shallowaria

Copy link
Copy Markdown
Contributor Author

@codex review

Co-authored-by: Codex <codex@users.noreply.github.com>
@shallowaria

Copy link
Copy Markdown
Contributor Author

Updated the branch with the latest origin/main to resolve the regression-notes conflict without force-pushing.

Current tested head: b6e1eec60e06af8f4dfb9e94a561e23c705771ac

Post-merge verification:

  • bun run typecheck
  • Focused Formula Copy, popup permission, and background routing tests: 3 files / 29 tests
  • bunx prettier --check .github/docs/REGRESSION_NOTES.md
  • git diff --check origin/main...HEAD

The merge keeps the feature code from 0788f161 unchanged, so the contributor's live Chrome verification still applies.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 0788f16181

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@shallowaria

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: b6e1eec60e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@shallowaria

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Co-authored-by: Codex <codex@users.noreply.github.com>
@shallowaria

Copy link
Copy Markdown
Contributor Author

Addressed CodeRabbit's Docstring Coverage warning by documenting the only newly added production function, requestPluginContentScriptSync(), including its best-effort behavior and the permissions-listener fallback.

Current tested head: c8a3f99d80cb8d4247320172037fb2da2976eaf6

Verification:

  • bunx prettier --check src/pages/popup/components/PluginManager.tsx
  • bun run lint — 0 errors; 209 existing warnings
  • bun run typecheck
  • Focused Formula Copy, popup permission, and background routing tests — 3 files / 29 tests
  • bun run build:chrome
  • git diff --check

@shallowaria

Copy link
Copy Markdown
Contributor Author

@codex review

@shallowaria

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: c8a3f99d80

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Co-authored-by: Codex <codex@users.noreply.github.com>
@shallowaria

Copy link
Copy Markdown
Contributor Author

Follow-up: CodeRabbit's docstring gate evaluates the modified exported component, not the private reconciliation helper. Added a responsibility-focused JSDoc directly to PluginManager().

Current tested head: 08f0c36ee214360f04fdf7c62e83639e9a742550

Verification:

  • bunx prettier --check src/pages/popup/components/PluginManager.tsx
  • bunx eslint src/pages/popup/components/PluginManager.tsx
  • bun run typecheck
  • bunx vitest run src/pages/popup/components/__tests__/PluginManager.test.tsx --silent — 11 tests
  • git diff --check

@shallowaria

Copy link
Copy Markdown
Contributor Author

@codex review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 08f0c36ee2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@shallowaria

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@shallowaria

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@shallowaria

Copy link
Copy Markdown
Contributor Author

Superseded by #911, which contains the same fix as one clean commit on the current main and has started a fresh full-diff review.

@shallowaria shallowaria closed this Aug 7, 2026
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.

[Bug] Formula Copy does not work on ChatGPT in Microsoft Edge

1 participant