Files
piik/prototype/channel-server
T
..

Piik 3.0 Site And Room Runtime

This reference describes the internal Piik 3.0 runtime: a shared Rust authority, the shared React interface and Browser WebRTC. Published 2.x App and Server instructions remain with the maintenance reference. The network design owns the accepted routing foundation; this file describes what currently runs. The product hierarchy is Site → Room / 站点 → 房间. Domain names the site's technical authority; existing Channel identifiers and package names retain their implementation meaning.

The Server executable consumes channel-core, the same Rust library used by Native and Browser/WASM. Its package and default binary remain piik-channel-prototype; the same runtime crate also builds piik-channel-app. The shared library is piik-channel-core. The Domain service owns its HTTP, WebSocket and directory lifetime; the Server composition adds deliberate Native room hosting. Local App composition reuses the Domain without inheriting that unattended participant.

The Server runs an embedded Native participant. In lightweight mode, rooms created in the interface use the creator's Browser/WASM runtime or linked App. In hosted mode, the embedded Native service opens and owns each room writer before the creator receives confirmation. The creator remains the room manager. The operator configuration below controls first-start hosting and creation policy.

The current room writer owns admission, policy, publication plans and confirmed history. The channel binds the authenticated writer and carries signed room commands through the domain WebSocket. Shared physical pairs serve independent room and publication work. File ranges travel over reliable data channels.

For an internal App package, follow the first-room guide for the launcher, invitations and sharing. The App data and backups reference explains saved data and backup scope.

Run

The Rust Server reads process environment variables; it does not load .env automatically. Compose and systemd load their environment files for it. The environment template owns the deployment example. The published 2.x guide describes a different runtime and its SFU controls.

Packaged Server

Use a matching 3.0 Server package and keep its bundled web/ directory beside the executable. For a new site, replace the placeholder below with a private random owner seed and save it securely. On Linux, run from the extracted directory:

export PIIK_CHANNEL_OWNER_KEY='<private owner bootstrap seed>'
./piik-server

On Windows, use PowerShell:

$env:PIIK_CHANNEL_OWNER_KEY = "<private owner bootstrap seed>"
./piik-server.exe

Open the address printed at startup. With no port or origin override, it is http://127.0.0.1:8791. The Server stores site and room data in data/ beside the executable unless PIIK_CHANNEL_DATA_DIR selects another directory. An existing site's database owns its saved key; changing the seed does not rotate it.

PIIK_CHANNEL_ROOM_CREATION_POLICY seeds the policy when a Server creates a channel. The default is ordinary, which lets members create ordinary rooms. invite_only limits members to unlisted, invite-only rooms. owner_only reserves room creation for the channel owner. The channel database retains the saved policy, including later changes by its owner, across restarts.

PIIK_CHANNEL_HOSTING_MODE selects the room host for a new Server channel. The default lightweight gives each creator's Browser or App the room data. hosted makes the Server the room host while the creator manages the room. The selected mode belongs to the saved channel and survives restarts. Restore a hosted channel backup on a standalone Server. App starts and restores lightweight channels.

A new Server site starts with Living room, Studio and Quiet corner hosted on the Server. The channel's hosting mode assigns the host for rooms created in the page. Hosting determines where room settings and history are stored.

Site forwarding

Site forwarding is off by default. To offer a fallback when participants cannot deliver media or files to one another, start or restart Piik Server with PIIK_CHANNEL_SERVICE_TRANSIT=true. The operator pays for the traffic that uses this fallback. All four switches accept lowercase true or false.

Optional switch What it controls
PIIK_CHANNEL_SERVICE_TRANSIT_SCREEN Live screen, window and camera shares, including share audio
PIIK_CHANNEL_SERVICE_TRANSIT_VOICE Room voice
PIIK_CHANNEL_SERVICE_TRANSIT_FILES Attachments and original video sent as data when watching together

Each optional switch defaults to true and takes effect only with the main switch on. Set a kind to false to disable it. Set all three to false to offer no forwarding.

This policy applies to both Server-hosted rooms and rooms hosted by a Browser or App on the site. A site started from Piik App uses participant connections. Room managers can turn off Use site forwarding under Room settings → Network, then select Save. The setting defaults to on, stays with the room across reconnections, and returns to the default when copied to a new room.

Piik uses an offered kind when assigning a route that participants cannot carry. An assigned route stays in use while it works and is needed. Screen viewers can still move to a direct connection to the sharer. Forwarding needs a reachable Server media path and enough bandwidth. Room hosting and chat or history access continue to follow their own permissions.

Development Server

Use Rust 1.91 or newer, the repository's Node/npm environment and installed npm dependencies. Build the standalone frontend first, and rebuild it after changing the shared Rust core. From the repository root, start Rust in one terminal:

$env:PIIK_CHANNEL_OWNER_KEY = "<private owner bootstrap seed for a new site>"
$env:PIIK_CHANNEL_WEB_DIR = (Resolve-Path build/channel-web).Path
$env:PIIK_CHANNEL_WEB_ORIGIN = "http://127.0.0.1:8790"
cargo +1.91.0 run --manifest-path prototype/channel-server/Cargo.toml

The value above is a placeholder. Supply a generated owner seed through your local environment when creating a site. Thereafter its database owns the owner key; changing or removing the environment value does not rotate it. Keep the key and hosting backups private and out of committed files and saved logs. Server does not print key-bearing URLs.

The Compose recipe keeps the root filesystem read-only. piik-data holds durable site/room data; the separate piik-tmp disk volume at /tmp holds backup snapshots and room import staging. The Server stages one full room restore or room copy import at a time and accepts a history ZIP up to one eighth of the scratch space available at the start of that upload. SQLite staging and installation also require free space on the temporary and data volumes. Normal completion, rejection and cancellation remove their temporary directories. After an abnormal container stop, the scratch volume can be recreated while the service is stopped; keep piik-data.

In another terminal, start the development interface:

node node_modules/vite/bin/vite.js --config prototype/channel-server/vite.config.ts

To sign in as the site owner, run this command in another terminal on the Server host using the same OS account and data directory as the running Server.

cargo +1.91.0 run --manifest-path prototype/channel-server/Cargo.toml -- owner-link

With a packaged Server, run ./piik-server owner-link (Windows: .\piik-server.exe owner-link). Open the printed link in your owner browser profile within 60 seconds. It can be used once. The browser saves the owner credential for later visits. Ordinary users open http://127.0.0.1:8790/ directly and can create their own rooms. Beside a room title, copy its public-room link or, as its owner, a private-room invitation. Private-room admission is handled after joining the site. Separate browser profiles represent separate users; tabs in one profile share a saved user credential but have independent live sessions. The default loopback ports are 8791 for Rust and 8790 for the interface. PIIK_CHANNEL_PORT, PIIK_CHANNEL_UI_PORT and PIIK_CHANNEL_WEB_ORIGIN allow an isolated instance with matching ports/origin. Optional PIIK_CHANNEL_INVITATION_ORIGIN selects a separate public HTTP(S) origin for invitations and permits that exact WebSocket Origin alongside the primary UI origin. Both values must be exact origins without paths, credentials, queries or fragments. The public origin must serve or proxy this same frontend and domain WebSocket; this setting does not create a listener or tunnel. The runtime supplies invitationOrigin in Welcome only when configured and does not save it in domain or room data. Keep owner-entry credentials on the local entry.

Server binds loopback by default. PIIK_CHANNEL_BIND_ADDRESS selects another IP address; set PIIK_CHANNEL_WEB_ORIGIN to the exact public frontend origin. Without an explicit Web origin, the local URL uses that listener address; wildcard listeners use the loopback address of the same IP family. Packaged Server resources default to web/ beside the executable, independently of its working directory.

Run piik-server --check-release to check for an update without starting the service or supplying room keys. It prints one JSON result and exits with 0 (up to date), 10 (an official update or different build is available), or 20 (unavailable). --api-url <endpoint> checks that endpoint alone. Released builds also check once after startup; network access never delays the listener.

For a standalone source deployment, build the same frontend as static assets, then set PIIK_CHANNEL_WEB_DIR to build/channel-web/ and PIIK_CHANNEL_WEB_ORIGIN to the service's own origin. Rust serves the frontend and existing WebSocket on that listener. / opens the frontend. Missing assets and unknown API paths return 404. Vite is only the development server; the deployed frontend requires no Node runtime.

Public origin and UDP

Use the Compose file and environment template from the same 3.0 source revision as the runtime. Copy the template to deploy/container/.env, set your public HTTPS origin and private owner seed, and set PIIK_IMAGE to the matching 3.0 image tag or digest. Use the packaged Server when that candidate has no matching image; do not assume latest selects the internal 3.0 build. From the repository root, start the configured image with:

docker compose --env-file deploy/container/.env -f deploy/container/compose.yaml up -d

For a Linux service, create the piik service account and install the executable with its matching web/ under /opt/piik/current. The systemd template reads /etc/piik/piik.env, runs /opt/piik/current/piik-server on HTTP 8787 and stores data under /var/lib/piik. Put the matching environment values in that file and install the unit as /etc/systemd/system/piik.service.

For the 3.0 public Demo profile, install the Demo drop-in as /etc/systemd/system/piik.service.d/demo.conf before first launch and set PIIK_CHANNEL_WEB_ORIGIN=https://demo.piik.tv in the service environment file. Once the unit and any drop-in are in place, run sudo systemctl daemon-reload and sudo systemctl enable --now piik.

For an existing lightweight channel, the owner can select Unlisted, invitation-only rooms in site settings. An existing hosted channel keeps its room writers and history on the Server when this policy changes. To run a lightweight Demo alongside that saved data, initialize the Demo in a separate empty data directory using the drop-in.

Set PIIK_CHANNEL_WEB_ORIGIN to the exact HTTPS origin users will open. Terminate HTTPS at your reverse proxy and forward HTTP/WebSocket traffic to the Server; the nginx example uses 127.0.0.1:8787. Compose and systemd select that port. When launching the binary directly, set PIIK_CHANNEL_PORT=8787 to match the example, or change the proxy upstream to the standalone port. Keep the proxy-facing HTTP listener private.

Allow the fixed PIIK_CHANNEL_UDP_PORT through the host firewall and cloud security group. It defaults to the actual HTTP port; the deployment template selects 8787. Media UDP goes directly to this listener, not through the HTTP proxy or HTTP tunnel. Offering forwarding capability does not prove that this UDP listener is reachable from a particular viewer. By default, the Server uses public STUN services for discovery. This setup does not require hosting the old 2.x STUN listeners on UDP 3478/3479/3480.

When NAT or a UDP tunnel changes the reachable address, set PIIK_CHANNEL_UDP_PUBLIC_ADDRESS to its public IP and port, for example 203.0.113.10:8787 with your own address, and forward that public UDP endpoint to the bound media port. This value accepts an IP:port, not a hostname. The local bind remains separate: an explicit loopback tunnel backend can use PIIK_CHANNEL_UDP_BIND_ADDRESS=127.0.0.1. The normal listener binds both IP families; set an explicit bind address when only one family should be used. The UDP bind also accepts a hostname resolving to local addresses, such as a hosting platform's service alias. Server resolves it once at startup and binds each distinct result; resolution or binding failure stops startup. The advertised public address remains a numeric IP:port with a matching listener family.

For LAN Browser capture, use an HTTPS reverse proxy with a certificate trusted by the devices, or use the App's Local-network HTTPS entry. The Rust Server does not implement the 2.x TLS_SELF_SIGNED option. Its standalone loopback HTTP entry is suitable for a local trial.

Check /healthz locally and through the public origin; the current response is piik-channel-prototype. Then verify picture and sound between two devices in a Server-hosted room. A successful webpage or health response does not prove the UDP media path. Preserve the complete data directory and replace the executable and its matching Web bundle together when updating; deployment and recovery owns the release procedure.

The piik-channel-app entry uses the same App button, local approval page and saved-site controls as the shared Web interface. Its own local site defaults to port 8787 and retains the successfully bound port across restarts. Site port in the startup settings selects another port before the site starts. An occupied port reports an error instead of silently choosing another. The loopback HTTP entry and Local-network HTTPS entry use this site port; the separate App management/discovery listener is not a site-forwarding endpoint. Changing the port retains App-hosted rooms but changes the web origin. Browser identity, preferences and cached files remain associated with the old address.

Build the App with its bundled Web files. The page checks local App compatibility at discovery, before approval. See versioning.

Build the frontend and start it:

npm run build:web
$env:PIIK_CHANNEL_APP_WEB_DIR = (Resolve-Path build/channel-web).Path
$env:PIIK_CHANNEL_CLOUDFLARED = "cloudflared"
cargo +1.91.0 run --manifest-path prototype/channel-server/Cargo.toml --features capture --bin piik-channel-app

On Windows, the App opens the shared interface in its own window using the installed system WebView. Window controls belong to the shell; rooms, media and site approval keep their existing owners. Closing the main window stops the App and its child windows. Pass --browser to use the system Browser instead; this is also the fallback when the system WebView cannot be created. Other desktop platforms use the Browser. The launcher and saved startup choice work in either interface. Windows microphone and camera requests use a Piik permission window naming the requesting site. Allow is remembered by the system WebView profile for that exact origin and permission kind, including microphone changes and later visits. Rejecting, closing or pressing Esc denies only the current request. Closing the requesting window cancels its pending requests without saving a denial. The App menu opens site management without leaving the current page. One list combines saved destinations and approved exact origins; each site's details separate its bookmark, App consent and startup preference. Bookmarks store a site address and optional name separately from device approval. Editing or removing a bookmark does not grant or revoke access. A changed invitation address can be updated manually; saved bookmarks contain no room invitation key. The launcher checks the public Piik marker at the site origin before adding, changing or opening a site address. A saved bookmark can be renamed offline. An unavailable site can be retried. In the Windows workspace, external links open in the system Browser. The webpage player accepts ordinary media sites.

From a Browser page, App → Open in client finds a running native-window App and opens its local confirmation page. The original room invitation can be passed without granting device access or transferring the Browser's identity. Confirming a different site ends the old page's personal activities and Browser-hosted rooms; App-hosted rooms continue. Same-site room links retain ordinary room navigation. The star remains available when a site fails to load. Platforms using the Browser entry can use the launcher's saved-site list without a native-window handoff.

The launcher and Site's App control show release notes and update notices. Updater-capable Windows packages can download a newer stable release and install it through the local launcher. Installation restarts the App and ends its active sessions; other installations retain manual downloads. The update contract defines package trust, data preservation and recovery. An external site's startup choice opens its fixed address. Selecting startup on the current App-owned site saves its launch selection: the next App run starts that mode and enters the new ready owner address, rather than reopening an expired invitation. Ownership follows the running App's exact local and invitation origins, not a hostname pattern. This preference grants no site access or capture permission; its launcher checkbox clears it, as does revoking its current origin. Older saved temporary URLs have no ownership information: start the site from the launcher and select the startup checkbox again on its current entry. The shared launcher offers Local network and Public address. Local uses a temporary certificate on the selected IPv4 address, including a virtual-LAN adapter; its fingerprint is printed locally. Follow the existing LAN HTTPS instructions before accepting that certificate on another device. Public address uses Cloudflare Quick Tunnel by default. Public address → Existing address accepts an HTTPS site origin for an already configured reverse proxy, such as frp. Forward that proxy's HTTP and WebSocket traffic to the displayed Local forwarding target, not the separate App management port. The address must be a site origin without a path, query or invitation fragment. TLS and the proxy remain operator-owned; frp's HTTPS-to-HTTP example describes that proxy side. No frp process or credentials are managed by Piik.

The local owner entry stays on loopback; the configured origin becomes the room invitation entry and exact WebSocket origin. It does not automatically receive device approval. The launcher reports local startup, not public reachability. Automatic startup saves the chosen public origin alongside its existing mode; changing a running entry requires exiting and restarting the App. This HTTP/WSS entry does not provide a media relay or change peer connectivity.

The development command explicitly selects cloudflared from PATH; PIIK_CHANNEL_CLOUDFLARED can instead name an installed executable.

Portable App resources have one root: the directory containing the executable, independent of the working directory. Copy the built build/channel-web/ contents to web/ beside it, and place the matching platform's cloudflared executable in runtime/tunnel/ (cloudflared.exe on Windows). These are the defaults when the two overrides above are unset. On macOS, keep this same layout inside the bundle's Contents/MacOS/ directory. Platform bundles, notices and distribution packaging use the shared packaging entry points.

Both modes start one domain with a local owner entry and a separate advertised invitation entry. Each navigation from the local launcher uses a short-lived, single-use ticket for the existing owner identity. The private bootstrap seed stays in the domain; reconnect uses the personal credential returned on entry. Neither the LAN nor public listener exposes App approval or control. Returning to the launcher reopens the same running domain. Startup continues if that page closes; a failed attempt releases its resources before the next retry.

On a running domain, click App and approve the site on that local page. New rooms then use the App's SQLite storage. The create-room form names the current hosting runtime. Existing Browser rooms remain in their pages and are not migrated; a remembered App preference cannot prevent Browser hosting when the App is absent.

An incompatible App Link prompts the user to update the older App or site. Without a selected port, discovery keeps looking for a compatible process before it reports the mismatch, and Browser capture stays available. Discovery has one bounded deadline, which starts once the Browser's local-network consent is no longer pending; a failed fetch alone does not establish that consent was denied. An explicit App action waits for that consent. Automatic checks do not: while local App access still needs consent or is denied, they treat the App as unavailable and ask again on a later attempt. Loopback pages, including App Local, need no cross-address-space consent, and Browsers without a permission query keep the bounded discovery.

Start sharing reuses the product source picker for Browser capture and the App's available sources, with small Native window/display thumbnails. Closing the picker cancels its pending thumbnails. App capture publishes through that same Native participant; the selecting page previews it as an ordinary subscriber. Stopping the share or closing its page stops only its captures, not its hosted rooms. Native capture uses the shared quality and codec settings, with optional source audio. The Native participant owns platform capture, shared encoding and adaptation; TODO tracks its remaining integration. Browser capture retains its existing behavior.

Approval covers room hosting and local window/screen capture and belongs to an exact site origin. Earlier room-only consent requires approval again, preserving the site's room-data namespace. Discovery exposes only the local approval address; the authorized health response supplies the process token. The token never appears in launch or room invitation URLs. Native verifies the Browser account through its authenticated site identity before opening its room data. Each approved origin owns a separate local namespace; replacing a tunnel origin does not silently grant access to an earlier site's data.

Closing the page ends its personal calls and shares, while App hosting continues. Revoking a site's approval stops that site's hosting and control connections, preserves its saved rooms and leaves other sites running. Reapproving the same site reuses its data; returning with the same domain account restores its rooms without restarting personal activities.

The App's own local entry is approved for its current runtime. app.sqlite retains approved origins, startup settings and the local permission namespace. domain/channel.sqlite owns the site's identity from creation onward, user credentials, owner key and directory; room databases stay under rooms/. A new local port or public tunnel address does not select another copy of those rooms. External sites retain their separate exact-origin approval boundary. App shutdown retires its Native hosts before the domain and tunnel. A local-domain failure leaves unrelated approved sites' hosting alone. In a terminal, Ctrl+C requests normal App shutdown.

The Browser entry and WebView fallback offer an interactive terminal when stdin and stderr are terminals. Use O + Enter to open the launcher, S + Enter to open a ready site, R + Enter to refresh, or Q + Enter / Ctrl+C for normal App shutdown. Use D + Enter to save an App report under the App data directory's diagnostics/ folder. The terminal displays the build, actual startup state, local/public addresses and any WebView fallback cause. It reads the existing launcher projection once per second and appends only changed status; existing diagnostic lines stay in scrollback. Site configuration and room actions remain in the Web UI.

Displayed addresses exclude query/fragment credentials; copy private invitations from the room UI. Site event messages follow the launcher's language, while terminal commands use English/Chinese labels. Redirected streams, TERM=dumb and NO_BROWSER keep plain output with no input reader. The ordinary Native window also creates no terminal reader.

The App uses the platform's local application-data directory under Piik/channel-app. PIIK_CHANNEL_APP_DATA_DIR selects isolated development data. One process owns that directory. PIIK_CHANNEL_APP_PORT may select a loopback port instead of the normal discovery range; a launch URL can supply the non-secret piik-client-port query parameter. PIIK_CHANNEL_APP_WEB_DIR selects the built frontend and PIIK_CHANNEL_APP_NO_BROWSER=1 suppresses browser opening for automated checks.

Local OBS input

With a supported desktop App connected, choose Start sharing → OBS / WHIP. Copy Server and Bearer Token into OBS's WHIP stream settings, using H.264 video and optional Opus audio. This input is local to the App's computer and works with either Local network or Public address mode. The receiving page, room admission and ordinary viewer routes remain the existing owners.

Configure input picture and sound in OBS. Piik retains automatic delivery adaptation without treating its capture presets as OBS's encoding limits. Closing the settings panel leaves the connection active. Stopping OBS ends that picture but retains the input connection; viewers select Watch again after a restart. Stop OBS sharing, closing the controlling page, or losing room authority revokes the connection and joins its receiver. Credentials stay in memory and are not part of room history or backups. Before OBS starts sharing, Cancel OBS input closes its pending input while preserving an existing screen share. Cancellation is disabled while a source change is being committed.

The shared Native capability controls availability. Android currently lacks the received-video adaptation used by this input and does not expose this choice. Windows, stock Alpine and Flathub OBS-to-Browser media and retirement have been exercised; other desktop packages and platforms still need their runtime acceptance.

On Linux, Piik also offers a local-interface media address for OBS packages whose ICE backend omits loopback addresses. The socket accepts only traffic arriving through Linux loopback; the input stays on this machine. Stock Alpine OBS Studio 32.1.2 and Flathub OBS Studio 33.0.1 with libnice passed picture, sound and stop/restart checks with Firefox on a separate network. FFmpeg WHIP remains supported. Other distribution packages still need their own runtime checks.

Watching video together

Choose Start sharing → Browser → Watch together. Paste a playable video link and select Start watching together. Direct links can point to video files, supported HLS streams or clear static DASH (.mpd) streams. For a YouTube video or Short, play the preview in the official player, then confirm sharing. Browser viewers can watch without an App or extension. If preparing an embedded player is unavailable, the explicit App webpage entry remains available. A hidden embedded player pauses locally; Start local playback returns it to the shared position.

With the Windows App connected, Open webpage and select video opens a separate website window. After loading or signing in, choose the video if Piik finds more than one. Open Playback method to change how viewers receive the selected video, or Track options to choose video and audio tracks when offered. Select Start watching together to share, or Switch video to replace your current share. For Sync video on its webpage, viewers open the same page in their App, select the matching video and confirm with Watch together. Sources with a direct link let browser viewers try the original site. When available, Receive from sharer uses the sharer's App. With App forwarding, the App sends the original encoded bytes through the room's peer paths; the website verification record records current limits. The sharer controls play, pause, position and speed. Each viewer controls local sound and can stop watching independently. When an HLS source offers multiple audio tracks, playback settings let each participant choose their own audio without changing the shared progress.

When the selected player exposes an independently usable media address, Browser viewers load it directly from the source. If direct playback fails, viewers can choose Open webpage and select video in a supported App and pick the player there. Each viewer signs in on the website if needed.

Playback state travels through the room's signaling connection. Direct viewing does not need a peer media path. The sharer can also choose Share settings → Forward original video, select a readable file, HLS or DASH source, and explicitly enable upload. Viewers then choose Receive from sharer to use the room's existing peer paths and consume the sharer's upload capacity. Compatible MP4, HLS and DASH sources use the Browser's Media Source Extensions, including on the App's local HTTPS entry. Other native-playable files require an origin where the Browser permits Service Workers. Stopping forwarding leaves the webpage and synchronized viewing activity open.

Forwarding currently supports finite media files with byte ranges and standard HLS VOD playlists, including variants, separate audio and initialization segments. Clear static DASH manifests support explicit video/audio selection and byte-range indexes. The viewer still needs a compatible decoder. Live/low-latency playlists, dynamic DASH and DRM playback are outside that forwarding support. Closing the sharer's source window, changing its selected media, or ending the share ends the activity; closing a viewer's window only ends that viewer's watch.

App diagnostics

The App service keeps a bounded technical history in process memory on desktop and Android. Restarting the service in the same process preserves it. Choose More options → App report on the local launcher to download a ZIP with build metadata, recent events and the latest stages of up to 256 connection pairs. Only the local launcher and terminal can export the process-wide report.

UDP send failures are summarized against the most recent ICE path observation, separating other candidates and unresolved paths without retaining endpoint addresses. Windows shared-sound configuration records distinguish default-output, process-tree inclusion and process-tree exclusion, with the selected and Native process IDs. They contain no window titles, program paths, device identifiers or audio samples.

Developers can set PIIK_DIAGNOSTIC_PROBES=1 before starting the App to sample Windows window-loop queue delay. The maximum reports sampled delay. Timer granularity affects the interval, and one in-flight probe bounds the backlog.

Each Browser page keeps up to 512 events per kind and 8 MiB of event data in memory until reload or close. More options → Diagnostic report downloads the recent history and samples the page's current media and connections. The same report is available from await window.__PIIK_DEBUG__.export(). The default history includes numerical long-frame events and configured ICE service failures. Developer mode (?debug=1) adds animation-frame gap sampling, raw statistics from existing samplers and cleaned error details. Requested statistics can include addresses and technical identifiers. Review reports before sharing.

On Windows, capture-frames.json lists active window and screen captures by an anonymous number. Compare two reports from the same App process to see how many capture callbacks arrived, how many frames the capture rate limit skipped, and how many raw frames entered the encoder pipeline. The encoded access-unit count covers all encoder outputs attached to that source. Counting starts with the capture. When the source ends, its final counters appear under the same number in events.ndjson.

Pair preparation records its existing stages and terminal outcome. A single check summary also records opened and primed pool sockets, sent checks and search targets, Ready sent and received, and a matched authenticated reply. Cancellation exports the counts reached so far. Pair aliases correlate the two reports without recording addresses, ports or credentials. These preparation facts do not establish which path ICE ultimately selected.

UI previews

The full room layout is the default. An empty site without a saved interface choice offers the optional minimal layout below Create your first room. Choosing or skipping saves the preference in this Browser origin; invitations and existing rooms remain direct. Change it later under More options → Interface.

Open /__tooltip-preview on the Vite service for the shared controls catalogue, including room management, invitations, App connection and error states. /__tooltip-preview?channel-room renders the production room view with local sample data. Add &layout=minimal for the minimal view, &screens=4 for multiple pictures, &no-rooms for first-room creation, or &empty-chat for an empty conversation. &fails=pause rejects the pause action, &unnamed-guest opens the first-name prompt, and &host-media enables media cleanup through More options. These use the production controls. /__tooltip-preview?channel-entry shows the current first-use controls with local sample state; it does not change actual saved preferences. /__tooltip-preview?channel-integrations presents the text-client example and the shared OBS settings with inert values. It does not connect an API or start a media input.

These previews use the current shared components without a Rust service, real capture or network permissions. Sample actions change preview state only; use the normal site and App to verify admission, persistence and media delivery. The guide-image generator uses the same component catalogue.

Rooms, conversation and media

A site contains rooms. Users allowed to create rooms manage their own rooms as room owners (房主). The site operator maintains site metadata and backups and can remove any room from the channel, including private or offline rooms. To read or moderate a private room's history in Piik, the operator must first be admitted. Users can share independently of maintenance or room ownership. Room admission permits chatting, voice, sharing and watching without separate role groups. Public rooms are open to site users. Private rooms require a room invitation or password, and hidden rooms do not appear in an unauthorized user's directory. Changing a password or invitation controls new admission; existing grants require explicit revocation.

Messages have a confirmed order within their room. The room store retains confirmed history and loads pages of up to 50; it does not automatically discard old messages. The interface keeps a reading window of up to 1,000 messages and lets readers move through earlier pages or return to the latest messages. Each message supports 2,000 Unicode characters and up to eight attachments. Text supports Markdown emphasis, lists, quotes, links, inline code and fenced code blocks with a copy action. Formatting preserves the saved message and confirmed mention identities; code remains literal and message HTML is not executed. Room history keeps a bounded static thumbnail. Original pictures and animations come from a local copy or an available file holder. Read pages and drafts stay in memory; refreshing retrieves history from the host. There is no separate offline history database or peer history replication.

Browse rooms without moving an existing call, share or subscription. Join voice from the personal activity area. Microphone mute controls your outgoing room voice; deafen controls local listening. Their attached volume menus adjust microphone and total listening gain from 0% to 200%, using the existing local preferences. Joined rooms share one microphone capture. Multiple users can share simultaneously. Watch selected pictures in an equal-weight grid or focus one picture with the others in a thumbnail strip. Short windows use a picture selector in place of the strip. Chat and the user list open as companion surfaces; narrow layouts switch surfaces instead of squeezing them beside the picture. These presentation choices do not implement media layering or a new quality policy. Local previews stay muted, including another page watching a source from the same verified local App endpoint. Only the selecting page retains capture controls. Closing a page's App control connection does not make that still-local source audible. Pausing a player does not stop forwarding its source. Start sharing from the selected room's header. Once active, source selection and picture/sound settings belong to that share's card; changing the room selection or focused picture never retargets those settings to another publication.

In the accepted model, reading and writing conversation require the domain connection and current room host, independently of ICE. Domain Join/Welcome apply the versioning rules. Each speaker, screen publication, file and forwarded webpage activity selects paths on confirmed connections within its authorized room graph. An eligible participant can forward voice without joining or hearing the call. Leaving the room view ends reading, while active media and necessary transit remain.

Each media flow has a lifetime separate from its publication and shared connection. Unwatching and watching again creates a new flow; late readiness or failure reports from the retired flow cannot change the replacement or close a shared transport used by another activity. Each active picture-preparation attempt has 20 seconds to deliver its first frame, even on an already connected path. If it expires, the same plan tries another available path. A downstream hop waiting for its upstream does not spend that window early. This media timeout keeps unrelated pictures, voice and their physical connections.

Each screen keeps its own distribution plan. Startup reuses eligible confirmed connections, including required non-viewing transit. If those paths cannot carry the picture, the same plan seeks an alternative through the source or ready media relays. The plan may prepare a direct source path for a leaf or an internal relay while retaining playback. Each affected viewer must decode, pass the shared quality comparison and supply a prewarmed frame; pure transit proves forwarding. The room commits that branch together, keeping its prepared inputs and outputs. Players adopt their existing candidate elements and source sound, preserving volume and pause. Candidate failure, changed viewing demand or expiry keeps the required old paths; view toggles do not restart spent attempts. Compatible data and media flows reuse physical peer connections. A relay can stop watching while continuing to serve downstream viewers; its transit ends when that demand ends. A failed DataChannel repairs its room paths without closing healthy media on the same connection. Stopping one share keeps unrelated received and forwarded media alive. Browser relays can decode and re-encode. The Native participant forwards encoded Opus, VP8 and H264, and publishes App capture through those same plans. When available, site forwarding uses the same publication plan to repair failed participant paths. The 2.x-specific SFU-only and peer-only operator policies are not implemented. WebRTC owns ICE and congestion control.

A signaling interruption has one 20-second recovery window. A resumed endpoint retains its committed media and resumes unfinished negotiation on the same connections; expiry releases captures and transports. Offline stop, unwatch and leave take effect locally and are reconciled on reconnect. Browser source pause and local voice mute/deafen also apply during this window. Pausing an App-produced picture requires domain signaling; stopping its capture uses the separate App connection.

ICE server configuration

Local network supplies only App's STUN listener on the selected network. Public address and standalone Server use public STUN services by default. PIIK_CHANNEL_ICE_SERVERS replaces that list with an ICE-server JSON array. Use [] to disable configured ICE servers for isolated loopback checks. The site sends the configured URLs and credentials to Browser and Native endpoints when they join. Use participant credentials issued by your TURN service. The local checks do not establish a public-NAT success rate or reliable background Browser service.

The following example is for source builds with Native TURN over TCP/TLS. If you already have a TURN service reachable from the network that blocks outbound UDP, set PIIK_CHANNEL_ICE_SERVERS to the JSON below. Set it in the desktop App's process environment before starting App in Public address mode, or in the Server's service environment before restarting Server. Use the hostname, port and participant credentials from your TURN service, then have participants reconnect and retry from the affected network.

[
  {
    "urls": ["turns:turn.example.com:443?transport=tcp"],
    "username": "<TURN username>",
    "credential": "<TURN password>"
  }
]

turns: with transport=tcp uses TLS over TCP from the client to the TURN listener. The certificate must be trusted and match the hostname. A plain TCP listener uses turn: with transport=tcp. The TURN service still allocates UDP relay addresses, which must be reachable from the other endpoint's selected route. See TURN URI syntax and TURN transports.

Saved data and files

Saved data belongs to its domain or room runtime. Server defaults to data/channel.sqlite beside its executable. PIIK_CHANNEL_DATA_DIR chooses a different real directory; point it at an existing source-run directory to reuse that data. Only one running instance can use a channel data directory at a time. After it shuts down, another instance can reopen the same directory. The domain checkpoint stores catalog summaries, identities and its owner admission key. Room files under rooms/<domainId>/<ownerId>/ store each room's policy, grants and confirmed history. Only a newly created standalone Server site bootstraps Living room, Studio and Quiet corner; subsequent starts reopen actual files. A new App site starts with an empty room list; users create rooms through the shared interface. A domain-only import leaves directory entries without room data unavailable. Existing room names and policy are not overwritten. The Native endpoint authenticates with that domain's saved owner key and restored owner identity; it does not create a new user on every service start. Browser-owned room policy and history stay in that Browser's IndexedDB; the domain retains only its directory summary. Messages commit individually: their room order, send identity and attachment descriptions are saved in one transaction before confirmation or distribution. A retry returns the original confirmed message without rebroadcasting it, including after restart. Storage failure leaves the send unconfirmed and preserves existing records. User credentials are stored as digests, and room passwords as password hashes. The room owner retains a private invitation's digest and recoverable key so it can read the current link. The site's bootstrap key is private hosting data. Sessions, captures and routes are not restored after a process restart.

Domain hosting metadata version 2 contains domain authority version 6. Portable site archives use version 3. Room storage and backups have separate versions. The storage reference records the supported SQLite, IndexedDB, room backup and room copy formats. One hosted room is offline. If the Server cannot read a room database, or two files claim the same room, that room may be unavailable while other rooms stay online. Keep the original files and ask the site operator to check the Server log. If you have a room copy, you can import it as a new room from Create room.

Server stops with unsupported_room_storage_layout. An older room database sits directly under rooms/. Keep the original data directory and use the build that created it to export supported room backups. To start an empty site, use a separate directory via PIIK_CHANNEL_DATA_DIR.

For other unsupported private stores or archives, keep the original and open it with the build that created it. To start an empty App site, choose a separate directory with PIIK_CHANNEL_APP_DATA_DIR.

The current site operator's personal credential authorizes GET and PUT on /prototype/channel/backup. The App or Server service validates the complete archive, stops its Native operators and waits for them to exit, replaces the domain checkpoint and retires old connections. Server bootstrap and the App owner entry then use the restored owner key. HTTP entries, tunnels and STUN retain their service lifetime; neither room histories nor participant retained files belong in a domain archive.

Room settings → Records separates personal text export, a full room backup and a room copy. The room creator can use both archive actions when Server hosts the writer. In either hosting mode, load a room copy from Create room and choose the new room's access settings. For an online Server-hosted room, restore a full backup from the original room's Records panel. The data model owns these scopes.

UI preferences belong to the client; the Browser also keeps its user credential locally. Participant reading windows and drafts stay in memory, as do the design board's sample data and edits. Hosting a room is separate: its saved policy and history survive reopening, while captures and voice do not restart automatically. Changing rooms keeps hosted rooms running. Browser-hosted rooms end with their page; App-hosted rooms end with their App. Personal voice and shares end with their owning page. Unexpected connection loss uses the recovery window. Server does not take over.

Native App hosting follows the room-data model. StoredRoomHost supplies the shared Rust room core's SQLite execution adapter: one database per room, with confirmations emitted after commit. It owns no network endpoint or hosting-session lifetime. The separate Native participant owns those resources and operates one or more rooms through that adapter. The Server embeds this participant; its separate executable remains an explicit development host. Explicit App linkage starts a separate Native hosting endpoint for the same user. Normal Server shutdown first ends Native hosting and releases its room locks, then closes the HTTP service. A failure of the shared Native hosting service also stops HTTP. A new service URL can use the same database, but a new Browser origin cannot read the previous origin's saved login or room data.

Messages contain complete file descriptions and their SHA256 digest. The selected file stays with its sender; a confirmed message does not upload bytes to the domain or room database. Browser- and Native-hosted rooms authorize requests from retained messages and deliver bytes over paths selected for each file, including the three default Server rooms. The domain database stores no file content.

Concurrent recipients share requested ranges through relays. Each recipient advances after its local write; cancellation only removes that recipient's demand. Network repair retains written progress. Completed copies may supply later requests, and idle copies alone do not keep room connections alive. If all copies disappear, the message remains but its file is unavailable.

The composer allows up to eight attachments per message. File transfers stream through a bounded range window across rooms, separate from the media/control queues. The Browser writes temporary files through OPFS and verifies the full size and digest before preview or download. Recognized PNG/JPEG/GIF/WebP images use the same file model. A receiving Browser needs secure-context file storage; there is no in-memory whole-file fallback. Unconfirmed selections remain session-only sources. Confirmed sent files and verified downloads may remain available after reopening through the participant's bounded retained store, scoped to its domain and user identity; the room-data model owns retention and reclamation. To free space used by one room's attachments, open Room settings → Records → Clear local room cache. Save any file whose only readable copy is on this device first. The action keeps chat history and files already saved as downloads. Current access controls offers and downloads; already downloaded bytes cannot be revoked.

Replicated history, federation and authority handoff remain outside this slice. Each site supports 128 live endpoints and 32 active room bindings or creation reservations. The directory holds up to 64 room identities in total, including offline registrations and restore permissions. When it fills, the channel owner can remove a registration to make space. Browser, App and Server endpoints count as resources; a person's endpoints share one user identity. The current multi-room acceptance scale is 20 users per room, without a separate hard person-count quota. Each endpoint may publish one screen and one voice source per room. Retained identities do not consume live slots. Live user summaries are lightweight; full profiles and the offline directory use bounded pages of up to 32 records over the existing site connection. Portable backups bound each JSON record, including the site metadata manifest, to 4 MiB. Site identities are separate NDJSON records, so this bound applies to each user rather than the complete user directory.

Checks

Run the shared Rust and Browser-adapter checks from the repository root:

npm run check:rust

When changing room scale or state projection, run the larger capacity acceptance explicitly with optimizations. It retains the real 81-endpoint, two-room graph and per-recipient state checks without adding that cost to each unit-test run:

cargo +1.91.0 test --release --locked --manifest-path prototype/channel-core/Cargo.toml --features sqlite --test base_routes two_twenty_person_rooms -- --ignored

The check:rust entry point uses Rust 1.91.0 and the Browser adapter's pinned wasm-bindgen and cargo-about tools. It checks the generated MPD resolver and its pure parser tests, core tests with and without SQLite, Native forwarding tests, Server tests including native_session, the shared Web/WASM build, Browser-adapter TypeScript and the finite WebSocket protocol check. The Web build uses development identity. It builds Native before the process-lock tests and supplies that executable to them. CARGO_TARGET_DIR selects the shared build directory; the working directory selects the source tree. It leaves capture disabled, so shared checks need no desktop media SDK or Linux GStreamer installation. Capture-enabled compilation belongs to platform packaging; physical capture/input and Browser media acceptance remain separate checks. The ordinary Web type-check and unit tests remain npm run typecheck and npm test.

For Browser acceptance, generate the adapter with the command above, build the capture-enabled App and select the executables when using a custom target directory:

cargo +1.91.0 build --manifest-path prototype/channel-server/Cargo.toml --features capture --bin piik-channel-app
node prototype/channel-server/run-browser-check.mjs
node prototype/channel-server/run-browser-check.mjs --rooms
node prototype/channel-server/run-browser-check.mjs --backup
node prototype/channel-server/run-browser-check.mjs --identity
node prototype/channel-server/run-browser-check.mjs --previews
node prototype/channel-server/run-browser-check.mjs --lifecycle
node prototype/channel-server/run-browser-check.mjs --hosts
node prototype/channel-server/run-browser-check.mjs --base
node prototype/channel-server/run-browser-check.mjs --app

The real Native session integration tests live in tests/native_session.rs in this crate, including App approval, storage ownership and startup/retry. To run them separately, build Native first and set CHANNEL_NATIVE_EXECUTABLE when using a custom target directory. Use cargo +1.91.0 test --manifest-path prototype/channel-server/Cargo.toml --test native_session to run those tests alone. Build Server and App separately as above: App enables the Native capture feature, while Server needs only forwarding. Building both with --features capture --bins would also link desktop capture dependencies into that Server artifact. CHANNEL_APP_EXECUTABLE can select a separately built App for --app.

The Native participant checks add --native for concurrent Browser-to-Native picture, voice and file forwarding, room storage and restart. --app exercises independent App hosting and Browser participation, including page closure, App loss and saved-room restoration.

The existing CI workflow can compile Native and App against the macOS SDK:

gh workflow run repository-hygiene.yml --ref feat/channel-prototype -f channel_native=true

This opt-in job builds and links test programs without running them. It skips the maintenance build and publication jobs; ordinary branch pushes stay quiet.

Browser checks require agent-browser and a current browser. Set AGENT_BROWSER_EXECUTABLE_PATH to choose the installed Chrome/Chromium executable; otherwise the CLI uses its managed browser. Record the actual browser version with acceptance results. The runner chooses free loopback ports and temporary test keys, starts its own Rust/Vite services, runs acceptance, and stops them on exit. It does not leave a preview service running or restart another instance. Default acceptance covers multiple real Browser peers and relay recovery; --rooms exercises room access and files; --backup uses an ordinary member's real UI to export and restore a Browser room's history, then reopen it from IndexedDB after reload, without media fixtures; --lifecycle focuses on capture, offline intent and expiry; --hosts exercises separate domain/Browser ownership, private admission, room recovery, cross-room media and actual IndexedDB/SQLite placement. --base blocks one direct negotiation and verifies bidirectional voice through a non-listening relay, DataChannel failure recovery and independent cross-room media leases. Generated captures replace only the system picker, not business state, routing or peer connections. The Rust runtime checks cover room storage, restart, failed writes and orderly shutdown. The Browser runner accepts CHANNEL_EXECUTABLE to select a Server artifact. On Windows it copies the default Cargo build into its temporary run directory before launch. When selecting a custom Cargo build through CHANNEL_EXECUTABLE, pass --built-server to use the same isolated copy.

--protocol runs the WebSocket check with its own temporary service. Against an already running isolated instance, use node --import tsx --test prototype/channel-server/check.mjs with its local key/endpoint environment variables. browser-acceptance.mjs is the corresponding Browser driver; prefer run-browser-check.mjs for automatic service cleanup. The design-study route and observation hook are development-only; the static entry mounts the functional frontend directly. The shared Rust library lives in channel-core; its default build excludes SQLite, and HTTP stays in this Server crate.