fix(tui): prune expired approvals anywhere in the queue - #46
Merged
Merged
Conversation
The expiry sweep only scanned from the head. Under the current uniform 60s TTL that is equivalent to pruning every expired entry (deadlines are arrival-ordered), but once odek sends per-frame timeout_seconds a short-TTL request can expire mid-queue while the head is still alive — and would linger, answerable, on a request the engine had already failed. Prune any expired index instead, keeping deadline/queue alignment and the unstamped-never-expires defense. Teardown now keys on the head actually changing: a surviving head keeps its selection state (no input reset, no relayout) while head drops still mirror answer(). Two regression tests: mid-queue expiry with the head alive (selection preserved, one coalesced notice, sweep re-arms) and head+tail expired skipping the alive middle (input reset as the head changed).
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.
Summary
Follow-up to #45: the expiry sweep only scanned from the queue head. Under the current uniform 60s TTL that's equivalent to pruning every expired entry (deadlines are arrival-ordered), but once odek sends per-frame
timeout_seconds— whichclient.Eventalready decodes — a short-TTL request can expire mid-queue while the head is still alive. The head-first sweep would let it linger: answerable, countdown hidden at 0s, a dead request the engine had already failed.Changes
resetApprovalInput+relayoutnow fire only when the queue head actually changed: a surviving head keeps its selection/typing state through a mid-queue drop; head drops still mirroranswer()exactly.Test plan
TestApprovalExpiryMidQueuePreservesHead— head alive, mid-queue expired, tail alive → exactly the expired one is dropped, selection preserved, one notice, sweep re-armsTestApprovalExpiryMultiDropSkipsAliveMiddle— head + tail expired, middle alive → only the middle survives, input resets as the head changedgo test -race -count=1 ./...all packages ok; vet/lint 0 issues