fix(opencode): keep plugin pty environment route local

This commit is contained in:
James Long 2026-06-29 17:55:24 -04:00
commit e0d655d08a
3 changed files with 13 additions and 16 deletions

View file

@ -1,12 +1,11 @@
export * as PluginPtyEnvironment from "./pty-environment"
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
import { PtyEnvironment } from "@opencode-ai/server/pty-environment"
import { Effect, Layer } from "effect"
import { InstanceStore } from "@/project/instance-store"
import { Plugin } from "."
const layer = Layer.effect(
export const layer = Layer.effect(
PtyEnvironment.Service,
Effect.gen(function* () {
const plugin = yield* Plugin.Service
@ -23,5 +22,3 @@ const layer = Layer.effect(
})
}),
)
export const node = LayerNode.make({ service: PtyEnvironment.Service, layer, deps: [Plugin.node, InstanceStore.node] })

View file

@ -102,7 +102,6 @@ import { handlers } from "@opencode-ai/server/handlers"
import { locationServiceMapLayer } from "@opencode-ai/core/location-services"
import { layer as locationLayer } from "@opencode-ai/server/location"
import { sessionLocationLayer } from "@opencode-ai/server/middleware/session-location"
import { PtyEnvironment } from "@opencode-ai/server/pty-environment"
import { schemaErrorLayer as v2SchemaErrorLayer } from "@opencode-ai/server/middleware/schema-error"
import { workspaceHandlers } from "./handlers/workspace"
import { instanceContextLayer } from "./middleware/instance-context"
@ -175,6 +174,7 @@ const instanceRoutes = instanceApiRoutes.pipe(
)
const serverRoutes = HttpApiBuilder.layer(Api).pipe(
Layer.provide(handlers),
Layer.provide(PluginPtyEnvironment.layer),
Layer.provide([serverHttpApiAuthLayer, v2SchemaErrorLayer]),
)
@ -264,7 +264,6 @@ const app = LayerNode.group([
ProjectV2.node,
ProjectCopy.node,
PtyTicket.node,
PluginPtyEnvironment.node,
])
export function createRoutes(
@ -293,7 +292,6 @@ export function createRoutes(
Layer.provide(sessionLocationLayer),
Layer.provide(locationLayer),
Layer.provide(PtyEnvironment.layer),
Layer.provide(
SessionV2.defaultLayer.pipe(
Layer.provide(SessionExecutionLocal.defaultLayer),

View file

@ -41,16 +41,18 @@ export const PtyHandler = HttpApiBuilder.group(Api, "server.pty", (handlers) =>
const pty = yield* Pty.Service
const location = yield* Location.Service
const cwd = ctx.payload.cwd || location.directory
const env = yield* environment.get({ directory: location.directory, cwd })
const created = yield* pty.create({
...ctx.payload,
args: ctx.payload.args ? [...ctx.payload.args] : undefined,
cwd,
env: {
...ctx.payload.env,
...env,
},
})
return yield* response(
pty.create({
...ctx.payload,
args: ctx.payload.args ? [...ctx.payload.args] : undefined,
cwd,
env: {
...ctx.payload.env,
...(yield* environment.get({ directory: location.directory, cwd })),
},
}),
Effect.succeed(created),
)
}),
)