fix(tui): guard server-synced store fields against null responses - #45322
Open
ofrades wants to merge 1 commit into
Open
fix(tui): guard server-synced store fields against null responses#45322ofrades wants to merge 1 commit into
ofrades wants to merge 1 commit into
Conversation
A null/undefined data field from any bootstrap endpoint (providers, agents, config, console state, MCP status) crashed the TUI with "Object.entries requires that input parameter not be null or undefined" inside a Solid.js reactive computation. Non-null assertions in the sync bootstrap propagated nulls straight into the store. - replace bootstrap `x.data!` assertions with fallback shapes so the store never receives null for object/array-typed fields - guard every Object.entries/keys/values consumer of sync.data.mcp, lsp and theme.theme with ?? fallbacks (defense-in-depth, matching the pattern of PRs anomalyco#22105/anomalyco#22206) Regression family: anomalyco#21014, anomalyco#20388, anomalyco#5151
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
|
The following comment was made by an LLM, it may be inaccurate: Found a related PR:
This PR appears to address the same crash family (Object.entries on null values). It seems like #44356 may be a prior partial fix or attempt at the same issue. You should verify whether #44356 has already been merged or if #45322 supersedes it with a more comprehensive solution. |
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
Fixes a recurring TUI crash family:
Previously reported as #21014, #20388, #5151 (v1 fixed the MCP slice via #22105 / #22206; this extends the same treatment to the remaining unguarded fields and consumers).
Type of change
What does this PR do?
During TUI bootstrap, several endpoints are read with non-null assertions (
x.data!):If any response arrives with null/undefined data (server busy, transient failure, version-mismatched background service restarting mid-bootstrap), that null is written straight into the Solid store. Every component then calling
Object.entries/Object.keys/Object.valueson it throws inside a reactive computation and kills the whole session with the "OpenCode crashed" screen.Root fix (
context/sync.tsx): replace all bootstrapx.data!assertions with fallback shapes (?? { providers: [], default: {} },?? [],?? {}, ...) so object/array-typed store fields can never receive null.Defense-in-depth at consumption sites, so even a transiently undefined store value during recomputation cannot crash:
plugin/adapters.tsxObject.entries(sync.data.mcp)→?? {}component/dialog-status.tsx?? {}routes/session/footer.tsx?? {}/?? []context/local.tsxsync.data.mcp[name]→sync.data.mcp?.[name]theme/index.tsObject.entries(theme.theme)→?? {}How did you verify your code works?
bun run typecheckinpackages/tuipasses (tsgo, no errors)oxlint packages/tui/srcreports 0 errorsbun test test/cli/cmd/tui/sync.test.tsxpassesChecklist