Skip to content

fix(desktop): keep preview picking active across subframe navigation - #9741

Open
Lucenx9 wants to merge 2 commits into
pingdotgg:mainfrom
Lucenx9:fix/keep-preview-picker-active-on-subframes
Open

fix(desktop): keep preview picking active across subframe navigation#9741
Lucenx9 wants to merge 2 commits into
pingdotgg:mainfrom
Lucenx9:fix/keep-preview-picker-active-on-subframes

Conversation

@Lucenx9

@Lucenx9 Lucenx9 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Keep the preview element-pick navigation listener active until the pick session is cleaned up.
  • Read isMainFrame from the current Electron navigation event details instead of deprecated positional arguments.
  • Make the regression test model Electron once semantics and cover a subframe navigation followed by a main-frame navigation.

Why

Electron removes a once listener after the first matching event, even when that event comes from a subframe. A subframe navigation could therefore consume the listener and leave the picker promise and listeners active when the main frame navigated afterward. Electron 43 exposes frame details on the event object, so the handler and regression test use that current shape.

sequenceDiagram
    participant S as Subframe
    participant P as Picker session
    participant M as Main frame
    S->>P: did-start-navigation
    Note over P: Ignore event and keep listener
    M->>P: did-start-navigation
    P->>P: Settle and remove listeners
Loading

Verification

  • pnpm exec vp test run src/preview/Manager.test.ts (80 tests)
  • pnpm --filter @t3tools/desktop typecheck
  • Targeted lint and format checks for both changed files
  • Fallow audit against main for @t3tools/desktop (pass; zero introduced findings)

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Screenshots are not applicable because there is no visual UI change
  • Video is not applicable because there is no animation or timing change

Made with GPT-5.6-sol using the Codex harness in T3 Code.


Note

Low Risk
Localized preview pick-session behavior with listener removal already handled in pickElement cleanup; regression test added for the subframe-then-main-frame case.

Overview
Fixes preview element picking ending too early when a subframe navigates before the main document does.

pickElement now registers a persistent did-start-navigation listener (removed in the existing pick cleanup) instead of once, because Electron drops one-shot listeners on the first event—including non–main-frame navigations that should not cancel the pick. The handler reads event.isMainFrame from the navigation event object.

Tests update the webview once mock to match real Electron behavior and assert the pick stays in flight after a subframe navigation and only settles when the main frame navigates.

Reviewed by Cursor Bugbot for commit c482cbd. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix PreviewManager element picking losing navigation listener on subframe nav

Changes the did-start-navigation subscription in PreviewManager.makeNativeOperations from a one-time listener to a regular listener so it keeps receiving navigation events until the pick settles. The callback now consumes the typed navigation event and only settles the pick with null when main-frame is true; non-main-frame events leave the pick pending. Tests in Manager.test.ts were updated to model one-time listener semantics, pass structured navigation events, and assert the pick settles after a main-frame navigation.

Macroscope summarized c482cbd.

Summary by CodeRabbit

  • Bug Fixes
    • Improved element picking during preview navigation.
    • Picking now remains active when a subframe navigates and correctly settles when the main frame navigates.
    • Navigation events are handled consistently across repeated navigation starts.

Copilot AI lite review requested due to automatic review settings September 4, 2026 18:10

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T18:24:10.065933Z c482cbd Manual request
ℹ️ 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.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Sep 4, 2026
@coderabbitai

coderabbitai Bot commented Sep 4, 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.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: a439e270-f742-4e5f-b7ad-3cda7632e1d2

📥 Commits

Reviewing files that changed from the base of the PR and between c45a5dc and c482cbd.

📒 Files selected for processing (2)
  • apps/desktop/src/preview/Manager.test.ts
  • apps/desktop/src/preview/Manager.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The element-picking session now handles every navigation start. Tests model Electron one-shot listeners and verify that subframe navigation does not end the pick session.

Changes

Element picking navigation

Layer / File(s) Summary
Navigation listener and validation
apps/desktop/src/preview/Manager.ts, apps/desktop/src/preview/Manager.test.ts
The handler reads typed navigation event objects and uses wc.on to process every navigation. Tests verify that subframe navigation keeps the pick active and main-frame navigation settles it.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to c482c

Desktop preview element picking now remains active through subframe navigation and ends on main-frame navigation, with regression coverage for that sequence. No current merge-blocking risk remains.

Suggested reviewers: juliusmarminge, t3dotgg

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: keeping desktop preview element picking active across subframe navigation.
Description check ✅ Passed The description explains what changed, why it changed, verification performed, and checklist status. It also states that screenshots and video are not applicable because there is no visual UI or anima…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c45a5dc. Configure here.

Comment thread apps/desktop/src/preview/Manager.ts
@macroscopeapp

macroscopeapp Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at c482cbd

Macroscope's review found this PR approvable — This is a focused preview-picking bug fix that keeps the listener active through subframe navigation and still cancels on main-frame navigation, with regression coverage for both cases. The runtime change is isolated to the existing preview manager and does not alter defaults, schemas, security-sensitive code, or deployment behavior.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 4, 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. 🎉

Reviewed commit: c482cbd2cf

ℹ️ 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".

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

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants