From a24291edd2dd229dadb62c7591121f3f432be0c7 Mon Sep 17 00:00:00 2001 From: ngqile Date: Wed, 2 Dec 2026 14:43:02 +0800 Subject: [PATCH] docs(i18n): design and OpenSpec change for the Co-Lite labels filter Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs --- ...026-12-02-messages-colite-filter-design.md | 39 +++++++++++++++++++ .../add-messages-colite-filter/.openspec.yaml | 2 + .../add-messages-colite-filter/proposal.md | 36 +++++++++++++++++ .../specs/ui-translations/spec.md | 32 +++++++++++++++ .../add-messages-colite-filter/tasks.md | 29 ++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 docs/superpowers/specs/2026-12-02-messages-colite-filter-design.md create mode 100644 openspec/changes/add-messages-colite-filter/.openspec.yaml create mode 100644 openspec/changes/add-messages-colite-filter/proposal.md create mode 100644 openspec/changes/add-messages-colite-filter/specs/ui-translations/spec.md create mode 100644 openspec/changes/add-messages-colite-filter/tasks.md diff --git a/docs/superpowers/specs/2026-12-02-messages-colite-filter-design.md b/docs/superpowers/specs/2026-12-02-messages-colite-filter-design.md new file mode 100644 index 0000000..b2b2bcc --- /dev/null +++ b/docs/superpowers/specs/2026-12-02-messages-colite-filter-design.md @@ -0,0 +1,39 @@ +# Translations: Co-Lite Labels Only + +Approved by the owner on 2026-12-02. Follow-up to `add-zh-cn-messages` (PR #49). + +## Why + +The Translations screen lists every area-A label, and about 3,400 of them were inherited from Tastefully. Co-Lite never shows those labels. The Missing Chinese filter therefore lists about 1,739 rows, almost none of which matter. This hides the few labels a Chinese reviewer needs to find. + +## Goal + +- The screen shows only the labels Co-Lite uses by default. +- A reviewer can turn that off and see every label, as the screen works today. + +Non-goals: + +- No labels are deleted. +- Export and import are unchanged and still cover every label. + +## Approaches + +1. **The portal sends its list of keys (chosen).** The portal's built-in English list (`defaultMessages.ts`, 706 keys) already defines the labels Co-Lite uses. The portal's server sends those keys with the search, and services-system filters on them in its existing in-memory search. This needs no schema change, and the list stays in the one place it already lives. +2. **A "used by Co-Lite" flag on each row.** The Chinese SQL generator would set the flag. This needs DDL in every environment, and the flag goes stale whenever a label is added without rerunning the SQL. +3. **Filter in the browser.** The page loads all labels and pages through them itself. That means a page rewrite for no extra benefit. + +## Design + +- **Portal page:** a **Co-Lite labels only** checkbox, on by default. Its state lives in the URL filters like the existing filters, so the default URL shows Co-Lite labels only. Search, Missing Chinese and the totals all respect the checkbox. +- **Portal route:** the list route turns the request into `POST /api/admin/messages/search` on mobile-api. It does this because 706 codes do not fit in a query string. + - The body is `{searchKey, missingLocale, page, size, codes}`. + - The route fills `codes` from `DEFAULT_MESSAGES` on the server; the browser never sends codes. + - The route sends no codes when the checkbox is off. +- **mobile-api:** `POST /api/admin/messages/search` (module `BO_MESSAGES`) passes the filters and `codes` to services-system with area A. + - `codes` must be a list of strings, at most 5,000 entries; otherwise the request is refused with 400. + - The existing `GET /api/admin/messages` stays as it is. +- **services-system:** `MessageSearchRequest.codes`. When it is present, only rows whose code matches one of the codes, ignoring case, are kept. Case is ignored because the database's unique code index ignores case. + +## Left to the builder + +The exact label wording, in English and Chinese, for the checkbox. diff --git a/openspec/changes/add-messages-colite-filter/.openspec.yaml b/openspec/changes/add-messages-colite-filter/.openspec.yaml new file mode 100644 index 0000000..eb2b21e --- /dev/null +++ b/openspec/changes/add-messages-colite-filter/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-12-02 diff --git a/openspec/changes/add-messages-colite-filter/proposal.md b/openspec/changes/add-messages-colite-filter/proposal.md new file mode 100644 index 0000000..cb79e91 --- /dev/null +++ b/openspec/changes/add-messages-colite-filter/proposal.md @@ -0,0 +1,36 @@ +## Why + +The Translations screen lists about 3,400 area-A labels inherited from Tastefully that Co-Lite never shows. Because of them, the Missing Chinese filter lists about 1,739 rows, which hides the few labels a Chinese reviewer needs to find. The owner decided on 2026-12-02 to ship `add-zh-cn-messages` first and add this filter as a follow-up. + +## What Changes + +- **Translations page:** a "Co-Lite labels only" checkbox, on by default. It limits the list, the search and the Missing Chinese filter to the labels in the portal's built-in English list (`DEFAULT_MESSAGES`). Turning it off shows every label, as before. +- **Portal route:** the route builds the code list on the server and calls a new search endpoint in mobile-api. +- **mobile-api:** `POST /api/admin/messages/search` (module `BO_MESSAGES`) takes the filters and an optional list of codes. +- **services-system:** the message search takes an optional list of codes and matches them ignoring case. +- Export and import are unchanged. No label is deleted, and no schema changes. + +## Capabilities + +### New Capabilities + +None. + +### Modified Capabilities + +- `ui-translations`: the Translations page can be limited to the labels Co-Lite uses. This capability is introduced by `add-zh-cn-messages`, which is merged but not yet archived, so this change adds a requirement instead of modifying one. + +## Impact + +- **services-system:** `MessageSearchRequest` and `MessageService.search`. +- **mobile-api:** + - `AdminMessageController`: a new POST mapping; + - `AdminTranslationService.search`: a new codes parameter. +- **Portal:** + - `app/api/messages/[[...path]]/route.ts`; + - `app/lib/services/translations.ts`; + - `app/messages/page.tsx`; + - two new labels in `defaultMessages.ts` and `zh_CN.seed.json`, so the Chinese SQL is regenerated. +- **Deploy:** `add-zh-cn-messages/sql/03-zh-cn-messages.sql` is regenerated and now also includes the two new labels. An environment that has already run 03 must not run it again, because it would overwrite reviewed Chinese. It runs this change's `sql/01-colite-filter-labels.sql` instead, which holds only the two new labels and is built by the same generator. The deployment doc states which file to run. + +Design: `docs/superpowers/specs/2026-12-02-messages-colite-filter-design.md`. diff --git a/openspec/changes/add-messages-colite-filter/specs/ui-translations/spec.md b/openspec/changes/add-messages-colite-filter/specs/ui-translations/spec.md new file mode 100644 index 0000000..fc3e356 --- /dev/null +++ b/openspec/changes/add-messages-colite-filter/specs/ui-translations/spec.md @@ -0,0 +1,32 @@ +## ADDED Requirements + +### Requirement: Translations Can Be Limited To Co-Lite Labels + +The Translations page SHALL offer a "Co-Lite labels only" checkbox, on by default, that limits the list, the search and the "Missing Chinese" filter to the labels in the portal's built-in English list. Codes SHALL match ignoring case. Turning the checkbox off SHALL list every back-office label. + +#### Scenario: Inherited labels hidden by default + +- **GIVEN** a back-office label "OrderPayment" that is not in the portal's built-in list, and a label "Leads" that is +- **WHEN** the user opens the Translations page +- **THEN** "Leads" is listed and "OrderPayment" is not +- **AND** "Co-Lite labels only" is checked + +#### Scenario: Missing Chinese counts only Co-Lite labels + +- **GIVEN** every label in the built-in list has Chinese and some inherited labels have none +- **WHEN** the user turns on "Missing Chinese" with "Co-Lite labels only" checked +- **THEN** no label is listed + +#### Scenario: Every label on request + +- **WHEN** the user unchecks "Co-Lite labels only" +- **THEN** "OrderPayment" is listed too + +### Requirement: The Co-Lite Code List Comes From The Portal Server + +The portal's server SHALL build the Co-Lite code list from its built-in list and SHALL NOT take codes from the browser. mobile-api SHALL refuse with 400 a code list that is not a list of strings or holds more than 5,000 entries. Export and import SHALL keep covering every back-office label. + +#### Scenario: Code list too long + +- **WHEN** mobile-api receives a search with 5,001 codes +- **THEN** it answers 400 and does not call services-system diff --git a/openspec/changes/add-messages-colite-filter/tasks.md b/openspec/changes/add-messages-colite-filter/tasks.md new file mode 100644 index 0000000..08a301c --- /dev/null +++ b/openspec/changes/add-messages-colite-filter/tasks.md @@ -0,0 +1,29 @@ +# Tasks: add-messages-colite-filter + +Design: `docs/superpowers/specs/2026-12-02-messages-colite-filter-design.md`. Every task is TDD. The owner said no workers, so everything runs serially in the main session with a self-review per task. + +## 1. services-system + +- [ ] 1.1 `MessageSearchRequest.codes`; when present, `MessageService.search` keeps only rows whose code matches one of the codes, ignoring case. Existing filters and paging still apply. + - Verify: `mvn -T 1C -B -q -pl solvway-services-system -am verify` + +## 2. mobile-api + +- [ ] 2.1 `POST /api/admin/messages/search` (module `BO_MESSAGES`) with the body `{searchKey, missingLocale, page, size, codes}`. `AdminTranslationService.search` forwards `codes` with area A. A `codes` value that is not a list of strings, or that holds more than 5,000 entries, gets 400 without calling services-system. + - Verify: `mvn -T 1C -B -q -pl solvway-mobile-api -am verify` + +## 3. Portal + +- [ ] 3.1 The list route posts to the new endpoint. It sends `codes` built on the server from `DEFAULT_MESSAGES` keys, unless the request asks for all labels. +- [ ] 3.2 Translations page: a "Co-Lite labels only" checkbox, on by default, kept in the list filters. Add its labels to `defaultMessages.ts` and `zh_CN.seed.json`, then regenerate the Chinese SQL. Write this change's `sql/01-colite-filter-labels.sql` with the new labels only. + - Verify (3.1 and 3.2): `cd solvway-admin-portal && npx vitest run; echo VITEST=$? && npx tsc --noEmit && npm run lint` + +## 4. Release + +- [ ] 4.1 `docs/deployment.md`: replace the follow-up note with the checkbox, and say which SQL file to run. +- [ ] 4.2 Live Playwright check on the local stack: the default list hides inherited labels, Missing Chinese shows close to zero, and unchecking the box shows every label. +- [ ] 4.3 Self-review, the PR to main and the merge. + +## Workflow follow-up + +- Archive after `add-zh-cn-messages`, because this change adds a requirement to the `ui-translations` capability that change introduces.