diff --git a/.github/scripts/integration-governance.cjs b/.github/scripts/integration-governance.cjs index 488d35bd1a..5dd455f578 100644 --- a/.github/scripts/integration-governance.cjs +++ b/.github/scripts/integration-governance.cjs @@ -9,7 +9,7 @@ const MAX_COMMITS = 1000; const MAX_AUTHOR_BATCH = 50; // This literal is inside the enrolled .github closure. A caller-supplied // preparedBy.sourceSHA must never choose a new executable verifier tree. -const TRUSTED_SCRIPTS_TREE = '308d64dd1ac3bf1061a4dced3071647236327e51'; +const TRUSTED_SCRIPTS_TREE = '9affee853918156f2e5e8463562008c8c46b8afa'; const SOURCE = 'https://github.com/kubernetes-sigs/kubebuilder-release-tools/tree/012269a88fa4c034a0acf1ba84c26b195c0dbab4'; const sha = value => crypto.createHash('sha256').update(value).digest('hex'); const git = (args, cwd = process.cwd()) => diff --git a/changelog.d/added-16236-kiosk-cta.md b/changelog.d/added-16236-kiosk-cta.md new file mode 100644 index 0000000000..8c0957cf44 --- /dev/null +++ b/changelog.d/added-16236-kiosk-cta.md @@ -0,0 +1 @@ +- Every `?kiosk=1` view — the spoke Activity Monitor, the Matrix view and the hub's public Fleet activity page, i.e. the three Twitch streams — shows a small "Request a Hive" call-to-action pill bottom-right with `hive.hivecommons.dev/get-started` and a QR code of it ([#16236](https://github.com/hivecommons/hive/issues/16236)). It never appears in the operator dashboard, `&cta=off` removes it, and the text is `dashboard.kiosk_cta_url` / `dashboard.kiosk_cta_text` on a spoke or `HIVE_HUB_KIOSK_CTA_URL` / `HIVE_HUB_KIOSK_CTA_TEXT` on the hub. `src/scripts/twitch-channel-cta.sh` sets the matching title, category and tags on the channels (`--dry-run`, idempotent, per-channel `channel:manage:broadcast` token). diff --git a/src/docs/api-reference/auth.md b/src/docs/api-reference/auth.md index 0e5d7c5fb4..db7bbe89bc 100644 --- a/src/docs/api-reference/auth.md +++ b/src/docs/api-reference/auth.md @@ -24,6 +24,6 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f | `GET` | `/api/openrouter/models` | Dashboard auth/session | Open Router Models | `pkg/dashboard/openrouter.go:47` | | `GET` | `/api/openrouter/credit` | Dashboard auth/session | Open Router Credit | `pkg/dashboard/openrouter.go:48` | | `GET` | `/openrouter/callback` | Public | Open Router Callback | `pkg/dashboard/openrouter.go:49` | -| `POST` | `/api/github-app/recheck` | Dashboard auth/session | GitHub App Recheck | `pkg/dashboard/server.go:1658` | -| `POST` | `/api/github-app/install-clicked` | Dashboard auth/session | GitHub App Install Clicked | `pkg/dashboard/server.go:1659` | -| `GET` | `/gh-setup` | Public | GitHub App Setup Callback | `pkg/dashboard/server.go:1660` | +| `POST` | `/api/github-app/recheck` | Dashboard auth/session | GitHub App Recheck | `pkg/dashboard/server.go:1659` | +| `POST` | `/api/github-app/install-clicked` | Dashboard auth/session | GitHub App Install Clicked | `pkg/dashboard/server.go:1660` | +| `GET` | `/gh-setup` | Public | GitHub App Setup Callback | `pkg/dashboard/server.go:1661` | diff --git a/src/docs/api-reference/dashboard-misc.md b/src/docs/api-reference/dashboard-misc.md index 88086e0c7c..54f8a5c488 100644 --- a/src/docs/api-reference/dashboard-misc.md +++ b/src/docs/api-reference/dashboard-misc.md @@ -65,4 +65,4 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f | `POST` | `/api/hives/{id}/heartbeat` | Dashboard auth/session | Hives Heartbeat | `pkg/dashboard/api_contribute.go:346` | | `DELETE` | `/api/hives/{id}` | Owner only | Hives Delete | `pkg/dashboard/api_contribute.go:347` | | `POST` | `/api/hives/onboard` | Dashboard auth/session | Hives Onboard | `pkg/dashboard/api_contribute.go:348` | -| `GET` | `/sso` | Public | SSO | `pkg/dashboard/server.go:1665` | +| `GET` | `/sso` | Public | SSO | `pkg/dashboard/server.go:1666` | diff --git a/src/docs/api-reference/health-status-events.md b/src/docs/api-reference/health-status-events.md index 8aa89fdb8f..cd499551c2 100644 --- a/src/docs/api-reference/health-status-events.md +++ b/src/docs/api-reference/health-status-events.md @@ -24,17 +24,17 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f | `GET` | `/api/version` | Dashboard auth/session | Build/version metadata; includes `upgradeMarker` (`target`, `current`, `attempts`, `maxAttempts`, `failed`, `requestedAt`, `lastError`) while a self-upgrade is in flight or has failed ([#6765](https://github.com/hivecommons/hive/issues/6765)), the hub-delivered `upgradePolicy` (`hub_managed`, `spoke_managed`, `schedule`, `schedule_hour`, `schedule_timezone`, `schedule_weekday`, `paused`, `branch`, `channel`, `target_sha`, `target_resolved`, `armed_target`, and `next_update_at` — the hub's RFC3339 ETA for the next promotion into the `stable` channel, omitted when unknown ([#10256](https://github.com/hivecommons/hive/issues/10256))) when available, and an `autoUpdate` object (`enabled`, `state` — one of `disabled`/`up_to_date`/`behind`/`retrying`/`failed`/`unknown` — `healthy`, `period`, `targetBranch`, `targetCommit`, `currentCommit`, `commitsBehind`, `lastAttemptAt`, `lastError`, `detail`, and `nextUpdateAt` — the hub's RFC3339 ETA for the next update, omitted when unknown, disabled or paused ([#10257](https://github.com/hivecommons/hive/issues/10257))) that never reports a failed or unknown update as healthy ([#6962](https://github.com/hivecommons/hive/issues/6962), [#6963](https://github.com/hivecommons/hive/issues/6963)). Also `startedAt` (RFC3339 process start — changes on every pod roll even when the build does not, so the dashboard can say "Restarted" vs "Upgraded") and, until the first status is published, `startupPhase`/`startupPhaseLabel` (the boot phase a fresh pod is in) ([#15788](https://github.com/hivecommons/hive/issues/15788)) | `pkg/dashboard/api.go:44` | | `GET` | `/api/version/release-notes` | Dashboard auth/session | Changelog gap between two revisions: `?from=&to=` returns `{from:{sha,version?}, to:{sha,ref,version?}, sections:[{version,date,categories:{added,changed,fixed,security,deprecated}}], unreleased?, truncated, source, error?}` — the `CHANGELOG.md` release sections present at `to` and absent at `from`, newest first, plus (when `to` is not a release tag) the `changelog.d/` fragments new at `to` under an `Unreleased (in this build)` section. Fetch failures return `source: "unavailable"` with `error` rather than an error status; results are cached per (from, to) for an hour ([#11065](https://github.com/hivecommons/hive/issues/11065)) | `pkg/dashboard/api.go:45` | | `POST` | `/api/release-channel` | Owner only | Hosted spoke self-service release-channel selector; relays `stable`/`candidate`/`edge` to the hub's existing switch-branch endpoint with the spoke dashboard-token proof, and reports the requested channel as pending until the Deployment image lands | `pkg/dashboard/api.go:69` | -| `GET` | `/api/health` | Public | Basic health probe | `pkg/dashboard/server.go:1638` | -| `GET` | `/api/health/deep` | Public | Deep health probe | `pkg/dashboard/server.go:1639` | -| `GET` | `/api/livez` | Public | Kubernetes liveness probe | `pkg/dashboard/server.go:1640` | -| `GET` | `/metrics` | Registered only when `HIVE_METRICS_ENABLED`; requires `Authorization: ****** (403 if the token is unset) | Prometheus metrics | `pkg/dashboard/server.go:1646` | -| `GET` | `/api/status` | Dashboard auth/session | Dashboard aggregate status; `labelPresets[]` (`{key,label,description,labels[],states[]}`) lists the built-in label-filter presets for the Projects cards, led by `needs-human` whose `labels[]` are the effective hard-suppress labels plus `needs-signal`, the hold labels, `stage/071-needs-author` and the reporter-trust awaiting label (#12172); accepts `?fields=a,b` for top-level selection and `?omit=repos` to drop heavy sections, and honors `Accept-Encoding: gzip`; `agents[]` includes busy-pane visibility fields (`kicksUndeliverable`, `busySince`, `lastTranscriptActivity`, `condition`, `conditionMessage`) when a Working pane cannot accept kicks; a working agent also carries `agents[].run` — the live per-run line (#14576): `{since, elapsedS, costUSD, tokens, priced, tests, filesChanged}`, the estimated spend/tokens since the kick was delivered (`lastKickAt`, falling back to `busySince`) (delta of the token collector's per-agent cumulative figure; `priced:false` when the agent has none yet), the last visible test-runner result (`pass`/`fail`/empty) and the last `N files changed` git summary (`-1` when none) parsed from the captured pane; top-level `fleetRun` `{running, hourUSD, hourPriced, dayUSD, weekUSD, monthUSD, windowsPriced}` is the governor strip's rotating `running N · $X this hour / today / this week / this month` figure (#15614) — the hour is the rise since the top of the clock hour, the wider windows are the daily cost ledger summed from 00:00 UTC today, Monday 00:00 UTC (ISO week) and the 1st 00:00 UTC plus the rise since the ledger's last snapshot, `windowsPriced:false` when there is no ledger yet; `sla` (fleet) and `repos[].sla` (per repo) carry the Delivery SLA block derived from the lifecycle timeline with no extra GitHub calls: `windows.{7d,30d}.{open_to_triage,triage_to_start,start_to_pr,pr_to_merge,open_to_merge}` as `{p50_h,p95_h,n}` (hours, nearest-rank), `history[]` of up to 30 daily buckets `{day,start_to_pr_p50,pr_to_merge_p50,open_to_merge_p50,n_started,n_pr,n_merged}` persisted under `/data/sla-history.json`, `stale_in_progress[]` (`{number,repo,started_at,age_h,agent}` — issues carrying `hive/in-progress` longer than the agent claim TTL with no linked PR), `stale_count`, `merged_7d`, `claim_ttl_s` and, on the fleet block, the effective `targets` (`start_to_pr_h`, `pr_to_merge_h`, `open_to_merge_h`); `staleSince` and `repos[].countsStale` / `countsStaleSince` mark totals served from last-good figures — the previous enumeration (#13382) or the ForgeState cache's last-good counts (#13376); `ci_failure_signals` `{count, last, kicks, unmatched}` is the webhook CI-failure signal store — distinct red (repo, head, check) signals retained, the most recent one `{repo, number, head_sha, check, conclusion, details_url, agent, at}`, webhook-triggered kicks/nudges since boot, and failure deliveries whose head matched no open PR; `hotspots` `{count, actionable, filed}` is the merge-hotspot advisor's one-line summary (files at/above the thresholds, those with a split recommendation, those with a modularize issue filed), absent when the advisor is not wired — details on `GET /api/hotspots`; `writeback.dedupe` `{enabled, dedupe_same_item, dedupe_burst, rate_capped, hourly_cap, burst_items, burst_window_s, same_item_ttl_s}` is the write-back gate's content layer — the effective `writeback.dedupe.*` settings and the last-hour counts of writes held as `duplicate`, `burst` and `rate-capped` (each also listed under `GET /api/writeback/suppressed`) | `pkg/dashboard/server.go:1651` | -| `GET` | `/api/status/summary` | Dashboard auth/session | Compact agent/governor/budget status summary for pollers; honors `Accept-Encoding: gzip` | `pkg/dashboard/server.go:1652` | -| `GET` | `/api/overview/issues.csv` | Dashboard auth/session | Cached Overview issue-band export as browser-compatible CSV; filters `band`, `repo`/`repos`, `stale`, and `held` are ANDed. | `pkg/dashboard/server.go:1653` | -| `GET` | `/api/overview/issues.json` | Dashboard auth/session | Cached Overview issue-band export as typed JSON with `bands[]` metadata and row fields matching the CSV columns. | `pkg/dashboard/server.go:1654` | -| `GET` | `/api/overview/prs.csv` | Dashboard auth/session | Cached Overview PR-band export as browser-compatible CSV; filters `band`, `repo`/`repos`, `stale`, and `held` are ANDed. | `pkg/dashboard/server.go:1655` | -| `GET` | `/api/overview/prs.json` | Dashboard auth/session | Cached Overview PR-band export as typed JSON with `bands[]` metadata and row fields matching the CSV columns. | `pkg/dashboard/server.go:1656` | -| `GET` | `/api/events` | Dashboard auth/session | Server-sent event stream | `pkg/dashboard/server.go:1657` | +| `GET` | `/api/health` | Public | Basic health probe | `pkg/dashboard/server.go:1639` | +| `GET` | `/api/health/deep` | Public | Deep health probe | `pkg/dashboard/server.go:1640` | +| `GET` | `/api/livez` | Public | Kubernetes liveness probe | `pkg/dashboard/server.go:1641` | +| `GET` | `/metrics` | Registered only when `HIVE_METRICS_ENABLED`; requires `Authorization: ****** (403 if the token is unset) | Prometheus metrics | `pkg/dashboard/server.go:1647` | +| `GET` | `/api/status` | Dashboard auth/session | Dashboard aggregate status; `labelPresets[]` (`{key,label,description,labels[],states[]}`) lists the built-in label-filter presets for the Projects cards, led by `needs-human` whose `labels[]` are the effective hard-suppress labels plus `needs-signal`, the hold labels, `stage/071-needs-author` and the reporter-trust awaiting label (#12172); accepts `?fields=a,b` for top-level selection and `?omit=repos` to drop heavy sections, and honors `Accept-Encoding: gzip`; `agents[]` includes busy-pane visibility fields (`kicksUndeliverable`, `busySince`, `lastTranscriptActivity`, `condition`, `conditionMessage`) when a Working pane cannot accept kicks; a working agent also carries `agents[].run` — the live per-run line (#14576): `{since, elapsedS, costUSD, tokens, priced, tests, filesChanged}`, the estimated spend/tokens since the kick was delivered (`lastKickAt`, falling back to `busySince`) (delta of the token collector's per-agent cumulative figure; `priced:false` when the agent has none yet), the last visible test-runner result (`pass`/`fail`/empty) and the last `N files changed` git summary (`-1` when none) parsed from the captured pane; top-level `fleetRun` `{running, hourUSD, hourPriced, dayUSD, weekUSD, monthUSD, windowsPriced}` is the governor strip's rotating `running N · $X this hour / today / this week / this month` figure (#15614) — the hour is the rise since the top of the clock hour, the wider windows are the daily cost ledger summed from 00:00 UTC today, Monday 00:00 UTC (ISO week) and the 1st 00:00 UTC plus the rise since the ledger's last snapshot, `windowsPriced:false` when there is no ledger yet; `sla` (fleet) and `repos[].sla` (per repo) carry the Delivery SLA block derived from the lifecycle timeline with no extra GitHub calls: `windows.{7d,30d}.{open_to_triage,triage_to_start,start_to_pr,pr_to_merge,open_to_merge}` as `{p50_h,p95_h,n}` (hours, nearest-rank), `history[]` of up to 30 daily buckets `{day,start_to_pr_p50,pr_to_merge_p50,open_to_merge_p50,n_started,n_pr,n_merged}` persisted under `/data/sla-history.json`, `stale_in_progress[]` (`{number,repo,started_at,age_h,agent}` — issues carrying `hive/in-progress` longer than the agent claim TTL with no linked PR), `stale_count`, `merged_7d`, `claim_ttl_s` and, on the fleet block, the effective `targets` (`start_to_pr_h`, `pr_to_merge_h`, `open_to_merge_h`); `staleSince` and `repos[].countsStale` / `countsStaleSince` mark totals served from last-good figures — the previous enumeration (#13382) or the ForgeState cache's last-good counts (#13376); `ci_failure_signals` `{count, last, kicks, unmatched}` is the webhook CI-failure signal store — distinct red (repo, head, check) signals retained, the most recent one `{repo, number, head_sha, check, conclusion, details_url, agent, at}`, webhook-triggered kicks/nudges since boot, and failure deliveries whose head matched no open PR; `hotspots` `{count, actionable, filed}` is the merge-hotspot advisor's one-line summary (files at/above the thresholds, those with a split recommendation, those with a modularize issue filed), absent when the advisor is not wired — details on `GET /api/hotspots`; `writeback.dedupe` `{enabled, dedupe_same_item, dedupe_burst, rate_capped, hourly_cap, burst_items, burst_window_s, same_item_ttl_s}` is the write-back gate's content layer — the effective `writeback.dedupe.*` settings and the last-hour counts of writes held as `duplicate`, `burst` and `rate-capped` (each also listed under `GET /api/writeback/suppressed`) | `pkg/dashboard/server.go:1652` | +| `GET` | `/api/status/summary` | Dashboard auth/session | Compact agent/governor/budget status summary for pollers; honors `Accept-Encoding: gzip` | `pkg/dashboard/server.go:1653` | +| `GET` | `/api/overview/issues.csv` | Dashboard auth/session | Cached Overview issue-band export as browser-compatible CSV; filters `band`, `repo`/`repos`, `stale`, and `held` are ANDed. | `pkg/dashboard/server.go:1654` | +| `GET` | `/api/overview/issues.json` | Dashboard auth/session | Cached Overview issue-band export as typed JSON with `bands[]` metadata and row fields matching the CSV columns. | `pkg/dashboard/server.go:1655` | +| `GET` | `/api/overview/prs.csv` | Dashboard auth/session | Cached Overview PR-band export as browser-compatible CSV; filters `band`, `repo`/`repos`, `stale`, and `held` are ANDed. | `pkg/dashboard/server.go:1656` | +| `GET` | `/api/overview/prs.json` | Dashboard auth/session | Cached Overview PR-band export as typed JSON with `bands[]` metadata and row fields matching the CSV columns. | `pkg/dashboard/server.go:1657` | +| `GET` | `/api/events` | Dashboard auth/session | Server-sent event stream | `pkg/dashboard/server.go:1658` | | `GET` | `/api/swarm` | Dashboard auth/session | Current swarm status: display name, duration, active repo, expiry, persisted prep metrics when available, and idle-unlock fields. | `pkg/dashboard/swarm.go:310` | | `POST` | `/api/swarm` | Owner only | Start a 24h repo swarm for a configured repo, returning 409 when another swarm is active and 423 when a previous swarm keeps the next swarm locked until enough agents are idle unless body `{"repo":"owner/name","force":true}` is used; saves the active record before repo prep, persists prep metrics, and announces the start to Discord when configured. | `pkg/dashboard/swarm.go:311` | | `DELETE` | `/api/swarm` | Owner only | End the active swarm, score issues closed and PRs merged in the window, append it to history, and announce the result to Discord when configured. | `pkg/dashboard/swarm.go:312` | diff --git a/src/docs/api-reference/snapshots-and-style.md b/src/docs/api-reference/snapshots-and-style.md index e9368ecbe2..7fa552fc14 100644 --- a/src/docs/api-reference/snapshots-and-style.md +++ b/src/docs/api-reference/snapshots-and-style.md @@ -6,7 +6,7 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f | Method | Path | Auth | Purpose | Source | |---|---|---|---|---| | `GET` | `/api/style` | Public | Sanitized custom dashboard CSS | `pkg/dashboard/api.go:46` | -| `GET` | `/branding/custom.css` | Dashboard auth/session | Operator branding stylesheet override, read per request (see [branding](../branding.md)) | `pkg/dashboard/server.go:1718` | +| `GET` | `/branding/custom.css` | Dashboard auth/session | Operator branding stylesheet override, read per request (see [branding](../branding.md)) | `pkg/dashboard/server.go:1722` | | `GET` | `/api/snapshot/frame-ancestors` | Public | Snapshot framing allowlist | `pkg/dashboard/api.go:82` | | `GET` | `/api/snapshot` | Public | Snapshot data | `pkg/dashboard/api.go:83` | | `GET` | `/snapshot` | Public | Public read-only snapshot page | `pkg/dashboard/api.go:84` | diff --git a/src/docs/env-vars.md b/src/docs/env-vars.md index 842849e5e5..007c20d120 100644 --- a/src/docs/env-vars.md +++ b/src/docs/env-vars.md @@ -77,6 +77,8 @@ behavior. [Maintenance limitations](#keeping-this-reference-current) still apply | `HIVE_HUB_TASK_STATUS_PUSH` | No | `hub.task_status_push`, default `true` | Enable the separate spoke task-status push loop. Accepts `1/true/yes/on` or `0/false/no/off` (case-insensitive); empty/invalid values fall back to config. Read at startup; restart after changing. Core heartbeat and hub-managed upgrade/config delivery remain enabled. | | `HIVE_HUB_PUBLIC_URL` | No | compiled fallback `https://hive.hivecommons.dev` (`defaultHubPublicURL`, `src/pkg/hub/saas_auth.go`) | Hub canonical public origin used to derive OAuth/OIDC callback URLs, hub Open Graph/notification links, same-origin checks, and the registrable-domain scope for hub SSO cookies. Public hub operators should set this to `https://hive.hivecommons.dev` for the cutover; leave the legacy value only while deliberately serving the redirect hostname. **Changing the registrable domain here signs users out of every first-party sibling product left on the old one** — the `hive_hub_user` cookie is scoped to this URL's registrable domain and a browser will not send it anywhere else. See [Moving a public hostname](hivecommons-migration.md#moving-a-public-hostname). | | `HIVE_HUB_SPOKE_DOMAIN` | No | compiled fallback `hive.hivecommons.dev` (`defaultHubSpokeDomain`, `src/pkg/hub/saas_auth.go`) | Parent domain used for hub-provisioned spoke ingress hostnames (for example `.`). Kept separate from `HIVE_HUB_PUBLIC_URL` because the wildcard spoke domain may differ from the hub's own hostname. | +| `HIVE_HUB_KIOSK_CTA_URL` | No | `https://hive.hivecommons.dev/get-started` (`kioskcta.DefaultURL`, `src/pkg/webassets/kioskcta`) | Destination of the call-to-action badge the hub Fleet activity page shows bottom-right when loaded with `?kiosk=1` (the fleet Twitch stream). Rendered as text and as a QR code. | +| `HIVE_HUB_KIOSK_CTA_TEXT` | No | `🐝 Want this for your repos?` (`kioskcta.DefaultText`) | Copy line above the URL on that badge. | | `HIVE_HUB_LEGACY_COOKIE_DOMAIN` | No | none | Optional transition-only hub SSO cookie domain to expire alongside the active cookie domain while accepting any carried `hive_hub_user` cookie value during a host migration. Writes still target the domain derived from `HIVE_HUB_PUBLIC_URL`; unset disables the extra legacy-domain cleanup. | | `HIVE_HUB_SECRET` | Required for spokes registered to a protected hub; optional for a standalone hub with `/data/saas/hub-secret.key` | `/data/saas/hub-secret.key` on the hub when present; no fallback for spoke heartbeat auth | Bearer secret for spoke heartbeats and hub/spoke SaaS APIs. | | `HIVE_HUB_AGENT_RESTART_PROBLEM_THRESHOLD` | No | `5` | Hosted hub threshold for surfacing agent restart storms on `/fleet`. When an agent reports at least this many restarts in the last 24 hours (or since the hub-side reset marker), the hive gets a restart problem chip and drift signal. | diff --git a/src/docs/streaming-the-activity-monitor.md b/src/docs/streaming-the-activity-monitor.md index 8436b4c041..dfb21a73de 100644 --- a/src/docs/streaming-the-activity-monitor.md +++ b/src/docs/streaming-the-activity-monitor.md @@ -38,6 +38,55 @@ monitor. Two knobs: Nothing here touches Twitch or the cluster until **you** create the Secrets and apply the overlay — the steps below are all yours to run. +### Call-to-action overlay + +Every kiosk view — this stream's Activity Monitor, the [Matrix](#matrix-mode-separate-channel) +and the hub's [public fleet page](#the-hivecommonsfleet-broadcast) — carries a +small pill bottom-right: "🐝 Want this for your repos?", the URL +`hive.hivecommons.dev/get-started` in 24px amber, and a 110px QR code of it, so +a viewer on a phone or a 720p transcode can get to **Request a Hive** without +typing. It appears only with `?kiosk=1` (never in the operator dashboard, +pop-out or display mode) and `&cta=off` in `DASHBOARD_PATH` removes it. On a +spoke the destination and the copy are `dashboard.kiosk_cta_url` and +`dashboard.kiosk_cta_text` in `hive.yaml` (read at start-up); on the hub they +are `HIVE_HUB_KIOSK_CTA_URL` and `HIVE_HUB_KIOSK_CTA_TEXT`. The QR code is +rendered server-side (`src/pkg/webassets/kioskcta`) as an inline `data:` PNG, so +nothing external is loaded and the pages' Content-Security-Policy is unchanged. +In Matrix mode the pill sits above the canvas at 85 % opacity so it does not +fight the effect. + +### Channel title, category, tags + +[`src/scripts/twitch-channel-cta.sh`](../scripts/twitch-channel-cta.sh) sets +the title, category and tags of `hivecommons`, `hivecommonsfleet` and +`hivecommonsmatrix` through Helix `PATCH /channels` so each channel page +carries the same call to action as the overlay; `--dry-run` shows the diff +without writing, and a channel that already matches is skipped. Twitch needs a +**user** access token per channel with the `channel:manage:broadcast` scope — +an app token cannot edit channel info — obtained once with the +[device-code grant](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#device-code-grant-flow): + +1. In the [Twitch developer console](https://dev.twitch.tv/console/apps) register + an application (category "Broadcasting Suite", OAuth redirect + `http://localhost`) and note its **Client ID** (`TWITCH_CLIENT_ID`). +2. For each channel, while logged in to Twitch as that channel: request a device + code — `curl -sX POST https://id.twitch.tv/oauth2/device -d client_id=$TWITCH_CLIENT_ID -d scopes=channel:manage:broadcast` — + open the returned `verification_uri`, enter the `user_code`, then exchange it: + `curl -sX POST https://id.twitch.tv/oauth2/token -d client_id=$TWITCH_CLIENT_ID -d device_code= -d grant_type=urn:ietf:params:oauth:grant-type:device_code`. + Keep the `access_token` (and `refresh_token`) out of the shell history, for + example in a password manager. +3. Export the tokens as `TWITCH_TOKEN_HIVECOMMONS`, `TWITCH_TOKEN_HIVECOMMONSFLEET` + and `TWITCH_TOKEN_HIVECOMMONSMATRIX`, then run + `src/scripts/twitch-channel-cta.sh --dry-run` and, when the diff is right, + without the flag. The script verifies that category id `1469308723` is + "Software and Game Development" against `/search/categories` before it writes + and never prints a token. + +Panels (the About tab under the player) have no API: upload the three images +produced for #16236 — "Request a Hive" → `hive.hivecommons.dev/get-started`, +"What is Hive?" → the docs, "Discord" → the invite — by hand on each channel's +**About → Edit panels**. + ## 1. Twitch side (once) Open the Creator Dashboard at `dashboard.twitch.tv` while logged in as diff --git a/src/internal/testutil/dashboard_import_allowlist.txt b/src/internal/testutil/dashboard_import_allowlist.txt index b7ac00bb75..1149871ee8 100644 --- a/src/internal/testutil/dashboard_import_allowlist.txt +++ b/src/internal/testutil/dashboard_import_allowlist.txt @@ -71,5 +71,6 @@ github.com/hivecommons/hive/pkg/timeline github.com/hivecommons/hive/pkg/tokens github.com/hivecommons/hive/pkg/turn github.com/hivecommons/hive/pkg/upstreamwatch +github.com/hivecommons/hive/pkg/webassets github.com/hivecommons/hive/pkg/worksource github.com/hivecommons/hive/pkg/writeback diff --git a/src/pkg/config/config.go b/src/pkg/config/config.go index 1f939970c3..7b455118c2 100644 --- a/src/pkg/config/config.go +++ b/src/pkg/config/config.go @@ -4988,6 +4988,12 @@ type DashboardConfig struct { // "redirect_uri is invalid". Validated at load time by // ValidateDashboardPublicURL. PublicURL string `yaml:"public_url,omitempty" json:"public_url,omitempty"` + // KioskCTAURL and KioskCTAText are the destination and copy of the + // call-to-action badge every `?kiosk=1` view shows bottom-right (#16236, + // pkg/webassets/kioskcta). Empty takes the hosted-hive request page and + // its default line. Read once at dashboard start-up, like branding. + KioskCTAURL string `yaml:"kiosk_cta_url,omitempty" json:"kiosk_cta_url,omitempty"` + KioskCTAText string `yaml:"kiosk_cta_text,omitempty" json:"kiosk_cta_text,omitempty"` // Theme names the built-in dashboard theme id ("hive" by default) or // "custom" when theme_overrides supplies the complete operator palette. Theme string `yaml:"theme,omitempty" json:"theme,omitempty"` diff --git a/src/pkg/dashboard/import_count_test.go b/src/pkg/dashboard/import_count_test.go index 80828584f6..a1c7d4e6e4 100644 --- a/src/pkg/dashboard/import_count_test.go +++ b/src/pkg/dashboard/import_count_test.go @@ -57,8 +57,11 @@ func TestDashboardInternalImportCountRatchet(t *testing.T) { // (hivecommons/hive#13536), plus pkg/hubactivity, the leaf wire contract // (ceilings, urgency order, sanitiser) the spoke's heartbeat activity // digest is built against from the dashboard's own stage tracker - // (hivecommons/hive#15963). - const maxDashboardInternalImports = 57 + // (hivecommons/hive#15963), plus pkg/webassets, the browser-asset + // packages (tracker view, kiosk call-to-action badge) shared verbatim by + // the spoke dashboard and the hub's public Fleet page so the two kiosk + // surfaces render one markup (hivecommons/hive#16236). + const maxDashboardInternalImports = 58 entries, err := os.ReadDir(".") if err != nil { diff --git a/src/pkg/dashboard/kiosk_cta.go b/src/pkg/dashboard/kiosk_cta.go new file mode 100644 index 0000000000..639ced1000 --- /dev/null +++ b/src/pkg/dashboard/kiosk_cta.go @@ -0,0 +1,17 @@ +package dashboard + +import "github.com/hivecommons/hive/pkg/webassets/kioskcta" + +// kioskCTAOptions is what the kiosk call-to-action badge (#16236) says on +// this spoke: dashboard.kiosk_cta_url / dashboard.kiosk_cta_text, or the +// package defaults (the hub's get-started page) when unset or when the +// server runs without a config, as in tests. +func (s *Server) kioskCTAOptions() kioskcta.Options { + if s.deps == nil || s.deps.Config == nil { + return kioskcta.Options{} + } + return kioskcta.Options{ + URL: s.deps.Config.Dashboard.KioskCTAURL, + Text: s.deps.Config.Dashboard.KioskCTAText, + } +} diff --git a/src/pkg/dashboard/kiosk_cta.test.js b/src/pkg/dashboard/kiosk_cta.test.js new file mode 100644 index 0000000000..7fbcef84f2 --- /dev/null +++ b/src/pkg/dashboard/kiosk_cta.test.js @@ -0,0 +1,35 @@ +// Kiosk call-to-action badge (hivecommons/hive#16236): boot.js turns the +// badge on for `?kiosk=1` only, `&cta=off` opts out, and the stylesheet keeps +// #kiosk-cta hidden without body.kiosk-cta-on so the operator dashboard never +// shows it. Runs against the shipped index.html. +const test = require('node:test'); +const assert = require('node:assert'); +const fs = require('node:fs'); +const path = require('node:path'); + +const html = fs.readFileSync(path.join(__dirname, 'static', 'index.html'), 'utf8'); + +test('hiveKioskCTAOn: kiosk=1 only, cta=off opts out', () => { + const m = html.match(/window\.hiveKioskCTAOn=function\(href\)\{[\s\S]*?\n \};\n/); + assert.ok(m, 'hiveKioskCTAOn not found in index.html'); + const window = {}; + new Function('window', m[0])(window); + const on = window.hiveKioskCTAOn; + assert.strictEqual(on('https://hive.example/?kiosk=1#section-activity-monitor-section'), true); + assert.strictEqual(on('https://hive.example/?kiosk=1&view=matrix&sound=off'), true); + assert.strictEqual(on('https://hive.example/?kiosk=1&cta=off'), false); + assert.strictEqual(on('https://hive.example/'), false); + assert.strictEqual(on('https://hive.example/?display=1'), false); + assert.strictEqual(on('https://hive.example/?popout=1'), false); + assert.strictEqual(on('not a url'), false); +}); + +test('badge wiring: placeholder outside the root, hidden without the body class, lifted and dimmed in matrix', () => { + assert.ok(html.includes("if(window.hiveKioskCTAOn(window.location.href)) document.body.classList.add('kiosk-cta-on');")); + const root = html.indexOf(''); + const ph = html.indexOf(''); + assert.ok(root > 0 && ph > root, 'placeholder must follow the dashboard root'); + assert.ok(html.includes('#kiosk-cta { display: none; }')); + assert.ok(html.includes('body.kiosk-cta-on #kiosk-cta {')); + assert.ok(html.includes('body.matrix-mode #kiosk-cta { z-index: 100001; opacity: .85; }')); +}); diff --git a/src/pkg/dashboard/kiosk_cta_test.go b/src/pkg/dashboard/kiosk_cta_test.go new file mode 100644 index 0000000000..1c646fcac1 --- /dev/null +++ b/src/pkg/dashboard/kiosk_cta_test.go @@ -0,0 +1,30 @@ +package dashboard + +import ( + "strings" + "testing" + + "github.com/hivecommons/hive/pkg/config" + "github.com/hivecommons/hive/pkg/webassets/kioskcta" +) + +// The served index carries the kiosk call-to-action badge (#16236) where the +// shipped document leaves its placeholder, with dashboard.kiosk_cta_* text. +func TestKioskCTAInjectedIntoIndex(t *testing.T) { + raw := indexHTML(t) + if !strings.Contains(raw, kioskcta.Placeholder) { + t.Fatal("static/index.html has no kiosk CTA placeholder") + } + s := &Server{deps: &Dependencies{Config: &config.Config{}}} + s.deps.Config.Dashboard.KioskCTAURL = "https://hive.example/go" + s.deps.Config.Dashboard.KioskCTAText = "Ask us" + out := string(kioskcta.Inject([]byte(raw), s.kioskCTAOptions())) + for _, want := range []string{`