Skip to content

feat(vscode): scope prompt input history to each conversation - #14632

Merged
brunoagatao merged 15 commits into
mainfrom
feat/per-conversation-prompt-history
Oct 2, 2026
Merged

brunoagatao merged 15 commits into
mainfrom
feat/per-conversation-prompt-history

Conversation

@brunoagatao

@brunoagatao brunoagatao commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #14553

Prompt input history (ArrowUp/ArrowDown recall) is one list shared by every conversation. This adds an option to keep it separate per conversation.

Change

  • New Per-Conversation Prompt History switch in Settings → Experimental. It is off by default.
  • Default (shared) behavior is unchanged. The shared list stays in the same kilo.prompt-history.v1 key and format, with no length limit, and is still seeded from session messages (including prompts sent from the TUI). Users who never enable the switch never write anything new to storage.
  • When on, history is stored per session under a new kilo.prompt-history.v2 key and restored when the conversation is reopened. The two lists are kept apart, so switching the setting loses nothing.
  • A prompt is always recorded against the conversation it was sent from, even if the user switches chats mid-send. A new chat's history moves to its session when the session is created.
  • Per-conversation storage is bounded: at most 50 conversations (least recently used are dropped), and prompts over 10,000 characters are not remembered in that mode.

Testing

Unit tests cover isolation, the shared mode, eviction, the entry cap, and storage load/save/quota paths. I also compared the old hook and the new shared mode on random operation sequences: results, index and saved bytes were identical.

@kilo-code-bot

kilo-code-bot Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • packages/kilo-vscode/webview-ui/src/hooks/usePromptHistory.ts
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx
  • packages/kilo-vscode/tests/unit/prompt-history.test.ts
  • packages/kilo-vscode/tests/unit/prompt-history-storage.test.ts
  • packages/kilo-vscode/tests/paste-collapse.spec.ts
Previous Review Summaries (6 snapshots, latest commit daa80f4)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit daa80f4)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (31 files)
  • .changeset/per-conversation-prompt-history.md
  • packages/kilo-vscode/package.json
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/tests/paste-collapse.spec.ts
  • packages/kilo-vscode/tests/unit/prompt-history-storage.test.ts
  • packages/kilo-vscode/tests/unit/prompt-history.test.ts
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/ExperimentalTab.tsx
  • packages/kilo-vscode/webview-ui/src/hooks/usePromptHistory.ts
  • packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts
  • packages/kilo-vscode/webview-ui/src/i18n/*.ts (21 locale files)

Previous review (commit 36fd092)

Status: No Issues Found | Recommendation: Merge

Incremental re-review of commit cef2b4629 (the experimental "Global Prompt History" setting): the prior findings (cross-conversation append, unbounded store growth, side-effecting index accessor) remain resolved, and no new issues were found in the changed code. No new inline comments were posted.

Files Reviewed (29 files)
  • .changeset/per-conversation-prompt-history.md
  • packages/kilo-vscode/package.json
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/tests/unit/prompt-history.test.ts
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/ExperimentalTab.tsx
  • packages/kilo-vscode/webview-ui/src/hooks/usePromptHistory.ts
  • packages/kilo-vscode/webview-ui/src/i18n/*.ts (21 locale files, new globalPromptHistory keys)
  • packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts

Previous review (commit 2e9c6fd)

Status: No Issues Found | Recommendation: Merge

Incremental re-review of the fix commits: prior findings (cross-conversation append, unbounded store growth, side-effecting index accessor) are resolved, and no new issues were found in the changed code. No new inline comments were posted.

Files Reviewed (7 files)
  • .changeset/per-conversation-prompt-history.md
  • packages/kilo-vscode/tests/paste-collapse.spec.ts
  • packages/kilo-vscode/tests/unit/prompt-history.test.ts
  • packages/kilo-vscode/tests/unit/prompt-send-contract.test.ts
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx
  • packages/kilo-vscode/webview-ui/src/components/chat/goal/useGoalComposer.ts
  • packages/kilo-vscode/webview-ui/src/hooks/usePromptHistory.ts

Previous review (commit dbee862)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • packages/kilo-vscode/tests/unit/prompt-history.test.ts
  • packages/kilo-vscode/tests/unit/prompt-send-contract.test.ts
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx
  • packages/kilo-vscode/webview-ui/src/components/chat/goal/useGoalComposer.ts
  • packages/kilo-vscode/webview-ui/src/hooks/usePromptHistory.ts

Previous review (commit fc3910b)

Status: 3 Issues Found | Recommendation: Address before merge

The latest commit (fc3910b60) only refactored the key-resolution and navigate ordering in usePromptHistory.ts; it fixed none of the earlier findings. Per-conversation isolation still has one timing edge that can mix history across conversations and unbounded per-conversation store growth.

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/webview-ui/src/hooks/usePromptHistory.ts 178 append targets the current conversation key; PromptInput's clearDraft appends before checking draftKey() !== key, so a send completing after a session switch can land in the wrong conversation's history.
packages/kilo-vscode/webview-ui/src/hooks/usePromptHistory.ts 96 Unbounded per-conversation store growth with no eviction, plus entriesFor retaining empty buckets (now also materialized by rejected navigate calls at line 145); every save serializes the whole store, risking quota failure and loss of persistence.

SUGGESTION

File Line Issue
packages/kilo-vscode/webview-ui/src/hooks/usePromptHistory.ts 190 Exposed index accessor mutates state via syncKey(); a side-effecting getter can trigger extra reactive re-runs if consumed.
Files Reviewed (4 files)
  • .changeset/per-conversation-prompt-history.md - no issues
  • packages/kilo-vscode/tests/unit/prompt-history.test.ts - no issues
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx - no issues
  • packages/kilo-vscode/webview-ui/src/hooks/usePromptHistory.ts - 3 issues

Fix these issues in Kilo Cloud

Previous review (commit fca1138)

Status: 3 Issues Found | Recommendation: Address before merge

The change cleanly scopes prompt history per conversation and adds targeted tests, but the new Store shape introduces unbounded growth and one timing edge that can still mix history across conversations.

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/webview-ui/src/hooks/usePromptHistory.ts 179 append uses the current conversation key; PromptInput's clearDraft appends before checking draftKey() !== key, so a send completing after a session switch can land in the wrong conversation's history.
packages/kilo-vscode/webview-ui/src/hooks/usePromptHistory.ts 96 Unbounded per-conversation store growth with no eviction, plus entriesFor retaining empty buckets; every save serializes the whole store, risking quota failure and loss of persistence.

SUGGESTION

File Line Issue
packages/kilo-vscode/webview-ui/src/hooks/usePromptHistory.ts 191 Exposed index accessor mutates state via syncKey(); a side-effecting getter can trigger extra reactive re-runs if consumed.
Files Reviewed (4 files)
  • .changeset/per-conversation-prompt-history.md - no issues
  • packages/kilo-vscode/tests/unit/prompt-history.test.ts - no issues
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx - no issues
  • packages/kilo-vscode/webview-ui/src/hooks/usePromptHistory.ts - 3 issues

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0

Review guidance: REVIEW.md from base branch main

@brunoagatao
brunoagatao force-pushed the feat/per-conversation-prompt-history branch from fca1138 to fc3910b Compare September 28, 2026 12:22
… and side-effecting accessor

Addresses PR review feedback on #14632:
- history.append() now accepts an optional targetKey so a send that completes
  after the user switches conversations still credits the conversation it was
  actually sent to, instead of whichever conversation is now active. Threaded
  through PromptInput's handleSend/clearDraft and the goal composer's
  send/begin/move/finish so both the direct-send and Goal-mode paths are covered.
- The per-conversation store no longer grows without bound: reads (ArrowUp) never
  allocate a bucket, and buckets are capped at MAX_CONVERSATIONS with LRU eviction.
- The exposed index accessor is now a pure signal read with no side effects;
  key-change resets happen only from action methods (navigate/append/seed).
@brunoagatao

Copy link
Copy Markdown
Collaborator Author

Addressed all three review comments in dbee862:

  1. Cross-conversation append after a session switch — history.append() now takes an optional targetKey. handleSend captures id (the actual send target) before the terminal/git attachment awaits and threads it through clearDraft into history.append(value, historyKey), so a completed send always credits the conversation it was sent to, even if the user switched away during the awaits. The Goal-mode path (goal.send/begin/move/finish) carries the same historyKey through to ops.clear, since that path resolves even later (on the backend's async sessionCommandCompleted/sendMessageFailed response).
  2. Unbounded store growth — reads (ArrowUp on an empty conversation) no longer allocate/persist a bucket; only writes (append/seed) create one. The store is now a Map capped at MAX_CONVERSATIONS (50) with LRU eviction of the least-recently-touched conversation.
  3. Side-effecting index accessor — removed the syncKey() call from the exposed index accessor; it's now a plain signal read. Key-change resets (browsing index + saved draft) happen only inside action methods (navigate/append/seed), which were already side-effecting.

Also updated the pre-existing prompt-send-contract.test.ts structural test (it string-matched the old clearDraft(key, draft)/history.append(value) call shapes) and added unit test coverage for the target-key override, LRU eviction, and the read-vs-write allocation split.

@brunoagatao brunoagatao self-assigned this Oct 1, 2026
@brunoagatao
brunoagatao merged commit 671c389 into main Oct 2, 2026
27 of 28 checks passed
@brunoagatao
brunoagatao deleted the feat/per-conversation-prompt-history branch October 2, 2026 10:00
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.

[FEATURE]: Option to keep prompt input history separate per conversation

2 participants