web: settings destination with connection, workspace and templates (L1)
Completes the item: the Settings view, its pure helpers and the client's socket-replacement path, plus the fix the review required (a header-side URL correction clears the Settings field's own error) and a smoke check for it.
This commit is contained in:
+21
-1
@@ -159,13 +159,33 @@ export class PipelinesClient extends EventTarget {
|
||||
retrying: false,
|
||||
});
|
||||
const socket = new this.#WebSocketImpl(current);
|
||||
const superseded = this.#ws;
|
||||
this.#ws = socket;
|
||||
// Replace the current socket, then close the one it superseded (mirrors
|
||||
// PipelinesClient.openLocked). Its callbacks are ignored from then on, so a
|
||||
// failure the old socket reports late can neither clear the new socket nor
|
||||
// schedule a reconnect that would undo it. A request already sent on the old
|
||||
// socket cannot receive a reply from the replacement, so fail it now rather
|
||||
// than leaving a view waiting for the ordinary request timeout.
|
||||
if (superseded) {
|
||||
this.#failPending("Connection replaced");
|
||||
try {
|
||||
superseded.close(NORMAL_CLOSURE, "superseded");
|
||||
} catch {
|
||||
/* already closed */
|
||||
}
|
||||
}
|
||||
socket.onopen = () => {
|
||||
if (this.#ws !== socket) return;
|
||||
this.#attempt = 0;
|
||||
this.#setState({ kind: CONNECTED, attempt: 0, reason: "", retrying: false });
|
||||
};
|
||||
socket.onmessage = (event) => this.#onMessage(event.data);
|
||||
socket.onmessage = (event) => {
|
||||
if (this.#ws !== socket) return;
|
||||
this.#onMessage(event.data);
|
||||
};
|
||||
socket.onclose = (event) => {
|
||||
if (this.#ws !== socket) return;
|
||||
this.#handleClosed(`Connection closed (${event.code ?? "?"})`);
|
||||
};
|
||||
socket.onerror = () => {
|
||||
|
||||
Reference in New Issue
Block a user