Skip to content

fix(serve): forward the full environment to the streaming daemon - #7796

Merged
JanDeDobbeleer merged 1 commit into
claude/powershell-utf8-encoding-ati5z1from
claude/loving-shannon-gokc13
Aug 12, 2026
Merged

fix(serve): forward the full environment to the streaming daemon#7796
JanDeDobbeleer merged 1 commit into
claude/powershell-utf8-encoding-ati5z1from
claude/loving-shannon-gokc13

Conversation

@JanDeDobbeleer

Copy link
Copy Markdown
Owner

Prerequisites

  • I have read and understood the [contributing guide][CONTRIBUTING.md].
  • The commit message follows the [conventional commits][cc] guidelines.
  • Tests for the changes have been added (for bug fixes / features).
  • Docs have been added/updated (for bug fixes / features).

Description

Fixes #7792.

When streaming is enabled, the persistent oh-my-posh serve daemon only saw environment variable changes for a hardcoded whitelist (PATH, POSH_* variables, VIRTUAL_ENV, CONDA_PROMPT_MODIFIER), forwarded per-prompt by the shell integration scripts. Anything outside that whitelist - like a variable direnv exports - stayed pinned to whatever value existed when the daemon started, so {{ .Env.XXX }} templates never picked up live changes.

The daemon now reads the shell's complete environment on every prompt instead of a whitelist. Each request's JSON header is unconditionally followed by a raw KEY=VALUE\0 record stream terminated by an empty record, which the daemon parses (readEnvBlob) before applying it via the existing overlay/unset machinery. This wire format needs no escaping - environment variable values can never contain a NUL byte on any OS - which also fixes latent correctness bugs in the shell-side JSON escapers it replaces (fish silently dropped embedded newlines; zsh's control-character stripper only handled the first stray character due to a single-substitution bug), and is cheaper to produce than the JSON it replaces, particularly in fish.

All four shell integrations (fish, zsh, pwsh, cmd/Clink) were updated to send the full environment this way, including at their abort/quit call sites, which now also send the (empty) blob every request line requires to keep the protocol stream in sync.

Docs were checked - streaming.mdx's "Known limitations" section never claimed environment variables were live, so nothing there needed correcting.


Generated by Claude Code

@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown

📦 Release binary size report

Compares this PR's release-equivalent build against the latest published release, per OS (amd64).

OS Baseline This PR Delta
darwin 13.78 MB 13.78 MB +4.0 KB (+0.03%)
linux 13.45 MB 13.45 MB +4.0 KB (+0.03%)
windows 14.01 MB 13.98 MB -34.8 KB (-0.24%)

🎉 Binary size shrank on at least one platform.

@JanDeDobbeleer
JanDeDobbeleer force-pushed the claude/loving-shannon-gokc13 branch from 730d018 to afc43df Compare August 12, 2026 20:20
@JanDeDobbeleer
JanDeDobbeleer changed the base branch from main to claude/powershell-utf8-encoding-ati5z1 August 12, 2026 20:34
When streaming is enabled, the daemon only saw environment variable
changes for a hardcoded whitelist (PATH, POSH_* variables, VIRTUAL_ENV,
CONDA_PROMPT_MODIFIER), forwarded per-prompt by the shell integration
scripts. Anything outside that whitelist - like a variable direnv
exports - stayed pinned to whatever value existed when the daemon
started, so `{{ .Env.XXX }}` templates never picked up live changes.

The daemon now reads the shell's complete environment on every prompt
instead: each request's JSON header is unconditionally followed by a
raw "KEY=VALUE\0" record stream terminated by an empty record, which
the daemon parses with readEnvBlob before applying it via the existing
overlay/unset machinery. This wire format needs no escaping (env
values can never contain a NUL byte on any OS), fixing latent
correctness bugs in the shell-side JSON escapers it replaces (fish
silently dropped embedded newlines; zsh's control-character stripper
only handled the first stray character due to a single-substitution
bug) and is cheaper to produce than the JSON it replaces, particularly
in fish.

All four shell integrations (fish, zsh, pwsh, cmd/Clink) were updated
to send the full env this way instead of a whitelist, including at
their abort/quit call sites, which now also send the (empty) blob
every request line requires to keep the stream in sync.

Fixes #7792.
@JanDeDobbeleer
JanDeDobbeleer force-pushed the claude/loving-shannon-gokc13 branch from afc43df to 041c38c Compare August 12, 2026 20:49
@JanDeDobbeleer
JanDeDobbeleer merged commit 4709f3e into main Aug 12, 2026
13 checks passed
@JanDeDobbeleer
JanDeDobbeleer deleted the claude/loving-shannon-gokc13 branch August 12, 2026 20:58
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.

When streaming is enabled, environment variable changes don't get picked up

2 participants