fix(audit-sprint-7b): toast consolidation onto sonner (resubmit, was #176) - #188
Conversation
Modal-audit agent found 4 hand-rolled toast implementations across the
codebase. This PR migrates 3 of them to the shared sonner Toaster
(Sprint 4c). The 4th (motion/InteractionFeedback.ToastItem) has no
external consumers and is left in place for separate cleanup.
Each migration preserves the component's call-site contract — only the
internals change. Visual unification is the win: same neutral default
surface across notifications, automation alerts, and compliance graph
events. Off-brand cyan/teal/violet badges go away (matches stored
"enterprise aesthetic" preference).
Migrated
- components/notifications/notification-toast.tsx (-60 LoC):
Realtime Supabase subscription stays (the actual job of the
component). Hand-rolled portal + queue + ToastItem render replaced
with toast.error / toast.warning. Click-to-route preserved via
sonner's action prop. Component now returns null; mount in
app/app/layout.tsx unchanged.
- components/automation/ComplianceToastAlerts.tsx (-140 LoC):
30-second polling against getAutomationHistory() stays. ToastItem
renderer + dismiss button + slide-in animation deleted. Critical
triggers (control_failed, risk_score_change) → toast.error;
others → toast.warning. Same returns-null pattern.
- components/compliance-system/compliance-toast.tsx (-150 LoC):
Trickier — this one has external consumers via the
useComplianceToast() hook in use-compliance-action.tsx. Preserves
the full public API (ComplianceToastData type, showToast,
dismissToast). Provider becomes a passthrough; internally
showToast maps to sonner's typed variants and builds a short
description from message/nodeType/nodeAction/impactArea/impactDelta.
No caller changes needed.
Out of scope
- components/motion/InteractionFeedback.tsx ToastItem export
(~30 lines of a 437-line utility module). Zero external consumers
of ToastItem found via grep — left in place. Can be a one-line
re-export removal later.
Built on top of fix/audit-sprint-4c-modal-primitives (PR #167) for the
shared Toaster.
Validation
- tsc -p tsconfig.typecheck.json: clean
- eslint: 0 errors, 18 warnings (baseline)
- jest: 5319/5334 pass (no test changes)
Test plan
- Send a critical notification → top-right red sonner toast with
title + body + View action that routes to data.href
- Trigger a control_failed automation → bottom-right red toast
- Call useComplianceToast().showToast({ type:'success', title:'x',
nodeType:'policy', nodeAction:'created' }) from a React component
→ green toast with description "policy created"
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThree toast-related components are refactored to remove local state management and rendering logic, delegating toast UI to a shared Sonner-based Toaster. The compliance-toast provider becomes an adapter; ComplianceToastAlerts shifts from rendering to polling and emitting; NotificationToast delegates from a local queue to direct toast API calls from its realtime subscription. ChangesToast System Consolidation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d38dd707ce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const [toasts, setToasts] = useState<ComplianceToastData[]>([]); | ||
| const idCounter = useRef(0); | ||
|
|
||
| export function ComplianceToastProvider({ |
There was a problem hiding this comment.
Restore ComplianceToast export to keep barrel imports valid
This refactor removes the ComplianceToast named export from compliance-toast.tsx, but the barrel file still re-exports it (components/compliance-system/index.ts exports ComplianceToast, ComplianceToastProvider, useComplianceToast). Re-exporting a missing binding breaks module linking/builds when consumers import @/components/compliance-system, so this change can fail app compilation/runtime import resolution until a compatibility export is restored or the barrel is updated in the same commit.
Useful? React with 👍 / 👎.
… by local tsc (#191) Every Vercel production deploy since #167 (modal primitives) errored because two re-exports referenced names that the audit sprints had deleted from their source files. Local `tsc -p tsconfig.typecheck.json` didn't catch them because its include list misses the barrel + default-export bundle below. What was broken 1. components/compliance-system/index.ts:47 re-exported `ComplianceToast` (the bespoke render component). Sprint 7b (PR #188) rewrote compliance-toast.tsx as a sonner shim and deleted that component — only ComplianceToastProvider and useComplianceToast remain. 2. components/motion/InteractionFeedback.tsx:386 default-export bundle still listed `ToastItem` as a shorthand property after Sprint 8b (PR #181) deleted the ToastItem function. Vercel error excerpt (from dpl_98NHQyUnwGo7CoSxKGTuWbfhoros): Type error: '"./compliance-toast"' has no exported member named 'ComplianceToast'. Did you mean 'useComplianceToast'? Fix - Drop ComplianceToast from the barrel re-export. No external importers — confirmed via grep. - Drop ToastItem from the default-export bundle. Same — zero importers of the default object reach for ToastItem. Validation - npm run build: green end-to-end (Compiled successfully → TypeScript pass → page tree generated, 0 errors) Why local tsc didn't catch this - tsconfig.typecheck.json's include list scopes type-checking to a subset of the tree. Sprint 4c-onwards needed full-app type coverage to catch downstream re-export drift. Out of scope here but worth tightening tsconfig.typecheck.json in a follow-up so Vercel doesn't have to be the integration test. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
♿ Accessibility Test ResultsTests Performed:
Artifacts: Download the accessibility reports from the "Artifacts" section for detailed results. |
Resubmit after base 4c branch deletion. Rebased onto main.
Summary by CodeRabbit