## 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.
321 lines
15 KiB
TypeScript
321 lines
15 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { runInNewContext } from "node:vm";
|
|
import ts from "typescript";
|
|
import { createElement } from "react";
|
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { AppConnectionButton } from "../src/client/components/living/AppConnectionButton";
|
|
import { CaptureSourcePicker } from "../src/client/components/living/CaptureSourcePicker";
|
|
|
|
describe("desktop App connection entry", () => {
|
|
afterEach(() => vi.unstubAllGlobals());
|
|
|
|
it.each([
|
|
["Android phone", "Mozilla/5.0 (Linux; Android 16) Mobile", "Linux armv8l", 5],
|
|
["Android tablet", "Mozilla/5.0 (Linux; Android 16)", "Linux armv8l", 5],
|
|
["iPhone", "Mozilla/5.0 (iPhone; CPU iPhone OS 26_0 like Mac OS X)", "iPhone", 5],
|
|
["iPad", "Mozilla/5.0 (iPad; CPU OS 26_0 like Mac OS X)", "iPad", 5],
|
|
["desktop-mode iPad", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15)", "MacIntel", 5],
|
|
])("omits the desktop workflow on %s, retaining Browser and camera choices", (_, userAgent, platform, maxTouchPoints) => {
|
|
vi.stubGlobal("navigator", { userAgent, platform, maxTouchPoints });
|
|
expect(renderToStaticMarkup(createElement(AppConnectionButton))).toBe("");
|
|
const html = renderToStaticMarkup(createElement(CaptureSourcePicker, {
|
|
nativeSources: { kind: "browser" },
|
|
onBrowser: () => {}, onNative: () => {}, onCamera: () => {},
|
|
onPreview: async () => null, onRefresh: () => {}, onCancel: () => {}, onAppConnected: () => {},
|
|
}));
|
|
expect(html).toContain('data-source-tab="browser"');
|
|
expect(html).toContain('data-source-tab="camera"');
|
|
expect(html).not.toContain("lr-source-app-connection");
|
|
});
|
|
|
|
it.each([
|
|
["touch Windows", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)", "Win32", 10],
|
|
["Mac", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15)", "MacIntel", 0],
|
|
["Linux", "Mozilla/5.0 (X11; Linux x86_64)", "Linux x86_64", 0],
|
|
["unknown", "", "", 0],
|
|
])("retains the shared connection entry on %s", (_, userAgent, platform, maxTouchPoints) => {
|
|
vi.stubGlobal("navigator", { userAgent, platform, maxTouchPoints });
|
|
expect(renderToStaticMarkup(createElement(AppConnectionButton))).toContain("lr-app-connect");
|
|
expect(renderToStaticMarkup(createElement(AppConnectionButton, { sourcePicker: true })))
|
|
.toContain("lr-source-app-connection");
|
|
});
|
|
});
|
|
|
|
// Exercise the button's actual operation and unmount effect without a Browser.
|
|
// Discovery has separate transport tests; this covers who may activate a page.
|
|
const source = ts.createSourceFile("AppConnectionButton.tsx", readFileSync(
|
|
new URL("../src/client/components/living/AppConnectionButton.tsx", import.meta.url), "utf8",
|
|
), ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
let connect: string | undefined;
|
|
const effects: string[] = [];
|
|
function collect(node: ts.Node): void {
|
|
if (ts.isFunctionDeclaration(node) && node.name?.text === "connect") connect = node.getText(source);
|
|
if (ts.isCallExpression(node) && node.expression.getText(source) === "useEffect") {
|
|
effects.push(node.arguments[0]!.getText(source));
|
|
}
|
|
ts.forEachChild(node, collect);
|
|
}
|
|
collect(source);
|
|
if (!connect || !effects.length) throw new Error("Missing App connection operation or cleanup");
|
|
const executable = ts.transpileModule(`${connect}\nconst cleanups = [${effects.map(effect => `(${effect})()`).join(",")}];
|
|
({ connect, cleanup: () => cleanups.reverse().forEach(fn => fn?.()) });`, {
|
|
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS },
|
|
}).outputText;
|
|
const settle = () => new Promise<void>(resolve => setImmediate(resolve));
|
|
const site = "https://site.example";
|
|
const approval = `http://127.0.0.1:39721/client?site=${encodeURIComponent(site)}`;
|
|
|
|
function mount(activated = false, state: "idle" | "ready" = "idle") {
|
|
const popup = { closed: false, close: vi.fn(() => { popup.closed = true; }) };
|
|
const window = Object.assign(new EventTarget(), { open: vi.fn((): typeof popup | null => popup), location: { origin: site } });
|
|
const native = {
|
|
discoverNativeConnect: vi.fn(async (_signal: AbortSignal): Promise<string | null> => approval),
|
|
discoverNativeHealth: vi.fn(async (_options: { signal: AbortSignal }): Promise<object | null> => ({})),
|
|
NativeCompatibilityError: class extends Error {},
|
|
};
|
|
const pending = { current: null as { controller: AbortController; cancel?: () => void } | null };
|
|
const healthCheck = { current: null as AbortController | null };
|
|
const help = { current: { hidePopover: vi.fn(), matches: vi.fn(() => false) } };
|
|
const showHelp = vi.fn();
|
|
const setState = vi.fn();
|
|
const activateClient = vi.fn();
|
|
const onConnected = vi.fn();
|
|
const operation = runInNewContext(executable, {
|
|
window, pending, healthCheck, help, showHelp, setState, activateClient, onConnected, AbortController, URL,
|
|
sourcePicker: false, state, isClientActivated: () => activated,
|
|
watchClientActivation: (changed: () => void) => {
|
|
window.addEventListener("activation", changed);
|
|
return () => window.removeEventListener("activation", changed);
|
|
},
|
|
require: (path: string) => {
|
|
if (path !== "../../native/client") throw new Error(`Unexpected dependency: ${path}`);
|
|
return native;
|
|
},
|
|
}) as { connect: () => Promise<void>; cleanup: () => void };
|
|
function message(overrides: Record<string, unknown> = {}) {
|
|
window.dispatchEvent(Object.assign(new Event("message"), {
|
|
source: popup, origin: new URL(approval).origin, data: { type: "piik-app-approved", site }, ...overrides,
|
|
}));
|
|
}
|
|
const activateElsewhere = () => { activated = true; window.dispatchEvent(new Event("activation")); };
|
|
const openApproval = async () => { await operation.connect(); await operation.connect(); };
|
|
return { ...operation, openApproval, popup, window, native, pending, help, showHelp, setState, activateClient, activateElsewhere, onConnected, message };
|
|
}
|
|
|
|
describe("App connection approval", () => {
|
|
it("keeps permission discovery in the original tab and opens only on a later click", async () => {
|
|
const page = mount();
|
|
let complete!: (url: string) => void;
|
|
page.native.discoverNativeConnect.mockImplementation(() => new Promise(resolve => { complete = resolve; }));
|
|
const connecting = page.connect();
|
|
await settle();
|
|
expect(page.setState).toHaveBeenLastCalledWith("busy");
|
|
expect(page.showHelp).toHaveBeenCalledOnce();
|
|
expect(page.window.open).not.toHaveBeenCalled();
|
|
complete(approval);
|
|
await connecting;
|
|
expect(page.setState).toHaveBeenLastCalledWith("approval");
|
|
expect(page.window.open).not.toHaveBeenCalled();
|
|
page.message({ source: null });
|
|
expect(page.native.discoverNativeHealth).not.toHaveBeenCalled();
|
|
await page.connect();
|
|
expect(page.window.open).toHaveBeenCalledWith(approval, "_blank");
|
|
expect(page.setState).toHaveBeenLastCalledWith("approving");
|
|
page.cleanup();
|
|
});
|
|
|
|
it("cancels dismissed discovery and ignores its late result before a retry", async () => {
|
|
const page = mount();
|
|
let complete!: (url: string) => void;
|
|
page.native.discoverNativeConnect.mockImplementationOnce(() => new Promise(resolve => { complete = resolve; }));
|
|
const connecting = page.connect();
|
|
await settle();
|
|
const first = page.pending.current!;
|
|
first.cancel!();
|
|
expect(first.controller.signal.aborted).toBe(true);
|
|
expect(page.pending.current).toBeNull();
|
|
expect(page.setState).toHaveBeenLastCalledWith("idle");
|
|
await page.connect();
|
|
complete(approval);
|
|
await connecting;
|
|
expect(page.setState).toHaveBeenLastCalledWith("approval");
|
|
expect(page.pending.current).not.toBe(first);
|
|
expect(page.window.open).not.toHaveBeenCalled();
|
|
await page.connect();
|
|
expect(page.window.open).toHaveBeenCalledOnce();
|
|
page.cleanup();
|
|
});
|
|
|
|
it("opens the launcher for an already connected Site without changing approval", async () => {
|
|
const page = mount(true, "ready");
|
|
await page.openApproval();
|
|
expect(page.window.open).toHaveBeenCalledWith("http://127.0.0.1:39721/client", "_blank");
|
|
expect(page.setState).toHaveBeenLastCalledWith("ready");
|
|
expect(page.pending.current).toBeNull();
|
|
expect(page.activateClient).not.toHaveBeenCalled();
|
|
expect(page.onConnected).not.toHaveBeenCalled();
|
|
page.cleanup();
|
|
expect(page.popup.closed).toBe(false);
|
|
});
|
|
|
|
it("offers recovery without activation or a stranded popup when no App is found", async () => {
|
|
const page = mount();
|
|
page.native.discoverNativeConnect.mockResolvedValue(null);
|
|
await page.connect();
|
|
expect(page.setState).toHaveBeenLastCalledWith("unavailable");
|
|
expect(page.showHelp).toHaveBeenCalledTimes(2);
|
|
expect(page.window.open).not.toHaveBeenCalled();
|
|
expect(page.pending.current).toBeNull();
|
|
expect(page.activateClient).not.toHaveBeenCalled();
|
|
page.cleanup();
|
|
});
|
|
|
|
it("offers recovery when the browser blocks the approval window", async () => {
|
|
const page = mount();
|
|
page.window.open.mockReturnValue(null);
|
|
await page.openApproval();
|
|
expect(page.setState).toHaveBeenLastCalledWith("unavailable");
|
|
expect(page.showHelp).toHaveBeenCalledTimes(2);
|
|
expect(page.native.discoverNativeConnect).toHaveBeenCalledOnce();
|
|
expect(page.activateClient).not.toHaveBeenCalled();
|
|
page.cleanup();
|
|
});
|
|
|
|
it("requires the exact window, origin and site, then verifies App health once", async () => {
|
|
const page = mount();
|
|
let complete!: (health: object) => void;
|
|
page.native.discoverNativeHealth.mockImplementation(() => new Promise(resolve => { complete = resolve; }));
|
|
await page.openApproval();
|
|
await page.connect();
|
|
expect(page.window.open).toHaveBeenCalledOnce();
|
|
expect(page.window.open).toHaveBeenCalledWith(approval, "_blank");
|
|
for (const invalid of [
|
|
{ source: {} }, { origin: "http://127.0.0.1:39722" },
|
|
{ data: { type: "piik-app-approved", site: "https://another.example" } },
|
|
{ data: { type: "other", site } }, { data: null },
|
|
]) page.message(invalid);
|
|
expect(page.native.discoverNativeHealth).not.toHaveBeenCalled();
|
|
page.message();
|
|
page.message();
|
|
expect(page.native.discoverNativeHealth).toHaveBeenCalledOnce();
|
|
expect(page.activateClient).not.toHaveBeenCalled();
|
|
complete({});
|
|
await settle();
|
|
expect(page.activateClient).toHaveBeenCalledOnce();
|
|
expect(page.onConnected).toHaveBeenCalledOnce();
|
|
expect(page.setState).toHaveBeenLastCalledWith("ready");
|
|
expect(page.popup.closed).toBe(true);
|
|
expect(page.pending.current).toBeNull();
|
|
expect(page.native.discoverNativeConnect.mock.calls[0]![0].aborted).toBe(true);
|
|
page.message();
|
|
expect(page.native.discoverNativeHealth).toHaveBeenCalledOnce();
|
|
});
|
|
|
|
it.each(["absent", "failed"])("does not activate from an approval message when health is %s", async result => {
|
|
const page = mount();
|
|
if (result === "absent") page.native.discoverNativeHealth.mockResolvedValue(null);
|
|
else page.native.discoverNativeHealth.mockRejectedValue(new Error("network unavailable"));
|
|
await page.openApproval();
|
|
page.message();
|
|
await settle();
|
|
expect(page.activateClient).not.toHaveBeenCalled();
|
|
expect(page.onConnected).not.toHaveBeenCalled();
|
|
expect(page.setState).toHaveBeenLastCalledWith("unavailable");
|
|
expect(page.popup.closed).toBe(true);
|
|
expect(page.pending.current).toBeNull();
|
|
await page.openApproval();
|
|
expect(page.window.open).toHaveBeenCalledTimes(2);
|
|
page.cleanup();
|
|
});
|
|
|
|
it("ignores a late healthy response after unmount and closes the popup", async () => {
|
|
const page = mount();
|
|
let complete!: (health: object) => void;
|
|
page.native.discoverNativeHealth.mockImplementation(() => new Promise(resolve => { complete = resolve; }));
|
|
await page.openApproval();
|
|
page.message();
|
|
page.cleanup();
|
|
complete({});
|
|
await settle();
|
|
page.message();
|
|
expect(page.native.discoverNativeHealth).toHaveBeenCalledOnce();
|
|
expect(page.activateClient).not.toHaveBeenCalled();
|
|
expect(page.onConnected).not.toHaveBeenCalled();
|
|
expect(page.popup.closed).toBe(true);
|
|
expect(page.native.discoverNativeHealth.mock.calls[0]![0].signal.aborted).toBe(true);
|
|
expect(page.setState).toHaveBeenLastCalledWith("approving");
|
|
});
|
|
|
|
it("never opens an approval page when discovery completes after unmount", async () => {
|
|
const page = mount();
|
|
let complete!: (url: string) => void;
|
|
page.native.discoverNativeConnect.mockImplementation(() => new Promise(resolve => { complete = resolve; }));
|
|
const connecting = page.connect();
|
|
await settle();
|
|
page.cleanup();
|
|
complete(approval);
|
|
await connecting;
|
|
expect(page.window.open).not.toHaveBeenCalled();
|
|
expect(page.activateClient).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("releases a closed approval window on focus and permits retry", async () => {
|
|
const page = mount();
|
|
await page.openApproval();
|
|
page.popup.closed = true;
|
|
page.window.dispatchEvent(new Event("focus"));
|
|
expect(page.pending.current).toBeNull();
|
|
expect(page.setState).toHaveBeenLastCalledWith("idle");
|
|
page.message();
|
|
expect(page.native.discoverNativeHealth).not.toHaveBeenCalled();
|
|
await page.openApproval();
|
|
expect(page.window.open).toHaveBeenCalledTimes(2);
|
|
page.cleanup();
|
|
});
|
|
|
|
it("verifies remembered activation without prompting and refreshes it on return", async () => {
|
|
const page = mount(true);
|
|
await settle();
|
|
expect(page.native.discoverNativeHealth).toHaveBeenCalledWith(expect.objectContaining({ waitForPermission: false }));
|
|
expect(page.setState).toHaveBeenLastCalledWith("ready");
|
|
expect(page.window.open).not.toHaveBeenCalled();
|
|
expect(page.activateClient).not.toHaveBeenCalled();
|
|
page.native.discoverNativeHealth.mockResolvedValue(null);
|
|
page.window.dispatchEvent(new Event("focus"));
|
|
await settle();
|
|
expect(page.setState).toHaveBeenLastCalledWith("idle");
|
|
page.cleanup();
|
|
});
|
|
|
|
it("reflects another App entry's activation without needing a focus change", async () => {
|
|
const page = mount();
|
|
await settle();
|
|
expect(page.native.discoverNativeHealth).not.toHaveBeenCalled();
|
|
page.activateElsewhere();
|
|
await settle();
|
|
expect(page.setState).toHaveBeenLastCalledWith("ready");
|
|
expect(page.window.open).not.toHaveBeenCalled();
|
|
page.cleanup();
|
|
page.activateElsewhere();
|
|
await settle();
|
|
expect(page.native.discoverNativeHealth).toHaveBeenCalledOnce();
|
|
});
|
|
|
|
it("does not let an earlier health check overwrite a newer approval", async () => {
|
|
const page = mount(true);
|
|
let complete!: (health: object | null) => void;
|
|
page.native.discoverNativeHealth.mockImplementationOnce(() => new Promise(resolve => { complete = resolve; }));
|
|
await settle();
|
|
await page.openApproval();
|
|
expect(page.native.discoverNativeHealth.mock.calls[0]![0].signal.aborted).toBe(true);
|
|
page.message();
|
|
await settle();
|
|
expect(page.setState).toHaveBeenLastCalledWith("ready");
|
|
complete(null);
|
|
await settle();
|
|
expect(page.setState).toHaveBeenLastCalledWith("ready");
|
|
page.cleanup();
|
|
});
|
|
});
|