Skip to content

Cascade-delete task runs and add task templates#243

Merged
oandregal merged 6 commits into
trunkfrom
awesome-hamilton-560076
May 21, 2026
Merged

Cascade-delete task runs and add task templates#243
oandregal merged 6 commits into
trunkfrom
awesome-hamilton-560076

Conversation

@oandregal
Copy link
Copy Markdown
Contributor

Summary

  • Task templates for onboarding: New task creation now offers starter templates (Daily Content Roundup, Weekly Link Digest, Topic Deep-Dive, Content Refresh Audit) so users don't face a blank instructions field. Templates write output into the project's sources/ folder.
  • Cascade-delete task runs: Deleting a task definition now also deletes all associated runs (index entries + .jsonl transcripts). Covers three paths:
    1. Definition deletiondeleteRunsByDefinition removes matching runs immediately.
    2. Project removaldeleteAllRuns wipes all runs when a project is unlinked.
    3. Startup hydrationdeleteOrphanedRuns catches runs orphaned by deletions in older sessions.
  • Race condition fix: Running tasks that are aborted mid-flight by a definition delete no longer re-persist themselves. A deleted flag on LiveRun prevents the runner's finally block from writing the run back after the store has been cleaned.
  • UI refresh: The renderer now re-fetches the run list on definitions-changed events so deleted runs disappear immediately.

Test plan

  • Create a task, run it, delete the definition → runs disappear from the Tasks screen
  • Delete a task while it's still running → run is aborted and removed, no orphan
  • Restart the app with pre-existing orphaned runs → they're cleaned up on boot
  • Unlink a project that has task runs → runs are deleted from disk
  • Create a new task → template picker appears with four options
  • npm run test:unit passes (534/534)

🤖 Generated with Claude Code

oandregal and others added 6 commits May 21, 2026 21:59
Six bundled templates (RSS feed digest, GitHub release notes, GitHub
issue roundup, Reddit topic monitor, Competitor watch, Link research)
surface in three places: a card grid in the Tasks screen empty state,
a compact list in the project sidebar Tasks tab empty state, and a chip
row inside the Create Task modal. Selecting a template pre-fills name,
description, instructions (with placeholder tokens), and schedule.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Files written to the project root don't get file cards in the task
detail transcript because withCreatedFileCards only recognizes writes
inside sources/, drafts/, or done/. Updating every template instruction
to target sources/ fixes this and is semantically correct — these are
external research materials, not drafts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Deleting a task left orphaned run records and transcript files on disk.
Now `deleteDefinition` aborts any live runs for the definition, removes
persisted run index entries, and deletes their `.jsonl` transcripts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Three paths now prune runs that lost their parent definition:

1. Project removal — `deleteAllRuns` wipes the run index and transcripts
   when the project is unlinked (`removeProject` now takes the project
   path so it can reach the disk after the store entry is gone).

2. Definition deletion — `deleteRunsByDefinition` (previous commit).

3. Startup hydration — `deleteOrphanedRuns` catches runs whose
   definition was removed in an older session before the cascade existed.

The three store helpers share a `deleteRunsWhere` predicate helper to
avoid duplicating the filter-write-unlink loop.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When a definition or project is deleted while a run is in-flight, the
abort triggers the runner's finally block which calls `persist(run)` —
re-writing the run we just removed. Add a `deleted` flag to `LiveRun`;
`persistRun` and `runOne`'s post-run bookkeeping (prune, lastRunAt
patch) skip when the flag is set. The live-map entry is left for
`runOne` to clean up so active-count bookkeeping stays correct.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The renderer re-fetched definitions on a `definitions-changed` event
but not runs, so deleted runs stayed visible until the next app
restart. Now both lists are refreshed together.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 21, 2026 20:27
@oandregal oandregal merged commit 5324939 into trunk May 21, 2026
1 check failed
@oandregal oandregal deleted the awesome-hamilton-560076 branch May 21, 2026 20:29
@oandregal oandregal review requested due to automatic review settings May 21, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant