fix(worktree): type expected errors (#27296)

This commit is contained in:
Shoubhit Dash
2026-05-13 15:05:30 +05:30
committed by GitHub
parent ccf93f3523
commit 2e7cf92c8b
7 changed files with 125 additions and 62 deletions
@@ -12,7 +12,15 @@ import { Effect, Option } from "effect"
import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse"
import { HttpApiBuilder, HttpApiError } from "effect/unstable/httpapi"
import { InstanceHttpApi } from "../api"
import { ConsoleSwitchPayload, SessionListQuery, ToolListQuery } from "../groups/experimental"
import { ConsoleSwitchPayload, SessionListQuery, ToolListQuery, WorktreeApiError } from "../groups/experimental"
function mapWorktreeError<A, R>(self: Effect.Effect<A, Worktree.Error, R>) {
return self.pipe(
Effect.mapError(
(error) => new WorktreeApiError({ name: error._tag, data: { message: error.message } }),
),
)
}
export const experimentalHandlers = HttpApiBuilder.group(InstanceHttpApi, "experimental", (handlers) =>
Effect.gen(function* () {
@@ -100,14 +108,14 @@ export const experimentalHandlers = HttpApiBuilder.group(InstanceHttpApi, "exper
const worktreeCreate = Effect.fn("ExperimentalHttpApi.worktreeCreate")(function* (ctx: {
payload: Worktree.CreateInput | undefined
}) {
return yield* worktreeSvc.create(ctx.payload)
return yield* mapWorktreeError(worktreeSvc.create(ctx.payload))
})
const worktreeRemove = Effect.fn("ExperimentalHttpApi.worktreeRemove")(function* (input: {
payload: Worktree.RemoveInput
}) {
const ctx = yield* InstanceState.context
yield* worktreeSvc.remove(input.payload)
yield* mapWorktreeError(worktreeSvc.remove(input.payload))
yield* project.removeSandbox(ctx.project.id, input.payload.directory)
return true
})
@@ -115,7 +123,7 @@ export const experimentalHandlers = HttpApiBuilder.group(InstanceHttpApi, "exper
const worktreeReset = Effect.fn("ExperimentalHttpApi.worktreeReset")(function* (ctx: {
payload: Worktree.ResetInput
}) {
yield* worktreeSvc.reset(ctx.payload)
yield* mapWorktreeError(worktreeSvc.reset(ctx.payload))
return true
})