Skip to content

Conversation

@4shub
Copy link
Contributor

@4shub 4shub commented Nov 1, 2025

History from API

@4shub 4shub requested review from Copilot and cpacker November 1, 2025 19:22
Copy link

Copilot AI left a 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 20 should 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;
Copy link

Copilot AI Nov 1, 2025

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.

Copilot uses AI. Check for mistakes.
}

// Fetch PAGE_SIZE + 1 to determine if there are more messages beyond this batch
const PAGE_SIZE = 50;
Copy link

Copilot AI Nov 1, 2025

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.

Copilot uses AI. Check for mistakes.
4shub and others added 2 commits November 2, 2025 09:42
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants