Skip to content

Commit e452112

Browse files
sahrizviclaude
andcommitted
fix(tui): wrap the direct-run theme changes in altimate_change markers
Marker Guard failed on #1152: theme.ts is an upstream-shared file, so custom code there must be fenced to survive an upstream merge overwriting it. The mode-aware fallback added in this branch was unmarked. Six regions are now fenced: the shared-resolver import, the per-mode seed, the memoized per-mode fallback theme, the mode probe, and both failure exits in resolveRunTheme. Verified with the same command CI runs: bun run script/upstream/analyze.ts --markers --base origin/main --strict Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent 0306bf0 commit e452112

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • packages/opencode/src/cli/cmd/run

‎packages/opencode/src/cli/cmd/run/theme.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
import { RGBA, SyntaxStyle, type CliRenderer, type ColorInput, type TerminalColors } from "@opentui/core"
99
import type { TuiThemeCurrent } from "@opencode-ai/plugin/tui"
1010
import type { EntryKind } from "./types"
11+
// altimate_change start — share the TUI's mode-resolution chain with the direct-run renderer
1112
// Shared with the full-screen TUI so both renderers agree on how a mode is chosen.
1213
import { resolveInitialMode } from "@opencode-ai/tui/terminal-detection"
14+
// altimate_change end
1315

1416
type Tone = {
1517
body: ColorInput
@@ -583,6 +585,7 @@ function map(
583585
}
584586
}
585587

588+
// altimate_change start — mode-aware fallback seed (#809: dark panel + black resolved fg)
586589
/**
587590
* Seed colours for the direct-run fallback theme.
588591
*
@@ -603,6 +606,7 @@ function fallbackSeed(mode: "dark" | "light") {
603606
error: RGBA.fromIndex(1, rgba(dark ? "#ef4444" : "#b91c1c")),
604607
}
605608
}
609+
// altimate_change end
606610

607611
function tone(body: ColorInput, start?: ColorInput): Tone {
608612
return {
@@ -615,6 +619,7 @@ const fallbackSplashIndexed = Array.from({ length: 256 }, (_, index) => RGBA.fro
615619
const fallbackSplashLeft = RGBA.fromIndex(67)
616620
const fallbackSplashRight = RGBA.fromIndex(110)
617621

622+
// altimate_change start — per-mode fallback theme; dark instance keeps identity for existing callers
618623
const fallbackByMode = new Map<"dark" | "light", RunTheme>()
619624

620625
/**
@@ -683,7 +688,9 @@ export function runThemeFallback(mode: "dark" | "light"): RunTheme {
683688

684689
/** Dark instance, kept as the default for callers with no mode to hand. */
685690
export const RUN_THEME_FALLBACK: RunTheme = runThemeFallback("dark")
691+
// altimate_change end
686692

693+
// altimate_change start — resolve a mode instead of always falling back to dark
687694
/**
688695
* Best guess at terminal mode when the palette query gives us nothing.
689696
*
@@ -698,6 +705,7 @@ function fallbackMode(renderer: CliRenderer): "dark" | "light" {
698705
osc: renderer.themeMode ?? null,
699706
})
700707
}
708+
// altimate_change end
701709

702710
export async function resolveRunTheme(renderer: CliRenderer): Promise<RunTheme> {
703711
try {
@@ -706,7 +714,9 @@ export async function resolveRunTheme(renderer: CliRenderer): Promise<RunTheme>
706714
})
707715
const bg = colors.defaultBackground ?? colors.palette[0]
708716
if (!bg) {
717+
// altimate_change start — light terminals must not get the dark fallback
709718
return runThemeFallback(fallbackMode(renderer))
719+
// altimate_change end
710720
}
711721

712722
// Palette-only terminal reloads can leave renderer.themeMode stale, but
@@ -731,6 +741,8 @@ export async function resolveRunTheme(renderer: CliRenderer): Promise<RunTheme>
731741
shared.generateSubtleSyntax(syntaxTheme),
732742
)
733743
} catch {
744+
// altimate_change start — light terminals must not get the dark fallback
734745
return runThemeFallback(fallbackMode(renderer))
746+
// altimate_change end
735747
}
736748
}

0 commit comments

Comments
 (0)