Pair displays at the platform's own /display/setup, with or without modules
CI / verify (pull_request) Successful in 1m12s
CI / infrastructure-smoke (pull_request) Successful in 45s
CI / package-release (pull_request) Successful in 50s
CI / migration-smoke (pull_request) Successful in 2m34s
CI / image-build (pull_request) Successful in 1m8s
CI / deploy-smoke (same-origin) (pull_request) Successful in 51s
CI / package-publication (pull_request) Successful in 57s
CI / deploy-smoke (split) (pull_request) Successful in 3m52s

Displays are platform-owned, but a screen could only start pairing on a
module's display page: every pairing request named a module, so an
installation with no module that uses displays could not set one up.

- /display/setup is the platform's own display page, served whenever
  the deployment has device support, whatever is installed. It pairs a
  platform display with no module. Once paired, it opens the module it
  is set to show; with none set, it shows its name and waits, rechecking
  so it stays alive and notices revocation. "setup" is now a reserved
  module id.
- Migration core:0009_platform_display_pairing lets a pairing request
  name no module. It relaxes module_id and permission_id and adds a
  both-or-neither check. It is additive and destroys nothing.
- POST /api/v1/device-pairing/requests accepts {} for a platform
  display. Approval accepts an optional moduleId, so the administrator
  can choose an installed display module and the device gets that
  module's declared permission. A module display's own request can't be
  redirected.
- GET /api/v1/device-pairing/self lets a paired device describe itself:
  its name and the module displays it may show. It renews the device's
  cookie.
- GET /api/v1/devices/setup is replaced by
  GET /api/v1/devices/display-modules: the modules a display can be set
  to show.
- Settings -> Displays always offers the /display/setup address, Copy
  setup link and Add display. Add display has an optional "Show on this
  screen" choice, and each paired display says what it shows.
- /display/<module-id> is unchanged, so released Signage 0.1.5 works as
  before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ekklesia
2026-10-16 16:43:02 -05:00
co-authored by Claude Opus 5.5
parent 906c015ca8
commit 300d9eab51
44 changed files with 3169 additions and 396 deletions
+47 -1
View File
@@ -22,14 +22,16 @@ import {
type LegacyModuleRuntimeServices,
type ModuleDatabase,
} from "@ekklesia/core/modules";
import type { Hono } from "hono";
import { Hono } from "hono";
import { afterEach, describe, expect, it, vi } from "vitest";
import { createApiApp } from "../src/app.js";
import { createDisplayHostAssets, type DisplayHostAssets } from "../src/display-host-assets.js";
import {
DISPLAY_HOST_SCRIPT_PATH,
DISPLAY_SERVICE_WORKER_PATH,
DISPLAY_SETUP_PAGE_URL,
ModuleDisplayConfigurationError,
mountModuleDisplayRoutes,
moduleDisplayDescriptorUrl,
moduleDisplayPageUrl,
} from "../src/module-display-routes.js";
@@ -568,3 +570,47 @@ describe("module display host asset publication", () => {
}
});
});
describe("the platform display setup page (ADR 0065)", () => {
function bare(options: { readonly platformSetup?: boolean; readonly assets?: boolean }) {
const app = new Hono();
mountModuleDisplayRoutes(app, {
evaluator: createAuthorizationEvaluator({
grants: { hasActiveGrant: async () => false },
platformOwners: { isPlatformOwner: async () => false },
}),
// No installed module has a display at all.
moduleUi: createModuleUiPublicationRegistry([]),
registry: composePlatformPermissionRegistry([]),
runtime: {
handleAuthRequest: vi.fn(),
resolvePrincipal: vi.fn().mockResolvedValue(ANONYMOUS_PRINCIPAL),
},
...(options.assets === false ? {} : { assets: displayHostAssets }),
...(options.platformSetup === undefined ? {} : { platformSetup: options.platformSetup }),
});
return app;
}
it("serves /display/setup and the display host with zero display modules installed", async () => {
const app = bare({ platformSetup: true });
expect(DISPLAY_SETUP_PAGE_URL).toBe("/display/setup");
const page = await app.request(DISPLAY_SETUP_PAGE_URL);
expect(page.status).toBe(200);
expect(page.headers.get("cache-control")).toBe("no-store");
// The same inert, module-agnostic page every display is served.
expect(await page.text()).toBe(displayHostAssets.html);
expect((await app.request(DISPLAY_HOST_SCRIPT_PATH)).status).toBe(200);
expect((await app.request(DISPLAY_SERVICE_WORKER_PATH)).status).toBe(200);
// Nothing else beneath /display/ exists.
expect((await app.request("/display/signage")).status).toBe(404);
});
it("is not served without device support, and device support needs the display host", async () => {
expect((await bare({}).request(DISPLAY_SETUP_PAGE_URL)).status).toBe(404);
expect(() => bare({ assets: false, platformSetup: true })).toThrow(
ModuleDisplayConfigurationError,
);
});
});