Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5cc8036
refactor(automation): add explicit owner scopes
Astro-Han Jun 11, 2026
e6c6338
feat(automation): run schedules from a process owner
Astro-Han Jun 11, 2026
45dd248
feat(automation): move fresh automations in place
Astro-Han Jun 11, 2026
a33b069
test(app): cover native automation moves
Astro-Han Jun 11, 2026
b0938f0
fix(automation): avoid bootstrapping projects during scans
Astro-Han Jun 11, 2026
1c76fc4
fix(automation): route scoped scheduler outcomes
Astro-Han Jun 11, 2026
be76df5
test(automation): cover unknown project moves
Astro-Han Jun 12, 2026
1404c97
refactor(app): share workspace picker popover
Astro-Han Jun 12, 2026
c9cedc1
feat(app): add sidebar workspace picker
Astro-Han Jun 12, 2026
1a37813
refactor(app): keep workspace picker list reactive
Astro-Han Jun 12, 2026
7b5c158
Revert "refactor(app): keep workspace picker list reactive"
Astro-Han Jun 12, 2026
5333482
Revert "feat(app): add sidebar workspace picker"
Astro-Han Jun 12, 2026
23ae891
Revert "refactor(app): share workspace picker popover"
Astro-Han Jun 12, 2026
52ceed9
fix(app): keep automation project picker available
Astro-Han Jun 12, 2026
5efc2f5
test(app): cover read-only continue automation project
Astro-Han Jun 12, 2026
f42b25a
fix(app): unify automation detail hover states
Astro-Han Jun 12, 2026
98a1d1a
fix(app): normalize automation detail hover targets
Astro-Han Jun 12, 2026
8a88e3f
fix(opencode): refresh moved automation outcomes
Astro-Han Jun 12, 2026
90a8fa2
fix(opencode): await automation scheduler initial scan
Astro-Han Jun 12, 2026
b215f7e
refactor(opencode): remove unused directory run stopper
Astro-Han Jun 12, 2026
867d9b6
test(opencode): keep move active-run guard live
Astro-Han Jun 12, 2026
e4a20fe
fix(opencode): clean up listener on scheduler settle failure
Astro-Han Jun 12, 2026
8ec43b3
refactor(opencode): share scheduler outcome refresh
Astro-Han Jun 12, 2026
9ad1760
refactor(opencode): drop unused scheduler stop wrappers
Astro-Han Jun 12, 2026
9022bd8
refactor(opencode): tighten scheduler event handling
Astro-Han Jun 12, 2026
d1b7a28
fix(opencode): preserve moved automation timer scope
Astro-Han Jun 12, 2026
289b60d
fix(opencode): stop scheduler scans cleanly
Astro-Han Jun 12, 2026
2b09a56
refactor(opencode): clarify automation validation options
Astro-Han Jun 12, 2026
c772070
refactor(opencode): keep scheduler stop runs private
Astro-Han Jun 12, 2026
03b61d6
fix(app): confirm automation move target before caching
Astro-Han Jun 12, 2026
5869d64
test(app): cover automation open-project picker
Astro-Han Jun 12, 2026
d2d8d68
test(app): cover automation project footer click
Astro-Han Jun 12, 2026
78e698d
chore: merge dev into process scheduler branch
Astro-Han Jun 12, 2026
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
30 changes: 12 additions & 18 deletions packages/app/e2e/automations/automations-panel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,19 +595,15 @@ test("automations panel: detail moves an automation to another open project", as
const detail = surface.locator('[data-component="automation-detail"]')
await expect(detail).toBeVisible()

// The Project row is a picker when another project is open. Moving is a
// create-in-target + delete-from-source pair: the automation appears in
// the target project's list, vanishes from the source, and the detail
// stays open on the recreated definition (new id, same fields).
// The Project row is a picker when another project is open. Moving updates
// the same automation in place: it appears in the target project's list,
// vanishes from the source, and the detail stays open on the same id.
await detail.locator('[data-action="automation-edit-project"]').click()
await page.locator(`[data-project="${otherProjectID}"]`).click()

await expect
.poll(async () =>
((await otherSDK.automation.list()).data?.items ?? []).filter((item) => item.title === "Migrating digest")
.length,
)
.toBe(1)
.poll(async () => ((await otherSDK.automation.list()).data?.items ?? []).find((item) => item.id === created.id))
.toMatchObject({ id: created.id, title: "Migrating digest" })
await expect
.poll(async () =>
((await project.sdk.automation.list()).data?.items ?? []).filter((item) => item.id === created.id).length,
Expand Down Expand Up @@ -670,12 +666,10 @@ test("automations panel: a paused automation arrives paused after a move", async
await detail.locator('[data-action="automation-edit-project"]').click()
await page.locator(`[data-project="${otherProjectID}"]`).click()

// The recreated copy must keep the silence the user set, not wake up live.
// The moved definition must keep the silence the user set, not wake up live.
await expect
.poll(async () => {
const moved = ((await otherSDK.automation.list()).data?.items ?? []).find(
(item) => item.title === "Silenced digest",
)
const moved = ((await otherSDK.automation.list()).data?.items ?? []).find((item) => item.id === created.id)
return moved ? moved.paused : "missing"
})
.toBe(true)
Expand All @@ -687,7 +681,7 @@ test("automations panel: a paused automation arrives paused after a move", async
}
})

test("automations panel: a failed pause during a move rolls back and keeps the source", async ({
test("automations panel: a failed move keeps the source", async ({
page,
project,
backend,
Expand All @@ -713,10 +707,10 @@ test("automations panel: a failed pause during a move rolls back and keeps the s
const detail = surface.locator('[data-component="automation-detail"]')
await expect(detail).toBeVisible()

// Re-applying the pause on the target fails. The move must fail as a whole:
// the fresh copy is deleted, the paused source is untouched, and the user
// is told — never a silenced automation suddenly live in another project.
await page.route("**/automation/*/pause*", (route) => route.fulfill({ status: 500, body: "{}" }))
await page.route(`**/automation/${created.id}`, (route) => {
if (route.request().method() !== "PUT") return route.continue()
return route.fulfill({ status: 500, body: "{}" })
})
await detail.locator('[data-action="automation-edit-project"]').click()
await page.locator(`[data-project="${otherProjectID}"]`).click()

Expand Down
21 changes: 19 additions & 2 deletions packages/app/src/context/global-sync.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import type {
AutomationCreateInput,
AutomationUpdateInput,
Expand Down Expand Up @@ -433,14 +433,31 @@
}
}

async function updateAutomation(directory: string, automationID: string, patch: AutomationUpdateInput) {
async function updateAutomation(
directory: string,
automationID: string,
patch: AutomationUpdateInput,
options?: { targetDirectory?: string },
) {
const targetDirectory = options?.targetDirectory
const moved = Boolean(targetDirectory && targetDirectory !== directory)
children.pin(directory)
if (moved && targetDirectory) children.pin(targetDirectory)
try {
const [store, setStore] = children.peek(directory, { bootstrap: false })
const res = await sdkFor(directory).automation.update({ automationID, automationUpdateInput: patch })
if (res.data) applyAutomationDefinition(store, setStore, res.data)
if (res.data) {
if (moved && targetDirectory) {
applyAutomationTombstone(store, setStore, { id: automationID, deleted: true, revision: res.data.revision })
const [targetStore, targetSetStore] = children.peek(targetDirectory, { bootstrap: false })
applyAutomationDefinition(targetStore, targetSetStore, res.data)
} else {
applyAutomationDefinition(store, setStore, res.data)
}
}
return res.data
} finally {
if (moved && targetDirectory) children.unpin(targetDirectory)
children.unpin(directory)
}
}
Expand Down
10 changes: 4 additions & 6 deletions packages/app/src/pages/automations/automation-detail-editors.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createEffect, createMemo, createSignal, Show, type Accessor, type JSX } from "solid-js"
import type { AutomationDefinition, AutomationUpdateInput } from "@opencode-ai/sdk/v2/client"
import { Icon } from "@opencode-ai/ui/icon"
Expand Down Expand Up @@ -120,12 +120,10 @@
)
}

// The "Project" row: there is no server-side move (each project is its own
// instance and update rejects a foreign projectID), so "move" is the create
// card's folder picker driving a create-in-target + delete-from-source pair
// (see moveToProject in automation-detail). A continue automation stays
// read-only — it loops inside a conversation that only exists in its source
// project — as does everything else when no other project is open.
// The "Project" row moves fresh automations by updating their owner in place.
// A continue automation stays read-only because it loops inside a conversation
// that only exists in its source project, as does everything else when no other
// project is open.
export function ProjectEditorRow(props: {
directory: Accessor<string>
automation: Accessor<AutomationDefinition>
Expand Down
42 changes: 9 additions & 33 deletions packages/app/src/pages/automations/automation-detail.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createEffect, createMemo, createSignal, For, Show, type Accessor, type JSX } from "solid-js"
import type {
AutomationCreateInput,
AutomationDefinition,
AutomationRun,
AutomationUpdateInput,
Expand Down Expand Up @@ -213,43 +212,20 @@
}
}

// There is no cross-project move on the server (per-project instances;
// update rejects a foreign projectID), so "move" recreates the definition in
// the target project, then deletes the source. Create-first so a failure
// loses nothing; if the source delete fails (e.g. a run in flight), the
// fresh copy is rolled back instead of leaving a duplicate. The id changes
// and the run list starts empty — past runs' sessions survive regardless.
const moveToProject = async (project: AutomationProject) => {
const previous = props.automation()
if (busy() || project.id === previous.where.projectID) return
setBusy(true)
try {
const common = {
title: previous.title,
prompt: previous.prompt,
context: "fresh" as const,
where: { projectID: project.id, ...(previous.where.worktree ? { worktree: previous.where.worktree } : {}) },
timezone: previous.timezone,
model: { providerID: previous.model.providerID, modelID: previous.model.modelID },
...(previous.variant ? { variant: previous.variant } : {}),
}
const input: AutomationCreateInput =
previous.kind === "oneshot"
? { kind: "oneshot", ...common, fireAt: previous.fireAt }
: { kind: "recurring", ...common, rhythm: previous.rhythm, stop: previous.stop }
const created = await globalSync.automation.create(project.worktree, input)
if (!created) return
// A paused source must arrive paused: if the target pause fails, the
// move fails — roll the copy back rather than leave an automation the
// user silenced suddenly live in another project.
try {
if (previous.paused) await globalSync.automation.pause(project.worktree, created.id)
await globalSync.automation.delete(props.directory(), previous.id)
} catch (error) {
await globalSync.automation.delete(project.worktree, created.id).catch(() => {})
throw error
}
props.onMoved(created)
const moved = await globalSync.automation.update(
props.directory(),
previous.id,
{
where: { projectID: project.id, ...(previous.where.worktree ? { worktree: previous.where.worktree } : {}) },
},
{ targetDirectory: project.worktree },
)
if (moved) props.onMoved(moved)
} catch (error) {
notifyFailure(error)
} finally {
Expand Down
Loading
Loading