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
4 changes: 3 additions & 1 deletion packages/desktop/src/main/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
WslConfig,
} from "../preload/types"
import { getStore } from "./store"
import { setTitlebar } from "./windows"
import { setTitlebar, setNativeThemeSource } from "./windows"

const pickerFilters = (ext?: string[]) => {
if (!ext || ext.length === 0) return undefined
Expand All @@ -38,6 +38,7 @@ type Deps = {
checkUpdate: () => Promise<{ updateAvailable: boolean; version?: string }>
installUpdate: () => Promise<void> | void
setBackgroundColor: (color: string) => void
setNativeTheme: (mode: "light" | "dark") => void
}

export function registerIpcHandlers(deps: Deps) {
Expand Down Expand Up @@ -69,6 +70,7 @@ export function registerIpcHandlers(deps: Deps) {
ipcMain.handle("check-update", () => deps.checkUpdate())
ipcMain.handle("install-update", () => deps.installUpdate())
ipcMain.handle("set-background-color", (_event: IpcMainInvokeEvent, color: string) => deps.setBackgroundColor(color))
ipcMain.handle("set-native-theme", (_event: IpcMainInvokeEvent, mode: "light" | "dark") => setNativeThemeSource(mode))
ipcMain.handle("store-get", (_event: IpcMainInvokeEvent, name: string, key: string) => {
const store = getStore(name)
const value = store.get(key)
Expand Down
4 changes: 4 additions & 0 deletions packages/desktop/src/main/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ function overlay(theme: Partial<TitlebarTheme> = {}) {
}
}

export function setNativeThemeSource(mode: "light" | "dark") {
nativeTheme.themeSource = mode
}

export function setTitlebar(win: BrowserWindow, theme: Partial<TitlebarTheme> = {}) {
if (process.platform !== "win32") return
win.setTitleBarOverlay(overlay(theme))
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const api: ElectronAPI = {
checkUpdate: () => ipcRenderer.invoke("check-update"),
installUpdate: () => ipcRenderer.invoke("install-update"),
setBackgroundColor: (color: string) => ipcRenderer.invoke("set-background-color", color),
setNativeTheme: (mode: "light" | "dark") => ipcRenderer.invoke("set-native-theme", mode),
}

contextBridge.exposeInMainWorld("api", api)
1 change: 1 addition & 0 deletions packages/desktop/src/preload/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ export type ElectronAPI = {
checkUpdate: () => Promise<{ updateAvailable: boolean; version?: string }>
installUpdate: () => Promise<void>
setBackgroundColor: (color: string) => Promise<void>
setNativeTheme: (mode: "light" | "dark") => Promise<void>
}
3 changes: 2 additions & 1 deletion packages/desktop/src/renderer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,12 @@ render(() => {

createEffect(() => {
theme.themeId()
theme.mode()
const mode = theme.mode()
const bg = getComputedStyle(document.documentElement).getPropertyValue("--background-base").trim()
if (bg) {
void window.api.setBackgroundColor(bg)
}
void window.api.setNativeTheme(mode)
})

return null
Expand Down
21 changes: 11 additions & 10 deletions packages/opencode/src/cli/cmd/tui/component/dialog-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,9 @@ export async function runCustomProviderWizard(opts: {
const baseURL = baseURLRaw.trim()
if (!baseURL) return

const apiKeyRaw = await step(4, 6, "API key", "sk-...")
const apiKeyRaw = await step(4, 6, "API key (optional, Enter to skip)", "sk-...")
if (apiKeyRaw === null) return
const apiKey = apiKeyRaw.trim()
if (!apiKey) return

const modelIDRaw = await step(5, 6, "First model id", "e.g. claude-sonnet-4-6")
if (modelIDRaw === null) return
Expand All @@ -208,7 +207,7 @@ export async function runCustomProviderWizard(opts: {
[providerID]: {
name,
npm: "@ai-sdk/openai-compatible",
env: [envKey],
...(apiKey ? { env: [envKey] } : {}),
options: {
baseURL,
setCacheKey: true,
Expand All @@ -228,13 +227,15 @@ export async function runCustomProviderWizard(opts: {
return
}

const authRes = await sdk.client.auth.set({
providerID,
auth: { type: "api", key: apiKey },
})
if (authRes.error) {
toast.show({ variant: "error", message: JSON.stringify(authRes.error) })
return
if (apiKey) {
const authRes = await sdk.client.auth.set({
providerID,
auth: { type: "api", key: apiKey },
})
if (authRes.error) {
toast.show({ variant: "error", message: JSON.stringify(authRes.error) })
return
}
}

await sdk.client.instance.dispose()
Expand Down