Implement retry button on failed LLM prompt#166
Conversation
📝 WalkthroughWalkthroughThis PR adds error recovery functionality by introducing a retry mechanism for failed LLM prompts. When the LLM session enters an error state, users can now dismiss the error and retry the last prompt, which removes incomplete context and regenerates the assistant response. ChangesError Recovery with Retry Capability
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
LLMonFHIR/FHIRInterpretation/UserStudy/UserStudyChatView.swift (1)
141-163: 💤 Low valueMove
viewStateAlert(state:onRetry:)to a dedicated utility file.The extension targets the module-level
Viewprotocol but lives inside a view-specific file. Placing it in its own file (e.g.,View+ViewStateAlert.swift) improves discoverability and makes the intent clear — especially since the existing SpeziViewsviewStateAlert(state:)is the peer being extended.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@LLMonFHIR/FHIRInterpretation/UserStudy/UserStudyChatView.swift` around lines 141 - 163, Move the extension View containing viewStateAlert(state:onRetry:) out of UserStudyChatView.swift into its own file (e.g., View+ViewStateAlert.swift); ensure the new file imports SwiftUI, declares the same extension View and the viewStateAlert(state: Binding<ViewState>, onRetry: `@escaping` () -> Void) method unchanged, and keep the same access level so callers still resolve, then remove the original extension from UserStudyChatView.swift to avoid duplicate symbols and improve discoverability relative to the existing SpeziViews viewStateAlert(state:).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@LLMonFHIR/FHIRInterpretation/UserStudy/UserStudyChatView.swift`:
- Around line 141-163: Move the extension View containing
viewStateAlert(state:onRetry:) out of UserStudyChatView.swift into its own file
(e.g., View+ViewStateAlert.swift); ensure the new file imports SwiftUI, declares
the same extension View and the viewStateAlert(state: Binding<ViewState>,
onRetry: `@escaping` () -> Void) method unchanged, and keep the same access level
so callers still resolve, then remove the original extension from
UserStudyChatView.swift to avoid duplicate symbols and improve discoverability
relative to the existing SpeziViews viewStateAlert(state:).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c1af981c-680d-44b1-a274-e9fcf26cfdc2
📒 Files selected for processing (3)
LLMonFHIR/FHIRInterpretation/UserStudy/UserStudyChatView.swiftLLMonFHIR/FHIRInterpretation/UserStudy/UserStudyChatViewModel.swiftLLMonFHIR/Resources/Localizable.xcstrings
Implement retry button on failed LLM prompt
♻️ Current situation & Problem
Issue #114
When an LLM prompt fails (e.g. due to a network error or timeout), the user has no way to retry without restarting their session or re-navigating to the chat.
⚙️ Release Notes
📚 Documentation
retryLastPrompt()is documented inline with a doc comment explaining the context-cleanup behavior before re-triggering generationviewStateAlert(state:onRetry:)View extension replaces the default.viewStateAlertmodifier inUserStudyChatViewto support the retry callbackLocalizable.xcstrings✅ Testing
The UI retry flow was manually verified:
.ready, and re-triggersgenerateAssistantResponse()Code of Conduct & Contributing Guidelines
By creating and submitting this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: