fix(sidebar): create task under correct project when using + button#1406
Conversation
|
@naaa760 is attempting to deploy a commit to the General Action Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR fixes the bug where clicking the What actually fixes the bug: The removal of Dead code introduced:
Confidence Score: 3/5
|
| Filename | Overview |
|---|---|
| src/renderer/hooks/useTaskManagement.ts | Bug fix for sidebar task creation: removes the racy pendingTaskProjectRef assignment and relies on activateProjectView to set selectedProject before the modal opens. The fix works at runtime, but the added initialProject prop (passed to showModal) and overrideProject parameter (added to handleCreateTask) are dead code — neither is consumed through the modal call chain. |
Sequence Diagram
sequenceDiagram
participant User
participant Sidebar
participant handleStartCreateTaskFromSidebar
participant activateProjectView
participant openTaskModal
participant openTaskModalImplRef
participant showModal
participant TaskModalOverlay
participant handleCreateTask
User->>Sidebar: clicks + next to Project X
Sidebar->>handleStartCreateTaskFromSidebar: project X
handleStartCreateTaskFromSidebar->>activateProjectView: targetProject (sets selectedProject = X)
handleStartCreateTaskFromSidebar->>openTaskModal: targetProject
openTaskModal->>openTaskModalImplRef: project X
Note over openTaskModalImplRef: initialProject = X (passed but unused by overlay)
openTaskModalImplRef->>showModal: taskModal, {initialProject: X, onClose}
showModal->>TaskModalOverlay: renders (reads selectedProject=X from context)
User->>TaskModalOverlay: fills form, submits
TaskModalOverlay->>handleCreateTask: (name, ...args, nameGenerated) — no overrideProject
Note over handleCreateTask: overrideProject=undefined, pendingTaskProjectRef=null\n→ falls back to selectedProject (= X) ✓
handleCreateTask-->>User: task created under Project X
Comments Outside Diff (2)
-
src/renderer/hooks/useTaskManagement.ts, line 966-974 (link)initialProjectpassed toshowModalis silently ignoredinitialProjectis included in theshowModal('taskModal', ...)args, butTaskModalOverlayis typed asTaskModalOverlayProps = BaseModalProps<CreateTaskResult>which only exposesonSuccessandonClose. The component signatureTaskModalOverlay({ onClose }: TaskModalOverlayProps)never destructures or usesinitialProject.Because
UserArgs<'taskModal'>resolves to{ onSuccess?: ...; onClose?: ... }(the non-onSuccess/onCloseremainder ofTaskModalOverlayPropsis empty), passinginitialProjecthere is a TypeScript excess-property violation that will surface under strict mode.More importantly, even at runtime the prop is a no-op —
TaskModalstill readsselectedProjectfromuseProjectManagementContext()for the branch display and name de-duplication, not from anyinitialProjectpassed down.The actual reason the bug is fixed is that
activateProjectView(targetProject)callssetSelectedProject(project)first, so by the time the user can submit the form,handleCreateTaskcorrectly closes over the updatedselectedProjectvalue. TheinitialProject/overrideProjectplumbing added by this PR is dead code that does not contribute to the fix. Consider either wiring it through properly (updateTaskModalOverlayProps, passinitialProjecttoTaskModal, and forwardoverrideProjectinTaskModalOverlay.onCreateTask) or removing it to keep the change minimal. -
src/renderer/hooks/useTaskManagement.ts, line 910-949 (link)overrideProjectparameter is unreachable from the modaloverrideProjectwas added as the 14th positional argument tohandleCreateTask, butTaskModalProps.onCreateTask(lines 58–72 inTaskModal.tsx) only declares 13 parameters and ends withnameGenerated.TaskModalOverlaycallshandleCreateTaskwith exactly those 13 arguments —overrideProjectcan never be supplied through the current call chain.To actually use this escape hatch,
TaskModalProps.onCreateTaskand theTaskModalOverlayadapter would both need to be extended. Until then the parameter is unreachable dead code.
Last reviewed commit: 9d54cb0
…buton-sibr # Conflicts: # src/renderer/hooks/useTaskManagement.ts
summary
Fixes
Snapshot
Type of change
[x] Bug fix (non-breaking change which fixes an issue)
Mandatory Tasks
[ ] I have self-reviewed the code
[ ] A decent size PR without self-review might be rejected
Checklist
[ ] I have read the contributing guide
[ ] My code follows the style guidelines of this project (pnpm run format)
[ ] I have commented my code, particularly in hard-to-understand areas
[ ] I have checked if my PR needs changes to the documentation
[ ] I have checked if my changes generate no new warnings (pnpm run lint)
[ ] I have added tests that prove my fix is effective or that my feature works
[ ] I haven't checked if new and existing unit tests pass locally with my changes
fix : #1400