Files
piik/docs/project-memory.md
T
08a76209c2 feat(room): add remote co-play and refresh the room experience (#497)
## Problem and outcome

This phase adds consented remote co-play to normal App/Web rooms and integrates the accepted audio, playback, participant-state and multi-site improvements. It also rebuilds the bilingual README/documentation reading path, refreshes real-component illustrations, and publishes the selected website film.

The candidate preserves the established 2.x sharing/viewing contracts. Optional new behavior follows negotiated capabilities; Windows gamepads use an externally installed driver. The separate accompaniment experiment and unselected film studies are outside this phase.

## Release notes

**Play together. Your turn!**

Approved friends can now play together with shared keyboard and mouse controls or optional gamepads.

**远程同乐,轮到你啦!**

获准的朋友现在可以共用键鼠,或使用可选手柄,一起玩本地多人游戏。

### English

Piik 2.4 adds remote co-play, improves shared sound and room controls, and rewrites the bilingual getting-started and help guides around what you want to do.

#### Highlights

- Let approved friends control together. Each player's held keys and gamepad retire independently; everyone shares the Host's mouse pointer. On Windows x64, optional virtual gamepads use a Host-installed ViGEmBus driver. Piik does not bundle or install it.
- Control shared output volume from the Host's playback bar. The optional share microphone adds your voice to the picture, independently of room voice; stopping the share leaves room voice running. Room voice now defaults to 64 kbps and offers a Host bitrate control.
- See voice and remote-control participation directly on the couch. Connection details group picture and voice by receive/send direction. Playback actions, chat-overlay settings and dismissible operation feedback have clearer, consistent places.
- Approve several Piik sites in App and manage each separately, with one optional startup favorite.
- Follow rewritten English and Chinese README and documentation paths: watching, starting a share, room tools, remote control/co-play, and symptom-based help. Illustrated guides use current product components, theme-aware screenshots and shared diagrams. A dedicated network guide covers campus networks, media UDP, SFU sites and optional virtual LANs.
- The website has clearer App and co-play FAQs and the selected bilingual 64-second film, with shared playback controls and a held closing card.

#### Fixes

- Tolerate small macOS capture-crop rounding errors without accepting genuinely invalid geometry.
- Keep shared-audio and microphone volume changes independent, preserve commentary through source replacement, and retire each input at its owning lifecycle boundary.
- Improve narrow-player controls, touch-held volume menus, tooltip placement and feedback cleanup after reconnection.
- Repair the release recovery test on macOS and refresh the build and tunnel runtimes.

#### Updating and limits

Update the Host's App and the room site, then refresh open pages to use the new features. Established sharing and viewing remain compatible within 2.x; older peers retain the features they support. The wire versions and SQLite schema are unchanged. Restarting App or Server interrupts active sessions.

Before downgrading App, remove extra approved sites in the newer launcher so at most one remains. Use the [remote-control guide](https://piik.tv/docs/remote-control.html?lang=en) for the optional Windows driver. Linux gamepads remain experimental; macOS virtual gamepads are not currently available. Windows 10 window-sharing black screens ([#495](https://github.com/TNTcraftHIM/Piik/issues/495)) remain under investigation; use screen sharing if affected.

### 中文

Piik 2.4 新增多人远程同乐,改进分享声音与房间控制,并围绕实际任务重写双语上手教程和帮助文档。

#### 主要更新

- 允许获准的朋友同时控制。各人的按键持有和手柄独立释放,大家共用房主的鼠标指针。Windows x64 可使用房主自行安装的 ViGEmBus 驱动提供虚拟手柄;Piik 不捆绑或安装驱动。
- 房主可通过播控调整分享输出音量。可选的分享麦克风把说话声加入画面,与房间语音独立;停播后房间语音继续。房间语音默认提升至 64 kbps,并提供房主码率设置。
- 沙发人物直接呈现语音和远控参与状态;连接详情按画面/语音、接收/发送分组。播放操作、弹幕设置和可关闭的操作提示各有清楚、一致的位置。
- App 可授权多个 Piik 站点,逐个管理,并选择一个启动时打开的星标站点。
- 重写中英文 README 和文档中心:从观看、开始分享、房间工具、远控/同乐到按症状排障。图文教程使用当前正式组件、明暗主题截图与同源示意图;独立网络指南说明校园网、媒体 UDP、SFU 站点和可选虚拟局域网的用法。
- 官网改进 App 与多人同乐 FAQ,采用选定的双语 64 秒短片,复用产品播控并保留结尾品牌卡。

#### 修复

- 容忍 macOS 采集裁剪中的微小舍入误差,仍拒绝真正无效的画面边界。
- 分享总音量与麦克风音量分别更新;换源保留解说,各项输入按所属生命周期释放。
- 改进窄屏播控、触摸长按音量菜单、提示定位,以及重连后的提示清理。
- 修复 macOS 上发布恢复测试的可移植性,更新构建与公网隧道运行组件。

#### 更新与限制

将房主 App 和房间站点更新后,刷新已打开的页面,即可使用新功能。2.x 内保留已有分享与观看兼容性,旧端继续使用其支持的功能;协议版本和 SQLite schema 不变。重启 App 或 Server 会中断当前会话。

如需降级 App,先在新版启动页删除额外授权,最多保留一个站点。可选的 Windows 驱动安装方法见[远控指南](https://piik.tv/docs/zh/remote-control.html)。Linux 手柄仍属实验能力,macOS 当前暂不提供虚拟手柄。Windows 10 窗口分享黑屏而整屏正常的反馈([#495](https://github.com/TNTcraftHIM/Piik/issues/495))仍在调查,本版不声称已修复。

## Verification

- Integrated Web typecheck, 98 test files / 1,734 tests and production build passed. Later scoped UI repairs passed focused typecheck/tests and preview checks.
- Focused Go checks cover input grant/held-state ownership, delayed device retirement, native control/Host, config/launcher/loopback, voice negotiation and source-volume binding. Windows capture compilation/probe and the isolated Linux uinput kernel gate passed.
- Normal-page P2P (22 checks) and embedded-SFU (19 checks) gates passed. P2P explicitly exercised source commentary with room voice, independent shutdown, share retirement and the next share's default-off state; SFU also covers live voice bitrate and voice recovery.
- Documentation links (108 Markdown files), generated-diagram freshness, the complete bilingual/theme screenshot pipeline and website production build passed. Website/readers were checked at 320, 768 and 1440 px with both languages/themes.
- macOS crop logic retains geometric self-tests; this Windows environment did not repeat a macOS SDK/hardware run. Linux desktop/game recognition and macOS virtual-gamepad entitlement/runtime remain explicit limits.
- Windows native window-sharing acceptance passed: Host/Viewer decoding, live and paused quality changes, resize/minimize/restore, source replacement, stop and restart. Capturing the Host Chrome window also passed with Auto/H.264 and VP8, including decoded-frame and pixel checks. The Windows 10 case in #495 was not reproduced and remains separate.
- Current Go serializers passed the published v2.0.0/v2.3.0 TypeScript readers; existing native input opt-in checks passed. This checks payload compatibility, not an end-to-end run of old published clients.

## Impact

Compatible 2.x feature release; Browser/server v24, Native control v10, capture v7 and SQLite schema 2 remain unchanged. New co-play, presence, voice settings and native volume behavior are capability-negotiated. Multi-site App settings retain the older single-site reader path; arbitrary binary downgrade is not promised. No independent room/router, new NAT policy, driver installer or separate accompaniment channel is introduced.

## Related work

Includes the macOS crop correction reported in #492 and the macOS deployment-test portability contribution from #496. Supersedes the incomplete phase PR #494. #495 remains open.

## Attribution

Co-authored-by: Yuqing Huang <670081066@qq.com>
Co-authored-by: luol75569-collab <297886760+luol75569-collab@users.noreply.github.com>
2026-10-23 16:29:31 -04:00

8.5 KiB

Project Memory

Last updated: 2026-10-23

Piik is private, low-latency screen sharing for one Host and up to 20 authenticated friends. The current product surface is Web Host, Web Viewer, and Browser relay; desktop and mobile Browsers are Viewer targets, and camera-capable mobile Browsers can also host. It is not a public broadcast service. Hosted and App run one shared Go core (ADR-0012); Node and Vite build the Browser UI and are not a runtime. Source includes a cross-platform App that runs that same core in a self-contained Local deployment or supplies native capability to explicitly approved Sites through the system Browser. Its single Go process starts the loopback capability service before room selection. The persistent launcher offers Local and temporary public-link choices and manages per-Site local approval and one starred startup Site. Site use can remain on standby without a Local room service; native media still belongs to the participant's Web UI. Room source and media implementation are independent: a topology may mix Browser and Native peers without changing participant, signaling, capacity, or route identity. Local is LAN-first; explicit one-link mode exposes that same authority through a temporary public control tunnel while media remains P2P. Host authority belongs to a tab, with one separate persistent origin resume hint. The App admits two independent native control sessions under its one loopback service.

The current source embeds Binding-only STUN and optional SFU forwarding in the Hosted Go process. Native and SFU use one shared Pion/LiveKit media adapter; Native parents reuse suitable encoded outputs and derive a missing lower output only for direct-child demand. Source-owned groups retain the highest needed output and lower fallbacks, while each child receives its selected output. Native Host SFU publication reuses the encoded source directly; its loopback Browser stream supplies local preview and Browser quality candidates. Eligible Browser capture and relay now share independent local WebRTC producers for compatible direct children under ADR-0014; unsupported APIs and failed pooling retain ordinary senders. Windows, macOS and Linux producers share one encoded-frame boundary and Host quality controls. Source replacement retains route and connection identity; lower-output adaptation preserves the original and higher sibling outputs. Status owns candidate and release readiness; runtime release descriptors own deployed identity. The Local launcher keeps an optional user-chosen site-access password; leaving it blank keeps the self-contained site open.

Product Map

  • Rooms and access owns room codes, invitations, code entry, credentials, room interactions and lightweight/SQLite persistence.
  • Routing and transport owns P2P-first distribution, endpoint capacity, SFU fallback, recovery, and privacy limits.
  • Capture and media quality owns Browser capture, profiles, codec selection, audio, and framework adaptation.
  • Presentation and lifecycle owns Host and Viewer workflows, playback authority, roster, state, and Browser lifecycle.

Non-obvious decisions live in ADRs; reproducible evidence and platform limits live in research. Source code and tests own self-evident implementation and routine UI detail.

Core Invariants

  • Rooms use random four-digit codes, exact Host ownership, room-scoped Viewer invitations and independent open | private code entry. Room authority ends through replacement/deletion, with separate invitation rotation or revocation. Hosted operators may opt into empty-room expiry and capacity reclamation; the default retains rooms indefinitely. Hosted defaults to SQLite, with explicit process-memory opt-out; App Local remains process-only. Site access has a separate 24-hour idle cookie lifetime within one service run. Production persists SQLite room authority; live participants, routes, and media remain process-only.
  • Media is automatic and distributed. Ordinary peers are STUN-only and prefer direct/peer UDP. A deployment may enable same-host auxiliary STUN for bounded, room-wide, connection-local NAT prediction; current pages use it automatically when available, and anonymous provenance distinguishes ordinary from predicted selected paths. The configuration default remains stock ICE. The only application fallback is one bounded embedded SFU/UDP publication; Piik configures no TURN or TCP media route. Hosted operators may require SFU-only media through the same controller. On P2P-first sites, a pre-share peer-only policy can exclude that SFU suffix for one share generation.
  • Ordinary endpoints share one steady outbound-copy cap, default 2 and limited to 1..3; the explicit relay volunteer uses the capacity owner. One room controller owns one committed graph, one reconcile loop, and one serial child operation. First decoded frame commits picture availability work; accepted quality work adds native edge proof before commit in that operation.
  • Browser WebRTC and the shared Pion/LiveKit media adapter own congestion control, media adaptation, pacing and layer selection. Parent demand is local to direct children and never a room-wide minimum or topology rebalance. Current source defaults persistent native-edge local P2P convergence on, with a pre-share Host opt-out. SFU quality work is limited to multi-root Host fanout relief and each Viewer must prove its own candidate non-regression before commit. A persistently limited edge with no different Peer parent may use one same-parent connection regeneration through that same operation; its exact post-commit sender identity damps only another same-edge regeneration. No weighted score, all-pairs probe, general parent-wide prediction, or periodic rebalance is accepted.
  • Browser video uses motion; each share chooses H.264 with VP8 fallback through an actual sender probe unless the Host explicitly selects VP8 or H264. Screen audio retains its compact presets and 128 kbps default. The 2.0 contract separates numeric bitrate requests from those UI shortcuts; implementation limits and admission remain in the media-quality owner.
  • Viewer playback uses one native video element. Presentation and recovery are fenced by current route/media identity and current-frame proof; hidden-page time alone is not media-failure evidence or a keepalive guarantee.

Current Snapshot

Room voice integrates normal App/Server/Web rather than a standalone demo. It keeps room authority and one route controller while picture generations and explicitly joined voice publications have separate lifetimes. Optional source commentary belongs to the share and can run independently of room voice. Status indexes delivery and room media owns the new behavior.

Optional attended input follows the committed media route back to the native Host. One grant covers keyboard/mouse and an optional gamepad. Control starts with one grantee; the Host may allow simultaneous approved Viewers for that source. Older published clients retain exclusive keyboard/mouse control. Source change, stop and revocation retire the affected grants. It adds no separate connection planner or listener. Viewer playback preferences and the combined interaction window remain local presentation owners under the existing 2.x compatibility boundary.

The current contract tuple is owned by status. Embedded SFU SDP/ICE and demand travel over the authenticated room WebSocket, without an external room service or media token. Committed first-frame readiness, bounded candidate-relative progress, durable room authority and the H.264/VP8 sender gate remain. Status indexes source and deployment evidence; protocol rollback requires matching Browser and App artifacts, not only an application symlink.

Unfinished work is owned by the TODO ledger. Verification status summarizes material evidence boundaries. Environment and initial services are owned by configuration and self-hosting; application release is owned by deployment, with exact deployed identity retained in the release descriptor and deployment record. Git history and pull requests own completed timelines.