Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Review Summary by QodoExpand widget local Convex wrapper hooks across all runtime modules
WalkthroughsDescription• Migrate all widget hooks and components to use custom Convex wrapper hooks • Replace direct convex/react imports with useWidgetQuery and useWidgetMutation • Replace makeFunctionReference calls with widgetQueryRef and widgetMutationRef • Harden adapter boundary by removing unsafe type casts and using proper Convex types • Expand test hardening guards to enforce wrapper usage across all widget runtime files Diagramflowchart LR
A["Direct convex/react imports"] -->|"Migrate to"| B["useWidgetQuery/Mutation hooks"]
C["makeFunctionReference calls"] -->|"Replace with"| D["widgetQueryRef/Mutation helpers"]
E["Unsafe type casts"] -->|"Harden to"| F["Typed Convex wrappers"]
G["Limited test coverage"] -->|"Expand to"| H["Comprehensive hardening guards"]
B --> I["Centralized adapter boundary"]
D --> I
F --> I
H --> I
File Changes1. apps/widget/src/lib/convex/hooks.ts
|
Code Review by Qodo
1.
|
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
There was a problem hiding this comment.
Pull request overview
This PR standardizes Convex usage in the widget by routing queries/mutations through a widget-local adapter (apps/widget/src/lib/convex/hooks.ts) and updating widget components/hooks to use those wrappers, with tests intended to enforce the boundary.
Changes:
- Replaced direct
convex/reacthook usage (useQuery,useMutation) withuseWidgetQuery/useWidgetMutationacross widget runtime modules. - Replaced
makeFunctionReferenceusage withwidgetQueryRef/widgetMutationRefin widget modules. - Expanded the ref hardening guard test to scan the widget source tree for unexpected direct Convex boundaries.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| openspec/changes/expand-widget-local-convex-wrapper-hooks/tasks.md | Marks migration/verification checklist items as completed. |
| apps/widget/src/lib/convex/hooks.ts | Refines the widget-local Convex adapter and improves typing to reduce unsafe casts. |
| apps/widget/src/test/refHardeningGuard.test.ts | Extends guardrails by scanning widget source for direct Convex boundaries and asserting an explicit allowlist. |
| apps/widget/src/tourOverlay/useTourOverlaySession.ts | Migrates tour overlay session mutation to useWidgetMutation and widgetMutationRef. |
| apps/widget/src/hooks/useWidgetTicketFlow.ts | Migrates ticket flow queries/mutations to widget-local Convex wrappers. |
| apps/widget/src/hooks/useWidgetShellValidation.ts | Migrates workspace/origin validation queries to widget-local wrappers. |
| apps/widget/src/hooks/useWidgetSettings.ts | Migrates messenger settings query to widget-local wrappers. |
| apps/widget/src/hooks/useWidgetSession.ts | Migrates session boot/refresh/heartbeat mutations to widget-local wrappers. |
| apps/widget/src/hooks/useWidgetConversationFlow.ts | Migrates conversation mutations to widget-local wrappers. |
| apps/widget/src/hooks/useNavigationTracking.ts | Migrates navigation tracking mutation to widget-local wrappers. |
| apps/widget/src/hooks/useEventTracking.ts | Migrates identify/track event mutations to widget-local wrappers. |
| apps/widget/src/components/Home.tsx | Migrates home/article queries to widget-local wrappers. |
| apps/widget/src/Widget.tsx | Migrates widget-level queries to widget-local wrappers. |
| apps/widget/src/TooltipAuthoringOverlay.tsx | Migrates tooltip authoring query/mutations to widget-local wrappers. |
| apps/widget/src/SurveyOverlay.tsx | Migrates survey mutations to widget-local wrappers. |
| apps/widget/src/OutboundOverlay.tsx | Migrates outbound overlay query/mutation to widget-local wrappers. |
| apps/widget/src/CsatPrompt.tsx | Migrates CSAT mutation to widget-local wrappers. |
| apps/widget/src/ChecklistOverlay.tsx | Migrates checklist query/mutations to widget-local wrappers. |
| apps/widget/src/AuthoringOverlay.tsx | Migrates authoring overlay query/mutations to widget-local wrappers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ]; | ||
|
|
||
| const DIRECT_CONVEX_IMPORT_PATTERN = /from "convex\/react"/; | ||
| const DIRECT_REF_FACTORY_PATTERN = /makeFunctionReference\(/; |
There was a problem hiding this comment.
DIRECT_REF_FACTORY_PATTERN is /makeFunctionReference\(/, which will not match the common typed usage makeFunctionReference<...>(...). As a result, findUnexpectedWidgetDirectConvexBoundaries() will miss direct makeFunctionReference calls and the guard can be bypassed unintentionally. Update the regex to also match optional generic parameters before the ( (or use a broader pattern that reliably detects the identifier).
| const DIRECT_REF_FACTORY_PATTERN = /makeFunctionReference\(/; | |
| const DIRECT_REF_FACTORY_PATTERN = /makeFunctionReference(?:\s*<[^>]*>)?\s*\(/; |
This pull request refactors how Convex queries and mutations are used throughout the widget application. The main goal is to replace direct usage of
convex/reactandconvex/serverhooks and helpers with custom hooks and references from./lib/convex/hooks, improving consistency and maintainability across the codebase.The most important changes are:
Adoption of Custom Convex Hooks and References
useQuery,useMutation, andmakeFunctionReferencefromconvex/reactandconvex/serverwith custom hooks (useWidgetQuery,useWidgetMutation) and reference creators (widgetQueryRef,widgetMutationRef) from./lib/convex/hooksin all overlay and widget components. [1] [2] [3] [4] [5] [6] [7]Component-Level Refactoring
Updated all query and mutation reference declarations in files such as
AuthoringOverlay.tsx,ChecklistOverlay.tsx,CsatPrompt.tsx,OutboundOverlay.tsx,SurveyOverlay.tsx,TooltipAuthoringOverlay.tsx, andWidget.tsxto use the newwidgetQueryRefandwidgetMutationRefhelpers. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]Updated all usages of query and mutation hooks within these components to use the new
useWidgetQueryanduseWidgetMutationhooks instead of the original Convex hooks. [1] [2] [3] [4] [5] [6]Code Consistency and Clean-up
convex/reactandconvex/serverin all affected files, ensuring only the new custom hooks and helpers are used. [1] [2] [3] [4] [5] [6] [7]This refactor centralizes and standardizes how Convex queries and mutations are handled in the widget, making the codebase easier to maintain and extend.