Skip to content

Commit e73c41b

Browse files
committed
core: remove legacy session dependency from v2 API handlers
Eliminates the dependency on LegacySession from the v2 HTTP API, simplifying the handler initialization by only using SessionV2. Also exports defaultLayer from SessionV2 for consistent layer provisioning.
1 parent dbef8b4 commit e73c41b

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

packages/opencode/src/server/routes/instance/httpapi/v2.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Session as LegacySession } from "@/session/session"
21
import { SessionID } from "@/session/schema"
32
import { SessionMessage } from "@/v2/session-message"
43
import { SessionV2 } from "@/v2/session"
@@ -37,18 +36,16 @@ export const V2Api = HttpApi.make("v2")
3736
}),
3837
)
3938

40-
export const v2Handlers = Layer.unwrap(
39+
export const v2Handlers = HttpApiBuilder.group(V2Api, "v2", (handlers) =>
4140
Effect.gen(function* () {
42-
const legacySession = yield* LegacySession.Service
4341
const session = yield* SessionV2.Service
44-
45-
const messages = Effect.fn("V2HttpApi.messages")(function* (ctx: { params: { sessionID: SessionID } }) {
46-
yield* legacySession.get(ctx.params.sessionID)
47-
return yield* session.messages(ctx.params.sessionID)
48-
})
49-
50-
return HttpApiBuilder.group(V2Api, "v2", (handlers) => handlers.handle("messages", messages))
42+
return handlers.handle(
43+
"messages",
44+
Effect.fn(function* (ctx) {
45+
return yield* session.messages(ctx.params.sessionID)
46+
}),
47+
)
5148
}),
52-
).pipe(Layer.provide(LegacySession.defaultLayer), Layer.provide(SessionV2.layer))
49+
).pipe(Layer.provide(SessionV2.defaultLayer))
5350

5451
export * as V2HttpApi from "./v2"

packages/opencode/src/v2/session.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ export const layer: Layer.Layer<Service> = Layer.effect(
3434
}),
3535
)
3636

37+
export const defaultLayer = layer
38+
3739
export * as SessionV2 from "./session"

0 commit comments

Comments
 (0)