feat(home): add auto-run toggle to quick actions#2987
Conversation
Adds an `auto` flag to `WorkflowAction` and an "Auto-run" toggle in the quick-action editor. When enabled, the server-side classifier (evaluate-code-workstreams worker) auto-runs the action as a cloud task whenever a workstream's primary situation matches the binding — gated so it never piles onto a workstream that already has a running task. This change is the config/UI half (harmless until the backend honors the flag): the `auto` field round-trips through the workflow config bindings, the editor exposes a Switch, and auto-enabled actions show a lightning glyph on the config map. Backend auto-run lands in posthog/posthog. Generated-By: PostHog Code Task-Id: e40b189a-6d1a-4de5-a228-79e681402b35
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
Reviews (1): Last reviewed commit: "feat(home): add auto-run toggle to quick..." | Re-trigger Greptile |
| <Switch | ||
| size="1" | ||
| checked={action.auto ?? false} | ||
| onCheckedChange={(checked) => patch({ auto: checked })} |
There was a problem hiding this comment.
When auto-run is toggled off,
patch({ auto: false }) spreads auto: false onto the action. JSON.stringify serialises false explicitly, so the resulting string differs from the baseline (which has no auto key at all). This leaves dirty === true even after a round-trip enable → disable, falsely prompting the user to save a semantically-unchanged config.
Using checked || undefined keeps the field absent when the toggle is off, matching the original serialisation and letting the dirty flag clear correctly.
| onCheckedChange={(checked) => patch({ auto: checked })} | |
| onCheckedChange={(checked) => patch({ auto: checked || undefined })} |
| it("toggles the auto flag and marks dirty", () => { | ||
| store().beginEdit(makeConfig({ ci_failing: [makeAction({ id: "a" })] })); | ||
| store().updateAction("ci_failing", "a", { auto: true }); | ||
| expect(store().draft?.bindings.ci_failing[0].auto).toBe(true); | ||
| expect(store().dirty).toBe(true); | ||
| store().updateAction("ci_failing", "a", { auto: false }); | ||
| expect(store().draft?.bindings.ci_failing[0].auto).toBe(false); | ||
| }); |
There was a problem hiding this comment.
The test verifies that toggling
auto to false leaves dirty as true, but it never checks whether the dirty flag clears after a round-trip (enable → disable back to the original state). A test that calls updateAction with { auto: true } then { auto: false } and asserts dirty === false would have caught the serialisation mismatch noted in ActionEditorPanel.tsx.
Keeps the frontend validationDiagnostic enum in sync with the backend workflow-config validator, which now rejects a non-boolean `auto` flag. The save-result parse is strict, so the code must be enumerated here or a returned diagnostic would fail to parse. Generated-By: PostHog Code Task-Id: e40b189a-6d1a-4de5-a228-79e681402b35
- Collapse the Auto-run Field to a single helper-text line with a state ternary, matching the Skill/Model field pattern (drops the one-off Flex wrapper and inline-label Text). - Document that `action_auto_not_bool` is emitted only by server-side save validation, so it isn't mistaken for dead surface and removed (it must stay listed for server-returned diagnostics to parse via saveResult). - Apply Biome formatting the original commits missed (multi-line @radix-ui/themes import, wrapped Lightning element) — fixes the red `quality` check. Generated-By: PostHog Code Task-Id: e40b189a-6d1a-4de5-a228-79e681402b35
Toggling auto-run off wrote an explicit `auto: false`, which serializes differently from the baseline (which has no `auto` key), so an enable → disable round-trip left `dirty === true` and falsely prompted an unsaved-changes save. The editor now sends `checked || undefined`, keeping the field absent when off so the serialization matches baseline and the dirty flag clears. Adds a store test covering the enable → disable round-trip clears dirty. Addresses Greptile review feedback on the PR. Generated-By: PostHog Code Task-Id: e40b189a-6d1a-4de5-a228-79e681402b35
Removes the explanatory comments on the `auto` field and the `action_auto_not_bool` diagnostic code per review feedback — the intent is clear from the field/code names. Generated-By: PostHog Code Task-Id: e40b189a-6d1a-4de5-a228-79e681402b35
What
Adds an auto-run toggle to Home-tab quick actions. When a quick action has auto-run enabled, the server-side classifier will launch it as a cloud task whenever a workstream lands in that action's situation (deduped against already-running tasks).
This PR is the config + UI half in
posthog/code. It's harmless on its own — the flag is just stored in the workflow config until the backend honors it. The backend auto-run (theevaluate-code-workstreamsworker + dedup) ships in a companionposthog/posthogPR.Changes
packages/core/src/workflow/schemas.ts— addauto?: booleantoworkflowAction(the schema is.strict(), so the field is required for it to round-trip on save). Type propagates to all consumers.ActionEditorPanel.tsx— add an "Auto-run"Switchto the quick-action editor.SituationStation.tsx— auto-enabled actions show a filled lightning glyph (instead of the sparkle) on the config map so they're visible at a glance.workflowEditorStoreround-trips theautoflag and marks the draft dirty.How it works (full picture)
autorides along inside theCodeWorkflowConfig.bindingsJSON. The server worker reads the per-user bindings, and for a workstream's primary situation fires any bound action withauto: true— once per workstream+action, and only when no task is already running on that workstream.Test plan
pnpm --filter @posthog/core typecheckpnpm --filter @posthog/ui typecheckpnpm --filter @posthog/ui test(973 passing, incl. new auto-flag test)biome linton changed files🤖 Generated with Claude Code