tui: keep history recall cursor at line end (#11295)

## Summary
- keep cursor at end-of-line after Up/Down history recall
- allow continued history navigation when recalled text cursor is at
start or end boundary
- add regression tests and document the history cursor contract in
composer docs

## Testing
- just fmt
- cargo test -p codex-tui --lib
history_navigation_leaves_cursor_at_end_of_line
- cargo test -p codex-tui --lib
should_handle_navigation_when_cursor_is_at_line_boundaries
- cargo test -p codex-tui *(fails in existing integration test
`suite::no_panic_on_startup::malformed_rules_should_not_panic` because
`target/debug/codex` is not present in this environment)*
This commit is contained in:
Josh McKinney
2026-02-10 09:21:46 -08:00
committed by GitHub
Unverified
parent 3322b99900
commit e704f488bd
3 changed files with 99 additions and 10 deletions
+5
View File
@@ -144,6 +144,10 @@ Local history entries capture:
Persistent history entries only restore text. They intentionally do **not** rehydrate attachments
or pending paste payloads.
For non-empty drafts, Up/Down navigation is only treated as history recall when the current text
matches the last recalled history entry and the cursor is at a boundary (start or end of the
line). This keeps multiline cursor movement intact while preserving shell-like history traversal.
### Draft recovery (Ctrl+C)
Ctrl+C clears the composer but stashes the full draft state (text elements, image paths, and
@@ -157,6 +161,7 @@ ranges and local image paths. Pending paste payloads are cleared during submissi
placeholders are expanded into their full text before being recorded. This means:
- Up/Down recall of a submitted message restores image placeholders and their local paths.
- Recalled entries place the cursor at end-of-line to match typical shell history editing.
- Large-paste placeholders are not expected in recalled submitted history; the text is the
expanded paste content.