Skip to content

fix(workspace): reload opencode.jsonc on initial activate#1515

Merged
src-opn merged 4 commits into
different-ai:devfrom
Pagecran:fix/870-activate-reloads-opencode-config
May 4, 2026
Merged

fix(workspace): reload opencode.jsonc on initial activate#1515
src-opn merged 4 commits into
different-ai:devfrom
Pagecran:fix/870-activate-reloads-opencode-config

Conversation

@pascalandr
Copy link
Copy Markdown
Contributor

Summary

  • emit a config reload event when POST /workspaces/:id/activate completes
  • trigger activateWorkspace during initial hydration and workspace switching so .opencode/opencode.jsonc changes are reloaded consistently

Closes #870.

Testing

  • pnpm --filter openwork-server typecheck
  • pnpm --filter @openwork/app typecheck currently fails on upstream/dev with pre-existing React cutover resolution/type errors; I reproduced the same failure on detached upstream/dev

Notes

  • I did not run the Docker + Chrome MCP flow for this UI/runtime interaction.
  • Manual follow-up: bash packaging/docker/dev-up.sh, switch into a workspace with a changed .opencode/opencode.jsonc, and confirm the config reload event is applied without restarting the app.

The workspace the user is on at launch ignored permissions defined in
opencode.jsonc until the user toggled to another workspace and back.
Root cause: POST /workspaces/:id/activate never emitted a "config"
reload event, and the app never called activateWorkspace either on
initial mount or on workspace switch. The OpenCode engine therefore
kept serving a stale config for the initial workspace.

Changes:
- Emit a synthetic config reload event on the activate route so the
  OpenCode engine re-reads opencode.jsonc (matching the pattern
  already used on config-mutating routes).
- Call openworkClient.activateWorkspace after the initial workspace
  selection resolves, and again from the workspace-switch handler.

Fire-and-forget transport; any error is non-fatal.

Fixes different-ai#870
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openwork-landing Ready Ready Preview, Comment, Open in v0 Apr 30, 2026 5:05am

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 22, 2026

@pascalandr is attempting to deploy a commit to the Different AI Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@src-opn src-opn added the EXTRA-ATTENTION-NEEDED Maintainers need to pay additional attention to reviewing this pr label Apr 29, 2026
Copy link
Copy Markdown
Collaborator

@src-opn src-opn left a comment

Choose a reason for hiding this comment

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

Security verification: I did not find malicious code, hidden prompt-like text, bidi/zero-width/control characters, or non-ASCII bytes in the added lines. I also compared the raw diff against an ASCII-visible diff and ran git diff --check; no added-line character or whitespace issues were found. The only non-ASCII bytes observed were pre-existing context comments, not PR additions.

Requesting changes for a functional/code-verification issue:

  • apps/server/src/server.ts:1514 records a debounced reload event from POST /workspaces/:id/activate, but that does not actually reload the OpenCode engine. In this codebase the actual reload path is POST /workspace/:id/engine/reload, which calls reloadOpencodeEngine at apps/server/src/server.ts:2589-2594. The event endpoint at apps/server/src/server.ts:2581-2586 only lists queued events, and I could not find a current app-side consumer of listReloadEvents beyond the client wrapper at apps/app/src/app/lib/openwork-server.ts:1340. As written, this PR appears to enqueue a config event and then swallow the activate call result in the app, but it does not force the engine to re-read opencode.jsonc. That means issue #870 can still reproduce on launch unless some other unshown process consumes the event and calls the reload endpoint.

Please either wire the event into the reload flow with a tested consumer, or call the server-side engine reload path from activation when that is the intended behavior. Add/adjust tests that prove activating a workspace with changed opencode.jsonc causes the runtime instance to reload/re-read config.

Verification performed locally in a dedicated worktree:

  • pnpm install --frozen-lockfile: passed
  • pnpm --filter openwork-server typecheck: passed
  • pnpm --filter @openwork/app typecheck: passed
  • pnpm --filter openwork-server test: passed, 83 tests
  • pnpm --filter openwork-server build: passed
  • pnpm --filter @openwork/app build: passed, with existing Vite chunk-size/dynamic-import warnings

@pascalandr
Copy link
Copy Markdown
Contributor Author

workspace activation now calls the real engine reload path, with a focused e2e test added, and the session route now avoids re-triggering that reload on every refresh.

@src-opn src-opn merged commit 3b0301f into different-ai:dev May 4, 2026
8 of 13 checks passed
benjaminshafii pushed a commit that referenced this pull request May 15, 2026
* fix(workspace): reload opencode.jsonc on initial activate

The workspace the user is on at launch ignored permissions defined in
opencode.jsonc until the user toggled to another workspace and back.
Root cause: POST /workspaces/:id/activate never emitted a "config"
reload event, and the app never called activateWorkspace either on
initial mount or on workspace switch. The OpenCode engine therefore
kept serving a stale config for the initial workspace.

Changes:
- Emit a synthetic config reload event on the activate route so the
  OpenCode engine re-reads opencode.jsonc (matching the pattern
  already used on config-mutating routes).
- Call openworkClient.activateWorkspace after the initial workspace
  selection resolves, and again from the workspace-switch handler.

Fire-and-forget transport; any error is non-fatal.

Fixes #870

* fix(server): reload the engine when activating a workspace

* fix(workspace): avoid reloading on every route refresh
benjaminshafii pushed a commit that referenced this pull request May 15, 2026
* fix(workspace): reload opencode.jsonc on initial activate

The workspace the user is on at launch ignored permissions defined in
opencode.jsonc until the user toggled to another workspace and back.
Root cause: POST /workspaces/:id/activate never emitted a "config"
reload event, and the app never called activateWorkspace either on
initial mount or on workspace switch. The OpenCode engine therefore
kept serving a stale config for the initial workspace.

Changes:
- Emit a synthetic config reload event on the activate route so the
  OpenCode engine re-reads opencode.jsonc (matching the pattern
  already used on config-mutating routes).
- Call openworkClient.activateWorkspace after the initial workspace
  selection resolves, and again from the workspace-switch handler.

Fire-and-forget transport; any error is non-fatal.

Fixes #870

* fix(server): reload the engine when activating a workspace

* fix(workspace): avoid reloading on every route refresh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

EXTRA-ATTENTION-NEEDED Maintainers need to pay additional attention to reviewing this pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Permissions in opencode.jsonc are ignored on every launch

2 participants