Repository navigation
fix(wework): unify task route and enforce list exclusivity - #1335
Conversation
Unify the conversation/task URL to the canonical path route (/projects/:projectId/tasks/:taskId or /tasks/:taskId) on send, replacing the legacy query-param URL produced after creating a chat. Enforce mutual exclusivity between the project task lists and the standalone conversation list so a project task no longer leaks into recent chats during the eventual-consistency window where the server momentarily reports project_id=0. The project.tasks list is the authoritative source used to dedupe recentTasks. Extract a shared selectStandaloneConversations selector reused by the desktop sidebar and mobile drawer, removing duplicated local sorting. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR refactors task-list logic by extracting sorting and filtering utilities into a shared module, applying those utilities across UI components, and enforcing mutual exclusivity between standalone conversations and project-assigned tasks in the reducer. Task routing is updated to use canonical routes instead of URL query parameters. ChangesTask List Extraction and Exclusivity Enforcement
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
wework/src/components/layout/DesktopSidebar.tsx (1)
1-1309: ⚖️ Poor tradeoffConsider splitting DesktopSidebar.tsx into smaller modules.
This file is 1309 lines, exceeding the 1000-line guideline. While this PR only touches 2 lines, consider extracting sub-components (e.g., ProjectItem, RecentTaskRow, SidebarSectionHeader) into separate files to improve maintainability.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@wework/src/components/layout/DesktopSidebar.tsx` around lines 1 - 1309, The DesktopSidebar.tsx is too large; split it into smaller modules by extracting the subcomponents and related helpers: create separate files (e.g., ProjectItem.tsx, ProjectTaskRow.tsx, RecentTaskRow.tsx, SidebarSectionHeader.tsx) and move their component implementations and any tightly-coupled helper functions they use (like getProjectTaskTitle, getProjectTaskTime, sortProjectTasks, formatRelativeSidebarTime, isGitWorktreeSession, GitWorktreeSidebarIcon, SidebarDeviceStatusIndicator, getSidebarDeviceState, getProjectDeviceId, getSidebarDeviceName, getSidebarDeviceStatusLabel, getDeviceUnavailableActionTitle) into those files or a shared utils file; keep all prop types and data-testid strings intact, export the components/utility functions, and update DesktopSidebar to import them (preserve names: ProjectItem, ProjectTaskRow, RecentTaskRow, SidebarSectionHeader, formatRelativeSidebarTime, etc.) so behavior and tests remain unchanged.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@wework/src/components/layout/DesktopSidebar.tsx`:
- Around line 1-1309: The DesktopSidebar.tsx is too large; split it into smaller
modules by extracting the subcomponents and related helpers: create separate
files (e.g., ProjectItem.tsx, ProjectTaskRow.tsx, RecentTaskRow.tsx,
SidebarSectionHeader.tsx) and move their component implementations and any
tightly-coupled helper functions they use (like getProjectTaskTitle,
getProjectTaskTime, sortProjectTasks, formatRelativeSidebarTime,
isGitWorktreeSession, GitWorktreeSidebarIcon, SidebarDeviceStatusIndicator,
getSidebarDeviceState, getProjectDeviceId, getSidebarDeviceName,
getSidebarDeviceStatusLabel, getDeviceUnavailableActionTitle) into those files
or a shared utils file; keep all prop types and data-testid strings intact,
export the components/utility functions, and update DesktopSidebar to import
them (preserve names: ProjectItem, ProjectTaskRow, RecentTaskRow,
SidebarSectionHeader, formatRelativeSidebarTime, etc.) so behavior and tests
remain unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2025822a-301d-40fd-8ae3-c522338d1e32
📒 Files selected for processing (7)
wework/src/components/layout/DesktopSidebar.tsxwework/src/components/layout/MobileDrawer.tsxwework/src/features/workbench/WorkbenchProvider.tsxwework/src/features/workbench/workbenchReducer.test.tswework/src/features/workbench/workbenchReducer.tswework/src/lib/taskLists.test.tswework/src/lib/taskLists.ts
Summary
/projects/:projectId/tasks/:taskId或无项目时/tasks/:taskId),替换原先创建后跳出的?taskId=查询参数 URL,与点击已有会话的行为保持一致。!task.project_id过滤,而服务端在创建后的最终一致性窗口里会瞬时返回project_id=0,叠加lists_refreshed重新插入,导致同一任务出现在两个列表。现以project.tasks为权威来源去重recentTasks,保证互斥。selectStandaloneConversations,桌面侧边栏与移动端抽屉复用,移除重复的本地排序逻辑。Changes
wework/src/features/workbench/workbenchReducer.ts:新增normalizeListExclusivity/collectProjectTaskIds/removeTaskFromProjects,并在bootstrapped、lists_refreshed、upsertOpenedTask中强制互斥。wework/src/features/workbench/WorkbenchProvider.tsx:发送创建任务后走buildTaskRoute+navigateTo生成规范路径,移除冗余的writeTaskIdToUrl。wework/src/lib/taskLists.ts(新增)+ 复用到DesktopSidebar.tsx/MobileDrawer.tsx。Test plan
npx vitest run src/features/workbench/workbenchReducer.test.ts src/lib/taskLists.test.ts— 14 passedeslint改动文件无报错/projects/:id/tasks/:taskId🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests