Hmbown/CodeWhale · error
fork_at_user_message: depth
Error message
fork_at_user_message: depth {} exceeds {} user turn(s) What it means
fork_at_user_message walked the source thread's turns and found fewer user turns than the requested depth, so the fork point does not exist; the fork is refused rather than silently forking at an unintended position.
Solutions
- Use a smaller depth_from_tail within the thread's user-turn count.
- Choose the target user message by inspecting the thread's turns and pass the correct depth.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/tui/src/runtime_threads.rs:8423 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/5586a6720d9172ff.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/runtime_threads.rs:8423
depth_from_tail: usize,
) -> Result<PreparedThreadFork> {
let source = self.get_thread(id).await?;
let source_turns = self.store.list_turns_for_thread(&source.id)?;
// Walk turns from newest to oldest. For each turn, ask: does it
// contain a UserMessage item? If yes, it counts toward the depth.
let mut user_turn_indices: Vec<usize> = Vec::new();
for (idx, turn) in source_turns.iter().enumerate().rev() {
let items = self.store.list_items_for_turn(&turn.id)?;
if items
.iter()
.any(|item| item.kind == TurnItemKind::UserMessage)
{
user_turn_indices.push(idx);
}
}
if depth_from_tail >= user_turn_indices.len() {
bail!(
"fork_at_user_message: depth {} exceeds {} user turn(s)",
depth_from_tail,
user_turn_indices.len()
);
}
// `user_turn_indices` is newest-first because we iterated in
// reverse, so the Nth element is exactly the Nth-from-tail user
// turn in the original chronological list.
let target_turn_idx = user_turn_indices[depth_from_tail];
let target_turn_id = source_turns[target_turn_idx].id.clone();
// Pull the original user-message text out of the dropped turn so
// the caller can drop it back into the composer.
let target_items = self.store.list_items_for_turn(&target_turn_id)?;
let original_user_text = target_items
.iter()
.find(|item| item.kind == TurnItemKind::UserMessage)
.and_then(|item| item.detail.clone());View on GitHub (pinned to 73e0f67d83)