mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-28 11:41:04 +00:00
fix(cli): promote resubmitted history prompt to most recent (#3531)
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 commit is contained in:
parent
aeeb2976d6
commit
5556699e43
4 changed files with 76 additions and 11 deletions
|
|
@ -280,6 +280,11 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
|||
[],
|
||||
);
|
||||
|
||||
// Ref to inputHistory.resetHistoryNav, populated after useInputHistory runs.
|
||||
// Needed because handleSubmitAndClear is passed into useInputHistory as
|
||||
// onSubmit, so we can't reference inputHistory directly here without a cycle.
|
||||
const resetHistoryNavRef = useRef<() => void>(() => {});
|
||||
|
||||
const handleSubmitAndClear = useCallback(
|
||||
(submittedValue: string) => {
|
||||
// Expand any large paste placeholders to their full content before submitting
|
||||
|
|
@ -317,6 +322,10 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
|||
buffer.setText('');
|
||||
onSubmit(finalValue);
|
||||
|
||||
// Reset history navigation so the next Up-arrow starts from the newest
|
||||
// entry rather than advancing from whatever index the user picked.
|
||||
resetHistoryNavRef.current();
|
||||
|
||||
// Dismiss follow-up suggestion after submit
|
||||
followup.dismiss();
|
||||
|
||||
|
|
@ -360,6 +369,8 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
|||
onChange: customSetTextAndResetCompletionSignal,
|
||||
});
|
||||
|
||||
resetHistoryNavRef.current = inputHistory.resetHistoryNav;
|
||||
|
||||
// When an arena session starts (agents appear), reset history position so
|
||||
// that pressing down-arrow immediately focuses the agent tab bar instead
|
||||
// of cycling through input history.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue