Repository navigation
Description
Summary
With several sessions waiting at once, answering the question/permission card in the notch sometimes delivers the answer to a different session than the one the card was showing. I hit this with two Claude Code sessions running in sibling directories (gitops-ansible and liverpool-cleanup): the card showed one project, I picked an option (and typed custom text), and the other session received the answer.
It is intermittent and I have not found a deterministic repro, but the code has a structural race that explains it.
Root cause (as far as I can tell)
The card's identity and the card's answer target come from two different places, and nothing ties them together:
NotchPanelViewrenderscase .questionCard(let sid)— the project name / cwd / mascot shown to the user come fromappState.sessions[sid].- The question text and options come from
appState.pendingQuestion, i.e.questionQueue.first. AppState.answerQuestion(_:)/answerQuestionMulti(_:)/skipQuestion()(and likewiseapprovePermission/denyPermissiononpermissionQueue) do an unconditionalqueue.removeFirst()and resume that continuation.
So the surface's sid is never compared against the head of the queue at the moment of submission. Any mutation of the queue head between "card rendered" and "user clicks" silently re-targets the answer. Ways the head can change while the card is up:
handlePeerDisconnect(sessionId:)→drainQuestions/drainPermissions(forSession:)removes the head entry when that session's socket drops (e.g. the user answered in the terminal, or the CLI exited).showNextPending()then only re-pointssurfaceifshouldAutoOpenQuestionSurface/shouldAutoOpenPendingSurfaceallows it — Smart Suppress can decline, leaving the stale.questionCard(sid)on screen with a new head behind it.showNextPending()reorderspermissionQueue(remove(at: idx)+insert(at: 0)), and the tool-use cache path removes entries by index.- A multi-question
AskUserQuestionwizard collects answers over several seconds of user interaction; the queue head can be drained mid-wizard, after whichanswerQuestionMultiposts the collected answers to whatever is now first.
The mismatch is not just "wrong recipient" — for AskUserQuestion the response is built as updatedInput from pending.event.toolInput, so answers can be zipped onto a different question's option list by position.
Suggested fix
Make the answer target explicit rather than positional. Two pieces:
- Carry an identity into the surface —
.questionCard(requestId:)/.approvalCard(requestId:)(or at minimum passsid+ the request'stoolUseId) — and haveanswerQuestion/approvePermission/denyPermission/skipQuestiontake that id, look it up in the queue, and resume that entry instead ofremoveFirst(). - If the id is no longer in the queue (drained, disconnected, answered in terminal), drop the answer and re-render rather than falling through to the head. A visible "this prompt is no longer waiting" beats a silent misroute.
A cheaper stopgap that would catch most of it: in the answer path, guard pending.event.sessionId == surfaceSessionId else { return }.
Environment
- CodeIsland 1.0.31, macOS 15.x (Darwin 25.5.0), Apple Silicon
- Agent: Claude Code (2 concurrent sessions, separate terminal tabs, sibling repos)
- Code references verified against
main@ 9e3a1eb (v1.0.31) — the unconditionalremoveFirst()is still present there. - Searched open/closed issues and open PRs; I did not find a duplicate. 修复(OMP):终端原生 Ask 与 CodeIsland 并行回答 #264 touches the adjacent "terminal answered it first" path (OMP-specific, still open) but does not address which queue entry the card resolves.
Activity
fix: address QA round 1
fix: address QA findings on the merged wxtsky#308 + wxtsky#309 pair
fix(panel): per-session card gate, and don't un-dismiss on a replay
chore(scout): upstream scout August 13, 2026 — T-083 answer routing b…
fix(panel): don't let a dismissed approval silence later requests (#309…
fix(panel): route answers to the card's session, not the queue head (#…
wxtsky commentedon Aug 15, 2026
Merged as 5b4d9f7 on
main. Answers now resolve the queued request belonging to the card's session instead ofqueue.removeFirst(), and the cards renderpendingPermission(forSession:)/pendingQuestion(forSession:)so display and resolution can't disagree. The three review rounds on your fork were worth it — thanks for pinning each guard by mutating the production path it names.feat(question-card): click the session row to focus the asking termin…
fix(companion): route iPhone approvals and answers to the session the…
fix(shortcuts): act only on the card on screen; open a hidden one ins…
fix(shortcuts): a shortcut brings the island to the user before it acts