Skip to content

feat(desktop): add input history navigation with Up/Down arrow keys#3648

Closed
PsjJourney wants to merge 2 commits into
esengine:main-v2from
PsjJourney:feat/desktop-input-history
Closed

feat(desktop): add input history navigation with Up/Down arrow keys#3648
PsjJourney wants to merge 2 commits into
esengine:main-v2from
PsjJourney:feat/desktop-input-history

Conversation

@PsjJourney

Copy link
Copy Markdown

增加键盘上下按键的时候,能直接呼出历史会话问题

- Add persistent input history saved to localStorage (survives app restart)
- Up arrow navigates to older inputs, Down arrow navigates to newer
- Saves current draft before entering history mode, restores on exit
- Only triggers history when cursor is on first/last line (respects multiline input)
- Deduplicates consecutive identical inputs
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) and removed v2 Go rewrite (1.x) — main-v2 branch, active development labels Jun 9, 2026
@esengine

Copy link
Copy Markdown
Owner

main-v2 absorbed a large batch of merges today and this branch now conflicts. Could you rebase onto the latest main-v2? The change itself is still wanted — once it's green I'll review promptly (fork CI gets approved as soon as you push).

@esengine

Copy link
Copy Markdown
Owner

Specifics for the rebase round so it's one pass:

  1. navigatingHistoryRef rests on a React misconception — programmatic setText never fires onChange (only user input does), so the ref is consumed by the user's first real keystroke instead of by navigation. Net effect: historyIndex survives an edit, and the next ArrowUp throws the user's edit away. Delete the ref entirely: any onChange is user input → reset history mode.
  2. cursorOnFirstLine only checks \n — on a soft-wrapped long line ArrowUp recalls history instead of moving the caret up a visual line. Safest cheap rule: only trigger when the caret is at position 0 or the textarea has a single visual line.
  3. Cap the history (e.g. 50 entries) — it currently grows unbounded in localStorage.
  4. Validate the localStorage parse (Array.isArray + string elements) per the boundary-validation rule; a corrupted entry currently throws into the component.
  5. Strip the restating comments (// Save to input history, etc.) per the repo comment policy.

Also note #3722 touches Composer.tsx and will land first — rebase over it.

@SivanCola

Copy link
Copy Markdown
Collaborator

Closing this as superseded by #4349.

Thanks @PsjJourney for the earlier implementation. I carried the contribution forward in #4349 by crediting:

  • establishing Up/Down as the desktop composer prompt-history navigation gesture
  • exploring draft preservation/restoration while moving through recalled prompts
  • keeping the behavior scoped to composer keyboard handling

#4349 keeps that UX direction and implements it with persisted session-backed replay plus broader regression coverage. @PsjJourney is also listed as a co-author on the updated #4349 commit.

@SivanCola SivanCola closed this Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants