Reconnect the desktop client when the local daemon socket drops - #218
Open
yaffalhakim1 wants to merge 2 commits into
Open
Reconnect the desktop client when the local daemon socket drops#218yaffalhakim1 wants to merge 2 commits into
yaffalhakim1 wants to merge 2 commits into
Conversation
monitor_daemon reconnected Remote targets but only checked whether a Local child process had exited. A live daemon with a dead client socket left the desktop stuck on 'daemon is disconnected' until restart (egoist#178). The supervisor now opens a replacement client against the same listener with the last replay cursors and publishes it through the supervisor, mirroring the remote reconnect path.
Extend UsageProvider to OpenCode/OpenCode2. The usage scan now reads OpenCode's session/session_v2 tables (per-session token + cost aggregates) instead of JSONL transcripts, so OpenCode usage finally appears in Settings > Usage. Generalize the Usage page charts, provider colors, and split bars to N providers (the canvas renderers were already generic). - waku-protocol: add OpenCode/OpenCode2 variants; grow DaySlice/MonthSlice/ ProjectSlice by_provider arrays to 4. - waku-core: add provider_db_path + read_opencode_db (read-only SQLite, model JSON unwrapped to its id, dedupe_key = session id); branch the scan loop for SQLite-backed providers; fix ProjectAccumulator array size. - usage_page: map provider_kind; build provider colors/series/split bars from UsageProvider::ALL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #178
Problem
A transient drop of the desktop-to-daemon WebSocket (suspend/resume, a socket reset) leaves the desktop permanently disconnected on Windows while
waku-daemon.exekeeps running.monitor_daemonreconnectsRemotetargets, but forLocaltargets it only checks whether the child process exited. A live child with a dead client socket never recovers, and every save afterwards repeats "Could not save local state: Waku daemon is disconnected" until the user restarts the app.Solution
The supervisor now treats a disconnected local client the way it already treats a disconnected remote client: it opens a replacement
DaemonClientagainst the same listener, replays the last cursors, and publishes it through the supervisor. The daemon process itself is left untouched, so provider runtimes survive the reconnect.DaemonProcessrecords the address it connected to and can swap its client.DaemonTarget::Localcarries the address and token, so the monitor can reconnect without re-reading exposure settings.monitor_daemongains a local reconnect path mirroring the existing remote one. The decision and the swap live inlocal_reconnect_params,replace_local_client, andtry_local_reconnect, which take an injected connector and stay unit-testable.DaemonClient::disconnected_for_test(test-only) builds a client marked disconnected with given replay cursors.Checks
cargo fmt -p waku-client -- --checkcargo check -p waku-clientcargo test -p waku-client: 22 passed, 5 new tests covering the reconnect decision, target filtering, client swap, and the injected connectorLimitations
The new tests cover the reconnect decision and client replacement, not a full lifecycle against a real daemon process. A lifecycle test would need a mock daemon binary, so I kept this patch focused. Some app-state holders capture
daemon.client()once and keep the old handle after a reconnect; task-state sync already followssubscribe_clients, so the save path recovers immediately.