CodeNomad/scripts
Pascal André bdac05bb25
fix(environment): refresh profile variables before each prompt (#714)
## Summary

Apply the existing CodeNomad profile environment **before every prompt,
custom command and session-shell send**, then forward the request only
after OpenCode acknowledges it. This makes profile changes available to
local commands even when the shared daemon is already running.

No per-conversation settings UI, polling, session-opening writes or
daemon restart. The implementation lives in the shared server for
Electron/Tauri/web parity.

close #711; awaiting reporter validation rather than automatically
closing the issue.

## Implementation

- Build a complete execution-host snapshot; preserve PATH and other
inherited values, normalize Windows key collisions, and exclude internal
authentication/storage variables. WSL reads its selected distro's
environment instead of sending Windows PATH/HOME.
- Apply after ownership checks and worktree mutation admission, using
the pinned native connection. Fail the send on environment errors, stale
connection or disconnect; never log the native environment request body.
- Update help and failure messages in every locale. Changes and removals
take effect on each conversation's next send.

## Validation

- Server suite: **586 passed, 2 platform skips**.
- Focused UI send/SDK/authority tests: **112 passed**.
- Server, UI and Electron typechecks; production UI build passed.
- **OpenCode 2.0.9 / Windows native fixture:** real WorkspaceManager +
guarded proxy + native shells, two conversations, changes/removal, no
mutation on read, Git Bash, unchanged daemon PID. Independent
configuration/database/port; only the fixture service was stopped.
- Reproduction: `node scripts/test-session-environment-native.mjs
<absolute-opencode-executable>`.

## Scope

This changes local session command environments, not provider/MCP/LSP
configuration or daemon-internal temporary files. The native environment
belongs to a session: another client or a new send during existing work
can replace it. Queued prompts do not get individual snapshots, and
native-created subagents are not automatically intercepted. Details:
`dev-docs/SESSION_ENVIRONMENT.md`.

Existing oversized files touched narrowly:
`packages/server/src/server/http-server.ts` (~2,300 lines),
`packages/server/src/workspaces/manager.ts` (~1,200 lines), and
`packages/ui/src/lib/i18n/messages/*/settings.ts` (~600 lines each).
2026-09-19 18:18:56 +02:00
..
winget chore: TASK-075 automate Winget updates on release (#513) 2026-06-03 09:03:46 +02:00
bump-version.js Fix bumpVersion script for both npm and tauri 2026-03-31 20:15:16 +01:00
desktop-server-resources.cjs feat(opencode): migrate CodeNomad to native V2 (#647) 2026-09-04 11:36:11 +01:00
desktop-server-resources.test.cjs feat(browser): add autonomous native previews (#666) 2026-09-18 17:46:14 +02:00
prepare-node-runtime.cjs Reduce App package sizes (#453) 2026-05-15 19:13:13 +01:00
smoke-packaged-resources.cjs Reduce App package sizes (#453) 2026-05-15 19:13:13 +01:00
test-automation-native.mjs fix(startup): restore saved sessions promptly and stop plugin heartbeat reloads (#712) 2026-09-19 12:39:23 +02:00
test-native-worktree-management.mjs fix(worktrees): bound ownership refreshes and lazily cache inventories (#708) 2026-09-18 13:58:35 +02:00
test-opencode-location-native.mjs fix(environment): refresh profile variables before each prompt (#714) 2026-09-19 18:18:56 +02:00
test-opencode-proxy-native.mjs fix(environment): refresh profile variables before each prompt (#714) 2026-09-19 18:18:56 +02:00
test-session-environment-native.mjs fix(environment): refresh profile variables before each prompt (#714) 2026-09-19 18:18:56 +02:00
test-session-pruning-native.mjs fix(opencode): support earlier and modern V2 runtime contracts (#695) 2026-09-16 23:48:08 +02:00
test-session-pruning-ui.mjs fix(environment): refresh profile variables before each prompt (#714) 2026-09-19 18:18:56 +02:00
test-worktree-families-native.mjs feat(v2): manage session families across worktrees (#649) 2026-09-17 22:57:37 +02:00
verify-bundled-node.cjs build: bundle node runtime for desktop packages 2026-05-04 20:08:04 +01:00