Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Show, createEffect, createMemo, onCleanup } from "solid-js"
import { createStore } from "solid-js/store"
import { useNavigate } from "@solidjs/router"
import { useSpring } from "@codeplane-ai/ui/motion-spring"
import { Button } from "@codeplane-ai/ui/button"
import { Icon } from "@codeplane-ai/ui/icon"
import { PromptInput } from "@/components/prompt-input"
import { useLanguage } from "@/context/language"
Expand Down Expand Up @@ -323,12 +324,23 @@ export function SessionComposerRegion(props: {
>
<div
ref={props.inputRef}
class="flex w-full items-center gap-2 rounded-[12px] border border-border-weak-base bg-background-base px-4 py-3 text-14-regular text-text-weak"
class="flex w-full flex-wrap items-center gap-2 rounded-[12px] border border-border-weak-base bg-background-base px-4 py-3 text-14-regular text-text-weak"
>
<Icon name={isCronSession() ? "bell" : "archive"} size="small" class="shrink-0" />
<span>
<span class="min-w-0 flex-1">
{isCronSession() ? language.t("session.cron.readonly") : language.t("session.archived.readOnly")}
</span>
<Show when={isCronSession() && props.state.working()}>
<Button
type="button"
variant="secondary"
size="small"
disabled={props.state.aborting()}
onClick={() => props.state.abort()}
>
{language.t("prompt.action.stop")}
</Button>
</Show>
</div>
</Show>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createEffect, createMemo, on, onCleanup } from "solid-js"
import { batch, createEffect, createMemo, on, onCleanup } from "solid-js"
import { createStore } from "solid-js/store"
import type { PermissionRequest, QuestionRequest, Todo } from "@codeplane-ai/sdk/v2"
import { useParams } from "@solidjs/router"
Expand Down Expand Up @@ -77,6 +77,7 @@ export function createSessionComposerState(options?: { closeMs?: number | (() =>
dock: todos().length > 0 && live(),
closing: false,
opening: false,
aborting: false,
})

const permissionResponding = createMemo(() => {
Expand All @@ -102,6 +103,26 @@ export function createSessionComposerState(options?: { closeMs?: number | (() =>
})
}

const abort = () => {
const id = params.id
if (!id || store.aborting) return

batch(() => {
globalSync.todo.set(id, [])
sync.set("todo", id, [])
sync.set("session_status", id, idle)
setStore("aborting", true)
})

sdk.client.session
.abort({ sessionID: id })
.catch((err: unknown) => {
const description = err instanceof Error ? err.message : String(err)
showToast({ title: language.t("common.requestFailed"), description })
})
.finally(() => setStore("aborting", false))
}
Comment on lines +106 to +124
Comment on lines +106 to +124

let timer: number | undefined
let raf: number | undefined

Expand Down Expand Up @@ -194,7 +215,10 @@ export function createSessionComposerState(options?: { closeMs?: number | (() =>
permissionRequest,
permissionResponding,
decide,
abort,
aborting: () => store.aborting,
todos,
working: busy,
dock: () => store.dock,
closing: () => store.closing,
opening: () => store.opening,
Expand Down
13 changes: 13 additions & 0 deletions packages/codeplane/src/server/routes/instance/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ import { Bus } from "@/bus"
import { NamedError } from "@codeplane-ai/shared/util/error"
import { jsonRequest, runRequest } from "./trace"
import { queryBoolean } from "@/server/query"
import { CronScheduler } from "@/cron"
import { makeRuntime } from "@/effect/run-service"

const log = Log.create({ service: "server" })
const cronSchedulerRuntime = makeRuntime(CronScheduler.Service, CronScheduler.defaultLayer)

export const SessionRoutes = lazy(() =>
new Hono()
Expand Down Expand Up @@ -439,6 +442,16 @@ export const SessionRoutes = lazy(() =>
async (c) =>
jsonRequest("SessionRoutes.abort", c, function* () {
const sessionID = c.req.valid("param").sessionID
const session = yield* Session.Service
const info = yield* session.get(sessionID).pipe(
Effect.catch(() => Effect.succeed(undefined as Session.Info | undefined)),
)
Comment on lines +446 to +448
Comment on lines +446 to +448
const cronRunID = info?.cronRunID
if (cronRunID) {
yield* Effect.tryPromise(() => cronSchedulerRuntime.runPromise((svc) => svc.cancelRun(cronRunID))).pipe(
Effect.catch(() => Effect.void),
)
}
const svc = yield* SessionPrompt.Service
const aborted = new DOMException("Aborted", "AbortError")
// Mark all pending+running queue rows cancelled BEFORE cancelling
Expand Down
Loading