Conversation
PATCH /config hot-reload w/ selective cache invalidation
* Fix cache corruption bug in refresh function
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const hotReloadEnabled = isConfigHotReloadEnabled() | ||
| if (hotReloadEnabled && input.scope === "global") { | ||
| await State.invalidate("config") | ||
| } | ||
| if (hotReloadEnabled && input.scope === "project") { | ||
| await Instance.invalidate("config") | ||
| } |
There was a problem hiding this comment.
Refresh cached config even when hot reload is off
Config.update now skips invalidating state when OPENCODE_CONFIG_HOT_RELOAD is not set to "true". In the default configuration the updated file is written, but the in-memory config (and dependent services like providers, agents, tools) remains cached, so subsequent Config.get() calls continue returning the old data until the process is manually restarted. The previous implementation always disposed the instance after an update, so this is a regression where the API reports success but the change never takes effect. Invalidate or reload the config regardless of the flag and keep the event-based invalidation as an optional fast path.
Useful? React with 👍 / 👎.
Note
Introduce config hot reload with PATCH /config, safe JSONC persistence (locking/backup/atomic writes), targeted invalidation/events, and refactor state to named registries.
persist.ts(locking, backup/restore, atomic writes),write.ts(JSONC incremental edits),diff.ts(change detection),error.ts,backup.ts,lock.ts,hot-reload.ts,global-file.ts.Config.Event.Updatedandconfig/invalidation.tsfor targeted cache invalidation;Config.readFreshConfig()and refactorstateviaState.register.PATCH /config(project/global scope), return merged config, publishconfig.updated, fan-out on global; enrich TUI toast messages.State.registerandState.invalidate(name, key?);Instance.invalidate,Instance.forEach; bootstrap invalidation setup.agent,command,provider,mcp,lsp,format,plugin(with cleanup),file/watcher,tool/registry,file/index.specs/config-spec.mdforPATCH /config.Written by Cursor Bugbot for commit e3d696e. This will update automatically on new commits. Configure here.