Skip to content

Adjust new task button to create new task#4063

Draft
TheodoreSpeaks wants to merge 3 commits intostagingfrom
feat/new-task-behavior
Draft

Adjust new task button to create new task#4063
TheodoreSpeaks wants to merge 3 commits intostagingfrom
feat/new-task-behavior

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

Brief description of what this PR does and why.

Fixes #(issue)

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

How has this been tested? What should reviewers focus on?

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)

Screenshots/Videos

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Apr 8, 2026 11:39pm

Request Review

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@BugBot review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 8, 2026

PR Summary

Medium Risk
Changes task creation/navigation behavior in the sidebar by introducing a client-side draft placeholder and new state store; risk is mainly UI/state consistency (e.g., draft not cleared or placeholder treated like a real task) rather than backend/data concerns.

Overview
Clicking New task from the sidebar/nav now creates a client-side draft task placeholder (via new Zustand useDraftTaskStore) before routing to /home, ensuring the task list immediately reflects an in-progress creation.

The sidebar task list logic is updated to inject/remove this draft-* item until a newly fetched real task appears, and to treat both draft-* and legacy new placeholders as non-interactive (no selection, drag, or context menu) via isPlaceholderTask.

Reviewed by Cursor Bugbot for commit 2913b67. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 5 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2913b67. Configure here.

const isCurrentRoute = task.id !== 'new' && pathname === task.href
const isRenaming = taskFlyoutRename.editingId === task.id
const isSelected = task.id !== 'new' && selectedTasks.has(task.id)
const isSelected =
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Collapsed sidebar allows actions on draft placeholder tasks

Medium Severity

The sidebar isn't consistently recognizing placeholder tasks (like new drafts). This means action buttons and context menus are incorrectly available for these tasks in the collapsed sidebar, which could lead to attempts at server-side operations on non-existent tasks. Also, the isCurrentRoute check still uses task.id !== 'new', potentially misidentifying placeholder tasks as the current route.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2913b67. Configure here.

label: 'Home',
icon: Home,
href: `/workspace/${workspaceId}/home`,
onClick: handleNewTaskFromNav,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Home button now creates draft task on every click

Medium Severity

The Home nav item now has onClick: handleNewTaskFromNav, which calls createDraft() and then router.push on every regular click. This transforms the "Home" navigation button into a task-creation button — any time a user clicks Home (without modifier keys), a draft task placeholder is inserted into the sidebar. Previously, Home simply navigated to /home. The PR title indicates the intent is to adjust the "New task" button, not repurpose the Home button.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2913b67. Configure here.

const isCurrentRoute = task.id !== 'new' && pathname === task.href
const isRenaming = taskFlyoutRename.editingId === task.id
const isSelected = task.id !== 'new' && selectedTasks.has(task.id)
const isSelected =
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

isCurrentRoute check not updated for draft task IDs

Low Severity

Both the collapsed (line 1478) and expanded (line 1501) sidebar compute isCurrentRoute using task.id !== 'new' instead of !isPlaceholderTask(task.id). Draft tasks with href pointing to /home will match as the current route when the user is on that page, receiving active styling inconsistent with their placeholder treatment everywhere else. The original 'new' placeholder was deliberately excluded from route matching.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2913b67. Configure here.

const handleNewTaskFromNav = useCallback(() => {
flushSync(() => useDraftTaskStore.getState().createDraft())
router.push(`/workspace/${workspaceId}/home`)
}, [router, workspaceId])
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Three identical draft-creation handlers are redundant

Low Severity

handleNewTaskFromNav, tasksPrimaryAction.onSelect, and handleNewTask all contain identical logic: calling flushSync with createDraft() then router.push to home. Two of these are useCallback wrappers with the same deps. tasksPrimaryAction.onSelect could reference handleNewTask, and handleNewTaskFromNav could be eliminated entirely in favor of handleNewTask, reducing the maintenance surface for this logic from three copies to one.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2913b67. Configure here.

}
}
prevFetchedTaskIdsRef.current = currentIds
}, [draftTaskId, fetchedTasks])
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Draft removed prematurely on cold-start task load

Medium Severity

prevFetchedTaskIdsRef is initialized via useRef with fetchedTasks, which defaults to [] on a cold cache. Since useRef only captures the mount-time value, the ref starts as an empty set. When the initial task list loads, every task satisfies !prevFetchedTaskIdsRef.current.has(t.id), so hasNewTask becomes true and removeDraft() fires — even though none of those tasks correspond to the user's draft. The draft placeholder briefly appears then vanishes. The same false-positive occurs if an unrelated user creates a task in a shared workspace.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2913b67. Configure here.

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