# REF-TASK-008 — Decompose the KDS page into cohesive feature modules

**Status:** Implemented  
**Kind:** Mechanical production refactor  
**Depends on:** REF-TASK-005

## Problem and evidence

`frontend/src/pages/KdsPage.tsx` is about 1,108 lines. It owns cart state and calculations,
commercial/non-commercial checkout handling, four operational queries, three mutation families,
fullscreen state, sales/unresolved-attempt banners, responsive slip selection, and the page markup.
Existing queue components show the repository already favors extracting cohesive visual units, but
the page remains the coordinator for unrelated UI and workflow details.

## Proposed change

Keep `KdsPage` as the route-level composition root and mechanically extract cohesive modules under a
KDS feature directory: current-order/cart presentation and pure cart operations; operational query
panels; queue orchestration; and the fullscreen hook/control. Keep checkout orchestration together
until its state lifetime (especially stable `operationId` and unresolved blocking) is explicitly
covered. Move constants with the concern that owns them.

## Constraints and sequence

First move pure functions/types with unchanged imports and tests; validate. Then move presentational
components; validate. Finally move hooks/orchestration one concern at a time; validate. Preserve
page-local, reload-discarded cart ownership, first-tap product snapshots, query keys/invalidation,
15-second polling, responsive counts, focus, accessible names, translations, and checkout safety. Do
not introduce global state, a new dependency, or a generic hooks/components bucket.

## Validation

Run focused pure/component tests after each extraction, all KDS component files after each hook
move, then the full frontend suite, frontend typecheck/build/coverage, the existing KDS E2E specs,
and `pnpm quality`. Run the canonical Docker/browser path if module loading or runtime composition
is affected beyond ordinary Vite output.

## Guidance / ADR

REF-TASK-018 should document route-page composition and feature-local module ownership. No ADR if
state ownership remains unchanged.
