Phase 8: widgets and polish

- Live job card widget (progress bar, in-widget cancel via widget_query)
  and live invoice widget (QR drawn from a bitmap, countdown, paid state),
  Bot API 10.4 sendWidget, private chats only
- Automatic fallback to the ordinary message when sendWidget fails, with
  a breaker that pauses widgets after repeated failures or on servers
  without the method; TELEGRAM_WIDGETS
- Prometheus metrics on the core (/metrics) and on every worker: queue
  depth and wait, slots, heartbeats, job outcomes, errors per site,
  deliveries, cache, invoices, Lightning, ledger check, widgets
- Example Prometheus config and alert rules, Caddyfile, dashboard notes
- Load test: cmd/loadtest and deploy/loadtest (make loadtest)
- Browser check of the widgets' HTML, including decoding a drawn QR
- docs/DEPLOY.md (production in under an hour) and docs/MONITORING.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Michilis
2026-11-18 18:24:36 +00:00
co-authored by Claude Opus 5.5
parent f1f9c6156c
commit 3c153af97f
45 changed files with 3158 additions and 20 deletions
+17 -3
View File
@@ -44,6 +44,12 @@ and in groups. Written in Go on top of yt-dlp.
the bot's profile texts and the Mini App, with numbers, sizes and dates
in the language's own format. Each user's Telegram language is
followed, and `/language` overrides it; `/grouplang` sets a group's.
- Live widgets in private chats (Bot API 10.4): the download status as a
progress bar with a cancel button, and the invoice with its QR code, a
countdown and the paid state. When Telegram refuses a widget the bot
uses the ordinary message, without anyone noticing.
- Prometheus metrics on the core and every worker, example alert rules,
dashboard notes and a load test.
- Friendly, translated error messages. Raw tool output stays in the logs.
## Quick start with docker compose
@@ -53,8 +59,10 @@ cp .env.example .env # set BOT_TOKEN, OWNER_IDS, WORKER_A_TOKEN, WORKER_B_TO
docker compose up -d --build
```
This runs the core and two workers. [docs/OPERATIONS.md](docs/OPERATIONS.md)
covers Postgres, S3, 2 GB uploads and TLS.
This runs the core and two workers. [docs/DEPLOY.md](docs/DEPLOY.md) is a
step by step guide to a production setup with TLS, payments, the Mini App
and monitoring in under an hour; [docs/OPERATIONS.md](docs/OPERATIONS.md)
covers Postgres, S3, 2 GB uploads and the other choices.
## Quick start from source
@@ -191,7 +199,8 @@ make test-postgres PG_DSN=postgres://... # the same suite on Postgres
make acceptance # kill a worker mid-job, watch the other finish
make i18n-check # translation completeness and consistency only
make miniapp # rebuild the Mini App front end after changing web/miniapp
make miniapp-e2e # click through the Mini App in headless Chromium
make miniapp-e2e # click through the Mini App and the widgets in headless Chromium
make loadtest # many simulated users against a real core and workers
```
The tests need neither a bot token nor network access. They run the real
@@ -204,7 +213,9 @@ change it. A test fails when `dist` is older than its sources.
## Documentation
- [docs/DEPLOY.md](docs/DEPLOY.md): from nothing to production in under an hour.
- [docs/OPERATIONS.md](docs/OPERATIONS.md): deploying and running it.
- [docs/MONITORING.md](docs/MONITORING.md): metrics, dashboards, alerts, load test.
- [docs/WORKERS.md](docs/WORKERS.md): adding download workers, tags, drain.
- [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md): how the pieces fit.
- [docs/TRANSLATING.md](docs/TRANSLATING.md): editing a catalog, adding a language.
@@ -216,6 +227,7 @@ change it. A test fails when `dist` is older than its sources.
cmd/core the bot gateway, with an embedded worker by default
cmd/worker the standalone download worker
cmd/faketelegram a fake Bot API for development and acceptance runs
cmd/loadtest simulated users for load tests
deploy Dockerfile, systemd units, acceptance script
internal/bot Telegram handlers, cards, status, delivery
internal/service download rules shared by all front ends
@@ -229,6 +241,8 @@ internal/ytdlp yt-dlp and ffprobe wrapper
internal/db migrations and queries
internal/storage file storage backends
internal/i18n translations and formatting
internal/widget the HTML widgets (status, invoice) and their limits
internal/metrics Prometheus metrics of the core and the worker
internal/api HTTP: health, payment webhook, worker protocol, Mini App API
web/miniapp the Mini App front end (Vite, React) and its embedded build
locales translation catalogs