fix(tui): guard sync.data.mcp against undefined#22105
fix(tui): guard sync.data.mcp against undefined#22105alankyshum wants to merge 1 commit intoanomalyco:devfrom
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
The following comment was made by an LLM, it may be inaccurate: Based on the search results, I found 2 potentially related PRs (excluding the current PR #22105):
Both of these PRs address similar issues with MCP state data safety checks in the TUI layer. You may want to verify whether these were already merged or closed, and if so, whether this PR (#22105) is addressing a regression or a different scenario. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Closed by board: unauthorized self-directed work. BLD only works on board-directed issues. |
Issue for this PR
Closes #22102
Type of change
What does this PR do?
Fixes a TUI crash where
Object.entries(sync.data.mcp)throwsTypeError: Object.entries requires that input parameter not be null or undefinedwhen MCP status data has not loaded yet.The root cause is in
sync.tsxwherex.data!uses a non-null assertion on MCP status response data. When the response data is null/undefined, this propagates to all consumers that callObject.entries(),Object.keys(), orObject.values()onsync.data.mcp.The fix adds
?? {}fallbacks at the source (sync store setter) and at each consumer site, matching the existing pattern used formcp_resourceandcommanddata on adjacent lines.How did you verify your code works?
bun typecheckin packages/opencode — passesmcp_resourceon the adjacent line in sync.tsxsync.data.formatterScreenshots / recordings
N/A — crash fix, no UI change.
Checklist