feat(pos): gate scan app, first slice of the Android POS (#69) #172

Merged
amiryahaya merged 18 commits from feat/pos-gate-scan-69 into main 2026-11-07 06:26:14 +01:00
Owner

First slice of the Android POS (#69): a gate scan app for an Android tablet. Staff sign in, pick park and gate, and scan visitors' QR codes to check them in or out, or look a ticket up. No payment, printing or violation fines (parked).

Design: docs/superpowers/specs/2026-11-06-gate-scan-app-design.md · Plan: docs/superpowers/plans/2026-11-06-gate-scan-app.md · ADR 0037.

Changes

  • API: POST /v1/admin/gates/{id}/check-in|check-out and GET /v1/admin/tickets/{code} accept admin_portal.tickets.scan or checker_app.checker, platform scope only (an organization-scoped grant is refused). OpenAPI x-permission updated.
  • mobile/pos: Kotlin + Compose app (ke.go.kws.pos): AppAuth sign-in with PKCE and prompt=login/max_age=0 (shared tablet), 12 h session, refresh token in EncryptedSharedPreferences; CameraX + ML Kit scanner, one scan per QR presentation; large green / red / amber (vehicle) result; overstay at check-out shows red and refuses; 503 retried once (Retry-After capped at 5 s); a lost response is "Unknown result: scan again", never success. Ticket codes are never logged or stored; the generated ApiClient is not compiled.
  • Client: scripts/generate-clients.sh kotlin (openapi-generator, Retrofit + kotlinx.serialization), module :kwsapi.
  • CI: .forgejo/workflows/mobile-pos.yml + scripts/mobile-pos-ci.sh (lint, unit tests, Kover, debug APK in a pinned Android SDK image).
  • Dev IdP: client kws-pos-app. Docs: ADR 0037, mobile/pos/README.md, CLAUDE.md.

Coverage

  • Go make cover: 91.5 % (minimum 80 %).
  • POS Kover (domain + data): 88.8 % line (minimum 80 %).

Review

Dual pass: ponytail review (no must-fix; fixed the debug endpoint flags, removed the uncompiled ApiClient and its two dependencies, a dead method) and the superpowers whole-branch review (all findings fixed and re-reviewed).

Not verified

  • Run on a real tablet, a real QR read by the camera, haptics and tone (tested on an API 30 emulator; the UI test ResultPanelTest passed 4/4 there).
  • Zitadel honouring prompt=login; the production IdP client is an operations task.

My calls (check these)

Vehicle tickets show amber "not scanned here yet"; any permitted user may pick any gate; the count excludes the master; compileSdk 35; 12 h expiry checked on resume and before each scan (no idle timer); Look up is a third segment of the scan screen.

Follow-up: merge the three copies of "any of these permissions, platform scope only" (checkin, documents.StaffOnly, rbac.PlatformOnly) into one rbac helper.

🤖 Generated with Claude Code

First slice of the Android POS (#69): a **gate scan app** for an Android tablet. Staff sign in, pick park and gate, and scan visitors' QR codes to check them in or out, or look a ticket up. No payment, printing or violation fines (parked). Design: `docs/superpowers/specs/2026-11-06-gate-scan-app-design.md` · Plan: `docs/superpowers/plans/2026-11-06-gate-scan-app.md` · ADR 0037. ## Changes - **API:** `POST /v1/admin/gates/{id}/check-in|check-out` and `GET /v1/admin/tickets/{code}` accept `admin_portal.tickets.scan` **or** `checker_app.checker`, platform scope only (an organization-scoped grant is refused). OpenAPI `x-permission` updated. - **`mobile/pos`:** Kotlin + Compose app (`ke.go.kws.pos`): AppAuth sign-in with PKCE and `prompt=login`/`max_age=0` (shared tablet), 12 h session, refresh token in EncryptedSharedPreferences; CameraX + ML Kit scanner, one scan per QR presentation; large green / red / amber (vehicle) result; overstay at check-out shows red and refuses; 503 retried once (Retry-After capped at 5 s); a lost response is "Unknown result: scan again", never success. Ticket codes are never logged or stored; the generated `ApiClient` is not compiled. - **Client:** `scripts/generate-clients.sh kotlin` (openapi-generator, Retrofit + kotlinx.serialization), module `:kwsapi`. - **CI:** `.forgejo/workflows/mobile-pos.yml` + `scripts/mobile-pos-ci.sh` (lint, unit tests, Kover, debug APK in a pinned Android SDK image). - **Dev IdP:** client `kws-pos-app`. Docs: ADR 0037, `mobile/pos/README.md`, CLAUDE.md. ## Coverage - Go `make cover`: **91.5 %** (minimum 80 %). - POS Kover (`domain` + `data`): **88.8 %** line (minimum 80 %). ## Review Dual pass: ponytail review (no must-fix; fixed the debug endpoint flags, removed the uncompiled `ApiClient` and its two dependencies, a dead method) and the superpowers whole-branch review (all findings fixed and re-reviewed). ## Not verified - Run on a real tablet, a real QR read by the camera, haptics and tone (tested on an API 30 emulator; the UI test `ResultPanelTest` passed 4/4 there). - Zitadel honouring `prompt=login`; the production IdP client is an operations task. ## My calls (check these) Vehicle tickets show amber "not scanned here yet"; any permitted user may pick any gate; the count excludes the master; compileSdk 35; 12 h expiry checked on resume and before each scan (no idle timer); Look up is a third segment of the scan screen. Follow-up: merge the three copies of "any of these permissions, platform scope only" (`checkin`, `documents.StaffOnly`, `rbac.PlatformOnly`) into one rbac helper. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gate routes accept admin_portal.tickets.scan or checker_app.checker,
platform scope only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Custom Tab keeps the IdP session after sign-out or the 12-hour expiry;
prompt=login and max_age=0 stop the next person being signed in as the last.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Camera (CameraX + bundled ML Kit QR) and Type code feed ScanController on the
main thread; result panels with fixed copy, haptic and tone; ticket lookup card;
settings with sign out / end shift. Services live in one Application holder
(one GatePrefs DataStore, corrupt file = no gate). A scan is never sent without
a token (401, nothing leaves the device); the session is re-checked on resume.
Back from the gate list returns to the parks; a gate gone opens Choose gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Found in the manual run: in a short (landscape) box the SurfaceView preview drew
over the header, so the preview uses a TextureView, clipped. The settings line was
blank for an account with neither a name nor an email. Mode switch in brand ochre.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Type code while a result panel was up was dropped silently, leaving the previous
ticket's result on screen as if it were the new one. Confirming now dismisses the
panel first, and Type code is disabled while a scan is in flight. Change and
Settings dismiss a shown result, so a looked-up holder is not shown to the next
person after sign-out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ScanController.reset (drops a shown result and one still in flight) is called on
  every sign-out (button, 12 hours on resume, 401); the scanner now lives in
  AppViewModel, not the Activity's ViewModel store.
- The camera effect ignores a provider bind or a decode that arrives after dispose.
- ScanController.onFrame re-arms the camera only after a frame without a QR, so a
  ticket held under the camera past the 4 s green is not checked again (no code kept).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(pos): debug builds honour the endpoint flags; the generated ApiClient is not compiled (#69)
All checks were successful
clients / clients (pull_request) Successful in 1m39s
mobile-pos / mobile-pos (pull_request) Successful in 9m20s
mobile-ticket / mobile-ticket (pull_request) Successful in 15m35s
web-admin / web-admin (pull_request) Successful in 5m52s
web-partner / web-partner (pull_request) Successful in 6m48s
web-ticket / web-ticket (pull_request) Successful in 6m0s
api / api (pull_request) Successful in 11m28s
4200406cba
Debug defaults stay 10.0.2.2 but -PkwsApiBaseUrl/-PkwsOidcIssuer now apply,
as the README's local-run steps need. :kwsapi excludes ApiClient.kt, so the
scalars converter and logging interceptor go and SourceGuardTest is replaced
by a compile error. AuthRepository.dispose had no callers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/kws!172
No description provided.