Skip to content

Commit f3513ba

Browse files
committed
tui: fix model state persistence when model store is not ready
1 parent 3aff88c commit f3513ba

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • packages/opencode/src/cli/cmd/tui/context

packages/opencode/src/cli/cmd/tui/context/local.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,16 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
113113
})
114114

115115
const file = Bun.file(path.join(Global.Path.state, "model.json"))
116+
const state = {
117+
pending: false,
118+
}
116119

117120
function save() {
121+
if (!modelStore.ready) {
122+
state.pending = true
123+
return
124+
}
125+
state.pending = false
118126
Bun.write(
119127
file,
120128
JSON.stringify({
@@ -135,6 +143,7 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
135143
.catch(() => {})
136144
.finally(() => {
137145
setModelStore("ready", true)
146+
if (state.pending) save()
138147
})
139148

140149
const args = useArgs()

0 commit comments

Comments
 (0)