Skip to content

Commit 5170669

Browse files
fix: restore TuiConfigProvider missing from merge with origin/main
The upstream commit `9d29d692c` (split tui/server config) introduced `TuiConfigProvider` and changed `theme.tsx` to call `useTuiConfig()`. These changes were dropped during the merge, causing the TUI to crash at startup with "TuiConfig context must be used within a context provider". - `app.tsx`: add `TuiConfigProvider` import, `TuiConfig.Info` to `tui()` signature, and wrap the provider tree with `<TuiConfigProvider>` - `thread.ts`: load `TuiConfig` via `Instance.provide()` and pass `config` + `directory` to `tui()` - `attach.ts`: same — load `TuiConfig` and pass `config` to `tui()` Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 759239a commit 5170669

3 files changed

Lines changed: 50 additions & 29 deletions

File tree

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import { ArgsProvider, useArgs, type Args } from "./context/args"
3838
import open from "open"
3939
import { writeHeapSnapshot } from "v8"
4040
import { PromptRefProvider, usePromptRef } from "./context/prompt"
41+
import { TuiConfigProvider } from "./context/tui-config"
42+
import { TuiConfig } from "@/config/tui"
4143

4244
async function getTerminalBackgroundColor(): Promise<"dark" | "light"> {
4345
// can't set raw mode if not a TTY
@@ -104,6 +106,7 @@ import type { EventSource } from "./context/sdk"
104106
export function tui(input: {
105107
url: string
106108
args: Args
109+
config: TuiConfig.Info
107110
directory?: string
108111
fetch?: typeof fetch
109112
headers?: RequestInit["headers"]
@@ -138,35 +141,37 @@ export function tui(input: {
138141
<KVProvider>
139142
<ToastProvider>
140143
<RouteProvider>
141-
<SDKProvider
142-
url={input.url}
143-
directory={input.directory}
144-
fetch={input.fetch}
145-
headers={input.headers}
146-
events={input.events}
147-
>
148-
<SyncProvider>
149-
<ThemeProvider mode={mode}>
150-
<LocalProvider>
151-
<KeybindProvider>
152-
<PromptStashProvider>
153-
<DialogProvider>
154-
<CommandProvider>
155-
<FrecencyProvider>
156-
<PromptHistoryProvider>
157-
<PromptRefProvider>
158-
<App />
159-
</PromptRefProvider>
160-
</PromptHistoryProvider>
161-
</FrecencyProvider>
162-
</CommandProvider>
163-
</DialogProvider>
164-
</PromptStashProvider>
165-
</KeybindProvider>
166-
</LocalProvider>
167-
</ThemeProvider>
168-
</SyncProvider>
169-
</SDKProvider>
144+
<TuiConfigProvider config={input.config}>
145+
<SDKProvider
146+
url={input.url}
147+
directory={input.directory}
148+
fetch={input.fetch}
149+
headers={input.headers}
150+
events={input.events}
151+
>
152+
<SyncProvider>
153+
<ThemeProvider mode={mode}>
154+
<LocalProvider>
155+
<KeybindProvider>
156+
<PromptStashProvider>
157+
<DialogProvider>
158+
<CommandProvider>
159+
<FrecencyProvider>
160+
<PromptHistoryProvider>
161+
<PromptRefProvider>
162+
<App />
163+
</PromptRefProvider>
164+
</PromptHistoryProvider>
165+
</FrecencyProvider>
166+
</CommandProvider>
167+
</DialogProvider>
168+
</PromptStashProvider>
169+
</KeybindProvider>
170+
</LocalProvider>
171+
</ThemeProvider>
172+
</SyncProvider>
173+
</SDKProvider>
174+
</TuiConfigProvider>
170175
</RouteProvider>
171176
</ToastProvider>
172177
</KVProvider>

packages/opencode/src/cli/cmd/tui/attach.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { cmd } from "../cmd"
22
import { UI } from "@/cli/ui"
33
import { tui } from "./app"
44
import { win32DisableProcessedInput, win32InstallCtrlCGuard } from "./win32"
5+
import { TuiConfig } from "@/config/tui"
6+
import { Instance } from "@/project/instance"
7+
import { existsSync } from "fs"
58

69
export const AttachCommand = cmd({
710
command: "attach <url>",
@@ -63,8 +66,13 @@ export const AttachCommand = cmd({
6366
const auth = `Basic ${Buffer.from(`altimate:${password}`).toString("base64")}`
6467
return { Authorization: auth }
6568
})()
69+
const config = await Instance.provide({
70+
directory: directory && existsSync(directory) ? directory : process.cwd(),
71+
fn: () => TuiConfig.get(),
72+
})
6673
await tui({
6774
url: args.url,
75+
config,
6876
args: {
6977
continue: args.continue,
7078
sessionID: args.session,

packages/opencode/src/cli/cmd/tui/thread.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { Filesystem } from "@/util/filesystem"
1212
import type { Event } from "@opencode-ai/sdk/v2"
1313
import type { EventSource } from "./context/sdk"
1414
import { win32DisableProcessedInput, win32InstallCtrlCGuard } from "./win32"
15+
import { TuiConfig } from "@/config/tui"
16+
import { Instance } from "@/project/instance"
1517

1618
declare global {
1719
const OPENCODE_WORKER_PATH: string
@@ -135,6 +137,10 @@ export const TuiThreadCommand = cmd({
135137
if (!args.prompt) return piped
136138
return piped ? piped + "\n" + args.prompt : args.prompt
137139
})
140+
const config = await Instance.provide({
141+
directory: cwd,
142+
fn: () => TuiConfig.get(),
143+
})
138144

139145
// Check if server should be started (port or hostname explicitly set in CLI or config)
140146
const networkOpts = await resolveNetworkOptions(args)
@@ -163,6 +169,8 @@ export const TuiThreadCommand = cmd({
163169

164170
const tuiPromise = tui({
165171
url,
172+
config,
173+
directory: cwd,
166174
fetch: customFetch,
167175
events,
168176
args: {

0 commit comments

Comments
 (0)