diff --git a/resources/lang/en.json b/resources/lang/en.json index 13d52455d0..4e842aa012 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -3076,6 +3076,10 @@ "none": "You don't have an active subscription.", "title": "Your Subscription" }, + "tab_attention": { + "pick_spawn": "Choose your spawn!", + "starting": "Game starting!" + }, "team_colors": { "blue": "Blue", "bot": "Tribes", @@ -3380,6 +3384,8 @@ "steam_lobby_links_label": "Open Lobby Links in Steam", "swap_direction": "Swap Rocket Direction", "swap_direction_desc": "Toggle rocket launch direction (up/down).", + "tab_attention_desc": "Flash the tab title and icon when the game is starting or you still need to pick a spawn while this tab is in the background.", + "tab_attention_label": "Flash Tab When Game Starts", "tab_audio": "Audio", "tab_display": "Display", "tab_gameplay": "Gameplay", diff --git a/src/client/ClientGameRunner.ts b/src/client/ClientGameRunner.ts index 8f961026be..b63d0639b2 100644 --- a/src/client/ClientGameRunner.ts +++ b/src/client/ClientGameRunner.ts @@ -73,6 +73,7 @@ import { ALL_UNIT_TYPES, UnitState } from "./render/types"; import { versionedPathForMismatchedGame } from "./ServerList"; import { audioMixer, initAudioMixer } from "./sound/AudioMixer"; import { SoundManager } from "./sound/SoundManager"; +import { tabAttention, type TabAttentionOwner } from "./TabAttention"; import { reportGameError } from "./Telemetry"; import { loadCachedTerrainMap, @@ -126,6 +127,10 @@ export interface LobbyConfig { // Host only: the play token the lobby was created under, used for the // first join so the host joins as the creator (see createLobby). creatorToken?: string; + // Who owns this lobby's tab flash. Main passes the same token to + // tabAttention.request("starting"), so leaving this lobby only ever clears + // its own flash, never a newer lobby's. + tabAttentionOwner?: TabAttentionOwner; } export interface JoinLobbyResult { @@ -141,6 +146,9 @@ export function joinLobby( // Mutable clientID state — assigned by server (multiplayer) or derived from gameStartInfo (singleplayer) let clientID: ClientID | undefined; + // Tab-flash ownership for this lobby; see LobbyConfig.tabAttentionOwner. + const attentionOwner: TabAttentionOwner = lobbyConfig.tabAttentionOwner ?? {}; + lobbyConfig.tabAttentionOwner = attentionOwner; let resolvePrestart: () => void; let resolveJoin: () => void; const prestartPromise = new Promise((r) => (resolvePrestart = r)); @@ -155,6 +163,9 @@ export function joinLobby( const transport = new Transport(lobbyConfig, eventBus); let currentGameRunner: ClientGameRunner | null = null; + // Set once this lobby has been left, so a load that was still pending + // doesn't start a runner for it. + let lobbyStopped = false; const onconnect = async () => { // Drop the tag if the ownership check failed; the server re-checks anyway. @@ -307,6 +318,12 @@ export function joinLobby( terrainMapFileLoader, ) .then((r) => { + if (lobbyStopped) { + // The lobby was left while this was loading. Dispose the runner + // without starting it; its release only touches this lobby's flash. + r.stop(); + return; + } currentGameRunner = r; r.start(); }) @@ -314,6 +331,8 @@ export function joinLobby( console.error("error creating client game", e); currentGameRunner = null; + // The game never started, so stop this lobby's "starting" tab flash. + tabAttention.release(attentionOwner); const startingModal = document.querySelector( "game-starting-modal", @@ -452,10 +471,14 @@ export function joinLobby( return false; } console.log("leaving game"); + lobbyStopped = true; if (currentGameRunner) { currentGameRunner.stop(); currentGameRunner = null; } else { + // No runner yet to release the flash. Only this lobby's own flash is + // cleared: a no-op if it never asked, or if a newer lobby has since. + tabAttention.release(attentionOwner); transport.leaveGame(); } return true; @@ -1118,6 +1141,7 @@ export class ClientGameRunner { this.updateHealth(); this.webglBuilder?.update(this.gameView); this.renderer.tick(); + this.updateTabAttention(); if (gu.tickExecutionDuration !== undefined) { this.metrics?.recordTickExecution(gu.tickExecutionDuration); } @@ -1285,7 +1309,38 @@ export class ClientGameRunner { void this.transport.rejoinGame(0); } + // Flash the tab while the player still has to pick a spawn and has switched + // to another tab; the flashing ends once they spawn or the phase is over. + private updateTabAttention(): void { + const config = this.gameView.config(); + const canPickSpawn = + this.gameView.inSpawnPhase() && + !config.isRandomSpawn() && + !config.isReplay() && + !config.isIntentionalSpectator(); + const owner = this.attentionOwner(); + if (!canPickSpawn) { + tabAttention.release(owner); + return; + } + const me = this.gameView.myPlayer(); + // Before the player shows up in the view, leave any "starting" flash alone. + if (me === null) return; + if (me.hasSpawned()) { + tabAttention.release(owner); + } else { + tabAttention.request("spawn", owner); + } + } + + // The lobby's own token (set by joinLobby), so this runner only ever starts + // or clears its own lobby's flash. + private attentionOwner(): TabAttentionOwner { + return (this.lobby.tabAttentionOwner ??= {}); + } + public stop() { + tabAttention.release(this.attentionOwner()); if (this.healthTimer !== null) clearInterval(this.healthTimer); this.healthTimer = null; document.removeEventListener("visibilitychange", this.updateHealth); @@ -1302,11 +1357,13 @@ export class ClientGameRunner { // disposals around it. this.input.destroy(); this.disposeRenderer?.(); + // Terminate the worker even if the runner never started (a lobby left while + // it was loading), otherwise nothing else would ever stop it. Idempotent. + this.worker.cleanup(); if (!this.isActive) return; this.isActive = false; this.metrics?.stop(); - this.worker.cleanup(); this.transport.leaveGame(); if (this.connectionCheckInterval) { clearInterval(this.connectionCheckInterval); diff --git a/src/client/Main.ts b/src/client/Main.ts index 662d2230d5..10cddf0537 100644 --- a/src/client/Main.ts +++ b/src/client/Main.ts @@ -170,6 +170,7 @@ import { import "./UserMeBroadcast"; import { classicReplayHref } from "./replay/ReplayEntry"; import { parseReplayViewerHash } from "./replay/ReplayViewerRoute"; +import { tabAttention } from "./TabAttention"; // The UsernameInput class is used as a type; retain this for registration. // oxlint-disable-next-line import/no-duplicates -- Required custom-element registration. import "./UsernameInput"; @@ -1961,7 +1962,11 @@ class Client { void showInGameAlert(translateText("error_modal.game_client_failed")); return; } + // This join's tab-flash owner: a join that gets superseded can then only + // ever release its own flash, never the newer join's. + const attentionOwner = {}; const newLobbyHandle = joinLobby(this.eventBus, { + tabAttentionOwner: attentionOwner, gameID: lobby.gameID, cosmetics: await getPlayerCosmeticsRefs({ verified: resolvedName.verified, @@ -2005,6 +2010,9 @@ class Client { // through the wait (e.g. the featured-stream panel) hide at this point instead of on join. this.menuTornDown = true; document.dispatchEvent(new CustomEvent("game-starting")); + // Flash the tab if the player has switched away while waiting; the game + // runner takes over (and stops it) once the spawn phase is under way. + tabAttention.request("starting", attentionOwner); // Earliest point the lobby is provably closed: the server has stopped // broadcasting lobby_info and refuses new seats, so the shell must stop // advertising this as joinable even though terrain is still loading. diff --git a/src/client/TabAttention.ts b/src/client/TabAttention.ts new file mode 100644 index 0000000000..2b0ecfdf1d --- /dev/null +++ b/src/client/TabAttention.ts @@ -0,0 +1,225 @@ +import { UserSettings } from "./UserSettings"; +import { translateText } from "./Utils"; + +export type TabAttentionKind = "starting" | "spawn"; + +/** + * Identifies who asked for attention (one per lobby). Only the current owner + * can release it, so a lobby that was left, or superseded by a newer one, can + * never clear the flash the newer lobby is showing. + */ +export type TabAttentionOwner = object; + +// Two full blinks per second: alert<->normal flips every 250 ms (500 ms per cycle). +const FLASH_INTERVAL_MS = 250; +// A safety net: if the game never reaches (or never leaves) the spawn phase, +// stop flashing rather than blinking in a background tab forever. +const MAX_FLASH_MS = 2 * 60 * 1000; + +// The game's own warship favicon on a white tile. Same pixels and the same +// padded -2 -2 15 15 framing as Favicon.svg (which has a black tile), so the +// ship stays the same size and only the background flips between black and +// white. Inline so it needs no asset pipeline entry. +const ALERT_ICON_SVG = + `` + + `` + + `` + + ``; +const ALERT_ICON_SVG_HREF = + "data:image/svg+xml," + encodeURIComponent(ALERT_ICON_SVG); + +/** + * Flashes the tab title and favicon while the page is in a background tab and + * the player still has something to do (the game is starting, or they have yet + * to pick a spawn). Flashing stops as soon as the tab is visible again, and + * resumes if the player leaves while the need remains. + */ +export class TabAttention { + private kind: TabAttentionKind | null = null; + // Who holds the current request. Kept after a timeout so the owner can still + // release the expired need, and replaced when another owner asks. + private owner: TabAttentionOwner | null = null; + private timer: ReturnType | null = null; + private startedAt = 0; + private alertShown = false; + private originalTitle: string | null = null; + private originalIconHref: string | null = null; + private originalIconType: string | null = null; + private listening = false; + // The kind whose two-minute limit ran out. Requests for that kind are ignored + // until the need is released, so repeated requests can't restart the limit. + // A different kind (e.g. "spawn" after "starting" timed out) is a new need and + // gets its own run. startedAt is when the current flashing run began. + private expiredKind: TabAttentionKind | null = null; + // Starts as the SVG; swapped for a PNG once it has been rendered, since not + // every browser draws SVG favicons from data URIs reliably. + private alertIconHref = ALERT_ICON_SVG_HREF; + private alertIconType = "image/svg+xml"; + private pngRequested = false; + + /** + * @param isEnabled Whether the player has the feature turned on. Checked on + * every request and every blink, so switching it off takes effect at once. + */ + constructor(private readonly isEnabled: () => boolean = () => true) {} + + /** + * Ask for the player's attention. Safe to call repeatedly. A request from a + * different owner takes over: it is a new need, so it never inherits the + * previous owner's kind, deadline or expiry. + */ + request( + kind: TabAttentionKind, + owner: TabAttentionOwner | null = null, + ): void { + if (!this.isEnabled()) { + this.release(); + return; + } + if (owner !== this.owner) { + this.owner = owner; + this.expiredKind = null; + this.kind = null; + } + if (kind === this.expiredKind) return; + // A different need gets its own full run, rather than inheriting whatever + // is left of the previous kind's limit (which could be a second or less). + // The same kind keeps its deadline so repeated requests can't extend it. + if (kind !== this.kind) this.startedAt = Date.now(); + this.kind = kind; + this.listen(); + this.preparePngIcon(); + this.sync(); + } + + /** + * The player no longer needs to be alerted. Safe to call repeatedly. With an + * owner, this only acts if that owner still holds the request; without one it + * always releases (used when the setting is turned off). + */ + release(owner?: TabAttentionOwner): void { + if (owner !== undefined && owner !== this.owner) return; + this.expiredKind = null; + this.owner = null; + if (this.kind === null) return; + this.kind = null; + this.sync(); + } + + private listen(): void { + if (this.listening || typeof document === "undefined") return; + this.listening = true; + document.addEventListener("visibilitychange", this.sync); + window.addEventListener("focus", this.sync); + } + + private readonly sync = (): void => { + // The limit only counts time spent actually flashing in a hidden tab, so a + // long wait in a visible tab doesn't use it up. + if (this.timer !== null && Date.now() - this.startedAt > MAX_FLASH_MS) { + this.expire(); + } + if (this.kind !== null && !this.isEnabled()) this.kind = null; + const shouldFlash = this.kind !== null && document.hidden; + if (shouldFlash) { + this.startFlashing(); + } else { + this.stopFlashing(); + } + }; + + private startFlashing(): void { + if (this.timer !== null) return; + this.startedAt = Date.now(); + this.originalTitle = document.title; + const link = this.iconLink(); + this.originalIconHref = link?.getAttribute("href") ?? null; + this.originalIconType = link?.getAttribute("type") ?? null; + this.alertShown = false; + this.flash(); + this.timer = setInterval(this.flash, FLASH_INTERVAL_MS); + } + + private stopFlashing(): void { + if (this.timer === null) return; + clearInterval(this.timer); + this.timer = null; + this.apply(false); + } + + private readonly flash = (): void => { + if (Date.now() - this.startedAt > MAX_FLASH_MS) { + this.expire(); + this.stopFlashing(); + return; + } + if (!this.isEnabled()) { + this.kind = null; + this.stopFlashing(); + return; + } + this.apply(!this.alertShown); + }; + + private expire(): void { + if (this.kind !== null) this.expiredKind = this.kind; + this.kind = null; + } + + private apply(alert: boolean): void { + this.alertShown = alert; + const link = this.iconLink(); + if (alert) { + document.title = this.message(); + if (link) { + link.setAttribute("type", this.alertIconType); + link.setAttribute("href", this.alertIconHref); + } + return; + } + if (this.originalTitle !== null) document.title = this.originalTitle; + if (link && this.originalIconHref !== null) { + link.setAttribute("href", this.originalIconHref); + if (this.originalIconType !== null) { + link.setAttribute("type", this.originalIconType); + } else { + link.removeAttribute("type"); + } + } + } + + private preparePngIcon(): void { + if (this.pngRequested || typeof Image === "undefined") return; + this.pngRequested = true; + const img = new Image(); + img.onload = () => { + try { + const canvas = document.createElement("canvas"); + canvas.width = 64; + canvas.height = 64; + const ctx = canvas.getContext("2d"); + if (!ctx) return; + ctx.imageSmoothingEnabled = false; + ctx.drawImage(img, 0, 0, 64, 64); + this.alertIconHref = canvas.toDataURL("image/png"); + this.alertIconType = "image/png"; + } catch { + // Keep the SVG icon. + } + }; + img.src = ALERT_ICON_SVG_HREF; + } + + private message(): string { + return this.kind === "spawn" + ? translateText("tab_attention.pick_spawn") + : translateText("tab_attention.starting"); + } + + private iconLink(): HTMLLinkElement | null { + return document.querySelector('link[rel~="icon"]'); + } +} + +const userSettings = new UserSettings(); +export const tabAttention = new TabAttention(() => userSettings.tabAttention()); diff --git a/src/client/UserSettingModal.ts b/src/client/UserSettingModal.ts index c6f110df06..6440848c77 100644 --- a/src/client/UserSettingModal.ts +++ b/src/client/UserSettingModal.ts @@ -527,6 +527,16 @@ export class UserSettingModal extends BaseModal { this.requestUpdate(); } + private toggleTabAttention() { + this.userSettings.toggleTabAttention(); + console.log( + "🔔 Tab Attention:", + this.userSettings.tabAttention() ? "ON" : "OFF", + ); + + this.requestUpdate(); + } + /** The ratio the player is actually attacking with right now. */ private currentAttackRatio(): number { return this.uiState?.attackRatio ?? this.userSettings.attackRatio(); @@ -2058,6 +2068,15 @@ export class UserSettingModal extends BaseModal { }} > + + + ({ + translateText: (key: string) => key, +})); + +vi.mock("../../src/client/UserSettings", () => ({ + UserSettings: class { + tabAttention() { + return true; + } + }, +})); + +import { TabAttention } from "../../src/client/TabAttention"; + +const ORIGINAL_HREF = "/images/Favicon.svg"; + +function setHidden(hidden: boolean) { + Object.defineProperty(document, "hidden", { + configurable: true, + get: () => hidden, + }); + document.dispatchEvent(new Event("visibilitychange")); +} + +function iconHref(): string | null { + return document.querySelector('link[rel~="icon"]')!.getAttribute("href"); +} + +describe("TabAttention", () => { + let attention: TabAttention; + let enabled = true; + + beforeEach(() => { + vi.useFakeTimers(); + document.head.innerHTML = ``; + document.title = "OpenFront"; + setHidden(false); + enabled = true; + attention = new TabAttention(() => enabled); + }); + + afterEach(() => { + attention.release(); + vi.useRealTimers(); + }); + + it("does nothing while the tab is visible", () => { + attention.request("spawn"); + vi.advanceTimersByTime(5000); + expect(document.title).toBe("OpenFront"); + expect(iconHref()).toBe(ORIGINAL_HREF); + }); + + it("alternates title and icon while the tab is hidden", () => { + setHidden(true); + attention.request("spawn"); + expect(document.title).toBe("tab_attention.pick_spawn"); + expect(iconHref()).not.toBe(ORIGINAL_HREF); + + vi.advanceTimersByTime(250); + expect(document.title).toBe("OpenFront"); + expect(iconHref()).toBe(ORIGINAL_HREF); + + vi.advanceTimersByTime(250); + expect(document.title).toBe("tab_attention.pick_spawn"); + }); + + it("uses the starting message before the spawn phase", () => { + setHidden(true); + attention.request("starting"); + expect(document.title).toBe("tab_attention.starting"); + }); + + it("restores the title and icon when the tab becomes visible", () => { + setHidden(true); + attention.request("spawn"); + setHidden(false); + expect(document.title).toBe("OpenFront"); + expect(iconHref()).toBe(ORIGINAL_HREF); + vi.advanceTimersByTime(5000); + expect(document.title).toBe("OpenFront"); + }); + + it("resumes when the player leaves again while still needed", () => { + attention.request("spawn"); + setHidden(true); + expect(document.title).toBe("tab_attention.pick_spawn"); + }); + + it("stops and restores on release", () => { + setHidden(true); + attention.request("spawn"); + attention.release(); + expect(document.title).toBe("OpenFront"); + expect(iconHref()).toBe(ORIGINAL_HREF); + vi.advanceTimersByTime(5000); + expect(document.title).toBe("OpenFront"); + }); + + it("gives up after two minutes", () => { + setHidden(true); + attention.request("spawn"); + vi.advanceTimersByTime(2 * 60 * 1000 + 500); + expect(document.title).toBe("OpenFront"); + expect(iconHref()).toBe(ORIGINAL_HREF); + }); + + it("does not restart the two-minute limit on repeated requests", () => { + setHidden(true); + attention.request("spawn"); + vi.advanceTimersByTime(2 * 60 * 1000 + 500); + expect(document.title).toBe("OpenFront"); + // A game tick asks again; it must stay stopped. + attention.request("spawn"); + vi.advanceTimersByTime(5000); + expect(document.title).toBe("OpenFront"); + expect(iconHref()).toBe(ORIGINAL_HREF); + }); + + it("does not use up the limit while the tab is visible", () => { + attention.request("spawn"); + // Waiting in a visible tab for longer than the limit, with game ticks. + for (let i = 0; i < 5; i++) { + vi.advanceTimersByTime(60 * 1000); + attention.request("spawn"); + } + setHidden(true); + expect(document.title).toBe("tab_attention.pick_spawn"); + vi.advanceTimersByTime(2 * 60 * 1000 + 500); + expect(document.title).toBe("OpenFront"); + }); + + it("still flashes for a spawn request after the starting flash timed out", () => { + setHidden(true); + attention.request("starting"); + vi.advanceTimersByTime(2 * 60 * 1000 + 500); + expect(document.title).toBe("OpenFront"); + + // Same kind stays ignored (no restart from repeated requests)... + attention.request("starting"); + expect(document.title).toBe("OpenFront"); + + // ...but a different need gets its own two minutes. + attention.request("spawn"); + expect(document.title).toBe("tab_attention.pick_spawn"); + vi.advanceTimersByTime(2 * 60 * 1000 + 500); + expect(document.title).toBe("OpenFront"); + }); + + it("gives a different kind its own two minutes when it replaces a run that is nearly over", () => { + setHidden(true); + attention.request("starting"); + vi.advanceTimersByTime(119 * 1000); + + // The game starts a second before the starting run would have ended. + attention.request("spawn"); + // Well past the old deadline, spawn must still be flashing... + vi.advanceTimersByTime(30 * 1000); + const titles = new Set(); + for (let i = 0; i < 4; i++) { + titles.add(document.title); + vi.advanceTimersByTime(250); + } + expect(titles.has("tab_attention.pick_spawn")).toBe(true); + + // ...and it still ends after its own two minutes. + vi.advanceTimersByTime(2 * 60 * 1000); + expect(document.title).toBe("OpenFront"); + expect(iconHref()).toBe(ORIGINAL_HREF); + }); + + it("keeps the deadline when the same kind is requested again", () => { + setHidden(true); + attention.request("spawn"); + vi.advanceTimersByTime(119 * 1000); + attention.request("spawn"); + vi.advanceTimersByTime(2 * 1000); + expect(document.title).toBe("OpenFront"); + expect(iconHref()).toBe(ORIGINAL_HREF); + }); + + it("allows a new two-minute period after the need is released", () => { + setHidden(true); + attention.request("spawn"); + vi.advanceTimersByTime(2 * 60 * 1000 + 500); + attention.release(); + attention.request("spawn"); + expect(document.title).toBe("tab_attention.pick_spawn"); + }); + + it("does nothing when the setting is off", () => { + enabled = false; + setHidden(true); + attention.request("spawn"); + vi.advanceTimersByTime(5000); + expect(document.title).toBe("OpenFront"); + expect(iconHref()).toBe(ORIGINAL_HREF); + }); + + it("stops and restores if the setting is switched off mid-flash", () => { + setHidden(true); + attention.request("spawn"); + expect(document.title).toBe("tab_attention.pick_spawn"); + enabled = false; + vi.advanceTimersByTime(250); + expect(document.title).toBe("OpenFront"); + expect(iconHref()).toBe(ORIGINAL_HREF); + vi.advanceTimersByTime(5000); + expect(document.title).toBe("OpenFront"); + }); + + it("flashes again once the setting is switched back on", () => { + enabled = false; + setHidden(true); + attention.request("spawn"); + expect(document.title).toBe("OpenFront"); + enabled = true; + attention.request("spawn"); + expect(document.title).toBe("tab_attention.pick_spawn"); + }); + + describe("ownership", () => { + const lobbyA = {}; + const lobbyB = {}; + + it("lets the owner release its own flash", () => { + setHidden(true); + attention.request("starting", lobbyA); + expect(document.title).toBe("tab_attention.starting"); + attention.release(lobbyA); + expect(document.title).toBe("OpenFront"); + expect(iconHref()).toBe(ORIGINAL_HREF); + }); + + it("ignores a release from an owner that never asked (a superseded lobby)", () => { + setHidden(true); + attention.request("starting", lobbyB); + attention.release(lobbyA); + expect(document.title).toBe("tab_attention.starting"); + vi.advanceTimersByTime(250); + expect(document.title).toBe("OpenFront"); + vi.advanceTimersByTime(250); + expect(document.title).toBe("tab_attention.starting"); + }); + + it("ignores a release from an owner that a newer owner has replaced", () => { + setHidden(true); + attention.request("starting", lobbyA); + attention.request("starting", lobbyB); + attention.release(lobbyA); + expect(document.title).toBe("tab_attention.starting"); + attention.release(lobbyB); + expect(document.title).toBe("OpenFront"); + }); + + it("still releases when no owner is given (setting switched off)", () => { + setHidden(true); + attention.request("starting", lobbyA); + attention.release(); + expect(document.title).toBe("OpenFront"); + }); + + it("gives a new owner a fresh run after the previous owner timed out", () => { + setHidden(true); + attention.request("spawn", lobbyA); + vi.advanceTimersByTime(2 * 60 * 1000 + 500); + expect(document.title).toBe("OpenFront"); + // Same kind, but a different lobby: its own need, its own two minutes. + attention.request("spawn", lobbyB); + expect(document.title).toBe("tab_attention.pick_spawn"); + }); + + it("keeps an owner's expiry from restarting on repeated requests", () => { + setHidden(true); + attention.request("spawn", lobbyA); + vi.advanceTimersByTime(2 * 60 * 1000 + 500); + attention.request("spawn", lobbyA); + expect(document.title).toBe("OpenFront"); + }); + + it("lets the owner release an expired need so it can ask again", () => { + setHidden(true); + attention.request("spawn", lobbyA); + vi.advanceTimersByTime(2 * 60 * 1000 + 500); + attention.release(lobbyA); + attention.request("spawn", lobbyA); + expect(document.title).toBe("tab_attention.pick_spawn"); + }); + + it("regression: a stale join released after the current lobby asked keeps the flash running", () => { + setHidden(true); + // Lobby B is current and has asked; stale lobby A (which never asked) is + // stopped afterwards, as Main does for a superseded join. + attention.request("starting", lobbyB); + attention.release(lobbyA); + attention.release(lobbyA); + const titles = new Set(); + for (let i = 0; i < 4; i++) { + titles.add(document.title); + vi.advanceTimersByTime(250); + } + expect(titles).toEqual(new Set(["tab_attention.starting", "OpenFront"])); + }); + }); +});