From 36cd8788dff44df663df13efcd7e4d1c816ec582 Mon Sep 17 00:00:00 2001 From: AAA <35992542+TNTcraftHIM@users.noreply.github.com> Date: Tue, 24 Nov 2026 06:33:25 -0500 Subject: [PATCH] fix(playback): reconcile webpage sources and clarify controls --- docs/research/room-interactions.md | 2 +- docs/todo.md | 24 ++++++++ .../channel/components/ChannelMedia.tsx | 11 ++-- .../channel/components/ChannelVoiceDock.tsx | 8 ++- .../components/ChannelVoiceSettings.tsx | 2 +- .../channel/components/channel-media.css | 20 +++++-- .../components/channel-voice-settings.css | 2 +- src/client/channel/session.ts | 24 +++++++- src/client/components/living/primitives.tsx | 4 +- src/client/room-voice/VoiceAudioButtons.tsx | 4 +- tests/channel-session.test.ts | 58 +++++++++++++++---- tests/watch-presentation.test.ts | 8 ++- 12 files changed, 129 insertions(+), 38 deletions(-) diff --git a/docs/research/room-interactions.md b/docs/research/room-interactions.md index 6a36706d2..61391f4cb 100644 --- a/docs/research/room-interactions.md +++ b/docs/research/room-interactions.md @@ -369,7 +369,7 @@ Renaming changes presentation without replacing media paths or input grants. Personal feedback sounds are off by default. **More options → Feedback sounds** sets the shared volume for this browser origin. Messages and throws can each be muted or previewed. A fresh message from another user, including an attachment-only message, -plays a short cue while the main page is hidden, unless the recipient is reading +plays a short cue while the main page is hidden or unfocused, unless the recipient is reading that room in a visible, focused popout. Foreground tomato and poop throws play for their sender and addressed user, whether directed at a person, message or shared picture. Other reactions and routine connection changes stay silent. diff --git a/docs/todo.md b/docs/todo.md index cd7a132cd..0a58d0ade 100644 --- a/docs/todo.md +++ b/docs/todo.md @@ -16,6 +16,30 @@ the feedback period; they do not delay that delivery. ### Active work +- [ ] **Audio device selection.** Provide explicit playback-device selection + through supported output APIs and shared playback owners. Distinguish room + microphones, source audio inputs and system-output capture; keep device + changes local to the intended audio path. +- [ ] **Message sounds in an unfocused window.** Verify beta.51 feedback where + message cues are silent while throw sounds work, including a visible but + unfocused main window and a focused conversation popout. +- [ ] **Voice shortcut discovery.** Make the existing microphone and listening + shortcuts easy to find and configure, with the same activity target for page + and global keyboard input. +- [ ] **Webpage source selection and watching continuity.** Reduce the steps + to choose and replace a webpage video. Keep existing viewers' surfaces during + replacement or temporary source absence, release old media and permissions, + and end retained viewing on explicit exit. Define replacement ownership + before changing the activity contract. +- [ ] **Playback control hierarchy.** Make progress, elapsed time and volume + immediately legible in screen and webpage playback, retaining shared controls + and usable narrow and touch layouts. +- [ ] **Webpage viewer readiness.** Reproduce reports of a loading viewer shown + as already watching, including Native original-page playback. Keep membership + distinct from proved playable media in the viewer surface and participant list. +- [ ] **Direct webpage delivery clarity.** Verify original-site playback and + explicit receipt from the sharer's App on the same source. Make the selected + route and upload responsibility clear without adding a competing route setting. - [ ] **Virtual LAN invitations time out.** Investigate intermittent page access and media failures reported on Android across several browsers in 2.x. Correlate the selected virtual address, effective firewall rules and incoming diff --git a/src/client/channel/components/ChannelMedia.tsx b/src/client/channel/components/ChannelMedia.tsx index 0bbd1ad77..a080019e7 100644 --- a/src/client/channel/components/ChannelMedia.tsx +++ b/src/client/channel/components/ChannelMedia.tsx @@ -122,7 +122,6 @@ export function ChannelWatchVideo({ player, owned, paused, label, presentation, const livePosition = live?.active ? live.syncPosition : null; const thumbnail = presentation === "thumbnail"; const showTimeline = !embedded && !thumbnail && seekAvailable; - const seekOverlay = showTimeline ? " lr-media-overlay" : ""; const [seekPreview, setSeekPreview] = useState(null); const draggingSeek = useRef(false); const position = Math.max(seekStart, Math.min(seekPreview ?? media.position, seekEnd || 1)); @@ -252,8 +251,8 @@ export function ChannelWatchVideo({ player, owned, paused, label, presentation, } : player.blocked &&
} - {hasControls &&
- {showTimeline &&
+ {hasControls &&
+ {showTimeline &&
{owned ? { draggingSeek.current = true; }} @@ -267,18 +266,18 @@ export function ChannelWatchVideo({ player, owned, paused, label, presentation, : }
}
- {!embedded &&
+ {!embedded &&
{owned && onPlayback({ paused: !ownerPaused })} />} {!thumbnail &&
{ended && {t("watch.ended")}} {live?.active && !seekAvailable && {t("watch.live")}} - {(!live || seekAvailable) && {timeLabel}} + {(!live || seekAvailable) && {live ? timeLabel : <>{formatMediaTime(position)}{` / ${formatMediaTime(media.duration || Number.NaN)}`}}}
} {owned && livePosition !== null && onPlayback({ position: livePosition, paused: false })} />}
} - {localControls &&
+ {localControls &&
{localVolume && { const video = player.video; if (!video) return; if (video.volume === 0) video.volume = 1; video.muted = !silent; }} />} diff --git a/src/client/channel/components/ChannelVoiceDock.tsx b/src/client/channel/components/ChannelVoiceDock.tsx index 67483699f..05e9e5e0f 100644 --- a/src/client/channel/components/ChannelVoiceDock.tsx +++ b/src/client/channel/components/ChannelVoiceDock.tsx @@ -18,7 +18,7 @@ import { VoiceOverlay } from "./voice-overlay"; import { useVoiceLevels } from "../../room-voice/use-voice-levels"; import { resolveVoiceDockControls } from "../voice-dock-controls"; import { useVoiceShortcuts } from "../use-voice-shortcuts"; -import { voiceShortcutAria } from "../voice-shortcut-binding"; +import { voiceShortcutAria, voiceShortcutLabel } from "../voice-shortcut-binding"; /** One persistent control surface for this endpoint's independently joined rooms. */ export function ChannelVoiceDock({ channel, selected, onSelect, onBrowse }: { @@ -41,6 +41,7 @@ export function ChannelVoiceDock({ channel, selected, onSelect, onBrowse }: { const roomName = nameOfRoom(roomId); const multipleRooms = joined.length > 1; const { muted, deafened } = activity; + const { microphone, listening } = shortcuts.bindings; const available = channel.connection === "connected" && !!state.channel.rooms.find(room => room.id === roomId)?.available; const appearances = overlay?.target ? roomVoicePeople(state, roomId, levels) : null; const run = (operation: Promise) => { void operation.catch(() => {}); }; @@ -93,11 +94,12 @@ export function ChannelVoiceDock({ channel, selected, onSelect, onBrowse }: {
toggle("microphone")} /> + cancelPending={microphonePending} quiet keyShortcuts={microphoneDisabled ? undefined : voiceShortcutAria(microphone)} + shortcutLabel={!microphoneDisabled && microphone ? voiceShortcutLabel(microphone, shortcuts.mac) : undefined} onClick={() => toggle("microphone")} /> toggle("listening")} /> + keyShortcuts={voiceShortcutAria(listening)} shortcutLabel={listening ? voiceShortcutLabel(listening, shortcuts.mac) : undefined} onClick={() => toggle("listening")} /> {overlay && <> ; } diff --git a/src/client/channel/components/channel-media.css b/src/client/channel/components/channel-media.css index efc65c98b..5baa2d9bb 100644 --- a/src/client/channel/components/channel-media.css +++ b/src/client/channel/components/channel-media.css @@ -120,7 +120,6 @@ @container (max-width: 280px) { .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; } - .c3-watch-actions > .lr-media-overlay { column-gap: 0; } /* Leave room for the shared timeline readout and direct actions at tile minimum. */ .c3-watch-inline-volume { display: none; } .c3-watch-volume { display: grid; } @@ -128,11 +127,20 @@ .c3-mini-player[data-thumbnail] .c3-mini-controls { width: fit-content; } .c3-mini-player[data-thumbnail] .c3-mini-controls .lr-btn:not(:where(.c3-mini-controls [popover] *)) { --button-size: var(--control-dense-size); } .c3-mini-controls.c3-watch-controls { display: grid; grid-template-columns: minmax(0, 1fr); row-gap: 0; border-radius: var(--c3-inset-radius); } -.c3-watch-controls:has(.c3-watch-timeline) { width: calc(100% - 2 * var(--mini-controls-inset)); row-gap: 4px; padding: 0; background: none; border: 0; box-shadow: none; } -.c3-watch-timeline { padding-inline: clamp(5px, 1.5cqi, 10px); } -.c3-watch-timeline, .c3-watch-actions > .lr-media-overlay { border-radius: var(--c3-inset-radius); } -.c3-watch-actions > .lr-media-overlay { padding-inline: clamp(2px, 0.8cqi, 4px); } -.c3-watch-timeline + .c3-watch-actions { column-gap: clamp(2px, 0.8cqi, 8px); } +.c3-watch-controls:has(.c3-watch-timeline) { + width: calc(100% - 2 * var(--mini-controls-inset)); + padding: 2px clamp(6px, 1.5cqi, 12px) 5px; +} +.c3-watch-timeline { padding-inline: 2px; } +.c3-watch-actions { gap: clamp(3px, 1cqi, 10px); } +.c3-watch-time strong { color: var(--ink); font-weight: 650; } +.c3-watch-position[data-seeking] .c3-watch-time strong { color: var(--action); } +.c3-watch-controls:has(.c3-watch-timeline) .c3-watch-local { flex: 1 0 auto; } +.c3-watch-controls:has(.c3-watch-timeline) .c3-watch-settings { margin-inline-start: auto; } +@container (max-width: 280px) { + .c3-watch-controls:has(.c3-watch-timeline) { padding-inline: 4px; } + .c3-watch-actions { gap: 2px; } +} .c3-watch-receiving .lr-btn:has(> .lr-cap) { width: fit-content; min-height: var(--control-compact-size); padding-inline: 8px; } @media (pointer: coarse) { .c3-watch-controls .lr-btn:not(:where(.c3-watch-controls [popover] *)) { --button-size: clamp(28px, 11.5cqi, var(--control-compact-size)); } diff --git a/src/client/channel/components/channel-voice-settings.css b/src/client/channel/components/channel-voice-settings.css index 2ce280206..8785520c6 100644 --- a/src/client/channel/components/channel-voice-settings.css +++ b/src/client/channel/components/channel-voice-settings.css @@ -3,7 +3,7 @@ .c3-voice-settings > p { margin: 6px 0; color: var(--muted); font-size: 12px; line-height: 1.6; } .c3-voice-settings > .lr-switch-item { margin-block-start: 6px; } .c3-voice-settings .lr-switch-item .lr-cap { white-space: normal; } -.c3-voice-shortcuts { margin-top: 14px; padding-top: 8px; border-top: 1px solid var(--control-edge); } +.c3-voice-shortcuts { margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--control-edge); } .c3-voice-shortcuts > header { display: flex; align-items: center; justify-content: space-between; } .c3-voice-shortcuts strong { font-size: var(--control-label-size); } .c3-voice-shortcuts p { margin: 4px 0 6px; color: var(--muted); font-size: 12px; line-height: 1.5; } diff --git a/src/client/channel/session.ts b/src/client/channel/session.ts index 9b36f7cb6..e0be93a3c 100644 --- a/src/client/channel/session.ts +++ b/src/client/channel/session.ts @@ -435,13 +435,13 @@ export class ChannelSession { const self = this.view.self?.id; if (this.closed || !self || !this.view.feedbackSound.enabled) return; const popout = this.conversationPopout; - const foreground = !document.hidden || (popout?.roomId === roomId && !popout.document.hidden && popout.document.hasFocus()); + const popoutFocused = popout?.roomId === roomId && !popout.document.hidden && popout.document.hasFocus(); if (event.payload.kind === "chat") { if (event.messageSeq !== undefined && event.messageSeq <= (this.view.readByRoom[roomId] ?? 0)) return; - if (!foreground && event.sender.peerId !== self) this.feedbackAudio.play("message"); + if (!popoutFocused && (document.hidden || !document.hasFocus()) && event.sender.peerId !== self) this.feedbackAudio.play("message"); return; } - if (!foreground || !isThrow(event.payload.reaction)) return; + if ((document.hidden && !popoutFocused) || !isThrow(event.payload.reaction)) return; const target = event.contentTarget; const recipient = target ? "messageSeq" in target ? this.view.messagesByRoom[roomId]?.find(message => message.seq === target.messageSeq && message.id === target.messageId)?.userId @@ -3156,6 +3156,24 @@ export class ChannelSession { }); }; private activateWatchOwner(id: string, player: WatchPlayer): void { + const page = player.media.page; + if (page instanceof AppPage) { + const reconcile = () => { + if (this.watchPlayers.get(id) === player && this.view.connection === "connected") + void this.reconcileWatchBytes(id, player).catch(() => {}); + }; + const release = page.listenMediaSources(reconcile); + let previous: WatchByteSource | undefined; + const publicationChanged = () => { + const declared = this.view.state?.watchActivities.find(activity => activity.id === id)?.byteSource; + if (previous === declared || (previous && sameWatchByteSource(previous, declared))) return; + previous = declared; + if (declared) reconcile(); + }; + const unsubscribe = this.subscribe(publicationChanged); + player.signal.addEventListener("abort", () => { release(); unsubscribe(); }, { once: true }); + publicationChanged(); + } player.activate(async playback => { if (this.watchPlayers.get(id) === player && this.view.connection === "connected") await this.request({ type: "update_watch", roomId: player.roomId, id, playback }, undefined, player.roomId); diff --git a/src/client/components/living/primitives.tsx b/src/client/components/living/primitives.tsx index 3781d184b..3ed49b900 100644 --- a/src/client/components/living/primitives.tsx +++ b/src/client/components/living/primitives.tsx @@ -57,6 +57,7 @@ export function Btn({ expanded, hasPopup, keyShortcuts, + shortcutLabel, controls, popoverTarget, onClick, @@ -89,6 +90,7 @@ export function Btn({ controls?: string; popoverTarget?: string; keyShortcuts?: string; + shortcutLabel?: string; onClick?: () => void; type?: "button" | "submit"; /** Shared hint comic with its localized caption. */ @@ -153,7 +155,7 @@ export function Btn({ ); return hint ? ( {button} - ) : textTooltip ? {button} : ( + ) : textTooltip ? {button} : ( button ); } diff --git a/src/client/room-voice/VoiceAudioButtons.tsx b/src/client/room-voice/VoiceAudioButtons.tsx index 8658fa079..de76ff654 100644 --- a/src/client/room-voice/VoiceAudioButtons.tsx +++ b/src/client/room-voice/VoiceAudioButtons.tsx @@ -2,7 +2,7 @@ import type { ComponentProps } from "react"; import { Btn } from "../components/living/primitives"; import { MicrophoneLevel } from "./MicrophoneLevel"; -type ButtonState = Pick, "disabled" | "busy" | "quiet" | "hint" | "hintText" | "keyShortcuts" | "onClick">; +type ButtonState = Pick, "disabled" | "busy" | "quiet" | "hint" | "hintText" | "keyShortcuts" | "shortcutLabel" | "onClick">; export function VoiceMicrophoneButton({ active, level, cancelPending, ...button }: ButtonState & { active: boolean; level?: number; cancelPending?: boolean }) { return ; + textTooltip={Boolean(button.shortcutLabel)} size="compact" draw="voice-listening" pressed={!deafened} />; } diff --git a/tests/channel-session.test.ts b/tests/channel-session.test.ts index bfa470bd4..496ecd899 100644 --- a/tests/channel-session.test.ts +++ b/tests/channel-session.test.ts @@ -467,7 +467,7 @@ test("accepted history resolves offline author, reply and mention IDs through th }); test("confirmed room events own personal feedback across text, attachments and throw targets", async () => { - const document = Object.assign(new EventTarget(), { hidden: true }); + const document = Object.assign(new EventTarget(), { hidden: true, hasFocus: (): boolean => true }); vi.stubGlobal("document", document); const play = vi.spyOn(FeedbackAudio.prototype, "play").mockImplementation(() => {}); const configure = vi.spyOn(FeedbackAudio.prototype, "configure").mockImplementation(() => {}); @@ -517,43 +517,48 @@ test("confirmed room events own personal feedback across text, attachments and t expect(play).toHaveBeenCalledTimes(3); document.hidden = false; + document.hasFocus = () => false; peer.live(fresh(94)); + expect(play).toHaveBeenLastCalledWith("message"); + expect(play).toHaveBeenCalledTimes(4); + document.hasFocus = () => true; + peer.live(fresh(95)); const reaction = (id: string, senderUserId: string, target: import("../src/client/channel/protocol").ReactionTarget, reaction = "tomato") => { peer.reply(peer.interactions[0], { type: "reaction", nonce: 1, snapshot: null, event: { id, senderUserId, target, reaction, occurredAt: Date.now() } }); }; reaction("self-person", "self-user-1234", { type: "person", userId: "friend-user-1234" }); - expect(play.mock.calls.length, "self-person").toBe(4); + expect(play.mock.calls.length, "self-person").toBe(5); reaction("self-person", "self-user-1234", { type: "person", userId: "friend-user-1234" }); reaction("to-person", "friend-user-1234", { type: "person", userId: "self-user-1234" }); - expect(play.mock.calls.length, "to-person").toBe(5); + expect(play.mock.calls.length, "to-person").toBe(6); reaction("to-message", "friend-user-1234", { type: "message", messageSeq: 90, messageId: message(90).id }, "poop"); - expect(play.mock.calls.length, "to-message").toBe(6); + expect(play.mock.calls.length, "to-message").toBe(7); reaction("to-screen", "friend-user-1234", { type: "publication", publicationId: "own-screen" }); - expect(play.mock.calls.length, "to-screen").toBe(7); + expect(play.mock.calls.length, "to-screen").toBe(8); reaction("self-message", "self-user-1234", { type: "message", messageSeq: 91, messageId: message(91).id }); - expect(play.mock.calls.length, "self-message").toBe(8); + expect(play.mock.calls.length, "self-message").toBe(9); reaction("self-screen", "self-user-1234", { type: "publication", publicationId: "own-screen" }, "poop"); - expect(play.mock.calls.length, "self-screen").toBe(9); - expect(play.mock.calls.map(([cue]) => cue)).toEqual(["message", "message", "message", ...Array(6).fill("throw")]); + expect(play.mock.calls.length, "self-screen").toBe(10); + expect(play.mock.calls.map(([cue]) => cue)).toEqual(["message", "message", "message", "message", ...Array(6).fill("throw")]); reaction("emoji", "friend-user-1234", { type: "person", userId: "self-user-1234" }, "heart"); reaction("bystander", "friend-user-1234", { type: "person", userId: "bystander" }); reaction("other-message", "friend-user-1234", { type: "message", messageSeq: 91, messageId: message(91).id }); reaction("unknown-screen", "friend-user-1234", { type: "publication", publicationId: "other-screen" }); document.hidden = true; reaction("hidden-throw", "friend-user-1234", { type: "person", userId: "self-user-1234" }); - expect(play).toHaveBeenCalledTimes(9); + expect(play).toHaveBeenCalledTimes(10); session.setConversationPopout("first", popout); reaction("popout-throw", "friend-user-1234", { type: "person", userId: "self-user-1234" }); - expect(play).toHaveBeenCalledTimes(10); + expect(play).toHaveBeenCalledTimes(11); expect(play).toHaveBeenLastCalledWith("throw"); session.setFeedbackSound({ enabled: false }); peer.live(fresh(93)); - expect(play).toHaveBeenCalledTimes(10); + expect(play).toHaveBeenCalledTimes(11); } finally { session.close(); } expect(close).toHaveBeenCalledOnce(); peer.live(fresh(94)); - expect(play).toHaveBeenCalledTimes(10); + expect(play).toHaveBeenCalledTimes(11); }); function stubFeedbackAudio() { @@ -12520,6 +12525,35 @@ test('closing forwarding settings during direct preparation releases the reader } finally { session.close(); } }); +test.each(["before activation", "before publication", "after publication"])("a native page source change %s withdraws the retired grant", async timing => { + let active: unknown = null; + const { session, page, socket } = await websiteSourceSelection(async () => ({ choices: [], indexedCandidates: [], byteSource: active })); + const media = new AppPageMedia(page); + await media.opening; + const player = new WatchPlayer("first", true, media, () => {}); + const owner = session as unknown as { watchPlayers: Map; activateWatchOwner(id: string, player: WatchPlayer): void }; + owner.watchPlayers.set("owned", player); + const state = session.getSnapshot().state!; + const activity = { + id: "owned", roomId: "first", viewerSessionIds: [], sessionId: "endpoint", userId: "self", + source: { kind: "website", url: page.url }, playback: { timeline: "media", position: 0, paused: true, rate: 1, anchorTime: 1000 }, + byteSource: { sessionId: crypto.randomUUID(), resourceId: crypto.randomUUID(), format: "file" }, + }; + try { + const publish = () => socket.receive({ type: "state", state: { ...state, watchActivities: [activity] } }); + const revoke = () => { active = null; page.receive({ type: "page_media_changed", pageId: page.id }); }; + active = activity.byteSource; + if (timing !== "before publication") publish(); + if (timing === "before activation") revoke(); + owner.activateWatchOwner("owned", player); + if (timing !== "before activation") revoke(); + if (timing === "before publication") publish(); + await vi.waitFor(() => expect(socket.sent.at(-1)).toMatchObject({ type: "set_watch_byte_source", id: "owned", byteSource: null })); + socket.receive({ type: "room_reply", roomId: "first", requestId: socket.sent.at(-1)!.requestId, result: { type: "done" } }); + expect(owner.watchPlayers.get("owned")).toBe(player); + } finally { session.close(); } +}); + test("foreground recovery cannot withdraw a replacement watch byte source", async () => { let completeRead!: (result: unknown) => void; const delayed = new Promise(resolve => { completeRead = resolve; }); diff --git a/tests/watch-presentation.test.ts b/tests/watch-presentation.test.ts index c4b426aa1..e3aa6eb80 100644 --- a/tests/watch-presentation.test.ts +++ b/tests/watch-presentation.test.ts @@ -33,6 +33,10 @@ function withWatchDocument(render: () => string): string { try { return render(); } finally { vi.unstubAllGlobals(); } } +function watchTimeReadout(html: string): string | undefined { + return html.match(/]*>(.*?)<\/span>/)?.[1].replace(/<[^>]+>/g, ""); +} + describe("Webpage watch presentation", () => { it("reserves a native slot only for a full stage with a local page and shell bridge", () => { const render = (pageId?: string, nativeStage = true, selected = true) => renderToStaticMarkup(createElement(ChannelWatchVideo, { @@ -121,7 +125,7 @@ describe("Webpage watch presentation", () => { const owner = render(true), viewer = render(false); expect(owner).toContain('aria-label="Playback progress for everyone"'); expect(owner).toContain('aria-valuetext="0:12 / 2:00"'); - expect(viewer).toContain('>0:12 / 2:00<'); + expect(watchTimeReadout(viewer)).toBe("0:12 / 2:00"); expect(owner).toMatch(/popover="auto"[\s\S]*]*aria-label="Playback speed for everyone"/); expect(viewer).toMatch(/]*max="120"[^>]*value="12"/); expect(viewer).not.toContain('type="range"'); @@ -367,7 +371,7 @@ describe("Webpage watch presentation", () => { expect(html).toContain(`role="group" aria-label="${t("en", "playback.controls")}"`); expect(html.includes('aria-label="Playback for everyone"')).toBe(owned); expect(html.includes('aria-label="Playback progress for everyone"')).toBe(owned); - expect(html).toContain('>0:42 / 4:00<'); + expect(watchTimeReadout(html)).toBe("0:42 / 4:00"); if (owned) expect(html).toMatch(/]*type="range"[^>]*max="240"/); else { expect(html).toMatch(/]*max="240"[^>]*value="42"/);