fix(chat-input): dismiss open question prompt when sending a message (#1740)

Sending a message while a question prompt was open left the prompt
lingering, blocked the send, or collided with the still-blocked agent
turn. Two root causes:

useSessionActivity treated pending permissions as idle but not pending
questions, so the send button became Stop during a question and Enter
queued/collided instead of sending. handleSubmit also never dismissed
the open question, stranding the session in a half-answered state.

The send path now dismisses open questions for the session subtree
(optimistic local clear so the card vanishes instantly, plus a formal
question.reject) and queues the message. The queued-message auto-send
hook then delivers it as the next turn once the rejected turn winds
down and the session returns to idle. Queueing avoids aborting the
turn, which surfaced an unwanted "running turn was stopped" notice.

Regression tests cover the no-op, subtree dismissal (root + subagent
child), and QuestionNotFoundError paths.
This commit is contained in:
Tom Rochette
2026-06-25 10:55:35 +03:00
committed by GitHub
parent 4a068fca86
commit 9a2012c94e
4 changed files with 188 additions and 5 deletions
@@ -1781,6 +1781,23 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ onOpenSettings, scrollTo
return;
}
// Sending is authoritative: if a question prompt is open, dismiss it
// so the prompt cannot linger or strand the session. The dismiss clears
// the card instantly (optimistic) and formally rejects the question.
// Rejecting unblocks the agent's tool but does NOT end its turn, so a
// direct send would race with the still-active run and be silently
// discarded by the OpenCode runner. Instead we queue the message; the
// queued-message auto-send hook delivers it as the next turn once the
// rejected turn winds down and the session returns to idle. This avoids
// aborting the turn (which would surface an "aborted" notice).
if (currentSessionId && !queuedOnly) {
const dismissedQuestions = await sessionActions.dismissOpenQuestionsForSession(currentSessionId);
if (dismissedQuestions) {
handleQueueMessage();
return;
}
}
// Build the primary message (first part) and additional parts
let primaryText = '';
let primaryAttachments: AttachedFile[] = [];