Answered chat approval reappears as a ghost card in the background-approval deck
Summary
After a chat approval card is answered, the same approval can reappear as a second card in the background-approval deck above the composer. Clicking that card fails with no pending approval found for request_id '…' (already decided or expired) and "Could not record your decision".
Reproduction
- In a chat, trigger a tool that needs approval (e.g.
GOOGLECALENDAR_CREATE_EVENTwith it removed from the always-allow list). - Leave the chat card up long enough for the background poll (
approval_list_pending, every 15 s) to run — a page reload triggers one immediately. - Deny (or approve) on the chat card.
- A second "Approval needed" card for the same request appears above the composer. Deciding it fails with "already decided".
Observed 2026-09-30 on main: decision recorded at 14:45:58, three failing approval_decide calls on the ghost card at 14:46:00–02 ([rpc:approval_decide] no pending approval found (already decided/expired — benign race)).
Cause
useUnroutedApprovals shows every polled pending row that is not currently in chatRuntime.pendingApprovalByThread. Deciding from a chat card clears that entry immediately (clearPendingApprovalForThread), but the polled rows keep the park until the next poll, so for up to 15 s the answered park matches the "unrouted" filter and is rendered again.
Expected
A park that a chat card has shown is never treated as unrouted; the deck only shows parks with no chat thread and no flow.
Source: tinyhumansai/openhuman