Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/opencode/src/cli/cmd/tui/context/exit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const { use: useExit, provider: ExitProvider } = createSimpleContext({
},
)
process.on("SIGHUP", () => exit())
process.on("SIGTERM", () => exit())
return exit
},
})
2 changes: 2 additions & 0 deletions packages/opencode/src/cli/cmd/tui/thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export const TuiThreadCommand = cmd({
process.on("uncaughtException", error)
process.on("unhandledRejection", error)
process.on("SIGUSR2", reload)
process.on("SIGTERM", () => stop())

let stopped = false
const stop = async () => {
Expand All @@ -171,6 +172,7 @@ export const TuiThreadCommand = cmd({
process.off("uncaughtException", error)
process.off("unhandledRejection", error)
process.off("SIGUSR2", reload)
process.off("SIGTERM", stop)
await withTimeout(client.call("shutdown", undefined), 5000).catch((error) => {
Log.Default.warn("worker shutdown failed", {
error: errorMessage(error),
Expand Down
5 changes: 4 additions & 1 deletion packages/opencode/src/project/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { makeRuntime } from "@/effect/run-service"
import { AppFileSystem } from "@opencode-ai/shared/filesystem"
import { iife } from "@/util/iife"
import { Log } from "@/util"
import { createLruCache } from "@/util/cache"
import { LocalContext } from "../util"
import * as Project from "./project"
import { WorkspaceContext } from "@/control-plane/workspace-context"
Expand All @@ -15,7 +16,9 @@ export interface InstanceContext {
}

const context = LocalContext.create<InstanceContext>("instance")
const cache = new Map<string, Promise<InstanceContext>>()
const cache = createLruCache<string, Promise<InstanceContext>>({
maxEntries: 20,
})
const project = makeRuntime(Project.Service, Project.defaultLayer)

const disposal = {
Expand Down
5 changes: 4 additions & 1 deletion packages/opencode/src/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,10 @@ NOTE: At any point in time through this workflow you should feel free to ask the
metadata: () => Effect.void,
ask: () => Effect.void,
})
.pipe(Effect.onInterrupt(() => Effect.sync(() => controller.abort())))
.pipe(
Effect.onInterrupt(() => Effect.sync(() => controller.abort())),
Effect.ensuring(Effect.sync(() => controller.abort())),
)
}

if (part.mime === "text/plain") {
Expand Down
Loading