* perf(runtime): compare mobile session sync key by reference instead of stringifying large maps
`getRuntimeMobileSessionSyncKey` used to `JSON.stringify` `terminalLayoutsByTabId` and `runtimePaneTitlesByTabId` whole, which scaled with the lifetime accumulation of tabs in a workspace and pinned the main thread for ~750ms per click in workspaces with hundreds of tabs while an agent was working. The maps reallocate on real changes and stay reference-stable otherwise, so the key now holds them by reference and only pre-serializes the small projected shapes that need value-level comparison. Subscriber gate also early-returns when those two maps are reference-stable, so the common click path (`updateTabTitle` reallocating `tabsByWorktree`) skips the key build entirely.
See docs/agent-working-pane-typing-lag.md for the trace and root-cause writeup.
Co-authored-by: Orca <help@stably.ai>
* docs: correct misleading comment on the relevant-fields gate
The earlier comment claimed adding terminalLayoutsByTabId /
runtimePaneTitlesByTabId to the gate prevented updateTabTitle from
falling through. That's wrong — updateTabTitle reallocates
tabsByWorktree, which is a separate field already in the gate and
already fails the AND-chain. The two added fields actually catch a
different path: layout-only mutations like setTabLayout that don't
touch any other gate field. Comment now describes the real intent:
the gate is a strict superset of every input to
getRuntimeMobileSessionSyncKey, so passing it guarantees the key is
unchanged without materializing one.
Doc updated to match.
Co-authored-by: Orca <help@stably.ai>
* chore: drop perf writeup from branch (kept in commit history)
Co-authored-by: Orca <help@stably.ai>
* test(runtime): pin down by-reference invariant of mobile sync key comparator
Reworks the existing reference-stable test to use two distinct AppState instances sharing every comparator-checked map, and adds a negative test that detects a regression to deep equality on terminalLayoutsByTabId. Extracts a makeSharedOverrides() helper so tests can isolate a single field without makeState's fresh-default churn defeating the assertion.
Co-authored-by: Orca <help@stably.ai>
---------
Co-authored-by: Orca <help@stably.ai>