fix(startup): restore saved sessions promptly and stop plugin heartbeat reloads - #712
Merged
Merged
Conversation
…at reloads Keep successfully restored project tabs when later session hydration times out. Seed the saved conversation identity before HTTP reads, prioritize its project, hydrate it directly, and load composer catalogues as soon as the client is ready. Retry reads invalidated by the first stream connection without selecting an unrelated conversation. Move desktop plugin payloads and presence leases out of OpenCode's recursively watched configuration root into a sibling namespace keyed by the authenticated discovery root. Migrate managed inside-root storage while continuing to read older backends' leases, retain existing outside-root storage, and preserve native WSL path translation and independent backend lifecycles. This removes the two-second heartbeat trigger that reproduced multi-second native message reads. Publish session lists independently of slow runtime-status reads, preserve concurrent SSE and local admission authority, and use lightweight status reconciliation for liveness. Share a bounded background-read budget across projects, coalesce Shell refreshes, and restrict native data projection to transcript-related events. Avoid unnecessary Git mutation-identity resolution for authorized reads and reject unrelated Git common directories before native inventory scans. Cover startup selection, hydration timeouts, reconnect races, runtime-status authority, background queue cancellation, projection isolation, lease migration, and concurrent backend presence. Validate native plugin provisioning with an isolated OpenCode 2.0.9 fixture and an OS watcher assertion that fails with the former lease placement. Targeted UI/server suites, six Electron/Tauri restore scenarios, typechecks, and the complete server/UI/plugin build pass. Installed-app checks retain 200-message pages, restore the requested conversation in 3.86-5.33 seconds, and confirm the model menu and fast forced reloads. A forced reload racing restoration of an old scroll position can still require the existing history retry control.
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.
Summary
Restore the saved project/conversation promptly, preserve restored tabs when later hydration fails, and remove a filesystem heartbeat that repeatedly invalidated OpenCode configuration.
Root cause and reproduction
PR #666 placed desktop plugin presence leases beneath the authenticated OpenCode configuration discovery root. Updating their mtimes every two seconds triggers recursive configuration watchers and expensive revalidation across loaded locations.
With CodeNomad closed and the same shared OpenCode daemon left running, updating only a temporary file in that directory reproduced the slowdown:
The pre-#666 server/UI comparison was only a partial baseline: native reads recovered after startup, but the older UI also exhibited restoration failures.
Implementation
Validation
git diff --checkpassed.Remaining observed edge case
A forced reload racing restoration of an old scroll position can still show the existing history retry control. Retrying succeeded. This PR addresses the reproduced latency trigger and startup restoration races; it does not claim that every scroll-restoration edge case is resolved.