Skip to content

refactor(mothership-chats): rename task feature to chat, move route, add redirect#4910

Merged
waleedlatif1 merged 2 commits into
stagingfrom
chore/task-to-chat-migration
Jun 8, 2026
Merged

refactor(mothership-chats): rename task feature to chat, move route, add redirect#4910
waleedlatif1 merged 2 commits into
stagingfrom
chore/task-to-chat-migration

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Renamed the Mothership "task" feature to "chat" across the codebase and moved the workspace route /workspace/[workspaceId]/task/[taskId]/workspace/[workspaceId]/chat/[chatId]
  • Added a permanent redirect in next.config.ts so existing bookmarks/deeplinks to the old /task/ URL keep working
  • Renamed client hooks queries/tasks.tsqueries/mothership-chats.ts using a mothership-chat-prefixed family — deliberately distinct from the existing deployed-chat hooks in queries/chats.ts to avoid React Query cache-key collisions
  • Renamed contract mothership-tasks.tsmothership-chats.ts, lib/copilot/tasks.tschat-status.ts, use-task-eventsuse-mothership-chat-events, use-task-selectionuse-chat-selection, and the folder-store chat-selection methods
  • Updated server-generated deeplinks (OAuth callback, inbox email response, inbox list nav) to the new /chat/ URL

Intentionally preserved (to avoid unintended side effects)

  • Wire/cross-process values: Redis channel task:status_changed and SSE event task_status (kept identical so live status updates keep flowing across pods during a rolling deploy)
  • Persisted discriminant: MothershipResourceType value 'task' (stored in chat resources + sent to the sim-agent backend), plus the aligned drag type/kind and itemType UI discriminants
  • Analytics continuity: posthog event names (task_request_started, task_message_sent, etc.) and result_type: 'task'
  • Unrelated features left untouched: scheduled-tasks, email-inbox tasks, the shared Task icon glyph, Microsoft Planner tasks, Trigger.dev/background jobs

Type of Change

  • Refactor / rename (no behavior change)

Testing

  • bun run type-check — passes (0 errors)
  • bun run check:api-validation — passes
  • Affected vitest suites (mothership-chats hooks, chat events, copilot/mothership chat routes, lifecycle) — 54 tests pass
  • Verified no stray /task/ URLs, no dangling old symbols/imports, and audited every globally-renamed token to confirm zero collateral in unrelated files

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…add redirect

- Move workspace route /task/[taskId] -> /chat/[chatId] and add a permanent
  redirect in next.config so existing bookmarks/deeplinks keep working
- Rename client hooks queries/tasks.ts -> queries/mothership-chats.ts with the
  mothership-chat-prefixed family (distinct from the existing deployed-chat
  hooks in queries/chats.ts to avoid query-key collisions)
- Rename contract mothership-tasks.ts -> mothership-chats.ts (MothershipChat)
- Rename lib/copilot/tasks.ts -> chat-status.ts (chatPubSub, ChatStatusEvent)
- Rename use-task-events -> use-mothership-chat-events, use-task-selection ->
  use-chat-selection, and folder-store chat-selection methods
- Update server-generated deeplinks (oauth callback, inbox response, inbox list)
- Preserve wire/persisted/analytics values that cross process or deploy
  boundaries: Redis channel task:status_changed, SSE event task_status,
  MothershipResourceType 'task', posthog event names, drag/itemType
  discriminants. Unrelated scheduled-tasks and email-inbox tasks untouched
@vercel

vercel Bot commented Jun 8, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jun 8, 2026 8:02pm

Request Review

@cursor

cursor Bot commented Jun 8, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Large cross-cutting rename touches routing, React Query keys, and many API/UI call sites; behavior is intended to be equivalent with wire-compat for live events, but URL and import changes warrant regression on chat CRUD, streaming, and sidebar SSE updates.

Overview
Renames the Mothership workspace task UX and code to chat: the app route moves from /workspace/:workspaceId/task/:chatId to /workspace/:workspaceId/chat/:chatId, with a permanent Next.js redirect for old links.

API and client layers swap mothership-tasks contracts and queries/tasks for mothership-chats / mothership-chats hooks (useMothershipChats, mothershipChatKeys, etc.), distinct from deployed-chat hooks to avoid React Query key clashes. Sidebar, search, home chat flow, fork, and folder selection follow the new names (useChatSelection, clearChatSelection).

Realtime status moves from lib/copilot/tasks (taskPubSub) to lib/copilot/chat-status (chatPubSub); Redis channel task:status_changed and SSE task_status are unchanged for rolling-deploy compatibility. Server deeplinks (OAuth return, inbox emails, inbox list) now use /chat/.

Wire analytics, resource type 'task', and unrelated inbox/scheduled-task features are intentionally left as-is per the PR description.

Reviewed by Cursor Bugbot for commit d2e26d8. Configure here.

@greptile-apps

greptile-apps Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This is a thorough rename/refactor moving the Mothership "task" feature to "chat" across 57 files — route, hooks, contracts, store, components, and server-side URL generators — while carefully preserving backward-compatible wire values (Redis channel task:status_changed, SSE label task_status, drag discriminants, PostHog event names) for rolling-deploy safety.

  • The /workspace/:workspaceId/task/:chatId/workspace/:workspaceId/chat/:chatId permanent redirect is correctly wired in next.config.ts, and all server-generated deep-links (OAuth callback, inbox email response, inbox list) have been updated to the new path.
  • The React Query cache-key family is renamed to mothership-chat-*, deliberately distinct from the existing deployed-chat family in queries/chats.ts, preventing cache-key collisions.
  • The lib/copilot/tasks.tschat-status.ts rename uses a new _chatStatusChannel global key while keeping the same Redis channel identifier, so old and new pods interoperate cleanly during a rolling deploy.

Confidence Score: 5/5

Safe to merge — this is a purely mechanical rename with no behavior changes on any hot path.

Every renamed symbol has been updated consistently across routes, hooks, stores, contracts, and tests. Wire-level identifiers (Redis channel, SSE label, drag discriminants, analytics events) are intentionally preserved, and the permanent redirect in next.config.ts protects existing bookmarks. Type-check and test suite pass cleanly. The only finding is a cosmetic stale string in the search-modal filter key.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/next.config.ts Adds a permanent redirect from /workspace/:workspaceId/task/:chatId to /workspace/:workspaceId/chat/:chatId to preserve existing bookmarks and deeplinks — correct and well-placed.
apps/sim/stores/folders/store.ts Renames all selectedTasks/lastSelectedTaskId state and selection actions to their chat equivalents; logic is unchanged and cross-selection clearing is preserved correctly.
apps/sim/lib/copilot/chat-status.ts New file replacing tasks.ts; intentionally keeps the Redis channel task:status_changed and label task so events keep flowing across old and new pods during a rolling deploy.
apps/sim/hooks/queries/mothership-chats.ts Renames the former tasks.ts query hooks to mothership-chat-prefixed variants with a new React Query cache-key family; avoids collisions with the deployed-chat hooks in queries/chats.ts.
apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts Updates all taskKeys/TaskChatHistory/upsertTaskChatHistory usages to the new mothership-chat equivalents, including URL generation for window.history.replaceState — all paths updated consistently.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx Large rename of task→chat for all sidebar items, hooks, mutations, and context-menu logic; drag type: 'task' intentionally preserved for discriminant compatibility.
apps/sim/app/api/mothership/events/route.ts Swaps taskPubSub for chatPubSub; SSE event label task_status intentionally preserved for backward compatibility across rolling deploys.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/search-modal.tsx Renames the tasks prop to chats and the group component; the filterAndSort key still uses the task- prefix string, which is a minor stale leftover.
apps/sim/lib/copilot/tools/handlers/oauth.ts Updates the OAuth callback return URL from /task/ to /chat/, consistent with the rest of the rename.
apps/sim/lib/mothership/inbox/executor.ts Replaces taskPubSub with chatPubSub for all inbox task status notifications; import updated to the new chat-status module.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Old URL\n/workspace/:wid/task/:chatId"] -->|"permanent redirect\n(next.config.ts)"| B["New URL\n/workspace/:wid/chat/:chatId"]

    subgraph "React Query Cache"
        C["mothership-chat-* keys\n(mothership-chats.ts)"]
        D["chat-* keys\n(queries/chats.ts)"]
    end

    subgraph "Pub/Sub (preserved for rolling deploy)"
        E["Redis channel: task:status_changed"]
        F["SSE label: task_status"]
        E --> F
    end

    subgraph "Renamed"
        G["tasks.ts → mothership-chats.ts"]
        H["lib/copilot/tasks.ts → chat-status.ts"]
        I["use-task-events → use-mothership-chat-events"]
        J["use-task-selection → use-chat-selection"]
        K["store: selectedTasks → selectedChats"]
    end

    B --> C
    C -.->|"no collision"| D
Loading

Reviews (2): Last reviewed commit: "refactor(mothership-chats): use skipToke..." | Re-trigger Greptile

Drop the enabled + chatId! non-null assertion in favor of the skipToken
pattern, matching useMothershipChats. Behavior-preserving.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d2e26d8. Configure here.

@waleedlatif1 waleedlatif1 merged commit d526b23 into staging Jun 8, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the chore/task-to-chat-migration branch June 8, 2026 20:16
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.

1 participant