Normalize instance lifecycle wiring (#25501)

This commit is contained in:
Kit Langton
2026-05-02 20:39:20 -04:00
committed by GitHub
parent a6464062b7
commit 7d91d3b1ed
71 changed files with 852 additions and 936 deletions

View File

@@ -48,6 +48,7 @@ beforeEach(() => {
const { MCP } = await import("../../src/mcp/index")
const { AppRuntime } = await import("../../src/effect/app-runtime")
const { Instance } = await import("../../src/project/instance")
const { WithInstance } = await import("../../src/project/with-instance")
const { tmpdir } = await import("../fixture/fixture")
const service = MCP.Service as unknown as Effect.Effect<MCPNS.Interface, never, never>
@@ -73,7 +74,7 @@ test("headers are passed to transports when oauth is enabled (default)", async (
},
})
await Instance.provide({
await WithInstance.provide({
directory: tmp.path,
fn: async () => {
// Trigger MCP initialization - it will fail to connect but we can check the transport options
@@ -112,7 +113,7 @@ test("headers are passed to transports when oauth is enabled (default)", async (
test("headers are passed to transports when oauth is explicitly disabled", async () => {
await using tmp = await tmpdir()
await Instance.provide({
await WithInstance.provide({
directory: tmp.path,
fn: async () => {
transportCalls.length = 0
@@ -150,7 +151,7 @@ test("headers are passed to transports when oauth is explicitly disabled", async
test("no requestInit when headers are not provided", async () => {
await using tmp = await tmpdir()
await Instance.provide({
await WithInstance.provide({
directory: tmp.path,
fn: async () => {
transportCalls.length = 0

View File

@@ -172,6 +172,7 @@ beforeEach(() => {
// Import after mocks
const { MCP } = await import("../../src/mcp/index")
const { Instance } = await import("../../src/project/instance")
const { WithInstance } = await import("../../src/project/with-instance")
const { tmpdir } = await import("../fixture/fixture")
// --- Helper ---
@@ -193,7 +194,7 @@ function withInstance(
},
})
await Instance.provide({
await WithInstance.provide({
directory: tmp.path,
fn: async () => {
await Effect.runPromise(MCP.Service.use(fn).pipe(Effect.provide(MCP.defaultLayer)))

View File

@@ -112,6 +112,7 @@ beforeEach(() => {
// Import modules after mocking
const { MCP } = await import("../../src/mcp/index")
const { Instance } = await import("../../src/project/instance")
const { WithInstance } = await import("../../src/project/with-instance")
const { tmpdir } = await import("../fixture/fixture")
test("first connect to OAuth server shows needs_auth instead of failed", async () => {
@@ -132,7 +133,7 @@ test("first connect to OAuth server shows needs_auth instead of failed", async (
},
})
await Instance.provide({
await WithInstance.provide({
directory: tmp.path,
fn: async () => {
const result = await Effect.runPromise(
@@ -162,7 +163,7 @@ test("state() generates a new state when none is saved", async () => {
await using tmp = await tmpdir()
await Instance.provide({
await WithInstance.provide({
directory: tmp.path,
fn: async () => {
const auth = await Effect.runPromise(
@@ -203,7 +204,7 @@ test("state() returns existing state when one is saved", async () => {
await using tmp = await tmpdir()
await Instance.provide({
await WithInstance.provide({
directory: tmp.path,
fn: async () => {
const auth = await Effect.runPromise(
@@ -252,7 +253,7 @@ test("authenticate() stores a connected client when auth completes without redir
},
})
await Instance.provide({
await WithInstance.provide({
directory: tmp.path,
fn: async () => {
await Effect.runPromise(

View File

@@ -106,6 +106,7 @@ const { AppRuntime } = await import("../../src/effect/app-runtime")
const { Bus } = await import("../../src/bus")
const { McpOAuthCallback } = await import("../../src/mcp/oauth-callback")
const { Instance } = await import("../../src/project/instance")
const { WithInstance } = await import("../../src/project/with-instance")
const { tmpdir } = await import("../fixture/fixture")
const service = MCP.Service as unknown as Effect.Effect<MCPNS.Interface, never, never>
@@ -127,7 +128,7 @@ test("BrowserOpenFailed event is published when open() throws", async () => {
},
})
await Instance.provide({
await WithInstance.provide({
directory: tmp.path,
fn: async () => {
openShouldFail = true
@@ -183,7 +184,7 @@ test("BrowserOpenFailed event is NOT published when open() succeeds", async () =
},
})
await Instance.provide({
await WithInstance.provide({
directory: tmp.path,
fn: async () => {
openShouldFail = false
@@ -237,7 +238,7 @@ test("open() is called with the authorization URL", async () => {
},
})
await Instance.provide({
await WithInstance.provide({
directory: tmp.path,
fn: async () => {
openShouldFail = false