Skip to content

Commit 2ac9842

Browse files
Merge pull request #42 from reddb-io/afk/38-adopt-the-reddb-brand-focus-across-the-r
resume: #38
2 parents 4d3a72a + 7c4091e commit 2ac9842

9 files changed

Lines changed: 166 additions & 52 deletions

File tree

‎.changeset/redcode-focus-theme.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"opencode": minor
3+
---
4+
5+
Add the RedDB-derived Redcode TUI theme as the default while preserving the legacy OpenCode theme as an explicit option.

‎packages/opencode/test/cli/run/run-process.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,20 @@ describe("opencode run (non-interactive subprocess)", () => {
6565
// Regression for #27371: an unknown model used to hang the process forever
6666
// waiting on a session.status === idle event that never arrived. The fix
6767
// makes the SDK call surface an error promptly so the process exits nonzero.
68-
// We assert nonzero exit AND wall-clock under the harness timeout — a hang
69-
// would expire the timeout and produce a different (signal-killed) failure.
68+
// We assert nonzero exit without hitting the harness timeout — a hang would
69+
// expire the timeout and produce a different (signal-killed) failure.
7070
cliIt.concurrent(
7171
"exits nonzero promptly when the model is unknown (regression for #27371)",
7272
({ opencode }) =>
7373
Effect.gen(function* () {
7474
const result = yield* opencode.run("say hi", {
7575
model: "test/nonexistent-model",
76-
timeoutMs: 15_000,
76+
timeoutMs: 30_000,
7777
})
7878
expect(result.exitCode).not.toBe(0)
79-
expect(result.durationMs).toBeLessThan(15_000)
79+
expect(result.timedOut).toBe(false)
8080
}),
81-
30_000,
81+
45_000,
8282
)
8383

8484
// The test provider's SSE error item is interpreted by the SDK as an unknown

‎packages/opencode/test/lib/cli-process.ts‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export type RunResult = {
8282
readonly stdout: string
8383
readonly stderr: string
8484
readonly durationMs: number
85+
readonly timedOut: boolean
8586
}
8687

8788
export type RunHandle = {
@@ -228,23 +229,28 @@ export function withCliFixture<A, E>(
228229
// Catch AppProcessError (timeout OR spawn failure) and synthesize a
229230
// non-zero result so the test sees it via the usual `expectExit`
230231
// path rather than as an unhandled Effect failure.
231-
const result = yield* appProc.run(command, { timeout: Duration.millis(timeoutMs) }).pipe(
232+
const outcome = yield* appProc.run(command, { timeout: Duration.millis(timeoutMs) }).pipe(
233+
Effect.map((result) => ({ result, timedOut: false })),
232234
Effect.catchTag("AppProcessError", (err) =>
233235
Effect.succeed({
234-
command: err.command,
235-
exitCode: err.exitCode ?? -1,
236-
stdout: Buffer.alloc(0),
237-
stderr: Buffer.from((err.stderr ?? String(err.cause ?? err.message)) + "\n"),
238-
stdoutTruncated: false,
239-
stderrTruncated: false,
240-
} satisfies AppProcess.RunResult),
236+
result: {
237+
command: err.command,
238+
exitCode: err.exitCode ?? -1,
239+
stdout: Buffer.alloc(0),
240+
stderr: Buffer.from((err.stderr ?? String(err.cause ?? err.message)) + "\n"),
241+
stdoutTruncated: false,
242+
stderrTruncated: false,
243+
} satisfies AppProcess.RunResult,
244+
timedOut: err.cause instanceof Error && err.cause.message === "Timed out",
245+
}),
241246
),
242247
)
243248
return {
244-
exitCode: result.exitCode,
245-
stdout: normalizeLines(result.stdout.toString()),
246-
stderr: normalizeLines(result.stderr.toString()),
249+
exitCode: outcome.result.exitCode,
250+
stdout: normalizeLines(outcome.result.stdout.toString()),
251+
stderr: normalizeLines(outcome.result.stderr.toString()),
247252
durationMs: Date.now() - start,
253+
timedOut: outcome.timedOut,
248254
}
249255
})
250256

@@ -307,6 +313,7 @@ export function withCliFixture<A, E>(
307313
stdout: normalizeLines(await stdout),
308314
stderr: normalizeLines(await stderr),
309315
durationMs: Date.now() - start,
316+
timedOut: false,
310317
})),
311318
} satisfies RunHandle
312319
})

‎packages/tui/src/component/prompt/index.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ export function Prompt(props: PromptProps) {
13061306
() => !!local.agent.current() && store.mode === "normal" && showVariant(),
13071307
animationsEnabled,
13081308
)
1309-
const borderHighlight = createMemo(() => tint(theme.border, highlight(), agentMetaAlpha()))
1309+
const borderHighlight = createMemo(() => tint(theme.border, theme.borderActive, agentMetaAlpha()))
13101310

13111311
const placeholderText = createMemo(() => {
13121312
if (props.showPlaceholder === false) return undefined
@@ -1328,13 +1328,15 @@ export function Prompt(props: PromptProps) {
13281328
return {
13291329
frames: createFrames({
13301330
color,
1331+
headColor: theme.accent,
13311332
style: "blocks",
13321333
inactiveFactor: 0.6,
13331334
// enableFading: false,
13341335
minAlpha: 0.3,
13351336
}),
13361337
color: createColors({
13371338
color,
1339+
headColor: theme.accent,
13381340
style: "blocks",
13391341
inactiveFactor: 0.6,
13401342
// enableFading: false,
@@ -1431,13 +1433,13 @@ export function Prompt(props: PromptProps) {
14311433
setTimeout(() => {
14321434
// setTimeout is a workaround and needs to be addressed properly
14331435
if (!input || input.isDestroyed) return
1434-
input.cursorColor = theme.text
1436+
input.cursorColor = props.disabled ? theme.backgroundElement : theme.borderActive
14351437
if (tuiConfig.cursor) input.cursorStyle = tuiConfig.cursor
14361438
}, 0)
14371439
}}
14381440
onMouseDown={(r: MouseEvent) => r.target?.focus()}
14391441
focusedBackgroundColor={theme.backgroundElement}
1440-
cursorColor={props.disabled ? theme.backgroundElement : theme.text}
1442+
cursorColor={props.disabled ? theme.backgroundElement : theme.borderActive}
14411443
cursorStyle={tuiConfig.cursor}
14421444
syntaxStyle={syntax()}
14431445
/>

‎packages/tui/src/context/theme.tsx‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { CliRenderEvents, SyntaxStyle, type TerminalColors } from "@opentui/core"
22
import { useRenderer } from "@opentui/solid"
33
import {
4+
DEFAULT_THEME,
45
DEFAULT_THEMES,
56
addTheme,
67
allThemes,
@@ -61,6 +62,7 @@ export async function discoverThemes(directories: string[]) {
6162
}
6263

6364
export {
65+
DEFAULT_THEME,
6466
DEFAULT_THEMES,
6567
addTheme,
6668
allThemes,
@@ -93,7 +95,7 @@ const [store, setStore] = createStore<State>({
9395
themes: allThemes(),
9496
mode: "dark",
9597
lock: undefined,
96-
active: "opencode",
98+
active: DEFAULT_THEME,
9799
ready: false,
98100
})
99101

@@ -118,8 +120,8 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
118120
if (!lock && pick(kv.get("theme_mode")) !== undefined) kv.set("theme_mode", undefined)
119121
draft.mode = mode
120122
draft.lock = lock
121-
const active = config.theme ?? kv.get("theme", "opencode")
122-
draft.active = typeof active === "string" ? active : "opencode"
123+
const active = config.theme ?? kv.get("theme", DEFAULT_THEME)
124+
draft.active = typeof active === "string" ? active : DEFAULT_THEME
123125
draft.ready = false
124126
}),
125127
)
@@ -140,7 +142,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
140142
}, {}),
141143
)
142144
})
143-
.catch(() => setStore("active", "opencode"))
145+
.catch(() => setStore("active", DEFAULT_THEME))
144146
}
145147

146148
onMount(() => {
@@ -159,7 +161,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
159161
if (!colors.palette[0]) {
160162
if (hasResolvedSystemTheme) return
161163
setSystemTheme(undefined)
162-
if (store.active === "system") setStore("active", "opencode")
164+
if (store.active === "system") setStore("active", DEFAULT_THEME)
163165
return
164166
}
165167
const next = store.lock ?? terminalMode(colors) ?? mode
@@ -174,7 +176,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
174176
.catch(() => {
175177
if (hasResolvedSystemTheme) return
176178
setSystemTheme(undefined)
177-
if (store.active === "system") setStore("active", "opencode")
179+
if (store.active === "system") setStore("active", DEFAULT_THEME)
178180
})
179181
}
180182

@@ -263,7 +265,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
263265
if (theme) return resolveTheme(theme, store.mode)
264266
}
265267

266-
return resolveTheme(store.themes.opencode, store.mode)
268+
return resolveTheme(store.themes[DEFAULT_THEME]!, store.mode)
267269
})
268270

269271
createEffect(() => renderer.setBackgroundColor(values().background))
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"provenance": {
4+
"repository": "https://github.com/reddb-io/brand",
5+
"revision": "8f9c1da8d807c206dac86d618f7c50eabe7b2298",
6+
"source": "tokens/tokens.json"
7+
},
8+
"color": {
9+
"red": {
10+
"400": "#ff6389",
11+
"500": "#ff2056",
12+
"600": "#d11a46",
13+
"700": "#ad163a"
14+
},
15+
"neutral": {
16+
"50": "#f4f5f7",
17+
"950": "#07080a"
18+
}
19+
}
20+
}

‎packages/tui/src/theme/index.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import nightowl from "./assets/nightowl.json" with { type: "json" }
2222
import nord from "./assets/nord.json" with { type: "json" }
2323
import onedark from "./assets/one-dark.json" with { type: "json" }
2424
import opencode from "./assets/opencode.json" with { type: "json" }
25+
import reddbTokens from "./assets/reddb-tokens.json" with { type: "json" }
2526
import orng from "./assets/orng.json" with { type: "json" }
2627
import osakaJade from "./assets/osaka-jade.json" with { type: "json" }
2728
import palenight from "./assets/palenight.json" with { type: "json" }
@@ -127,6 +128,37 @@ export type ThemeJson = {
127128
}
128129
}
129130

131+
const redcode: ThemeJson = {
132+
...opencode,
133+
defs: {
134+
...opencode.defs,
135+
reddbRed400: reddbTokens.color.red["400"],
136+
reddbRed500: reddbTokens.color.red["500"],
137+
reddbRed600: reddbTokens.color.red["600"],
138+
reddbRed700: reddbTokens.color.red["700"],
139+
reddbInk: reddbTokens.color.neutral["950"],
140+
reddbPaper: reddbTokens.color.neutral["50"],
141+
},
142+
theme: {
143+
...opencode.theme,
144+
primary: "reddbRed500",
145+
secondary: "reddbRed500",
146+
accent: "reddbRed400",
147+
selectedListItemText: "reddbInk",
148+
borderActive: "reddbRed600",
149+
text: {
150+
dark: "reddbPaper",
151+
light: "reddbInk",
152+
},
153+
markdownLink: {
154+
dark: "reddbRed400",
155+
light: "reddbRed700",
156+
},
157+
},
158+
}
159+
160+
export const DEFAULT_THEME = "redcode"
161+
130162
export const DEFAULT_THEMES: Record<string, ThemeJson> = {
131163
aura,
132164
ayu,
@@ -150,6 +182,7 @@ export const DEFAULT_THEMES: Record<string, ThemeJson> = {
150182
["one-dark"]: onedark,
151183
["osaka-jade"]: osakaJade,
152184
opencode,
185+
redcode,
153186
orng,
154187
["lucent-orng"]: lucentOrng,
155188
palenight,

‎packages/tui/src/ui/spinner.ts‎

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ export interface KnightRiderOptions {
253253
colors?: ColorInput[]
254254
/** Single color to derive trail from (alternative to providing colors array) */
255255
color?: ColorInput
256+
/** Optional luminous head color while the trail remains derived from color */
257+
headColor?: ColorInput
256258
/** Number of trail steps when using single color (default: 6) */
257259
trailSteps?: number
258260
defaultColor?: ColorInput
@@ -264,6 +266,26 @@ export interface KnightRiderOptions {
264266
minAlpha?: number
265267
}
266268

269+
function trailColors(options: KnightRiderOptions) {
270+
if (options.colors) return options.colors
271+
if (options.color) {
272+
const colors = deriveTrailColors(options.color, options.trailSteps)
273+
if (!options.headColor) return colors
274+
return [
275+
options.headColor instanceof RGBA ? options.headColor : RGBA.fromHex(options.headColor as string),
276+
...colors.slice(1),
277+
]
278+
}
279+
return [
280+
RGBA.fromHex("#ff0000"),
281+
RGBA.fromHex("#ff5555"),
282+
RGBA.fromHex("#dd0000"),
283+
RGBA.fromHex("#aa0000"),
284+
RGBA.fromHex("#770000"),
285+
RGBA.fromHex("#440000"),
286+
]
287+
}
288+
267289
/**
268290
* Creates frame strings for a Knight Rider style scanner animation
269291
* @param options Configuration options for the Knight Rider effect
@@ -275,18 +297,7 @@ export function createFrames(options: KnightRiderOptions = {}): string[] {
275297
const holdStart = options.holdStart ?? 30
276298
const holdEnd = options.holdEnd ?? 9
277299

278-
const colors =
279-
options.colors ??
280-
(options.color
281-
? deriveTrailColors(options.color, options.trailSteps)
282-
: [
283-
RGBA.fromHex("#ff0000"), // Brightest Red (Center)
284-
RGBA.fromHex("#ff5555"), // Glare/Bloom
285-
RGBA.fromHex("#dd0000"), // Trail 1
286-
RGBA.fromHex("#aa0000"), // Trail 2
287-
RGBA.fromHex("#770000"), // Trail 3
288-
RGBA.fromHex("#440000"), // Trail 4
289-
])
300+
const colors = trailColors(options)
290301

291302
const defaultColor =
292303
options.defaultColor ??
@@ -337,18 +348,7 @@ export function createColors(options: KnightRiderOptions = {}): ColorGenerator {
337348
const holdStart = options.holdStart ?? 30
338349
const holdEnd = options.holdEnd ?? 9
339350

340-
const colors =
341-
options.colors ??
342-
(options.color
343-
? deriveTrailColors(options.color, options.trailSteps)
344-
: [
345-
RGBA.fromHex("#ff0000"), // Brightest Red (Center)
346-
RGBA.fromHex("#ff5555"), // Glare/Bloom
347-
RGBA.fromHex("#dd0000"), // Trail 1
348-
RGBA.fromHex("#aa0000"), // Trail 2
349-
RGBA.fromHex("#770000"), // Trail 3
350-
RGBA.fromHex("#440000"), // Trail 4
351-
])
351+
const colors = trailColors(options)
352352

353353
const defaultColor =
354354
options.defaultColor ??

0 commit comments

Comments
 (0)