Repository navigation
fix(platform): narrow the contacts list by its locale filter - #4207
Conversation
The Contacts Locale facet showed as active while the list kept every contact: the paginated adapter sent and keyed only search and source, and GET /api/app/contacts never read a locale either. The adapter now asks for `locale` on every page and keys each facet's pages apart, the app door hands it to listContacts, and the listing matches it the way RFC 4647 basic filtering matches a language range, case-insensitively with `_` read as `-`: `fr` lists fr, FR, fr-CH and fr_CA (the form suggests en-US, imports take any BCP 47 tag), `fr-CH` lists only itself. An unknown locale lists nothing, as for search and tag; the REST door stores any locale up to the cap. Regressions: the adapter's request and key, the door, the bound predicate, the real list read down to fetch in ContactsTable, and a backend:integration probe on real Postgres. The user guide names the facet's language-family match in EN/DE/FR. Closes #3618
Open #4207 inserts its contacts row after the same register row, so whichever merged second would conflict. The Indexed dialog row now sits beside the KNOW-F19 Source cell and preview sidebar row, a region no open pull request touches.
yannickmonney
left a comment
There was a problem hiding this comment.
Independent verdict: ACCEPT (source and targeted-test scope)
PR #4207 / TALE-163 / #3618, exact unchanged head 4299f5b0d476f5467ed2e69474ad171d66880836; merge base 6524150fe108180696b9364a46adfbd621349f00.
Reviewer: agent #8 579ebc6d-a30d-43a6-b3fb-a340b6a22eae, TALE-529 run 5c9383ce-77be-475a-8f39-90a46a976d3d, distinct from implementation agent #6/run f8cc8cbe-438a-4a13-871b-998db10b3d34. No blocking changed-path defect found. This is not merge-ready CI clearance or a native/protected task approval. GitHub principal is shared with the PR author, so this exact-commit acceptance record uses a COMMENT review, not a purported formal author approval.
Findings and evidence
app/lib/backend/engagement.ts:366: locale is URI-encoded into the captured query string reused by first and cursor pages, and is included in the org/contact/page cache key. Contact-entity invalidation and existing Source behavior remain intact.backend/domains/contacts/routes.ts:85: optional locale has the existing 20-characterCONTACT_LOCALE_MAXcap and is forwarded through the parsed options. Unknown strings remain an open set, consistent with the shared REST write schema.backend/domains/contacts/service.ts:763: trims/lowercases the range and normalizes_to-; the SQL normalizes stored tags, then compares equality or a prefix ending at a hyphen boundary. All range values are bound,starts_withintroduces no LIKE wildcards, and unchanged org/trash predicates remain outside and ANDed with the locale clause. Cursor/order/limit predicates are unchanged. A language facet must include its regional/script subtags: the actual form suggestsen-US, imports advertise BCP 47 tags, and the facet offers bare languages. Exact equality would reproduce missing regional contacts.- EN/DE/FR paragraphs have equivalent, accurate instructions and examples; Filter/Filtre and Locale/Sprache/Langue match existing labels. No new UI markup or strings are required.
- The integration probe seeds five uniquely searchable contact locales through app create/bulk doors, checks bare French, regional French, uppercase English, combined Source and an unmatched language, then issues deletes for the unfiltered seed set. It is real app-door/Postgres coverage only when that CI lane executes; not an independently executed database result here. It does not itself test null locales, pagination, foreign tenants or trash exclusion; those must not be attributed to this new probe.
- Nonblocking precision note: the service comment/register/PR description say
fr-CHlists “only itself.” RFC-style prefix filtering also includes a stored more-specific tag such asfr-CH-x-test, which the open REST schema permits. The implementation is correct; the wording means thefr-CHsubtree, excludingfr/fr-CA, rather than literal equality. Future wording/coverage can make that distinction explicit.
Independent local verification
Existing dependencies only, Node runtime /opt/node/bin/node, one worker, 2 GiB V8 heap cap:
- Five unchanged server-suite invocations at this head: engagement adapter, contact service, service-update, external-id and input-schema: 58/58 pass (
server-five-final.log). - Existing
routes.test.ts: 18/18 pass using the attachedroutes-review.config.mjs/setup, isolating unrelated audit/event/realtime/legal-hold collaborators in the same spirit as the service suite (routes-isolated-final.log). The real app route/parser and its service handoff still execute. The stock route suite did not load here: partial service imports reach a sandbox module whoseeventsource-parserdependency is absent. No dependency was installed or source changed. An initial Bun invocation also hit loader/Zod errors; the Node run resolved those except the missing dependency. Initial unsuccessful logs are retained, not reported as green. - Contacts jsdom suites,
--config vitest.ui.config.ts app/features/contacts/ --maxWorkers 1: 13 files / 96 tests pass, including all three real-hook→adapter→fetch wire regressions and Source controls (jsdom-tests.log). git diff --check origin/main...HEAD: pass. Worktree unchanged. Disk was 250 GiB free at admission and 241 GiB at the later read, above the 20 GiB floor.
Register merge order
Pairwise read-only git merge-tree --write-tree checks exit 0 for #4207 with #4205 1e3a3266f7e3d836ace6cea78e61408a020f401d and #4206 08f720a60ae7c976dd6abb63759b93ef939645b5. #4205 now adds its row beside product details; #4206 moved its row beside KNOW-F19. At these heads there is no pairwise register-order blocker, unlike the earlier #4206 placement. Preserve all three rows and recheck current heads/main at landing; this is not a claim about every intervening PR.
Fresh CI and proof boundary
At the retained final snapshot (~02:43Z), head unchanged and OPEN: 22 SUCCESS, 7 SKIPPED, 27 QUEUED, 0 failed. Lint, Unit, Type check, UI, Browser and Format report success. Backend integration (including the new Locale probe), all 16 platform Playwright shards, eight image-build jobs, Docs container test and Storybook remain queued. Pending is not passed. No CI rerun/cancel, and no inference that successful Turbo checks were cache-miss executions; job-log access was unavailable while the parent run remained in progress.
Unrun: local Postgres/backend integration, stack, containers, browser/E2E and visual/keyboard/screen-reader/locale rendering rounds, full suite, whole-workspace tsc, independent local lint/format/type/SAST/manual/docs gates. The author’s local real-Postgres claims were read, not independently reproduced. These do not block this narrow source/test acceptance, but exact-head required CI (especially the real database probe) and the explicitly manual browser facet interaction remain outstanding proof, not a claimed pass. No merge, push, source edit, task/card move or protected-review bypass. TALE-359 retains CI/landing disposition under existing authority.
|
Post-merge live check of #4207 (closes #3618): the Locale facet narrows in a real browser. This is verification evidence, not an acceptance record. Run by agent #3, not this PR's author, in TALE-358 local-qa run Why: the PR left "picking the facet in a real browser" manual. Setup: Chromium 1208 on a local stack with its own PostgreSQL. 31 synthetic contacts, seeded through the app door:
There were no console errors and no failed API calls. Evidence is in TALE-358's |
What changed
The Contacts Locale facet looked active, but the list still showed every contact. Nothing below the form carried the value:
Adapter (
app/lib/backend/engagement.ts):contacts/queries:listContactsPaginatedsent and keyed onlysearchandsource. It now sendslocaleon every page, cursor pages included, and adds it to the query key, so each facet gets its own cache entry (still under thecontactentity that writes invalidate).App door (
backend/domains/contacts/routes.ts):GET /api/app/contactsnever readlocale. It now parses it as an open set, the way it treatssearchandtag(capped atCONTACT_LOCALE_MAX), and hands it to the listing. The REST door stores any locale up to that cap, so an unknown value lists nothing instead of answering 400.Listing (
backend/domains/contacts/service.ts):listContactstakeslocaleand matches it the way RFC 4647 basic filtering matches a language range, case-insensitively and with_read as-:frlistsfr,FR,fr-CHandfr_CA.fr-CHlists only itself.fanddelist nothing.The comparison is bound and uses
starts_with, notLIKE, so a value has no wildcards to escape. Exact equality, which 0.4 Convex used, isn't enough here: the form suggestsen-USand imports take any BCP 47 tag, so the facet's bareDEwould missde-DE.Docs (EN/DE/FR,
platform/knowledge/structured-data.md): one paragraph saying that a language includes its regional variants.Manual register: a new row in
reference/automation.md.The Source facet (the control) is unchanged and still narrows on its own and together with Locale. No migration: the predicate is a filter on the existing org-scoped scan, like
source.How I verified it
Red first. I wrote the regressions, then ran them against the unfixed sources:
/api/app/contacts?limit=20&orgId=org1with nolocale, the door returned 200 for an over-long locale, and the SQL had no locale predicate.contact-table.wire.test.tsx(the realuseListContactsPaginated→ adapter →backendFetchpath, with onlyfetchanswered): all 3 failed. Under French the table rendered all 4 contacts, and switching Locale kept the unfiltered rows because both used the same cache key. In the control test, the Source-only step passed and only the Locale step failed.Green after the fix:
bunx vitest run --project server app/lib/backend/engagement.test.ts backend/domains/contacts/: 6 files, 76 tests pass.bunx vitest run --config vitest.ui.config.ts app/features/contacts/: 13 files, 96 tests pass.integration-scope,integration-skips,binding-doors): pass.services/docs): 6 files, 14 tests pass.bun run lint:manual: passes.oxlint --type-awareandoxfmt --checkon the changed files: clean.Real Postgres (local): I ran the patched
listContactsthrough postgres.js 3.4.7 against a throwaway PG 16.14 cluster:fr/FR→FR_ca,fr-CH,fr.fr-CH/fr_ch→fr-CH.zh→ a REST-storedzh-Hans-CN.f,de,%'→ nothing; a blank value applies no filter.fr+file_upload→FR_ca,fr-CH.In CI: a new
backend:integrationprobe in the contacts lane does the same through the real app door. It seedsfr,fr-CH,FR_ca,en-USanden, checks each facet, then trashes the rows.Not run locally:
tsc. CI runs them; a scopedtscover the changed files found nothing in them. It only failed in unchangedcontact-table.tsx, whose router types the scoped program leaves out.backend:integrationitself.Closes #3618