Files
codex/codex-rs/tui/src/backend_id.rs
T
Benjamin Carlsson 440312f113 Keep TUI session selections bound to their backend (#54681)
## Why

A thread ID alone does not identify the backend that owns a session. Resume and fork selections must retain that ownership across connection replacement so they cannot operate on another backend, even when thread IDs match.

## What changed

- Add a process-local `BackendId` to app-server sessions and session targets, preserving it across reconnects and auxiliary picker connections.
- Reject selections from a different backend before changing session state or sending resume, fork, or unarchive requests.
- Disable local-daemon fallback to an embedded server for auxiliary pickers and after selecting a session, while retaining fallback for fresh startup.

## Testing

Add regression coverage for foreign selections with matching thread IDs, startup resume and fork rejection before requests, shared ownership across picker connections, and fallback eligibility.

GitOrigin-RevId: 05a3ca0a901a8dc24337d130548aa2c048b4d586
2026-10-16 19:13:40 +00:00

13 lines
448 B
Rust

//! Logical backend identity, independent of a transport connection or native thread ID.
//! Reconnecting and auxiliary picker connections reuse the launch owner; a different
//! backend gets a fresh identity. These process-local IDs never appear on the wire.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub(crate) struct BackendId(uuid::Uuid);
impl BackendId {
pub(crate) fn new() -> Self {
Self(uuid::Uuid::new_v4())
}
}