Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(time-timer): meeting pace timer in the conference info bar (#17468)
David Szabo8f37e82d1fb0
diff --git a/config.js b/config.jsindex bc5ecc8600..3ecbe9737a 100644--- a/config.js+++ b/config.js@@ -1586,7 +1586,7 @@ var config = {// If a label's id is not in any of the 2 arrays, it will not be visible at all on the header.// conferenceInfo: {// // those labels will not be hidden in tandem with the toolbox.- // alwaysVisible: ['recording', 'raised-hands-count'],+ // alwaysVisible: ['recording', 'raised-hands-count', 'time-timer'],// // those labels will be auto-hidden in tandem with the toolbox buttons.// autoHide: [// 'subject',@@ -1919,6 +1919,15 @@ var config = {// Application logo url// defaultLogoUrl: 'images/watermark.svg',+ // Meeting-pace timer shown in the conference info bar. It only appears+ // once a meeting duration is known — from a calendar event (calendar+ // sync) or pushed at runtime via the `setMeetingTimer` iframe API+ // command. With no such info nothing is shown, so it is enabled by+ // default; set `enabled: false` to hide it even when that info exists.+ // timeTimer: {+ // enabled: true,+ // },+// Settings for the Excalidraw whiteboard integration.// whiteboard: {// // Whether the feature is enabled or not.diff --git a/css/_time_timer.scss b/css/_time_timer.scssnew file mode 100644index 0000000000..33e27f3402--- /dev/null+++ b/css/_time_timer.scss@@ -0,0 +1,22 @@+/**+ * When the meeting time-timer has reached / passed the scheduled end, draw a+ * red inset frame around the whole conference video area. Implemented via an+ * `::after` pseudo-element so the frame paints on top of LargeVideo / the+ * filmstrip (those children fill #videospace and would otherwise cover any+ * shadow / border drawn on the parent itself). The pseudo-element is+ * non-interactive so it doesn't intercept clicks.+ */+// #videospace already has `position: absolute` so it acts as the+// containing block for our absolutely-positioned ::after.+#videospace.timer-expired::after {+ border: 3px solid #F24D5F;+ box-sizing: border-box;+ content: '';+ height: 100%;+ left: 0;+ pointer-events: none;+ position: absolute;+ top: 0;+ width: 100%;+ z-index: 1000;+}diff --git a/css/main.scss b/css/main.scssindex dbc4365b33..f135b6e7a1 100644--- a/css/main.scss+++ b/css/main.scss@@ -76,5 +76,6 @@ $flagsImagePath: "../images/";@import 'participants-pane';@import 'reactions-menu';@import 'plan-limit';+@import 'time_timer';/* Modules END */diff --git a/lang/main.json b/lang/main.jsonindex 39063f8ae0..60995b0404 100644--- a/lang/main.json+++ b/lang/main.json@@ -1329,6 +1329,10 @@"termsView": {"title": "Terms"},+ "timeTimer": {+ "endedOver": "You are {{time}} over schedule.",+ "endedTitle": "Timer ended"+ },"toggleTopPanelLabel": "Toggle top panel","toolbar": {"Settings": "Settings",diff --git a/modules/API/API.js b/modules/API/API.jsindex 7f1981836f..38528f743c 100755--- a/modules/API/API.js+++ b/modules/API/API.js@@ -129,6 +129,7 @@ import { SETTINGS_TABS } from '../../react/features/settings/constants';import { playSharedVideo, stopSharedVideo } from '../../react/features/shared-video/actions';import { extractYoutubeIdOrURL } from '../../react/features/shared-video/functions';import { setRequestingSubtitles, toggleRequestingSubtitles } from '../../react/features/subtitles/actions';+import { setMeetingTimer } from '../../react/features/time-timer/actions';import { isAudioMuteButtonDisabled } from '../../react/features/toolbox/functions';import { setTileView, toggleTileView } from '../../react/features/video-layout/actions.any';import { muteAllParticipants, muteRemote } from '../../react/features/video-menu/actions';@@ -525,6 +526,10 @@ function initCommands() {sendAnalytics(createApiEvent('screen.sharing.toggled'));toggleScreenSharing(options.enable);},+ 'set-meeting-timer': (options = {}) => {+ sendAnalytics(createApiEvent('meeting.timer.set'));+ APP.store.dispatch(setMeetingTimer(options));+ },'set-noise-suppression-enabled': (options = {}) => {APP.store.dispatch(setNoiseSuppressionEnabled(options.enabled));},diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.jsindex 9ca7bf9733..7e754f1e94 100644--- a/modules/API/external/external_api.js+++ b/modules/API/external/external_api.js@@ -67,6 +67,7 @@ const commands = {setFollowMe: 'set-follow-me',setLargeVideoParticipant: 'set-large-video-participant',setMediaEncryptionKey: 'set-media-encryption-key',+ setMeetingTimer: 'set-meeting-timer',setNoiseSuppressionEnabled: 'set-noise-suppression-enabled',setParticipantVolume: 'set-participant-volume',setSubtitles: 'set-subtitles',diff --git a/react/features/app/middlewares.web.ts b/react/features/app/middlewares.web.tsindex 3d581b8284..d9b40dd299 100644--- a/react/features/app/middlewares.web.ts+++ b/react/features/app/middlewares.web.ts@@ -25,6 +25,7 @@ import '../talk-while-muted/middleware';import '../toolbox/middleware';import '../face-landmarks/middleware';import '../gifs/middleware';+import '../time-timer/middleware.web';import '../whiteboard/middleware.web';import '../file-sharing/middleware.web';import '../custom-panel/middleware.web';diff --git a/react/features/app/reducers.web.ts b/react/features/app/reducers.web.tsindex 4fc2ccd477..20d94e7428 100644--- a/react/features/app/reducers.web.ts+++ b/react/features/app/reducers.web.ts@@ -17,6 +17,7 @@ import '../screen-share/reducer';import '../noise-suppression/reducer';import '../screenshot-capture/reducer';import '../talk-while-muted/reducer';+import '../time-timer/reducer';import '../virtual-background/reducer';import '../web-hid/reducer';import '../file-sharing/reducer';diff --git a/react/features/app/types.ts b/react/features/app/types.tsindex 2a627f7ac9..89d16097f8 100644--- a/react/features/app/types.ts+++ b/react/features/app/types.ts@@ -74,6 +74,7 @@ import { ISharedVideoState } from '../shared-video/reducer';import { ISpeakerStatsState } from '../speaker-stats/reducer';import { ISubtitlesState } from '../subtitles/reducer';import { ITalkWhileMutedState } from '../talk-while-muted/reducer';+import { ITimeTimerState } from '../time-timer/reducer';import { IToolboxState } from '../toolbox/reducer';import { ITranscribingState } from '../transcribing/reducer';import { IVideoLayoutState } from '../video-layout/reducer';@@ -166,6 +167,7 @@ export interface IReduxState {'features/subtitles': ISubtitlesState;'features/talk-while-muted': ITalkWhileMutedState;'features/testing': ITestingState;+ 'features/time-timer': ITimeTimerState;'features/toolbox': IToolboxState;'features/transcribing': ITranscribingState;'features/video-layout': IVideoLayoutState;diff --git a/react/features/base/config/configType.ts b/react/features/base/config/configType.tsindex 46c0d722dd..1396c53151 100644--- a/react/features/base/config/configType.ts+++ b/react/features/base/config/configType.ts@@ -695,6 +695,9 @@ export interface IConfig {disabled?: boolean;numberOfVisibleTiles?: number;};+ timeTimer?: {+ enabled?: boolean;+ };tokenAuthInline?: boolean;tokenAuthUrl?: string;tokenGetUserInfoOutOfContext?: boolean;diff --git a/react/features/base/config/configWhitelist.ts b/react/features/base/config/configWhitelist.tsindex cf6592e9e0..19b4f0a659 100644--- a/react/features/base/config/configWhitelist.ts+++ b/react/features/base/config/configWhitelist.ts@@ -233,6 +233,7 @@ export default ['stereo','subject','testing',+ 'timeTimer','toolbarButtons','toolbarConfig','tileView',diff --git a/react/features/calendar-sync/components/CalendarListContent.web.tsx b/react/features/calendar-sync/components/CalendarListContent.web.tsxindex 73382fe407..5c18644fd9 100644--- a/react/features/calendar-sync/components/CalendarListContent.web.tsx+++ b/react/features/calendar-sync/components/CalendarListContent.web.tsx@@ -6,10 +6,24 @@ import { sendAnalytics } from '../../analytics/functions';import { appNavigate } from '../../app/actions.web';import { IReduxState, IStore } from '../../app/types';import MeetingsList from '../../base/react/components/web/MeetingsList';+import { setCalendarTimerDuration } from '../../time-timer/actions';import AddMeetingUrlButton from './AddMeetingUrlButton.web';import JoinButton from './JoinButton.web';+/**+ * A calendar event, limited to the fields this component reads. Mirrors the+ * shape stored in {@code features/calendar-sync}: the dates are ISO strings.+ */+interface ICalendarEvent {+ calendarId?: string;+ endDate?: string;+ id?: string;+ startDate?: string;+ title?: string;+ url?: string;+}+/*** The type of the React {@code Component} props of* {@link CalendarListContent}.@@ -19,7 +33,7 @@ interface IProps {/*** The calendar event list.*/- _eventList: Array<Object>;+ _eventList: Array<any>;/*** Indicates if the list is disabled or not.@@ -118,6 +132,26 @@ class CalendarListContent extends Component<IProps> {_onPress(url: string, analyticsEventName = 'meeting.tile') {sendAnalytics(createCalendarClickedEvent(analyticsEventName));+ // Find the event being joined and, if it has a parseable start + end,+ // record its duration for the time-timer keyed to this URL. The+ // middleware only applies it when the joined conference matches that+ // URL, so opening a meeting and bailing at prejoin cannot leak its+ // duration into a different meeting joined afterwards.+ const event: ICalendarEvent | undefined = this.props._eventList?.find(e => e.url === url);+ const startUnix = event?.startDate ? Date.parse(event.startDate) : NaN;+ const endUnix = event?.endDate ? Date.parse(event.endDate) : NaN;++ if (!isNaN(startUnix) && !isNaN(endUnix) && endUnix > startUnix) {+ this.props.dispatch(setCalendarTimerDuration(+ Math.round((endUnix - startUnix) / 1000),+ {+ startTimeUnix: startUnix,+ url+ }));+ } else {+ this.props.dispatch(setCalendarTimerDuration(undefined));+ }+this.props.dispatch(appNavigate(url));}diff --git a/react/features/conference/components/constants.ts b/react/features/conference/components/constants.tsindex 770df5ad39..aa1be58fef 100644--- a/react/features/conference/components/constants.ts+++ b/react/features/conference/components/constants.ts@@ -1,5 +1,5 @@export const CONFERENCE_INFO = {- alwaysVisible: [ 'raised-hands-count', 'recording' ],+ alwaysVisible: [ 'raised-hands-count', 'recording', 'time-timer' ],autoHide: ['highlight-moment','subject',diff --git a/react/features/conference/components/web/Conference.tsx b/react/features/conference/components/web/Conference.tsxindex 7fe2683c4f..8f13154cd1 100644--- a/react/features/conference/components/web/Conference.tsx+++ b/react/features/conference/components/web/Conference.tsx@@ -29,6 +29,7 @@ import ParticipantsPane from '../../../participants-pane/components/web/Participimport Prejoin from '../../../prejoin/components/web/Prejoin';import { isPrejoinPageVisible } from '../../../prejoin/functions.web';import ReactionAnimations from '../../../reactions/components/web/ReactionsAnimations';+import { isTimeTimerExpiredUnacknowledged } from '../../../time-timer/functions';import { toggleToolboxVisible } from '../../../toolbox/actions.any';import { fullScreenChanged, showToolbox } from '../../../toolbox/actions.web';import JitsiPortal from '../../../toolbox/components/web/JitsiPortal';@@ -119,6 +120,11 @@ interface IProps extends AbstractProps, WithTranslation {*/_showVisitorsQueue: boolean;+ /**+ * Whether the meeting time-timer has reached / passed the scheduled end.+ */+ _timerExpired: boolean;+dispatch: IStore['dispatch'];}@@ -237,9 +243,12 @@ class Conference extends AbstractConference<IProps, any> {_showLobby,_showPrejoin,_showVisitorsQueue,+ _timerExpired,t} = this.props;+ const videospaceClassName = _timerExpired ? 'timer-expired' : undefined;+if (_reducedUI) {return (<div@@ -256,6 +265,7 @@ class Conference extends AbstractConference<IProps, any> {<ConferenceInfo /><Notice /><div+ className = { videospaceClassName }id = 'videospace'onTouchStart = { this._onVideospaceTouchStart }><LargeVideo />@@ -288,6 +298,7 @@ class Conference extends AbstractConference<IProps, any> {{ _showPrejoin || _showLobby || <ConferenceInfo /> }<Notice /><div+ className = { videospaceClassName }id = 'videospace'onTouchStart = { this._onVideospaceTouchStart }><LargeVideo />@@ -471,7 +482,8 @@ function _mapStateToProps(state: IReduxState) {_roomName: getConferenceNameForTitle(state),_showLobby: getIsLobbyVisible(state),_showPrejoin: isPrejoinPageVisible(state),- _showVisitorsQueue: showVisitorsQueue(state)+ _showVisitorsQueue: showVisitorsQueue(state),+ _timerExpired: isTimeTimerExpiredUnacknowledged(state)};}diff --git a/react/features/conference/components/web/ConferenceInfo.tsx b/react/features/conference/components/web/ConferenceInfo.tsxindex a2092cac5a..cd89587171 100644--- a/react/features/conference/components/web/ConferenceInfo.tsx+++ b/react/features/conference/components/web/ConferenceInfo.tsx@@ -8,6 +8,8 @@ import E2EELabel from '../../../e2ee/components/E2EELabel';import HighlightButton from '../../../recording/components/Recording/web/HighlightButton';import RecordingLabel from '../../../recording/components/web/RecordingLabel';import TranscribingLabel from '../../../recording/components/web/TranscribingLabel';+import TimeTimerPill from '../../../time-timer/components/web/TimeTimerPill';+import { isTimeTimerEnabled } from '../../../time-timer/functions';import { showToolbox } from '../../../toolbox/actions.web';import { isToolboxVisible } from '../../../toolbox/functions.web';import VideoQualityLabel from '../../../video-quality/components/VideoQualityLabel.web';@@ -40,6 +42,17 @@ interface IProps {*/_reducedUI: boolean;+ /**+ * Whether the time-timer is actually showing — i.e. enabled AND a timer+ * is running for the current meeting. Only then does the unified+ * {@code TimeTimerPill} replace the separate subject + conference-timer+ * labels. It must NOT be gated on "enabled" alone: the feature is on by+ * default but renders nothing until a duration is known, so gating on+ * enabled would hide the subject + clock on every default deployment with+ * nothing to replace them.+ */+ _timerActive: boolean;+/*** Indicates whether the component should be visible or not.*/@@ -51,6 +64,13 @@ interface IProps {dispatch: IStore['dispatch'];}+/**+ * IDs of {@code COMPONENTS} that the time-timer pill supersedes. When the+ * time-timer is enabled these are hidden from the info bar because their+ * content is already shown inside {@code TimeTimerPill}.+ */+const TIMER_REPLACED_IDS = new Set([ 'subject', 'conference-timer' ]);+const COMPONENTS: Array<{Component: React.ComponentType<any>;id: string;@@ -67,6 +87,10 @@ const COMPONENTS: Array<{Component: ConferenceTimer,id: 'conference-timer'},+ {+ Component: TimeTimerPill,+ id: 'time-timer'+ },{Component: SpeakerStatsLabel,id: 'participants-count'@@ -147,6 +171,7 @@ class ConferenceInfo extends Component<IProps> {*/_renderAutoHide() {const { autoHide } = this.props._conferenceInfo;+ const { _timerActive } = this.props;if (!autoHide?.length) {return null;@@ -159,6 +184,7 @@ class ConferenceInfo extends Component<IProps> {{COMPONENTS.filter(comp => autoHide.includes(comp.id))+ .filter(comp => !_timerActive || !TIMER_REPLACED_IDS.has(comp.id)).map(c =><c.Component key = { c.id } />)@@ -174,6 +200,7 @@ class ConferenceInfo extends Component<IProps> {*/_renderAlwaysVisible() {const { alwaysVisible } = this.props._conferenceInfo;+ const { _timerActive } = this.props;if (!alwaysVisible?.length) {return null;@@ -186,6 +213,7 @@ class ConferenceInfo extends Component<IProps> {{COMPONENTS.filter(comp => alwaysVisible.includes(comp.id))+ .filter(comp => !_timerActive || !TIMER_REPLACED_IDS.has(comp.id)).map(c =><c.Component key = { c.id } />)@@ -235,7 +263,8 @@ function _mapStateToProps(state: IReduxState) {return {_conferenceInfo: getConferenceInfo(state),_reducedUI: reducedUI,- _visible: isToolboxVisible(state),+ _timerActive: isTimeTimerEnabled(state) && state['features/time-timer'].running,+ _visible: isToolboxVisible(state)};}diff --git a/react/features/time-timer/actionTypes.ts b/react/features/time-timer/actionTypes.tsnew file mode 100644index 0000000000..5830b16c77--- /dev/null+++ b/react/features/time-timer/actionTypes.ts@@ -0,0 +1,79 @@+/**+ * The type of (redux) action which records the duration (and optionally the+ * scheduled start + room URL) of the calendar event the participant is about+ * to join, so the timer can be started from a native calendar source on join.+ *+ * {+ * type: SET_TIME_TIMER_CALENDAR_DURATION,+ * durationSeconds: number|undefined,+ * startTimeUnix: number|undefined,+ * url: string|undefined+ * }+ */+export const SET_TIME_TIMER_CALENDAR_DURATION = 'SET_TIME_TIMER_CALENDAR_DURATION';++/**+ * The type of (redux) action which marks the timer-ended notification as+ * acknowledged (dismissed) by the user.+ *+ * {+ * type: SET_TIME_TIMER_ACKNOWLEDGED+ * }+ */+export const SET_TIME_TIMER_ACKNOWLEDGED = 'SET_TIME_TIMER_ACKNOWLEDGED';++/**+ * The type of (redux) action which records that the meeting has reached or+ * passed its scheduled end.+ *+ * {+ * type: SET_TIME_TIMER_EXPIRED+ * }+ */+export const SET_TIME_TIMER_EXPIRED = 'SET_TIME_TIMER_EXPIRED';++/**+ * The type of (redux) action which records that the one-time warning-window+ * attention-grab (bar expand) has fired, so it does not repeat.+ *+ * {+ * type: SET_TIME_TIMER_WARNING_TRIGGERED+ * }+ */+export const SET_TIME_TIMER_WARNING_TRIGGERED = 'SET_TIME_TIMER_WARNING_TRIGGERED';++/**+ * The type of (redux) action which starts (or restarts) the timer for a+ * meeting of a known duration.+ *+ * {+ * type: START_TIME_TIMER,+ * durationSeconds: number,+ * elapsedSeconds: number,+ * nowUnix: number+ * }+ */+export const START_TIME_TIMER = 'START_TIME_TIMER';++/**+ * The type of (redux) action which stops the timer and clears its derived+ * state (running / expired / acknowledged / counters).+ *+ * {+ * type: STOP_TIME_TIMER+ * }+ */+export const STOP_TIME_TIMER = 'STOP_TIME_TIMER';++/**+ * The type of (redux) action dispatched once per second while the timer runs.+ * It carries a fresh wall-clock reading so the reducer recomputes the+ * remaining / overrun time from the stored scheduled-end timestamp rather than+ * counting ticks (which drift when a background tab throttles the interval).+ *+ * {+ * type: TICK_TIME_TIMER,+ * nowUnix: number+ * }+ */+export const TICK_TIME_TIMER = 'TICK_TIME_TIMER';diff --git a/react/features/time-timer/actions.ts b/react/features/time-timer/actions.tsnew file mode 100644index 0000000000..5487aa305a--- /dev/null+++ b/react/features/time-timer/actions.ts@@ -0,0 +1,135 @@+import { IStore } from '../app/types';++import {+ SET_TIME_TIMER_ACKNOWLEDGED,+ SET_TIME_TIMER_CALENDAR_DURATION,+ SET_TIME_TIMER_EXPIRED,+ SET_TIME_TIMER_WARNING_TRIGGERED,+ START_TIME_TIMER,+ STOP_TIME_TIMER,+ TICK_TIME_TIMER+} from './actionTypes';+import { isTimeTimerEnabled } from './functions';++/**+ * Starts the time-timer.+ *+ * @param {number} durationSeconds - The meeting's scheduled duration. Always+ * supplied by a real source (a calendar event or the iframe API) — the timer+ * is never started without one.+ * @param {number} elapsedSeconds - Seconds elapsed since the scheduled+ * start. MAY exceed durationSeconds (late joiner past the scheduled end) —+ * the reducer pins the scheduled end from this value and derives remaining /+ * overrun / expired from timestamps thereafter.+ * @returns {Object}+ */+export function startTimeTimer(+ durationSeconds: number,+ elapsedSeconds = 0) {+ return {+ type: START_TIME_TIMER,+ durationSeconds,+ elapsedSeconds,+ nowUnix: Date.now()+ };+}++export function stopTimeTimer() {+ return {+ type: STOP_TIME_TIMER+ };+}++/**+ * Advances the timer by recomputing its remaining / overrun counters from the+ * stored scheduled-end timestamp against the current wall-clock time. Carrying+ * `nowUnix` keeps the reducer pure and makes the timer immune to background-tab+ * interval throttling.+ *+ * @returns {Object}+ */+export function tickTimeTimer() {+ return {+ type: TICK_TIME_TIMER,+ nowUnix: Date.now()+ };+}++/**+ * Sets (or clears) the meeting timer at runtime from the iframe API+ * `setMeetingTimer` command. This is the channel embedded/JaaS deployments+ * use — the host app (which owns the meeting schedule) pushes the values in,+ * with no calendar or config involved.+ *+ * A positive `duration` starts/updates the timer; a missing or non-positive+ * duration clears it (so the embedder can turn the timer off for a meeting it+ * has no schedule for). The command is ignored entirely when the feature is+ * disabled (`timeTimer.enabled === false`), so a deployment that opts out is+ * never driven into the running / expired state through this path.+ *+ * @param {Object} options - Timer parameters from the embedder.+ * @param {number} options.duration - Scheduled duration in seconds.+ * @param {number} [options.elapsed] - Seconds since the scheduled start+ * (may exceed duration for a late joiner). Defaults to 0.+ * @returns {Function}+ */+export function setMeetingTimer({ duration, elapsed = 0 }: { duration?: number; elapsed?: number; } = {}) {+ return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {+ if (!isTimeTimerEnabled(getState())) {+ return;+ }++ if (typeof duration === 'number' && duration > 0) {+ dispatch(startTimeTimer(duration, Math.max(0, elapsed)));+ } else {+ dispatch(stopTimeTimer());+ }+ };+}++/**+ * Records the duration (and optionally the scheduled start time + room URL) of+ * the calendar event the participant is about to join, so the time-timer can+ * derive duration + elapsed from a native calendar source — independent of any+ * iframe-API embedder. Mirrors the `configOverwrite.timeTimer` channel: the+ * timer core stays source-agnostic, this is just one more way to feed it.+ *+ * @param {number|undefined} durationSeconds - Scheduled duration in seconds.+ * @param {Object} [options] - Optional context.+ * @param {number} [options.startTimeUnix] - Scheduled start, ms since epoch.+ * When provided, the middleware computes `elapsed = now - start` at join so+ * late joiners land in the correct (possibly overrun) state.+ * @param {string} [options.url] - The room URL this duration belongs to. The+ * middleware only applies the duration when the joined conference matches, so+ * a duration from a meeting the user opened but never joined cannot leak into+ * a different meeting.+ * @returns {Object}+ */+export function setCalendarTimerDuration(+ durationSeconds: number | undefined,+ { startTimeUnix, url }: { startTimeUnix?: number; url?: string; } = {}) {+ return {+ type: SET_TIME_TIMER_CALENDAR_DURATION,+ durationSeconds,+ startTimeUnix,+ url+ };+}++export function setTimeTimerExpired() {+ return {+ type: SET_TIME_TIMER_EXPIRED+ };+}++export function setTimeTimerAcknowledged() {+ return {+ type: SET_TIME_TIMER_ACKNOWLEDGED+ };+}++export function setTimeTimerWarningTriggered() {+ return {+ type: SET_TIME_TIMER_WARNING_TRIGGERED+ };+}diff --git a/react/features/time-timer/components/web/Disk.tsx b/react/features/time-timer/components/web/Disk.tsxnew file mode 100644index 0000000000..d20276f173--- /dev/null+++ b/react/features/time-timer/components/web/Disk.tsx@@ -0,0 +1,180 @@+import React from 'react';+import { makeStyles } from 'tss-react/mui';++import { EXPIRED_DISK_COLOR, EXPIRED_OVERRUN_EDGE_COLOR } from '../../functions';++/**+ * SVG disk renderer used by {@code TimeTimerPill}. Draws a ring with an+ * optional filled wedge. During overrun lap 2+ (once the disk has filled+ * once), an additional CSS conic-gradient overlay conveys the ongoing+ * sweep — a continuous gradient from the base red at the 12 o'clock origin+ * to a darker red at the current leading edge.+ */++const CX = 50;+const CY = 50;+const RADIUS = 46;++/**+ * Converts a polar coordinate (clock angle in degrees, 0 = 12 o'clock) to+ * cartesian coordinates on the disk.+ *+ * @param {number} angleDeg - Angle in degrees, clockwise from the top.+ * @param {number} r - Radius.+ * @returns {{ x: number, y: number }}+ */+function polarToCartesian(angleDeg: number, r: number) {+ const rad = ((angleDeg - 90) * Math.PI) / 180;++ return {+ x: CX + (r * Math.cos(rad)),+ y: CY + (r * Math.sin(rad))+ };+}++/**+ * Builds an SVG path for a filled pie wedge covering the given fraction of+ * the disk, drawn clockwise from the top.+ *+ * @param {number} fraction - Fraction of the disk to fill (0..1).+ * @returns {string}+ */+function wedgePath(fraction: number): string {+ const clamped = Math.max(0, Math.min(1, fraction));++ if (clamped <= 0) {+ return '';+ }+ if (clamped >= 1) {+ const top = polarToCartesian(0, RADIUS);+ const bottom = polarToCartesian(180, RADIUS);++ return [+ `M ${top.x} ${top.y}`,+ `A ${RADIUS} ${RADIUS} 0 0 1 ${bottom.x} ${bottom.y}`,+ `A ${RADIUS} ${RADIUS} 0 0 1 ${top.x} ${top.y}`,+ 'Z'+ ].join(' ');+ }++ const endAngle = clamped * 360;+ const start = polarToCartesian(0, RADIUS);+ const end = polarToCartesian(endAngle, RADIUS);+ const largeArc = endAngle > 180 ? 1 : 0;++ return [+ `M ${CX} ${CY}`,+ `L ${start.x} ${start.y}`,+ `A ${RADIUS} ${RADIUS} 0 ${largeArc} 1 ${end.x} ${end.y}`,+ 'Z'+ ].join(' ');+}++interface IProps {+ color: string;+ fraction: number;++ /**+ * Angular position (degrees, clockwise from the top / 12 o'clock) of+ * the leading edge of the overrun sweep during lap 2 and onward. When+ * provided, the disk renders a conic-gradient overlay from the base+ * red at the origin to a darker red at this angle, over the (fully+ * filled) base disk.+ */+ overrunArcEndDeg?: number;+ size: number;+}++const useStyles = makeStyles<{ size: number; }>()((_theme, { size }) => {+ return {+ root: {+ flex: '0 0 auto',+ height: size,+ position: 'relative',+ width: size+ },++ svg: {+ display: 'block',+ height: size,+ width: size+ },++ // Circular element overlaid exactly on top of the solid SVG disk. Its+ // conic-gradient background is applied inline (see below) rather than+ // here: the leading-edge angle changes every second during overrun, so+ // baking it into a tss-react style would generate a fresh CSS class on+ // every tick. The static positioning stays here.+ overrunOverlay: {+ borderRadius: '50%',+ inset: 0,+ position: 'absolute'+ }+ };+});++/**+ * Builds the lap-2+ overrun sweep — a conic gradient running clockwise from+ * the 12 o'clock origin: base red → darker red at the current leading edge,+ * then back to base red for the remainder (already filled from lap 1).+ *+ * @param {number} deg - Angular position of the leading edge, in degrees.+ * @returns {string}+ */+function overrunGradient(deg: number): string {+ return `conic-gradient(from 0deg, ${EXPIRED_DISK_COLOR} 0deg, `+ + `${EXPIRED_OVERRUN_EDGE_COLOR} ${deg}deg, `+ + `${EXPIRED_DISK_COLOR} ${deg}deg, ${EXPIRED_DISK_COLOR} 360deg)`;+}++/**+ * Renders the time-timer disk as a ring with an optional filled wedge, plus+ * a conic-gradient overrun sweep during lap 2+.+ *+ * @param {IProps} props - Component props.+ * @returns {ReactElement}+ */+const Disk = ({ color, fraction, overrunArcEndDeg, size }: IProps) => {+ const { classes } = useStyles({ size });+ const showOverrun = typeof overrunArcEndDeg === 'number';++ return (+ <div className = { classes.root }>+ <svg+ className = { classes.svg }+ viewBox = '0 0 100 100'>+ {/*+ * Per Figma: a faint 5% white fill behind the wedge so the+ * unfilled portion of the disk reads as a subtle lighter+ * shape against the navy chip background. Drawn FIRST so the+ * wedge paints over it.+ */}+ <circle+ cx = { CX }+ cy = { CY }+ fill = '#FFFFFF'+ fillOpacity = '0.05'+ r = { RADIUS } />+ <circle+ cx = { CX }+ cy = { CY }+ fill = 'none'+ r = { RADIUS }+ stroke = { color }+ strokeWidth = '6' />+ {fraction > 0 && (+ <path+ d = { wedgePath(fraction) }+ fill = { color } />+ )}+ </svg>+ {showOverrun && (+ <div+ className = { classes.overrunOverlay }+ style = {{ background: overrunGradient(overrunArcEndDeg ?? 0) }} />+ )}+ </div>+ );+};++export default Disk;diff --git a/react/features/time-timer/components/web/TimeTimerEndedDescription.tsx b/react/features/time-timer/components/web/TimeTimerEndedDescription.tsxnew file mode 100644index 0000000000..b2b46bb79f--- /dev/null+++ b/react/features/time-timer/components/web/TimeTimerEndedDescription.tsx@@ -0,0 +1,41 @@+import React from 'react';+import { useTranslation } from 'react-i18next';+import { useSelector } from 'react-redux';++import { IReduxState } from '../../../app/types';+import { getLocalizedDurationFormatter } from '../../../base/i18n/dateUtil';+import { EXPIRED_NOTIFICATION_TEXT_COLOR } from '../../functions';++/**+ * Description for the sticky "Timer ended" notification. Subscribes to the+ * timer's overrun counter directly so only this text node re-renders each+ * second — the notification itself is dispatched once at expiry and never+ * touched again. This keeps middleware free of React-element construction and+ * avoids re-pushing the notification through its reducer every tick.+ *+ * @returns {ReactElement}+ */+function TimeTimerEndedDescription() {+ const { t } = useTranslation();+ const overSeconds = useSelector((state: IReduxState) => state['features/time-timer'].overSeconds);++ // The localized string carries a {{time}} placeholder; we split on a+ // unique sentinel so we can colour the time span without inventing a new+ // translation key. The time uses the same formatter as the pill so the+ // two never disagree (e.g. 1:15:03, not 75:03).+ const TIME_PLACEHOLDER = '__TIME__';+ const raw = t('timeTimer.endedOver', { time: TIME_PLACEHOLDER });+ const [ pre, post ] = raw.split(TIME_PLACEHOLDER);++ return (+ <span>+ {pre}+ <span style = {{ color: EXPIRED_NOTIFICATION_TEXT_COLOR }}>+ {getLocalizedDurationFormatter(overSeconds * 1000)}+ </span>+ {post}+ </span>+ );+}++export default TimeTimerEndedDescription;diff --git a/react/features/time-timer/components/web/TimeTimerPill.tsx b/react/features/time-timer/components/web/TimeTimerPill.tsxnew file mode 100644index 0000000000..65b022e602--- /dev/null+++ b/react/features/time-timer/components/web/TimeTimerPill.tsx@@ -0,0 +1,290 @@+import React from 'react';+import { useSelector } from 'react-redux';+import { makeStyles } from 'tss-react/mui';++import { IReduxState } from '../../../app/types';+import { getConferenceName } from '../../../base/conference/functions';+import { getLocalizedDurationFormatter } from '../../../base/i18n/dateUtil';+import { isToolboxVisible } from '../../../toolbox/functions.web';+import {+ EXPIRED_NAME_SEGMENT_BG,+ EXPIRED_PILL_TEXT_COLOR,+ EXPIRED_TIMER_SEGMENT_BG,+ WARNING_COLOR,+ WARNING_NAME_SEGMENT_BG,+ WARNING_TIMER_SEGMENT_BG,+ getTimerVisualState,+ isTimeTimerEnabled+} from '../../functions';++import Disk from './Disk';++// Geometry — matches the Figma spec: 28px tall pill, 20px disk, 6px corner+// radius, two side-by-side segments with their own paddings and backgrounds.+const PILL_HEIGHT = 28;+const DISK_SIZE = 20;+const BORDER_RADIUS = 6;++// Per Figma: left segment uses 12px horizontal padding around the meeting+// name + scheduled duration; right segment uses 4px vertical / 8px horizontal+// padding around the remaining-time digits + disk.+const NAME_SEGMENT_PAD_X = '12px';+const TIMER_SEGMENT_PAD_X = '8px';+const TIMER_SEGMENT_PAD_Y = '4px';+const NAME_GAP = '8px';+const TIMER_GAP = '8px';++// Figma palette — deep navy + lighter navy + bright blue, replacing the+// previous translucent-black backgrounds.+const NAME_SEGMENT_BG = '#1F3057';+const TIMER_SEGMENT_BG = '#1A2542';+const REMAINING_TEXT_COLOR = '#82C3FE';++// When collapsed the pill becomes a 36×28 chip — per Figma, slightly wider+// than tall, with 8px horizontal and 4px vertical padding around the 20px+// disk. The same `4px 8px` padding the right-segment uses while expanded+// keeps the disk's position consistent through the collapse animation.+const COLLAPSED_WIDTH = '36px';+const COLLAPSED_DISK_PAD_X = '8px';+const COLLAPSED_DISK_PAD_Y = '4px';++// Collapse / expand timing — matches the surrounding `.subject` info bar's+// `.6s ease-in-out` fade (see _subject.scss) so the morph stays in sync.+const TIMING = '.6s ease-in-out';+const CONTAINER_TRANSITION = `max-width ${TIMING}`;+const SEGMENT_TRANSITION = `padding ${TIMING}`;+const TEXT_TRANSITION = `opacity ${TIMING}`;++const useStyles = makeStyles()(theme => {+ return {+ // Outer clipping container. A single `max-width` transition shrinks+ // this from the natural pill width down to the chip width; everything+ // inside is right-anchored (`justify-content: flex-end`) so the LEFT+ // side gets clipped off as the box narrows, producing a smooth+ // single-property morph from full pill → disk-only chip. The outer+ // border-radius means the visible portion always has matching rounded+ // corners on whichever side currently shows.+ container: {+ ...theme.typography.labelRegular,+ borderRadius: `${BORDER_RADIUS}px`,+ boxSizing: 'border-box',+ color: theme.palette.text01,+ display: 'flex',+ height: PILL_HEIGHT,+ justifyContent: 'flex-end',+ // Bound the expanded width so the max-width transition has an+ // immediate visual effect. Names longer than 324px are already+ // truncated with ellipsis (see `nameSegment.maxWidth`), so this+ // figure is a safe ceiling for the full pill.+ maxWidth: '450px',+ overflow: 'hidden',+ transition: CONTAINER_TRANSITION,++ '@media (max-width: 300px)': {+ display: 'none'+ }+ },++ containerCollapsed: {+ maxWidth: COLLAPSED_WIDTH+ },++ // Left segment: meeting name + scheduled duration. Lighter navy.+ nameSegment: {+ alignItems: 'center',+ backgroundColor: NAME_SEGMENT_BG,+ display: 'flex',+ flex: '0 0 auto',+ gap: NAME_GAP,+ maxWidth: '324px',+ paddingLeft: NAME_SEGMENT_PAD_X,+ paddingRight: NAME_SEGMENT_PAD_X+ },++ // Text spans fade to opacity 0 in lock-step with the width collapse+ // so the pill's content visually dissolves into the shrinking shape+ // rather than getting hard-clipped at the container's edge.+ name: {+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ transition: TEXT_TRANSITION,+ whiteSpace: 'nowrap'+ },++ scheduled: {+ flex: '0 0 auto',+ fontVariantNumeric: 'tabular-nums',+ transition: TEXT_TRANSITION,+ whiteSpace: 'nowrap'+ },++ // Right segment: elapsed time + disk. Deeper navy. Keeps its+ // natural width while expanded — the outer container's collapsing+ // max-width is what clips everything to the left of the disk away.+ // When collapsed, the left/right paddings shrink so the disk sits+ // symmetrically in a square chip — that subtle right-side pull-in+ // (along with the much larger left-side clip via max-width) makes+ // the morph feel like the shape closes in from both directions+ // rather than just the left.+ timerSegment: {+ alignItems: 'center',+ backgroundColor: TIMER_SEGMENT_BG,+ display: 'flex',+ flex: '0 0 auto',+ gap: TIMER_GAP,+ paddingBottom: TIMER_SEGMENT_PAD_Y,+ paddingLeft: TIMER_SEGMENT_PAD_X,+ paddingRight: TIMER_SEGMENT_PAD_X,+ paddingTop: TIMER_SEGMENT_PAD_Y,+ transition: SEGMENT_TRANSITION+ },++ timerSegmentCollapsed: {+ paddingBottom: COLLAPSED_DISK_PAD_Y,+ paddingLeft: COLLAPSED_DISK_PAD_X,+ paddingRight: COLLAPSED_DISK_PAD_X,+ paddingTop: COLLAPSED_DISK_PAD_Y+ },++ // Remaining-time digits — Inter regular at the same size/spacing as+ // Figma's "Labels/labelBold" spec, just dropped to weight 400 per+ // design feedback. Colour comes from the active state class+ // (`elapsedWarning`, `elapsedExpired`) or falls back to the+ // bright `#82C3FE` baseline.+ elapsed: {+ color: REMAINING_TEXT_COLOR,+ flex: '0 0 auto',+ fontFamily: 'Inter, sans-serif',+ fontSize: '12px',+ fontStyle: 'normal',+ fontVariantNumeric: 'tabular-nums',+ fontWeight: 400,+ letterSpacing: '0.16px',+ lineHeight: '16px',+ transition: TEXT_TRANSITION,+ whiteSpace: 'nowrap'+ },++ // During the final minutes (warning window) the elapsed digits go+ // amber to match the disk colour change.+ elapsedWarning: {+ color: WARNING_COLOR+ },++ // Warning-state segment backgrounds — same lighter-left /+ // deeper-right pattern as the blue baseline, but in warm browns.+ nameSegmentWarning: {+ backgroundColor: WARNING_NAME_SEGMENT_BG+ },++ timerSegmentWarning: {+ backgroundColor: WARNING_TIMER_SEGMENT_BG+ },++ // Expired-state segment backgrounds — warm wine tones with the same+ // lighter-left / deeper-right pattern. More urgent than warning;+ // expired overrides warning when both could apply (though in+ // practice they're mutually exclusive).+ nameSegmentExpired: {+ backgroundColor: EXPIRED_NAME_SEGMENT_BG+ },++ timerSegmentExpired: {+ backgroundColor: EXPIRED_TIMER_SEGMENT_BG+ },++ // Once the timer has expired, the elapsed value shifts to a soft+ // pink to flag that the meeting is now over schedule.+ elapsedExpired: {+ color: EXPIRED_PILL_TEXT_COLOR+ },++ textHidden: {+ opacity: 0+ }+ };+});++/**+ * Time-timer pill rendered in the always-visible conference info row.+ *+ * Shows the meeting name + scheduled duration on the left and the elapsed+ * time + countdown disk on the right. When the toolbox auto-hides, the pill+ * smoothly retracts from left to right via a single `max-width` transition+ * on the outer container — content is anchored to the right edge and clipped+ * by the container's rounded corners as it narrows, leaving a chip-sized+ * dark rectangle around the disk.+ *+ * Living in `alwaysVisible` (rather than `autoHide`) is what lets us keep+ * something rendered while the rest of the bar collapses, so the disk stays+ * visible to the user at all times.+ *+ * Elapsed-time formatting reuses {@code getLocalizedDurationFormatter} — the+ * same util used by Jitsi's {@code ConferenceTimer} — for consistency.+ *+ * @returns {ReactElement | null}+ */+const TimeTimerPill = () => {+ const { classes } = useStyles();+ const timerState = useSelector((state: IReduxState) => state['features/time-timer']);+ const timerEnabled = useSelector(isTimeTimerEnabled);+ const meetingName = useSelector(getConferenceName);+ const toolboxVisible = useSelector(isToolboxVisible);++ if (!timerEnabled || !timerState.running) {+ return null;+ }++ const { elapsedSeconds, fillColor, fraction, overrunArcEndDeg, warning } = getTimerVisualState(timerState);+ const { expired } = timerState;+ const scheduled = getLocalizedDurationFormatter(timerState.durationSeconds * 1000);+ const elapsed = getLocalizedDurationFormatter(elapsedSeconds * 1000);+ const collapsed = !toolboxVisible;++ // Expired wins over warning if both somehow applied — the red colour is+ // more urgent. In practice they're mutually exclusive (warning is gated+ // on `!expired` in getTimerVisualState).+ let nameSegmentStateClass = '';+ let timerSegmentStateClass = '';+ let elapsedStateClass = '';++ if (expired) {+ nameSegmentStateClass = ` ${classes.nameSegmentExpired}`;+ timerSegmentStateClass = ` ${classes.timerSegmentExpired}`;+ elapsedStateClass = ` ${classes.elapsedExpired}`;+ } else if (warning) {+ nameSegmentStateClass = ` ${classes.nameSegmentWarning}`;+ timerSegmentStateClass = ` ${classes.timerSegmentWarning}`;+ elapsedStateClass = ` ${classes.elapsedWarning}`;+ }++ const containerClass+ = `${classes.container}${collapsed ? ` ${classes.containerCollapsed}` : ''}`;+ const nameSegmentClass = `${classes.nameSegment}${nameSegmentStateClass}`;+ const timerSegmentClass = `${classes.timerSegment}`+ + `${collapsed ? ` ${classes.timerSegmentCollapsed}` : ''}`+ + timerSegmentStateClass;+ const hiddenClass = collapsed ? ` ${classes.textHidden}` : '';+ const elapsedClass = `${classes.elapsed}${elapsedStateClass}${hiddenClass}`;++ return (+ <div+ className = { containerClass }+ data-testid = 'time-timer-pill'>+ <div className = { nameSegmentClass }>+ <span className = { `${classes.name}${hiddenClass}` }>{ meetingName }</span>+ <span className = { `${classes.scheduled}${hiddenClass}` }>({ scheduled })</span>+ </div>+ <div className = { timerSegmentClass }>+ <span className = { elapsedClass }>{ elapsed }</span>+ <Disk+ color = { fillColor }+ fraction = { fraction }+ overrunArcEndDeg = { overrunArcEndDeg }+ size = { DISK_SIZE } />+ </div>+ </div>+ );+};++export default TimeTimerPill;diff --git a/react/features/time-timer/constants.ts b/react/features/time-timer/constants.tsnew file mode 100644index 0000000000..183558e4a4--- /dev/null+++ b/react/features/time-timer/constants.ts@@ -0,0 +1,8 @@+export const TIME_TIMER_NOTIFICATION_ID = 'time-timer-ended';++/**+ * Threshold (seconds remaining) at which the timer enters its "warning"+ * state: the disk + elapsed digits flip to amber and the pill briefly+ * expands to draw the user's attention to the final stretch.+ */+export const WARNING_THRESHOLD_SECONDS = 300; // 5 minutesdiff --git a/react/features/time-timer/functions.ts b/react/features/time-timer/functions.tsnew file mode 100644index 0000000000..ae9718759f--- /dev/null+++ b/react/features/time-timer/functions.ts@@ -0,0 +1,207 @@+import { IReduxState } from '../app/types';++import { WARNING_THRESHOLD_SECONDS } from './constants';+import { ITimeTimerState } from './reducer';++/**+ * Minimum visible fraction of the disk drawn in red right after the timer+ * expires. Without this floor, the wedge would start at ~0 and be invisible+ * for the first several minutes of overrun; a small floor keeps the red+ * slice visible from the moment the timer ends. Real overrun catches up+ * once `overSeconds / durationSeconds` exceeds this floor.+ */+const EXPIRED_WEDGE_FLOOR = 0.02;++/**+ * Soft pink/rose used for the elapsed-time digits in the pill once the+ * meeting is over schedule. Reads well on the pill's dark background.+ */+export const EXPIRED_PILL_TEXT_COLOR = '#FF9DA0';++/**+ * Amber used for the disk fill and the remaining-time digits during the+ * final {@code WARNING_THRESHOLD_SECONDS} of the meeting. Matches the+ * Figma amber-state spec.+ */+export const WARNING_COLOR = '#F8AE1A';++/**+ * Background colours for the amber/warning state — mirror the blue baseline+ * pattern (right segment is the deeper one).+ */+export const WARNING_NAME_SEGMENT_BG = '#3C2E1D';+export const WARNING_TIMER_SEGMENT_BG = '#302417';++/**+ * Background colours for the red/expired state — same lighter-left /+ * deeper-right pattern as the other states, in warm wine tones.+ */+export const EXPIRED_NAME_SEGMENT_BG = '#4F2627';+export const EXPIRED_TIMER_SEGMENT_BG = '#3E1D1E';++/**+ * Coral-red used for the disk fill once the meeting is over schedule —+ * matches Figma's expired-state spec. Stronger / warmer than the previous+ * `theme.palette.iconError`.+ */+export const EXPIRED_DISK_COLOR = '#F24D5F';++/**+ * Deep wine red the overrun lap-2+ sweep darkens toward at its leading+ * edge. Once the disk is fully filled (lap 1 complete), each subsequent+ * lap is drawn as a continuous conic gradient running from+ * {@code EXPIRED_DISK_COLOR} at the 12 o'clock origin to this darker tone+ * at the current leading edge — conveying ongoing motion without leaving+ * the red family. See {@code TimeTimerPill} / {@code Disk}.+ */+export const EXPIRED_OVERRUN_EDGE_COLOR = '#8E2530';++/**+ * Bright 8x8 blue used for the disk in the normal/running state — matches+ * the Figma spec for the time-timer pill baseline.+ */+export const DISK_BLUE = '#1084FE';++/**+ * Disk-red used for the overrun-time text in the "Timer ended" notification.+ * Matches the colour of the disk's expired wedge — same hex as+ * `theme.palette.iconError` resolves to in the current Jitsi theme — and+ * reads with stronger contrast on the notification's white background.+ */+export const EXPIRED_NOTIFICATION_TEXT_COLOR = '#D83848';++export interface ITimerVisualState {++ /**+ * Time elapsed since the calendar event's scheduled start, in seconds.+ * Derived so that every participant sees the same value regardless of+ * when they joined.+ */+ elapsedSeconds: number;++ /**+ * Fill colour for the disk (white during the meeting, amber during the+ * final {@code WARNING_THRESHOLD_SECONDS}, red once over schedule).+ */+ fillColor: string;++ /**+ * Fraction of the disk to fill (0..1).+ */+ fraction: number;++ /**+ * Angular position (degrees, clockwise from the top / 12 o'clock) of+ * the leading edge of the overrun sweep during lap 2 and onward — once+ * the disk has filled once, subsequent overrun laps draw a continuous+ * conic gradient (base red → darker red at this angle) over the solid+ * disk to make the ongoing motion visible. `undefined` during normal+ * running, warning and the first overrun lap (which still uses the+ * standard growing wedge).+ */+ overrunArcEndDeg?: number;++ /**+ * True during the warning window — the final+ * {@code WARNING_THRESHOLD_SECONDS} before scheduled end. Drives the+ * amber colour treatment in the pill (disk + elapsed digits).+ */+ warning: boolean;+}++/**+ * Derives the visual state of the time-timer disk (color + fill fraction ++ * elapsed seconds) from the timer reducer state. Consumed by+ * {@code TimeTimerPill}.+ *+ * @param {ITimeTimerState} state - The current time-timer reducer state.+ * @returns {ITimerVisualState}+ */+export function getTimerVisualState(state: ITimeTimerState): ITimerVisualState {+ const { durationSeconds, remainingSeconds, overSeconds, expired } = state;++ // Time elapsed since the calendar event's scheduled start. Before the+ // scheduled end this is `duration - remaining` (which already accounts+ // for late joiners via `defaultRemaining`). After the scheduled end the+ // timer keeps ticking via `overSeconds`, so total elapsed =+ // duration + overrun.+ const elapsedSeconds = Math.max(+ 0,+ (durationSeconds - remainingSeconds) + overSeconds+ );++ // Warning state: within the last `WARNING_THRESHOLD_SECONDS` of the+ // scheduled duration but not yet expired. Used both for the amber+ // colouring and (in middleware) to trigger the one-time bar-expand.+ const warning = !expired && remainingSeconds > 0 && remainingSeconds <= WARNING_THRESHOLD_SECONDS;++ let fillColor = DISK_BLUE; // Bright blue during normal running state.+ let fraction = durationSeconds > 0+ ? (durationSeconds - remainingSeconds) / durationSeconds+ : 0;++ if (warning) {+ fillColor = WARNING_COLOR;+ }++ let overrunArcEndDeg: number | undefined;++ if (expired) {+ fillColor = EXPIRED_DISK_COLOR;++ if (durationSeconds > 0) {+ // Treat overrun as a series of laps, each one+ // `durationSeconds` long — the disk fills exactly once over+ // the first lap (matching the original scheduled duration),+ // then stays solid red while a glowing arc sweeps subsequent+ // laps to convey ongoing motion.+ const lapIndex = Math.floor(overSeconds / durationSeconds);+ const lapFraction = (overSeconds % durationSeconds) / durationSeconds;++ if (lapIndex === 0) {+ // Lap 1: standard growing wedge, with a small visible+ // floor right at expiry so the red slice is never invisible.+ fraction = Math.max(EXPIRED_WEDGE_FLOOR, lapFraction);+ } else {+ // Lap 2+: disk fully filled. The leading edge of the+ // current lap is rendered separately as a glowing+ // comet-tail arc (see Disk component).+ fraction = 1;+ overrunArcEndDeg = lapFraction * 360;+ }+ } else {+ fraction = EXPIRED_WEDGE_FLOOR;+ }+ }++ return { elapsedSeconds, fillColor, fraction, overrunArcEndDeg, warning };+}++/**+ * Whether the time-timer is enabled. It is enabled by default — only an+ * explicit {@code timeTimer.enabled === false} turns it off. The timer+ * renders nothing until a duration is known, so being on by default is+ * harmless and lets calendar / iframe-API deployments see it with no extra+ * config. This is the single source of truth for the enabled rule; use it+ * everywhere (middleware, components) rather than reading the config inline.+ *+ * @param {IReduxState} state - The redux state.+ * @returns {boolean}+ */+export function isTimeTimerEnabled(state: IReduxState): boolean {+ return state['features/base/config']?.timeTimer?.enabled !== false;+}++/**+ * Whether the meeting has run past its scheduled end and the user has not yet+ * dismissed the timer-ended notification. Drives the red border around the+ * conference grid.+ *+ * @param {IReduxState} state - The redux state.+ * @returns {boolean}+ */+export function isTimeTimerExpiredUnacknowledged(state: IReduxState): boolean {+ const { acknowledged, expired } = state['features/time-timer'];++ return expired && !acknowledged;+}diff --git a/react/features/time-timer/logger.ts b/react/features/time-timer/logger.tsnew file mode 100644index 0000000000..425a99bfa0--- /dev/null+++ b/react/features/time-timer/logger.ts@@ -0,0 +1,3 @@+import { getLogger } from '../base/logging/functions';++export default getLogger('features/time-timer');diff --git a/react/features/time-timer/middleware.web.ts b/react/features/time-timer/middleware.web.tsnew file mode 100644index 0000000000..3a09bab5fa--- /dev/null+++ b/react/features/time-timer/middleware.web.ts@@ -0,0 +1,209 @@+import React from 'react';++import { IStore } from '../app/types';+import { CONFERENCE_JOINED, CONFERENCE_LEFT } from '../base/conference/actionTypes';+import { getRoomName } from '../base/conference/functions';+import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';+import { parseURIString } from '../base/util/uri';+import { HIDE_NOTIFICATION } from '../notifications/actionTypes';+import { showNotification } from '../notifications/actions';+import { NOTIFICATION_ICON, NOTIFICATION_TIMEOUT_TYPE, NOTIFICATION_TYPE } from '../notifications/constants';+import { showToolbox } from '../toolbox/actions.web';++import { START_TIME_TIMER, STOP_TIME_TIMER, TICK_TIME_TIMER } from './actionTypes';+import {+ setTimeTimerAcknowledged,+ setTimeTimerExpired,+ setTimeTimerWarningTriggered,+ startTimeTimer,+ stopTimeTimer,+ tickTimeTimer+} from './actions';+import TimeTimerEndedDescription from './components/web/TimeTimerEndedDescription';+import {+ TIME_TIMER_NOTIFICATION_ID,+ WARNING_THRESHOLD_SECONDS+} from './constants';+import { isTimeTimerEnabled } from './functions';+import logger from './logger';++let _tickInterval: ReturnType<typeof setInterval> | undefined;++// True once the sticky "ended" notification has been posted for the current+// timer, so it is posted exactly once whether the meeting crosses the end+// live or starts already past it (e.g. a late joiner / an embedder pushing an+// already-overrun timer). Reset whenever a timer starts or stops.+let _notifiedExpiry = false;++/**+ * Clears the per-second tick interval if one is running.+ *+ * @returns {void}+ */+function _clearTick() {+ if (_tickInterval !== undefined) {+ clearInterval(_tickInterval);+ _tickInterval = undefined;+ }+}++/**+ * Posts the sticky "Timer ended" notification once per timer. Its description+ * is a connected component that subscribes to `overSeconds`, so the live+ * counter ticks via that component's own re-renders — the notification itself+ * is never re-dispatched.+ *+ * @param {Function} dispatch - The redux dispatch.+ * @returns {void}+ */+function _notifyExpiredOnce(dispatch: IStore['dispatch']) {+ if (_notifiedExpiry) {+ return;+ }+ _notifiedExpiry = true;++ dispatch(showNotification({+ appearance: NOTIFICATION_TYPE.NORMAL,+ description: React.createElement(TimeTimerEndedDescription),+ icon: NOTIFICATION_ICON.ERROR,+ titleKey: 'timeTimer.endedTitle',+ uid: TIME_TIMER_NOTIFICATION_ID+ }, NOTIFICATION_TIMEOUT_TYPE.STICKY));+}++MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: any) => {+ const result = next(action);+ const { dispatch, getState } = store;++ switch (action.type) {+ case CONFERENCE_JOINED: {+ // Enabled by default (see isTimeTimerEnabled). A deployment opts out+ // with `timeTimer: { enabled: false }` to hide it even when a+ // duration is available (e.g. calendar users who don't want it).+ if (isTimeTimerEnabled(getState())) {+ const { calendarDurationSeconds, calendarStartTimeUnix, calendarUrl }+ = getState()['features/time-timer'];++ // A real meeting duration must come from a source: a native+ // calendar event, or the `setMeetingTimer` iframe API command at+ // runtime. With nothing here we DON'T start the timer — there is+ // no meaningful countdown to show for a meeting we have no+ // schedule for. The iframe-API path drives the timer later, on+ // its own, independent of this join-time check.+ //+ // The calendar duration is only honoured when it was recorded for+ // the room actually being joined — otherwise a duration left over+ // from a meeting the user opened but bailed on at prejoin would+ // leak into a different meeting. Compare by room name (robust to+ // differing URL forms) rather than raw URL equality, and+ // case-insensitively since room names are normalised to lowercase+ // while a calendar URL may preserve the original casing.+ const calendarRoom = calendarUrl ? parseURIString(calendarUrl)?.room?.toLowerCase() : undefined;+ const joinedRoom = getRoomName(getState())?.toLowerCase();+ const calendarMatchesRoom = !calendarRoom || calendarRoom === joinedRoom;++ if (calendarMatchesRoom+ && typeof calendarDurationSeconds === 'number' && calendarDurationSeconds > 0) {+ // Elapsed-since-scheduled-start is the single source of truth+ // and may exceed the duration (joined after the scheduled+ // end). Compute it live from the calendar start time so late+ // joiners land directly in the correct (possibly overrun)+ // state; otherwise start from 0.+ const elapsed = typeof calendarStartTimeUnix === 'number'+ ? Math.max(0, Math.round((Date.now() - calendarStartTimeUnix) / 1000))+ : 0;++ dispatch(startTimeTimer(calendarDurationSeconds, elapsed));+ }+ }+ break;+ }+ case CONFERENCE_LEFT: {+ // Stop the interval and fully reset the timer so the next meeting+ // never inherits a frozen / expired pill or a lingering red border.+ // `stopTimeTimer` resets the running state; the calendar inputs are+ // cleared separately on the next selection.+ _clearTick();+ dispatch(stopTimeTimer());+ break;+ }+ case START_TIME_TIMER: {+ logger.info(`Timer started: duration=${action.durationSeconds}s elapsed=${action.elapsedSeconds}s`);+ _clearTick();+ _notifiedExpiry = false;+ _tickInterval = setInterval(() => {+ dispatch(tickTimeTimer());+ }, 1000);++ // The reducer derives `expired` synchronously from the start values, so+ // a timer that begins already past its end (late joiner / an embedder+ // pushing an overrun timer) is expired from tick zero and would never+ // hit the live "crossing" branch below. Post the notification here in+ // that case; _notifyExpiredOnce keeps it to a single notification.+ if (getState()['features/time-timer'].expired) {+ _notifyExpiredOnce(dispatch);+ }+ break;+ }+ case STOP_TIME_TIMER: {+ _clearTick();+ _notifiedExpiry = false;++ // The timer (and thus its sticky "ended" notification) is gone — clear+ // the notification so it does not outlive the timer that produced it.+ dispatch({+ type: HIDE_NOTIFICATION,+ uid: TIME_TIMER_NOTIFICATION_ID+ });+ break;+ }+ case TICK_TIME_TIMER: {+ const { expired, remainingSeconds, running, warningTriggered }+ = getState()['features/time-timer'];++ if (!running) {+ break;+ }++ // Warning crossing — fire the one-time attention-grab the moment we+ // enter the final `WARNING_THRESHOLD_SECONDS`. Using `<=` (rather than+ // an exact match) keeps it robust to a throttled background tab that+ // snaps several seconds forward in a single tick. `warningTriggered`+ // is one-shot and is also pre-set at start when joining mid-warning,+ // so the animation is suppressed in that case.+ if (!warningTriggered && !expired && remainingSeconds <= WARNING_THRESHOLD_SECONDS) {+ dispatch(setTimeTimerWarningTriggered());+ dispatch(showToolbox());+ }++ // First moment we cross the scheduled end live: flag expired and give+ // the bar the same one-time attention-grab expand we use at the+ // warning threshold. The `!expired` guard runs this only on the+ // transition tick.+ if (remainingSeconds <= 0 && !expired) {+ dispatch(setTimeTimerExpired());+ dispatch(showToolbox());+ }++ // Post the sticky "ended" notification while expired. _notifyExpiredOnce+ // makes it fire exactly once per timer — covering both the live+ // crossing above and the already-expired-at-start case handled in+ // START_TIME_TIMER.+ if (remainingSeconds <= 0) {+ _notifyExpiredOnce(dispatch);+ }+ break;+ }+ case HIDE_NOTIFICATION: {+ // The user (or anything else) closed our timer-ended notification —+ // treat that as acknowledgment, which clears the red border around+ // the conference grid (Conference.tsx reads expired && !acknowledged).+ if (action.uid === TIME_TIMER_NOTIFICATION_ID) {+ dispatch(setTimeTimerAcknowledged());+ }+ break;+ }+ }++ return result;+});diff --git a/react/features/time-timer/reducer.ts b/react/features/time-timer/reducer.tsnew file mode 100644index 0000000000..6d2e71c559--- /dev/null+++ b/react/features/time-timer/reducer.ts@@ -0,0 +1,161 @@+import ReducerRegistry from '../base/redux/ReducerRegistry';++import {+ SET_TIME_TIMER_ACKNOWLEDGED,+ SET_TIME_TIMER_CALENDAR_DURATION,+ SET_TIME_TIMER_EXPIRED,+ SET_TIME_TIMER_WARNING_TRIGGERED,+ START_TIME_TIMER,+ STOP_TIME_TIMER,+ TICK_TIME_TIMER+} from './actionTypes';+import { WARNING_THRESHOLD_SECONDS } from './constants';++export interface ITimeTimerState {+ acknowledged: boolean;+ calendarDurationSeconds?: number;++ /**+ * Scheduled start of the calendar event (ms since epoch) the participant+ * is joining, when supplied by a native calendar source. Lets the+ * middleware compute elapsed-since-start at join time.+ */+ calendarStartTimeUnix?: number;++ /**+ * Room URL the calendar duration was recorded for. The middleware only+ * uses the duration when the joined conference matches this URL, so a+ * duration left over from a meeting the user opened but never joined does+ * not leak into a different meeting.+ */+ calendarUrl?: string;+ durationSeconds: number;+ expired: boolean;+ overSeconds: number;+ remainingSeconds: number;+ running: boolean;++ /**+ * Wall-clock time (ms since epoch) of the meeting's scheduled end. This is+ * the single source of truth while the timer runs: `remainingSeconds` and+ * `overSeconds` are recomputed from it against `Date.now()` on every tick,+ * so a throttled background tab can never accumulate drift.+ */+ scheduledEndUnix?: number;+ warningTriggered: boolean;+}++const DEFAULT_STATE: ITimeTimerState = {+ acknowledged: false,+ durationSeconds: 0,+ expired: false,+ overSeconds: 0,+ remainingSeconds: 0,+ running: false,+ warningTriggered: false+};++/**+ * Derives the running counters (remaining / over / expired) from the+ * scheduled-end timestamp and a wall-clock reading. Keeping this in one place+ * means START and TICK stay consistent.+ *+ * @param {number} durationSeconds - The meeting's scheduled duration.+ * @param {number} scheduledEndUnix - Scheduled end, ms since epoch.+ * @param {number} nowUnix - Current wall-clock time, ms since epoch.+ * @returns {{ expired: boolean, overSeconds: number, remainingSeconds: number }}+ */+function _deriveCounters(durationSeconds: number, scheduledEndUnix: number, nowUnix: number) {+ const remainingSeconds = Math.max(0, Math.round((scheduledEndUnix - nowUnix) / 1000));+ const overSeconds = Math.max(0, Math.round((nowUnix - scheduledEndUnix) / 1000));++ return {+ expired: remainingSeconds <= 0,+ overSeconds,+ remainingSeconds: Math.min(remainingSeconds, durationSeconds)+ };+}++ReducerRegistry.register<ITimeTimerState>('features/time-timer', (state = DEFAULT_STATE, action) => {+ switch (action.type) {+ case SET_TIME_TIMER_CALENDAR_DURATION:+ return {+ ...state,+ calendarDurationSeconds: action.durationSeconds,+ calendarStartTimeUnix: action.startTimeUnix,+ calendarUrl: action.url+ };+ case START_TIME_TIMER: {+ const { durationSeconds, nowUnix } = action;++ // `elapsedSeconds` is seconds since the scheduled start and may exceed+ // the duration (joining after the scheduled end). From it and the+ // current wall-clock time we pin the scheduled end as an absolute+ // timestamp; everything else is derived from that timestamp, both here+ // and on every subsequent tick. This is what lets a late joiner land+ // directly in the correct overrun / lap state.+ const elapsedSeconds = Math.max(0, action.elapsedSeconds);+ const scheduledEndUnix = nowUnix + ((durationSeconds - elapsedSeconds) * 1000);+ const counters = _deriveCounters(durationSeconds, scheduledEndUnix, nowUnix);++ return {+ ...state,+ acknowledged: false,+ durationSeconds,+ ...counters,+ running: true,+ scheduledEndUnix,++ // Suppress the one-time attention-grab expand if we joined already+ // inside the warning window or past the end — the disk just shows+ // the correct colour from the start. `warningTriggered` only gates+ // the animation, not the colour.+ warningTriggered: counters.remainingSeconds <= WARNING_THRESHOLD_SECONDS+ };+ }+ case STOP_TIME_TIMER:+ // Full reset of the derived/running state so a stopped or cleared+ // timer leaves nothing behind — no frozen pill, no lingering red+ // border on the next meeting. Calendar inputs are managed separately+ // by SET_TIME_TIMER_CALENDAR_DURATION and intentionally not touched+ // here.+ return {+ ...state,+ acknowledged: false,+ durationSeconds: 0,+ expired: false,+ overSeconds: 0,+ remainingSeconds: 0,+ running: false,+ scheduledEndUnix: undefined,+ warningTriggered: false+ };+ case SET_TIME_TIMER_EXPIRED:+ return {+ ...state,+ expired: true+ };+ case SET_TIME_TIMER_ACKNOWLEDGED:+ return {+ ...state,+ acknowledged: true+ };+ case SET_TIME_TIMER_WARNING_TRIGGERED:+ return {+ ...state,+ warningTriggered: true+ };+ case TICK_TIME_TIMER: {+ if (!state.running || typeof state.scheduledEndUnix !== 'number') {+ return state;+ }++ return {+ ...state,+ ..._deriveCounters(state.durationSeconds, state.scheduledEndUnix, action.nowUnix)+ };+ }+ }++ return state;+});diff --git a/tests/specs/iframe/setMeetingTimer.spec.ts b/tests/specs/iframe/setMeetingTimer.spec.tsnew file mode 100644index 0000000000..219f04f1fd--- /dev/null+++ b/tests/specs/iframe/setMeetingTimer.spec.ts@@ -0,0 +1,115 @@+import { expect } from '@wdio/globals';++import { setTestProperties } from '../../helpers/TestProperties';+import { ensureOneParticipant } from '../../helpers/participants';++import { checkIframeApi } from './util';++setTestProperties(__filename, {+ usesBrowsers: [ 'p1' ]+});++const PILL_SELECTOR = '[data-testid="time-timer-pill"]';+const ENDED_NOTIFICATION_SELECTOR = '[data-testid="timeTimer.endedTitle"]';+const EXPIRED_BORDER_SELECTOR = '#videospace.timer-expired';++describe('setMeetingTimer iframe API command', () => {+ it('does not show the timer until a duration is pushed', async () => {+ await ensureOneParticipant({}, { name: 'p1', iFrameApi: true });++ const { p1 } = ctx;++ if (!await checkIframeApi(p1)) {+ return;+ }++ // Inside the iframe — the timer is enabled by default but has no+ // duration yet, so the pill must not render. The default meeting+ // subject / conference-timer chrome remains in its place.+ await p1.switchToIFrame();+ await expect(await p1.driver.$(PILL_SELECTOR)).not.toBeDisplayed();+ });++ it('shows the timer pill when a duration is pushed via the iframe API', async () => {+ const { p1 } = ctx;++ await p1.switchToMainFrame();+ await p1.getIframeAPI().executeCommand('setMeetingTimer', {+ duration: 1800, // 30 min+ elapsed: 0+ });++ await p1.switchToIFrame();+ await expect(await p1.driver.$(PILL_SELECTOR)).toBeDisplayed();+ });++ it('flips to the expired state when an over-schedule timer is pushed', async () => {+ const { p1 } = ctx;++ await p1.switchToMainFrame();+ await p1.getIframeAPI().executeCommand('setMeetingTimer', {+ duration: 1800, // 30 min+ elapsed: 2520 // already 12 minutes past the scheduled end+ });++ await p1.switchToIFrame();++ // Pill stays visible …+ await expect(await p1.driver.$(PILL_SELECTOR)).toBeDisplayed();++ // … the videospace gets the red expired-border class …+ await p1.driver.waitUntil(+ async () => await p1.driver.$(EXPIRED_BORDER_SELECTOR).isExisting(),+ { timeout: 3000, timeoutMsg: 'expired border did not appear' });++ // … and the sticky "Timer ended" notification appears.+ await p1.driver.waitUntil(+ async () => await p1.driver.$(ENDED_NOTIFICATION_SELECTOR).isExisting(),+ { timeout: 3000, timeoutMsg: 'timer-ended notification did not appear' });+ });++ it('clears the pill, border and notification when the timer is cleared', async () => {+ const { p1 } = ctx;++ await p1.switchToMainFrame();+ // No duration => clear.+ await p1.getIframeAPI().executeCommand('setMeetingTimer', {});++ await p1.switchToIFrame();++ await p1.driver.waitUntil(+ async () => !await p1.driver.$(PILL_SELECTOR).isDisplayed(),+ { timeout: 3000, timeoutMsg: 'pill did not disappear on clear' });+ await p1.driver.waitUntil(+ async () => !await p1.driver.$(EXPIRED_BORDER_SELECTOR).isExisting(),+ { timeout: 3000, timeoutMsg: 'expired border did not clear' });+ await p1.driver.waitUntil(+ async () => !await p1.driver.$(ENDED_NOTIFICATION_SELECTOR).isExisting(),+ { timeout: 3000, timeoutMsg: 'timer-ended notification did not clear' });+ });++ it('ignores the command when the feature is disabled', async () => {+ // Hangup and rejoin the same conference with `timeTimer.enabled = false`+ // so we can prove the command is a no-op on opt-out deployments.+ await ctx.p1.hangup();+ await ensureOneParticipant({+ configOverwrite: {+ timeTimer: { enabled: false }+ }+ }, { name: 'p1', iFrameApi: true });++ const { p1 } = ctx;++ await p1.switchToMainFrame();+ await p1.getIframeAPI().executeCommand('setMeetingTimer', {+ duration: 1800,+ elapsed: 0+ });++ await p1.switchToIFrame();++ // Give the dispatch a moment, then assert the pill never appeared.+ await p1.driver.pause(1000);+ await expect(await p1.driver.$(PILL_SELECTOR)).not.toBeDisplayed();+ });+});