Skip to content

fix(desktop): ping only the active connection at startup#196

Merged
huhamhire merged 1 commit into
devfrom
fix/ping-active-connection-only
Jul 5, 2026
Merged

fix(desktop): ping only the active connection at startup#196
huhamhire merged 1 commit into
devfrom
fix/ping-active-connection-only

Conversation

@huhamhire

Copy link
Copy Markdown
Owner

Problem

At startup, ConnectionRuntimeController.ping() looped over every configured connection to refresh its remote identity (currentUser) and probe serverVersion. For non-active connections this is wasted work:

  • Their identity has no UI consumerapp:connections filters the summary to the active connection (services/app.ts), and the connection config schema carries no user field, so the connection list can't render it either.
  • The persisted identity of a non-active connection is only used to prewarm an in-memory adapter cache, which is refreshed anyway once that connection becomes active.

Meanwhile the cost is real: extra startup network requests to every connection, and — for an unreachable / misconfigured connection (e.g. a TLS cert altname mismatch) — a adapter ping failed WARN on every launch for a connection that isn't even in use.

Change

Narrow ping() to the active connection only (find(active) + early return). Because the loop now handles a single connection, the pervasive isActive branches collapse (behaviour-equivalent, simpler).

Switching the active connection still re-pings the new active one: the settings-save path sets active_connection_id then calls reconfigureConnections()reconfigure()ping(). So on-demand identity refresh on switch is preserved — no separate on-switch hook needed.

The active connection's first-sync trigger and PAT fallback (sync-once-even-if-ping-fails) are unchanged.

Effect

  • Startup pings only the active connection; no startup network churn for the rest.
  • A broken non-active connection no longer pollutes the startup log with a WARN.
  • Active-connection identity refresh / first sync: unchanged.

Verification

npx nx typecheck desktop and npx nx lint desktop both pass.

🤖 Generated with Claude Code

Startup ping looped over every configured connection to refresh its
remote identity, but non-active connections' identity has no UI consumer
(app:connections filters the summary to the active connection, and the
connection schema carries no user field) — the persisted identity was
only used to prewarm an adapter cache that is refreshed anyway when the
connection becomes active. Pinging them just added startup network
requests and, for an unreachable/misconfigured connection, a WARN on
every launch for a connection not in use.

Narrow ping() to the active connection only; switching the active
connection still re-pings via the settings-save path
(reconfigure -> ping), so on-demand identity refresh is preserved. The
active connection's first-sync and PAT fallback behaviour is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@huhamhire huhamhire added the bug Something isn't working label Jul 5, 2026
@huhamhire huhamhire merged commit 997f5c9 into dev Jul 5, 2026
1 check passed
@huhamhire huhamhire deleted the fix/ping-active-connection-only branch July 5, 2026 07:08
huhamhire added a commit that referenced this pull request Jul 5, 2026
Add a Fixed entry under Unreleased (both EN canonical and ZH mirror) for
#196, and soften the "behavior unchanged from 0.9.0" highlight to note
the minor startup fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant