fix(sync): restore UI state and task sync after reconnect or sleep (#107) - #111
Merged
Merged
Conversation
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.
Closes #107
Summary
Addresses session and task state divergence when closing the browser tab, computer sleeps/hibernates, or network disconnects.
Root Cause
public/kanban.html, polling relied solely onsetTimeout, which is paused by the browser when a tab is throttled or computer sleeps, with novisibilitychange,focus, oronlineevents to trigger self-healing.public/index.html, when WebSocket reconnected whilecurrentSessionIdwas already populated,loadSesswas skipped. If a background task finished while away, the final response saved in the database was not loaded into the chat DOM.server.js, the 60s watchdog skipped any task present intaskRunning, even if its subprocess had already died (worker_pidno longer running), leaving stale tasks stuck inin_progress.Changes
public/kanban.html: Addedvisibilitychange,focus, andonlineevent listeners to immediately refresh the board and restart auto-refresh upon wake-up.public/index.html: Addedonlineevent listener for immediate reconnection; updated reconnect and refocus handlers to callloadSess(activeTabId)so completed results, summaries, and checkmarks are rendered.server.js: AddedisPidAlive(pid)helper and updated watchdog to evict deadworker_pidprocesses fromtaskRunningand recover stuck tasks.test/interrupted-recovery.test.js: Added test suite verifying watchdogisPidAlivechecks, task recovery, and UI self-healing event bindings.