Files
piik/docs/standards/presentation-lifecycle.md
T
AAA da7218bf44 feat(voice): add room voice and secure local invitations
## Problem and outcome / 问题与结果

Planned release: **v2.3.0**, preserving the published 2.x sharing contracts.

Friends can now talk in a Piik room before, during or after screen sharing. Room
voice, media forwarding and the picture retain separate lifetimes under the
existing room authority and route controller. This phase also improves direct LAN
entry, native capture startup, interaction controls and first-use documentation.

Related: #484, #437, #486, #488, #485 and #489. These references do not declare
all reported hardware or distribution problems fixed.

## Release notes

**Less typing. More talking.**

Piik now supports room voice, with or without screen sharing.

**聊不够?开麦吧!**

Piik 现已支持房间语音,不开播也能聊。

### English

This update adds room voice alongside sharing, chat and reactions, with clearer
controls and direct HTTPS invitations for local and virtual networks.

#### Highlights

- Create a room before sharing. The Host opens or closes room voice; friends
  can join, control their own microphone and listening, or mute someone locally.
  Joining voice keeps the microphone off until you enable it.
- Choose your microphone, adjust microphone, master and individual listening
  volumes from 0% to 200%, and enable voice processing in the interaction window.
  Audio icons offer quick volume sliders. The microphone icon shows live input
  level. Voice continues when the picture stops.
- Use a local HTTPS invitation for microphone and remote-control features on a
  LAN or virtual LAN. A temporary local certificate requires a browser warning
  confirmation; a self-hosted Server can also use supplied certificate files.
- Rotate your local picture, optionally volunteer more relay capacity, and
  download a native Windows x64 Server package.

#### Fixes and polish

- Align Windows automatic encoder probes with the surfaces used during actual
  capture; keep video capture progressing while optional source audio starts.
- Correct Linux desktop pixel-aspect negotiation and accept fitted native
  source dimensions without forcing a different aspect ratio.
- Avoid retaining false media queue congestion when producer and consumer
  clocks disagree.
- Distinguish chat authors with identical names, clarify remote permissions,
  and keep floating tools, contextual hints and microphone indicators aligned.
- Separate first-use guides, room tools and troubleshooting so help is easier
  to find.

Use updated Server/Web pages for room voice and update the App for the native
capture and local HTTPS improvements. Established 2.x sharing remains supported.
macOS builds do not yet carry Developer ID signing or Apple notarization; see the first-launch instructions.
The macOS audio-startup changes still need confirmation on an affected Mac.

### 中文

本次更新为分享、聊天和表情互动加入房间语音,同时打磨操作控件,并为局域网和虚拟局域网提供直接 HTTPS 邀请。

#### 主要变化

- 不开播也能创建房间。房主开启或关闭房间语音;朋友可以加入、自行开关麦克风和收听,或仅在自己这边静音某人。加入语音时默认不开麦。
- 在互动窗口选择麦克风、分别调整 0%–200% 的麦克风、总收听与个人音量,并设置语音处理。音频图标可展开快捷音量条,麦克风图标显示实时输入音量。停止画面分享后,语音仍可继续。
- 局域网和虚拟局域网可使用本地 HTTPS 邀请,启用麦克风和远程控制;临时本地证书需要在浏览器确认警告。自部署服务端也可使用自行提供的证书文件。
- 可旋转本地观看画面、自愿增加转发容量,并提供 Windows x64 服务端下载包。

#### 修复与打磨

- Windows 自动编码探测使用与实际采集一致的输入;可选来源音频启动期间,画面采集继续运行。
- 修正 Linux 桌面采集的像素比例协商;原生来源保留实际画幅,不再要求固定比例的尺寸。
- 避免生产者和消费者时钟不一致时,错误保留媒体队列拥塞状态。
- 区分同名聊天作者,明确远控授权,并统一浮窗、上下文提示与麦克风指示器的细节。
- 分开首次使用、房间工具和故障排查文档,让帮助更容易查找。

房间语音需使用更新后的服务端和网页;原生采集与本地 HTTPS 改进需更新 App。既有 2.x 分享仍保持兼容。
macOS 构建仍未正式签名和公证,首次启动请参照文档;音频启动调整仍需在受影响的 Mac 上确认。

## Verification / 验证

Full Web checks, Go tests/vet/build/native probes, reachable vulnerability checks,
normal-page P2P/SFU voice and compatible sharing, LAN HTTPS, detached interaction
tools, responsive controls and tooltip/pure-visual checks provide acceptance
evidence. Physical macOS/Linux capture and acoustic behavior on arbitrary devices
are not established by these controls.

Scoped contributions from #488 (Linux pixel aspect) and #485 (Windows Server
packaging) are retained as their original authors' patch commits in this PR.
The remaining implementation and integration belong to the maintainer.

## Impact / 影响

Preserve the published 2.x sharing contract. New room-voice behavior is opt-in;
Host voice activation, capture and picture lifetimes remain distinct. Local
certificate material remains in memory; no system trust installation is performed.
2026-10-21 06:51:22 -04:00

23 KiB
Raw Blame History

Presentation And Lifecycle

This file owns user-visible workflow, presentation authority, presence, and Browser lifecycle promises. Component structure, CSS, exact copy, and routine UI tests belong in source code.

Product Surface

The first screen is the working tool, not a marketing page. Once site access is available, starting a share and joining a room are equally discoverable actions; joining expands the four-digit room form in place, while /join remains a direct entry route. Users never choose a media topology.

Host entry requires both site access and a validated capability description. Initial entry, retry and password recovery load the same prerequisites; failed authentication cannot leave a later successful entry using absent capability state. A capability-load failure remains retryable and does not imply that a service is available or disabled. Viewer/Join entry does not need this Host-only description.

The Host workspace centers the capture preview, room code, invitation and common share controls. The Viewer workspace centers one persistent 16:9 video stage, room identity, current state, roster, and one manual media-reconnect action. Controls and text must remain usable without overlap or horizontal overflow on desktop and mobile viewports.

Personal room-tool presentation and incoming-route preferences are remembered within the same Browser origin across rooms and reloads. Their existing domain owners still apply capability and room-policy constraints. Remote-control shortcut choices follow this same boundary; App applies them only in memory. Restoring preferences never restores room admission, control grants, actual held input, passwords or message drafts, and never starts capture or remote control.

A capable, opted-in authenticated room session outlives its current publication. Stopping capture retires media, not chat; restoring an existing room joins it without starting capture. Entering the page alone does not create a room. Room close, lost authority and page teardown still retire the session, including its App control connection and pending discovery. That retirement cannot wait for the denied page to unmount. Connected Viewers may keep interacting while the Host page is absent, provided the room service and their admitted sessions remain available. Rooms and access owns interaction authority and retention; status owns release readiness.

The Host can explicitly Create room before sharing. Chat and voice use tabs in the existing interaction window, including its detached presentation. Closing or changing that window does not leave voice or stop capture. Microphone, admission and connection states stay literal; an enabled microphone is not proof that someone is speaking. The room voice contract owns channel activation and membership, independently of the window and picture publication.

On capable desktop browsers, the interaction window can move to a Document Picture-in-Picture window. It retains the admitted room session's messages, reactions and draft. Read visibility and guidance follow its current document. Closing the window returns it to the page; room retirement or opener teardown closes it, including a late asynchronous open. Browser window support does not promise game-overlay transparency, click-through or exclusive-fullscreen coverage.

Piik App opens this same application in the system Browser. Its startup surface offers Local and temporary public invitation; the running App is already available to its approved Site before either mode starts. The desktop App entry is omitted on known mobile platforms; Browser and camera actions retain their own capability checks. A Site's explicit App action discovers the local approval page, where the user confirms its exact origin. The launcher shows and revokes that approval. Starring the approved Site makes an ordinary App launch open it; without a star, the launcher opens. This preference grants no access and starts no room. Replacing or revoking approval clears it; explicit CLI entry keeps precedence. The ready App button and terminal launcher address return to its management page in every mode. Local/public room startup is one selection per App run; reopening the launcher does not stop or replace that room. Changing between those modes requires restarting App. Activating a page supplies native capability without restarting its room or healthy media session. The source selector exposes that same connection action before sharing; a successful connection refreshes its current list. An already approved exact origin needs no repeat confirmation, but the page still verifies authorized App health. Closing the selector cancels its pending connection action. Existing Browser shares retain their capture implementation until sharing ends. App-created Local/public-invite Host pages open at their automatically approved loopback origin. The shared App button reflects verified authorized health, including activation through another entry and return to an activated page; a remembered activation alone cannot show readiness. Idle verification holds no media session or polling loop. Viewer links opened at that activated origin may use the same running App without changing the Viewer UI. Starting a share offers the Browser picker and any exact App-owned native windows. It never chooses a window automatically. A reproduced Browser-window, capture, or background failure is required before introducing an embedded Web runtime.

Opening the system Browser is an asynchronous convenience action. One pending OS handoff is allowed; a slow or failed handler cannot block readiness or App exit. The console retains the entry address and reports the underlying error. The App does not terminate the user's browser to enforce a handoff deadline.

Server and App share one control layout and vocabulary. Deployment capabilities may fix a control on or off, but do not remove its place in the interface; disabled controls explain their reason in text and pure-visual modes. Real workflow differences remain explicit: site authorization, opt-in diagnostics and the capture/audio capabilities of the connected device are not alternate versions of the product UI.

A remembered App activation permits discovery when choosing a source or receiving media; it does not make App a prerequisite for sharing. Idle Host pages hold no App control session. The shared source selector orders Browser, Camera, Window and Screen, defaulting to Window after App detection. Without an App it shows only Browser and Camera, defaulting to Browser. Discovery never blocks Browser selection or overrides an explicitly chosen tab. Refresh remains reachable after failed App discovery; pending attempts are shared, completed failures do not suppress later discovery. Cancelling the selector or ending a share releases its unused control session; an obsolete operation cannot install or retire another operation's media. Cancellation covers discovery and the opening handshake, not just a connection returned later. Camera thumbnails own only temporary preview inputs; leaving their tab or picker retires them. An active shared camera is borrowed, never reopened or stopped by preview. Optional native ingress uses an already available connection without another scan. If it is not ready at Browser startup, that share keeps Browser senders.

Native Host startup acquires its required Browser media connection before starting capture. Cancellation owns that connection immediately, while native share ownership and required audio tracks come from the accepted App response. Browser initialization failure remains distinct from capture permission failure.

A reachable Piik App with an incompatible control protocol is distinct from an absent App. Discovery continues looking for a compatible process before reporting the mismatch; the source selector retains Browser operation and offers update/ refresh guidance. Discovery metadata may grow, while known identity and capability types remain validated. Missing optional capabilities are unavailable; control commands and responses retain their strict protocol contract. An empty source list means enumeration succeeded for the selected category. Connection, capture-capability and enumeration failures keep their own feedback. Discovery has one bounded deadline that allows time for browser local-network consent; a failed fetch alone cannot establish that consent was denied. Optional Viewer reception uses Browser media immediately when the browser reports that local App access still needs consent or is denied. It rechecks permission on a later connection attempt; a later grant does not replace healthy Browser media. App Local needs no cross-address-space consent. Browsers without a permission query retain bounded discovery.

Visual Language

Chinese, English, and pure-visual modes are three expressions of the same typed state and command catalog. On first use, the App and Server UI match the Browser's primary system language against registered locales, using English when none matches. Current catalogs cover Simplified Chinese and English. Both Simplified and Traditional Chinese system locales select the current Chinese catalog across App, Server UI and website; this includes region and script tags such as zh-CN, zh-TW, zh-HK, zh-Hans and zh-Hant. Pure-visual mode remains an explicit choice. An explicit later choice is persisted and takes precedence over that default, including App launch handoff. Explicit launcher choices apply only to the presentation domains the user chose. Older launchers cannot distinguish defaults from explicit choices; updated Sites preserve their saved preferences when receiving those unmarked hints. The App console uses its own supported presentation languages and falls back to English for additional UI languages. Text modes use concise copy.

The visual language is the single owner of illustrative roles and objects, semantic colour, panel grammar, motion, accessible input and responsive hierarchy.

Playback Ownership

One <video> element owns Viewer playback and frame proof. The shared playback bar reflects that element and provides local play/pause, mute, volume, theater, picture-in-picture, fullscreen and the existing reconnect action. It stays reachable while waiting or disconnected. Theater and fullscreen are separate modes. Page-element fullscreen includes the playback bar; Safari's video-only fullscreen uses system controls and native video events to reflect playback and exit. Identity, connection details and topology stay in the deck. Room tools outside the fullscreen player close when it enters fullscreen. Returning a detached tool during fullscreen keeps it closed in the page; leaving fullscreen allows reopening it with its session and draft intact. The fullscreen bar retains the danmaku toggle, not an interaction-window entry.

Viewer playback settings reuse shared controls in an anchored popover; placement follows the visual language without resizing video. Local picture fit defaults to contain; cover preserves proportions and may crop edges, while stretch fills the player by changing proportions. These choices do not change capture or encoding. Manual quarter-turn rotation is another local picture preference; it does not depend on device auto-rotation and applies to page playback, including theater and DOM fullscreen. System video presentations retain their browser-owned behavior. Remote input and magnification use the same rendered picture geometry. Incoming-route choice follows the routing contract; its selected value is server-acknowledged intent, not evidence of the currently playing route.

Replacement video bindings do not consult Viewer-local pause: when the Host is playing, they attempt playback subject to browser autoplay permission. There is no separate remembered playback intent for source changes or reconnects. A new binding received while the Host is paused waits for the Host to resume; it does not inherit the previous binding's Viewer-local pause. Adding, replacing or removing audio on the same video binding updates only its audio consumer; it preserves current-frame proof and Viewer-local playback. A pending play() canceled by pause or rebinding is not a media failure; cancellation alone must not invalidate frame proof or disable local playback.

The bar floats at the picture's lower edge. Narrow screens shorten the volume slider and move secondary display actions into settings, preserving one row and 44px control height; the percentage readout hides on narrow screens. Playing video hides the bar after two idle seconds, following Media Chrome's default. Pause or unavailable playback keeps it visible. Control hover, keyboard focus, dragging and an open tooltip hold it open. Mouse movement reveals it; a touch tap on the picture toggles only visibility. Remote input owns picture clicks and movement, so use the bezel pull during control; pointer-locked input also never reveals the toolbar through mouse movement. One presentation hook owns visibility for the current player, using one idle timer; it never changes playback or route state. Controls follow the shared motion grammar.

A picture click does not pause playback; the playback button and focused-video keyboard shortcut own that action. Desktop double-click toggles the available fullscreen action. Remote-control input consumes its own clicks and key presses; controls and overlays keep their own immediate behavior.

Host source-audio feedback describes the selected source independently of room voice. Viewer picture-sound controls require a received audio track and, when the Host supplies input availability, an available source or microphone input (including published commentary from older Hosts). With no input, sound controls are disabled with the no-audio explanation; the Viewer's volume and mute preferences remain intact for audio returning. Older Hosts without this fact retain received-track feedback. These controls do not infer input presence from silence or change capture, transport or relay audio.

Volume starts on native audio output. An explicit setting away from 100% activates a local Web Audio stream source and gain, from silence to 200% amplitude. This also avoids iPhone's system-owned video.volume. This output exclusively owns sound while running, follows video pause and user mute, and rebinds when the audio track changes. It never modifies the received track or the stream relayed downstream. Unmount closes the graph. Browsers without gain support retain 0–100%; video-only system fullscreen also hands audio back to the native controls at at most 100%, rather than running two outputs.

This uses the standard Web Audio stream-source and gain nodes. The gain is amplitude scaling, so loud source peaks can clip above 100%.

Picture-in-picture uses the browser's native video window, including Safari's presentation-mode API. Native enter/leave events own its displayed state; closing the window or replacing the received stream does not create another playback owner. Successful entry exits this video's other fullscreen mode, and unmount closes only this video's window. Unavailable capabilities remain disabled with an explanation. The native window contains video and system controls, not page overlays or the custom bar. See the PiP specification and Safari integration.

Local playback actions never change Host capture or another Viewer. Reconnect retains the existing route-operation owner. The Host preview remains muted and has no media controls; explicit Host actions own authoritative pause and stop.

Autoplay rejection exposes the play action. A connection, track object, or playing event alone is not proof that the current route is visible. The Viewer removes its blocking presentation only after a current-generation frame is composited, using requestVideoFrameCallback() where available and a decoded- progress fallback otherwise.

State And Recovery

Access, Host presence and pause, route prepare/active, P2P/SFU connection, media binding, frame proof, autoplay, and terminal failure are typed facts interpreted by one presentation reducer. Older route or media generations cannot overwrite the current result, and raw server errors are never rendered directly.

The room route revision orders control messages; it is not a Viewer media identity. Reauthentication replaces the route snapshot authoritatively, even if a replacement controller restarted revision numbering; ordinary updates remain monotonic within that authority. A Viewer frame belongs to its local media generation and remains current across unrelated graph revisions until that exact binding is replaced, invalidated, or terminally failed. Pending candidates never own the primary badge, status line, or overlay while committed media remains proved. A shared visual projection maps those facts to title, media status, notices and overlays. None of these views owns state for another. Connection availability, actual playback and quality limitation remain separate; raw transport snapshots do not prove playback or quality. The status preview records the visual vocabulary and the evidence needed for participant lamps.

Excluding time spent in the Browser's capture/play authorization UI, a Viewer request targets a first visible frame within three seconds. Until then, the page must continuously show a truthful accessible connection stage rather than a black screen, ICE-connected state, or unproved playing event.

  • A proved current frame remains visible behind non-terminal recovery state.
  • The status projection owns the television, Header, notices, participant lamps and title. These consumers cannot turn an unproved frame into playback or ordinary quality into failure.
  • The Host's couch and Viewer overview share the participant projection. The Host's own pawn has no additional lamp. Committed mediaReady owns readiness; transport diagnostics and quality samples cannot override it in either direction.
  • Viewers do not infer another Viewer's quality or diagnose missing readiness as terminal failure; roster readiness and quality evidence remain distinct.
  • An overlay explains the absence of a usable picture, authoritative Host pause, or a required user action. Ordinary quality warnings never cover playback.
  • Host pause retains the current frame and waits for resume.
  • Host signaling loss alone does not invalidate media that is still healthy.
  • Exact media failure or terminal route failure invalidates current-frame proof before showing a retained frozen background and recovery or failure state.
  • Room not found is distinct from current-room access denial and does not prompt for a password.
  • Manual reconnect recovers the same route. It does not select a new parent.
  • An actionable overlay may appear while fullscreen remains active; application state never forces the user out of fullscreen.

Decoded-frame silence is not a route-failure signal. A live source can stop repainting; media-framework failures, not an application silence timer, own recovery. First-frame admission and candidate-relative proof still require decoded progress. Visibility, page freeze, and pagehide invalidate quality observations, not already-proved playback. Returning to the page re-arms frame observation; an existing recovery state still requires a fresh current frame to clear. SFU media is retained independently of transient room-signaling loss, but Browser or OS suspension and page reclamation remain outside Web guarantees.

The local Native media bridge owns bounded ICE recovery on its existing connection and stream. Its offer identity fences each answer; retirement cancels pending negotiation and cannot recreate a source or receiver. Connection recovery does not assert fresh media, and an intentionally paused source is not a failure. First-frame and playback owners retain their existing evidence requirements.

Terminal failure of the local Native media bridge disables Native reception for the current Viewer session before route recovery runs. Future peers in that session use Browser reception; existing healthy peers are not torn down by this choice. Parent-network failure alone is not evidence that the local Native capability is unavailable.

The Native Host's local bridge remains required by its Browser share owner: the stream supplies preview and Browser quality candidates and participates in source and quality changes. A terminal failure retires that share through the existing Host lifecycle; it is not merely a missing preview. An individual downstream network failure instead recovers that edge and does not retire the bridge or capture. Browser capture's optional Native fanout can fall back to Browser senders because the Browser still owns its source.

Presence And Diagnostics

Host and Viewer pages show the authoritative online Viewer count and roster, independent of the media graph. A display name is Browser-local, NFC-normalized, at most 24 Unicode code points, and rejects unsafe control or bidirectional characters. It is a label, not an account, authorization identity, or routing input. Duplicate names are allowed and receive a room-scoped peer suffix only when disambiguation is needed. Chat applies the same labeling rule to recorded sender names; repeated messages from one peer do not create another identity. Media readiness never owns identity.

Connection details are progressive and use one card shape for P2P, peer relay, and SFU Viewers. Summary fields prioritize actual resolution, FPS, bitrate, and loss; deeper fields appear only when meaningful. Topology is a separate view. Native bandwidth or CPU limitation warnings describe the exact outbound sender that reported adaptation; they do not by themselves locate the physical bottleneck or describe the Viewer's receive path. The Host's participant freeze warning requires fresh receive evidence matching the current upstream and a positive freeze count or duration for that window. Window *Delta fields never inherit older values; other fields may retain their existing details-display cache. The existing evidence expiry removes stale warnings. No additional participant state, broadcast, timer or quality score is introduced. Detailed per-edge observations remain available without a global warning selected from the first limited child. Locally exposed selected-candidate addresses may be shown only on the Browser that owns that PeerConnection and are never uploaded, persisted, or used for identity or route selection. Explicit Debug mode can export a bounded diagnostic report through the separate diagnostic owner; ordinary connection details do not collect or expose that report.

Current scope includes Web Host, Web Viewer, Browser relay, and optional Native Host/Viewer media beneath those same pages. Desktop and mobile Browsers are Viewer targets; mobile Web capture, reliable background relay, App-owned SFU, and physical non-Windows native acceptance remain later platform work.

Primary References