b463840c28
The Bot Mode 'session not found' / bot-runs-on-wrong-backend bug. wiring's requestGateway is ONE shared closure for every session-scoped RPC in the window, but it derived the owning profile from the globally-FOCUSED tile ($focusedStoredSessionId). A bot chat is a background tile while another pane is active, so its prompt.submit carried the bot's own session_id yet was dispatched on the FOCUSED tile's backend — the default backend served the bot via ?profile= from the default's state.db, or answered 4001 'session not found' when it didn't hold the runtime session. Route by the session the RPC TARGETS (params.session_id) instead. session_id is a RUNTIME id while tiles/rows key on the STORED id, so translate via the state cache then a reverse scan of the stored->runtime map (the same ladder use-session-tile-delegate's storedSessionIdForRuntime uses); an unresolved id is already a stored id (several RPCs pass stored ids directly). RPCs with no session_id (ambient/config) keep the focused->selected fallback. Pure helpers extracted to wiring-routing.ts so they're unit-testable without importing the React controller; 6 tests cover the target-vs-focused routing, the stored-id passthrough, and the no-session fallback. tsc 0 errors. Diagnosis verified on a live install: the fix was present in source but the running build still misrouted, and logs showed the bot's turn executing on the default backend while its own per-profile backend sat idle.