Skip to content

feat(Chat): add blank-input prompt history navigation#78

Merged
remarkablemark merged 2 commits into
masterfrom
feat/history
May 16, 2026
Merged

feat(Chat): add blank-input prompt history navigation#78
remarkablemark merged 2 commits into
masterfrom
feat/history

Conversation

@remarkablemark
Copy link
Copy Markdown
Member

@remarkablemark remarkablemark commented May 16, 2026

What is the motivation for this pull request?

Feature: add shell-like prompt history navigation to the chat input.

What is the current behavior?

Pressing Up/Down in the chat input only controls file suggestions and command menus — there is no way to recall previously submitted prompts.

What is the new behavior?

When the input is blank, Up recalls older submitted prompts and Down moves forward toward newer prompts, ending at an empty draft. History is scoped to the current chat session, initialized from the session's persisted transcript on load, and maintained in memory for the rest of the mounted session.

Implementation changes:

  • Extend Chat/Input to own prompt-history state, initialized from the active session's existing user prompts. Append newly submitted non-command user prompts; track a navigation index and empty-draft state so Down returns to blank input. Reset navigation state when the history prop changes (new session).
  • Update Chat to derive session prompt history once from initialMessages (role user, excluding slash commands) and pass it into Input as history.
  • Intercept Up/Down in Chat/Input only when input is blank or already navigating history; preserve existing behavior otherwise.
  • Rename Input component to ChatInput.

Public interface changes:

  • Input props gain history: string[].

plan.md

Checklist:

Summary:

Add shell-like prompt history navigation to the chat input: when the input is blank, `Up` recalls older submitted prompts and `Down` moves forward toward newer prompts, ending at an empty draft. History is scoped to the current chat session, derived from that session's persisted transcript on load, then maintained in memory for the rest of the mounted session.

Implementation Changes:

- Extend `Chat/Input` to own prompt-history state:
  - Initialize history from the active session's existing user prompts.
  - Append newly submitted non-command user prompts after trimming and successful submit.
  - Track a navigation index plus an empty-draft state so `Down` can return to blank input after recall.
  - Reset navigation state whenever the input `history` prop changes for a different session.
- Update `Chat` to derive session prompt history once from `initialMessages` for the active session and pass it into `Input` as `history`.
  - Include only `role === user` messages.
  - Exclude slash commands from history.
  - Do not persist or read any separate history file.
- Intercept `Up`/`Down` in `Chat/Input` only when:
  - input is blank, or
  - the user is already navigating history.
- Preserve existing behavior when not navigating history:
  - `Up`/`Down` continue to work for file suggestions and command menus.
  - Normal typing exits navigation mode and resumes ordinary editing from the recalled value.

Public Interface Changes:

- `Input` props gain `history: string[]`.

Tests:

- Add `Chat` coverage for deriving `history` from `initialMessages`, including excluding slash commands.
- Add `Input` tests for:
  - recalling the most recent prompt with blank-input `Up`
  - stepping backward through multiple prompts with repeated `Up`
  - stepping forward with `Down`
  - returning to empty input at the end of forward navigation
  - not recording empty submissions
- not recording slash commands
- resetting navigation state when `history` changes for the new session
  - preserving existing file-suggestion `Up`/`Down` behavior when suggestions are visible

Assumptions:

- Source of truth for persisted recall is `~/.code-ollama/sessions/<sessionId>/messages.jsonl`, already loaded into `initialMessages`.
- History derivation happens once per active session load; no repeated transcript scans during input editing.
- Prompt history is prompt-only, not command history.
- `/clear` creates a new session and therefore starts with empty history.
- Rename Input.tsx to ChatInput.tsx
- Rename Input.test.tsx to ChatInput.test.tsx
- Update component name from Input to ChatInput
- Update all imports and references
- Update mock in Chat.test.tsx
@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/components/Chat/Chat.tsx 100.00% <100.00%> (ø)
src/components/Chat/ChatInput.tsx 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@remarkablemark remarkablemark self-assigned this May 16, 2026
@remarkablemark remarkablemark added the enhancement New feature or request label May 16, 2026
@remarkablemark remarkablemark merged commit b441fa1 into master May 16, 2026
16 checks passed
@remarkablemark remarkablemark deleted the feat/history branch May 16, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant