GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||
GeezerVison is showing github.com — fix(tui): restore the live draft after browsing prompt history by jlongster · Pull Request #63262 · anomalyco/opencode Conversation
| |||||||
| @@ -0,0 +1,240 @@ | |||
| import { TextareaRenderable } from "@opentui/core" | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This file is 240 lines, with a hand-rolled fetch mock and five long key-sequence scenarios, and none of them checks the headline case directly: draft → Up → Down restores the draft text and its mode. Could it be cut to that case plus one reset case (e.g. clearing a recalled entry)? The stash pop/list scenario and the paste-mutation scenario mostly repeat what the provider test in history-provider.test.tsx already covers, so they could be dropped.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Cut this from 240 lines to 50 and removed the fetch mock. Two tests remain: draft → Up → Down restores the text and shell mode, and clearing a recalled entry leaves the composer empty on Down. I dropped the stash and paste scenarios since the provider test covers the underlying reset and copy behavior. The round-trip test fails on base (Up leaves echo pen in the composer) and passes here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The trimmed file at e2cbe610 looks right. It has 50 lines, no fetch mock, history is seeded through prompt-history.jsonl, and both tests pass on the PR head. The remaining issue is that the round-trip test fails on base at the Up step, before it reaches the Down step where the reported bug happens. So it doesn't actually show that the fix restores the draft.
Why it fails at Up: on base, move() only lets Up through when the composer text matches store.history.at(store.index) (packages/tui/src/prompt/history.tsx:112-114). With index at 0, that is the oldest saved entry. A draft of echo pen with only previous saved fails that check, so Up does nothing. That's the "Up leaves echo pen in the composer" failure you saw. Pressing Up more times doesn't help (I tried up to 5). Your PR recording works on dev only because echo pen was already saved.
Fix: save echo pen as the oldest entry in shell mode. Base then lets Up through, and the test fails where the bug is:
- await Bun.write(file, JSON.stringify({ text: "previous", pasted: [] })) + await Bun.write( + file, + [ + JSON.stringify({ text: "echo pen", pasted: [], mode: "shell" }), + JSON.stringify({ text: "previous", pasted: [] }), + ].join("\n"), + )
With that change:
previous, then Down fails with Expected: "echo pen", Received: "". That is the blank prompt from the PR's before/after recording.The clearing test also fails at Up on base (Received: "unsent"). That's fine because it covers new reset behavior, not the original bug.
What I ran: throwaway worktrees of pr/head and pr/base (with the head test file copied in), running bun test on both test files:
I didn't change anything in repo/ (the shared checkout is still at 394f40dc, and the bun.lock change was already there). I removed the worktrees afterwards.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Seeded echo pen in normal mode as the oldest entry. On base (1002a979f9), Up now recalls previous, and the final Down leaves the composer empty: Expected: "echo pen", Received: "". On this branch, Down restores echo pen in Shell mode. Both tests pass.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Confirmed at b59efcd6. The round-trip test now fails on base at the step where the bug happens, and both tests pass on the branch.
1002a979f9, with the head test file copied in: Up recalls previous, then Down fails with Expected: "echo pen", Received: "". The clearing test also fails on base, at Up (Received: "unsent"). That's expected because it covers the new reset behaviour.Saving echo pen in normal mode is a better choice than shell mode. The Shell frame check can then only pass if the draft's mode is restored, because no saved entry was in Shell mode.
I ran these in temporary worktrees and removed them afterwards. Nothing in repo/ changed; the bun.lock change there was already present and I left it alone.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
User decisions: - Keep the draft text and mode round trip and one clear/reset case - Drop the stash and paste scenarios covered by the provider test
User decisions: - Seed history so Up succeeds on base and Down exposes the empty composer - Distinguish the saved entry from the shell draft by mode - Keep the composer suite at two tests
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The test point is addressed: history-composer.test.tsx is now a small file covering the headline case (draft text and Shell mode come back on the last Down) and one reset case. Both tests fail on base and pass here, consistently across three runs. Source is unchanged since my last review, so the earlier verification still holds. Public API is unchanged. Nothing new to raise.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Port of #63262. Each prompt keeps its own history cursor and saves the draft, with its mode, when Up leaves it; Down past the newest entry brings it back. Up from a typed prompt now recalls the newest entry. Submitting, clearing, stashing and setting the prompt reset the cursor.
Port of #63262. Each prompt keeps its own history cursor and saves the draft, with its mode, when Up leaves it; Down past the newest entry brings it back. Up from a typed prompt now recalls the newest entry. Submitting, clearing, stashing and setting the prompt reset the cursor.
Port of #63262. Each prompt keeps its own history cursor and saves the draft, with its mode, when Up leaves it; Down past the newest entry brings it back. Up from a typed prompt now recalls the newest entry. Submitting, clearing, stashing and setting the prompt reset the cursor.
Port of #63262. Each prompt keeps its own history cursor and saves the draft, with its mode, when Up leaves it; Down past the newest entry brings it back. Up from a typed prompt now recalls the newest entry. Submitting, clearing, stashing and setting the prompt reset the cursor.
Port of #63262. Each prompt keeps its own history cursor and saves the draft, with its mode, when Up leaves it; Down past the newest entry brings it back. Up from a typed prompt now recalls the newest entry. Submitting, clearing, stashing and setting the prompt reset the cursor.
Port of #63262. Each prompt keeps its own history cursor and saves the draft, with its mode, when Up leaves it; Down past the newest entry brings it back. Up from a typed prompt now recalls the newest entry. Submitting, clearing, stashing and setting the prompt reset the cursor.
Port of #63262. Each prompt keeps its own history cursor and saves the draft, with its mode, when Up leaves it; Down past the newest entry brings it back. Up from a typed prompt now recalls the newest entry. Submitting, clearing, stashing and setting the prompt reset the cursor.
Port of #63262. Each prompt keeps its own history cursor and saves the draft, with its mode, when Up leaves it; Down past the newest entry brings it back. Up from a typed prompt now recalls the newest entry. Submitting, clearing, stashing and setting the prompt reset the cursor.
Port of #63262. Each prompt keeps its own history cursor and saves the draft, with its mode, when Up leaves it; Down past the newest entry brings it back. Up from a typed prompt now recalls the newest entry. Submitting, clearing, stashing and setting the prompt reset the cursor.
Port of #63262. Each prompt keeps its own history cursor and saves the draft, with its mode, when Up leaves it; Down past the newest entry brings it back. Up from a typed prompt now recalls the newest entry. Submitting, clearing, stashing and setting the prompt reset the cursor.
Port of #63262. Each prompt keeps its own history cursor and saves the draft, with its mode, when Up leaves it; Down past the newest entry brings it back. Up from a typed prompt now recalls the newest entry. Submitting, clearing, stashing and setting the prompt reset the cursor.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.