feat(ui): add tabbed navigation to AskUserQuestion for multi-question flows#125
feat(ui): add tabbed navigation to AskUserQuestion for multi-question flows#125Miista wants to merge 4 commits intohappier-dev:devfrom
Conversation
… flows When multiple questions are present, renders a tab bar with checkmark indicators instead of stacking all questions vertically.
WalkthroughRefactors AskUserQuestionView to support multiple questions via a tabbed UI, adds activeTab state with clamped synchronization, introduces renderQuestionContent and isQuestionAnswered helpers, adds early-return for empty questions, and updates UI imports/styles for tab rendering. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR replaces the vertical-stack layout in
Confidence Score: 3/5
|
| Filename | Overview |
|---|---|
| apps/ui/sources/components/tools/renderers/workflow/AskUserQuestionView.tsx | Adds tabbed navigation for multi-question flows; introduces a Rules-of-Hooks violation (new isQuestionAnswered useCallback placed after a conditional early return), a potential activeTab out-of-bounds crash when questions shrinks between renders, and a non-scrolling tab bar that will overflow with many questions. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[AskUserQuestionView renders] --> B{questions\nempty/missing?}
B -- yes --> C[return null]
B -- no --> D{tool.state === completed\nor isSubmitted?}
D -- yes --> E[Render submitted summary\nfor all questions]
D -- no --> F{showTabs?\nquestions.length > 1}
F -- no single question --> G[renderQuestionContent\nquestions 0 , index 0]
F -- yes multiple questions --> H[Render tab bar\none tab per question\nwith checkmark if answered]
H --> I[renderQuestionContent\nquestions activeTab , activeTab]
G --> J[Render submit button\nif canInteract]
I --> J
J --> K{allQuestionsAnswered?}
K -- yes --> L[Submit button enabled]
K -- no --> M[Submit button disabled]
L --> N[handleSubmit\ncaptures selections + freeform\ncalls sessionAllowWithAnswers\nor sessionDeny + sendMessage]
Last reviewed commit: 5c4b745
apps/ui/sources/components/tools/renderers/workflow/AskUserQuestionView.tsx
Show resolved
Hide resolved
apps/ui/sources/components/tools/renderers/workflow/AskUserQuestionView.tsx
Outdated
Show resolved
Hide resolved
apps/ui/sources/components/tools/renderers/workflow/AskUserQuestionView.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/ui/sources/components/tools/renderers/workflow/AskUserQuestionView.tsx`:
- Around line 507-533: The tab row currently rendered when showTabs is true (the
View with style styles.tabBar containing questions.map and TouchableOpacity
tabs) can overflow; wrap that list in a horizontal ScrollView
(horizontal={true}, optionally showsHorizontalScrollIndicator={false}) so tabs
become scrollable on small viewports, ensuring the children (the mapped
TouchableOpacity elements and Ionicons) remain unchanged; keep styles.tabBar as
a row container or adjust to allow horizontal scrolling as needed.
- Around line 275-284: Normalize the questions variable before any hooks and
move the early return until after all hooks: replace direct use of
input?.questions with a local normalized const questions = input?.questions ??
[]; ensure useUnistyles() and all useState/useEffect hooks (and the useCallback
isQuestionAnswered which references selections and freeformAnswers) are declared
unconditionally, then perform the early return that returns null if the original
input/questions are absent; this preserves hook call order and keeps
isQuestionAnswered, selections, and freeformAnswers intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 19d92a63-bfaa-4462-ad72-13b055886099
📒 Files selected for processing (1)
apps/ui/sources/components/tools/renderers/workflow/AskUserQuestionView.tsx
apps/ui/sources/components/tools/renderers/workflow/AskUserQuestionView.tsx
Show resolved
Hide resolved
apps/ui/sources/components/tools/renderers/workflow/AskUserQuestionView.tsx
Outdated
Show resolved
Hide resolved
Normalize questions array before hooks to prevent Rules of Hooks violation when the component re-renders with different question counts.
If the questions array shrinks while activeTab points beyond its length, the component would crash. Clamp to valid range and sync state via effect.
With 5+ questions on smaller screens, tabs would compress or overflow. Wrapping in a horizontal ScrollView keeps all tabs accessible.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/ui/sources/components/tools/renderers/workflow/AskUserQuestionView.tsx`:
- Around line 439-455: Replace the direct react-native TextInput with the app's
shared TextInput component to ensure proper font scaling: in
AskUserQuestionView.tsx swap the JSX element currently using TextInput (the
freeform input bound to freeformAnswers and qIndex) to use the imported
component from "@/components/ui/text/TextInput" and keep all existing props
(style, value, onChangeText, placeholder, placeholderTextColor, editable,
autoCapitalize, autoCorrect) and behavior (checking canInteract and
setFreeformAnswers) intact; also add or update the import for TextInput from
"@/components/ui/text/TextInput" and remove any unused react-native TextInput
import.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: faf66172-f0a3-4d39-a5d5-04b632dfd396
📒 Files selected for processing (1)
apps/ui/sources/components/tools/renderers/workflow/AskUserQuestionView.tsx
When multiple questions are present, renders a tab bar with checkmark indicators instead of stacking all questions vertically.
Summary
Adds tabbed navigation to the AskUserQuestionView component when multiple questions are present, replacing the previous vertical stacking layout.
Why
When an AskUserQuestion tool call contains multiple questions, stacking them all vertically makes the UI long and hard to navigate. Tabs provide a cleaner, more focused experience; users see one question at a time with clear progress indicators (checkmark icons) showing which questions they've already answered.
How to test
Screenshots / recording (UI changes)
Question 1:

Question 2:

Question 3 answered:

All questions answered and response sent:

Notes (optional)
yarn webChecklist
dev(notmain)Summary by CodeRabbit