Skip to content

fix(platform): narrow the contacts list by its locale filter - #4207

Merged
yannickmonney merged 2 commits into
mainfrom
fix/contacts-locale-filter
Oct 4, 2026
Merged

yannickmonney merged 2 commits into
mainfrom
fix/contacts-locale-filter

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

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:listContactsPaginated sent and keyed only search and source. It now sends locale on every page, cursor pages included, and adds it to the query key, so each facet gets its own cache entry (still under the contact entity that writes invalidate).

  • App door (backend/domains/contacts/routes.ts): GET /api/app/contacts never read locale. It now parses it as an open set, the way it treats search and tag (capped at CONTACT_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): listContacts takes locale and matches it the way RFC 4647 basic filtering matches a language range, case-insensitively and with _ read as -:

    • fr lists fr, FR, fr-CH and fr_CA.
    • fr-CH lists only itself.
    • f and de list nothing.

    The comparison is bound and uses starts_with, not LIKE, so a value has no wildcards to escape. Exact equality, which 0.4 Convex used, isn't enough here: the form suggests en-US and imports take any BCP 47 tag, so the facet's bare DE would miss de-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:

  • Adapter, door and service: 7 of 7 new tests failed. The request was /api/app/contacts?limit=20&orgId=org1 with no locale, the door returned 200 for an over-long locale, and the SQL had no locale predicate.
  • contact-table.wire.test.tsx (the real useListContactsPaginated → adapter → backendFetch path, with only fetch answered): 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 guards (integration-scope, integration-skips, binding-doors): pass.
  • Docs locale and structure suites (services/docs): 6 files, 14 tests pass.
  • bun run lint:manual: passes.
  • oxlint --type-aware and oxfmt --check on the changed files: clean.

Real Postgres (local): I ran the patched listContacts through 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-stored zh-Hans-CN.
  • f, de, %' → nothing; a blank value applies no filter.
  • fr + file_upload → FR_ca, fr-CH.
  • Another org's rows and trashed rows stay out, and the keyset cursor keeps the filter on page 2.

In CI: a new backend:integration probe in the contacts lane does the same through the real app door. It seeds fr, fr-CH, FR_ca, en-US and en, checks each facet, then trashes the rows.

Not run locally:

  • The full platform suite and the whole-program tsc. CI runs them; a scoped tsc over the changed files found nothing in them. It only failed in unchanged contact-table.tsx, whose router types the scoped program leaves out.
  • backend:integration itself.
  • Picking the facet in a real browser, which stays manual per the register row.

Closes #3618

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
yannickmonney added a commit that referenced this pull request Oct 4, 2026
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 yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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-character CONTACT_LOCALE_MAX cap 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_with introduces 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 suggests en-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-CH lists “only itself.” RFC-style prefix filtering also includes a stored more-specific tag such as fr-CH-x-test, which the open REST schema permits. The implementation is correct; the wording means the fr-CH subtree, excluding fr/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 attached routes-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 whose eventsource-parser dependency 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.

@yannickmonney
yannickmonney merged commit 32dfe31 into main Oct 4, 2026
@yannickmonney
yannickmonney deleted the fix/contacts-locale-filter branch October 4, 2026 04:50
@yannickmonney

Copy link
Copy Markdown
Contributor Author

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 01879aef-d562-4abd-b5b5-2b3bdf431a89, on origin/main d29a3c8fe.

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:

  • 23 × fr (3 of them uploads), plus FR, fr-CH (an upload) and fr_CA;
  • en ×2 and en-US;
  • de-DE;
  • one without a locale.
Step on Contacts › Filter List requests Rows Matches the RFC 4647 expectation
none ?limit=20, then a cursor page 31 ✓
Locale = FR locale=fr on the first and the cursor page; URL ?locale=fr 26 (fr ×23, FR, fr-CH, fr_CA) ✓
Reload (same) 26 ✓
+ Source = Upload source=file_upload&locale=fr 4 ✓
Source off, Locale = DE locale=de; URL ?locale=de 1 (de-DE) ✓
Locale off all pages 31 of 31 ✓

There were no console errors and no failed API calls.

Evidence is in TALE-358's r20261004T0815 deliverables: the probe scripts/c1-contacts-locale-facet.ts, evidence/c1-contacts-locale-facet.log and screenshots in evidence/c1/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Contacts Locale filter does not affect its request, cache key or rows

1 participant