Clear stale transcript history when switching threads (#43994)

## Why

History events queued by the previous thread can repopulate the transcript after a thread switch, mixing old content into the new thread's replay.

## What changed

- Reset the transcript immediately and queue another reset before replaying the new thread, covering both snapshot switches and app-server thread replacement.
- Leave the alternate screen when resetting, and pause terminal event handling until queued resets finish.
- Process queued resets even when the transport is offline.

## Testing

Add regression tests for both switch paths, including queued history, an open transcript overlay, and a disconnect before replay events are handled. Snapshot the replacement transcript to verify it contains only the new thread's content.

GitOrigin-RevId: b68b07fb10ff35e908c2c184f80859dda637f977
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-09 02:26:50 +00:00
1 parent 721f46a07a
commit b831057106
8 files changed
+185 -1

No files matched your search

+3
View File
@@ -508,6 +508,9 @@ pub(crate) enum AppEvent {
name: Option<String>,
},
/// Clear history queued by the previous thread before the new thread's replay events.
ResetTranscriptForThreadSwitch,
/// Re-render the transcript using the selected scrollback rendering mode.
RawOutputModeChanged {
enabled: bool,