Repository navigation
feat(desktop-gpui): run saved automation rules - #4059
Open
richiemcilroy wants to merge 9 commits into
Open
richiemcilroy wants to merge 9 commits into
richiemcilroy wants to merge 9 commits into
Conversation
|
Sandchest reviewed Sandchest reviews every change for vulnerabilities an attacker could use · 13 credits · Review details |
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What this does
The desktop app saves automation rules in Settings > Automations but never ran them. The old Tauri app did, so anyone with a saved rule (for example compress-then-delete) silently lost it when they updated. This PR runs those rules again in the GPUI app, using the same engine the CLI already uses (
crates/automation), so there is still one rule model and one runner.Existing users: rules they already saved start running after this update. Disabled rules stay disabled (the engine skips
enabled: false, and a test reads rules written by the settings page through the runner to prove it).Where it hooks in
RecordingSession::activate, once the capture is liverun_video_import, after the bundle and thumbnail are writtenupload::queue::delete_recording(every user delete: library, settings, editor)SkipEditor/OpenEditoroverride the post-recording editor choice at stop time and the screenshot editor choice, the same way 0.6.0 did.How it runs
automationskey and look for an enabled rule with that trigger. With no rules saved, nothing else happens, so record, stop, finalize, export and upload behave as on main.spawn_blocking. Actions that need the UI (clipboard, open editor, reveal, open URL, library refresh) are sent to a main-thread channel and awaited.automation action did not complete, with rule id and reason), as 0.6.0 did. Nothing panics or blocks.Guards on destructive actions
DeleteLocalFilesnow runs only when all of these hold:AutomationHost::verify_before_deletehook (default allows, so the CLI is unchanged): the GPUI host requires the action right before the delete to be an Export or Save to location that succeeded, and its output file to exist, be non-empty and sit outside the folder being deleted. An export to the project folder therefore never lets the recording be deleted.RecordingInProgress, fix(desktop-gpui): refuse deleting the recording in progress #3969) and not open in an editor (ProjectBeingDeleted/ProjectOpenInEditor, fix(desktop-gpui): delete a recording as a unit, closing the editor that has it open #4001). The delete itself goes through the samedelete_recordingpath as the library, so it is also limited to the recordings folders and cancels nothing silently.A delete action that is refused leaves every file in place and logs why.
Not covered
Settings copy
The page no longer says automations do not run, in all seven locales. The command warning drops "In the Cap CLI" because the app runs those commands now.
Proof
Real app on macOS (Apple Silicon), debug build of this branch, sandboxed data folder, real 5 second Studio recordings started by the app's auto-record hook. Media committed at
bee9626feonscratch/automations-proof. The saved store had three rules: "Compress then delete" (Studio finished: Export MP4, Potato, 720p, then Delete local files), a disabled rule that would touch a marker file, and "On start" (Recording started: run a command).1. Rule fires, delete refused because the editor has the recording open. Export wrote a 507 KB, 4.4 s H.264 file; the recording is still in the library and open in the editor; the disabled rule's marker was never created; the start rule wrote its file.
2. Safe compress-then-delete. With Skip editor added, the export lands outside the recording and is checked (exists, non-empty), then the recording is removed through the library delete path. The editor never opened, so Skip editor overrides the "open editor" setting.
3. Delete refused because the export is inside the recording. Export to the project folder succeeds, but the delete is refused and the recording is kept.
Settings copy with the saved rules (the disabled one shows as Disabled):
The editor preview is blurred because it shows the test machine's desktop. Windows and Linux: covered by the GPUI test suite in CI (the actions use the same cross-platform code as before; Run command uses
cmd /Con Windows as 0.6.0 did).Tests
crates/automation: the new hook sees the action before the delete and whether it succeeded; a refusal keeps the files and reports the reason; the hook runs only after the upload checks pass.cap-automationtests now run in CI.apps/desktop-gpui/src/automation/tests.rs: rules written by the settings page keep their enabled state through the runner; no rules means nothing listens; one event runs once; SkipEditor/OpenEditor/duration overrides; delete refused with no prior action, a failed or non-file action, a missing, empty or in-folder output; delete refused for a recording in progress, open in an editor, with an unfinished upload, or outside the library; a failed export keeps the recording end to end; Save to location, export paths and compression, clipboard source, templates, environment, Run command, Webhook (local server, 200 and 500), Apply preset, and the two unsupported actions.This PR is not ready to merge because automatic sharing, upload events, editor behavior, and repeated screenshots still have unresolved failures.
Findings
Fix with agent prompt
Summary
This PR connects saved automation rules to the GPUI desktop app.
Reviews (6) · Last reviewed commit: "feat(desktop-gpui): update automations s..." · Reviewed by Greptile