feat(export): platform-native delivery — TG popup+downloadFile, VK viewer, mobile share sheet
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 14s
CI / ui (pull_request) Failing after 1m7s
CI / conformance (pull_request) Successful in 9s
CI / gate (pull_request) Failing after 0s
CI / deploy (pull_request) Has been skipped
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 14s
CI / ui (pull_request) Failing after 1m7s
CI / conformance (pull_request) Successful in 9s
CI / gate (pull_request) Failing after 0s
CI / deploy (pull_request) Has been skipped
Per the on-device review, the last hop is now the most native affordance per platform, all fed by the same signed URL: - Telegram: the native showPopup chooser returns (safe here — the whole TG chain is bridge calls, which need no user activation) and both formats go to the native downloadFile dialog on iOS and Android alike. - VK: the PNG opens in VK's native photo viewer (VKWebAppShowImages) — on screen at once, saved/shared from the viewer's own controls; the GCG keeps VKWebAppDownloadFile; either falls back to a plain anchor download (the desktop iframe). The gateway now serves /dl/* via http.ServeContent (Content-Length + Range/206) — another swing at the VK Android DownloadManager hang; if it persists, the next step is the clipboard fallback for the VK-Android GCG. - Mobile browsers: the OS share sheet with the fetched file (the proven fetch-then-share pattern) — nothing lands in Downloads first; desktop keeps the anchor download. Legacy Telegram (< 8.0, no downloadFile) keeps the app modal + GCG clipboard copy and hides the image option.
This commit is contained in:
@@ -794,9 +794,14 @@ platform: the client calls the authenticated `game.export_url` op, the backend m
|
||||
**relative, HMAC-signed, short-lived path**
|
||||
(`/dl/{game}/{kind}?e=<expiry>&…&s=<HMAC-SHA256>`, 10-minute TTL,
|
||||
`BACKEND_EXPORT_SIGN_KEY`), and the client resolves it against its **own origin** (no
|
||||
service ever needs to know the public host) and hands it to the platform's native
|
||||
download: Telegram `downloadFile` (Bot API 8.0), `VKWebAppDownloadFile`, or a plain
|
||||
browser anchor elsewhere (including the desktop VK iframe). The GET is the gateway's
|
||||
service ever needs to know the public host) and hands it to the platform's most
|
||||
native affordance: Telegram `downloadFile` (Bot API 8.0; the chooser there is the
|
||||
native showPopup — the whole TG chain is activation-free bridge calls), VK's native
|
||||
photo viewer for the PNG (`VKWebAppShowImages`) + `VKWebAppDownloadFile` for the
|
||||
GCG, the OS share sheet with the fetched file on a mobile browser, or a plain
|
||||
anchor download (desktop, and the VK desktop iframe fallback). The gateway serves
|
||||
the bytes via `http.ServeContent` (Content-Length + Range/206 — Android's system
|
||||
DownloadManager hangs on chunked bodies of unknown length). The GET is the gateway's
|
||||
**only unauthenticated data route** (`/dl/*` — in the caddy `@gateway` matcher and the
|
||||
per-IP public rate limiter): the native download calls carry no cookies or headers, so
|
||||
the URL's signature — verified by the backend on its `/api/v1/public` group in constant
|
||||
|
||||
+14
-12
@@ -322,9 +322,9 @@ Finished games are archived in a dictionary-independent form and exportable in
|
||||
**two formats behind one 📤 button** — the GCG file and a rendered **PNG image** of
|
||||
the final position; the export is offered **only once a game is finished**, and
|
||||
never for an honest-AI practice game (a live game's export would leak the move
|
||||
journal; an AI game is throwaway). The format chooser is always the app's **own
|
||||
modal** — deliberately not Telegram's native popup, whose callback runs without
|
||||
user activation and silently breaks the share/clipboard delivery it leads to.
|
||||
journal; an AI game is throwaway). The format chooser is Telegram's **native popup**
|
||||
inside Telegram (safe there: the whole Telegram chain is bridge calls, which need no
|
||||
user activation) and the app's own modal elsewhere (VK has no native chooser).
|
||||
|
||||
The **image** is rendered on the server (the internal render sidecar runs the same
|
||||
drawing module the web client tests; always the light theme): the final board with
|
||||
@@ -340,15 +340,17 @@ running totals alone do not include it). The footer stamps the site host and the
|
||||
finish date in the device locale. The scoresheet typography is fixed; a long game
|
||||
stretches the board (never below its minimum) so the image carries no dead space.
|
||||
|
||||
Delivery is **one route for both formats on every platform**: the app requests a
|
||||
signed, short-lived download link and hands it to the platform's native download —
|
||||
Telegram's download dialog, VK's `VKWebAppDownloadFile`, or an ordinary browser
|
||||
file download elsewhere (including the desktop VK iframe). The link needs no login
|
||||
to fetch (the platforms' download calls carry none), is valid for minutes, and
|
||||
serves the artifact as a named file attachment. The single exception is a legacy
|
||||
Telegram client without the download dialog (pre-Bot API 8.0): there the GCG falls
|
||||
back to the old clipboard copy (with the confirming toast) and the image option is
|
||||
not offered. Statistics (durable accounts only):
|
||||
Delivery is **one signed, short-lived link for both formats on every platform**,
|
||||
handed to the most native affordance: Telegram's download dialog (both TG
|
||||
platforms; sharing onwards from Telegram's own file preview); on VK the image opens
|
||||
in **VK's native photo viewer** (on screen at once — saving/sharing are the
|
||||
viewer's own controls) and the GCG goes through VK's download; a **mobile browser
|
||||
gets the OS share sheet** with the file (nothing lands in Downloads first); a
|
||||
desktop browser downloads the file. The link needs no login to fetch (the
|
||||
platforms' downloaders carry none) and is valid for minutes. The single exception
|
||||
is a legacy Telegram client without the download dialog (pre-Bot API 8.0): there
|
||||
the GCG falls back to the old clipboard copy (with the confirming toast) and the
|
||||
image option is not offered. Statistics (durable accounts only):
|
||||
wins, losses, draws, max points in a game, and max points for a single move (the
|
||||
best play, which already includes every word it formed plus the all-tiles bonus). It
|
||||
also shows the player's **move count** (their plays — passes and exchanges do not
|
||||
|
||||
+14
-11
@@ -331,9 +331,10 @@ Telegram.
|
||||
**двух форматах за одной кнопкой 📤** — файл GCG и отрисованная **PNG-картинка**
|
||||
финальной позиции; экспорт доступен **только после завершения партии** и никогда —
|
||||
для тренировочной партии с ИИ (экспорт идущей партии раскрыл бы журнал ходов, а
|
||||
партия с ИИ одноразовая). Выбор формата — всегда **собственный модал** приложения,
|
||||
сознательно не нативный попап Telegram: его коллбек приходит без user activation и
|
||||
молча ломает доставку через share/буфер, к которой ведёт выбор.
|
||||
партия с ИИ одноразовая). Выбор формата — **нативный попап Telegram** внутри
|
||||
Telegram (там это безопасно: вся телеграмовская цепочка — bridge-вызовы, которым
|
||||
user activation не нужна) и собственный модал приложения в остальных случаях (у VK
|
||||
нативного чузера нет).
|
||||
|
||||
**Картинка** рендерится на сервере (внутренний рендер-сайдкар исполняет тот же
|
||||
модуль отрисовки, что тестирует веб-клиент; всегда светлая тема): финальная
|
||||
@@ -349,14 +350,16 @@ Telegram.
|
||||
и дата завершения в локали устройства. Типографика таблицы фиксирована; длинная
|
||||
партия растягивает доску (не ниже минимума), так что пустот на картинке нет.
|
||||
|
||||
Доставка — **один путь для обоих форматов на любой платформе**: приложение
|
||||
запрашивает подписанную короткоживущую ссылку на скачивание и передаёт её родному
|
||||
механизму платформы — диалогу загрузки Telegram, `VKWebAppDownloadFile` у VK или
|
||||
обычному браузерному скачиванию файла в остальных случаях (включая десктопный
|
||||
iframe VK). Ссылка не требует логина при скачивании (родные загрузчики платформ его
|
||||
не несут), живёт минуты и отдаёт артефакт именованным файлом. Единственное
|
||||
исключение — устаревший клиент Telegram без диалога загрузки (до Bot API 8.0): там
|
||||
GCG откатывается на прежнее копирование в буфер (с подтверждающим тостом), а пункт
|
||||
Доставка — **одна подписанная короткоживущая ссылка для обоих форматов на любой
|
||||
платформе**, отданная самому родному механизму: диалог загрузки Telegram (обе
|
||||
платформы TG; поделиться дальше — из телеграмовского превью файла); в VK картинка
|
||||
открывается в **нативном просмотрщике фото VK** (сразу на экране — сохранение и
|
||||
шаринг штатными кнопками просмотрщика), а GCG идёт через загрузку VK; **мобильный
|
||||
браузер получает системную share-шторку** с файлом (ничего не оседает в Загрузках);
|
||||
десктопный браузер скачивает файл. Ссылка не требует логина при скачивании (родные
|
||||
загрузчики платформ его не несут) и живёт минуты. Единственное исключение —
|
||||
устаревший клиент Telegram без диалога загрузки (до Bot API 8.0): там GCG
|
||||
откатывается на прежнее копирование в буфер (с подтверждающим тостом), а пункт
|
||||
«картинка» не предлагается. Статистика (только у постоянных аккаунтов):
|
||||
победы, поражения, ничьи, макс. очков за партию и макс. очков за один ход (лучший
|
||||
ход, уже включающий все образованные им слова и бонус за все фишки). Также
|
||||
|
||||
+13
-9
@@ -406,15 +406,19 @@ enabled on the first, uncached load) and flip in place when an event refreshes t
|
||||
- **History / export**: the in-game slide-down history lays each move out in a per-seat grid
|
||||
(the word(s) and the move score, no running total); the 📤 in the history header appears
|
||||
only once the game is finished — never in an honest-AI game (throwaway practice) — and
|
||||
opens the **format chooser**: always the app's own modal, never Telegram's native popup
|
||||
(a `showPopup` callback carries no user activation, which silently breaks gesture-gated
|
||||
delivery APIs — on-device finding). The accent button leads with the image, the GCG file
|
||||
is the quiet alternative; both need the connection. Both formats travel the same
|
||||
signed-URL route: the app mints a relative link (`game.export_url`), resolves it against
|
||||
its own origin and hands it to the platform's native download — Telegram `downloadFile`,
|
||||
`VKWebAppDownloadFile`, else a plain anchor download (also the desktop VK iframe, where
|
||||
the bridge method is absent and the anchor works). A legacy Telegram client without
|
||||
`downloadFile` keeps the old GCG clipboard copy and hides the image option. Confirming a
|
||||
opens the **format chooser**: Telegram's native popup inside Telegram — safe there,
|
||||
since the whole TG chain is bridge calls needing no user activation (a popup callback
|
||||
must never lead into `navigator.share`/clipboard, the on-device finding) — and the app's
|
||||
own modal elsewhere (VK has no native chooser; the accent button leads with the image,
|
||||
both options need the connection). Both formats mint the same signed relative link
|
||||
(`game.export_url`), resolved against the app's own origin, then delivered natively:
|
||||
Telegram `downloadFile` (both TG platforms); on VK the PNG opens in the native photo
|
||||
viewer (`VKWebAppShowImages`, save/share from its controls) and the GCG goes through
|
||||
`VKWebAppDownloadFile`, both falling back to a plain anchor download (the desktop
|
||||
iframe); a mobile browser fetches the bytes and opens the OS share sheet
|
||||
(`navigator.share` with the file — the proven fetch-then-share pattern), a desktop
|
||||
browser downloads by anchor. A legacy Telegram client without `downloadFile` keeps the
|
||||
old GCG clipboard copy, hides the image option and stays on the app modal. Confirming a
|
||||
resign reveals the full board: it closes the history drawer (portrait) and zooms the
|
||||
board out.
|
||||
- **Export image** (`lib/gameimage.ts` — the shared drawing module the render sidecar
|
||||
|
||||
Reference in New Issue
Block a user