Skip to content

feat: enhance theme handling with custom theme normalization and error reporting#5002

Closed
OpeOginni wants to merge 7 commits into
anomalyco:devfrom
OpeOginni:fix/ansi-theme-support
Closed

feat: enhance theme handling with custom theme normalization and error reporting#5002
OpeOginni wants to merge 7 commits into
anomalyco:devfrom
OpeOginni:fix/ansi-theme-support

Conversation

@OpeOginni

Copy link
Copy Markdown
Contributor
Screen.Recording.2025-12-03.at.00.33.19.mov

Extra for #4429

Comment on lines +342 to +352
function resolveColor(
value: ColorValue,
mode: "dark" | "light",
defs: Record<string, ColorValue>,
themeColors: Record<string, ColorValue | undefined>,
themeName: string,
): RGBA | { error: string } {
if (value instanceof RGBA) return value
if (typeof value === "string") {
if (value === "transparent" || value === "none") return RGBA.fromInts(0, 0, 0, 0)
if (value.startsWith("#")) return RGBA.fromHex(value)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code over here just seems insanely complex to me

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think updating the name of the params would reduce the complexity?

The whole function itself just tries to turn the color value from whatever is provided in the many types we allow, to the RGBA type, based on user set defs (line 345) and other set theme attributes (line 346).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure the cleanest solution but ideally we can make this follow style guide bit better, it isn't very idiomatic rn

@rekram1-node

Copy link
Copy Markdown
Collaborator

/review

Comment thread packages/opencode/src/cli/cmd/tui/context/theme.tsx
Comment thread packages/opencode/src/cli/cmd/tui/context/theme.tsx
Comment thread packages/opencode/src/cli/cmd/tui/context/theme.tsx
Comment thread packages/opencode/src/cli/cmd/tui/context/theme.tsx Outdated
Comment thread packages/opencode/src/cli/cmd/tui/context/theme.tsx
Comment thread packages/opencode/src/cli/cmd/tui/app.tsx

@OpeOginni OpeOginni left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completed Looking through Copilot Style Guide recommendation, and worked with OC on other places the code style could be improved and be a lot more idiomatic

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