chore(cost-insights): remove frontend pages, components, and tRPC routers - #4993
Conversation
…ters First step of the Cost Insights shutdown. This removes every user-facing surface and the API it depended on. Follow-ups stop writing to the cost_insight_* tables and then drop the tables. Removed: - personal and organization route trees, including the release-toggle and admin layout gates - apps/web/src/components/cost-insights/ and its Storybook stories - costInsights and organizations.costInsights tRPC routers (19 procedures) and their registrations - router-only server lib: presenter, tracking, posthog-tracking - Cost Insights sidebar entries plus the now-dead formatReviewItemBadge helpers and orphaned query wiring - dev/seed/cost-insights, which only existed to populate the deleted UI Spend Alert emails deep-linked to the deleted dashboard, so delivery now stops: dispatchPendingCostInsightNotifications drains claimed rows to 'skipped' instead of sending, and the email template, subject, sender, and URL builder are gone. The removed routes serve a discontinued notice through an optional catch-all so old bookmarks and previously sent alert emails do not 404. CONTEXT.md claimed Spend Alerts reached only platform admins. That was wrong for organization owners: recipient selection and revalidation checked membership role only, with no is_admin or active-status filter. Corrected alongside the removed frontend claims. Retained for the follow-up PRs: cron routes, jobs, evaluation, rollup maintenance, and the spend-capture paths.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryClean removal of the Cost Insights frontend surface, tRPC routers, and alert email path; all deleted modules verified free of dangling references, the notification drain-to-skipped behavior is covered by an updated integration test, and the catch-all tombstone pages are correctly wired. Files Reviewed (76 files)Modified / added:
Deleted (60 files): cost-insights route pages/layouts, Reviewed by kimi-k3 · Input: 148.8K · Output: 19.7K · Cached: 2.7M Review guidance: REVIEW.md from base branch |
First of three PRs shutting down Cost Insights. This one removes every user-facing surface and the API it depended on. Follow-ups stop writing to the
cost_insight_*tables, then drop the tables.Removed
cost-insightsrelease-toggle layout.apps/web/src/components/cost-insights/plus the Storybook stories and fixtures.costInsightsandorganizations.costInsightstRPC routers (19 procedures) and their registrations inroot-router.ts/organization-router.ts.presenter.ts,tracking.ts,posthog-tracking.ts.presenter.tswas the blocker for deleting the component directory: it imported 11 types from@/components/cost-insights/types.formatReviewItemBadgehelpers and the orphaneduseQuery/useTRPCwiring left behind.dev/seed/cost-insights/, which existed only to populate the deleted dashboards and printed login URLs to the removed routes.Spend Alert emails now stop
The alert email's only CTA deep-linked to the deleted dashboard, so leaving delivery on would have shipped a 404 CTA.
dispatchPendingCostInsightNotificationsnow drains claimed rows toskippedwith reasonfeature_discontinuedinstead of sending. The template (costInsightSpendAlert.html), subject entry,sendCostInsightSpendAlertEmail, and thecostInsightOwnerBasePathURL builder are deleted.Discontinued notice
Both former base paths serve a short notice via an optional catch-all (
[[...segments]]), so old bookmarks and previously sent emails land on an explanation instead of a 404 — including deep links like/cost-insights/configand/cost-insights/activity. Personal keepsgetUserFromAuthOrRedirect; organization keepsOrganizationByPageLayoutauthorization.Doc correction
CONTEXT.mdstated Spend Alerts were "sent only to Kilo platform admins... organization owners or billing managers who are also platform admins". The code disagreed for organizations: bothlistCostInsightNotificationRecipientUserIdsandhasCurrentCostInsightAccesschecked membership roleowner/billing_manageronly — nois_admincheck and nostatus = 'active'filter. Corrected along with the now-false frontend claims about routes, sidebar placement, dashboards, and settings.Retained for follow-ups
vercel.jsoncron entries, both cron routes,jobs,evaluation,notificationsclaim/terminalize machinery,repository,rollup-maintenance,rollup-repairs,spend-repository,canonical-sources,suggestion-eligibility,owner,policy,hourly-sweep-repository, and all spend-capture call sites. Each is transitively required by the cron jobs or the spend-write paths.repository.tsstill exports settings/acknowledge/dismiss helpers that no longer have callers; they belong with PR2's write removal.Verification
apps/webtypecheck,apps/storybooktypecheck,oxlint(0 warnings, 0 errors),oxfmt.lib/cost-insights,lib/email, both cron routes, androot-router; plus 8 suites / 336 tests over the spend paths (processUsage,exa-usage,coding-plans,kiloclaw-billing-router,usage-post-commit-work)./cost-insights,/cost-insights/config, and/organizations/<id>/cost-insightsall return 200 with the notice, "View usage" navigates to/usage, and no Cost Insights entry appears in the sidebar for an admin.