-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Description
Hallo, I believe I found a bug that affects switching to themes using ANSI color indexes in the defs block (like 0-15 numbers, as per the OpenCode docs and theme schema).
I created a custom theme according to the documentation, referencing ANSI indexes inside the defs and using those in the rest of the theme. The theme is accepted by the schema and matches the docs' requirements for terminal support. However, as soon as I switch to this theme in the tui, OpenCode crashes immediately with the following error:
A fatal error occurred! Reset TUI Exit
TypeError: undefined is not an object (evaluating 'c3[mode2]')
at resolveColor (src/cli/cmd/tui/context/theme.tsx:69:25)
at <anonymous> (src/cli/cmd/tui/context/theme.tsx:72:18)
at map (native:1:11)
at resolveTheme (src/cli/cmd/tui/context/theme.tsx:71:57)
at runComputation (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:742:22)
at updateComputation (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:724:3)
at runTop (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:833:7)
at runQueue (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:904:42)
at completeUpdates (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:860:84)
at runUpdates (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:850:5)
at setStore (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/store/dist/dev.js:221:5)
at set (src/cli/cmd/tui/context/theme.tsx:128:9)
at onMove (src/cli/cmd/tui/component/dialog-theme-list.tsx:26:13)
at moveTo (src/cli/cmd/tui/ui/dialog-select.tsx:64:11)
at move (src/cli/cmd/tui/ui/dialog-select.tsx:60:5)
at <anonymous> (src/cli/cmd/tui/ui/dialog-select.tsx:83:62)
at emit (node:events:95:22)
at emitWithPriority (../../node_modules/.bun/@opentui+core@0.1.42+81ecd8642a1892ca/node_modules/@opentui/core/index-y49e47t2.js:2353:38)
at processInput (../../node_modules/.bun/@opentui+core@0.1.42+81ecd8642a1892ca/node_modules/@opentui/core/index-y49e47t2.js:2315:14)
at <anonymous> (../../node_modules/.bun/@opentui+core@0.1.42+81ecd8642a1892ca/node_modules/@opentui/core/index-y49e47t2.js:13549:13)
at emit (node:events:95:22)
at process (../../node_modules/.bun/@opentui+core@0.1.42+81ecd8642a1892ca/node_modules/@opentui/core/index-y49e47t2.js:4617:12)
at <anonymous> (../../node_modules/.bun/@opentui+core@0.1.42+81ecd8642a1892ca/node_modules/@opentui/core/index-y49e47t2.js:13491:23)
at emit (node:events:95:22)
at addChunk (internal:streams/readable:264:47)
at readableAddChunkPushByteMode (internal:streams/readable:242:18)
at internalRead (native:38:40)
at processTicksAndRejections (native:7:39)
undefined is not an object (evaluating 'c3[mode2]')
Switching back to official or other string-based themes works as expected, so it appears related to the use of numeric indexes.
If you require my theme JSON or other technical info, I am happy to provide.
Best!
OpenCode version
1.0.68
Steps to reproduce
- Create a theme using numbers (ANSI indexes) as values in the defs section, per the OpenCode docs (https://opencode.ai/docs/themes/#terminal-requirements)
- Enable or switch to that theme in the tui (OpenCode terminal interface)
- OpenCode instantly crashes (terminal window closes)
- Switching back to a theme with only string values in defs, everything works again.
Here's my theme:
{
"$schema": "https://opencode.ai/theme.json",
"defs": {
"base03": 8,
"base02": 0,
"base01": 10,
"base00": 11,
"base0": 12,
"base1": 14,
"base2": 7,
"base3": 15,
"yellow": 3,
"orange": 9,
"red": 1,
"magenta": 5,
"violet": 13,
"blue": 4,
"cyan": 6,
"green": 2
},
"theme": {
"primary": {
"dark": "blue",
"light": "blue"
},
"secondary": {
"dark": "violet",
"light": "violet"
},
"accent": {
"dark": "cyan",
"light": "cyan"
},
"error": {
"dark": "red",
"light": "red"
},
"warning": {
"dark": "yellow",
"light": "yellow"
},
"success": {
"dark": "green",
"light": "green"
},
"info": {
"dark": "orange",
"light": "orange"
},
"text": {
"dark": "base0",
"light": "base00"
},
"textMuted": {
"dark": "base01",
"light": "base1"
},
"background": {
"dark": "base03",
"light": "base3"
},
"backgroundPanel": {
"dark": "base02",
"light": "base2"
},
"backgroundElement": {
"dark": "black",
"light": "white"
},
"border": {
"dark": "base02",
"light": "base2"
},
"borderActive": {
"dark": "base01",
"light": "base1"
},
"borderSubtle": {
"dark": "black",
"light": "white"
},
"diffAdded": {
"dark": "green",
"light": "green"
},
"diffRemoved": {
"dark": "red",
"light": "red"
},
"diffContext": {
"dark": "base01",
"light": "base1"
},
"diffHunkHeader": {
"dark": "base01",
"light": "base1"
},
"diffHighlightAdded": {
"dark": "green",
"light": "green"
},
"diffHighlightRemoved": {
"dark": "red",
"light": "red"
},
"diffAddedBg": {
"dark": "black",
"light": "white"
},
"diffRemovedBg": {
"dark": "black",
"light": "white"
},
"diffContextBg": {
"dark": "base02",
"light": "base2"
},
"diffLineNumber": {
"dark": "base01",
"light": "base1"
},
"diffAddedLineNumberBg": {
"dark": "black",
"light": "white"
},
"diffRemovedLineNumberBg": {
"dark": "black",
"light": "white"
},
"markdownText": {
"dark": "base0",
"light": "base00"
},
"markdownHeading": {
"dark": "blue",
"light": "blue"
},
"markdownLink": {
"dark": "cyan",
"light": "cyan"
},
"markdownLinkText": {
"dark": "violet",
"light": "violet"
},
"markdownCode": {
"dark": "green",
"light": "green"
},
"markdownBlockQuote": {
"dark": "base01",
"light": "base1"
},
"markdownEmph": {
"dark": "yellow",
"light": "yellow"
},
"markdownStrong": {
"dark": "orange",
"light": "orange"
},
"markdownHorizontalRule": {
"dark": "base01",
"light": "base1"
},
"markdownListItem": {
"dark": "blue",
"light": "blue"
},
"markdownListEnumeration": {
"dark": "cyan",
"light": "cyan"
},
"markdownImage": {
"dark": "cyan",
"light": "cyan"
},
"markdownImageText": {
"dark": "violet",
"light": "violet"
},
"markdownCodeBlock": {
"dark": "base0",
"light": "base00"
},
"syntaxComment": {
"dark": "base01",
"light": "base1"
},
"syntaxKeyword": {
"dark": "green",
"light": "green"
},
"syntaxFunction": {
"dark": "blue",
"light": "blue"
},
"syntaxVariable": {
"dark": "cyan",
"light": "cyan"
},
"syntaxString": {
"dark": "cyan",
"light": "cyan"
},
"syntaxNumber": {
"dark": "magenta",
"light": "magenta"
},
"syntaxType": {
"dark": "yellow",
"light": "yellow"
},
"syntaxOperator": {
"dark": "green",
"light": "green"
},
"syntaxPunctuation": {
"dark": "base0",
"light": "base00"
}
}
}Screenshot and/or share link
Operating System
macOS
Terminal
Alacritty 256-color
