Render the initial TUI session header before input (#38639)

## What changed

- Drain queued app events until the initial session header is installed before
  handling terminal input.
- Render the active session header without a leading separator so it starts at
  the top of the viewport.

## Testing

- Add a rendering snapshot that verifies the initial header begins on the first
  viewport row.

GitOrigin-RevId: 070417776b629c681b3f94e93ba619dfefe764b1
This commit is contained in:
Charlie Marsh authored and copyberry committed 2026-08-14 20:19:42 +00:00
1 parent ccee70f813
commit 7e65e4f330
3 files changed
+57 -3

No files matched your search

+16 -2
View File
@@ -1181,6 +1181,7 @@ See the Codex keymap documentation for supported actions and examples."
let mut listen_for_app_server_events = true;
let mut waiting_for_initial_session_configured = wait_for_initial_session_configured;
let mut waiting_for_initial_session_header = true;
#[cfg(not(debug_assertions))]
let pre_loop_exit_reason = if let Some(latest_version) = upgrade_version {
@@ -1207,10 +1208,23 @@ See the Codex keymap documentation for supported actions and examples."
Ok(exit_reason)
} else {
loop {
let initial_session_header_pending = waiting_for_initial_session_header
&& app.primary_session_configured.is_some()
&& !app_event_rx.is_empty();
let control = select! {
Some(event) = app_event_rx.recv() => {
let is_initial_session_header = matches!(
&event,
AppEvent::InsertHistoryCell(cell)
if cell.as_any().is::<history_cell::SessionInfoCell>()
);
match Box::pin(app.handle_event(tui, &mut app_server, event)).await {
Ok(control) => control,
Ok(control) => {
if is_initial_session_header {
waiting_for_initial_session_header = false;
}
control
}
Err(err) => break Err(err),
}
}
@@ -1233,7 +1247,7 @@ See the Codex keymap documentation for supported actions and examples."
}
AppRunControl::Continue
}
event = tui_events.next() => {
event = tui_events.next(), if !initial_session_header_pending => {
if let Some(event) = event {
match app.handle_tui_event(tui, &mut app_server, event).await {
Ok(control) => control,