summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2026-04-21 12:08:12 -0400
committerGitHub <[email protected]>2026-04-21 12:08:12 -0400
commite95474df05d7054f905dc9294148e5e425f2e656 (patch)
tree2b5b90f7864faac6cc6b45e73f2627febd6c25d7 /packages
parent96a534d8c639db794012281b5419e727df538e97 (diff)
downloadopencode-e95474df05d7054f905dc9294148e5e425f2e656.tar.gz
opencode-e95474df05d7054f905dc9294148e5e425f2e656.zip
fix: revert parts of a824064c4 which caused system theme regression (#23714)
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/package.json4
-rw-r--r--packages/opencode/src/cli/cmd/tui/app.tsx8
-rw-r--r--packages/opencode/src/cli/cmd/tui/util/terminal.ts39
-rw-r--r--packages/plugin/package.json8
4 files changed, 52 insertions, 7 deletions
diff --git a/packages/opencode/package.json b/packages/opencode/package.json
index 5d8fd4b54..199f4b215 100644
--- a/packages/opencode/package.json
+++ b/packages/opencode/package.json
@@ -123,8 +123,8 @@
"@opentelemetry/exporter-trace-otlp-http": "0.214.0",
"@opentelemetry/sdk-trace-base": "2.6.1",
"@opentelemetry/sdk-trace-node": "2.6.1",
- "@opentui/core": "0.1.101",
- "@opentui/solid": "0.1.101",
+ "@opentui/core": "0.1.99",
+ "@opentui/solid": "0.1.99",
"@parcel/watcher": "2.5.1",
"@pierre/diffs": "catalog:",
"@solid-primitives/event-bus": "1.1.2",
diff --git a/packages/opencode/src/cli/cmd/tui/app.tsx b/packages/opencode/src/cli/cmd/tui/app.tsx
index 5da2740cc..2b31d078c 100644
--- a/packages/opencode/src/cli/cmd/tui/app.tsx
+++ b/packages/opencode/src/cli/cmd/tui/app.tsx
@@ -1,6 +1,7 @@
import { render, TimeToFirstDraw, useKeyboard, useRenderer, useTerminalDimensions } from "@opentui/solid"
import * as Clipboard from "@tui/util/clipboard"
import * as Selection from "@tui/util/selection"
+import * as Terminal from "@tui/util/terminal"
import { createCliRenderer, MouseButton, type CliRendererConfig } from "@opentui/core"
import { RouteProvider, useRoute } from "@tui/context/route"
import {
@@ -119,6 +120,12 @@ export function tui(input: {
const unguard = win32InstallCtrlCGuard()
win32DisableProcessedInput()
+ const mode = await Terminal.getTerminalBackgroundColor()
+
+ // Re-clear after getTerminalBackgroundColor() because setRawMode(false)
+ // restores the original console mode, including processed input on Windows.
+ win32DisableProcessedInput()
+
const onExit = async () => {
unguard?.()
resolve()
@@ -129,7 +136,6 @@ export function tui(input: {
}
const renderer = await createCliRenderer(rendererConfig(input.config))
- const mode = (await renderer.waitForThemeMode(1000)) ?? "dark"
await render(() => {
return (
diff --git a/packages/opencode/src/cli/cmd/tui/util/terminal.ts b/packages/opencode/src/cli/cmd/tui/util/terminal.ts
index c026b7381..a61390f2c 100644
--- a/packages/opencode/src/cli/cmd/tui/util/terminal.ts
+++ b/packages/opencode/src/cli/cmd/tui/util/terminal.ts
@@ -17,6 +17,12 @@ function parse(color: string): RGBA | null {
return null
}
+function mode(background: RGBA | null): "dark" | "light" {
+ if (!background) return "dark"
+ const luminance = (0.299 * background.r + 0.587 * background.g + 0.114 * background.b) / 255
+ return luminance > 0.5 ? "light" : "dark"
+}
+
/**
* Query terminal colors including background, foreground, and palette (0-15).
* Uses OSC escape sequences to retrieve actual terminal color values.
@@ -94,3 +100,36 @@ export async function colors(): Promise<{
}, 1000)
})
}
+
+// Keep startup mode detection separate from `colors()`: the TUI boot path only
+// needs OSC 11 and should resolve on the first background response instead of
+// waiting on the full palette query used by system theme generation.
+export async function getTerminalBackgroundColor(): Promise<"dark" | "light"> {
+ if (!process.stdin.isTTY) return "dark"
+
+ return new Promise((resolve) => {
+ let timeout: NodeJS.Timeout
+
+ const cleanup = () => {
+ process.stdin.setRawMode(false)
+ process.stdin.removeListener("data", handler)
+ clearTimeout(timeout)
+ }
+
+ const handler = (data: Buffer) => {
+ const match = data.toString().match(/\x1b]11;([^\x07\x1b]+)/)
+ if (!match) return
+ cleanup()
+ resolve(mode(parse(match[1])))
+ }
+
+ process.stdin.setRawMode(true)
+ process.stdin.on("data", handler)
+ process.stdout.write("\x1b]11;?\x07")
+
+ timeout = setTimeout(() => {
+ cleanup()
+ resolve("dark")
+ }, 1000)
+ })
+}
diff --git a/packages/plugin/package.json b/packages/plugin/package.json
index 110d6a091..231d16e5e 100644
--- a/packages/plugin/package.json
+++ b/packages/plugin/package.json
@@ -22,8 +22,8 @@
"zod": "catalog:"
},
"peerDependencies": {
- "@opentui/core": ">=0.1.101",
- "@opentui/solid": ">=0.1.101"
+ "@opentui/core": ">=0.1.99",
+ "@opentui/solid": ">=0.1.99"
},
"peerDependenciesMeta": {
"@opentui/core": {
@@ -34,8 +34,8 @@
}
},
"devDependencies": {
- "@opentui/core": "0.1.101",
- "@opentui/solid": "0.1.101",
+ "@opentui/core": "0.1.99",
+ "@opentui/solid": "0.1.99",
"@tsconfig/node22": "catalog:",
"@types/node": "catalog:",
"typescript": "catalog:",