Skip to content

fix(platform): make Inbox assignment, selection and activity reliable - #3784

Merged
yannickmonney merged 7 commits into
mainfrom
fix/inbox-assignment-selection-activity
Sep 29, 2026
Merged

yannickmonney merged 7 commits into
mainfrom
fix/inbox-assignment-selection-activity

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Six Inbox defects reported from the local audit, one commit each (TALE-88). Each fix comes with its own regression tests. The fixes reuse the boundaries they share: one assignment wire contract, one bulk limit constant, one list error state, and one rule for how a conversation's summary is written.

What changed

Assignment doors: null clears, and a broken body clears nothing (#3708, #3732)

  • POST /api/app/conversations/:id/assign and …/assign-team read a body that failed to parse as {}, and read a missing field as "unassign". A truncated body therefore answered 200 and removed the person (Bug: Inbox assignment silently unassigns a conversation when the JSON body is malformed #3708).
  • The Inbox's own Unassign and Remove team send {"assigneeUserId": null}, which the doors refused with a 400 (bug(platform): Inbox Unassign sends null that the assignment API rejects #3732). Since the Postgres move, the Inbox had no working way to clear an assignment.
  • Each door now requires exactly one field: an id, or null. null is the clear gesture the REST door's teamId: null already documents. The body goes through the app door's JSON reader:
    • a truncated or empty body answers 400 INVALID_JSON;
    • {} answers 400 naming the field;
    • in both cases the assignment is unchanged.
  • The adapter sends null only for an explicit clear, and refuses a missing target before sending anything. The picker passes null for each clear.

A conversation's summary is written under its row lock (#3735)

  • addMessageToConversation read the parent row without a lock and wrote back the unread count and activity time it had computed from that read. Two overlapping appends both committed, and the later write left one unread message and the older timestamp.
  • The same unlocked read-then-write existed in the send lane, undo, discard, mark as read, the PATCH door and the bulk verbs. Each of those could drop the unread increment of a message landing at the same moment.
  • All of them now read the row FOR UPDATE inside the transaction that writes it back, as the API mirror lane already did. nextConversationLastMessageAt remains the only place the activity time is computed; no second copy of it in SQL.

A failed list read says so (#3709)

  • When the list read gave up after its retries, the view showed the "No conversations" empty state. Both the Home panel's Inbox view and the phone list now show Couldn't load conversations with Try again. Rows that did load stay on screen.
  • retry from useCachedPaginatedQuery now re-issues the request that actually failed. It used to call refetch, which reloads only the pages already loaded, so a later page that failed was never requested again.
  • New strings in EN, DE and FR.

Select all reads three states (#3734)

  • The Home toolbar turned the selection hook's 'indeterminate' into true. One ticked row showed as "all selected", and the next click cleared that row instead of selecting the rest.
  • The value now passes through unchanged, as on the phone list.
  • Additional finding, same surface, separate cause: each row's checkbox sat underneath the row link, which is lifted z-10 above the sliding highlight. elementFromPoint confirmed it in Chromium: a mouse click or tap on the checkbox opened the conversation. A selection could only start from the keyboard, which contradicts CONV-F28 and the Home docs. The checkbox now takes the same lift and sits after the link, while still passing under the sticky group heading.

Bulk verbs go out in batches the door accepts (#3733)

  • Selecting 201 rows sent one request, which the door refuses above 200, so nothing changed.
  • The five status verbs now send the selection as consecutive requests of at most BULK_CONVERSATION_LIMIT. This is the same constant the door validates against, in lib/shared.
  • The busy state holds until the last request settles, and a run longer than one request shows its progress: Updating conversations... 200 of 201, new in EN/DE/FR.
  • One toast states the outcome for the whole selection. A refused request counts as failed, and the rows it named stay selected so the verb can be retried on exactly those.
  • The per-request generic failure toast is turned off for these five verbs, because the outcome toast now carries the refusal reason.

Docs and manual layer

  • The Home section of docs/{en,de,fr}/platform/index.md now covers select all, batches, the failed-load state, and how Owners and Admins clear a person or a team.
  • New boxes CONV-F34 (bulk verbs over more than one request) and CONV-B7 (a list that does not load); a clause added to CONV-F28.
  • New rows in reference/automation.md naming the specs that own each automated part.

How I verified it

All six were reproduced on origin/main before any code changed. They were verified again after the fix through native routes and the real UI: a local stack running the real backend with ROLE=api (no worker, so no sends and no agent runs), Vite, a scratch Postgres 16, and Chromium.

Issue Before (main) After
#3708 truncated person or team body → 200, and that assignee was cleared in the DB; {} → 200, cleared truncated/empty → 400 INVALID_JSON; {} → 400 assigneeUserId: is required; DB unchanged
#3732 real picker Unassign sent {"assigneeUserId":null} → 400; person kept → 200; person cleared, team kept; Remove team → 200, team cleared
#3709 forced 403 → "No conversations", no retry 403 (1 attempt) and 503 (4 attempts) → "Couldn't load conversations" + Try again → 30 rows load
#3733 201 selected at 390 px → one POST with 201 ids → 400; all still open 200 + 1 requests → 201 closed; Home Reopen with the second request forced to 503 → "Reopened 200 conversations, 1 failed", that row stays selected, second Reopen → all 201 open
#3734 one row ticked → select all aria-checked="true", a click cleared it mixed → click selects all loaded rows (30) → click again clears; a mouse click on a row's checkbox selects it and does not navigate
#3735 append held before its UPDATE + one through the door → unread 1, older time (metadata, index and projection) the door's append waits for the lock; unread 2, newer time everywhere

Checks run:

  • backend:integration lane checkConversations (real PG 16, run locally; this lane is not a CI job). It gains three checks:

    • an assignment clears only on null, and bodies that name no target change nothing;
    • two overlapping appends;
    • mark as read overlapping an append.

    With main's routes.ts/service.ts/send.ts all three FAIL, with exactly the reported symptoms. With this branch: 24/25 pass. The one failure is the BM25 boot check, which needs pg_search and fails the same way on main.

  • Unit and component tests. Every new test was also run against main's version of its source and fails there:

    • routes.test.ts: 10 of the 18 new cases fail on main. The other 8 are controls: valid ids, typed refusals, and the cap that already existed.
    • conversations.wire.test.ts (the real adapters through the real routes): 4/6 fail on main.
    • service.summary-lock.test.ts + send.test.ts lock cases: 7/7 fail on main.
    • use-cached-paginated-query.test.tsx: 1/3 fail on main.
    • home-inbox-list.test.tsx: 4 of the 6 new select-all and read-failure cases fail on main. The other 2 are controls: each row ticked by hand, and loaded rows kept.
    • use-bulk-actions.test.ts: all 12 new status-verb cases fail on main.
    • home-inbox-list.wire.test.tsx (the real list, selection and bulk hooks down to fetch): 5/6 fail on main.
    • home-panel.browser.test.tsx real-pointer case (Chromium): 2/2 fail on main.
  • vitest related over every changed source file on the final branch (server + client projects), 487 files. In one loaded run, 481 passed and 6 unrelated settings/tasks files hit the 5 s client timeout; run on their own, those 6 pass (137/137). The changed UI tests also pass under vitest.ui.config.ts, and the browser project file passes in Chromium.

  • oxlint --type-aware on the changed files; scoped tsc --noEmit; oxfmt --check; bun run lint:manual; check-guide.ts on conversations.md; the docs suite (services/docs, 35 files); lib/i18n/messages.test.ts. All clean.

  • visual-aspect-analyzer on three changed states (Home Inbox with one row ticked, Home Inbox after a failed read, phone list after a failed read). Main and this branch report the same page-load layout shifts in the view switcher, score 99 on both. No defect is attributable to this change. It does not reach 100 because of that existing shift.

Screenshots (before/after for each issue, the failed-load state in DE and FR, and phone progress) and the probe outputs are attached to the TALE-88 task.

Notes for review

Closes #3708
Closes #3709
Closes #3732
Closes #3733
Closes #3734
Closes #3735

The assignment doors read a body that failed to parse as `{}`, and an
absent field as "unassign": a truncated request answered 200 and took the
conversation away from its person (#3708). The Inbox's own Unassign and
Remove team send `null`, which the doors refused, so an admin could not
clear an assignment at all (#3732).

Each door now takes one required field, the id or `null` (the clear the
REST door's `teamId: null` already documents), and reads its body through
the app door's JSON reader: a truncated or empty body answers 400
`INVALID_JSON`, `{}` answers 400 naming the field, and the assignment is
left as it was. The adapter sends `null` only when the caller asked for
the clear and refuses a missing target before any request; the picker
passes `null` for every clear.

Tests: the doors behind the app JSON reader, the real adapters through
the real routes, the picker's clears, and a `checkConversations` lane on
real Postgres (a clear keeps the other dimension; the refused bodies
change nothing).
Every writer rewrites a conversation's unread count, status stamps and
activity time from a read of the row. Two appends that read the same
unlocked snapshot both committed and the later write won: one unread
message instead of two, and the older message's time (#3735). The send
lane, undo, discard, mark as read, the PATCH door and the bulk verbs
had the same read, so a message landing beside any of them could lose its
count.

Each of them now reads the row FOR UPDATE in the transaction that writes
it back, as the API mirror lane already did, and the one monotonic
`nextConversationLastMessageAt` rule stays the only place activity time
is decided.

Tests: the statement shape of every writer, and two overlaps on real
Postgres in `checkConversations`: an append held before its UPDATE beside
one through the native door, and mark as read beside an append.
A list read whose retries gave up rendered the status's empty state, so
an operator read "No conversations" while the server had answered nothing
(#3709). The Home panel's Inbox view and the phone list now show
"Couldn't load conversations" with Try again in its place; loaded rows stay
on screen. Retry re-issues the request that failed: a refetch reloaded
only the pages already there, so a page that failed after them was never
asked for again.

The new strings ship in EN, DE and FR.
The toolbar's Select all coerced the selection hook's "indeterminate" to
checked, so one ticked row read as all of them and the next click cleared
it (#3734). It now passes the three states through, as the phone list
does, and ticking the mixed box selects the rest.

A row's checkbox sat under the row link, which is lifted above the
sliding highlight, so a click or tap on it opened the conversation and a
selection could only start from the keyboard (CONV-F28). It now takes the
link's lift and comes after it, still under the sticky group heading.
A selection of 201 conversations went out as one request, which the bulk
door refuses above 200, so nothing changed (#3733). The five status verbs
now send the selection in consecutive requests of at most
`BULK_CONVERSATION_LIMIT`, the constant the door validates with. The
busy state holds until the last request settles, and a selection over one
request is counted off. One toast states the whole outcome with a refused
request counted as failed, and the rows a refused request named stay
selected so the verb can be retried on exactly those.

The progress string ships in EN, DE and FR.
The Home docs say how the select-all box reads, that a large selection
goes out in parts and what happens to the rows that fail, what a list
that did not load shows, and how Owners and Admins clear a person or a
team. The manual suite gains CONV-F34 (bulk verbs over more than one
request) and CONV-B7 (a list that does not load), and the automation
register names the specs that own each half.
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Rebased onto 3257d0eff (force-pushed; nobody else works on this branch).

The first head failed only the Browser job, on packages/ui/src/hooks/use-resizable.browser.test.tsx: expect(panel.getBoundingClientRect().width).toBe(width) got 384 against 383.99993896484375. That test had just come into main with #3768, and this branch does not touch it. The run could not be re-run.

After the rebase I re-ran locally the conversation and Home suites (63 files), the Home browser file in Chromium (25/25, twice), the checkConversations real-Postgres lane (the three new checks pass), the docs suite and lint:manual. All 50 CI checks on 151d628d2 are green.

yannickmonney added a commit that referenced this pull request Sep 29, 2026
A failed `useBackendMutation` / `useBackendAction` raises its own
destructive toast unless the call passes `errorToast: false`, and 182
callers on main reported the same failure again: their catch, `.catch`
or `onError` toast, a batch summary toast, `EditorActions` for a
rejected editor `save`, the bulk bars or `EntityDeleteDialog` for a
rejected callback, or a query retrying the write.

The guard parses every app source file with the TypeScript compiler,
indexes each write that toasts on failure (a direct call, a hook
returning one, resolving option-forwarding hooks by their call-site
argument, a hook returning a function that rethrows one, and a hook an
adapter object names), and follows each invocation's rejection through
awaits, returns, rethrowing catches, local functions and their callers
to the place that reports it. It fails on a second toast, naming the
write and the caller. Five pairs stay allowlisted with #3784, which
fixes its bulk verbs; the entries turn stale when it lands.
`.agents/repo.md` states the rule.
…selection-activity

# Conflicts:
#	services/platform/app/features/conversations/components/conversation-assignee-picker.test.tsx
#	services/platform/app/features/conversations/components/conversation-assignee-picker.tsx
#	services/platform/tests/manual/suites/conversations.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment