Stage 17 round 6 (#4/#5/#6): draft persistence wire + gateway + UI
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 11s
CI / ui (pull_request) Successful in 32s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m7s

Complete the client-side draft feature on top of the shipped backend
foundation (the game_drafts store/service):

- FB: DraftRequest{game_id,json} + DraftView{json} (a draft get reuses
  GameActionRequest); regenerated committed Go + TS bindings.
- Backend REST: GET/PUT /games/:id/draft, a draftDTO
  (rack_order/board_tiles) mapped to game.Draft.
- Gateway: draft.get/draft.save transcode forwarding the composition
  JSON verbatim (json.RawMessage both ways -- no double-encode).
- UI: debounced save of the rack order + board tiles and restore on
  load (lib/draft.ts), plus #5 -- tiles may be arranged on the
  opponent's turn (placement relaxed; the preview and Make-move stay
  your-turn-only, so an off-turn draft is position-only).

Tests: backend handler validation, gateway pass-through round-trip, UI
draft/codec units, and a draft-restore e2e.
This commit is contained in:
Ilia Denisov
2026-06-07 22:25:29 +02:00
parent 353dff20c4
commit f5c2404123
22 changed files with 721 additions and 7 deletions
+16
View File
@@ -3,6 +3,7 @@ import { describe, expect, it } from 'vitest';
import * as fb from '../gen/fbs/scrabblefb';
import { BLANK_INDEX, setAlphabet } from './alphabet';
import {
decodeDraftView,
decodeFriendList,
decodeGameList,
decodeInvitation,
@@ -11,6 +12,7 @@ import {
decodeStateView,
decodeStats,
encodeCheckWord,
encodeDraftSave,
encodeExchange,
encodeStateRequest,
encodeSubmitPlay,
@@ -18,6 +20,20 @@ import {
} from './codec';
describe('codec', () => {
it('round-trips a draft save request and view (Stage 17)', () => {
const json = '{"rack_order":"1,0","board_tiles":[]}';
const req = fb.DraftRequest.getRootAsDraftRequest(new ByteBuffer(encodeDraftSave('g1', json)));
expect(req.gameId()).toBe('g1');
expect(req.json()).toBe(json);
const b = new Builder(64);
const j = b.createString('{"x":1}');
fb.DraftView.startDraftView(b);
fb.DraftView.addJson(b, j);
b.finish(fb.DraftView.endDraftView(b));
expect(decodeDraftView(b.asUint8Array())).toBe('{"x":1}');
});
it('encodes a SubmitPlayRequest with alphabet indices (Stage 13)', () => {
setAlphabet('english', [
{ index: 0, letter: 'a', value: 1 },