Fix GraphSection type error in build#487
Fix GraphSection type error in build#487ngoiyaeric wants to merge 3 commits intofeature/generative-graphs-ui-data-preview-17358342468692938721from
Conversation
…e<string> Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ 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 |
|
|
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
There was a problem hiding this comment.
- The prop type expansion is correct per context, but the current runtime narrowing (
isStatic) relies onany+ key probing, which can misclassifyStreamableValue<string>(or other opaque wrappers) as aDataAnalysisResult. - Consider replacing the probe with a stricter type guard to prevent wrapper-shape collisions and reduce reliance on
any.
Additional notes (1)
- Maintainability |
components/graph-section.tsx:35-35
isStaticuses(result as any)and then probes keys within. This is now even more brittle becauseresultcan beStreamableValue<string>(an object) and could accidentally satisfy the'title' in ...check depending on the streamable wrapper shape, causing the component to treat a stream wrapper as aDataAnalysisResult. That would be a correctness bug (misclassification) rather than just a typing issue.
Since this PR broadens the input types, it’s a good moment to make the narrowing more robust without relying on any.
Summary of changes
What changed
- Expanded
GraphSectionProps.resultto accept an additional type:StreamableValue<string>.- Before:
DataAnalysisResult | string | StreamableValue<DataAnalysisResult> - After:
DataAnalysisResult | string | StreamableValue<DataAnalysisResult> | StreamableValue<string>
- Before:
Why
- Aligns
GraphSection’s public prop typing with actual runtime usage during chat hydration, where tool outputs can be streamed as JSON strings (StreamableValue<string>), preventing a build failure inapp/actions.tsx.
1. Fix type error in `app/actions.tsx`: Expanded `GraphSectionProps` to support `StreamableValue<string>` for hydrated tool outputs. 2. Fix random refreshes in `components/chat.tsx`: Implemented `lastRefreshedMessageIdRef` to ensure `router.refresh()` is called exactly once per unique AI response, preventing infinite loops and unintended reloads. Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
1. Fix type error in `app/actions.tsx`: Expanded `GraphSectionProps` to support `StreamableValue<string>` for hydrated tool outputs. 2. Fix infinite/random refreshes in `components/chat.tsx`: - Implemented `lastRefreshedMessageIdRef` to ensure `router.refresh()` is called exactly once per AI response. - Removed nested `MapDataProvider` shadowing, which was resetting map state on every `Chat` re-render. 3. Fix map re-initialization in `components/map/mapbox-map.tsx`: Adjusted `useEffect` dependencies to prevent destroying and recreating the Mapbox instance during camera movements. Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
User description
The GraphSection component's result prop was too strictly typed to StreamableValue, causing a build failure in app/actions.tsx during chat hydration where tool outputs are passed as StreamableValue (JSON). This change expands the prop type to include StreamableValue, which the component already handles correctly in its internal logic.
PR created automatically by Jules for task 3486905341998850719 started by @ngoiyaeric
PR Type
Bug fix
Description
Expand GraphSection result prop type to accept StreamableValue
Resolves type mismatch when tool outputs passed as JSON strings
Maintains backward compatibility with existing DataAnalysisResult types
Diagram Walkthrough
File Walkthrough
graph-section.tsx
Add StreamableValue to result prop typecomponents/graph-section.tsx
resultprop type definition to includeStreamableValueStreamableValue