Preserve draft text when navigating command history with arrow keys#581
Open
Preserve draft text when navigating command history with arrow keys#581
Conversation
When pressing Up arrow in the chat input, the current draft text was permanently lost — pressing Down arrow back to the live position returned an empty string instead of the original draft. Added a draft slot to CommandHistory that stashes the current input text on the first Up navigation and restores it when the user navigates back down past the newest history entry. The draft is cleared when a message is sent (Add). Changes: - CommandHistory: added _draft field, Navigate accepts optional currentText - Dashboard.razor JS: passes ta.value to JsNavigateHistory - Dashboard.razor C#: forwards currentText to hist.Navigate - CommandHistoryTests: 4 new tests (14 total, all passing) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Problem
Pressing Up Arrow in the chat input replaces the current draft with a previous sent message. Pressing Down Arrow back to the live position returns an empty string — the original draft is permanently lost.
This is a standard shell-history UX expectation: bash, zsh, and fish all stash the in-progress line when entering history mode and restore it on return.
Fix
Added a draft slot to
CommandHistory:_draft_draftinstead of returning""Add()(message sent): clears_draftChanges
CommandHistory.cs_draftfield;Navigate()accepts optionalcurrentTextparamDashboard.razor(JS)ta.valuetoJsNavigateHistoryDashboard.razor(C#)currentTexttohist.Navigate()CommandHistoryTests.csTesting
dotnet test --filter CommandHistoryTests— 14/14 passed