Co-authored-by: nova28 <17953305+nova28@users.noreply.github.com> Co-authored-by: Carlos Florencio <carlosmflorencio@gmail.com>
6.0 KiB
id, title, status, wave, depends_on, plan, requirements, acceptance_criteria, system_design
| id | title | status | wave | depends_on | plan | requirements | acceptance_criteria | system_design | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 01-wire-adapter | camelCase/snake_case adapter and cron-reconcile control flow | done | 0 | plan.md |
|
|
|
Task 01: camelCase/snake_case adapter and cron-reconcile control flow
Summary
The routines UI sent and read camelCase against a snake_case backend contract, so multi-word fields (assignee, policies, task template, cron schedule, declared variables) were silently discarded on write and rendered as blanks, placeholders, or one character per line on read, and a cron trigger could not be armed at all. This task adds a single adapter pair at the client's API boundary — a request builder that emits the contract's exact snake_case keys and a response normalizer that produces camelCase models with no snake_case fallback and no unchecked cast — plus the cron-reconcile control flow that replaces an armed trigger correctly when its schedule changes.
In scope
apps/web/lib/api/domains/office-routine-api.ts: request builders for create/update routine and create routine trigger, emitting only the keys and shapesapps/backend/internal/office/routines/dto.gobinds.apps/web/lib/api/domains/office-routine-normalize.ts: the response-side adapter — envelope unwrap, JSON-string decode fortask_templateandvariables, and the routine/trigger/run camelCase mapping.apps/web/lib/api/domains/office-api.ts: wires the two modules above into the existing exported API surface.apps/web/app/office/routines/[id]/cron-reconcile.ts: create-before-delete trigger replacement, the two-cron-trigger warning, and the failed-relist message.apps/web/app/office/routines/{routine-row.tsx, routines-content.tsx, create-routine-dialog.tsx, [id]/routine-detail-view.tsx, [id]/page.tsx},apps/web/app/office/agents/[id]/layout.tsx,apps/web/app/office/lib/catch-up-max.ts,apps/web/src/office-routine-client-routes.tsx: consume model-shape fields exclusively;create-routine-dialog.tsx'sonSubmitreturnsPromise<boolean>so a rejected create leaves the dialog open.apps/web/app/office/routines/routine-wire-scan.test.ts: the static no-snake_case / no-as unknown asscan required by AC-003.10, and the closed-set assertion required by AC-003.18.apps/web/src/locales/{en,pt-pt,zh-cn,zh-hk,zh-tw,pseudo}/office.json: the new trigger-replacement and stale-schedule toast copy (AC-002.12).apps/web/e2e/tests/office/routines-ui.spec.tsand the routine catch-up/fire/agentctl-cli E2E suites touched by the model-shape change.
Acceptance
Every acceptance criterion under REQ-OFFICE-ROUTINE-WIRE-001 through REQ-OFFICE-ROUTINE-WIRE-004 in the requirements, listed in this file's frontmatter.
Verification
cd apps/web
pnpm run typecheck
pnpm run lint
pnpm run test -- app/office/routines lib/api/domains/office-routine-api.test.ts lib/api/domains/office-routine-normalize.test.ts
pnpm run i18n:ratchet
pnpm run i18n:check
pnpm run build
pnpm run e2e:run -- routines-ui routine-catch-up-policy-ui routine-fire
Files likely touched
See ## In scope above; full diff stat against the branch's merge-base:
git diff --stat $(git merge-base HEAD origin/main)..HEAD.
Dependencies
None — single task, single wave.
Parallelism
Not applicable: the request builder, response adapter, and the components that consume them change together behind one contract.
Results
Shipped on feature/routines-ui-camelcas-rf9. Four independent review
rounds (code-reviewer, security-reviewer, test-supervisor, and a
cross-vendor outside voice) converged with no residual defect. The final
round's one verified new finding — a React crash on a non-string
task_template.title/.description, reachable only because this branch is
the first time that field's content reaches JSX — was fixed with a
templateText guard and regression test. A second, pre-existing
finding surfaced by that same round's test work — the create dialog
resetting and losing the operator's input on a rejected createRoutine call
— was fixed by making onSubmit report success/failure and only
closing/resetting on success, with regression coverage in
routines-content.test.tsx.