Skip to content

fix(tui): prune expired approvals anywhere in the queue - #46

Merged
jkyberneees merged 1 commit into
mainfrom
fix/approval-expiry-anywhere
Aug 30, 2026
Merged

jkyberneees merged 1 commit into
mainfrom
fix/approval-expiry-anywhere

Conversation

@jkyberneees

Copy link
Copy Markdown
Contributor

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 — which client.Event already 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

  • Any-position prune — the sweep now filters every expired index, keeping the deadline queue in lockstep and the unstamped-never-expires defense intact.
  • Head-change-gated teardown — resetApprovalInput + relayout now fire only when the queue head actually changed: a surviving head keeps its selection/typing state through a mid-queue drop; head drops still mirror answer() exactly.
  • Status/coalesced-notice/plain-line behavior unchanged.

Test plan

  • 2 new regression tests (RED-first, both failing against the head-only sweep):
    • TestApprovalExpiryMidQueuePreservesHead — head alive, mid-queue expired, tail alive → exactly the expired one is dropped, selection preserved, one notice, sweep re-arms
    • TestApprovalExpiryMultiDropSkipsAliveMiddle — head + tail expired, middle alive → only the middle survives, input resets as the head changed
  • Full existing expiry suite still green; go test -race -count=1 ./... all packages ok; vet/lint 0 issues

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).
@jkyberneees
jkyberneees merged commit 1fba98f into main Aug 30, 2026
7 checks passed
@jkyberneees
jkyberneees deleted the fix/approval-expiry-anywhere branch August 30, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant