[bug] text typed during a turn is lost when the agent completes#41
Open
sesh-dispatch[bot] wants to merge 2 commits into
Open
[bug] text typed during a turn is lost when the agent completes#41sesh-dispatch[bot] wants to merge 2 commits into
sesh-dispatch[bot] wants to merge 2 commits into
Conversation
A steering message typed while the agent worked was discarded when the turn completed. beginInput unconditionally zeroed the editor buffer when the between-turns prompt re-opened the editor, destroying a draft that survived the turn in the live editor's buffer. Carry an existing non-empty buffer (with its cursor, snippets, and images) into the next prompt. Submit, steer, and /stop all clear the buffer before returning, so a non-empty buffer here uniquely identifies the carry-over. A masked (secret) buffer never carries, keyed on the prior mask so it holds in both directions.
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.
Closes #33
Problem
Text typed into the message bar while the agent was working was discarded when the turn completed. The live editor kept the draft in its buffer through the turn (the
errTurnOverreturn path does not clear it), but the between-turns prompt re-opened the editor throughbeginInput, which unconditionally zeroed the buffer, throwing away whatever the user had been mid-typing.Changes
harness/tui.go,beginInput: when re-opening the editor, carry an existing non-empty buffer (and its cursor position, snippets, and images) into the next prompt instead of zeroing it. The submit, steer, and/stoppaths all clear the buffer before they return, so a non-empty buffer here uniquely identifies the carry-over from a turn that ended mid-draft. A buffer left masked (a secret prompt) never carries, so a secret cannot leak into an ordinary prompt; the guard keys on the prior mask rather than the new one so that holds in both directions.How to test
Reproduce the original bug and the fix headless through the editor:
TestBeginInputPreservesDraftAcrossTurnEndtypes a steering draft during a turn, ends the turn, then confirms the next prompt returns the carried draft. Without the fix (revertbeginInputtot.buf = nilunconditionally) it fails withline = "".TestBeginInputDropsMaskedDraftForOrdinaryPromptseeds a masked, non-empty buffer and confirms an ordinary prompt clears it. Drop the!t.maskguard and it fails withbuf = "hush".Verification
go build ./... && go vet ./... && go test ./...pass.