Preserve transcript position when opening settings pickers (#46910)

## Why

Opening a settings picker while reading older messages should preserve the
reading position. Settings errors and confirmations still need to be visible.

## What changed

- Keep the transcript anchored when opening `/model`, `/theme`, `/keymap`,
  `/memories`, `/title`, and `/statusline` without arguments.
- Resume transcript following for settings actions that report confirmations
  or errors, including save failures and unavailable commands.
- Keep inline commands and commands with arguments following their output.

## Testing

Add regression tests for picker open/close behavior, settings save failures,
confirmation output, and `/model` before startup completes. Include snapshots
of the preserved reading position and a visible theme save error.

GitOrigin-RevId: 0680e6414d43b8b5d2a3ab9a2df187abfb727d49
This commit is contained in:
Eric Traut
2026-09-21 00:16:33 +00:00
committed by copyberry
parent 88ef37c649
commit ee2149a9b4
6 changed files with 304 additions and 19 deletions
+25 -6
View File
@@ -3,7 +3,8 @@
//! The queue data itself lives in `input_queue`; this module owns the app-level
//! effects around taking composer input, submitting user turns, draining queued
//! follow-ups, and restoring draft state across interrupts or thread switches.
//! Composer submissions resume transcript following before dispatch or startup queueing.
//! Composer submissions resume transcript following before dispatch or startup queueing,
//! except for reversible settings pickers that preserve the reading position.
use super::*;
use crate::bottom_pane::prompt_args::parse_slash_name;
@@ -22,12 +23,26 @@ impl ChatWidget {
input_result: InputResult,
had_modal_or_popup: bool,
) {
if matches!(
&input_result,
let follow_transcript = match &input_result {
// Opening settings is not a request to leave the current reading anchor.
// Inline commands still follow so their output (including usage errors) is visible.
InputResult::Command(
SlashCommand::Model
| SlashCommand::Keymap
| SlashCommand::Memories
| SlashCommand::Title
| SlashCommand::Statusline
| SlashCommand::Theme,
) => false,
InputResult::Command(_)
| InputResult::ServiceTierCommand(_)
| InputResult::CommandWithArgs(..)
) {
| InputResult::ServiceTierCommand(_)
| InputResult::CommandWithArgs(..) => true,
InputResult::Submitted { .. }
| InputResult::Queued { .. }
| InputResult::ParentOwnedInputBlocked
| InputResult::None => false,
};
if follow_transcript {
self.app_event_tx.send(AppEvent::FollowTranscript);
}
match input_result {
@@ -80,6 +95,10 @@ impl ChatWidget {
}
InputResult::Command(cmd) => {
self.handle_slash_command_dispatch(cmd);
// A settings command can instead report why it is unavailable.
if !follow_transcript && self.bottom_pane.no_modal_or_popup_active() {
self.app_event_tx.send(AppEvent::FollowTranscript);
}
}
InputResult::ServiceTierCommand(command) => {
self.handle_service_tier_command_dispatch(command);