Files
Psychotoxical-psysonic/src/components/OrbitQueueHead.tsx
T
Psychotoxical e4cc54a1b5 revert(orbit): drop maxPending cap feature, keep suggestion mute
The pending counter desynced from the actual approval list (state.queue
holds approved items as history, so the count never decreased after a
host approve). The host-pushed pendingApprovalCount workaround didn't
hold up under live testing either, so we're rolling the whole cap
feature back rather than ship something flaky.

What's gone:
- OrbitSettings.maxPending + state.pendingApprovalCount
- cap branch in applyOutboxSnapshotsToState (now back to mute-only)
- maxPending number input in settings popover
- pending counter chip in OrbitQueueHead
- 'cap-reached' branch in evaluateOrbitSuggestGate / OrbitSuggestGateReason
- cap-related toasts in ContextMenu / useOrbitSongRowBehavior
- cap-related i18n keys (suggestBlockedCap, settingMaxPending*, pendingCounter*)
- cap CSS (.orbit-queue-head__pending, .orbit-settings-pop__number)

What stays: per-guest suggestion mute (works correctly) and everything
that fed into both features (OrbitState.suggestionBlocked,
setOrbitSuggestionBlocked, evaluateOrbitSuggestGate, the participants
popover Mic/MicOff toggle, the suggestBlockedMuted toast).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 01:40:22 +02:00

61 lines
2.2 KiB
TypeScript

import { useEffect, useState } from 'react';
import { Users, Wifi, WifiOff } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { useOrbitStore } from '../store/orbitStore';
import type { OrbitState } from '../api/orbit';
interface Props {
state: OrbitState;
}
/** Host's state hasn't updated for this long → guest treats them as offline. */
const HOST_AWAY_THRESHOLD_MS = 15_000;
/**
* Shared Orbit head strip rendered at the top of the queue for both host
* and guest. Shows the session name and a comma-separated list of every
* participant (host first, then guests in join order).
*
* Guest view additionally surfaces host-presence: when the host's tick
* hasn't been seen for 15 s we render a subtle "host offline" badge so
* the guest knows the stalled playback isn't a local problem.
*/
export default function OrbitQueueHead({ state }: Props) {
const { t } = useTranslation();
const role = useOrbitStore(s => s.role);
const [nowMs, setNowMs] = useState(() => Date.now());
// Guest-only clock tick — React wouldn't re-render a stale state blob
// on its own, and the presence threshold is time-based.
useEffect(() => {
if (role !== 'guest') return;
const id = window.setInterval(() => setNowMs(Date.now()), 2000);
return () => window.clearInterval(id);
}, [role]);
const names = [state.host, ...state.participants.map(p => p.user)];
const showPresence = role === 'guest' && state.positionAt > 0;
const hostAway = showPresence && (nowMs - state.positionAt) > HOST_AWAY_THRESHOLD_MS;
return (
<div className="orbit-queue-head">
<div className="orbit-queue-head__title-row">
<h2 className="orbit-queue-head__title">{state.name}</h2>
{showPresence && (
<span
className={`orbit-queue-head__presence orbit-queue-head__presence--${hostAway ? 'away' : 'online'}`}
role="status"
>
{hostAway ? <WifiOff size={11} /> : <Wifi size={11} />}
<span>{t(hostAway ? 'orbit.hostAway' : 'orbit.hostOnline')}</span>
</span>
)}
</div>
<div className="orbit-queue-head__meta">
<Users size={11} />
<span className="orbit-queue-head__names">{names.join(', ')}</span>
</div>
</div>
);
}