chore(chat): migrate YouTube connector to Composio

Merged
AR
6mo ago
+385-2665

Summary

Replaces the chat-side custom YouTube OAuth flow with the existing Composio connector path. Connect/disconnect/channel-info all go through `/api/connectors` and `/api/connectors/actions`. The legacy `/api/youtube/*` routes, the `youtube_tokens` Supabase helpers, and the four LLM-tool result components for login/channels/playlist/thumbnail are deleted (Composio's toolkit covers them). Revenue dispatch is kept since the api-side `get_youtube_revenue` MCP tool stays.

Pairs with api#494 and docs#XXX.

Test plan

  • On preview, click Connect YouTube on an artist → Composio OAuth → returns to settings with the YouTube card showing connected
  • ChannelInfo + ChatInputYoutubeButtonPopover render the artist's channel name, thumbnail, and stats
  • Click logout → Composio reports disconnected, channel-info query invalidates
  • In chat, ask the agent for YouTube channel stats / playlist videos / thumbnail upload — verify Composio actions fire
  • Ask for YouTube revenue — verify the retained `get_youtube_revenue` MCP tool returns data
  • `pnpm test` (53/53 green)
  • `npx tsc --noEmit` clean for changed files

Summary by cubic

Migrates YouTube to Composio for auth and channel stats, removes legacy OAuth/UI, unwraps Composio responses, and moves connector state to React Query; keeps the custom revenue tool. Adds proper “YouTube” naming and a connector description so the settings card reads correctly.

  • Refactors

    • Enable YouTube in ALLOWED_ARTIST_CONNECTORS; connect/disconnect now use useConnectors + useConnectorHandlers (shared React Query cache, in-flight disable, aria-labels). Adds onDisconnectSuccess to also invalidate ["youtube-channel-info", accountId] and restores authorize to return null on failure.
    • useYoutubeChannel calls YOUTUBE_GET_CHANNEL_STATISTICS via executeConnectorActionApi with part: "snippet,statistics"; extracts lib/youtube/fetchYoutubeChannel; query gated on Privy authenticated. useYoutubeStatus now derives from connectors and surfaces errors.
    • Adds lib/composio/api/executeConnectorActionApi to unwrap Composio’s ToolExecuteResponse. Maps youtube to “YouTube” in formatConnectorName and adds a YouTube description in connectorMetadata.
    • Removes legacy /api/auth/callback/google, /api/youtube/*, Supabase youtube_tokens, OAuth/analytics libs, types/youtube.ts, and unused chat UIs; keeps get_youtube_revenue MCP tool/UI with an inlined result type and fallback error message.
  • Migration

    • Requires api#494 (Composio actions endpoint). Ensure the Composio YouTube connector is enabled; users must reconnect via settings. Legacy Supabase youtube_tokens are no longer used and can be cleaned up separately.

Summary by CodeRabbit

  • Refactor

    • YouTube integration now uses the connector system for auth, status, and channel data.
    • Connect/disconnect flows and status checks moved to connector-driven behavior; UI now reacts to connector state.
  • Bug Fixes / Chores

    • Removed legacy YouTube server endpoints and many legacy YouTube UI pieces (video dialogs, stats, channel displays, skeletons).
    • Added YouTube to supported account connectors; connect button updated to use the connector flow.