[bug] text typed during a turn is lost when the agent completes - #41
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.
0a965dd to
52c025e
Compare
|
Reviewed, validated, and amended on this branch. Issue #33 is valid, reproduced independentlyDrove the real console rather than taking the report on trust: The issue's own diagnosis of the location is also correct. The fix is soundThe claim it rests on holds. Verified every path that can leave a buffer behind:
So a non-empty buffer really does uniquely identify the carry-over, across the Two things amended1. 2. The mask guard was one-directional. The comment claimed it held "either In that direction the draft renders as dots and Enter would submit it as the Rebased, because the base could not validateThe branch was based on All three Force-push is the documented behavior for a dispatch branch, so the rebase is Nit, not addressed: a whitespace-only Enter during a turn hits neither the |
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.