Repository navigation
Conversation
…prompts
Up and down in the prompt walk one history file shared by every
session and every OpenCode window on the machine, so a session recalls
prompts that were written for unrelated work. prompt.history_scope
chooses between 'global' (the default, unchanged behaviour) and
'session', where a session walks only the prompts submitted in it.
Each prompt-history.jsonl entry now records the session it was
submitted in. The first prompt sent from the home screen is recorded
with the session it creates. The view is filtered at recall time
(promptHistoryView in packages/tui/src/prompt/history.tsx), so
switching the setting needs no migration and the home screen, which
has no session yet, keeps walking every session's prompts.
Tagging the file was chosen over deriving history from the session's
user messages: messages lose what history needs to bring a prompt back
as typed - shell mode ('!' commands are stored as tool parts), paste
placeholders with their sources, and cleared drafts, which never
become messages. Entries written by older versions have no session and
are recalled only on the home screen and with the global scope.
Retention follows the scope. Global keeps the newest 50 entries, as
before. Session keeps the newest 50 of each of the 50 most recently
used sessions, so a busy session cannot push a quiet one's history
out. A trim rereads the file before rewriting it, so a TUI that has
been open for hours does not drop entries other TUIs appended.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: I'm aware v1 is now the maintenance branch and new features go to v2 only. This PR is here for others to use, and I'll submit the v2 version once I've migrated my whole plugin system to it.
Issue for this PR
Refs #52154
The v2 counterpart is #55261 by @asamarts, against
dev. This PR uses the same key and values (prompt.history_scope:"global"|"session"), so atui.jsonwritten for one works with the other.Type of change
What does this PR do?
up and down in the prompt walk one history file shared by every session and every OpenCode window on the machine, so a session recalls prompts written for unrelated work in another terminal.
prompt.history_scopein tui.json:"global"(default, today's behavior) or"session", where a session walks only the prompts submitted in it.prompt-history.jsonlentry records itssessionID. The first prompt sent from the home screen is recorded with the session it creates. Recall filters at read time (promptHistoryView), so switching the setting needs no migration.globalrecall them.!) entries, paste placeholders and cleared drafts come back exactly as before; that is why history stays in the file rather than being derived from the session's user messages, which lose all three.globalkeeps the newest 50 entries, as before.sessionkeeps the newest 50 of each of the 50 most recently used sessions, so a busy session cannot push a quiet one's history out.How did you verify your code works?
bun typecheckin packages/tui;bun test test/prompt test/config.test.tsxpass.history.test.tscovers both scopes' views and retention, the home-screen fallback and shell mode.session: session B recalls onlyecho beta-1; reopened session A recallsecho alpha-2, thenecho alpha-1, in shell mode, and nothing from B.global: session B recallsecho beta-1,echo alpha-2,echo alpha-1.Screenshots / recordings
Behavior-only change, no visual change.
Checklist
This PR is AI generated, but under direct supervision and on request of @Nowaker.