Skip to content

fix(tui): guard Object.entries against null MCP/theme/input - #44356

Open
pantha704 wants to merge 1 commit into
anomalyco:devfrom
pantha704:fix/tui-object-entries-null
Open

fix(tui): guard Object.entries against null MCP/theme/input#44356
pantha704 wants to merge 1 commit into
anomalyco:devfrom
pantha704:fix/tui-object-entries-null

Conversation

@pantha704

@pantha704pantha704 commented Aug 23, 2026

Copy link
Copy Markdown

Issue for this PR

Closes#44100

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

TUI dies with TypeError: Object.entries requires that input parameter not be null or undefined on 0.0.0-beta-17823 (same stack as #44100). Solid is iterating a value that is still null: theme colors, MCP status, tool input, attention sounds.

This PR passes ?? {} (or optional chaining) at those call sites, falls back to the built-in opencode theme if the active one is missing, and adds a test that resolveTheme({}) does not throw.

How did you verify your code works?

Added packages/tui/test/theme.test.ts coverage for a theme object with no theme key.

Screenshots / recordings

N/A (crash guard, no UI change).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

TUI crash: TypeError Object.entries requires that input parameter not be null or undefined.
Harden theme resolve, MCP status views, tool input formatting, and attention packs so missing objects do not take down the renderer.
@github-actionsgithub-actionsBot added needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Aug 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actionsgithub-actionsBot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Aug 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@github-actionsgithub-actionsBot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Aug 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@github-actionsgithub-actionsBot mentioned this pull request Aug 23, 2026
6 tasks
@Enough1122

Copy link
Copy Markdown

AI code review — automated review for reference, author can ignore or act on any point.

Low-risk hardening, but I'd push back on the approach: most of these guards defend an invariant that the codebase already enforces, and scattering ?? {} across consumers is the weaker fix compared to enforcing it at one place.

  1. sync.data.mcp should never be null today. The TUI store types it as a non-optional record (packages/tui/src/context/sync.tsx:166-174), initializes it to {} (sync.tsx:217), and every writer already normalizes server payloads (setStore("mcp", reconcile(x.data ?? {})) at sync.tsx:918; same for lsp at :737/:915). So what concrete runtime path produced undefined/null here? If you have a crash trace, the durable fix is at that write site (or make the type honest — mcp?: Record<...> — so tsc enumerates every consumer instead of manual auditing). Without a repro, ~20 call-site guards add noise and will drift: e.g. packages/tui/src/routes/session/footer.tsx:15 still calls Object.keys(sync.data.lsp) unguarded two lines below the newly-guarded mcp memos, and dialog-mcp.tsx stays guard-free by design.

  2. The one behavioral change deserves its own note.packages/tui/src/context/theme.tsx:266 falling back to DEFAULT_THEMES.opencode silently masks a missing/corrupted built-in theme entry instead of failing loudly; acceptable, but worth a comment since every other hunk is a pure no-op guard.

  3. Test scope (packages/tui/test/theme.test.ts:38-42): good start; also assert a color resolves from defs/fallbacks (e.g. background), since thinkingOpacity alone passes even if color resolution regressed.

Happy with #2/#3 as-is; #1 needs either a repro or a narrower scope before this lands.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TUI crash: Object.entries requires that input parameter not be null or undefined

2 participants

@pantha704@Enough1122