generated from nhcarrigan/template
feat: add AskUserQuestion tool support (#60)
## Summary Implements support for Claude's `AskUserQuestion` tool, allowing Claude to ask the user questions with multiple choice options during a conversation. ## Changes - Add `UserQuestionEvent` and `QuestionOption` types (Rust and TypeScript) - Detect `AskUserQuestion` in permission denials and emit `claude:question` event - Create `UserQuestionModal` component with option selection and custom answer input - Use stop/reconnect approach (same as `PermissionModal`) since Claude API doesn't accept tool_result for permission-denied tools - Add `pendingQuestion` to conversation store and `hasQuestionPending` derived store ## Technical Notes We discovered that Claude Code's permission denial system doesn't allow sending tool results back directly - the API rejects them with "unexpected tool_use_id found in tool_result blocks". The solution was to use the same stop/reconnect pattern that permissions use: stop the session, reconnect with context, and include the user's answer in the context restoration message. ## Test Plan - [x] Build compiles without errors (Rust + TypeScript) - [x] Question modal appears when Claude uses `AskUserQuestion` - [x] Can select options and submit answer - [x] Answer is properly restored to Claude after reconnect Closes #51 --- ✨ This PR was created with help from Hikari~ 🌸 Co-authored-by: Hikari <hikari@nhcarrigan.com> Reviewed-on: #60
This commit was merged in pull request #60.
This commit is contained in:
@@ -21,6 +21,7 @@ export const claudeStore = {
|
||||
currentWorkingDirectory: conversationsStore.currentWorkingDirectory,
|
||||
terminalLines: conversationsStore.terminalLines,
|
||||
pendingPermission: conversationsStore.pendingPermission,
|
||||
pendingQuestion: conversationsStore.pendingQuestion,
|
||||
isProcessing: conversationsStore.isProcessing,
|
||||
grantedTools: conversationsStore.grantedTools,
|
||||
pendingRetryMessage: conversationsStore.pendingRetryMessage,
|
||||
@@ -49,6 +50,10 @@ export const claudeStore = {
|
||||
clearPermission: conversationsStore.clearPermission,
|
||||
requestPermissionForConversation: conversationsStore.requestPermissionForConversation,
|
||||
clearPermissionForConversation: conversationsStore.clearPermissionForConversation,
|
||||
requestQuestion: conversationsStore.requestQuestion,
|
||||
clearQuestion: conversationsStore.clearQuestion,
|
||||
requestQuestionForConversation: conversationsStore.requestQuestionForConversation,
|
||||
clearQuestionForConversation: conversationsStore.clearQuestionForConversation,
|
||||
grantTool: conversationsStore.grantTool,
|
||||
revokeAllTools: conversationsStore.revokeAllTools,
|
||||
isToolGranted: conversationsStore.isToolGranted,
|
||||
@@ -89,6 +94,11 @@ export const hasPermissionPending = derived(
|
||||
($conversation) => $conversation?.pendingPermission !== null
|
||||
);
|
||||
|
||||
export const hasQuestionPending = derived(
|
||||
claudeStore.activeConversation,
|
||||
($conversation) => $conversation?.pendingQuestion !== null
|
||||
);
|
||||
|
||||
// Derived store to check if Claude is currently processing (can be interrupted)
|
||||
export const isClaudeProcessing = derived(
|
||||
[claudeStore.connectionStatus, characterState],
|
||||
|
||||
Reference in New Issue
Block a user