Skip to content

fix/hisotry#458

Draft
phanen wants to merge 4 commits into
sudo-tee:mainfrom
phanen:fix/hisotry
Draft

fix/hisotry#458
phanen wants to merge 4 commits into
sudo-tee:mainfrom
phanen:fix/hisotry

Conversation

@phanen

@phanen phanen commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

history refactor split from #453

phanen added 4 commits July 8, 2026 11:57
Problem: /undo and the timeline picker undo action only sent the
revert request to the opencode server but left the input buffer empty,
so users had to retype the prompt to tweak it.

Solution: add `build_prompt_from_message` and
`refill_prompt_from_message` in `input_window.lua` to reconstruct prompt
lines from a message parts (text / file / agent) while skipping
synthetic text and non-input parts. `M.actions.undo` captures the full
message before reverting and, after the server acknowledges the
revert, refills the input buffer and parks the cursor at the end of
the text so the user can keep typing.
Problem: `opencode.history` kept a parallel file at
`stdpath("data")/opencode/history.txt` shared across every Neovim
instance. This made the prev/next arrow keys and the history picker
leak prompts across projects and sessions, contradicting how the
opencode TUI and App build prompt history from the current session
messages.

Solution: rewrite `history.lua` to read user messages from
`state.messages` for the active session, filter them by `sessionID`,
and reuse `input_window.build_prompt_from_message` so file and
agent mentions restore exactly as on the original send. The picker
drops its delete/clear actions (the server already owns the
messages) and falls back to a `session.get_messages` API call when
the SSE cache is empty. `prev_history` / `next_history` now restore
the user draft when navigating past the newest entry.
Problem: After dropping the local history.txt, history_picker and
timeline_picker rendered the same data through the same base_picker with
nearly identical format functions, only differing by title, time
display,
and the post-selection action.

Solution: Extend timeline_picker.pick(messages, opts) with a { title,
callback } shape so the caller picks what happens on selection. Move
workflow.select_history to feed the timeline picker and refill the input
in the callback, then delete history_picker along with its keymap, type,
doc snippet, and topology reference.
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.

1 participant