diff --git a/docs/standards/versioning.md b/docs/standards/versioning.md index 82a873a4a..681973bf7 100644 --- a/docs/standards/versioning.md +++ b/docs/standards/versioning.md @@ -153,6 +153,12 @@ notice. Unknown SHA is not inferred from a branch name in GitHub metadata. The publisher records a full SHA in `target_commitish` and verifies actual tag identity separately. Stable update notices ignore prereleases. +Mode entry and the Site's App control share the check against the App's compiled +identity. A newer stable release marks that App control; its panel groups the +installed version, manual download and App management. This also covers starred +Site startup, which bypasses mode entry. Approved health supplies build identity; +older Apps without that metadata retain their ordinary connection and management. + ### Major-Upgrade Guidance The App update notice keeps direct download as its primary action, with a small diff --git a/src/client/channel/app-link.ts b/src/client/channel/app-link.ts index 6212e80a5..76a1bb2f8 100644 --- a/src/client/channel/app-link.ts +++ b/src/client/channel/app-link.ts @@ -10,7 +10,8 @@ import type { CaptureDevice } from "../media/capture-devices"; import type { BrowserVideoCodecMode } from "../webrtc/video-codec"; const identitySchema = z.object({ service: z.literal("piik-channel-app"), protocol: z.number().int().positive(), port: z.number().int().min(1).max(65535) }); -const healthSchema = identitySchema.extend({ protocol: z.literal(1), token: z.string().min(1).max(256).regex(/^[A-Za-z0-9_-]+$/) }); +const healthSchema = identitySchema.extend({ protocol: z.literal(1), token: z.string().min(1).max(256).regex(/^[A-Za-z0-9_-]+$/), + version: z.string().optional(), revision: z.string().optional(), packageTarget: z.string().optional() }); type AppHealth = z.infer; const captureSourcesSchema = z.object({ sources: z.array(nativeCaptureTargetSchema), processAudio: z.boolean(), processAudioExclusion: z.boolean().default(false), systemAudio: z.boolean(), activationURL: z.string().url().max(512).optional() }).strict(); diff --git a/src/client/components/living/AppConnectionButton.tsx b/src/client/components/living/AppConnectionButton.tsx index 0fb53b581..0f3c9af3a 100644 --- a/src/client/components/living/AppConnectionButton.tsx +++ b/src/client/components/living/AppConnectionButton.tsx @@ -10,6 +10,9 @@ import { LoadingStatus } from "./WaitingStatus"; import { useAnchoredPopover } from "./use-anchored-popover"; import { androidAppIntent } from "../../native/activation"; import type { AppDiscovery } from "../../native/discovery"; +import type { AppReleaseIdentity } from "../../lib/release-update"; +import { useReleaseUpdate } from "../../lib/use-release-update"; +import { AppReleaseNotice } from "./AppReleaseNotice"; interface AppConnectionProps { onConnected?: () => void; @@ -43,25 +46,34 @@ export function AppConnectionButton({ onConnected, discovery, connected }: AppCo useAnchoredPopover(trigger, help); const pending = useRef(null); const healthCheck = useRef(null); + const [build, setBuild] = useState(); + const { update: release, refresh: checkRelease } = useReleaseUpdate(build); + function rememberBuild(health: Partial | null) { + setBuild(health?.version && health.revision + ? { version: health.version, revision: health.revision, packageTarget: health.packageTarget } : undefined); + } useEffect(() => { + if (connected === false) rememberBuild(null); const refresh = async () => { if (pending.current) return; if (connected) { - healthCheck.current?.abort(); setState("ready"); - return; } - if (help.current?.matches(":popover-open") || !isClientActivated()) return; + if (help.current?.matches(":popover-open") || (!connected && !isClientActivated())) return; healthCheck.current?.abort(); const current = healthCheck.current = new AbortController(); const native = await loadDiscovery(); if (current.signal.aborted) return; try { const health = await native.health({ signal: current.signal, waitForPermission: false }); - if (!current.signal.aborted && !pending.current) setState(health ? "ready" : "idle"); + if (!current.signal.aborted && !pending.current) { + rememberBuild(health); + if (!connected) setState(health ? "ready" : "idle"); + } } catch (error) { if (!current.signal.aborted && !pending.current) { - setState(native.isIncompatible(error) ? "incompatible" : "idle"); + rememberBuild(null); + if (!connected) setState(native.isIncompatible(error) ? "incompatible" : "idle"); } } }; @@ -99,6 +111,7 @@ export function AppConnectionButton({ onConnected, discovery, connected }: AppCo if (signal.aborted) return; approving = false; if (health) { + rememberBuild(health); finish("ready"); activateClient(); onConnected?.(); @@ -149,6 +162,7 @@ export function AppConnectionButton({ onConnected, discovery, connected }: AppCo if (!url) { finish("unavailable"); return; } const health = await native.health({ signal, waitForPermission: false }); if (signal.aborted) return; + rememberBuild(health); manage = manage && health !== null; if (health && !manage) { finish("ready"); @@ -197,19 +211,23 @@ export function AppConnectionButton({ onConnected, discovery, connected }: AppCo incompatible: "native.incompatible", } as const)[state]); const failed = state === "unavailable" || state === "incompatible"; - return <> @@ -231,6 +249,8 @@ export function AppConnectionButton({ onConnected, discovery, connected }: AppCo

{state === "busy" ? t("client.connect.permissionHint") : label}

+ {state === "ready" && build &&

{t("client.launch.version", { version: build.version })}

} + {update && }
{state !== "busy" &&