refactor(front): one page file per route, leaner Room services, tests on the real route tree #534

Merged
root merged 8 commits from claude/spec-408-implementation-3f8d53 into main 2026-10-15 15:17:47 +00:00
root commented 2026-10-15 13:17:08 +00:00 (Migrated from gitlab.core-project.space)

Summary

The front's rules as the owner decided (ADR 0043 supersedes 0011), and the refactor they allow. Nothing a Player sees changes.

 apps/front/src/<vertical>/
-├── <name>.view.tsx          # hooks, queries, mutations
-├── <name>.ui.tsx            # layout only
+├── <name>.page.tsx          # one page file per route: hooks + layout
 ├── components/              # presentational; still no Query/zustand/oRPC; may use @/lib/form
+├── <name>.widget.tsx        # connected piece that is not a route
 └── <name>.harness.tsx       # mounts the app's router via @/app/router.harness

 apps/front/src/room/
 ├── services/                # 11 files → 5
+│   ├── room-query.ts        # query + invalidation
+│   ├── room-mutations.ts    # create, leave, resign, offers
 │   ├── move-mutation.ts     # the Move alone; ADR 0019 exception unchanged
 │   ├── enter-room.ts
+│   └── refusal.ts           # toast + write handler
 └── hooks/                   # 6 files → 5
+    └── use-room-announcements.ts   # offers + new opponent, was two hooks
  • #414 rules and lint: front/view-is-composition deleted; routes import page files, services/ and exported constants; @/routeTree.gen only from app/; widgets for connected non-route pieces.
  • #415 13 *.page.tsx replace 26 view/UI files; not-found screens import directly.
  • #416 Room services by concept.
  • #417 auth, games and home tests mount the app's own route tree; no test re-declares a loader or search validator.

Evidence

  • Before: view tests mounted hand-built trees (auth.harness, games.harness, home.test re-declared /games' loader, /account's search validator, profile params…).
    After: they mount the app's router through @/app/router.harness. Gate green on Node 24: lint, typecheck, test (engine 742, api 826, front 1385), build, format:check.
  • Lint-plugin test (S1): page importing Query → passes; component importing Query or a page → fails; route importing a sibling's internals → fails; page/component/route importing @/routeTree.gen → fails; a component importing a widget → fails; a test importing @/app/router.harness → passes, any other app/ file → fails.

Merge Danger

Door: two-way

Blast Radius: front-structure

Refactor and rule edits only. Where a test changed beyond its mount, it follows from the real tree:

  • home "asks no server for anything": spies every fetch and allows only the site frame's /rpc/account and /rpc/devtools reads, once each.
  • waitFor around five landing checks (sign-in, sign-up ×2, reset-password, account delete) and home's "create called once": navigation now settles a tick later. Same values.
  • My games empty state reads links inside <main>, since the site frame adds its own.

Owner decisions folded in

  • A connected piece that is not a route is a <name>.widget.tsx: auth/account-nav.widget.tsx (site frame) and auth/claim-banner.widget.tsx (My games). Routes and app/ may import widgets; components/ may not.
  • Vertical tests and harnesses mount the app's router through @/app/router.harness, their one allowed app/ import. lib/routes.harness.tsx is deleted, and only app/ imports @/routeTree.gen.

Proposed rule changes

  • .agents/skills/to-spec/SKILL.md still gives "front tests go through the view" as an example; should read "the page".

Closes #408
Closes #414
Closes #415
Closes #416
Closes #417

## Summary The front's rules as the owner decided (ADR 0043 supersedes 0011), and the refactor they allow. Nothing a Player sees changes. ```diff apps/front/src/<vertical>/ -├── <name>.view.tsx # hooks, queries, mutations -├── <name>.ui.tsx # layout only +├── <name>.page.tsx # one page file per route: hooks + layout ├── components/ # presentational; still no Query/zustand/oRPC; may use @/lib/form +├── <name>.widget.tsx # connected piece that is not a route └── <name>.harness.tsx # mounts the app's router via @/app/router.harness apps/front/src/room/ ├── services/ # 11 files → 5 +│ ├── room-query.ts # query + invalidation +│ ├── room-mutations.ts # create, leave, resign, offers │ ├── move-mutation.ts # the Move alone; ADR 0019 exception unchanged │ ├── enter-room.ts +│ └── refusal.ts # toast + write handler └── hooks/ # 6 files → 5 + └── use-room-announcements.ts # offers + new opponent, was two hooks ``` - #414 rules and lint: `front/view-is-composition` deleted; routes import page files, `services/` and exported constants; `@/routeTree.gen` only from `app/`; widgets for connected non-route pieces. - #415 13 `*.page.tsx` replace 26 view/UI files; not-found screens import directly. - #416 Room services by concept. - #417 auth, games and home tests mount the app's own route tree; no test re-declares a loader or search validator. ## Evidence - **Before:** view tests mounted hand-built trees (`auth.harness`, `games.harness`, `home.test` re-declared `/games`' loader, `/account`'s search validator, profile params…). **After:** they mount the app's router through `@/app/router.harness`. Gate green on Node 24: lint, typecheck, test (engine 742, api 826, front 1385), build, format:check. - Lint-plugin test (S1): page importing Query → passes; component importing Query or a page → fails; route importing a sibling's internals → fails; page/component/route importing `@/routeTree.gen` → fails; a component importing a widget → fails; a test importing `@/app/router.harness` → passes, any other `app/` file → fails. ## Merge Danger **Door:** two-way **Blast Radius:** front-structure Refactor and rule edits only. Where a test changed beyond its mount, it follows from the real tree: - home "asks no server for anything": spies every `fetch` and allows only the site frame's `/rpc/account` and `/rpc/devtools` reads, once each. - `waitFor` around five landing checks (sign-in, sign-up ×2, reset-password, account delete) and home's "create called once": navigation now settles a tick later. Same values. - My games empty state reads links inside `<main>`, since the site frame adds its own. ### Owner decisions folded in - A connected piece that is not a route is a `<name>.widget.tsx`: `auth/account-nav.widget.tsx` (site frame) and `auth/claim-banner.widget.tsx` (My games). Routes and `app/` may import widgets; `components/` may not. - Vertical tests and harnesses mount the app's router through `@/app/router.harness`, their one allowed `app/` import. `lib/routes.harness.tsx` is deleted, and only `app/` imports `@/routeTree.gen`. ## Proposed rule changes - `.agents/skills/to-spec/SKILL.md` still gives "front tests go through the view" as an example; should read "the page". Closes #408 Closes #414 Closes #415 Closes #416 Closes #417
project_1_bot_a8dd9262857d850eef8dca5206e61de5 commented 2026-10-15 13:20:37 +00:00 (Migrated from gitlab.core-project.space)

Screenshots

Before is production, after is this merge request's review app at f9f53ad.

Desktop

Page Before After
Home
Local game
Room

Mobile

Page Before After
Home
Local game
Room
<!-- chess-screenshots --> ### Screenshots Before is production, after is this merge request's review app at f9f53ad. #### Desktop | Page | Before | After | | --- | --- | --- | | Home | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1377/artifacts/raw/review-screenshots/before/home-desktop.png" width="400"> | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1377/artifacts/raw/review-screenshots/after/home-desktop.png" width="400"> | | Local game | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1377/artifacts/raw/review-screenshots/before/local-desktop.png" width="400"> | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1377/artifacts/raw/review-screenshots/after/local-desktop.png" width="400"> | | Room | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1377/artifacts/raw/review-screenshots/before/room-desktop.png" width="400"> | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1377/artifacts/raw/review-screenshots/after/room-desktop.png" width="400"> | #### Mobile | Page | Before | After | | --- | --- | --- | | Home | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1377/artifacts/raw/review-screenshots/before/home-mobile.png" width="200"> | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1377/artifacts/raw/review-screenshots/after/home-mobile.png" width="200"> | | Local game | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1377/artifacts/raw/review-screenshots/before/local-mobile.png" width="200"> | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1377/artifacts/raw/review-screenshots/after/local-mobile.png" width="200"> | | Room | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1377/artifacts/raw/review-screenshots/before/room-mobile.png" width="200"> | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1377/artifacts/raw/review-screenshots/after/room-mobile.png" width="200"> |
root commented 2026-10-15 13:27:15 +00:00 (Migrated from gitlab.core-project.space)

added 2 commits

  • 7e2d65c9 - refactor(front): merge each route's view and UI into one page file
  • 43e5989f - chore(front): drop the transitional view allowances from the lint config

Compare with previous version

added 2 commits <ul><li>7e2d65c9 - refactor(front): merge each route&#39;s view and UI into one page file</li><li>43e5989f - chore(front): drop the transitional view allowances from the lint config</li></ul> [Compare with previous version](/amaurycoudr/chess-project/-/merge_requests/34/diffs?diff_id=224&start_sha=0818df5e7ae6f40d859114c9cbb5ff23be205ece)
root commented 2026-10-15 13:30:25 +00:00 (Migrated from gitlab.core-project.space)

added 1 commit

  • 7263e908 - refactor(front): group the Room's services by concept and merge its announcement hooks

Compare with previous version

added 1 commit <ul><li>7263e908 - refactor(front): group the Room&#39;s services by concept and merge its announcement hooks</li></ul> [Compare with previous version](/amaurycoudr/chess-project/-/merge_requests/34/diffs?diff_id=226&start_sha=43e5989fd7818de79430035bfde0e9a6c9354d31)
root commented 2026-10-15 13:37:05 +00:00 (Migrated from gitlab.core-project.space)

added 2 commits

  • 42ee1332 - test(front): render the auth, games and home view tests on the app's route tree
  • e1a1872e - Merge branch 'claude/spec-408-implementation-3f8d53' into worktree-agent-ad96c6f38065c53bc

Compare with previous version

added 2 commits <ul><li>42ee1332 - test(front): render the auth, games and home view tests on the app&#39;s route tree</li><li>e1a1872e - Merge branch &#39;claude/spec-408-implementation-3f8d53&#39; into worktree-agent-ad96c6f38065c53bc</li></ul> [Compare with previous version](/amaurycoudr/chess-project/-/merge_requests/34/diffs?diff_id=228&start_sha=7263e9087d505beba0643099dc61879d2c88a547)
root commented 2026-10-15 13:47:31 +00:00 (Migrated from gitlab.core-project.space)

added 1 commit

  • 31b760f4 - fix(front): address the spec 408 review: home I/O check, route-tree lint, auth link

Compare with previous version

added 1 commit <ul><li>31b760f4 - fix(front): address the spec 408 review: home I/O check, route-tree lint, auth link</li></ul> [Compare with previous version](/amaurycoudr/chess-project/-/merge_requests/34/diffs?diff_id=230&start_sha=e1a1872e4dddc7abb3f8579162ffb2c06e4a7525)
root commented 2026-10-15 13:48:11 +00:00 (Migrated from gitlab.core-project.space)

changed the description

changed the description
root commented 2026-10-15 13:54:38 +00:00 (Migrated from gitlab.core-project.space)

marked this merge request as ready

marked this merge request as **ready**
root commented 2026-10-15 14:14:09 +00:00 (Migrated from gitlab.core-project.space)

added 8 commits

  • 68c95e41 - 1 commit from branch main
  • a37c5c0f - feat(front): one page file per route in the front's rules and lint
  • 30b3ae60 - refactor(front): merge each route's view and UI into one page file
  • 2a892714 - chore(front): drop the transitional view allowances from the lint config
  • 605fbf62 - test(front): render the auth, games and home view tests on the app's route tree
  • 1369dbd8 - refactor(front): group the Room's services by concept and merge its announcement hooks
  • 9de3d0d7 - fix(front): address the spec 408 review: home I/O check, route-tree lint, auth link
  • 8ec9c87d - refactor(front): add the widget suffix and mount vertical tests on the app's router

Compare with previous version

added 8 commits <ul><li>68c95e41 - 1 commit from branch <code>main</code></li><li>a37c5c0f - feat(front): one page file per route in the front&#39;s rules and lint</li><li>30b3ae60 - refactor(front): merge each route&#39;s view and UI into one page file</li><li>2a892714 - chore(front): drop the transitional view allowances from the lint config</li><li>605fbf62 - test(front): render the auth, games and home view tests on the app&#39;s route tree</li><li>1369dbd8 - refactor(front): group the Room&#39;s services by concept and merge its announcement hooks</li><li>9de3d0d7 - fix(front): address the spec 408 review: home I/O check, route-tree lint, auth link</li><li>8ec9c87d - refactor(front): add the widget suffix and mount vertical tests on the app&#39;s router</li></ul> [Compare with previous version](/amaurycoudr/chess-project/-/merge_requests/34/diffs?diff_id=235&start_sha=31b760f46bd97cb5a45b24d1c0d41b11b8c8fc21)
root commented 2026-10-15 14:14:18 +00:00 (Migrated from gitlab.core-project.space)

changed the description

changed the description
root (Migrated from gitlab.core-project.space) scheduled this pull request to auto merge when all checks succeed 2026-10-15 14:14:34 +00:00
root commented 2026-10-15 15:10:33 +00:00 (Migrated from gitlab.core-project.space)

aborted the automatic merge because the source branch was updated. Learn more.

aborted the automatic merge because the source branch was updated. [Learn more](https://gitlab.core-project.space/help/ci/pipelines/merge_trains.md#merge-request-dropped-from-the-merge-train).
root commented 2026-10-15 15:10:33 +00:00 (Migrated from gitlab.core-project.space)

added 1 commit

  • f9f53ad5 - fix(front): refuse an unserved procedure in the fake API instead of letting it through

Compare with previous version

added 1 commit <ul><li>f9f53ad5 - fix(front): refuse an unserved procedure in the fake API instead of letting it through</li></ul> [Compare with previous version](/amaurycoudr/chess-project/-/merge_requests/34/diffs?diff_id=237&start_sha=8ec9c87d131775397020af09fca4b577a5dbb2ce)
root (Migrated from gitlab.core-project.space) scheduled this pull request to auto merge when all checks succeed 2026-10-15 15:10:51 +00:00
root (Migrated from gitlab.core-project.space) merged commit into main 2026-10-15 15:17:47 +00:00
root commented 2026-10-15 16:04:47 +00:00 (Migrated from gitlab.core-project.space)

mentioned in merge request !536

mentioned in merge request !536
root commented 2026-10-15 21:19:13 +00:00 (Migrated from gitlab.core-project.space)

mentioned in merge request !537

mentioned in merge request !537
Sign in to join this conversation.
No description provided.