Compare commits

..
Author SHA1 Message Date
MoepchiandClaude Opus 5.5 5e7add6dc8 Drain queued packets before audio ticks in the connector
After a stall (CPU steal on the host), the missed 20 ms ticks fire in a
burst. With an unbiased select a tick could run before the already
received voice packets were processed, find an empty queue and play Opus
loss concealment, which sounds like a slowed-down tape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-10-16 08:18:20 +00:00
MoepchiandClaude Opus 5.5 983ce1e105 Rejoin the last channel after an automatic reconnect
A dropped gateway connection reconnected with the original connect
parameters, so everyone landed in the server's default channel again.
The reconnect now aims at the channel the user was in ("/<id>"), with
its cached password if one was entered.

The client log also records why a gateway connection ended: the
WebSocket close code, or the keepalive watchdog firing. Until now a drop
left no trace on the client side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-10-15 12:14:12 +00:00
2 changed files with 20 additions and 2 deletions

No files matched your search

+4
View File
@@ -1148,6 +1148,10 @@ async fn run(args: Args) -> Result<()> {
loop {
let mut events = con.events();
let outcome = tokio::select! {
// After a stall (e.g. CPU steal) the missed audio ticks fire in a burst.
// Polling in order drains the queued packets first, otherwise a tick can
// find an empty queue and play Opus loss concealment instead.
biased;
line = stdin_lines.next_line() => LoopOutcome::StdinLine(line),
ev = events.next() => LoopOutcome::ConEvent(ev),
_ = audio_ticker.tick() => LoopOutcome::AudioTick,
+16 -2
View File
@@ -8000,14 +8000,17 @@ function AppInner() {
// detach and run the drop handling right away.
socket.onmessage = socket.onerror = socket.onclose = null;
socket.close();
logClient("warning", "Connection", `No keepalive from the gateway for ${KEEPALIVE_TIMEOUT_MS / 1000} s`);
current().onclose();
}, KEEPALIVE_TIMEOUT_MS);
}
if (event.data !== KEEPALIVE_MESSAGE) current().onmessage(event);
};
socket.onerror = () => current().onerror();
socket.onclose = () => {
socket.onclose = (event) => {
clearTimeout(watchdog);
// 1000/1001 are clean closes; 1006 means the link died without a close frame.
logClient("info", "Connection", `Gateway connection closed (code ${event.code ?? "?"})`);
current().onclose();
};
};
@@ -8113,7 +8116,7 @@ function AppInner() {
// network blip, or the page coming back from being backgrounded/suspended
// — without disturbing which tab is active or losing chat/scroll history.
const reconnectSession = (sessionId: string) => {
const params = sessionParamsRef.current.get(sessionId);
let params = sessionParamsRef.current.get(sessionId);
const rec = sessionsRef.current.get(sessionId);
if (!params || !rec) return;
// Already open or mid-(re)connect — nothing to do.
@@ -8121,6 +8124,17 @@ function AppInner() {
return;
}
// Come back in the channel we were in, like the native client does. Kept
// in the params so a failed attempt (empty client list) still aims there.
const isActive = sessionId === activeSessionIdRef.current;
const state = isActive ? { clients, ownClientId } : rec.parked;
const lastChannel = state?.clients.find((c) => c.id === state.ownClientId)?.channel;
if (lastChannel) {
const cachedPassword = isActive ? channelPasswordCacheRef.current.get(lastChannel) : undefined;
params = { ...params, defaultChannel: `/${lastChannel}`, channelPassword: cachedPassword ?? params.channelPassword };
sessionParamsRef.current.set(sessionId, params);
}
logClient("info", "Connection", `Reconnecting to ${params.host}…`);
const socket = DEMO_MODE ? new DemoSocket() : new WebSocket(GATEWAY_URL);
rec.socket = socket;