From 9c6e2e129b4da42e145c86b200cdc2bc79cfdc78 Mon Sep 17 00:00:00 2001 From: AAA <35992542+TNTcraftHIM@users.noreply.github.com> Date: Fri, 27 Nov 2026 18:13:39 -0500 Subject: [PATCH] fix(ui): keep playback state and floating controls consistent Native original-page readiness now reaches the existing participant projection. Narrow playback gives time priority over the inline volume slider. Floating panels join room Back handling after their document adoption so return from picture-in-picture remains dismissible. Checked actual touch controls and PiP return in Chrome, focused playback and panel suites, and both TypeScript projects. --- docs/guide/troubleshooting.md | 5 +--- docs/guide/troubleshooting.zh-CN.md | 4 +-- .../channel/components/channel-media.css | 5 ++-- src/client/channel/presentation.ts | 4 +-- src/client/channel/watch-playback.ts | 3 +++ .../components/living/FloatingPanel.tsx | 3 +++ tests/channel-presentation.test.ts | 26 +++++++++++++++++-- 7 files changed, 36 insertions(+), 14 deletions(-) diff --git a/docs/guide/troubleshooting.md b/docs/guide/troubleshooting.md index 54336c838..d2164c8ff 100644 --- a/docs/guide/troubleshooting.md +++ b/docs/guide/troubleshooting.md @@ -221,7 +221,7 @@ its public rooms. Use the same browser profile to retain your existing identity; private/incognito profiles have separate saved credentials. -If Piik asks you to refresh, reload the page. If it asks you to update the +If Piik asks you to refresh, click **Refresh page**. If it asks you to update the site, contact the administrator who runs its Piik App or Server. ### The page opens but the site will not connect @@ -252,9 +252,6 @@ your 3.0 test and restart it. If it asks you to refresh, reload the page. If the page still needs an update, contact the site administrator. Then select **App** again. -If you are using an earlier beta with the old handshake, ask -the site administrator for the App package from that candidate. - ## Chat and files ### Chat or history will not load diff --git a/docs/guide/troubleshooting.zh-CN.md b/docs/guide/troubleshooting.zh-CN.md index ab22d58c0..d6ed2fce5 100644 --- a/docs/guide/troubleshooting.zh-CN.md +++ b/docs/guide/troubleshooting.zh-CN.md @@ -178,7 +178,7 @@ Piik App 的本地网络邀请使用临时自签名 HTTPS 证书,浏览器可 房间邀请被拒绝不会妨碍你继续使用站点或进入公开房间。 使用原浏览器配置可保留已有身份;隐私模式或另一浏览器配置使用各自保存的凭据。 -如果 Piik 提示刷新,请重新加载页面。如果提示更新站点,请联系站点管理员更新托管站点的 App 或 Server。 +如果 Piik 提示刷新,请点击 **刷新页面**。如果提示更新站点,请联系站点管理员更新托管站点的 App 或 Server。 ### 网页能打开但站点连接不上 @@ -201,8 +201,6 @@ Piik App 的本地网络邀请使用临时自签名 HTTPS 证书,浏览器可 如果 Piik 提示更新 App,请安装本次 3.0 内测提供的最新版并重启 App。如果提示刷新,请重新加载页面。 如果页面仍提示需要更新,请联系站点管理员。完成后再次点击 **App**。 -如果还在使用采用旧握手的内测站点,请向站点管理员索取同一内测批次的 App。 - ## 聊天与文件 ### 聊天或历史记录加载不出来 diff --git a/src/client/channel/components/channel-media.css b/src/client/channel/components/channel-media.css index 0cb8e4c9f..90c66f3d0 100644 --- a/src/client/channel/components/channel-media.css +++ b/src/client/channel/components/channel-media.css @@ -83,7 +83,6 @@ .c3-watch-position { display: flex; align-items: center; gap: 6px; min-width: 0; padding-inline: 2px; font-size: 12px; line-height: 1.2; } .c3-watch-status { display: inline-flex; align-items: center; gap: 4px; flex: none; white-space: nowrap; font-weight: 650; } .c3-watch-time { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; } -.c3-watch-time[data-live] { white-space: normal; text-overflow: clip; } .c3-watch-position[data-seeking] .c3-watch-time { color: var(--action); } .c3-mini-player[data-thumbnail] .c3-mini-controls > :is(.lr-chat-overlay-toggle, .lr-remote-controls), .c3-mini-player[data-thumbnail] .c3-mini-controls:not(.c3-watch-controls) .lr-playback-window { display: none; } @@ -135,8 +134,8 @@ .c3-mini-controls { --mini-controls-inset: 2px; width: calc(100% - 2 * var(--mini-controls-inset)); gap: 0; padding: 2px; } .c3-mini-controls .c3-mini-space { display: none; } } -@container (max-width: 256px) { - /* Keep the direct actions readable in the smallest tiles. */ +@container (max-width: 440px) { + /* Keep time and direct actions readable before exposing the volume slider. */ .c3-watch-inline-volume { display: none; } .c3-watch-volume { display: grid; } } diff --git a/src/client/channel/presentation.ts b/src/client/channel/presentation.ts index 5e71f5655..eeb893baa 100644 --- a/src/client/channel/presentation.ts +++ b/src/client/channel/presentation.ts @@ -69,7 +69,7 @@ export interface ParticipantActivity { } interface LocalWatchPresentation { sessionId: string | null; - watchPlayers: ReadonlyMap>; + watchPlayers: ReadonlyMap>; } export const viewingAppearance = { joined: { icon: "clapperboard", label: "watch.joined", rank: 0 }, @@ -87,7 +87,7 @@ function watchViewerState(watch: WatchActivity, sessionId: string, local?: Local if (player?.error) return "failed"; if (player?.blocked) return "joined"; if (player?.waitingForPicture) return "preparing"; - return player?.hasPresentedFrame ? "active" : "joined"; + return player?.hasPresentedFrame || player?.hasReadyOriginalPage ? "active" : "joined"; } function takesViewingPriority(next: ParticipantViewing, current?: ParticipantViewing): boolean { diff --git a/src/client/channel/watch-playback.ts b/src/client/channel/watch-playback.ts index bf89e597d..e7090097b 100644 --- a/src/client/channel/watch-playback.ts +++ b/src/client/channel/watch-playback.ts @@ -43,6 +43,9 @@ export class WatchPlayer { const required = media.paused || media.ended ? HAVE_CURRENT_DATA : HAVE_FUTURE_DATA; return media.readyState < required || Boolean(video && video.videoWidth > 0 && !this.hasPresentedFrame); } + get hasReadyOriginalPage(): boolean { + return !this.video && !!this.media.page && !this.waitingForPicture; + } presentFrame(): void { if (this.signal.aborted || this.presented) return; this.presented = true; this.changed(); diff --git a/src/client/components/living/FloatingPanel.tsx b/src/client/components/living/FloatingPanel.tsx index dddba0994..a0ac1ecc2 100644 --- a/src/client/components/living/FloatingPanel.tsx +++ b/src/client/components/living/FloatingPanel.tsx @@ -3,6 +3,7 @@ import { useImperativeHandle, useLayoutEffect, useRef, useState, type PointerEve import { createPortal } from "react-dom"; import { useCopy } from "../../ui/copy"; import { Glyph } from "../../ui/icons"; +import { useLayerHistory } from "../../ui/layer-history"; import { surfaceViewport } from "../../ui/window-appearance"; import { usePanelWindow, panelWindowAPI, SurfaceDocument, PANEL_SIZE } from "../../ui/panel-window"; import { Btn } from "./primitives"; @@ -121,6 +122,8 @@ export function FloatingPanel({ onDetachedTrigger, onNativeReady, closeOnReturn return () => owner.removeEventListener("fullscreenchange", hideOutsideFullscreen); }, [surfaceDocument]); + useLayerHistory(panelRef, open && !detached); + useLayoutEffect(() => { if (!surfaceDocument) return; if (surfaceDocument !== document) surfaceDocument.title = `${title} · Piik`; diff --git a/tests/channel-presentation.test.ts b/tests/channel-presentation.test.ts index f5431ee53..1f29a8ac4 100644 --- a/tests/channel-presentation.test.ts +++ b/tests/channel-presentation.test.ts @@ -12,7 +12,7 @@ import { firstUnreadMessageId, messageDateFormats, roomActivityPeople, roomPeopl import { messageSchema, snapshotSchema, watchActivitySchema } from "../src/client/channel/protocol"; import { say, t, type CopyKey } from "../src/client/ui/copy"; import { WatchPlayer } from "../src/client/channel/watch-playback"; -import type { WatchMedia } from "../src/client/channel/watch-media"; +import { AppPageMedia, type WatchMedia } from "../src/client/channel/watch-media"; const english = (key: CopyKey) => t("en", key); const chinese = (key: CopyKey) => t("zh", key); @@ -27,7 +27,7 @@ it("adds the date to a message timestamp across local midnight", () => { expect(formats.clock(message, new Date(2027, 0, 1))).toContain("2026"); }); -it("projects joined watch people independently of transport and deduplicates their endpoints", () => { +it("projects joined watch people independently of transport and deduplicates their endpoints", async () => { const sessions = [["owner-page", "owner"], ["owner-app", "owner"], ["viewer-web", "viewer"], ["viewer-app", "viewer"], ["direct-web", "direct"], ["relay-endpoint", "relay"]]; const activity = watchActivitySchema.parse({ id: "watch", roomId: "room", sessionId: "owner-page", userId: "owner", source: { kind: "website", url: "https://video.test/watch" }, playback: { timeline: "media" as const, position: 0, paused: true, rate: 1, anchorTime: 0 }, @@ -86,6 +86,28 @@ it("projects joined watch people independently of transport and deduplicates the expect(viewing("viewer")).toBe("failed"); expect(localViewing()).toBe("failed"); } finally { player.close(); } + let sample = { position: 0, paused: true, rate: 1, duration: 10, readyState: 1, ended: false, buffered: null }; + const page = new AppPageMedia({ id: "native-page", selectedCandidateId: "native-video", read: async () => sample, + patch: async () => {}, listen: () => () => {}, focus: async () => {}, close() {} }); + const originalPlayer = new WatchPlayer("room", false, page, () => {}); + local.watchPlayers.set("watch", originalPlayer); + state.watchActivities[0].viewerSessionIds = ["viewer-web", "direct-web"]; + try { + originalPlayer.calibrate(0, performance.now()); + originalPlayer.update(activity.playback); + await originalPlayer.sample(); + expect(viewing("viewer")).toBe("preparing"); + expect(localViewing()).toBe("preparing"); + sample = { ...sample, readyState: 4 }; + await originalPlayer.sample(); + expect(viewing("viewer")).toBe("active"); + expect(localViewing()).toBe("active"); + expect(viewing("direct")).toBe("joined"); + sample = { ...sample, readyState: 2, ended: true }; + await originalPlayer.sample(); + expect(viewing("viewer")).toBe("active"); + expect(localViewing()).toBe("active"); + } finally { originalPlayer.close(); } });