-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(wren-ui): show text based answer preview data error #1903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe preview rendering logic in TextBasedAnswer.tsx was adjusted. A hasPreviewData boolean is introduced. The preview container and PreviewData component are now always rendered, with the “context window” note shown only when hasPreviewData is true. No exported signatures or mutations were changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant T as TextBasedAnswer
participant D as previewDataResult
participant P as PreviewData
U->>T: Render component
T->>D: Access data?.previewData
D-->>T: previewData (maybe undefined)
T->>T: hasPreviewData = Boolean(previewData)
T->>P: Render PreviewData with previewData (possibly undefined)
alt hasPreviewData
T->>U: Show "context window limit" note
else
T->>U: Hide note
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
wren-ui/src/components/pages/home/promptThread/TextBasedAnswer.tsx (3)
119-119: Clarify “hasPreviewData” semantics (object vs. non-empty rows).If “preview data exists” is meant to indicate non-empty rows, consider checking row count instead of truthiness of the container object.
- const hasPreviewData = !!previewDataResult.data?.previewData; + const hasPreviewData = + (previewDataResult.data?.previewData?.data?.length ?? 0) > 0;If the current behavior (showing the note when a previewData object exists, even with 0 rows) is intended, ignore this.
254-257: Avoid a brief “flash of empty” by treating the initial not-yet-called state as loading.Before the mutation is called, loading is false and previewData is undefined, which can momentarily render an empty preview area. Consider leveraging Apollo’s called flag to keep the preview in a loading state until the first request is issued.
- <PreviewData - error={previewDataResult.error} - loading={previewDataResult.loading} - previewData={previewDataResult?.data?.previewData} - /> + <PreviewData + error={previewDataResult.error} + loading={previewDataResult.loading || !previewDataResult.called} + previewData={previewDataResult?.data?.previewData} + />Please confirm that usePreviewDataMutation’s result exposes called in your codegen setup (it typically does for Apollo useMutation).
246-246: Minor a11y: Mark the preview region as busy while loading.Helps assistive tech understand that content is being fetched/updated.
- <div className="mt-2 mb-3" data-guideid="text-answer-preview-data"> + <div + className="mt-2 mb-3" + data-guideid="text-answer-preview-data" + aria-busy={previewDataResult.loading} + >
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
wren-ui/src/components/pages/home/promptThread/TextBasedAnswer.tsx(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
wren-ui/src/components/pages/home/promptThread/TextBasedAnswer.tsx (1)
wren-ui/src/components/dataPreview/PreviewData.tsx (1)
PreviewData(89-121)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
wren-ui/src/components/pages/home/promptThread/TextBasedAnswer.tsx (1)
246-258: LGTM: Always rendering the container and PreviewData fixes the visibility/layout regression.This aligns with the PR objective: the preview area is now stable, and the explanatory text is shown only when data is present via hasPreviewData.
fredalai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
This PR addresses a text answer preview issue where the preview data section was not properly displayed when data was available. The fix ensures that the preview data section is always rendered, but the explanatory text is conditionally shown based on whether preview data exists.
Implementation
The implementation follows a conditional rendering approach where:
PreviewDatacomponent are always rendered to maintain consistent layouthasPreviewDatais truehasPreviewDatavariable to avoid repeated property access and improve readabilityActual Changes
Text Answer Preview Enhancement
TextBasedAnswer.tsxto always render the preview data sectionhasPreviewDatavariable for cleaner conditional logicSummary by CodeRabbit
Bug Fixes
Refactor