fix/hisotry#458
Draft
phanen wants to merge 4 commits into
Draft
Conversation
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.
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.
history refactor split from #453