fix: restore instance context in prompt runs (#22498)

This commit is contained in:
Shoubhit Dash
2026-04-15 03:59:12 +05:30
committed by GitHub
parent f9d99f044d
commit f6409759e5
4 changed files with 103 additions and 14 deletions

View File

@@ -1,8 +1,11 @@
import { expect, test } from "bun:test"
import { Context, Effect, Layer, Logger } from "effect"
import { AppRuntime } from "../../src/effect/app-runtime"
import { InstanceRef } from "../../src/effect/instance-ref"
import { EffectLogger } from "../../src/effect/logger"
import { makeRuntime } from "../../src/effect/run-service"
import { Instance } from "../../src/project/instance"
import { tmpdir } from "../fixture/fixture"
function check(loggers: ReadonlySet<Logger.Logger<unknown, any>>) {
return {
@@ -40,3 +43,19 @@ test("AppRuntime also installs EffectLogger through Observability.layer", async
expect(current.effectLogger).toBe(true)
expect(current.defaultLogger).toBe(false)
})
test("AppRuntime attaches InstanceRef from ALS", async () => {
await using tmp = await tmpdir({ git: true })
const dir = await Instance.provide({
directory: tmp.path,
fn: () =>
AppRuntime.runPromise(
Effect.gen(function* () {
return (yield* InstanceRef)?.directory
}),
),
})
expect(dir).toBe(tmp.path)
})