feat(config): support layered OpenCode config sources with revision-guarded saves (#358)

* feat(config): support layered OpenCode config sources with revision-guarded saves

* refactor(config): harden multi-source OpenCode config handling

- extract shared config-source helpers and default source name
- reject shadowed removals with 409 and require sources/revision
- restart the server on reload with session resume
- mirror multiple host config files on import and warn on removals
- skip restart for mcp-only saves
- drop removedFields and CONFIG_PATCH_TIMEOUT_MS

* fix(config): return null when archiving broken OpenCode config fails
This commit is contained in:
Chris Scott authored and GitHub committed 2026-09-20 15:51:40 -04:00
1 parent 97370a8296
commit b5dd900efb
53 files changed
+3003 -1665

No files matched your search

-1
View File
@@ -51,7 +51,6 @@ async function handleResponse(response: Response): Promise<never> {
{
details: data.details,
validationIssues: data.validationIssues,
removedFields: data.removedFields,
}
)
}
+22 -2
View File
@@ -6,9 +6,12 @@ import {
DEFAULT_LEADER_KEY,
BLOCKED_SERVER_ENV_KEYS,
DEFAULT_SERVER_ENV_VARS,
selectPreferredOpenCodeConfigSourceName,
type TTSConfig,
type STTConfig,
type OpenCodeConfigFile,
type OpenCodeConfigSourceFile,
type OpenCodeConfigSourceName,
type UpdateOpenCodeConfigRequest,
type ModelConfig,
type ProviderConfig,
@@ -21,9 +24,25 @@ import {
type InstallSkillResponse,
} from '@opencode-manager/shared'
import type { NotificationPreferences } from '@opencode-manager/shared/types'
import { saveFile } from '@/lib/download'
export type { TTSConfig, STTConfig, OpenCodeConfigFile, UpdateOpenCodeConfigRequest, ModelConfig, ProviderConfig, SandboxPreferences, NotificationPreferences, SkillFileInfo, CreateSkillRequest, UpdateSkillRequest, SkillScope, InstallSkillFromGithubRequest, InstallSkillResponse }
export type { TTSConfig, STTConfig, OpenCodeConfigFile, OpenCodeConfigSourceFile, OpenCodeConfigSourceName, UpdateOpenCodeConfigRequest, ModelConfig, ProviderConfig, SandboxPreferences, NotificationPreferences, SkillFileInfo, CreateSkillRequest, UpdateSkillRequest, SkillScope, InstallSkillFromGithubRequest, InstallSkillResponse }
export { DEFAULT_TTS_CONFIG, DEFAULT_STT_CONFIG, DEFAULT_KEYBOARD_SHORTCUTS, DEFAULT_USER_PREFERENCES, DEFAULT_LEADER_KEY, BLOCKED_SERVER_ENV_KEYS, DEFAULT_SERVER_ENV_VARS }
export { isOpenCodeConfigSourceName } from '@opencode-manager/shared'
export function getOpenCodeConfigSources(config: OpenCodeConfigFile): OpenCodeConfigSourceFile[] {
return config.sources
}
export function getPreferredOpenCodeConfigSource(config: OpenCodeConfigFile): OpenCodeConfigSourceFile | null {
const name = selectPreferredOpenCodeConfigSourceName(config.sources.map((source) => source.name))
return name ? config.sources.find((source) => source.name === name) ?? null : null
}
export function downloadOpenCodeConfigSource(source: OpenCodeConfigSourceFile): void {
const blob = new Blob([source.rawContent], { type: 'application/json' })
void saveFile(blob, source.name)
}
export interface CustomCommand {
name: string
@@ -88,13 +107,14 @@ export interface UpdateSettingsRequest {
export interface OpenCodeConfigSaveResponse extends OpenCodeConfigFile {
restartRequired?: boolean
removedFields?: string[]
}
export interface OpenCodeImportStatus {
configSourcePath: string | null
configSourcePaths: string[]
stateSourcePath: string | null
workspaceConfigPath: string
workspaceConfigPathsToRemove: string[]
workspaceStatePath: string
workspaceStateExists: boolean
}