/******************************************************************************** * Copyright (c) 2026 CrossBreeze, EclipseSource and others. * * This program and the accompanying materials are made available under the * terms of the MIT License which is available in the project root. * * SPDX-License-Identifier: MIT ********************************************************************************/ import { type Stopwatch } from '@hydranium/protocol'; import { MessageService } from '@theia/core'; import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution'; import { ConnectionStatus, ConnectionStatusService } from '@theia/core/lib/browser/connection-status-service'; import { WebSocketConnectionSource } from '@theia/core/lib/browser/messaging/ws-connection-source'; import { type interfaces } from '@theia/core/shared/inversify'; import { Clock } from '../common/clock'; import { type ConnectionBufferOverflow } from '../common/framed-socket-write-buffer'; import { ChannelLogger } from './channel-logger'; /** * Records the browser side of the websocket lifecycle into the adopter's Output * channel, and tells the user the one thing they cannot recover from on their * own. * * Theia reports an outage only as an "Offline" status-bar item, which cannot * distinguish a plain network drop from the server having stopped answering on a * socket that is still up. The latter is what a connection defect looks like * from here, so the two are logged differently — that distinction is what says * whether reopening an editor helps or only a reload does. * * Purely observational apart from the overflow message: nothing here changes how * the connection behaves. */ export declare class ConnectionDiagnosticsContribution implements FrontendApplicationContribution { protected readonly connectionSource: WebSocketConnectionSource; protected readonly connectionStatus: ConnectionStatusService; protected readonly logger: ChannelLogger; protected readonly messageService: MessageService; /** Times the outages the log reports: the container's {@link Clock}, or a `SystemClock`. */ protected readonly clock: Clock; /** Main channels created so far; more than one means the server did not recognise this frontend. */ protected channelCount: number; protected sinceSocketClosed?: Stopwatch; protected sinceOffline?: Stopwatch; initialize(): void; protected handleSocketOpen(): void; protected handleSocketClose(): void; /** * A second channel means the reconnect was refused and the session discarded. * Only reachable with `reloadOnReconnect` off — with it on, Theia reloads the * page instead of opening another channel. */ protected handleChannelOpen(): void; protected handleStatusChange(status: ConnectionStatus): void; /** * The outage outlasted what the buffer can hold, so changes made from here on * are being thrown away rather than queued. Reconnecting resumes sending but * cannot bring those back, which leaves the editor disagreeing with the * server — and without a message the user would see nothing but an editor * that has quietly stopped saving, so say it plainly. */ protected handleBufferOverflow(overflow: ConnectionBufferOverflow): void; protected socketId(): string; protected statusName(status: ConnectionStatus): string; } /** * Bind {@link ConnectionDiagnosticsContribution} as a `FrontendApplicationContribution`. * * Needs a {@link ChannelLogger} binding, so call it from a module that has also * called `bindChannelLogger`. Unlike `bindConnectionResilience` this belongs in a * normal frontend module: it only observes, so it has no reason to run during * preload, and `MessageService` is not available that early. */ export declare function bindConnectionDiagnostics(bind: interfaces.Bind): void; //# sourceMappingURL=connection-diagnostics-contribution.d.ts.map