Skip to content

fix(browser): match official routed-session attach and port official recency rule - #301

Merged
Hona merged 7 commits into
devfrom
browser-tools/fix-lazy-rpc-attach
Nov 20, 2026
Merged

Hona merged 7 commits into
devfrom
browser-tools/fix-lazy-rpc-attach

Conversation

@Hona

@Hona Hona commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Replaces the earlier lazy-attach draft (archived on browser-tools/lazy-attach-archived) with exact official parity on dev (48534ca6, incl. #292, #294, #274), closing the batch-8 Home bucket regression from #287 (a974a664) and all Round-3 READER-10 findings with zero prompt gate and zero opencode-kit changes.

1. Attach Moment & Set — #287 (dev) vs Official (anomalyco/opencode origin/dev)

  • What #287 attached on dev: reconcile_sessions (apps/desktop/src/surfaces/browser/rpc/mod.rs:352-368) attached EVERY non-draft tab in app.tabs (including all restored tabs at startup and background tabs opened with open_in_background) plus Route::Session.
  • What Official attaches (packages/gui-plugins/src/browser/model.ts:664-689, machine.ts:1000-1025): Never attaches restored or listed tabs at startup (sessions.list()). Attaches ONLY the routed session on open (sessions.current() at model.ts:664-671), keeps an already-attached session alive while open until closed or deleted (model.ts:617-619, 643-644), and aborts cleanly on close.
  • Fix in #301: BrowserRpcState.routed_sessions records (active_server, id) when Route::Session routes to it (including when open_dirs.contains_key(&key) precedes app.sessions loading info.directory), keeps it attached while still open in app.tabs or routed, prunes on tab close / session.deleted, and implements Drop on SessionAttachment (rpc/session.rs) so window close aborts held attach sockets cleanly.

2. Non-Mutating Official Recency Projection (mergeRootSessionIndex) Across Every List

  • Why Official projects instead of mutating (packages/app/src/runtime/server/session-index.ts:4-20, recent-sessions-model.ts:374-403, home/sessions/controller.tsx:357):
    • On the server, experimental.browser/attach writes permissions (connection.ts:181, 453-464) -> projector.ts:990-992 (time_updated: event.created), and renames/model/agent updates also bump time_updated.
    • Official keeps the raw SessionInfo intact in store (data.session) and clamps ONLY the recency projection whenever (info.idle ?? 0) <= (indexed_idle ?? 0) (advancing only when a run completes with info.idle > indexed_idle or a new session is created).
  • Round-3 READER-10 Fixes:
    1. Zero mutation of s.sessions (apps/desktop/src/workspace/search/recent_page.rs, incoming.rs, cost.rs): Replaced mutating merge_info with non-mutating would_record_info / record_info + clamped_ms inside recent_page::Page::active_ms and time. Raw s.sessions[i].updated stays untouched so pages/mod.rs:519, 589 (page_key) invalidates cached transcripts on any second-client update and Sessions:Get (services/session.rs:135, 146, 242) returns the raw server updated.
    2. Every list & search reader routed through the same non-mutating recency:
      • Home & Sidebar: home/list.rs:82, home/browse.rs:94, sidebar/recent.rs:156, 351, sidebar/customized.rs:51, 75, inbox/model.rs:142, 718, jump_list.rs:81.
      • Command Palette & Search: features/switcher/src/{lib.rs, entries.rs, search_index.rs:318,351, session_index.rs:27,34,47,60, servers.rs:116,133,162} + apps/desktop/src/workspace/search/switcher.rs (session_active_ms, recent_page version in sessions_version, and per-remote Remote.indexed non-mutating clamp in RemoteSeed/Remote).
      • Projects: apps/desktop/src/app.rs:423 (sort_projects uses self.recent_page.active_ms(s)).
      • Recently Closed: apps/desktop/src/shell/tabs/recently_closed.rs:69 (s.recent_page.active_ms).
      • @session Mentions: features/mentions/src/{lib.rs, index.rs:102-112, 146, 279} + apps/desktop/src/session/composer/mentions.rs (MentionsHost::session_active_ms + recent_page version in sessions_stamp).
    3. Minor routed_now fix (rpc/mod.rs:380-390): Sets routed_now = Some(key) when open_dirs.contains_key(&key) even if t.directory precedes app.sessions.

3. No Prompt Gate & dev Reconciliation

  • Zero prompt gate (gate.rs, Incoming::PromptGate, hold_write, and all opencode-kit changes removed; prompt gate belongs strictly to #302).
  • Merged origin/dev cleanly through 48534ca6 (#292, #294, #274, #309, #310).

Security Scope

  • Actions added: None (zero new RPC actions, zero contract.json growth, zero ENGINE_REVISION bump, zero struct App field growth).
  • Who can call / which tab/session touched: Native Rust BrowserRpcFeature scoped strictly to (active_server, routed_session_id) on open; never exposed to Luau plugins.
  • User confirmation required: None.

Driven Verification (proof/browser-tools/lazy-attach/summary-v4.json, 10/10 PASS)

  • Baseline Home (baseline): 0 attaches; Home buckets Today:[ses_01], Yesterday:[ses_02], Older:[ses_03,ses_04,ses_05].
  • Open all 5 sessions (open5): All 5 routed sessions attached (["ses_01".."ses_05"]), server time_updated bumped +50 s on all 5 (e.g. ses_05: 1792612996045 -> 1795205055251), Home buckets/row order and Projects (["proj_1", "proj_2"]) stayed 100% unchanged, and window close aborted all 5 held attaches (attachAbortedCount: 5).
  • Project Switcher (projects, Ctrl+Shift+O -> sort_projects): Opening ses_04 (proj_2, bumped +50 s ahead of wall clock) before ses_01 (proj_1) kept ["proj_1", "proj_2"].
  • Command Palette (palette, Ctrl+Shift+F + "Session" server search -> sw.loaded): Kept clamped order ["ses_01", "ses_02", "ses_03", "ses_04", "ses_05"].
  • Recently Closed (closed, right-click +): Kept clamped order ["ses_01", "ses_02", "ses_03", "ses_04", "ses_05"].
  • @session Mentions (mentions, "@Session" in ses_01): Kept clamped order ["ses_03", "ses_05", "ses_02", "ses_04"].
  • Sessions:Get raw timestamp (sesget): Plugin Sessions:Get("ses_05").updated returned exact raw server 1795205089646 (NOT clamped 1792613036470).
  • Second-client transcript cache refresh (transcript): Second client updating ses_03 (updated bumped, idle unchanged) invalidated page_key cache (messageFetches.ses_03: 4) and rendered "SECOND_CLIENT_UPDATE_42".
  • Completed run (done): session.execution.succeeded advancing time_idle on ses_03 promoted ONLY ses_03 (Today:[ses_03,ses_01], Yesterday:[ses_02], Older:[ses_04,ses_05]).
  • Checks: Guardrails 5/5, web.ps1 -Check, browser-policy aarch64-apple-darwin & x86_64-unknown-linux-gnu via tools/cargo.ps1, --workspace --all-targets, opencode-desktop --features browser: ALL PASS. Pinged REFERENCE in notes/ORCHESTRATOR-inbox.md to rerun home-unread-badge, context-menu-home-row, home-row-hover.

Held unmerged for READER-10 review.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR test build retired — merged into dev. Install or auto-update OpenCode (Rune) from https://anoma.ly/release/opencode/desktop-rune/dev/macos-arm64-dmg.

@Hona Hona changed the title fix(browser): attach experimental.browser lazily on browser/prompt use with BuiltinPromptGate fix(browser): match official routed-session attach and port official recency rule Nov 20, 2026
Hona added a commit that referenced this pull request Nov 20, 2026
- Fold security-confirmed merged PRs #292 (6d7a6ed, WS-1 mandatory
  RemoteServer proxy), #294 (ae3e910, BROWSER-UI file-link/click-to-run
  fix with known symlink/junction root limitation), and #274 (5da6474,
  WS-9 engine MV3 extension host, inert without --extension flags)
- Update browser Reviewed column: #301 in rework (#287 eager-attach
  time_updated regression still live on dev), #296/#298/#302/#303/#305/#306
  in rework, #307 open for pre-merge security review
- Audit upstream anomalyco/opencode fe8def6854..4122af0206 (+2 commits:
  1 skipped #65255 core/codemode, 1 added UP-135 #65215 -> WS-8)
Hona added a commit that referenced this pull request Nov 20, 2026
…310)

- Update UP-095-UI evidence to reflect that the 4 #294 findings remained
  present from 0.0.0-dev-440 through published 0.0.0-dev-449 (b62e698)
- Refresh open browser PR security-review states (#296 4th read, #301 3rd
  read, #303 2nd read, #307 updated after 1st read, #308 1st read)
@Hona
Hona merged commit 6522f11 into dev Nov 20, 2026
7 checks passed
@Hona
Hona deleted the browser-tools/fix-lazy-rpc-attach branch November 20, 2026 20:40
Hona added a commit that referenced this pull request Nov 20, 2026
Hona added a commit that referenced this pull request Nov 20, 2026
…P-143 (#318)

- Fold confirmed merged PRs #307 (a1e7d0d, click-to-load reply videos),
  #306 (b5167f7, atomic agent_driven), #301 (6522f11, routed-session
  attach + recency closing #287 regression), #296 (95cb36a, legacy
  rune_mcp suppression + Half::is_builtin + check_cdp), #303 (6fb05ce,
  oc-preview:// app routing + raw file:// ban completing UP-095-PREVIEWS),
  and #316 (6e98fc2, Rune 7a707454 / #1307 strict local video opening)
- Add missing browser follow-up rows UP-095-3P-CONTRACT (#296 narrow
  third-party plugin browser contract gap) and UP-095-PROMPT-GATE
  (new-session-start-only prompt gate split from #302)
- Record #302 split (tunnel vs gate), #314 masking stream paused pending
  owner decision on agent-tab contexts, and updated browser Reviewed entries
- Audit upstream anomalyco/opencode 4122af0206..b9a60d9d07 (+11 commits:
  3 skipped, 8 added UP-136..UP-143)
Hona added a commit that referenced this pull request Nov 20, 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.

1 participant