Commit 68c0191
* feat: add prompt history navigation with arrow keys (#4139)
- Navigate through prompt history using arrow up/down keys
- Only triggers when cursor is at first line (up) or last line (down)
- Preserves current input when starting navigation
- Resets navigation state when typing or sending messages
- Follows VSCode's standard UX patterns for history navigation
* fix: correct prompt history order and add workspace filtering (#4139)
- Remove reverse() to maintain chronological order in history array
- Add workspace filtering to only show prompts from current workspace
- Ensure arrow up navigates to older prompts (as expected)
- Filter history items by workspace field matching current cwd
* test: Fix Windows unit test failures for prompt history navigation
- Add missing taskHistory and cwd properties to all useExtensionState mocks
- Add comprehensive test coverage for prompt history navigation feature
- Ensure all 25 tests pass including new prompt history functionality
Fixes failing Windows CI test in PR #4450
* refactor: Improve cursor positioning with useLayoutEffect
- Replace setTimeout(..., 0) with useLayoutEffect for more reliable cursor positioning
- Implement state-based cursor positioning pattern suggested by @mochiya98
- Add CursorPositionState interface for better type safety
- Maintain all existing functionality while improving timing reliability
This addresses the technical suggestion in PR #4450 comment about using
useLayoutEffect instead of setTimeout for DOM manipulation timing.
* feat: optimize prompt history with performance improvements and memory management
- Add useMemo for prompt history filtering to prevent unnecessary re-computations
- Implement MAX_PROMPT_HISTORY_SIZE = 100 limit for memory management
- Extract logic into usePromptHistory custom hook for better code organization
- Simplify ChatTextArea component by delegating history logic to custom hook
Addresses review feedback on PR #4450 for issue #4139
* refactor: clean up unused code and fix linting issues in prompt history
- Remove unused CursorPositionState interface from ChatTextArea
- Remove unused destructured variables from usePromptHistory hook
- Fix missing dependency in useEffect dependency array
- Rename unused parameter with underscore prefix
Related to #4139
* feat: implement hybrid prompt history with position reset
- In chat: Use conversation messages (user_feedback), newest first
- Out of chat: Use task history, oldest first
- Reset navigation position when switching between history sources
- Switch from taskHistory to clineMessages for active conversations
- Maintain backward compatibility with task history fallback
- Add comprehensive tests for hybrid behavior and position reset
This provides intuitive UX where:
- Users navigate recent conversation messages during tasks (newest first)
- Users access initial task prompts when starting fresh (oldest first)
- Navigation always starts fresh when switching contexts
* fix: correct task history slicing order for prompt navigation
Task history was using .slice(-100) which gets the newest 100 tasks,
but we want to show oldest tasks first when navigating. Changed to
.slice(0, 100) to get the oldest 100 tasks instead.
This ensures that when starting fresh (no conversation), up arrow
shows the oldest task prompts first, which is the intended behavior.
* refactor: remove comment on task history size limitation and clarify order preservation
* refactor: replace local ClineMessage and TaskHistoryItem interfaces with imported types
* fix: prevent prompt history fallback to task list during active conversation
When an active task has only an initial prompt with no follow-up user messages,
the prompt history should return empty instead of falling back to task history.
This fixes the "Starting Fresh" behavior appearing inappropriately.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: Daniel Riccio <[email protected]>
Co-authored-by: Claude <[email protected]>
1 parent 9e4bcdd commit 68c0191
File tree
3 files changed
+594
-1
lines changed- webview-ui/src/components/chat
- __tests__
- hooks
3 files changed
+594
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| 79 | + | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
| |||
153 | 156 | | |
154 | 157 | | |
155 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
156 | 174 | | |
157 | 175 | | |
158 | 176 | | |
| |||
360 | 378 | | |
361 | 379 | | |
362 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
363 | 386 | | |
364 | 387 | | |
365 | 388 | | |
366 | 389 | | |
| 390 | + | |
| 391 | + | |
367 | 392 | | |
368 | 393 | | |
369 | 394 | | |
| |||
427 | 452 | | |
428 | 453 | | |
429 | 454 | | |
| 455 | + | |
| 456 | + | |
430 | 457 | | |
431 | 458 | | |
432 | 459 | | |
| |||
437 | 464 | | |
438 | 465 | | |
439 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
440 | 488 | | |
441 | 489 | | |
442 | 490 | | |
| |||
445 | 493 | | |
446 | 494 | | |
447 | 495 | | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
448 | 499 | | |
449 | 500 | | |
450 | 501 | | |
| |||
499 | 550 | | |
500 | 551 | | |
501 | 552 | | |
502 | | - | |
| 553 | + | |
503 | 554 | | |
504 | 555 | | |
505 | 556 | | |
| |||
0 commit comments