Skip to content

fix(browser): restore hover after leaving a mobile viewport preset - #22846

Merged
brennanb2025 merged 1 commit into
stablyai:mainfrom
AmoabaKelvin:AmoabaKelvin/fix-lost-hover-effects-after-switching-browser-vp
Sep 29, 2026
Merged

brennanb2025 merged 1 commit into
stablyai:mainfrom
AmoabaKelvin:AmoabaKelvin/fix-lost-hover-effects-after-switching-browser-vp

Conversation

@AmoabaKelvin

Copy link
Copy Markdown
Collaborator

ELI5

If you switched Orca's built-in browser to a phone or tablet size and then back to a desktop size, the page kept thinking it was on a touch screen. Sites that only show hover effects when a mouse is present stopped showing them. Switching back now fully returns the page to desktop mode.

What Changed

  • Before: after picking Mobile or Tablet under Viewport Size and then switching back to Laptop, Desktop or Default, hover effects stopped working. The page still reported "no hover, touch screen, 5 touch points" and kept the mobile user agent, even on later page loads.
  • After: switching back restores hover, a mouse pointer, zero touch points and the desktop user agent.
  • Mechanism: leaving a mobile preset turns touch emulation off with Emulation.setTouchEmulationEnabled. We sent { enabled: false, maxTouchPoints: 0 }, but Chromium only accepts 1–16 touch points, even when turning emulation off, so it rejected the whole call. Touch emulation stayed on, and the error also skipped the user-agent restore after it. We now send { enabled: false } with no maxTouchPoints, and Chromium puts back the original value itself. This covers both ways out of a mobile preset: switching to a desktop preset, or going back to Default.

Why

The rejected call was the whole bug, so the fix is the smallest correct payload rather than a workaround such as detaching the debugger, which would also wipe the agent bridge's per-page state. It went unnoticed because the unit tests mocked the debugger and accepted any payload. The test mock now rejects out-of-range touch points the way Chromium does, so this can't regress silently.

Fixes #22749

Visual Proof

Before:

CleanShot.2026-09-25.at.12.08.31.2.mp4

After:

CleanShot.2026-09-25.at.12.11.04.mp4

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: no change.
  • Cross-platform: the fix is a Chromium DevTools call that behaves the same on all platforms.
  • SSH/remote: the embedded browser always runs in the local app, so remote workspaces aren't affected.
  • Mobile: not affected.
  • Backwards compatibility: saved viewport choices are unchanged.
  • Performance: no change.
  • Side effect: Orca re-sends the "no preset" setting on every page load. That call used to fail silently, and it now succeeds, which resets the user agent to the default as intended.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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

✅ No new issues found.

Reviewed changes

  • Viewport touch reset (the fix) — browser-manager-viewport.ts now sends { enabled: false } (no maxTouchPoints) when leaving a mobile preset, via a shared TOUCH_EMULATION_DISABLED const used by both the desktop-preset and no-preset branches. Mobile still sends { enabled: true, maxTouchPoints: 5 }.
  • Stricter shared test mock — browser-manager-viewport-test-fixtures.ts replaces mockResolvedValue(undefined) with rejectInvalidTouchPoints, which rejects an out-of-range maxTouchPoints on setTouchEmulationEnabled the way Chromium does.
  • New regression test — browser-manager-viewport-touch-reset.test.ts covers mobile → desktop preset and mobile → no preset, asserting the disabled payload and that a later navigation does not re-install the iPhone UA.
  • Existing assertion updated — the override=null case in browser-manager-viewport-override.test.ts now expects { enabled: false }.

I verified the load-bearing claim against Chromium source: inspector_emulation_agent.cc's setTouchEmulationEnabled rejects maxTouchPoints outside 1..16 regardless of enabled, and dev_tools_emulator.cc restores the embedder's original max-touch-points, pointer and hover types when disabling. I also confirmed the new test fails on the pre-fix payload (both cases) and passes with it, that no other call site sends maxTouchPoints: 0, and that all 51 tests across the 6 files consuming the stricter fixture mock pass (ORCA_BACKGROUND_LAUNCH=1). oxlint is clean on the changed files.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 463f70ec-5a15-4291-9c22-35a4774a92f3

📥 Commits

Reviewing files that changed from the base of the PR and between 43f1236895cc2239c876e775cd370c2f4266315e and a5aaac1.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: fc3447e6-0a06-4a90-a8de-89b01527954a

📥 Commits

Reviewing files that changed from the base of the PR and between e0b9ba0de2a33741258a6338f60333f2e1892470 and 43f1236895cc2239c876e775cd370c2f4266315e.

📒 Files selected for processing (3)
  • src/main/browser/browser-manager-viewport-override.test.ts
  • src/main/browser/browser-manager-viewport-test-fixtures.ts
  • src/main/browser/browser-manager-viewport.ts

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


📝 Walkthrough

Walkthrough

Touch emulation is now disabled without a maxTouchPoints value when a viewport override is cleared or changed to a non-mobile preset. Mobile overrides continue to use five touch points. Tests verify the reset command and check that switching from mobile does not retain an iPhone user agent during subsequent navigation.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 43f12

The reset payload and regression tests address the mobile-to-desktop transition. No concrete current-head failure is established; behavior in the embedded Chromium version was not independently exercised.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 43f12

The fix restores desktop input behavior without adding a new browser entrypoint or expanding its authority. Risk is limited, though actual Chromium behavior and unusual command failures have not been fully verified here.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed command affects emulation state for the selected browser guest; the changed source shows no broader service, credential, or data-store authority.

Trust Boundaries and Controls

  • observed — The existing tab-to-WebContents identity checks and per-tab command ordering still precede the changed touch command; no boundary bypass is visible in the changed path.

Resilience and Maintainability Implications

  • inferred — An unrelated touch-command failure could still leave touch emulation active while desktop identity is restored. The changed payload removes the identified invalid-value failure; no evidence shows that it introduces or worsens this pre-existing partial-failure behavior.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. 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 and concisely describes the main change: restoring hover behavior after leaving a mobile viewport preset.
Description check ✅ Passed The description is complete and relevant. It explains the user impact, mechanism, rationale, linked issue, visual proof, testing, compatibility considerations, and checklist status. The optional AI Di…
Linked Issues check ✅ Passed Issue [#22749] is closed and provides historical context only. No active directly linked issue supplies coding requirements. The reported behavior is relevant to the change, which omits `maxTouchPoint…
Out of Scope Changes check ✅ Passed The changes remain within the historical issue context. Production code changes the touch-emulation reset, and tests validate the Chromium constraint and the mobile-to-desktop or Default transition. N…
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@brennanb2025
brennanb2025 requested review from brennanb2025 and removed request for nwparker September 28, 2026 18:05
@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks @AmoabaKelvin, the fix is right: Chromium rejects maxTouchPoints: 0 even when disabling touch, and I confirmed this fixes #22749 on every way out of a mobile preset.

One catch that isn't on you: because that call always failed, the desktop-preset user-agent step after it has never run. With your fix it runs, and it drops the sec-ch-ua* client hints on the Laptop / Laptop L / Desktop presets. The root problem is ours (viewport presets shouldn't own browser identity), so I'm fixing that in a separate PR. I'll merge that first, then this one.

@brennanb2025
brennanb2025 force-pushed the AmoabaKelvin/fix-lost-hover-effects-after-switching-browser-vp branch from e0b9ba0 to 43f1236 Compare September 29, 2026 03:57
@brennanb2025

Copy link
Copy Markdown
Contributor

Rebased this onto main now that #23718 has landed, and force-pushed. #23718 split the viewport update into independent steps, so your change now lives in the touch-emulation step: disabling touch sends { enabled: false } with no maxTouchPoints. Your tests pass on the new structure, and putting maxTouchPoints: 0 back still fails them.

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Fixes touch emulation state when switching viewport presets.

The PR appears safe to merge.

Summary

The PR corrects the Chromium touch-emulation command used when leaving a mobile viewport preset. It also updates the viewport tests to reject invalid touch-point values and cover transitions back to desktop and default presets.

Reviews (2) · Last reviewed commit: "fix(browser): restore hover after leavin..."

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

✅ No new issues found.

Reviewed changes

Since the prior pullfrog review the branch was force-pushed onto current main (which now contains the tab-identity ownership refactor from #23718). The net PR-authored diff is unchanged; the fix simply moved into the refactored surrounding code.

  • Touch fix re-homed, behavior unchanged — browser-manager-viewport.ts still sends TOUCH_EMULATION_DISABLED = { enabled: false } (no maxTouchPoints) for the desktop-preset and no-preset cases, now inside the shared runViewportEmulationStep pipeline rather than the old if/else; the mobile branch still sends { enabled: true, maxTouchPoints: 5 }.
  • Regression test unchanged — browser-manager-viewport-touch-reset.test.ts and its assertions are identical to the previously reviewed revision.
  • Existing assertion unchanged — the override=null case in browser-manager-viewport-override.test.ts still expects { enabled: false }.

I re-ran the eight test files that consume the now-stricter shared fixture mock (browser-manager-viewport-touch-reset, -override, -partial-failure, -ownership, browser-manager-tab-identity, browser-manager-auth-user-agent, browser-manager-worker-request-user-agent, browser-manager-annotation-bridge) with ORCA_BACKGROUND_LAUNCH=1: 82 tests pass. Main's new tab-identity case that rejects any touch payload regardless of shape (so it outlives a payload fix) also passes next to this branch's payload-validating mock.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Turning touch emulation off sent maxTouchPoints: 0, which Chromium
rejects (it only accepts 1-16, even when disabling). Touch emulation
stayed on, so pages kept reporting no hover and a coarse pointer, and
the desktop user agent was never restored. Omit maxTouchPoints when
disabling so Chromium restores the original value.
@brennanb2025
brennanb2025 force-pushed the AmoabaKelvin/fix-lost-hover-effects-after-switching-browser-vp branch from 43f1236 to a5aaac1 Compare September 29, 2026 06:52
@brennanb2025
brennanb2025 merged commit b7e3bbf into stablyai:main Sep 29, 2026
36 checks passed
brennanb2025 added a commit that referenced this pull request Sep 29, 2026
…3745, #23783, #22971, #22565, #22846, #23724, #23721, #23693, #23810) into #23059

#23671 (group chat rows by the turn that produced them) is ported onto
#23059's turn-scope model, so there is one grouping mechanism, not two:

- A host that states each row's turn scope groups by that scope, as
  before. #23671's journal-order derivation (rows between one turn record
  and the next belong to it) moves from the timing selector into
  src/shared/native-chat-turn-grouping.ts and runs only for a host that
  states no scope, replacing the positional fallback there.
- #23671's anchor rules live in structuredAgentTurnAnchors, which
  membership, settled timing and the live clock all read: a turn whose
  opener key nothing resolves yet takes the send still in flight ahead of
  its record (Codex before its echo), else its own record.
- The live turn is one key again. #23671 made row liveness follow the
  owning turn, so the bar key and the liveness key are always the same;
  nativeChatTurnMembership now returns only liveTurnKey (barTurnKey,
  activeTurnOpenedBy and turnKeysByItemId are gone).
- A turn with no user bubble draws its bar above its first row
  (nativeChatTurnBarRows, desktop and mobile), and a turn's diff rollup
  goes under its last row.
- The Codex full-history restore writes each record ahead of its items;
  that also fixes the derived turn scope on #23059's journal.

#23026 (Stop from the moment a message is sent) is ported onto #23059's
command turns: the cancel paths ask the translator for a command's
provider turn instead of the removed compaction tracker, and a Stop that
names no turn still ends a running /compact through its child.
performCancel moved to structured-agent-session-turns-cancel.ts to keep
the turns module under the line limit.

#22090's awaitingInput replaces showTurnStatus/showLiveTurnActivity; the
waiting-behind-/compact rows are kept.
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]: Lose hover effects after switching browser viewport to mobile/tablet and back

2 participants