fix(platform): make failed status unconditionally terminal and remove dead code#603
Conversation
… dead code The SDK maps stream abort to 'failed' (not 'aborted') at the UIMessage level, which means several checks were dead code. More critically, when generation failed mid-tool-call, isUnfinishedToolTurn kept isLoading stuck forever because 'failed' was only terminal when the last part wasn't a tool part. - Make 'failed' bypass tool-turn check (fixes stuck loading on failure) - Remove dead 'aborted' status checks (SDK never surfaces this value) - Remove dead finishReason === 'cancelled' check (not a valid value) - Remove dead 'history.toast.titleEmpty' i18n key - Fix min-h mismatch between edit input and display span in sidebar
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (6)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughThis pull request refactors the chat loading state logic and message processing across multiple files. The core changes involve simplifying the loading determination by removing the Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
Greptile SummaryThis PR addresses review feedback from #599 by simplifying loading state management and removing dead code paths. The key insight is that the Convex Agent SDK maps stream abort to Key changes:
All changes are well-tested with comprehensive test coverage that verifies the new behavior, including a new test specifically for Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| services/platform/app/features/chat/hooks/use-chat-loading-state.ts | Simplified loading state logic by removing tool-turn awareness and making failed status unconditionally terminal |
| services/platform/app/features/chat/hooks/tests/use-chat-loading-state.test.ts | Updated tests to remove tool-turn awareness checks and added test for failed mid-tool-call clearing isPending |
| services/platform/app/features/chat/hooks/use-message-processing.ts | Removed aborted status check from streaming state cleanup logic |
| services/platform/convex/lib/agent_chat/internal_actions.ts | Removed unreachable early return for finishReason === 'cancelled' |
Last reviewed commit: ad2c63a
Summary
Addresses review feedback from @larryro on #599. The Convex Agent SDK maps stream abort to
failed(notaborted) at the UIMessage level viastatusFromStreamStatus(), andfinishReasonnever containscancelled(valid values: stop, length, content-filter, tool-calls, error, other, unknown).failedis now unconditionally terminal — when generation fails during a tool turn,isLoadingcorrectly resolves tofalseinstead of staying stuck foreverabortedstatus checks: SDK never surfacesabortedas a UIMessage status (maps tofailed), so these checks inuse-chat-loading-state.tsanduse-message-processing.tswere unreachablefinishReason === 'cancelled'check: Not a validvFinishReasonvalue in the SDK, so this early-return ininternal_actions.tswas unreachablehistory.toast.titleEmptyi18n key: No longer referenced anywhere after sidebar rename UX changesmin-hmismatch in sidebar: Edit input usedmin-h-[1.5rem](24px) while display span usedmin-h-[20px]— aligned both to1.5remTest plan
use-chat-loading-state.test.ts— replaced tool-turn-aware tests withfailedunconditionally terminal testsfailedmid-tool-call clearsisPending🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Style