Skip to content

chore: remove dead segment report surface#1678

Merged
sweetmantech merged 2 commits intotestfrom
chore/remove-segment-report
Apr 16, 2026
Merged

chore: remove dead segment report surface#1678
sweetmantech merged 2 commits intotestfrom
chore/remove-segment-report

Conversation

@arpitgupta1214
Copy link
Copy Markdown
Collaborator

@arpitgupta1214 arpitgupta1214 commented Apr 15, 2026

Summary

The segment report flow is no longer mounted on any active product surface. The entire surface is being removed rather than migrated. No user-facing flow renders ChatReport, polls /api/segment_report, or relies on segment_reports / segment_rooms.

What was removed

API route

  • app/api/segment_report/route.ts

Components

  • components/Chat/ChatReport/* (entire directory)

Hooks

  • hooks/useReportData.ts
  • hooks/useFunnelReport.tsx
  • hooks/useDownloadReport.tsx
  • hooks/useGenerateSegmentReport.tsx

Library helpers

  • lib/report/* (entire directory)
  • lib/getPdfReport.tsx
  • lib/formatPdf.tsx

Supabase helpers

  • lib/supabase/getSegmentRoom.ts
  • lib/supabase/createSegmentRoom.ts
  • lib/supabase/getSegmentWithArtist.ts
  • lib/supabase/getSegmentIdForRoomId.ts
  • lib/supabase/getRoomReports.ts
  • lib/supabase/createRoomWithReport.ts renamed to createRoom.ts; report_id parameter stripped (sole remaining caller, handleChatCompletion, never passed it)

Page routes

  • app/segment/[segmentId]/page.tsx
  • app/docs/segment_report/*

Provider

  • providers/FunnelReportProvider.tsx

What was edited (not deleted)

  • components/VercelChat/chat.tsx — dropped ChatReport import/render and the now-unused reportId prop
  • components/Segments/Segments.tsx + SegmentButton.tsx — dropped the useGenerateSegmentReport CTA wiring
  • app/chat/[roomId]/page.tsx — stopped fetching reportId via getRoomReports and stopped passing it to Chat
  • providers/Providers.tsx — removed FunnelReportProvider wrapper
  • app/globals.css — removed .segment-report* rules
  • types/Chat.tsx, types/Stack.tsx, hooks/useConversations.tsx — dropped dead room_reports fields from the Conversation type (no consumers read them)

Out of scope

  • The database drop migration for segment_reports / segment_rooms / room_reports is intentionally not part of this PR — it ships separately, after which types/database.types.ts will be regenerated
  • Residual matches in types/database.types.ts are auto-generated and will be cleaned up by that regeneration

Test Plan

  • segments page renders without the report-generation CTA
  • chat rooms that previously linked to a report still load without error
  • no UI surface attempts to fetch /api/segment_report
  • grep confirms no remaining references to removed modules (only acceptable hits are in auto-generated types/database.types.ts)

🤖 Generated with Claude Code


Summary by cubic

Removed the unused segment report surface and all plumbing. This simplifies chat and segments, removes dead API calls, and cleans up types and CSS.

  • Refactors
    • Deleted the report API, UI, hooks, and helpers: /api/segment_report, components/Chat/ChatReport/*, lib/report/*, useReportData, useFunnelReport, useDownloadReport, useGenerateSegmentReport, docs under app/docs/segment_report, and the segment generation page.
    • Unwired all references: Chat no longer accepts reportId; app/chat/[roomId]/page.tsx stopped using getRoomReports; Segments removed the generate-report CTA; FunnelReportProvider removed from Providers.
    • Renamed and simplified lib/supabase/createRoom (was createRoomWithReport): removed report_id plumbing and updated call sites (e.g., lib/chat/handleChatCompletion.ts).
    • Removed Supabase helpers tied to the report flow: getSegmentRoom, createSegmentRoom, getSegmentWithArtist, getSegmentIdForRoomId, getRoomReports.
    • Cleaned up .segment-report* CSS and dropped room_reports from Conversation types.
    • Note: DB drops for segment_reports, segment_rooms, room_reports will ship in a separate PR.

Written for commit 04e6c14. Summary will update on new commits.

The segment report flow is no longer mounted on any active product
surface. Remove the entire surface (route, components, hooks, helpers,
generation page, docs page, provider) per SEGMENTS_SURFACE_MIGRATION_PLAN.md.

- Delete app/api/segment_report route
- Delete components/Chat/ChatReport directory
- Delete hooks: useReportData, useFunnelReport, useDownloadReport,
  useGenerateSegmentReport
- Delete lib/report directory, lib/getPdfReport, lib/formatPdf
- Delete segment-room supabase helpers (getSegmentRoom,
  createSegmentRoom, getSegmentWithArtist, getSegmentIdForRoomId,
  getRoomReports)
- Delete app/segment/[segmentId] generation page and
  app/docs/segment_report docs
- Delete providers/FunnelReportProvider
- Strip report_id plumbing from createRoomWithReport
- Unwire ChatReport/useGenerateSegmentReport/FunnelReportProvider from
  call sites (VercelChat/chat, Segments, chat/[roomId]/page, Providers)
- Drop .segment-report CSS rules and room_reports fields from
  Conversation types

Database drop migration for segment_reports / segment_rooms /
room_reports is the next step in the plan and is intentionally out of
scope for this PR.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
recoup-chat Ready Ready Preview Apr 15, 2026 2:09pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 15, 2026

Warning

Rate limit exceeded

@arpitgupta1214 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 28 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 52 minutes and 28 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 447c7e41-37aa-4b3f-9aaf-583abe610294

📥 Commits

Reviewing files that changed from the base of the PR and between dd85d58 and 04e6c14.

📒 Files selected for processing (2)
  • lib/chat/handleChatCompletion.ts
  • lib/supabase/createRoom.ts
📝 Walkthrough

Walkthrough

This PR removes the entire segment report generation and display infrastructure, including the API route for fetching reports, report creation/management hooks, React display components, database operations for report tracking, and the provider context that distributed report state across the application.

Changes

Cohort / File(s) Summary
API & Server Routes
app/api/segment_report/route.ts
Deleted GET handler that fetched segment reports from Supabase with artist details and cache directives.
Report Generation Hooks
hooks/useGenerateSegmentReport.tsx, hooks/useFunnelReport.tsx, hooks/useReportData.ts
Removed hooks for initiating report generation, polling report data, and managing funnel report state/lifecycle.
Report Display Components
components/Chat/ChatReport/index.tsx, components/Chat/ChatReport/Content.tsx, components/Chat/ChatReport/Actions.tsx, components/Chat/ChatReport/types.ts
Deleted components and types for rendering reports with artist banners, report content, next steps, and PDF download functionality.
Report Utilities & PDF
lib/report/createReport.tsx, lib/report/getSegmentReport.tsx, lib/formatPdf.tsx, lib/getPdfReport.tsx, hooks/useDownloadReport.tsx
Removed helpers for creating reports via external API, fetching report data, formatting HTML for PDF, and downloading PDF files.
Database Operations
lib/supabase/createRoomWithReport.ts, lib/supabase/createSegmentRoom.ts, lib/supabase/getRoomReports.ts, lib/supabase/getSegmentRoom.ts, lib/supabase/getSegmentIdForRoomId.ts, lib/supabase/getSegmentWithArtist.ts
Removed Supabase queries and mutations for managing report↔room associations, segment↔room mappings, and related data fetching.
Page Routes & Documentation
app/segment/[segmentId]/page.tsx, app/docs/segment_report/page.tsx, app/docs/segment_report/constants.ts
Deleted dynamic segment page that triggered report generation flow, and removed API documentation page with code examples and response schemas.
Provider & Context
providers/FunnelReportProvider.tsx, providers/Providers.tsx
Removed FunnelReportProvider and context hook; updated provider tree to remove FunnelReportProvider wrapper.
Component Integration
app/chat/[roomId]/page.tsx, components/VercelChat/chat.tsx, components/Segments/SegmentButton.tsx, components/Segments/Segments.tsx, hooks/useConversations.tsx, lib/report/types.ts, app/globals.css
Updated Chat component to remove reportId prop; removed onGenerateReport callback from SegmentButton; cleaned up segment report styling and optimistic conversation state.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • migrate to dedicated api for chat endpoints #1602: Deletes chat create/generate API handlers and proxied chat endpoints that previously called report generation and room creation functions being removed here; directly complementary removal of backend API layer.

Suggested reviewers

  • sweetmantech
  • cubic-dev-ai

Poem

🧹 Reports fade to memory,
Hooks unwind, hooks set free,
API calls dissolve to night,
Clean slate shines, architecture bright!

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Solid & Clean Code ✅ Passed PR comprehensively removes dead report feature with zero dangling references, properly updates dependent code, simplifies component responsibilities, and eliminates unnecessary abstractions while maintaining clean code practices.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/remove-segment-report

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
lib/supabase/createRoomWithReport.ts (2)

14-19: Rename this helper to reflect current behavior.

createRoomWithReport now only creates a room; the report linkage is gone. Renaming to createRoom (and updating the caller in lib/chat/handleChatCompletion.ts) will keep the API self-descriptive.

♻️ Proposed rename
-export const createRoomWithReport = async ({
+export const createRoom = async ({
-        createRoomWithReport({
+        createRoom({

As per coding guidelines, "Ensure code is self-documenting through precise naming with verbs for functions and nouns for variables."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/supabase/createRoomWithReport.ts` around lines 14 - 19, Rename the
exported helper function createRoomWithReport to createRoom (update its
declaration and export) and update all call sites to use createRoom instead of
createRoomWithReport—in particular replace the import and usage in the caller
function handleChatCompletion; keep the function signature and return type
unchanged so only the symbol name changes, and run a quick search for any
remaining references to createRoomWithReport to rename them as well.

19-22: Simplify the return contract (throw or error object, not both).

This function throws on failures but still returns { error: null } on success. Consider returning only new_room to reduce API noise and keep call sites simpler.

♻️ Proposed simplification
 }: CreateRoomParams): Promise<{
-  new_room: Room & { memories: [] };
-  error: PostgrestError | null;
-}> => {
+  new_room: Room & { memories: [] };
+}> => {
@@
     return {
       new_room: {
         ...new_room,
         memories: [],
       },
-      error: null,
     };

As per coding guidelines, "Write minimal code - use only the absolute minimum code needed."

Also applies to: 39-49

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/supabase/createRoomWithReport.ts` around lines 19 - 22, The function
currently returns an object { new_room, error } while also throwing on failures;
change the API to either throw errors or return an error object — pick throwing:
update the createRoomWithReport function signature (remove the error field from
the Promise return type so it returns Promise<Room & { memories: [] }>) and
modify the implementation to return only new_room on success; remove all
constructions like { new_room, error: null } and any error-return branches
(lines referenced around 39-49) so errors are propagated via throw, and update
any callers to handle exceptions instead of reading an error property; keep
CreateRoomParams and the Room & { memories: [] } types as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@lib/supabase/createRoomWithReport.ts`:
- Around line 14-19: Rename the exported helper function createRoomWithReport to
createRoom (update its declaration and export) and update all call sites to use
createRoom instead of createRoomWithReport—in particular replace the import and
usage in the caller function handleChatCompletion; keep the function signature
and return type unchanged so only the symbol name changes, and run a quick
search for any remaining references to createRoomWithReport to rename them as
well.
- Around line 19-22: The function currently returns an object { new_room, error
} while also throwing on failures; change the API to either throw errors or
return an error object — pick throwing: update the createRoomWithReport function
signature (remove the error field from the Promise return type so it returns
Promise<Room & { memories: [] }>) and modify the implementation to return only
new_room on success; remove all constructions like { new_room, error: null } and
any error-return branches (lines referenced around 39-49) so errors are
propagated via throw, and update any callers to handle exceptions instead of
reading an error property; keep CreateRoomParams and the Room & { memories: [] }
types as-is.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fd71d501-480c-4b13-9964-b88a333de497

📥 Commits

Reviewing files that changed from the base of the PR and between ab21089 and dd85d58.

⛔ Files ignored due to path filters (2)
  • types/Chat.tsx is excluded by none and included by none
  • types/Stack.tsx is excluded by none and included by none
📒 Files selected for processing (31)
  • app/api/segment_report/route.ts
  • app/chat/[roomId]/page.tsx
  • app/docs/segment_report/constants.ts
  • app/docs/segment_report/page.tsx
  • app/globals.css
  • app/segment/[segmentId]/page.tsx
  • components/Chat/ChatReport/Actions.tsx
  • components/Chat/ChatReport/Content.tsx
  • components/Chat/ChatReport/index.tsx
  • components/Chat/ChatReport/types.ts
  • components/Segments/SegmentButton.tsx
  • components/Segments/Segments.tsx
  • components/VercelChat/chat.tsx
  • hooks/useConversations.tsx
  • hooks/useDownloadReport.tsx
  • hooks/useFunnelReport.tsx
  • hooks/useGenerateSegmentReport.tsx
  • hooks/useReportData.ts
  • lib/formatPdf.tsx
  • lib/getPdfReport.tsx
  • lib/report/createReport.tsx
  • lib/report/getSegmentReport.tsx
  • lib/report/types.ts
  • lib/supabase/createRoomWithReport.ts
  • lib/supabase/createSegmentRoom.ts
  • lib/supabase/getRoomReports.ts
  • lib/supabase/getSegmentIdForRoomId.ts
  • lib/supabase/getSegmentRoom.ts
  • lib/supabase/getSegmentWithArtist.ts
  • providers/FunnelReportProvider.tsx
  • providers/Providers.tsx
💤 Files with no reviewable changes (25)
  • hooks/useConversations.tsx
  • app/globals.css
  • components/Chat/ChatReport/Actions.tsx
  • hooks/useGenerateSegmentReport.tsx
  • app/docs/segment_report/page.tsx
  • lib/report/createReport.tsx
  • hooks/useDownloadReport.tsx
  • lib/supabase/getSegmentRoom.ts
  • lib/report/types.ts
  • lib/supabase/getRoomReports.ts
  • lib/formatPdf.tsx
  • lib/getPdfReport.tsx
  • lib/supabase/getSegmentIdForRoomId.ts
  • components/Chat/ChatReport/Content.tsx
  • app/segment/[segmentId]/page.tsx
  • lib/report/getSegmentReport.tsx
  • components/Chat/ChatReport/types.ts
  • hooks/useReportData.ts
  • hooks/useFunnelReport.tsx
  • app/api/segment_report/route.ts
  • providers/FunnelReportProvider.tsx
  • lib/supabase/getSegmentWithArtist.ts
  • components/Chat/ChatReport/index.tsx
  • lib/supabase/createSegmentRoom.ts
  • app/docs/segment_report/constants.ts

The report plumbing was stripped in the preceding commit, so the
"WithReport" suffix is misleading — the helper only creates a room.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: no supabase libs should exist in the Chat codebase.

  • Supabase should only be accessed via API.

@sweetmantech sweetmantech merged commit 739b54b into test Apr 16, 2026
3 checks passed
@sweetmantech sweetmantech deleted the chore/remove-segment-report branch April 16, 2026 23:52
sweetmantech added a commit that referenced this pull request Apr 16, 2026
Promote test → main (includes #1678 dead segment-report removal)
arpitgupta1214 added a commit that referenced this pull request Apr 17, 2026
Deletes the remaining segment list/create routes, the Segments UI
components, segment-fans renderers, segment hooks, lib/segments,
chat-segment lookup, segment MCP/AI tool wrappers, sidebar segment
nav entries, and segment-related supabase helpers. The Segments
feature is being removed entirely; the earlier migration plan is
abandoned. Follows #1678 (segment report removal). Part of
SEGMENTS_SURFACE_REMOVAL_PLAN.md.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants