Skip to content

fix: root-fix browser link opens, context menus, typing lag, and tab-switch presentation - #725

Merged
timjang3 merged 2 commits into
mainfrom
fix/browser-link-open-and-native-perf
Nov 23, 2026
Merged

timjang3 merged 2 commits into
mainfrom
fix/browser-link-open-and-native-perf

Conversation

@timjang3

Copy link
Copy Markdown
Collaborator

Summary

Root-level architectural fixes across Opensteer's native Electron and Playwright/Chromium browser stacks for link-open gestures, context menus, typing responsiveness, tab-switch blank screens, and new-tab creation latency.

1. Link-Open Gestures & Right-Click → "Open Link in New Tab"

  • Native Electron (electron-browser-launcher.ts, browser-presentation.ts):
    • Unified popup creation and context-menu opens through ElectronBrowserContext.#openChildPage() and ElectronBrowserPage.openInNewTab().
    • Fixed native Right-Click → "Open Link in New Tab" / "Open Image in New Tab" (previously sent via hostTransport.openBrowserSurface with openerId: null, silently creating ghost tabs in agent sessions) to open opener-attributed background tabs directly for http:/https: URLs without leaking a cross-origin/suppressed referrer, and passed frame to Menu.popup().
    • Fixed OpenURLFromTab (!options.webContents) to load non-blank URLs + Blink-supplied details.referrer for all dispositions (background-tab, foreground-tab, new-window), while leaving Electron 44.10.2's pre-created webContents path untouched.
    • Scoped Control+Click context-menu arming in before-mouse-event to darwin only.
  • Playwright / Chromium (playwright-launcher.ts, page-ownership.ts, surface-ledger.ts):
    • Added chromiumLinkOpenDisposition() matching Chromium's ui::DispositionFromClick / HTMLAnchorElement rules so OpenURLFromTab tabs (Cmd/Ctrl+Click, Middle-Click, Shift+Click, Primary+Enter — which emit no popup event or openerId) are attributed to their opener with accurate openedInBackground disposition.
    • Identified explicit createPage() targets by exact Page object identity (inFlightCreations + explicitPages), retained only the latest gesture per opener, and isolated multi-session contexts via handOff(..., inferred) + PageOwnership.attachSession / singleSessionIn (even while another session's tabs are asleep).
    • Prevented openedInBackground tabs from stealing activeId in SurfaceLedger.registerOnce().
  • Streamed Context Menu & Modifiers (controller.ts, editing-observer.ts, streamed-context-menu.tsx, browser.ts):
    • Preserved menuConsumers across same-viewer pointer move jitter, cursor.query, cursor.reset, and viewport.follow, consuming authorization on delivery.
    • Guarded streamed contextmenu collection with event.isTrusted, fixed empty href="" resolution, added <area href> and namespaced SVG <a xlink:href>, and restricted "Open Link in New Tab" to http(s):.
    • Preserved mixed-version wire compatibility while supporting EditingModifiersSchema (primary) and Mac→Linux/Win meta→control pointer/wheel translation.

2. Typing Lag, Blank Tab Switch & Slow Cmd+Click Overhaul

  • Native-only remote editing gating (editing-observer.ts, controller.ts, runtime.ts):
    • Added serialized setRemoteEditing(enabled) reconciliation (and stream rollback resync) so native Electron views with no remote frame viewer skip Emulation.setFocusEmulationEnabled, caret-mirror reflows, and Page.getLayoutMetrics keystroke round-trips while keeping password fill/save active.
    • Replaced the ~380-property getComputedStyle mirror copy with 27 cached text-layout CSS properties, added pre-measurement caret caching, deduplicated unchanged publishPerson boxes, and scheduled plain keystroke finishInput() via rAF.
  • UI / Main-process overhead (native-autofill.ts, surface-ledger.ts, electron-browser-launcher.ts, browser-presentation.ts):
    • Scoped useNativeAutofill to subscribe only to autofill (preventing BrowserView re-renders on caret updates).
    • Throttled SurfaceLedger.touch() policyChanged() scans (1,000 ms, while keeping usedAt exact and notifying immediately on first touch or !personUsed -> personUsed).
    • Added synchronous native ElectronBrowserPage.navigationState() (canGoBack/canGoForward) to skip Page.getNavigationHistory CDP round-trips, and cached setIgnoreMenuShortcuts() on state transitions.
  • Blank-tab-switch & fast tab-strip open (electron-browser-launcher.ts, browser-presentation.ts, browser-service.ts):
    • Triggered webContents.invalidate() on mounted paint subscriptions and added ±1px display-scale rounding tolerance.
    • Added paintTimedOut fallback promotion (both on timeout when placed and on late placement after timeout) when !owner.current?.page, so live tabs are never stranded blank behind appView.
    • Flushed structural tab changes (added/removed/structural) immediately (0 ms) in BrowserService while keeping metadata-only updates debounced at 100 ms.

Verification

  • Unit suites: 14 files, 536/536 tests passed.
  • Real headless Chromium suites (vitest.browser.config.ts): chromium-popup-follow.test.ts (4/4) and editing.test.ts (6/6) passed.
  • Workspace gates: pnpm typecheck, pnpm lint, Prettier, and git diff --check passed.
  • Reviewed across two gpt-6.2-sol review passes with all findings resolved.

@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
opensteer-marketing Skipped Skipped Nov 23, 2026 2:34pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect browser tab creation, editing, menus, and presentation across Electron and Chromium.

Fix the stuck remote-editing update before merging.

Findings

  1. P1 Remote editing cannot restart ▶
  2. P2 Caret keeps old text styles ▶

Summary

This PR fixes link opening and context menus across Electron and Chromium. It also reduces typing overhead and improves native tab presentation.

  • Link-open gestures now create tabs tied to the page and session that opened them.
  • Browser context menus keep their input owner and only offer supported link actions.
  • Browser typing and caret updates do less work, especially in native Electron pages.
  • Native pages appear sooner when tabs change or return to view.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Native presentation or frame subscription changes] --> B[Compute whether remote editing is needed]
  B --> C[setRemoteEditing]
  C --> D{Saved update promise exists?}
  D -->|No| E[Update focus and caret tracking]
  E --> F[Promise finishes but stays saved]
  F --> D
  D -->|Yes| G[Later update is skipped]
Loading

Reviews (1) · Last reviewed commit: "fix: root-fix browser link opens, contex..." · Reviewed by Greptile

@timjang3
timjang3 merged commit fa3edb4 into main Nov 23, 2026
39 of 41 checks passed
@timjang3
timjang3 deleted the fix/browser-link-open-and-native-perf branch November 23, 2026 14:56
timjang3 added a commit that referenced this pull request Nov 23, 2026
…-smokes

One conflict, apps/host/src/server.ts: main moved the person's tab commands
into TabService.executeCommand; this branch added tab.group.close beside
tab.group.delete in the server's switch. Kept main's shape: tab.group.close
is one more case forwarded to executeCommand, which now handles it with
closeGroup.

Aligned without a textual conflict, apps/host/src/tabs/tab-service.ts:
main's tab mutations finish through tabMutationMeta and
#applyCatalogMutation (a replay ends no viewers and answers with the current
layout); closeGroup now does the same, as #close does.

Auto-merged and checked: browser-service.ts keeps E1 (the page ends only on
the tab's own not_found) and E2 (the witness is the row the bind wrote)
beside main's #723 and #725; tab-store.ts keeps closeGroup and bindPage's
row; tab-group.tsx keeps the selected title and the single tab.group.close;
tab-closer.tsx is main's; app-shell.tsx keeps the wait for the complete tab
list. The passwords package and the journey's policy fixture are unchanged
by the merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
timjang3 added a commit that referenced this pull request Nov 23, 2026
…b-restore-2

Resolved by behaviour; both sides' rules hold. Conflicted files:

- packages/browser-runtime-core/src/browser/page-ownership.ts: main forgets a session in every
  adopted context's session set when the session ends; this branch abandons that session's page
  creations through abandon() (which also releases what they hold). Kept both.

- apps/browser-runtime/src/browser/playwright-launcher.ts: main (#725) attributes a page that
  Chromium opened from a link (OpenURLFromTab, no popup event) to the one recent modifier or
  middle-click, marks a background tab, and announces a page only after the runtime's own
  in-flight newPage() calls settle, so its own page is told apart by identity. This branch hands
  pages off from arrive(): ordinary pages through handOutOrdinary(), and the runtime's own pages
  and woken tabs through publish(), a sleeping tab's page never handed out (M1, K3, Q1, Q3).
  Kept: one announce() for both paths, with main's attribution; publish() never infers (the
  runtime's own pages and woken tabs are explicit); openFreshPage() is main's in-flight creation
  and marks its page explicit. The wait for in-flight opens applies only to a page with no
  opener while a link gesture is pending: then the runtime's own page is known before a gesture
  is taken (main's test 3), and otherwise a page is handed off at once, never waiting on an
  unrelated open (this branch's Q3 test). Fields and the context's close: both sides' fields;
  markClosed() and main's clearing of pending link gestures. Page handle: both sides' fields.

- apps/browser-runtime/src/browser/playwright-launcher.test.ts: both sides added tests at the same
  place; kept all of them. Main's "resolves explicit createPage by identity" waits until
  Playwright is asked for the page: here an open is admitted by the sleeper first (TS13), a few
  turns later than on main.

Main's structural tab flushes without the 100 ms debounce (#725) met no conflict; the browser
unit suites (Home browser, runtime, runtime core, client, web, phone, harness: 619 files, 7,066
tests) pass on Linux on the merged tree. No migration on this branch, so none is renumbered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
timjang3 added a commit that referenced this pull request Nov 24, 2026
Conflict resolutions (by behaviour, preserving both sides):
- apps/host/src/browser/browser-service.ts: pool-home-next (X6) guarded HostedBrowserBroker readiness on !#stopping && !#detaching and confirmed onState("ready") before marking #runtimeReady; main-into-overhaul (f4b9b03 + #725) flushed #sessionStateTimer/#sessionStateHold around the initial #sendSessionState(), skipped the redundant refreshSessionState() when becameReady, and passed structural to #onTabsChanged. Kept both: only set becameReady, mark #runtimeReady, and flush the session-state hold around #sendSessionState() when readyConfirmed && !#stopping && !#detaching, while keeping #725's structural #onTabsChanged flush.
- packages/database/src/browser-pool-migration.ts (auto-merged, renumbered): main-into-overhaul placed 0046_run_provider_retry before overhaul 0100..0107; renumbered browserPoolSessionsMigrationName from 0052_browser_pool_sessions to 0116_browser_pool_sessions so it sorts after 0107.
- packages/database/src/migrations.test.ts: pool-home-next appended 0052_browser_pool_sessions; main-into-overhaul renumbered overhaul migrations to 0100..0107. Kept 0100..0107 plus 0116_browser_pool_sessions in sorted order.
- packages/database/src/personal-state-upgrade.integration.test.ts: pool-home-next appended browserPoolSessionsMigrationName after 0051; main-into-overhaul moved to 0046 + 0100..0107. Kept 0107_needs_you_counts_requests followed by browserPoolSessionsMigrationName.
- tests/personal-state-upgrade.integration.test.ts: pool-home-next appended browserPoolSessionsMigrationName after 0051; main-into-overhaul moved to 0046 + 0100..0107. Kept 0107_needs_you_counts_requests followed by browserPoolSessionsMigrationName.
- apps/host/src/runtime/team-era-home.integration.test.ts: pool-home-next dropped browser_pool_sessions/browser_pool_retired_targets and deleted migrations >= 0051 so migrateToLatest replays both; main-into-overhaul updated the migration name to 0107_needs_you_counts_requests. Kept dropping the pool session tables and deleting migrations >= '0107_needs_you_counts_requests'.
timjang3 added a commit that referenced this pull request Nov 24, 2026
Resolved conflicts by keeping both sides' behavior:

- packages/browser-runtime-core/src/browser/editing-observer.ts:
  - start() / remote sync: phone-typing-next published the initial page context
    at start so page-level commands carry a contextId (CY7); main (#725) added
    setRemoteEditing() and #scheduleRemoteSync() to disable focus emulation and
    caret mirror reflows when a native Electron page has no remote viewer. Kept
    both: publish initial context at start and reconcile remote editing toggles.
  - beginInput() / finishInput(): phone-typing-next added live focus, fieldKey,
    and collapsed-selection verification in beginInput(request) (P3/S7) plus
    closeGuard clearing in finishInput() (CY3); main (#725) added an immediate
    flag to finishInput(immediate = true) so keystrokes coalesce publish() into
    requestAnimationFrame via schedule(). Kept both: live focus/collapsed check
    in beginInput(request), closeGuard clearing in finishInput, and immediate vs
    rAF-coalesced publish/schedule.
  - publish(): phone-typing-next cleared blurTimer at the top of publish() to
    avoid transient null-field publications on field-to-field focus switches
    (W4); main (#725) returned early before syncSelection() when !remote. Kept
    both: clear blurTimer first, then return early when !remote before running
    syncSelection().

- packages/browser-runtime-core/src/browser/editing-observer-dom.test.ts:
  - phone-typing-next added the field-to-field focus switch test (W4); main
    added the untrusted contextmenu / SVG xlink:href test and two remote-editing
    suppression/reconciliation tests (#725). Kept all four tests.
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