refactor(tui): simplify config context

This commit is contained in:
Dax Raad 2026-07-12 17:12:19 -04:00
commit f8f8cc9546
27 changed files with 135 additions and 142 deletions

View file

@ -6,12 +6,12 @@ import { Global } from "@opencode-ai/core/global"
import { readJson, writeJsonAtomic } from "../util/persistence"
import { useTuiPaths } from "./runtime"
import path from "path"
import { useTuiConfigOptional, type TuiConfig } from "../config"
import { useConfigOptional, type Config } from "../config"
export const { use: useKV, provider: KVProvider } = createSimpleContext({
name: "KV",
init: (props: { config?: TuiConfig.Info }) => {
const config = props.config ?? useTuiConfigOptional()
init: (props: { config?: Config.Info }) => {
const config = props.config ?? useConfigOptional()?.data
const paths = useTuiPaths()
void Global.Path.state
const file = path.join(paths.state, "kv.json")
@ -80,7 +80,7 @@ export const { use: useKV, provider: KVProvider } = createSimpleContext({
},
})
function configValues(config: TuiConfig.Info) {
function configValues(config: Config.Info) {
const values: Record<string, any> = {}
if (config.theme?.name !== undefined) values.theme = config.theme.name
if (config.theme?.mode !== undefined) {

View file

@ -23,7 +23,7 @@ import { createEffect, createMemo, onCleanup, onMount } from "solid-js"
import { createStore, produce } from "solid-js/store"
import { createSimpleContext } from "./helper"
import { useKV } from "./kv"
import { useTuiConfig } from "../config"
import { useConfig } from "../config"
import { Global } from "@opencode-ai/core/global"
import { Glob } from "@opencode-ai/core/util/glob"
import { readFile } from "node:fs/promises"
@ -103,7 +103,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
name: "Theme",
init: (props: { mode: "dark" | "light"; source?: ThemeSource }) => {
const renderer = useRenderer()
const config = useTuiConfig()
const config = useConfig().data
const kv = useKV()
const themes = props.source ?? themeSource
const pick = (value: unknown) => {