Skip to content

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

Closed as not planned
Closed as not planned

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.

Activity

  1. github-actions commented on May 5, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Please review those issues and consider adding your findings there if they cover the same root cause.

  2. github-actions commented on Jul 5, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions