Files
scrabble-game/ui
Ilia Denisov 3590df28db
Tests · Go / test (push) Successful in 7s
Tests · Go / test (pull_request) Successful in 6s
Tests · Integration / integration (pull_request) Successful in 12s
Tests · UI / test (pull_request) Failing after 5m9s
Stage 9: Telegram integration (connector side-service, Mini App, out-of-app push)
New platform/telegram connector (own container, bot token only there):
- go-telegram/bot long-poll loop: /start deep-links + Mini App launch button.
- gRPC API pkg/proto/telegram/v1 (Telegram service): ValidateInitData, Notify
  (renders a localized message + deep-link button), SendToUser/SendToGameChannel
  (admin, wired in Stage 10). Generic methods are platform-agnostic (external_id).
- Bot API base override for Telegram's test environment; Dockerfile + compose
  (VPN sidecar, no public ingress); README.

Gateway:
- initData validation relocated from the gateway into the connector; the gateway
  calls ValidateInitData over gRPC (GATEWAY_CONNECTOR_ADDR), drops the bot token,
  and deletes internal/auth.
- Out-of-app push: runPushPump routes events whose recipient has no live in-app
  stream to connector.Notify, gated by /internal/push-target + the in-app-only
  flag (race-free de-dup); HasSubscribers added to the push hub.

Backend:
- Migration 00007 accounts.notifications_in_app_only (default true) + jetgen.
- ProvisionTelegram seeds a new account's language/display name from the launch
  fields; IdentityExternalID reverse lookup; /internal/push-target handler.

UI:
- Telegram Mini App launch: detect initData, apply themeParams, authTelegram,
  route the deep-link start_param (g/i/f); /telegram/ guard redirects outside
  Telegram. Vite relative base + telegram-web-app.js. In-app-only profile toggle;
  share-to-Telegram link for a friend code. Vitest + Playwright coverage.

Wire/docs/CI: fbs Profile/UpdateProfileRequest gain notifications_in_app_only
(Go + TS); go.work uses ./platform/telegram; go-unit.yaml covers it; PLAN,
ARCHITECTURE, FUNCTIONAL (+ru), UI_DESIGN, READMEs updated.
2026-06-04 01:48:03 +02:00
..
2026-06-03 00:55:38 +02:00

scrabble-ui

Pure-HTML5 game client — plain Svelte 5 (runes) + TypeScript + Vite, no SvelteKit. Talks to the gateway over Connect-RPC + FlatBuffers; embeddable in platform webviews and packageable to native via Capacitor.

Stage 7 ships the playable slice: sign in (guest / email), the "my games" lobby, auto-match, the board (place tiles by drag or tap, pass, exchange, resign), hint, word-check + complaint, per-game chat and nudge, the live in-app stream, i18n (en/ru), theme, and the profile. Stage 8 adds friends/blocks (with one-time friend codes), friend-game invitations, profile editing + email binding, the statistics screen, the lobby notification badge, and the in-game history + GCG export (share or download, finished games only).

Scripts

pnpm install
pnpm start        # mock mode (VITE_MOCK): lobby -> game with no backend, :5173
pnpm dev          # against a running gateway (Vite proxies /scrabble.edge.v1.Gateway -> :8081)
pnpm check        # svelte-check / tsc
pnpm test:unit    # Vitest (pure logic + FlatBuffers codec)
pnpm test:e2e     # Playwright smoke against the mock
pnpm build        # static bundle into dist/ (prod ~67 KB gzip JS)
pnpm codegen      # regenerate src/gen from edge.proto + scrabble.fbs (dev-time)

GATEWAY_URL overrides the dev proxy target; VITE_GATEWAY_URL sets the runtime gateway origin for a packaged (non-proxied) build.

How it talks to the gateway

A single Connect Execute(message_type, payload) carries every unary op; the request and response bodies are FlatBuffers tables (pkg/fbs/scrabble.fbs) in payload. The session token rides in Authorization: Bearer; a domain failure comes back in result_code. Subscribe is the live event stream. lib/transport.ts is the real client; lib/mock/ is an in-memory fake selected by MODE === 'mock' (and tree-shaken out of production). Both speak the plain lib/model.ts types via lib/codec.ts.

No board on the wire: StateView is a summary + rack only, so the client reconstructs the 15×15 board by replaying the decoded move journal (game.history). Premium squares and tile values (lib/premiums.ts) are a client-side map ported from scrabble-solver/rules/rules.go (pinned by a Vitest parity test). Board, tiles and effects are pure CSS + Unicode — no image/font/SVG assets.

Codegen

src/gen/ is committed; CI builds it, it is not regenerated there (the same model as the Go committed jet/fbs output). pnpm codegen runs flatc --ts on ../pkg/fbs/scrabble.fbs and buf generate (protoc-gen-es) on the edge proto. Needs flatc 23.5.26 and buf on PATH.

Theming

Design tokens are CSS custom properties (src/app.css); light/dark follows prefers-color-scheme or an explicit choice in Settings. The token system is Telegram-themeParams-ready (lib/theme.ts) — a Mini App can override the tokens at runtime; the Telegram SDK itself is wired in the Telegram stage.

Layout

src/
  lib/         model, client facade, transport (+ mock), codec, board replay,
               placement state machine, premiums, stats, share, i18n, theme, session, router, app store
  components/  Header, Menu (+ badge), Modal, Toast, TabBar, Screen
  screens/     Login, Lobby, NewGame, Profile, Settings, About, Friends, Stats
  game/        Game, Board, Rack, Controls, MakeMove, Chat
  gen/         committed edge codegen (FlatBuffers + Connect)
e2e/           Playwright smoke + social specs (mock)