Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 36 additions & 14 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/opencode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.99",
"@opentui/solid": "0.1.99",
"@opentui/core": "0.0.0-20260422-52f6ed27",
"@opentui/solid": "0.0.0-20260422-52f6ed27",
"@parcel/watcher": "2.5.1",
"@pierre/diffs": "catalog:",
"@solid-primitives/event-bus": "1.1.2",
Expand Down
8 changes: 1 addition & 7 deletions packages/opencode/src/cli/cmd/tui/app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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 {
Expand Down Expand Up @@ -120,12 +119,6 @@ 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()
Expand All @@ -136,6 +129,7 @@ export function tui(input: {
}

const renderer = await createCliRenderer(rendererConfig(input.config))
const mode = (await renderer.waitForThemeMode(1000)) ?? "dark"

await render(() => {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/opencode/src/cli/cmd/tui/context/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
setStore(
produce((draft) => {
const lock = pick(kv.get("theme_mode_lock"))
const mode = lock ?? props.mode
const mode = lock ?? pick(renderer.themeMode) ?? props.mode
if (!lock && pick(kv.get("theme_mode")) !== undefined) {
kv.set("theme_mode", undefined)
}
Expand Down
39 changes: 0 additions & 39 deletions packages/opencode/src/cli/cmd/tui/util/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ 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.
Expand Down Expand Up @@ -100,36 +94,3 @@ 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)
})
}
8 changes: 4 additions & 4 deletions packages/plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"zod": "catalog:"
},
"peerDependencies": {
"@opentui/core": ">=0.1.99",
"@opentui/solid": ">=0.1.99"
"@opentui/core": ">=0.0.0-20260422-52f6ed27",
"@opentui/solid": ">=0.0.0-20260422-52f6ed27"
},
"peerDependenciesMeta": {
"@opentui/core": {
Expand All @@ -34,8 +34,8 @@
}
},
"devDependencies": {
"@opentui/core": "0.1.99",
"@opentui/solid": "0.1.99",
"@opentui/core": "0.0.0-20260422-52f6ed27",
"@opentui/solid": "0.0.0-20260422-52f6ed27",
"@tsconfig/node22": "catalog:",
"@types/node": "catalog:",
"typescript": "catalog:",
Expand Down
Loading