Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。
feat(ui): refine host presence and diagnostics layout (#344)
AAA837cbe1cf431
diff --git a/src/client/components/living/Comic.tsx b/src/client/components/living/Comic.tsxindex eaebf71c..29e5a4f1 100644--- a/src/client/components/living/Comic.tsx+++ b/src/client/components/living/Comic.tsx@@ -198,10 +198,9 @@ export function Moon({k?: number;}) {return (- <g transform={`translate(${r2(x - 229 * k)} ${r2(y - 48 * k)}) scale(${k})`}>+ <g transform={`translate(${r2(x)} ${r2(y)}) scale(${k})`}><path- fillRule="evenodd"- d="M229 39.5a8.5 8.5 0 1 1 0 17 8.5 8.5 0 1 1 0-17ZM232.5 42.3a6.3 6.3 0 1 0 0 11.4 6.3 6.3 0 1 0 0-11.4Z"+ d="M0 -8.5A8.5 8.5 0 1 0 0 8.5A6.2 8.5 0 0 1 0 -8.5Z"fill="#f2e9c9"/></g>@@ -471,11 +470,7 @@ ${rmBlock(<rect x={206} y={28} width={64} height={42} rx={8} fill={TV_BODY} stroke={TV_EDGE} strokeWidth={2} /><rect x={212} y={34} width={52} height={28} rx={4} fill={TV_SCREEN} /><g className="vls-wf-moon">- <path- fillRule="evenodd"- d="M229 39.5a8.5 8.5 0 1 1 0 17 8.5 8.5 0 1 1 0-17ZM232.5 42.3a6.3 6.3 0 1 0 0 11.4 6.3 6.3 0 1 0 0-11.4Z"- fill="#f2e9c9"- />+ <Moon x={229} y={48} /></g><g stroke="#a9bcd4" strokeWidth={2} strokeLinecap="round" fill="none"><path className="vls-wf-z1" opacity={0.55} d="M244 51h6l-6 4h6" />diff --git a/src/client/components/living/Couch.tsx b/src/client/components/living/Couch.tsxindex 964d14dd..6d4e54d1 100644--- a/src/client/components/living/Couch.tsx+++ b/src/client/components/living/Couch.tsx@@ -1,5 +1,5 @@// The couch: the roster as pawns watching the TV. Joining pawns hop in,-// self carries the green pointer, the host wears a crown (topology only).+// self carries the green pointer, and the host wears a crown.import { Glyph } from "../../ui/icons";import { useCopy } from "../../ui/copy";import { participantColor } from "./participant-color";@@ -30,19 +30,30 @@ export interface CouchEntry {selectable?: boolean;}+export interface CouchHostEntry {+ key: string;+ name: string;+ you?: boolean;+ selected?: boolean;+ controls?: string;+ onSelect?: () => void;+}+export function Couch({+ host,entries,selectedKey,onSelect,emptyHint,}: {+ host?: CouchHostEntry | null;entries: CouchEntry[];selectedKey?: string | null;onSelect?: (key: string) => void;emptyHint?: string;}) {const { vis, t } = useCopy();- const crowded = entries.length > 10;+ const crowded = entries.length + (host ? 1 : 0) > 10;return (<div className="lr-couch">@@ -59,8 +70,37 @@ export function Couch({<divclassName={`lr-pawns${crowded ? " is-crowded" : ""}`}role="group"- aria-label={t("common.viewers")}+ aria-label={`${t("common.host")} · ${t("common.viewers")}`}>+ {host+ ? host.onSelect+ ? (+ <button+ type="button"+ className={`lr-pawn is-host${host.you ? " is-you" : ""}${host.selected ? " is-selected" : ""}`}+ title={host.name}+ aria-label={`${host.name} · ${t("common.host")}`}+ aria-pressed={host.selected}+ aria-controls={host.controls}+ onClick={host.onSelect}+ >+ <PawnSvg color={participantColor(host.key)} crown />+ <i className="lr-pawn-led" aria-hidden="true" />+ <span className="lr-pawn-name">{host.name}</span>+ </button>+ )+ : (+ <span+ className={`lr-pawn is-host is-static${host.you ? " is-you" : ""}`}+ title={host.name}+ aria-label={`${host.name} · ${t("common.host")}`}+ >+ <PawnSvg color={participantColor(host.key)} crown />+ <i className="lr-pawn-led" aria-hidden="true" />+ <span className="lr-pawn-name">{host.name}</span>+ </span>+ )+ : null}{entries.map((entry, index) => {const stateLabel = entry.connected? t("state.peer.connected")@@ -124,7 +164,7 @@ export function Couch({<Glyph name="users" size={14} /><b>{entries.length}</b></span>- {entries.length === 0 ? (+ {entries.length === 0 && !host ? (<divclassName="lr-couch-empty"title={vis ? undefined : (emptyHint ?? t("host.viewers.empty"))}diff --git a/src/client/components/living/RouteTree.tsx b/src/client/components/living/RouteTree.tsxindex 16ca7215..2eb68d85 100644--- a/src/client/components/living/RouteTree.tsx+++ b/src/client/components/living/RouteTree.tsx@@ -1,7 +1,7 @@// The connection topology as a real tree: host (crowned) roots direct P2P// viewers and the SFU node; relay children hang off their parent viewer.// Data comes from deriveParticipantTopology.-import { memo, useSyncExternalStore } from "react";+import { memo, useLayoutEffect, useRef, useState } from "react";import type { LabeledViewerPresence } from "../../lib/viewer-presence";import {@@ -12,7 +12,7 @@ import { useCopy } from "../../ui/copy";import { PawnSvg } from "./Couch";import { participantColor } from "./participant-color";import {- topologyLayoutForViewport,+ topologyLayoutForWidth,type TopologyLayout,} from "./route-tree-layout";@@ -26,37 +26,34 @@ interface TreeNode {}const ROW_BASE = 40;-const NARROW_TOPOLOGY_QUERY = "(max-width: 640px)";+const DEFAULT_TOPOLOGY_WIDTH = 640;const PAWN_CENTER_X = 20;-const HOST_SCALE = 0.85;-const ROOT_SCALE = 0.72;-const CHILD_SCALE = 0.52;-const ROOT_LABEL_OFFSET_Y = 36;-const CHILD_LABEL_OFFSET_Y = 20;+const PAWN_SCALE = 0.72;+const PAWN_CENTER_Y = 24;+const LABEL_GAP = 12;function centeredPawnX(centerX: number, scale: number): number {return centerX - PAWN_CENTER_X * scale;}-function subscribeToNarrowViewport(listener: () => void): () => void {- if (typeof window === "undefined" || !window.matchMedia) return () => {};- const query = window.matchMedia(NARROW_TOPOLOGY_QUERY);- query.addEventListener("change", listener);- return () => query.removeEventListener("change", listener);+function centeredPawnY(centerY: number, scale: number): number {+ return centerY - PAWN_CENTER_Y * scale;}-function narrowViewportSnapshot(): boolean {- return (- typeof window !== "undefined" &&- Boolean(window.matchMedia?.(NARROW_TOPOLOGY_QUERY).matches)- );+function pawnLabelY(centerY: number, scale: number): number {+ return centerY + PAWN_CENTER_Y * scale + LABEL_GAP;}-function useNarrowViewport(): boolean {- return useSyncExternalStore(- subscribeToNarrowViewport,- narrowViewportSnapshot,- () => false,+function PawnOutline({ className }: { className: string }) {+ return (+ <rect+ className={className}+ x="1"+ y="2"+ width="38"+ height="46"+ rx="8"+ />);}@@ -104,8 +101,30 @@ export const RouteTree = memo(function RouteTree({onSelectPeer?: (peerId: string) => void;}) {const { t } = useCopy();- const narrowViewport = useNarrowViewport();- const layoutConfig = topologyLayoutForViewport(narrowViewport);+ const routeRef = useRef<HTMLDivElement>(null);+ const [containerWidth, setContainerWidth] = useState(+ DEFAULT_TOPOLOGY_WIDTH,+ );+ const [hoveredPeerId, setHoveredPeerId] = useState<string | null>(null);+ useLayoutEffect(() => {+ const route = routeRef.current;+ if (!route) return;+ const updateWidth = () => {+ const width = Math.round(route.getBoundingClientRect().width);+ if (width > 0) {+ setContainerWidth((current) => (current === width ? current : width));+ }+ };+ updateWidth();+ if (typeof ResizeObserver === "undefined") {+ window.addEventListener("resize", updateWidth);+ return () => window.removeEventListener("resize", updateWidth);+ }+ const observer = new ResizeObserver(updateWidth);+ observer.observe(route);+ return () => observer.disconnect();+ }, []);+ const layoutConfig = topologyLayoutForWidth(containerWidth);const topology = deriveParticipantTopology(hostPeerId, viewers);const selectable = new Set(selectablePeerIds ?? (onSelectPeer ? viewers.map((viewer) => viewer.peerId) : []),@@ -245,6 +264,7 @@ export const RouteTree = memo(function RouteTree({return (<div+ ref={routeRef}className="lr-route"role="group"aria-labelledby={topologyTitleId}@@ -260,7 +280,7 @@ export const RouteTree = memo(function RouteTree({aria-label={onSelectPeer ? t("host.topology") : undefined}focusable={onSelectPeer ? undefined : "false"}style={- narrowViewport || scrollableCanvas+ scrollableCanvas? { width, maxWidth: "none" }: {width: "100%",@@ -325,14 +345,14 @@ export const RouteTree = memo(function RouteTree({<gclassName="lr-route-node is-host"- transform={`translate(${centeredPawnX(hostPos.x, HOST_SCALE)}, ${hostPos.y - 20}) scale(${HOST_SCALE})`}+ transform={`translate(${centeredPawnX(hostPos.x, PAWN_SCALE)}, ${centeredPawnY(hostPos.y, PAWN_SCALE)}) scale(${PAWN_SCALE})`}><PawnSvg color={participantColor(hostPeerId ?? "host-pending")} crown /></g><textclassName="lr-route-label is-host"x={hostPos.x}- y={hostPos.y + 30}+ y={pawnLabelY(hostPos.y, PAWN_SCALE)}textAnchor="middle">{compactVisibleLabel(@@ -363,56 +383,59 @@ export const RouteTree = memo(function RouteTree({{nodes.map((node) => {const point = pos.get(node.key)!;- const child = node.via !== null && !node.sfu;const selected = selectedPeerId === node.key;- const scale = child ? CHILD_SCALE : ROOT_SCALE;+ const hovered = hoveredPeerId === node.key;return (<gkey={node.key}- className={`lr-route-node${node.ready ? "" : " is-recovering"}${selected ? " is-selected" : ""}`}- transform={`translate(${centeredPawnX(point.x, scale)}, ${point.y - 15}) scale(${scale})`}+ className={`lr-route-node${node.ready ? "" : " is-recovering"}${hovered ? " is-hovered" : ""}${selected ? " is-selected" : ""}`}+ transform={`translate(${centeredPawnX(point.x, PAWN_SCALE)}, ${centeredPawnY(point.y, PAWN_SCALE)}) scale(${PAWN_SCALE})`}><PawnSvg color={participantColor(node.key)} />+ {hovered && !selected ? (+ <PawnOutline className="lr-route-hover" />+ ) : null}{selected ? (- <circle className="lr-route-selection" cx="20" cy="26" r="25" />+ <PawnOutline className="lr-route-selection" />) : null}{node.you ? (- <circle className="lr-route-you" cx="20" cy="26" r="21" />+ <PawnOutline className="lr-route-you" />) : null}</g>);})}- {pendingPos.map((point) => (- <g- key={`pending-${point.viewer.peerId}`}- className={`lr-route-node is-recovering${selectedPeerId === point.viewer.peerId ? " is-selected" : ""}`}- transform={`translate(${centeredPawnX(point.x, ROOT_SCALE)}, ${point.y - 15}) scale(${ROOT_SCALE})`}- >- <PawnSvg- color={participantColor(point.viewer.peerId)}- />- {selectedPeerId === point.viewer.peerId ? (- <circle className="lr-route-selection" cx="20" cy="26" r="25" />- ) : null}- {selfPeerId === point.viewer.peerId ? (- <circle className="lr-route-you" cx="20" cy="26" r="21" />- ) : null}- </g>- ))}+ {pendingPos.map((point) => {+ const selected = selectedPeerId === point.viewer.peerId;+ const hovered = hoveredPeerId === point.viewer.peerId;+ return (+ <g+ key={`pending-${point.viewer.peerId}`}+ className={`lr-route-node is-recovering${hovered ? " is-hovered" : ""}${selected ? " is-selected" : ""}`}+ transform={`translate(${centeredPawnX(point.x, PAWN_SCALE)}, ${centeredPawnY(point.y, PAWN_SCALE)}) scale(${PAWN_SCALE})`}+ >+ <PawnSvg color={participantColor(point.viewer.peerId)} />+ {hovered && !selected ? (+ <PawnOutline className="lr-route-hover" />+ ) : null}+ {selected ? (+ <PawnOutline className="lr-route-selection" />+ ) : null}+ {selfPeerId === point.viewer.peerId ? (+ <PawnOutline className="lr-route-you" />+ ) : null}+ </g>+ );+ })}{nodes.map((node) => {const point = pos.get(node.key)!;- const child = node.via !== null && !node.sfu;return (<textkey={`label-${node.key}`}- className={`lr-route-label${selectedPeerId === node.key ? " is-selected" : ""}`}+ className={`lr-route-label${hoveredPeerId === node.key ? " is-hovered" : ""}${selectedPeerId === node.key ? " is-selected" : ""}`}x={point.x}- y={- point.y +- (child ? CHILD_LABEL_OFFSET_Y : ROOT_LABEL_OFFSET_Y)- }+ y={pawnLabelY(point.y, PAWN_SCALE)}textAnchor="middle">{compactVisibleLabel(@@ -425,9 +448,9 @@ export const RouteTree = memo(function RouteTree({{pendingPos.map((point) => (<textkey={`label-pending-${point.viewer.peerId}`}- className={`lr-route-label is-recovering${selectedPeerId === point.viewer.peerId ? " is-selected" : ""}`}+ className={`lr-route-label is-recovering${hoveredPeerId === point.viewer.peerId ? " is-hovered" : ""}${selectedPeerId === point.viewer.peerId ? " is-selected" : ""}`}x={point.x}- y={point.y + ROOT_LABEL_OFFSET_Y}+ y={pawnLabelY(point.y, PAWN_SCALE)}textAnchor="middle">{compactVisibleLabel(@@ -458,7 +481,22 @@ export const RouteTree = memo(function RouteTree({role="button"tabIndex={0}aria-label={`${node.label} · ${t("host.details")}`}- onClick={() => selectPeer(node.key)}+ onPointerEnter={() => setHoveredPeerId(node.key)}+ onPointerLeave={() =>+ setHoveredPeerId((current) =>+ current === node.key ? null : current,+ )+ }+ onFocus={() => setHoveredPeerId(node.key)}+ onBlur={() =>+ setHoveredPeerId((current) =>+ current === node.key ? null : current,+ )+ }+ onClick={(event) => {+ selectPeer(node.key);+ if (event.detail !== 0) event.currentTarget.blur();+ }}onKeyDown={(event) => {if (event.key === "Enter" || event.key === " ") {event.preventDefault();diff --git a/src/client/components/living/route-tree-layout.ts b/src/client/components/living/route-tree-layout.tsindex a7fbcc99..e82cda23 100644--- a/src/client/components/living/route-tree-layout.ts+++ b/src/client/components/living/route-tree-layout.ts@@ -6,22 +6,29 @@ export interface TopologyLayout {maxVisibleLabelCodePoints: number;}-const DESKTOP_LAYOUT: TopologyLayout = {- baseWidth: 640,- hostX: 170,- columnGap: 220,- rightLabelReserve: 170,- maxVisibleLabelCodePoints: 16,-};+const MIN_LAYOUT_WIDTH = 260;+const MAX_LAYOUT_WIDTH = 640;-const NARROW_LAYOUT: TopologyLayout = {- baseWidth: 260,- hostX: 54,- columnGap: 130,- rightLabelReserve: 65,- maxVisibleLabelCodePoints: 10,-};+function interpolate(start: number, end: number, progress: number): number {+ return Math.round(start + (end - start) * progress);+}-export function topologyLayoutForViewport(narrow: boolean): TopologyLayout {- return narrow ? NARROW_LAYOUT : DESKTOP_LAYOUT;+export function topologyLayoutForWidth(containerWidth: number): TopologyLayout {+ const finiteWidth = Number.isFinite(containerWidth)+ ? containerWidth+ : MAX_LAYOUT_WIDTH;+ const baseWidth = Math.round(+ Math.min(MAX_LAYOUT_WIDTH, Math.max(MIN_LAYOUT_WIDTH, finiteWidth)),+ );+ const progress =+ (baseWidth - MIN_LAYOUT_WIDTH) /+ (MAX_LAYOUT_WIDTH - MIN_LAYOUT_WIDTH);+ return {+ baseWidth,+ hostX: interpolate(54, 170, progress),+ columnGap: interpolate(130, 220, progress),+ rightLabelReserve: interpolate(65, 170, progress),+ maxVisibleLabelCodePoints:+ baseWidth < 420 ? 10 : baseWidth < 560 ? 13 : 16,+ };}diff --git a/src/client/lib/display-name.ts b/src/client/lib/display-name.tsindex d6ccf242..f5a20317 100644--- a/src/client/lib/display-name.ts+++ b/src/client/lib/display-name.ts@@ -42,7 +42,7 @@ export function defaultViewerDisplayName(visual: boolean,): DisplayName {return visual- ? suffixedDefaultName("👀", clientId)+ ? suffixedDefaultName("👤", clientId): (say("common.name.viewerDefault") as DisplayName);}@@ -51,7 +51,7 @@ export function defaultHostDisplayName(visual = false,): DisplayName {return suffixedDefaultName(- visual ? "📺" : say("common.name.hostDefault"),+ visual ? "👑" : say("common.name.hostDefault"),clientId,);}diff --git a/src/client/pages/HostPage.tsx b/src/client/pages/HostPage.tsxindex f916f28f..239e485e 100644--- a/src/client/pages/HostPage.tsx+++ b/src/client/pages/HostPage.tsx@@ -2562,6 +2562,9 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {};},);+ const hostDiagnosticsAvailable = Boolean(+ (details && stream) || viewerOverviewEntries.length > 0,+ );const noticeText = noticeValue? noticeValue.kind === "text"@@ -2817,6 +2820,28 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {</StageTv><div className="lr-shelf" aria-hidden="true" /><Couch+ host={{+ key: hostPeerId ?? hostClientIdRef.current ?? "host-local",+ name: hostPresence?.displayName ?? displayName,+ you: true,+ selected:+ hostDiagnosticsAvailable &&+ showConnectionDetails &&+ selectedPawn === null,+ controls: hostDiagnosticsAvailable+ ? "host-details-panel host-viewer-overview"+ : undefined,+ onSelect: hostDiagnosticsAvailable+ ? () => {+ if (selectedPawn !== null) {+ setSelectedPawn(null);+ setShowConnectionDetails(true);+ return;+ }+ setShowConnectionDetails((current) => !current);+ }+ : undefined,+ }}entries={couchEntries}selectedKey={selectedPawn}onSelect={(key) =>@@ -2829,6 +2854,213 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {</div><div className="lr-deck">+ <Row>+ {room ? (+ <RowGroup>+ <FieldCap k="common.roomCode" />+ <RoomChip+ roomId={room.roomId}+ onReplace={replaceCurrentRoom}+ replaceDisabled={phase === "starting" || roomMutating}+ />+ </RowGroup>+ ) : null}+ <RowGroup>+ <StatusText>{phaseLine}</StatusText>+ {!details?.hasAudio && stream ? (+ <Pill icon="speaker" label={t("host.noAudio")} comic="no-audio" />+ ) : null}+ {qualityLimitation ? (+ <Pill icon="alert" label={qualityLimitation} comic="warning" />+ ) : null}+ {noticeText && (vis || noticeText !== phaseLine) ? (+ <Pill+ icon={noticeComic ? "alert" : "check"}+ tone={noticeComic ? undefined : "good"}+ label={noticeText}+ comic={noticeComic ?? undefined}+ />+ ) : null}+ </RowGroup>+ <span className="lr-spacer" />+ <div className="lr-host-personal-controls">+ <div className="lr-row-group lr-group-name lr-host-identity-slot">+ {editingDisplayName ? (+ <form+ style={{ display: "contents" }}+ onSubmit={(event) => {+ event.preventDefault();+ commitDisplayName();+ }}+ >+ <span className="lr-input lr-name-editor">+ <input+ id="host-display-name"+ type="text"+ value={displayNameDraft}+ maxLength={96}+ autoComplete="nickname"+ autoFocus+ aria-label={t("host.name")}+ aria-invalid={displayNameError ? "true" : undefined}+ onChange={(event) => {+ setDisplayNameDraft(event.target.value);+ setDisplayNameError(null);+ }}+ />+ </span>+ <Btn+ icon="check"+ title="host.nameSave"+ hint="hint-rename"+ type="submit"+ disabled={displayNameDraft === displayName}+ />+ {hintWrap(+ "hint-close",+ <Btn+ icon="x"+ title="host.nameCancel"+ onClick={() => {+ setDisplayNameDraft(displayName);+ setDisplayNameError(null);+ setEditingDisplayName(false);+ }}+ />,+ "end",+ )}+ </form>+ ) : (+ <>+ <NameTag+ name={hostPresence?.displayName ?? displayName}+ identity={+ hostPeerId ?? hostClientIdRef.current ?? "host-pending"+ }+ />+ {hintWrap(+ "hint-rename",+ <Btn+ icon="pencil"+ cap="common.edit"+ title="host.nameEdit"+ onClick={() => {+ setDisplayNameDraft(displayName);+ setDisplayNameError(null);+ setEditingDisplayName(true);+ }}+ />,+ "end",+ )}+ </>+ )}+ {displayNameError ? (+ <Pill+ icon="alert"+ tone="bad"+ label={displayNameError}+ alert+ comic="warning"+ />+ ) : null}+ </div>+ <div className="lr-row-group lr-group-actions lr-host-diagnostics-slot">+ {hintWrap(+ "hint-details",+ <Btn+ icon="gauge"+ cap={+ showConnectionDetails+ ? "host.details.hide"+ : "host.details"+ }+ title={+ showConnectionDetails+ ? "host.details.hide"+ : "host.details"+ }+ tone={showConnectionDetails ? "on" : undefined}+ expanded={showConnectionDetails}+ controls="host-details-panel host-viewer-overview"+ disabled={!hostDiagnosticsAvailable}+ onClick={() =>+ setShowConnectionDetails((current) => !current)+ }+ />,+ "start",+ )}+ {hintWrap(+ "hint-topology",+ <Btn+ icon="network"+ cap="host.topology"+ title={+ showTopology+ ? "host.topology.hide"+ : "host.topology.show"+ }+ tone={showTopology ? "on" : undefined}+ expanded={showTopology}+ controls="room-topology"+ onClick={() => setShowTopology((current) => !current)}+ />,+ "end",+ )}+ </div>+ {phase === "live" || phase === "starting" ? (+ <div className="lr-row-group lr-group-actions lr-host-share-slot">+ {phase === "live" ? (+ <>+ <Btn+ icon={sharingPaused ? "play" : "pause"}+ cap={sharingPaused ? "host.resume" : "host.pause"}+ title={sharingPaused ? "host.resume" : "host.pause"}+ hint={sharingPaused ? "hint-resume" : "hint-pause"}+ draw="host-share-toggle"+ disabled={switchingSource || changingQuality}+ onClick={toggleSharingPause}+ />+ {hintWrap(+ "hint-switch-source",+ <Btn+ icon="switchSource"+ cap={switchingSource ? "host.switching" : "host.switchSource"}+ title="host.switchSource"+ disabled={switchingSource || changingQuality}+ onClick={() => void switchSource()}+ />,+ "end",+ )}+ {hintWrap(+ "hint-share-stop",+ <Btn+ icon="stop"+ tone="danger"+ cap="host.stop"+ title="host.stop"+ onClick={() => endSharing({ key: "host.stopNotice" })}+ />,+ "end",+ )}+ </>+ ) : (+ hintWrap(+ "hint-share-stop",+ <Btn+ icon="x"+ tone="danger"+ cap="host.cancelStart"+ title="host.cancelStart"+ onClick={() => endSharing({ key: "host.startCancelled" })}+ />,+ "end",+ )+ )}+ </div>+ ) : null}+ </div>+ </Row>+{showConnectionDetails && details && stream ? (<Row sub><div id="host-details-panel" style={{ display: "contents" }}>@@ -2934,169 +3166,46 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {</div></Row>) : null}- <Row>- {room ? (- <RowGroup>- <FieldCap k="common.roomCode" />- <RoomChip- roomId={room.roomId}- onReplace={replaceCurrentRoom}- replaceDisabled={phase === "starting" || roomMutating}- />- </RowGroup>- ) : null}- <RowGroup>- <StatusText>{phaseLine}</StatusText>- {!details?.hasAudio && stream ? (- <Pill icon="speaker" label={t("host.noAudio")} comic="no-audio" />- ) : null}- {qualityLimitation ? (- <Pill icon="alert" label={qualityLimitation} comic="warning" />- ) : null}- {noticeText && (vis || noticeText !== phaseLine) ? (- <Pill- icon={noticeComic ? "alert" : "check"}- tone={noticeComic ? undefined : "good"}- label={noticeText}- comic={noticeComic ?? undefined}- />- ) : null}- </RowGroup>- <span className="lr-spacer" />- <div- style={{- display: "flex",- flexWrap: "wrap",- alignItems: "center",- gap: 12,- minWidth: 0,- }}- >- <RowGroup>- {editingDisplayName ? (- <form- style={{ display: "contents" }}- onSubmit={(event) => {- event.preventDefault();- commitDisplayName();- }}- >- <span className="lr-input lr-name-editor">- <input- id="host-display-name"- type="text"- value={displayNameDraft}- maxLength={96}- autoComplete="nickname"- autoFocus- aria-label={t("host.name")}- aria-invalid={displayNameError ? "true" : undefined}- onChange={(event) => {- setDisplayNameDraft(event.target.value);- setDisplayNameError(null);- }}- />- </span>- <Btn- icon="check"- title="host.nameSave"- hint="hint-rename"- type="submit"- disabled={displayNameDraft === displayName}- />- {hintWrap(- "hint-close",- <Btn- icon="x"- title="host.nameCancel"- onClick={() => {- setDisplayNameDraft(displayName);- setDisplayNameError(null);- setEditingDisplayName(false);- }}- />,- "end",- )}- </form>- ) : (- <>- <NameTag- name={hostPresence?.displayName ?? displayName}- identity={- hostPeerId ?? hostClientIdRef.current ?? "host-pending"- }- />- {hintWrap(- "hint-rename",- <Btn- icon="pencil"- cap="common.edit"- title="host.nameEdit"- onClick={() => {- setDisplayNameDraft(displayName);- setDisplayNameError(null);- setEditingDisplayName(true);- }}- />,- "end",- )}- </>- )}- {displayNameError ? (- <Pill icon="alert" tone="bad" label={displayNameError} alert comic="warning" />- ) : null}- </RowGroup>- <RowGroup actions>- {phase === "live" ? (- <>- <Btn- icon={sharingPaused ? "play" : "pause"}- cap={sharingPaused ? "host.resume" : "host.pause"}- title={sharingPaused ? "host.resume" : "host.pause"}- hint={sharingPaused ? "hint-resume" : "hint-pause"}- draw="host-share-toggle"- disabled={switchingSource || changingQuality}- onClick={toggleSharingPause}- />- {hintWrap(- "hint-switch-source",- <Btn- icon="switchSource"- cap={switchingSource ? "host.switching" : "host.switchSource"}- title="host.switchSource"- disabled={switchingSource || changingQuality}- onClick={() => void switchSource()}- />,- "end",- )}- {hintWrap(- "hint-share-stop",- <Btn- icon="stop"- tone="danger"- cap="host.stop"- title="host.stop"- onClick={() => endSharing({ key: "host.stopNotice" })}- />,- "end",- )}- </>- ) : phase === "starting" ? (- hintWrap(- "hint-share-stop",- <Btn- icon="x"- tone="danger"- cap="host.cancelStart"- title="host.cancelStart"- onClick={() => endSharing({ key: "host.startCancelled" })}- />,- "end",+ {showConnectionDetails && viewerOverviewEntries.length > 0 ? (+ <ViewerOverview+ entries={viewerOverviewEntries}+ selectedKey={selectedPawn}+ onSelect={(peerId) =>+ setSelectedPawn((current) =>+ current === peerId ? null : peerId,)- ) : null}- </RowGroup>- </div>- </Row>+ }+ />+ ) : null}+ {selectedViewer && selectedDetail ? (+ <PawnDetail+ pawnKey={selectedViewer.peerId}+ name={selectedViewer.label}+ route={selectedDetail.route}+ metrics={selectedDetail.metrics}+ direction={selectedDetail.direction}+ tag={selectedDetail.tag}+ error={selectedDetail.error}+ expanded={metricsExpanded}+ onToggleMetrics={setMetricsExpanded}+ onClose={() => setSelectedPawn(null)}+ />+ ) : null}+ {showTopology ? (+ <Row sub>+ <RouteTree+ hostPeerId={hostPeerId}+ hostLabel={labeledHostPresence?.label ?? displayName}+ viewers={viewers}+ selectedPeerId={selectedPawn}+ onSelectPeer={(peerId) =>+ setSelectedPawn((current) =>+ current === peerId ? null : peerId,+ )+ }+ />+ </Row>+ ) : null}{room ? (<Row label={t("host.invite")}>@@ -3666,77 +3775,6 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {</div></div>- {showConnectionDetails && viewerOverviewEntries.length > 0 ? (- <ViewerOverview- entries={viewerOverviewEntries}- selectedKey={selectedPawn}- onSelect={(peerId) =>- setSelectedPawn((current) =>- current === peerId ? null : peerId,- )- }- />- ) : null}- {selectedViewer && selectedDetail ? (- <PawnDetail- pawnKey={selectedViewer.peerId}- name={selectedViewer.label}- route={selectedDetail.route}- metrics={selectedDetail.metrics}- direction={selectedDetail.direction}- tag={selectedDetail.tag}- error={selectedDetail.error}- expanded={metricsExpanded}- onToggleMetrics={setMetricsExpanded}- onClose={() => setSelectedPawn(null)}- />- ) : null}- {showTopology ? (- <Row sub>- <RouteTree- hostPeerId={hostPeerId}- hostLabel={labeledHostPresence?.label ?? displayName}- viewers={viewers}- selectedPeerId={selectedPawn}- onSelectPeer={(peerId) =>- setSelectedPawn((current) =>- current === peerId ? null : peerId,- )- }- />- </Row>- ) : null}- <Row label={t("host.details")}>- <RowGroup actions>- {hintWrap(- "hint-details",- <Btn- icon="gauge"- cap={showConnectionDetails ? "host.details.hide" : "host.details"}- title={showConnectionDetails ? "host.details.hide" : "host.details"}- tone={showConnectionDetails ? "on" : undefined}- expanded={showConnectionDetails}- controls="host-details-panel host-viewer-overview"- disabled={(!details || !stream) && viewers.length === 0}- onClick={() => setShowConnectionDetails((current) => !current)}- />,- "start",- )}- {hintWrap(- "hint-topology",- <Btn- icon="network"- cap="host.topology"- title={showTopology ? "host.topology.hide" : "host.topology.show"}- tone={showTopology ? "on" : undefined}- expanded={showTopology}- controls="room-topology"- onClick={() => setShowTopology((current) => !current)}- />,- "end",- )}- </RowGroup>- </Row></div></main></div>diff --git a/src/client/pages/ViewerPage.tsx b/src/client/pages/ViewerPage.tsxindex 8660cd29..4c95c117 100644--- a/src/client/pages/ViewerPage.tsx+++ b/src/client/pages/ViewerPage.tsx@@ -2503,6 +2503,14 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {) : null}<div className="lr-shelf" aria-hidden="true" /><Couch+ host={+ labeledHostPresence+ ? {+ key: labeledHostPresence.peerId,+ name: labeledHostPresence.label,+ }+ : null+ }entries={couchEntries}selectedKey={selectedPawn}onSelect={(key) =>@@ -2668,27 +2676,28 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {setShowConnectionDetails((current) => !current)}/>- {labeledHostPresence- ? hintWrap(- "hint-topology",- <Btn- icon="network"- cap="host.topology"- title={- showTopology- ? "host.topology.hide"- : "host.topology.show"- }- tone={showTopology ? "on" : undefined}- expanded={showTopology}- controls="room-topology"- onClick={() =>- setShowTopology((current) => !current)- }- />,- "start",- )- : null}+ {hintWrap(+ "hint-topology",+ <Btn+ icon="network"+ cap="host.topology"+ title={+ labeledHostPresence && showTopology+ ? "host.topology.hide"+ : "host.topology.show"+ }+ tone={+ labeledHostPresence && showTopology ? "on" : undefined+ }+ expanded={Boolean(labeledHostPresence && showTopology)}+ controls="room-topology"+ disabled={!labeledHostPresence}+ onClick={() =>+ setShowTopology((current) => !current)+ }+ />,+ "start",+ )}</span></div></div>diff --git a/src/client/styles.css b/src/client/styles.cssindex b54d62c5..0f11fdb6 100644--- a/src/client/styles.css+++ b/src/client/styles.css@@ -568,6 +568,8 @@ body.lr-theater-open { overflow: hidden; }transform: translateX(-50%);}.lr-pawn.is-you { z-index: 1; }+.lr-pawn.is-host { margin-right: 6px; }+.lr-pawn.is-host .lr-pawn-name { font-weight: 850; }.lr-pawn.is-static { cursor: default; }.lr-pawn.is-selected { transform: translateY(-5px); }.lr-pawn.is-selected::before {@@ -646,6 +648,23 @@ body.lr-theater-open { overflow: hidden; }.lr-row.is-sub { background: var(--wall-2); border-color: transparent; }.lr-row-group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; }.lr-group-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }+.lr-host-personal-controls {+ display: flex;+ min-width: 0;+ flex: 0 1 auto;+ flex-wrap: wrap;+ align-items: center;+ gap: 8px;+}+.lr-host-identity-slot,+.lr-host-diagnostics-slot,+.lr-host-share-slot { flex: 0 0 auto; }+.lr-host-diagnostics-slot,+.lr-host-share-slot,+.lr-viewer-actions-slot {+ padding-inline-start: 10px;+ border-inline-start: 2.5px solid var(--wall-2);+}.lr-viewer-summary-row {display: flex;flex-wrap: wrap;@@ -700,7 +719,9 @@ html[data-theme="dark"] .lr-viewer-host-slot svg { color: #9bb0c5; }}.lr-viewer-action-separator {width: 2.5px;- align-self: stretch;+ height: 32px;+ flex: 0 0 auto;+ align-self: center;border-radius: 2px;background: var(--wall-2);}@@ -1026,7 +1047,14 @@ html[data-theme="dark"] .lr-meter-cell svg { color: #7d92a8; }.lr-pawn-detail { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }.lr-pawn-mini { display: grid; place-items: center; }.lr-pawn-mini svg { width: 28px; height: 34px; display: block; }-.lr-pawn-detail-name { font-size: 14px; font-weight: 800; }+.lr-pawn-detail-name {+ min-width: 0;+ max-width: 100%;+ flex: 1 1 160px;+ overflow-wrap: anywhere;+ font-size: 14px;+ font-weight: 800;+}.lr-pawn-detail .lr-meter { flex: 1 1 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); }.lr-pawn-detail-close {display: grid;@@ -1072,10 +1100,16 @@ html[data-theme="dark"] .lr-meter-cell svg { color: #7d92a8; }stroke-dasharray: 6 7;animation: lr-flow 1.1s linear infinite;}-.lr-route-node { transition: opacity 180ms ease; }+.lr-route-node {+ transform-box: fill-box;+ transform-origin: center;+ transition: opacity 180ms ease;+}.lr-route-node.is-recovering { opacity: .58; }+.lr-route-hover,.lr-route-selection,.lr-route-you { fill: none; vector-effect: non-scaling-stroke; }+.lr-route-hover { stroke: color-mix(in srgb, var(--action) 62%, transparent); stroke-width: 2; }.lr-route-selection { stroke: var(--action); stroke-width: 3; }.lr-route-you { stroke: var(--route-p2p); stroke-width: 2.5; stroke-dasharray: 4 3; }.lr-route-sfu { fill: none; stroke: var(--route-sfu); stroke-width: 2.5; }@@ -1093,6 +1127,7 @@ html[data-theme="dark"] .lr-meter-cell svg { color: #7d92a8; }.lr-route-label.is-host { font-weight: 800; opacity: 1; }.lr-route-label.is-sfu { fill: var(--route-sfu); font-weight: 800; opacity: 1; }.lr-route-label.is-recovering { fill: var(--route-pending); opacity: 1; }+.lr-route-label.is-hovered { fill: var(--action-deep); opacity: 1; }.lr-route-label.is-selected { fill: var(--action-deep); font-weight: 800; opacity: 1; }.lr-route-hit {fill: transparent;@@ -1102,9 +1137,10 @@ html[data-theme="dark"] .lr-meter-cell svg { color: #7d92a8; }transition: stroke 140ms ease, fill 140ms ease;}.lr-route-hit:hover,+.lr-route-hit:focus,.lr-route-hit:focus-visible {- fill: color-mix(in srgb, var(--action) 8%, transparent);- stroke: color-mix(in srgb, var(--action) 50%, transparent);+ fill: transparent;+ stroke: transparent;outline: none;}@keyframes lr-flow { to { stroke-dashoffset: -24; } }@@ -1373,7 +1409,14 @@ html[data-theme="dark"] .lr-switch::after { background: var(--ink); }max-width: 180px;}.lr-viewer-state-slot { flex: 1 1 120px; }- .lr-viewer-self-slot { flex: 1 1 auto; gap: 6px; margin-left: 0; }+ .lr-viewer-self-slot { flex: 1 1 auto; gap: 8px; margin-left: 0; }+ .lr-host-personal-controls {+ width: 100%;+ margin-left: 0;+ }+ .lr-host-identity-slot,+ .lr-host-diagnostics-slot,+ .lr-host-share-slot { width: 100%; }.lr-viewer-personal-controls {width: 100%;margin-left: 0;@@ -1389,6 +1432,12 @@ html[data-theme="dark"] .lr-switch::after { background: var(--ink); }.lr-viewer-action-separator { display: none; }.lr-input.lr-name-editor { width: min(136px, 40vw); }.lr-group-actions { display: flex; width: 100%; gap: 8px; min-width: 0; }+ .lr-host-diagnostics-slot,+ .lr-host-share-slot,+ .lr-viewer-actions-slot {+ padding-inline-start: 0;+ border-inline-start: 0;+ }.lr-group-actions .lr-btn { flex: 1 1 0; min-width: 0; min-height: 52px; padding: 4px 5px; gap: 6px; }.lr-group-actions .lr-btn .lr-cap { white-space: normal; text-align: center; line-height: 1.25; font-size: 11px; }.lr-lcd { flex: 1; justify-content: center; }diff --git a/tests/client-state.test.ts b/tests/client-state.test.tsindex 0663a4f3..6cc44122 100644--- a/tests/client-state.test.ts+++ b/tests/client-state.test.ts@@ -71,8 +71,8 @@ describe("browser-local display name", () => {expect(defaultViewerDisplayName("viewer-abcdef", false)).toBe("Viewer");expect(defaultHostDisplayName("host-abcdef", false)).toBe("Host-abcdef");- expect(defaultViewerDisplayName("viewer-abcdef", true)).toBe("👀-abcdef");- expect(defaultHostDisplayName("host-abcdef", true)).toBe("📺-abcdef");+ expect(defaultViewerDisplayName("viewer-abcdef", true)).toBe("👤-abcdef");+ expect(defaultHostDisplayName("host-abcdef", true)).toBe("👑-abcdef");});it("stores only the canonical preference and falls back when cleared", () => {diff --git a/tests/living-components.test.ts b/tests/living-components.test.tsindex c763307f..840d1393 100644--- a/tests/living-components.test.ts+++ b/tests/living-components.test.ts@@ -93,6 +93,47 @@ describe("living-room presentation", () => {expect(html).toContain('aria-label="Viewers 1"');});+ it("shows the Host as a stable couch participant without counting it as a Viewer", () => {+ const hostKey = "host-stable-identity";+ const html = renderToStaticMarkup(+ createElement(Couch, {+ host: { key: hostKey, name: "Host", you: true },+ entries: [],+ }),+ );++ expect(html).toContain("lr-pawn is-host is-static is-you");+ expect(html).toContain(participantColor(hostKey));+ expect(html).toContain("Host · 分享者");+ expect(html).toContain('aria-label="分享者 · 观看者"');+ expect(html).toContain('aria-label="观看者 0"');+ expect(html).not.toContain("lr-couch-empty");+ });++ it("lets the Host pawn own the existing connection-details control", () => {+ const html = renderToStaticMarkup(+ createElement(Couch, {+ host: {+ key: "host-interactive",+ name: "Host",+ selected: true,+ controls: "host-details-panel host-viewer-overview",+ onSelect: () => undefined,+ },+ entries: [+ { key: "viewer-after-host", name: "Viewer", connected: true },+ ],+ }),+ );++ expect(html).toContain("lr-pawn is-host is-selected");+ expect(html).toContain('aria-pressed="true"');+ expect(html).toContain(+ 'aria-controls="host-details-panel host-viewer-overview"',+ );+ expect(html.indexOf("Host")).toBeLessThan(html.indexOf("Viewer"));+ });+it("keeps the current display name visible in visual mode", () => {setCopy({ lang: "en", vis: true });const identity = "viewer-name-tag";@@ -162,6 +203,18 @@ describe("living-room presentation", () => {expect(html).not.toContain("M229 39.5a8.5");});+ it("draws the waiting moon as one open crescent instead of nested circles", () => {+ const html = renderToStaticMarkup(+ createElement(Comic, { kind: "waiting-for-host", theme: "stage" }),+ );++ expect(html).toContain(+ "M0 -8.5A8.5 8.5 0 1 0 0 8.5A6.2 8.5 0 0 1 0 -8.5Z",+ );+ expect(html).not.toContain("M229 39.5a8.5");+ expect(html).not.toContain('fill-rule="evenodd"');+ });+it("keeps every crowded and relay Viewer name visible in visual mode", () => {setCopy({ lang: "en", vis: true });const html = renderToStaticMarkup(diff --git a/tests/route-tree.test.ts b/tests/route-tree.test.tsindex f9ca3f3a..99476db8 100644--- a/tests/route-tree.test.ts+++ b/tests/route-tree.test.ts@@ -4,7 +4,7 @@ import { afterEach, describe, expect, it } from "vitest";import { RouteTree } from "../src/client/components/living/RouteTree.tsx";import { participantColor } from "../src/client/components/living/participant-color.ts";-import { topologyLayoutForViewport } from "../src/client/components/living/route-tree-layout.ts";+import { topologyLayoutForWidth } from "../src/client/components/living/route-tree-layout.ts";import { labelParticipantSnapshot } from "../src/client/lib/viewer-presence.ts";import { setCopy } from "../src/client/ui/copy.ts";@@ -34,8 +34,8 @@ describe("RouteTree", () => {});it("uses real-size narrow coordinates without compressing deep trees", () => {- const narrow = topologyLayoutForViewport(true);- const desktop = topologyLayoutForViewport(false);+ const narrow = topologyLayoutForWidth(260);+ const desktop = topologyLayoutForWidth(640);expect(narrow).toEqual({baseWidth: 260,@@ -54,6 +54,14 @@ describe("RouteTree", () => {expect(desktop.columnGap).toBe(220);});+ it("keeps topology geometry continuous across the former viewport breakpoint", () => {+ const atBreakpoint = topologyLayoutForWidth(640);+ const afterBreakpoint = topologyLayoutForWidth(641);++ expect(afterBreakpoint).toEqual(atBreakpoint);+ expect(topologyLayoutForWidth(390).baseWidth).toBe(390);+ });+it("disambiguates names without exposing complete peer IDs", () => {const { host, viewers } = labelParticipantSnapshot([{@@ -291,6 +299,9 @@ describe("RouteTree", () => {expect(html).toContain('class="lr-route-node is-recovering is-selected"',);+ expect(html).toContain(+ 'class="lr-route-selection" x="1" y="2" width="38" height="46" rx="8"',+ );expect(html).toContain("Recovering");expect(html).toContain("← Host");});