Skip to content

fix(client): link tasks and notes through targetCompanyId, Twenty 2.x's morph relation [FACT-1967] - #14

Merged
practical-bot merged 1 commit into
mainfrom
fix/target-company-id-FACT-1967
Nov 17, 2026
Merged

practical-bot merged 1 commit into
mainfrom
fix/target-company-id-FACT-1967

Conversation

@jcotillo

Copy link
Copy Markdown
Contributor

Why

Twenty 2.57 links taskTarget and noteTarget rows through morph relations (targetCompany, targetPerson, targetOpportunity; confirmed in twenty-sdk@2.57.0's generated types). The client still posted companyId, which Twenty rejects with:

crm POST /taskTargets failed: 400 ... Object taskTarget doesn't have any "companyId" field.

Seen live on 2026-11-16 through factory_crm_add_task. The task was created but never linked, and every task in factory_crm_list_tasks has companyId: null. addNote hits the same 400 after its note is created.

What

  • createTask and addNote write targetCompanyId.
  • listTasks({ companyId }) filters on targetCompanyId[eq]. A moved task reads targetCompanyId, with companyId kept as a fallback.
  • When a task link fails, the error names the task it already created ("created but not linked… do not retry the create"), so a caller doesn't file a duplicate.
  • @practicalworks/crm 0.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.
  • Not yet run against the live Twenty. The live check is FACT-1967's How to verify, once a consumer picks up 0.13.1.

🤖 Generated with Claude Code

…'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>
@jcotillo jcotillo added the merge:queued Queued for the merge drain once Talos approves and CI is green label Nov 16, 2026

@practical-bot practical-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 /taskTargets with { 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 skipped lint and test; local commands supplied those checks for this review. The stated twenty-app 28 count was not re-run because this diff does not touch twenty-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.

@practical-bot

Copy link
Copy Markdown
Contributor

Review evidence follow-up: the native approval for head 3d6cd234e467600b64a3ea141e9e6cfd872efc52 remains posted. The reviewed diff is base=main files=4 lines=51; client typecheck, 120 client tests, guard checks, and build all passed locally. The only remaining item is post-merge live verification in Twenty for the Driven Image Customs task.

@practical-bot
practical-bot merged commit fdc6eb3 into main Nov 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge:queued Queued for the merge drain once Talos approves and CI is green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants