Repository navigation
fix(claude-tty): show the text Claude writes above a question before the question - #158
Merged
Merged
Conversation
…the question In Auto mode Claude Code keeps the whole assistant message out of the transcript until every PreToolUse hook has returned. The adapter raised the card for an `AskUserQuestion` from that hook and held it until somebody answered, so Paseo showed the question without the text that explains it, and the text arrived only after the answer. In the other modes Claude writes the message right away, which is why this only happened in Auto mode. PreToolUse now lets a question through without a card. Claude then raises a PermissionRequest for it in every mode, which already answered questions the same way as a fallback: it drains the transcript, raises the same card under the same id, and answers with the answers as `updatedInput`. Plan approval stays on PreToolUse. Measured against Claude Code 2.1.306 with a hook that sleeps for 25 seconds. In Auto mode the text and the question were written to the transcript when the hook returned, 25 seconds after they were made; with no hook, or in Default mode, they were written at once. With the question on PermissionRequest instead, the text was written before the hook fired in Default, Accept Edits, Plan, Bypass Permissions and Auto, on Haiku and Opus, and Claude took the hook's answers every time. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… asks it now The test raised its card from PreToolUse, which no longer opens one for a question. It now sends PreToolUse and then the PermissionRequest that carries the card, and reads the PermissionRequest's decision. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged
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.
What happened
In Auto mode, the text Claude writes just before an
AskUserQuestiondidn't show in Paseo until after the question was answered. The card showed the question alone, with nothing to explain it. Example: "Post the six drafted replies?" with the drafts it refers to missing until after you answer.Claude Code holds the whole assistant message back from the transcript until every PreToolUse hook has returned, but only in Auto mode. The adapter raised the question card from inside its PreToolUse hook and kept that hook open until someone answered. Its transcript drain before the card ran correctly, but the text wasn't in the file yet.
Measured against Claude Code 2.1.306, with a PreToolUse hook that sleeps 25 seconds and a prompt asking for three sentences followed by a question:
tool_usewere written 25 seconds after they were created, right when the hook returned.In a live session on the provider, the transcript still had nothing of the message four minutes after the card went up.
What this does
handlePreToolUselets anAskUserQuestionthrough with{}and raises no card. It still records the call, so the PermissionRequest that follows is matched to it.handlePermissionRequestalready handled questions as the fallback for a killed PreToolUse hook: it drains the transcript, raises the same card under the same<tool_use_id>-questionsid (the one the plugin files answers under), and answers with the answers asupdatedInput. That path is now the only one for questions.ExitPlanModestays on PreToolUse.Before relying on the PermissionRequest path, I checked it directly against Claude Code 2.1.306, with a PermissionRequest hook that waits and then answers. In Default, Accept Edits, Plan, Bypass Permissions and Auto, on Haiku and on Opus:
updatedInput.The Auto-mode classifier never refused a question. That refusal was the reason for answering from PreToolUse in d1a0c16, but there it followed a killed hook.
While the card is up, Claude now shows its own question dialog in the PTY instead of a "running PreToolUse hooks" spinner.
DialogWatcheralready ignores the screen whileinteractions.pendingis set, the same as for ordinary permission prompts.Tests
{}without asking anybody, and the PermissionRequest after it raises the card under the call's own id.delivers the assistant text before an interactive hook promptsnow writes the text after PreToolUse returns and before PermissionRequest, which is the order Claude uses in Auto mode.On this branch:
claude-tty-acp253 pass, 0 fail;claude-tty125 pass, 3 skipped (noPASEO_SERVER_DIST), 0 fail; typecheck clean.Verified live: an Auto-mode session on a dev install of this branch had the text in its timeline while the question card was open, and the answer given through
paseo permit allow --inputreached Claude.🤖 Generated with Claude Code