fix(policies): restore AI-tailoring UI on the Policies page (ENG-108)#2584
Merged
fix(policies): restore AI-tailoring UI on the Policies page (ENG-108)#2584
Conversation
…108) The legacy PoliciesTable + PolicyFilters wiring was removed when we migrated to PoliciesTableDS in Jan 2026 (commit 8974418). Since then the page wrapped <PolicyFilters> in PolicyTailoringProvider with an empty statuses map, so the per-row "Tailoring/Queued/Preparing" UI that PoliciesTableDS already renders had no data to show. Vendors and Risks were restored at the time; Policies was left missing. Wires it back up without touching the trigger.dev pipeline (which still emits policiesTotal/policiesCompleted/policy_<id>_status as before): 1. policies/(overview)/hooks/use-policy-onboarding-status.ts — new hook mirroring the risks/vendors ones, using useRealtimeRun. Handles the policies/policy singular/plural conversion correctly (the shared hook's `itemType.slice(0,-1)` would have produced "policie_"). 2. policies/(overview)/page.tsx — fetch /v1/organization/onboarding alongside /v1/policies (same pattern as risks/vendors) and pass the trigger run id into PolicyFilters. Move PolicyTailoringProvider into PolicyFilters since that's where the realtime data lives. 3. PolicyFilters.tsx — accept onboardingRunId, subscribe via the hook, wrap children in PolicyTailoringProvider with live statuses, render the "Tailoring your policies – Personalized N/M" banner while the run is active. Orphaned apps/app/.../policies/all/components/policies-table.tsx (the pre-migration table, now dead code) is left in place for a follow-up cleanup PR so this diff stays scoped. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
cubic analysis
No issues found across 3 files
Auto-approved: Restores lost AI-tailoring UI elements on the Policies page using existing patterns. Frontend-only change with no impact on core logic or data.
Linked issue analysis
Linked issue: ENG-108: The UI for indicating AI is working on Policies/Vendors/Risks is gone
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Show "Tailoring your policies — Personalized X/Y policies" banner during active onboarding | Banner JSX added and shows progress.completed/progress.total |
| ✅ | Restore per-row tailoring status badges (Tailoring/Queued/Preparing) in Policies table rows | PoliciesTableDS wrapped with PolicyTailoringProvider supplying statuses |
| ✅ | Fetch onboarding triggerJobId on the Policies page and pass it to client component | page.tsx fetches /v1/organization/onboarding and passes triggerJobId |
| ✅ | Subscribe to realtime trigger.dev run and derive per-policy statuses (useRealtimeRun) | New usePolicyOnboardingStatus hook uses useRealtimeRun and derives statuses |
| ✅ | Ensure page renders unchanged for orgs without an active onboarding run (no banner/state) | onboardingRunId null prevents subscription; showTailoringBanner false |
| ❌ | Restore equivalent AI-tailoring UI for Vendors and Risks as well (Policies/Vendors/Risks) | No diffs touching vendors/risks pages or hooks |
Contributor
|
🎉 This PR is included in version 3.23.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes ENG-108 — during first-run onboarding, the "AI is tailoring your policies" banner and per-row tailoring status disappeared from the Policies page. Vendors and Risks already got their equivalent restored; Policies was the last holdout.
Root cause
Commit
8974418c6(Jan 2026 design-system migration) replaced the oldPoliciesTablewithPoliciesTableDS. The new flow wraps<PolicyFilters>in<PolicyTailoringProvider statuses={{}}>with an empty map, soPoliciesTableDS's existing per-row "Tailoring/Queued/Preparing" rendering had no data to show. The page also never fetched the onboardingtriggerJobId, so there was nothing to subscribe to.Fix
No trigger.dev pipeline changes — the backend still emits
policiesTotal/policiesCompleted/policy_<id>_statusexactly as before. Only the frontend wiring:New hook:
apps/app/.../policies/(overview)/hooks/use-policy-onboarding-status.ts— mirrors the existing risks/vendorsuseOnboardingStatusbut handles the singular/plural correctly (the shared hook'sitemType.slice(0, -1)would have producedpolicie_, notpolicy_).policies/(overview)/page.tsx: fetch/v1/organization/onboardingalongside/v1/policiesand pass thetriggerJobIdintoPolicyFilters. MovedPolicyTailoringProviderout of the server component (where it had empty statuses) intoPolicyFilters(client) where the realtime data lives.PolicyFilters.tsx: acceptonboardingRunId, subscribe via the new hook, wrap children inPolicyTailoringProviderwith live statuses, render the "Tailoring your policies — Personalized N/M" banner while the run is active.Scope
apps/app/.../policies/all/components/policies-table.tsx(pre-migration legacy table, imported by nothing) is left in place to keep this PR focused; it's a follow-up cleanup candidate.Test plan
PoliciesTableDSrendering)🤖 Generated with Claude Code
Summary by cubic
Restores the “Tailoring your policies” banner and per-row tailoring badges on the Policies page during onboarding, addressing ENG-108. The page now streams onboarding progress so users see real-time status until completion.
usePolicyOnboardingStatususing@trigger.dev/react-hooksto exposepoliciesTotal,policiesCompleted, andpolicy_<id>_status.policies/(overview)/page.tsxto fetch/v1/organization/onboardingand passonboardingRunIdtoPolicyFilters.PolicyTailoringProviderintoPolicyFilters; added a progress banner;PoliciesTableDSnow shows live per-row statuses.Written for commit 6d2434c. Summary will update on new commits.