mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 16:10:07 +00:00
feat(client): offer the new version when a release lands during a session
A tab kept open across a deploy ran the previous build until its next start. The server now names its version in the realtime welcome frame, which every open client reads again when it reconnects after the restart a deploy brings. When that version is not the build the page runs, a notice offers to reload. The reload goes through the same service worker handover a launch uses: it waits for the new worker to take over, or for a short timeout, and records the version only when the takeover happened. The notice reads the error boundary's texts for the same situation, so every language has it already. It is one component for both shells, sits above the offline pill, stays away offline and after a reload for that version that did not bring it, and can be closed for the session.
This commit is contained in:
@@ -35,6 +35,7 @@ import {
|
||||
type TrekWebSocket,
|
||||
} from './ws-state';
|
||||
import { JourneyDomainService } from '../journey/journey-domain.service';
|
||||
import { hostVersion } from '../plugins/install/host-compat';
|
||||
|
||||
const HEARTBEAT_INTERVAL = 30_000;
|
||||
|
||||
@@ -153,7 +154,10 @@ export class RealtimeGateway
|
||||
|
||||
socket.isAlive = true;
|
||||
const sid = registerSocket(socket, user as User);
|
||||
socket.send(JSON.stringify({ type: 'welcome', socketId: sid }));
|
||||
// The version lets a client that stayed open across a deploy notice it
|
||||
// runs the previous build: a deploy restarts the server, so every open
|
||||
// client reconnects and reads this again.
|
||||
socket.send(JSON.stringify({ type: 'welcome', socketId: sid, version: hostVersion() }));
|
||||
socket.on('pong', () => { socket.isAlive = true; });
|
||||
} catch (err) {
|
||||
logError(`ws handshake failed: ${err instanceof Error ? err.message : String(err)}`);
|
||||
|
||||
Reference in New Issue
Block a user