Skip to content

Commit 251177d

Browse files
fix(tui): forward environment to worker (anomalyco#35925)
Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com>
1 parent 13b9e55 commit 251177d

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

packages/opencode/src/cli/cmd/tui.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ export const TuiThreadCommand = cmd({
207207
}
208208
const cwd = Filesystem.resolve(process.cwd())
209209

210-
const worker = new Worker(file)
210+
const worker = new Worker(file, {
211+
env: Object.fromEntries(
212+
Object.entries(process.env).filter((entry): entry is [string, string] => entry[1] !== undefined),
213+
),
214+
})
211215
const client = Rpc.client<typeof rpc>(worker)
212216
const reload = () => {
213217
client.call("reload", undefined).catch(() => {})

packages/opencode/test/cli/tui/thread.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ describe("tui thread", () => {
1616
expect(source).not.toContain('import("./app")')
1717
})
1818

19+
test("forwards the CLI environment to the TUI worker", async () => {
20+
const source = await Bun.file(new URL("../../../src/cli/cmd/tui.ts", import.meta.url)).text()
21+
22+
expect(source).toMatch(/new Worker\(file, \{\s*env: Object\.fromEntries\(\s*Object\.entries\(process\.env\)/)
23+
})
24+
1925
async function check(project?: string) {
2026
await using tmp = await tmpdir({ git: true })
2127
const link = path.join(path.dirname(tmp.path), path.basename(tmp.path) + "-link")

0 commit comments

Comments
 (0)