fix: stabilize Runtime workflows for 0.12.3
OpenCode status checks could cold-start throwaway servers, unrelated conversations could block each other, and model, Continue, or remote paths could replay or duplicate work under failure and backlog conditions. Settings could also lose edits or overwrite unrelated model fields. This update makes status checks passive, keeps per-conversation ordering while allowing concurrency, preserves native long-running work with bounded display capture and backpressure, narrows retries to known pre-dispatch failures, and aligns remote Ask permissions without reducing Execute. It also keeps Embedding updates narrow, improves settings and browser guidance, removes the unused legacy Main gateway state, and records the validated Desktop 0.12.3 and Agent 0.11.17 release metadata. Release note: 改善 OpenCode 切换、多会话长任务、模型重试、远程 Ask/Execute 与设置保存可靠性,并完成 Desktop 0.12.3 / Agent 0.11.17 发布准备。
This commit is contained in:
@@ -305,6 +305,11 @@ export type RuntimeSettingsRollback = {
|
||||
publicSettings: RuntimeSettings
|
||||
restore(): Promise<RuntimeSettings>
|
||||
}
|
||||
export type ActiveEmbeddingConnectionUpdate = {
|
||||
changed: boolean
|
||||
previousConnectionId: string
|
||||
restore(): Promise<RuntimeSettings>
|
||||
}
|
||||
type Version17StoredSettings = z.infer<
|
||||
typeof version17StoredSettingsSchema
|
||||
>
|
||||
@@ -1998,6 +2003,85 @@ export class RuntimeSettingsStore {
|
||||
return operation
|
||||
}
|
||||
|
||||
setActiveEmbeddingConnection(
|
||||
connectionId: string
|
||||
): Promise<ActiveEmbeddingConnectionUpdate> {
|
||||
let result: ActiveEmbeddingConnectionUpdate | undefined
|
||||
const operation = this.updateQueue.then(async () => {
|
||||
const current = await this.load()
|
||||
const previousConnectionId =
|
||||
current.activeEmbeddingConnectionId
|
||||
const changed = previousConnectionId !== connectionId
|
||||
if (changed) {
|
||||
const next = this.withActiveEmbeddingConnection(
|
||||
current,
|
||||
connectionId
|
||||
)
|
||||
await writeJsonFileAtomically(this.filePath, next)
|
||||
this.settings = next
|
||||
this.loadWarnings = []
|
||||
}
|
||||
result = {
|
||||
changed,
|
||||
previousConnectionId,
|
||||
restore: () =>
|
||||
this.restoreActiveEmbeddingConnection(
|
||||
connectionId,
|
||||
previousConnectionId
|
||||
)
|
||||
}
|
||||
})
|
||||
this.updateQueue = operation.then(
|
||||
() => undefined,
|
||||
() => undefined
|
||||
)
|
||||
return operation.then(() => result!)
|
||||
}
|
||||
|
||||
private restoreActiveEmbeddingConnection(
|
||||
expectedConnectionId: string,
|
||||
previousConnectionId: string
|
||||
): Promise<RuntimeSettings> {
|
||||
const operation = this.updateQueue.then(async () => {
|
||||
const current = await this.load()
|
||||
if (
|
||||
current.activeEmbeddingConnectionId !== expectedConnectionId
|
||||
) {
|
||||
return this.toPublicSettings(current)
|
||||
}
|
||||
const restored = this.withActiveEmbeddingConnection(
|
||||
current,
|
||||
previousConnectionId
|
||||
)
|
||||
await writeJsonFileAtomically(this.filePath, restored)
|
||||
this.settings = restored
|
||||
this.loadWarnings = []
|
||||
return this.toPublicSettings(restored)
|
||||
})
|
||||
this.updateQueue = operation.then(
|
||||
() => undefined,
|
||||
() => undefined
|
||||
)
|
||||
return operation
|
||||
}
|
||||
|
||||
private withActiveEmbeddingConnection(
|
||||
current: StoredSettings,
|
||||
connectionId: string
|
||||
): StoredSettings {
|
||||
const connectionExists = current.embeddingConnections.some(
|
||||
(candidate) => candidate.id === connectionId
|
||||
)
|
||||
if (!connectionExists) {
|
||||
throw new Error('当前向量连接不存在')
|
||||
}
|
||||
return {
|
||||
...current,
|
||||
version: CURRENT_SETTINGS_VERSION,
|
||||
activeEmbeddingConnectionId: connectionId
|
||||
}
|
||||
}
|
||||
|
||||
private async performUpdate(
|
||||
input: RuntimeSettingsInput
|
||||
): Promise<RuntimeSettings> {
|
||||
|
||||
Reference in New Issue
Block a user