-
Notifications
You must be signed in to change notification settings - Fork 20
chore: support history #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds message history pagination support to the CLI input component, allowing users to navigate through older messages using the up arrow key with automatic fetching of earlier messages from the server.
Key changes:
- Extracts user messages from the full message history to populate command history
- Implements pagination logic to fetch earlier messages when navigating near the beginning of history
- Adds loading states for initial and incremental history fetching
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/cli/components/InputRich.tsx | Adds helper function to extract user messages, integrates message history prop with command history state, implements pagination triggers, and adds loading state UI indicators |
| src/cli/App.tsx | Implements message history state management, adds initial history fetch on mount, creates pagination fetch function, and passes history data to Input component |
Comments suppressed due to low confidence (1)
src/cli/components/InputRich.tsx:1
- The magic number
20should be defined as a named constant (e.g.,PREFETCH_HISTORY_THRESHOLD) at the file level for better maintainability and clarity about its purpose.
// Import useInput from vendored Ink for bracketed paste support
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const client = await getClient(); | ||
|
|
||
| // Fetch more messages initially to have a good buffer for fast scrolling | ||
| const INITIAL_LIMIT = 200; |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant INITIAL_LIMIT = 200 is defined inside the function. Consider moving it to the file level for consistency with PAGE_SIZE and to avoid redefinition on each render.
| } | ||
|
|
||
| // Fetch PAGE_SIZE + 1 to determine if there are more messages beyond this batch | ||
| const PAGE_SIZE = 50; |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant PAGE_SIZE = 50 is defined inside the callback function. Consider moving it to the file level for better maintainability and to avoid redefinition on each invocation.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
History from API