fix(claudbg-eej6,claudbg-80fb): fix two TUI session/agent transcript bugs

fix(claudbg-eej6): wrap Handle::block_on with block_in_place in TUI
load_transcript_for_session and load_transcript_for_agent called
Handle::current().block_on() from within the tokio::main async context,
causing a panic on session selection. Wrap with block_in_place() to
signal the scheduler to move other tasks off the thread before blocking.

fix(claudbg-80fb): add #[serde(rename = "sessionId")] to RawEntry.session_id
The JSONL field is camelCase ("sessionId") but serde matched only the
literal field name, so session_id always deserialized as None. This made
AgentRef.session_id default to "", and since any_str.starts_with("") is
always true, load_transcript_for_agent matched the wrong session and
found no agent, leaving sub-agent transcripts permanently empty.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main
Elijah Voigt 2 months ago
parent 5bc207c455
commit 96fc4d948d

@ -0,0 +1,25 @@
---
# claudbg-80fb
title: 'TUI sub-agent transcript always empty: sessionId serde rename missing'
status: completed
type: bug
priority: normal
created_at: 2026-03-31T22:32:07Z
updated_at: 2026-03-31T22:33:04Z
---
When selecting a sub-agent in the TUI transcript screen, the transcript is always empty.
Root cause: RawEntry.session_id has no #[serde(rename = "sessionId")] attribute. The JSONL field is camelCase ("sessionId") but serde only matches literal field names, so entry.session_id is always None after deserialization.
This causes read_session_id_from_first_line (discovery.rs) to always return None, so AgentRef.session_id defaults to empty string.
In load_transcript_for_agent, the find predicate uses s.session_id.starts_with(parent_session_id) — and in Rust, any_string.starts_with("") is always true. So it matches the first session in filesystem order (wrong session), fails to find the agent there, and returns with no entries loaded.
Fix: Add #[serde(rename = "sessionId")] to RawEntry.session_id in models/session.rs.
## Summary of Changes
Added `#[serde(rename = "sessionId")]` to `RawEntry.session_id` in `src/models/session.rs`.
This causes `read_session_id_from_first_line` to correctly parse the parent session UUID from agent JSONL files, so `AgentRef.session_id` is populated with the real UUID instead of defaulting to empty string. The TUI `load_transcript_for_agent` function then correctly locates the parent session and loads the agent transcript.

@ -0,0 +1,21 @@
---
# claudbg-eej6
title: 'TUI session select panics: Handle::block_on called from within async context'
status: completed
type: bug
priority: normal
created_at: 2026-03-31T22:15:18Z
updated_at: 2026-03-31T22:16:16Z
---
When selecting a session in the TUI, a panic occurs because load_transcript_for_session (and load_transcript_for_agent) calls tokio::runtime::Handle::current().block_on() from within the tokio::main async context. block_on cannot be called from within an async context — the thread is already driving async tasks.
Root cause: transcript.rs lines 487-489 and 528-530 use Handle::current().block_on() which panics when the calling thread is already inside a tokio runtime (as it is, since main.rs uses #[tokio::main]).
Fix: Wrap both block_on calls with tokio::task::block_in_place(), which tells the multi-thread scheduler to move other tasks off the current thread before blocking.
## Summary of Changes
Replaced with in both and (transcript.rs).
signals the tokio multi-thread scheduler to move other tasks off the current OS thread before blocking it, which is required when blocking from synchronous code called within an async context.

@ -18,6 +18,7 @@ pub struct RawEntry {
#[serde(rename = "type")] #[serde(rename = "type")]
pub entry_type: Option<String>, pub entry_type: Option<String>,
/// UUID of this session. /// UUID of this session.
#[serde(rename = "sessionId")]
pub session_id: Option<String>, pub session_id: Option<String>,
/// UUID of the parent agent, if this is a sub-agent run. /// UUID of the parent agent, if this is a sub-agent run.
pub parent_session_id: Option<String>, pub parent_session_id: Option<String>,

@ -483,10 +483,16 @@ pub fn load_transcript_for_session(session_id: &str, state: &mut AppState) {
state.subagents = agents; state.subagents = agents;
} }
// Read the JSONL file; block on the async reader using the current runtime. // Read the JSONL file. We are in a synchronous function called from within
let handle = tokio::runtime::Handle::current(); // the tokio::main async context, so Handle::block_on alone would panic.
// block_in_place tells the multi-thread scheduler to move other tasks off
// this thread before we block it.
let file_path = sr.file_path.clone(); let file_path = sr.file_path.clone();
if let Ok(entries) = handle.block_on(crate::parser::reader::read_session_file(&file_path)) { let entries_result = tokio::task::block_in_place(|| {
tokio::runtime::Handle::current()
.block_on(crate::parser::reader::read_session_file(&file_path))
});
if let Ok(entries) = entries_result {
state.transcript_entries = entries; state.transcript_entries = entries;
} }
} }
@ -525,9 +531,12 @@ pub fn load_transcript_for_agent(
let Some(ar) = agent_ref else { return }; let Some(ar) = agent_ref else { return };
let handle = tokio::runtime::Handle::current();
let file_path = ar.file_path.clone(); let file_path = ar.file_path.clone();
if let Ok(entries) = handle.block_on(crate::parser::reader::read_session_file(&file_path)) { let entries_result = tokio::task::block_in_place(|| {
tokio::runtime::Handle::current()
.block_on(crate::parser::reader::read_session_file(&file_path))
});
if let Ok(entries) = entries_result {
state.transcript_entries = entries; state.transcript_entries = entries;
} }
} }

Loading…
Cancel
Save