Skip to content

updating /config endpoint#3

Closed
shuv1337 wants to merge 8 commits intodevfrom
feature/config-endpoint-updates
Closed

updating /config endpoint#3
shuv1337 wants to merge 8 commits intodevfrom
feature/config-endpoint-updates

Conversation

@shuv1337
Copy link
Collaborator

@shuv1337 shuv1337 commented Nov 6, 2025

No description provided.

@shuv1337 shuv1337 requested a review from Copilot November 6, 2025 22:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the config API to support both global and project-scoped configuration updates. It migrates from config.json to opencode.jsonc filenames and adds robust error handling, validation, and backup/rollback mechanisms.

Key Changes

  • Added scope parameter (global or project) to config update endpoint and function
  • Migrated config filename from config.json to opencode.jsonc
  • Implemented permission checks, config validation, and automatic backup/rollback

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
packages/opencode/src/config/config.ts Added scope-aware config update logic with validation, error handling, and backup/rollback
packages/opencode/src/server/server.ts Added scope query parameter to PATCH /config endpoint with validation
packages/opencode/test/config/config.test.ts Updated existing test and added 5 new tests for scope handling, merging, validation, and rollback
CONFIG_API_UPDATES.md Comprehensive documentation of API changes, usage examples, and migration guide
Comments suppressed due to low confidence (2)

packages/opencode/test/config/config.test.ts:417

  • Unused variable mockGlobal.
  const mockGlobal = {

packages/opencode/test/config/config.test.ts:531

  • Unused variable originalContent.
      const originalContent = await Bun.file(path.join(tmp.path, "opencode.jsonc")).text()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +945 to +948
// Dispose instance if project config was updated
if (scope === "project") {
await Instance.dispose()
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Global config updates leave cached config stale

The new scope support writes to the global config file but never invalidates the in‑memory config cache. Config.update only disposes the cached state when scope === "project", so PATCH /config?scope=global writes a file yet future calls to Config.get (including the GET /config endpoint) continue returning the previous values until the process is restarted or someone manually disposes the instance. Global updates need to call Instance.dispose() (or disposeAll) to ensure consumers see the new config.

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex push a commit to fix this

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot fix this

shuv1337 and others added 2 commits November 6, 2025 14:34
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI commented Nov 6, 2025

@kcrommett I've opened a new pull request, #4, to work on those changes. Once the pull request is ready, I'll request review from you.

shuv1337 and others added 5 commits November 6, 2025 14:35
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
[WIP] Address feedback on the /config endpoint update PR
@shuv1337 shuv1337 closed this Nov 6, 2025
@coderabbitai coderabbitai bot mentioned this pull request Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants