Skip to content

Commit 3a54c11

Browse files
gantoineclaude
andcommitted
fix(discord-presence): quiet reconnect logging when Discord isn't running
Log and emit the disconnected state once per streak instead of on every 15s reconnect attempt: drop the per-attempt IPC debug line and gate the service's log/status-emit behind a `waiting` flag that resets on connect or disable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 345a1f9 commit 3a54c11

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

apps/code/src/main/services/discord-presence/discord-ipc.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ export class DiscordIpcClient extends TypedEventEmitter<DiscordIpcClientEvents>
9090

9191
private tryConnect(paths: string[], index: number): void {
9292
if (index >= paths.length) {
93-
log.debug("No reachable Discord IPC socket");
9493
this.emit("disconnect", undefined);
9594
return;
9695
}

apps/code/src/main/services/discord-presence/service.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export class DiscordPresenceService extends TypedEventEmitter<DiscordPresenceSer
3939
private showTaskTitle: boolean;
4040
private showRepoName: boolean;
4141
private connected = false;
42+
private waiting = false;
4243
private intent: PresenceIntent = IDLE_INTENT;
4344
private reconnectTimer: NodeJS.Timeout | null = null;
4445
private throttleTimer: NodeJS.Timeout | null = null;
@@ -120,13 +121,24 @@ export class DiscordPresenceService extends TypedEventEmitter<DiscordPresenceSer
120121
this.client = client;
121122
client.on("ready", () => {
122123
this.connected = true;
124+
this.waiting = false;
123125
log.info("Connected to Discord");
124126
this.render(true);
125127
this.emitStatus();
126128
});
127129
client.on("disconnect", () => {
130+
const wasConnected = this.connected;
128131
this.connected = false;
129-
this.emitStatus();
132+
if (wasConnected) {
133+
log.info("Lost Discord connection; retrying in the background");
134+
this.emitStatus();
135+
} else if (!this.waiting) {
136+
this.waiting = true;
137+
log.debug(
138+
"Discord not running; retrying in the background until it appears",
139+
);
140+
this.emitStatus();
141+
}
130142
this.scheduleReconnect();
131143
});
132144
client.connect();
@@ -139,6 +151,7 @@ export class DiscordPresenceService extends TypedEventEmitter<DiscordPresenceSer
139151
this.client = null;
140152
}
141153
this.connected = false;
154+
this.waiting = false;
142155
}
143156

144157
private scheduleReconnect(): void {

0 commit comments

Comments
 (0)