Skip to content

CLI prompt history is global, not project-scoped #25811

@bold84

Description

@bold84

Bug description

The CLI TUI prompt history (arrow-up/down navigation in the input) is stored in a single global file rather than being scoped per project. This means pressing arrow-up in one project shows messages typed in completely different projects.

Steps to reproduce

  1. Open opencode CLI in project A, type and send several messages
  2. Close opencode
  3. Open opencode CLI in project B
  4. Press arrow-up in the input

Expected: See messages previously typed in project B
Actual: See messages from project A (and all other projects) mixed together

Root cause

packages/opencode/src/cli/cmd/tui/component/prompt/history.tsx:32 stores history at a global path:

const historyPath = path.join(Global.Path.state, "prompt-history.jsonl")

Global.Path.state resolves to the OS XDG state directory (~/.local/state/opencode/) which is shared across all projects. The file has no project identifier in its path, and the load/append/move functions have no project filtering.

Suggested fix

Scope the history file per project, e.g.:

const historyPath = path.join(Global.Path.state, `${projectID}`, "prompt-history.jsonl")

Or use Instance.context to derive a project-specific path rather than the global one.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions