Skip to content

fix: eliminate full-catalog tab projections on mutations and fix Team sidebar liveness probes - #724

Merged
timjang3 merged 3 commits into
mainfrom
fix/tab-projection-and-realtime-liveness
Nov 23, 2026
Merged

timjang3 merged 3 commits into
mainfrom
fix/tab-projection-and-realtime-liveness

Conversation

@timjang3

Copy link
Copy Markdown
Collaborator

Summary

Fixes the root architectural causes behind slow/hanging local tab mutations and the Team realtime 35.5 s reconnect storm:

1. Targeted Tab Mutations, Incremental Catalog Maintenance, and Batched Projection

  • apps/host/src/server.ts & apps/host/src/tabs/tab-service.ts:
    • Added TabService.executeCommand(ownerId, command) as the single person-command entry point, using the committed layout returned directly by TabStore mutations instead of running redundant full-catalog tabs.project() calls after tab.close, tab.open, tab.organize, and tab.group.update.
    • Replaced full-catalog invalidations (this.changed(ownerId)) on mutations with incremental catalog updates (#applyCatalogMutation) fenced by per-row rowVersions, per-tab invalidation versions (dirty: Map<TabId, number> | null), and structureEpoch so concurrent refreshes, activations, mid-projection invalidations, and post-commit failures remain coherent.
    • Made get(), activate(), open(), reopen(), organize(), updateGroup(), deleteGroup(), and authorizeShow() project only the affected tab(s) rather than all N tabs, while sharing a single maskVisibleLayout helper for partial-reach group masking.
    • Eliminated N+1 and O(N^2) work in #projectRows: builds layoutGroupMap once (O(N)), reuses computer.selfRunnerId (deduplicating fallback requireDeviceSelfRunnerId per device), deduplicates apps.get per appId, and batches native window state checks via NativeTabTargets.windowStates.
  • packages/database/src/tab-store.ts:
    • Returns replayed: true and currentLayout on idempotent command replays, and passes replayedTabIds into TabAuthorization so:
      • replaying tab.close after reopen/activate never terminates the reopened tab's viewer generation;
      • replaying tab.reopen without tabId authorizes against the originally reopened tab;
      • replayed commands keep a consistent current-layout response contract (while preserving pages.admitted on replayed page opens).
  • apps/host/src/tabs/ports.ts & apps/host/src/computer-use/native-tab-targets.ts:
    • Added windowStates(ownerId, windows) batch projection (one owns per unique computer, one connections(ownerId) per batch, one connectivity cut, and views.list only for connected owned computers with approved apps) and unified windowState onto the same path.
    • Bounded #observed with LRU touch-on-read (defaultMaxObservedWindows = 2048 > tabsMaxPerOwner), bounded concurrent background probes per computer (defaultMaxConcurrentWindowProbesPerComputer = 8), centralized in-flight probe supersession inside #rememberObserved, and scoped unavailable-eviction recovery tracking per computer.

2. Team Realtime Idle Liveness Probes & Access-Fence Safety

  • apps/host/src/team/realtime.ts:
    • Answered repeated sidebar-only team.subscribe liveness probes (subscriptionId: "sidebar", sidebar: true, scope: null) with team.sidebar while keeping channel/thread subscribes and unsubscribes free of redundant sidebar snapshots—eliminating the 35.5 s idle reconnect loop and restoring team.access.changed sidebar recovery.
    • Extracted #sendSidebar(peer) so this.access.handoff re-authorizes and rebuilds the sidebar at the current revision if access changes between directory() capture and delivery (preventing stale private-channel leaks across subscribe, probe, and resync).

Verification

  • pnpm --filter @opensteer/database typecheck & pnpm --filter @opensteer/host typecheck — passed
  • pnpm exec prettier --check & pnpm exec oxlint on all modified files — 0 warnings, 0 errors
  • Unit tests (tab-service.test.ts, native-tab-binding.test.ts, realtime.test.ts) — 32/32 passed
  • PostgreSQL integration tests (tab-store.integration.test.ts, tab-authority.integration.test.ts, coordination.integration.test.ts, browser-source-journey.integration.test.ts) — all passed
  • Adversarial architectural & concurrency review by gpt-6.2-sol (reasoningEffort: high) — signed off (Ship)

@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 4:43am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The PR replaces full-catalog work after tab mutations with targeted reads and incremental cache updates.

  • Tab commands update only the rows they change.
  • Tab lists check native windows in batches.
  • Idle sidebar checks get a fresh Team reply.

No actionable issues were found. This review checked source and tests; it did not run tests.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Person tab command] --> B[executeCommand]
  B --> C[TabStore mutation]
  C --> D{Replayed?}
  D -->|No| E[Project affected tabs]
  E --> F[Update cached rows and layout]
  D -->|Yes| G[Use current layout]
  F --> H[Return command result]
  G --> H
  I[Sidebar subscribe or probe] --> J[Build sidebar]
  J --> K{Access revision changed?}
  K -->|Yes| L[Check access and rebuild]
  L --> K
  K -->|No| M[Send sidebar]
Loading

Reviews (1) · Last reviewed commit: "fix: eliminate full-catalog tab projecti..." · Reviewed by Greptile

@timjang3
timjang3 merged commit 298adb4 into main Nov 23, 2026
21 checks passed
@timjang3
timjang3 deleted the fix/tab-projection-and-realtime-liveness branch November 23, 2026 04:57
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