fix(app): use module-level slot for TitlebarRight to fix direct session URL crash - #45357
Closed
TomKalina wants to merge 1 commit into
Closed
fix(app): use module-level slot for TitlebarRight to fix direct session URL crash#45357TomKalina wants to merge 1 commit into
TomKalina wants to merge 1 commit into
Conversation
…on URL crash
Direct navigation to /server/{key}/session/{id} routes crashes with
'TitlebarRight must be used within TitlebarRightProvider' even though
the provider is mounted. Root cause is SolidJS context propagation
across lazy-loaded route chunks: the context lookup in TitlebarRight
(session-header.tsx, in route chunk) fails to find the provider that
lives in the main chunk (shell.tsx).
Replacing createContext/useContext with a module-level singleton slot
sidesteps the issue entirely. The provider becomes a no-op wrapper for
backward compatibility. createTitlebarRightSlot is preserved as a
factory for tests.
Verified:
- Direct URL to /server/{key}/session/{id} loads session content
- Click from home page works
- Back/forward navigation works
- Newly created sessions display correctly
Refs: anomalyco#30898 (similar 'ServerSync context' report)
Contributor
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
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
Direct navigation to
/server/{key}/session/{id}routes crashes with:even though the provider is mounted. The error boundary catches it and shows "Something went wrong".
Root cause
SolidJS context propagation across lazy-loaded route chunks: the
useContextlookup inTitlebarRight(session-header.tsx, in route chunk) fails to find the provider that lives in the main chunk (shell.tsx).Verified via console logs in production build:
[Provider] mountedfires successfully in the main chunk[Mount] has slot—TitlebarRightMount(inshell.tsx, same chunk as Provider) sees the context[useSlot] context lookup: MISSING—TitlebarRight(in lazy-loadedroute-*.jschunk) cannot find the contextThis is the same class of bug as #30898 ("ServerSync context must be used within a context provider"), which is still open.
In Vite dev mode (HMR) the bug does not reproduce — context propagation works correctly there.
Fix
Replace
createContext/useContextwith a module-level singleton slot. Both the provider and consumers reference the same module-level instance, sidesteping the cross-chunk context lookup entirely.TitlebarRightProviderbecomes a no-op wrapper (kept for backward compatibility / minimal diff)createTitlebarRightSlotfactory is preserved for the existing unit testTitlebarRightMount,TitlebarRight) reference the module-levelslotdirectlyVerification
Built
opencode2v2 binary from this branch, deployed, and tested:/server/{key}/session/{id}loads session contentDiff
Single file change (
packages/app/src/shell/titlebar/right-slot.tsx):Related