fix(cli): promote resubmitted history prompt to most recent#3531
Merged
Conversation
Selecting an older entry from input history via the arrow keys and pressing Enter now moves that entry to the most recent position, so the next Up press surfaces it first. Previously two bugs combined to keep stale copies in place: the history-navigation index was not reset on submit, and deduplication only collapsed consecutive repeats, leaving non-consecutive duplicates intact.
Collaborator
Author
E2E Test ReportBinary: SetupPre-seeded Test 1 — Pre-fix reproduction (global
|
| Step | Action | Expected | Observed | Result |
|---|---|---|---|---|
| 1 | Up×1 | third prompt |
third prompt |
pass |
| 2 | Up×2 | second prompt |
second prompt |
pass |
| 3 | Up×3 | first prompt (oldest) |
first prompt |
pass |
| 4 | Press Enter, wait for model | submit succeeds | submit succeeds | pass |
| 5 | Up×1 | first prompt (most recent) |
first prompt (stuck) |
bug |
| 6 | Up×2 | third prompt |
first prompt again |
FAIL |
| 7 | Up×3 | second prompt |
first prompt again |
FAIL |
| 8 | After Down-reset, Up all the way | each entry once | duplicate first prompt appears at the tail |
FAIL |
Test 2 — Post-fix verification (node dist/cli.js)
| Step | Action | Expected | Observed | Result |
|---|---|---|---|---|
| 1 | Up×1 | third prompt |
third prompt |
pass |
| 2 | Up×2 | second prompt |
second prompt |
pass |
| 3 | Up×3 | first prompt |
first prompt |
pass |
| 4 | Press Enter, wait for model | submit succeeds | submit succeeds | pass |
| 5 | Up×1 | first prompt (just submitted) |
first prompt |
pass |
| 6 | Up×2 | third prompt |
third prompt |
pass |
| 7 | Up×3 | second prompt |
second prompt |
pass |
| 8 | Up×4 | stays at second prompt (no duplicate) |
stays at second prompt |
pass |
| 9 | Up×5 | still bounded at second prompt |
still bounded | pass |
Unit tests
Added two regression tests, both passing:
InputPrompt— verifiesresetHistoryNavis invoked when the user submits via Enter.dedupeNewestFirst— covers empty input, no duplicates, consecutive duplicates, and non-consecutive duplicates (keeps newest occurrence).
Full suites for the two affected files pass: InputPrompt.test.tsx and AppContainer.test.tsx (155 pass, 1 skipped). Typecheck clean.
Contributor
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
wenshao
approved these changes
Apr 24, 2026
wenshao
left a comment
Collaborator
There was a problem hiding this comment.
No issues found. LGTM! ✅ — gpt-5.5 via Qwen Code /review
xaelistic
pushed a commit
to xaelistic/qwen-code
that referenced
this pull request
Jun 7, 2026
) Selecting an older entry from input history via the arrow keys and pressing Enter now moves that entry to the most recent position, so the next Up press surfaces it first. Previously two bugs combined to keep stale copies in place: the history-navigation index was not reset on submit, and deduplication only collapsed consecutive repeats, leaving non-consecutive duplicates intact.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
When a user navigates up through their prompt history with the arrow keys and presses Enter on an older entry, the submitted prompt should move to the most recent position — so the next Up arrow surfaces it first. Today it doesn't: the entry stays wherever it was in the list, and in many cases a stale copy also remains at its old position. This PR fixes both problems so history follows an intuitive most-recently-used ordering.
Screenshots / Video Demo
N/A — behavior change, best validated interactively. See the Reviewer Test Plan below.
Dive Deeper
Two distinct bugs interact to produce the reported behavior:
1. History navigation index isn't reset on submit. When the user uses the arrow keys to walk up into an older prompt and then hits Enter, the submit handler never clears the in-memory navigation position. On the very next Up press, navigation advances from that stale index rather than starting fresh from the newest entry, which in turn lands the user on an older (and now duplicate) entry and then blocks further Up presses until they press Down enough times to reset.
2. History deduplication only collapses consecutive duplicates. After a session appends a new entry, the combined (current-session + past-session) list is deduped by skipping adjacent repeats only. When the user resubmits a prompt that already existed elsewhere in history, the original occurrence is preserved — so the same text ends up appearing in two positions and Up-arrow navigation eventually surfaces the old copy again.
The fix addresses both:
The second change is effectively a small semantic shift from "collapse adjacent repeats" to "unique entries, newest wins" — which matches how most shells and editors treat input history.
Reviewer Test Plan
Testing Matrix
Linked issues / bugs
N/A — reported by a user, no existing GitHub issue.