Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

fix(cron): add stop button for automated tasks in web UI#35

Merged
devinoldenburg merged 1 commit into
mainfrom
fix/stop-automated-tasks-web-ui
Jun 1, 2026
Merged

fix(cron): add stop button for automated tasks in web UI#35
devinoldenburg merged 1 commit into
mainfrom
fix/stop-automated-tasks-web-ui

Conversation

@devinoldenburg
Copy link
Copy Markdown
Collaborator

Summary

  • Adds a Stop button to the shared web session composer for active cron sessions
  • Wires the button to an abort() action that clears todos and calls the session abort endpoint
  • Cancels the linked cron run via CronScheduler.cancelRun before aborting the prompt on the server

Changes

  • packages/app/src/pages/session/composer/session-composer-state.ts: added aborting flag, abort() action (clears todos, sets idle, calls sdk.client.session.abort), and exported aborting() accessor + working alias
  • packages/app/src/pages/session/composer/session-composer-region.tsx: renders a Stop button (variant="secondary") for active cron sessions within the read-only bar
  • packages/codeplane/src/server/routes/instance/session.ts: SessionRoutes.abort now checks session.cronRunID and cancels it via CronScheduler.cancelRun before proceeding with the prompt abort

Verification

  • bun --cwd packages/app typecheck — 0 errors
  • bun --cwd packages/codeplane typecheck — 1 pre-existing error in src/mcp/index.ts (Zod schema mismatch, unrelated)

Add a Stop button to the shared session composer for active cron
sessions, wired to a new `abort()` action that clears todos and calls
the session abort endpoint. On the server, `SessionRoutes.abort` now
cancels the linked `cronRunID` via `CronScheduler.cancelRun` before
aborting the prompt.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Co-Authored-By: codeplane-agent[bot] <287208015+codeplane-agent[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 1, 2026 12:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a user-facing “Stop” control for active cron-driven sessions in the session composer UI, and wires it through to the server abort endpoint so that stopping a session also cancels the associated cron run.

Changes:

  • App: Introduces an aborting flag + abort() action in the session composer state, and exposes working/aborting accessors for UI use.
  • App UI: Renders a Stop button in the read-only bar for cron sessions while the session is working.
  • Server: Enhances session.abort to cancel the linked cron run (CronScheduler.cancelRun) before aborting the session prompt.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
packages/app/src/pages/session/composer/session-composer-state.ts Adds abort state/action and exposes aborting() + working for the Stop UI wiring.
packages/app/src/pages/session/composer/session-composer-region.tsx Displays Stop button for working cron sessions in the read-only bar.
packages/codeplane/src/server/routes/instance/session.ts Cancels associated cron run before proceeding with prompt/session abort.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +106 to +124
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 +446 to +448
const info = yield* session.get(sessionID).pipe(
Effect.catch(() => Effect.succeed(undefined as Session.Info | undefined)),
)
Comment on lines +106 to +124
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 +446 to +448
const info = yield* session.get(sessionID).pipe(
Effect.catch(() => Effect.succeed(undefined as Session.Info | undefined)),
)
@devinoldenburg
Copy link
Copy Markdown
Collaborator Author

Triage — Keep Open

Confirmed real defects in this PR. Copilot review flagged them; no past agent commentary here.

Defects found

  1. State not restored on abort failure (packages/app/src/pages/session/composer/session-composer-state.ts): abort() optimistically clears todos and forces session_status to idle before the request completes. On failure, the UI stays idle/cleared even though the server may still be working. Previous state must be captured and reverted in .catch.
  2. Unsafe type assertion (packages/codeplane/src/server/routes/instance/session.ts): undefined as Session.Info | undefined weakens type safety and can mask refactors. Prefer typing Effect.succeed explicitly.

Why not close

The abort rollback gap is a real UX bug — users see a falsely-idle session after a failed abort. The type assertion is a real correctness concern. Keep open.

@devinoldenburg
Copy link
Copy Markdown
Collaborator Author

Review: stop button for automated tasks in web UI

Status: Merge candidate

All CI checks are green. The server-side abort handler correctly cancels the linked cron run via CronScheduler.cancelRun before proceeding with prompt abort. This pairs cleanly with PR #34's UI changes.

@devinoldenburg devinoldenburg merged commit 778b11f into main Jun 1, 2026
12 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants