Repository navigation
fix(client): link tasks and notes through targetCompanyId, Twenty 2.x's morph relation [FACT-1967] - #14
Conversation
…'s morph relation [FACT-1967] Twenty 2.57 links a taskTarget / noteTarget through morph relations (targetCompany, targetPerson, targetOpportunity), so the join column is targetCompanyId. Posting companyId was a 400, "Object taskTarget doesn't have any companyId field": every createTask with a company left an unlinked task behind, and every addNote threw after creating its note. - createTask, addNote write targetCompanyId - listTasks filters on targetCompanyId; a moved task reads targetCompanyId (companyId still read as a fallback) - a failed task link now names the task it already created, so a caller does not retry the create into a duplicate Bumps @practicalworks/crm to 0.13.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
practical-bot
left a comment
There was a problem hiding this comment.
Review
The implementation correctly uses Twenty 2.x's morph join field targetCompanyId for both task and note links, changes the company-filtered task query to the same field, and reads targetCompanyId with a backwards-compatible companyId fallback when resolving task updates. The task-link failure path preserves the created task id and explicitly warns callers not to retry the create. The tests cover the request payloads, filtered listing, expanded contract response, and created-but-unlinked error.
Acceptance criteria checked:
createTask({ companyId })posts/tasks, then/taskTargetswith{ taskId, targetCompanyId }and returns the linked company id.- Link failure reports the task id and the no-duplicate retry instruction.
- Filtered listing uses
targetCompanyId[eq]and returns the requested company id on expanded task rows. - The Driven Image Customs task is a live-data check and is listed below as needing verification after merge.
Claim ledger:
- “
pnpm typecheck,pnpm test(client 120, twenty-app 28),pnpm guard,pnpm build: all green.” PASS for this changed surface:pnpm --filter @practicalworks/crm typecheck(exit 0);pnpm --filter @practicalworks/crm test(5 files, 120 tests passed);pnpm guard(14 tests passed,guard: 76 files clean);pnpm build(exit 0). The PR CI run 43972272702 was green, but its reusable workflow skippedlintandtest; local commands supplied those checks for this review. The statedtwenty-app 28count was not re-run because this diff does not touchtwenty-app. - “Not yet run against the live Twenty.” PASS: no live Twenty check was attempted from this review workspace.
No code findings. The checkout was clean and git diff --check passed.
REVIEW VERDICT: approve
REVIEWED DIFF: base=main files=4 lines=51
NEEDS VERIFICATION: In Twenty, company f6585dc9-1942-4fa2-895d-e2694edd4621 (Driven Image Customs) shows the task “Check in with Driven Image Customs on the 20x20 home garage floor…” under Tasks.
|
Review evidence follow-up: the native approval for head |
Why
Twenty 2.57 links
taskTargetandnoteTargetrows through morph relations (targetCompany,targetPerson,targetOpportunity; confirmed intwenty-sdk@2.57.0's generated types). The client still postedcompanyId, which Twenty rejects with:Seen live on 2026-11-16 through
factory_crm_add_task. The task was created but never linked, and every task infactory_crm_list_taskshascompanyId: null.addNotehits the same 400 after its note is created.What
createTaskandaddNotewritetargetCompanyId.listTasks({ companyId })filters ontargetCompanyId[eq]. A moved task readstargetCompanyId, withcompanyIdkept as a fallback.@practicalworks/crm0.13.0 → 0.13.1 (publish.yml ships it on merge).Verified
pnpm typecheck,pnpm test(client 120, twenty-app 28),pnpm guard,pnpm build: all green.🤖 Generated with Claude Code