Hmbown/CodeWhale · error · std::io::Error
session '{session_id}' is open in an interactive Codewhale s
Error message
session '{session_id}' is open in an interactive Codewhale session; change it there instead — an external write would be reverted by its next autosave What it means
live_session_conflict is the sentinel the session manager returns (io::ErrorKind::ResourceBusy) when an external writer tries to rename or archive a session that a live interactive Codewhale process currently owns; the write is refused because the owning session's autosave would revert it.
Source
Thrown at crates/tui/src/session_manager.rs:281
}
/// Is this session currently owned by **this process's** interactive surface?
///
/// The registry is process-local. Reclamation must not treat a missing entry
/// here as proof that no other Codewhale process still owns the directory.
#[must_use]
pub fn is_live_session(session_id: &str) -> bool {
live_sessions()
.read()
.is_ok_and(|live| live.contains(session_id))
}
/// The error an external writer gets when the session is live.
///
/// `ResourceBusy` so callers can map it to a typed conflict rather than
/// pattern-matching on a message.
fn live_session_conflict(session_id: &str) -> std::io::Error {
std::io::Error::new(
std::io::ErrorKind::ResourceBusy,
format!(
"session '{session_id}' is open in an interactive Codewhale session; \
change it there instead — an external write would be reverted by its next autosave"
),
)
}
/// File-name stem of the sidecar mapping session ids to the session
/// instance (process boot) that created their persisted record. Lives in
/// the sessions directory next to the `<id>.json` records it describes.
const SESSION_BOOT_OWNERS_STEM: &str = "session_boot_owners";
static SESSION_BOOT_ID: std::sync::OnceLock<String> = std::sync::OnceLock::new();
/// Identity of this running session instance (one per process boot).
///
/// Mirrors the `SubAgentManager` boot id from #405: persisted records areView on GitHub (pinned to 0c42157ee5)
Solutions
- Perform the rename/archive inside the interactive session that owns it.
- Close the interactive session first, then retry the external change.
- Treat the ResourceBusy error as a typed conflict and surface it rather than retrying blindly.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/tui/src/session_manager.rs:281 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/4523abaa7cad44f2.
Report an issue: GitHub.