Add AskUserQuestion tool support with interactive UI #97
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.
Summary
Implements full support for the AskUserQuestion tool, allowing Claude to ask users multiple-choice and multi-select questions during conversations with an interactive card-based UI.
Changes
🎯 Core Features
Data Models (
AskUserQuestionModels.swift)QuestionOption- Individual answer options with label and descriptionQuestion- Question structure with header, text, options, and multiSelect flagQuestionSet- Collection of questions with toolUseId for response matchingQuestionAnswer- User's responses with selected labels and optional "Other" textStream Processing (
StreamProcessor.swift)AskUserQuestiontool by name during stream processingQuestionSetand message for UI displayUI Components
QuestionCardView.swift - Individual question cards with:
AskUserQuestionView.swift - Main container with:
Answer Collection (
ChatViewModel.swift)submitQuestionAnswers()method formats answers as JSONTool Formatting (
AskUserQuestionFormatter.swift)ClaudeCodeToolenum with icon and metadataToolDisplayFormatter📝 Type Extensions
MessageTypeenum with.askUserQuestionMessageRoleenum with.askUserQuestionquestionSetproperty toChatMessage✅ Quality Assurance
Technical Implementation
UI Design
Integration Flow
AskUserQuestiontool useFiles Changed
New Files (4)
Sources/ClaudeCodeCore/Models/AskUserQuestionModels.swiftSources/ClaudeCodeCore/UI/ChatMessageView/QuestionCardView.swiftSources/ClaudeCodeCore/UI/ChatMessageView/AskUserQuestionView.swiftSources/ClaudeCodeCore/ToolFormatting/Formatters/AskUserQuestionFormatter.swiftModified Files (10)
Sources/ClaudeCodeCore/ViewModels/ChatMessage.swiftSources/ClaudeCodeCore/ViewModels/StreamProcessor.swiftSources/ClaudeCodeCore/ViewModels/MessageFactory.swiftSources/ClaudeCodeCore/ViewModels/ChatViewModel.swiftSources/ClaudeCodeCore/UI/ChatMessageView/MessageContentView.swiftSources/ClaudeCodeCore/UI/ChatMessageView/MessageTextFormatterView.swiftSources/ClaudeCodeCore/UI/ChatMessageView/ChatMessageView.swiftSources/ClaudeCodeCore/UI/ChatMessageRow.swiftSources/ClaudeCodeCore/ToolFormatting/ToolType.swiftSources/ClaudeCodeCore/ToolFormatting/ToolDisplayFormatter.swiftTesting
Ready for testing! The feature can be tested by having Claude use the
AskUserQuestiontool in a conversation.Screenshots
(UI screenshots can be added after testing)
🤖 Generated with Claude Code