Skip to content

Conversation

@OpeOginni
Copy link
Contributor

Solves Issues #4245 and #4246

The Error needed to be render better, its tough because it’s thrown before the full TUI is initialized. To solve this, I kept the error state through initialization and, instead of rendering the main app, rendered InitErrorScreen when appropriate.

Required several iterations to get the flow working.

  • Handled config/init error in sync.tsx
  • Displaying better error with options for users to exit the application (did not exist previously).
Screen.Recording.2025-11-12.at.15.12.40.mov

…nfiguration error screen

- Added a new `InitErrorScreen` component to handle and display initialization errors.
- Updated the local context to return safe dummy objects when an initialization error occurs.
- Updated the App rendering to showcase `InitErrorScreen` on Init errors allowing users to easily exit the application.
- Enhanced the sync context to capture and propagate initialization errors during data fetching.
@rekram1-node
Copy link
Collaborator

@OpeOginni when I do an invalid theme i still get this:

Error: undefined is not an object (evaluating 'c[mode]')
    at resolveColor (/Users/aidencline/development/opencode3/packages/opencode/src/cli/cmd/tui/context/theme.tsx:64:25)
    at <anonymous> (/Users/aidencline/development/opencode3/packages/opencode/src/cli/cmd/tui/context/theme.tsx:67:18)
    at map (native)
    at resolveTheme (/Users/aidencline/development/opencode3/packages/opencode/src/cli/cmd/tui/context/theme.tsx:66:57)
    at runComputation (/Users/aidencline/development/opencode3/node_modules/.bun/[email protected]/node_modules/solid-js/dist/solid.js:695:22)
    at updateComputation (/Users/aidencline/development/opencode3/node_modules/.bun/[email protected]/node_modules/solid-js/dist/solid.js:677:3)
    at readSignal (/Users/aidencline/development/opencode3/node_modules/.bun/[email protected]/node_modules/solid-js/dist/solid.js:613:67)
    at get (/Users/aidencline/development/opencode3/packages/opencode/src/cli/cmd/tui/context/theme.tsx:106:18)
    at <anonymous> (/Users/aidencline/development/opencode3/packages/opencode/src/cli/cmd/tui/ui/dialog-select.tsx:279:16)
    at runComputation (/Users/aidencline/development/opencode3/node_modules/.bun/[email protected]/node_modules/solid-js/dist/solid.js:695:22)
    at updateComputation (/Users/aidencline/development/opencode3/node_modules/.bun/[email protected]/node_modules/solid-js/dist/solid.js:677:3)
    at runTop (/Users/aidencline/development/opencode3/node_modules/.bun/[email protected]/node_modules/solid-js/dist/solid.js:784:7)
    at runUserEffects (/Users/aidencline/development/opencode3/node_modules/.bun/[email protected]/node_modules/solid-js/dist/solid.js:879:18)
    at runUpdates (/Users/aidencline/development/opencode3/node_modules/.bun/[email protected]/node_modules/solid-js/dist/solid.js:800:17)
    at completeUpdates (/Users/aidencline/development/opencode3/node_modules/.bun/[email protected]/node_modules/solid-js/dist/solid.js:851:17)
    at runUpdates (/Users/aidencline/development/opencode3/node_modules/.bun/[email protected]/node_modules/solid-js/dist/solid.js:801:5)
    at <anonymous> (/Users/aidencline/development/opencode3/packages/opencode/src/cli/cmd/tui/ui/dialog-select.tsx:146:7)
    at emit (node:events:95:22)
    at insertText (/Users/aidencline/development/opencode3/node_modules/.bun/@[email protected]+81ecd8642a1892ca/node_modules/@opentui/src/renderables/Input.ts:211:10)
    at handleKeyPress (/Users/aidencline/development/opencode3/node_modules/.bun/@[email protected]+81ecd8642a1892ca/node_modules/@opentui/src/renderables/Input.ts:278:16)
    at <anonymous> (/Users/aidencline/development/opencode3/node_modules/.bun/@[email protected]+81ecd8642a1892ca/node_modules/@opentui/src/Renderable.ts:366:14)
    at emitWithPriority (/Users/aidencline/development/opencode3/node_modules/.bun/@[email protected]+81ecd8642a1892ca/node_modules/@opentui/src/lib/KeyHandler.ts:162:9)
    at processInput (/Users/aidencline/development/opencode3/node_modules/.bun/@[email protected]+81ecd8642a1892ca/node_modules/@opentui/src/lib/KeyHandler.ts:99:14)
    at <anonymous> (/Users/aidencline/development/opencode3/node_modules/.bun/@[email protected]+81ecd8642a1892ca/node_modules/@opentui/src/renderer.ts:859:13)
    at emit (node:events:95:22)
    at process (/Users/aidencline/development/opencode3/node_modules/.bun/@[email protected]+81ecd8642a1892ca/node_modules/@opentui/src/lib/stdin-buffer.ts:338:12)
    at <anonymous> (/Users/aidencline/development/opencode3/node_modules/.bun/@[email protected]+81ecd8642a1892ca/node_modules/@opentui/src/renderer.ts:792:23)
    at emit (node:events:95:22)
    at addChunk (internal:streams/readable:264:47)
    at readableAddChunkPushByteMode (internal:streams/readable:242:18)
    at internalRead (native)
    at processTicksAndRejections (native)...

Theme:

{
  "$schema": "https://opencode.ai/theme.json",
  "defs": {
    "dark_bg": "#161617",
    "dark_fg": "#c9c7cd",
    "dark_bg_dark": "#131314",

    "dark_black": "#27272a",
    "dark_red": "#f5a191",
    "dark_green": "#adskafe",
    "dark_yellow": "#e6b99d",
    "dark_blue": "#aca1cf",
    "dark_magenta": "#e29eca",
    "dark_cyan": "#ea83a5",
    "dark_white": "#c1c0d4",

    "dark_bright_black": "#353539",
    "dark_bright_red": "#ffae9f",
    "dark_bright_green": "#9dc6ac",
    "dark_bright_yellow": "#f0c5a9",
    "dark_bright_blue": "#b9aeda",
    "dark_bright_magenta": "#ecaad6",
    "dark_bright_cyan": "#f591b2",
    "dark_bright_white": "#cac9dd",

    "dark_gray00": "#18181a",
    "dark_gray01": "#1b1b1d",
    "dark_gray02": "#2a2a2d",
    "dark_gray03": "#3e3e43",
    "dark_gray04": "#57575f",
    "dark_gray05": "#757581",
    "dark_gray06": "#9998a8",
    "dark_gray07": "#c1c0d4"
  },
  "theme": {
    "primary": "dark_cyan",
    "secondary": "dark_cyan",
    "accent": "dark_blue",
    "error": "dark_cyan",
    "warning": "dark_yellow",
    "success": "dark_green",
    "info": "dark_blue",
    "text": "dark_fg",
    "textMuted": "dark_white",
    "background": "none",
    "backgroundPanel": "dark_gray01",
    "backgroundElement": "dark_gray02",
    "border": "dark_gray02",
    "borderActive": "dark_gray01",
    "borderSubtle": "dark_gray00",
    "diffAdded": "dark_black",
    "diffRemoved": "dark_black",
    "diffContext": "a",
    "diffHunkHeader": "dark_magenta",
    "diffHighlightAdded": "dark_bright_green",
    "diffHighlightRemoved": "dark_bright_red",
    "diffAddedBg": "dark_green",
    "diffRemovedBg": "dark_red",
    "diffContextBg": "dark_gray00",
    "diffLineNumber": "diffContextBg",
    "diffAddedLineNumberBg": "dark_green",
    "diffRemovedLineNumberBg": "dark_red",
    "markdownText": "dark_fg",
    "markdownHeading": "dark_gray06",
    "markdownLink": "dark_blue",
    "markdownLinkText": "dark_cyan",
    "markdownCode": "dark_bright_green",
    "markdownBlockQuote": "dark_gray00",
    "markdownEmph": "dark_bright_yellow",
    "markdownStrong": "dark_bright_red",
    "markdownHorizontalRule": "markdownText",
    "markdownListItem": "dark_blue",
    "markdownListEnumeration": "dark_bright_blue",
    "markdownImage": "markdownLink",
    "markdownImageText": "markdownLinkText",
    "markdownCodeBlock": "dark_fg",
    "syntaxComment": "dark_gray05",
    "syntaxKeyword": "dark_blue",
    "syntaxFunction": "dark_gray07",
    "syntaxVariable": "dark_fg",
    "syntaxString": "b",
    "syntaxNumber": "dark_magenta",
    "syntaxType": "dark_magenta",
    "syntaxOperator": "dark_yellow",
    "syntaxPunctuation": "dark_gray06"
  }
}

@OpeOginni
Copy link
Contributor Author

Yeah, ill go ahead to add these types of errors in 🫡

@rekram1-node
Copy link
Collaborator

I think original issue was addressed but if you are up for it this can change to become better error handling for bad themes?

@OpeOginni
Copy link
Contributor Author

@rekram1-node Moved the new fix to another PR , this one was a bit too complex to change.

@OpeOginni OpeOginni closed this Nov 19, 2025
Sign up for free to 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.

2 participants