fix(app): namespace lastProjectSession by server origin#18305
Open
Skeptomenos wants to merge 1 commit intoanomalyco:devfrom
Open
fix(app): namespace lastProjectSession by server origin#18305Skeptomenos wants to merge 1 commit intoanomalyco:devfrom
Skeptomenos wants to merge 1 commit intoanomalyco:devfrom
Conversation
When connecting Desktop to multiple servers, lastProjectSession was
stored as a flat record keyed by directory path. Session IDs from one
server would persist after switching to another, causing a 'Session
not found' polling loop every ~4 seconds.
Changes:
- server.tsx: expose origin getter on server context
- pages/layout.tsx: change lastProjectSession from
{ [directory]: route } to { [origin]: { [directory]: route } }
- Add migration that wraps existing flat entries under 'local' origin
- All reads go through originSessions() helper
- All writes use server.origin as the first key
Closes anomalyco#18302
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.
Issue for this PR
Closes #18302
Type of change
What does this PR do?
When OpenCode Desktop connects to multiple servers (local sidecar + remote
opencode serve),lastProjectSessionis stored as a flat record keyed by directory path. Session IDs from one server persist after switching to another server, causing the Desktop to poll for sessions that only exist on the previous server — resulting in a "Session not found" error loop every ~4 seconds with audible chimes and red notification badges.The fix namespaces
lastProjectSessionby server origin, matching the pattern already used bystore.projects[origin]inserver.tsx.server.tsx: Expose theorigingetter (derived fromprojectsKey(state.active)) sopages/layout.tsxcan use it. Follows the existingkeyandnamegetter pattern.pages/layout.tsx: ChangelastProjectSessionfrom{ [directory]: route }to{ [origin]: { [directory]: route } }. All reads go through a neworiginSessions()helper. All writes includeserver.originas the first key. Migration wraps existing flat entries under the"local"origin key so no session history is lost.The migration detects old vs new format by checking if the first value has an
idfield (old flat format) vs being a nested record (new namespaced format). This is idempotent — re-running migration on already-migrated data is a no-op.How did you verify your code works?
lastProjectSessionacrossrememberSessionRoute,clearLastProjectSession,syncSessionRoute,navigateToProject,deleteWorkspace, and the route-change effectserver.originuses the sameprojectsKey()logic that already namespacesstore.projectscorrectlyChecklist