Skip to content

fix(runtime): snapshot process.env for daemon launch options - #102

Open
sorrycc wants to merge 1 commit into
mainfrom
fix/101-daemon-env-snapshot
Open

sorrycc wants to merge 1 commit into
mainfrom
fix/101-daemon-env-snapshot

Conversation

@sorrycc

@sorrycc sorrycc commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #101.

Problem

buildDaemonLaunchOptions() copied the live process.env into the daemon's env every time it ran. Obsidian plugins share the renderer's process.env. Copilot (and Claudian) set CLAUDE_AGENT_SDK_VERSION there after Qoderian's daemon has started. The SDK checks env key by key across both the stored and the new options, so a key added later counts as a difference, and every new tab failed with Global daemon is already initialized with different options.

Change

  • src/qoder/runtime/qoder-daemon-launch.ts: the env Qoderian passes on is now a copy of process.env taken the first time the function runs, so the daemon options stay the same for the life of the plugin. PATH, QODER_SDK_CUSTOM_BASE_URL_BYOK and QODER_INTEGRATION_ID still go on top as before.
  • tests/unit/qoder/runtime/qoder-daemon-launch.test.ts: a regression test that adds a process.env key between two calls and expects the same env keys both times. It compares keys only, so a failure never prints env values.

How I checked it

  • Reproduced against the real SDK (1.0.58) with a dummy CLI: initDaemon(opts), then set process.env.CLAUDE_AGENT_SDK_VERSION, then initDaemon(opts) again → DaemonConfigurationConflictError. Without the env write, the second call joins the first initialization.
  • The new test failed before the fix and passes after it.
  • npm test (171 suites, 3612 tests), npm run typecheck and npm run lint all pass.

Not in scope

  • getEnhancedPath() still reads the live process.env.PATH, so a plugin that changes PATH could cause the same conflict. That wasn't reported.
  • Listing the differing keys in the conflict error would need an SDK change.
Other plugins share the renderer's process.env and may add keys later
(e.g. Copilot sets CLAUDE_AGENT_SDK_VERSION). The SDK compares daemon env
over the union of keys, so new Queries were rejected with
"Global daemon is already initialized with different options".

Fixes #101

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant