Skip to content

[ttp1-phoenix] Single batch screen with per-file cards (TTP task 1) - #25

Merged
FranciscoMateusVG merged 3 commits into
portal-phoenixfrom
team/ttp1-phoenix/coder
Oct 9, 2026
Merged

FranciscoMateusVG merged 3 commits into
portal-phoenixfrom
team/ttp1-phoenix/coder

Conversation

@FranciscoMateusVG

Copy link
Copy Markdown
Owner

TTP task 1 (trial ttp1-phoenix) for the Phoenix arm, against the frozen v2 batch contract (monorepo-incluir PR #1053 @ 2702246; fixture/schema/assets copied byte-exact into test/fixtures/).

What changed

  • Home / = current batch (GET /api/print-portal/v2/batches/open): LOT-xxxx, status, item count, total copies, track Pronto → Arquivos retirados → Orçamento enviado → Orçamento aprovado → Impresso; empty state Nenhum pedido aguardando.
  • One card per file, grouped under its request (IMP-xxxx · title), jobs first then residual files: name, size, copies, instructions, Baixar arquivo (session-authenticated /api/print/v2/batches/:id/orders/:orderId/files/:fileId). Residual files say Não identificadas / Sem vínculo seguro — consulte instruções gerais; residual generalInstructions render in an Instruções gerais block inside their own request only. previouslyCancelledIn shows Este item esteve no lote LOT-xxxx, cancelado — confira antes de imprimir.
  • Actions by status, each with explicit confirmation, If-Match = batch ETag, one Idempotency-Key per intent (kept for Repetir after no answer):
    • open → checkbox Conferi todos os arquivos + Retirei os arquivos (412 → re-read + reconfirm, with Atualizar)
    • files_collected / quote_rejected → Enviar orçamento (file + total R$; rejection reason shown)
    • quote_pending → Aguardando aprovação do Financeiro; quote_approved → Marcar como impresso; printed → Aguardando recebimento
    • Actions not allowed in a state aren't rendered.
  • Lotes anteriores (/lotes, /lotes/:id): batch history (reference, status, dates, approved amount) + read-only detail with the same cards.
  • Notas fiscais now reads/submits v2 monthly closes (batch items link to their lot; legacy items show the reference).
  • Old per-order list/detail screens removed (/orders, /orders/:id). The /api/print/v1 JSON routes are unchanged.
  • Port: PrintApi gains the v2 batch callbacks, implemented in the HTTP adapter (strict v2 contract validation), the memory fake and FakeHono, all covered by the shared conformance suite.
  • data-ttp smoke markers on the real components.

No backend/contract change, no new dependency.

Tests

  • mix check green locally (178 tests; lint, structure, typecheck, depcruise, coverage, examples, hooks).
  • New: test/unit/contract_v2_test.exs, test/unit/batch_test.exs, v2 conformance cases (Memory + HTTP over real sockets), test/integration/portal_batch_live_test.exs (plain HTTP GET marker checks, byte-exact downloads, checkbox/confirm, stale 412, quote type/size/415 refusals, lost reply → Repetir reuses the key with no duplicate quote, printed, history, empty state), confidentiality now covers the batch page.
  • Also ran infra/ttp/feature_smoke.py's verify() over the rendered pages for every checkpoint (flow ×7, cancel/rebatched, empty): all pass.

Note: the default v1 staging smoke fetches the HTML /orders, which this task retires on purpose. The trial needs the task1-v2 selector.

🤖 Generated with Claude Code

Francisco Mateus and others added 3 commits October 9, 2026 14:48
The home page `/` is now the current print batch (v2 contract,
monorepo-incluir PR #1053): reference, status, item count, total copies
and the Pronto → Impresso track, then one card per file grouped under its
request (jobs first, then residual files), with residual general
instructions in their own request block and the backend's
previouslyCancelledIn warning. Batch actions by status (collect with
checkbox + confirmation, whole-batch quote, mark printed) run over the
socket with If-Match = the batch ETag and one Idempotency-Key per intent;
a 412 re-reads the batch and asks for confirmation again; "Repetir" after
a lost reply reuses the key. "Lotes anteriores" lists every batch with a
read-only detail; "Notas fiscais" reads the v2 monthly closes. The old
per-order list/detail screens are removed (the v1 JSON API is unchanged).

PrintApi gains the v2 batch port (HTTP adapter, memory fake, FakeHono and
the shared conformance suite), with strict v2 contract validation.
The data-ttp smoke markers are rendered on the real components.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
By contract, GET /batches/open is null while a collected…printed batch
is active (print-portal-v2.md; the fixture's visibilityTimeline), so the
home page lost the batch right after "Retirei os arquivos". The memory
fake now follows the contract (failing conformance case first), and
getCurrentBatch falls back to the active batch from the history (every
page of GET /batches), read with its ETag through GET /batches/:id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@FranciscoMateusVG
FranciscoMateusVG merged commit 58a5522 into portal-phoenix Oct 9, 2026
3 checks passed
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.

1 participant