Repository navigation
feat(desktop-gpui): run saved automation rules - #4059
Merged
Merged
Conversation
|
Sandchest reviewed Sandchest reviews every change for vulnerabilities an attacker could use · 7 credits · Review details |
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Member
Author
|
hey @greptileai, please re-review the PR |
Member
Author
|
hey @greptileai, please re-review the PR |
…ads as screenshots, hold Instant folders for their rules
…ant rule cleanup in the real app
Member
Author
|
hey @greptileai, please re-review the PR |
Member
Author
|
hey @greptileai, please re-review the PR |
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 saved automation rules in Settings > Automations but never ran them. The 0.6.0 app did, so a saved rule (a user reported their "compress, then delete the original" rule stopped working after the update) silently did nothing. This PR runs saved rules again in the GPUI app through the shared engine in
crates/automation, the same one the CLI uses. Rules saved by 0.6.0 are read as they are: same store file, sameautomationskey, same types.flowchart LR E[App event] --> Q{enabled rule for this trigger?} Q -- no --> M[main's behaviour, unchanged] Q -- yes --> R[cap_automation::run on tokio] R --> A[GPUI host actions] A -- clipboard, editor, reveal, delete screenshot, preset --> UI[main thread] A -- Delete local files --> G[delete guards]Triggers
RecordingSession::activateonce capture is liveupload_exported_video, editor or Upload action), screenshot share (editor or Upload action)run_video_importupload::queue::delete_recording(library, settings, editor)With no enabled rule for a trigger, each hook returns after one cached store read, so record, stop, export and upload follow main's code path.
Behaviour worth knowing
Skip editorandOpen editordecide the editor once, when the recording stops or the screenshot lands; Skip wins. A rule's ownOpen editoraction does nothing for those two triggers, so they cannot disagree.Uploadof a Studio recording that was never exported renders it first (MP4, 30 fps, 1080p base) into the recording's output file. 0.6.0 failed here with "Rendered video not found", so the "Upload and grab the share link" template now works for the first time.Apply presetgoes through the open editor when there is one (waiting for it to finish loading), otherwise writes the file on the main thread, so an editor never saves old settings over it.Notifyshows a native notification throughnotify-rust(as 0.6.0 did viatauri-plugin-notificationand its Linux helper), only while System notifications is on, as 0.6.0 did.Uploadof a screenshot sends the team chosen in the rule.Delete local files: when it deletes
DeleteLocalFilesdeletes only when every check holds; otherwise every file is kept and the reason is logged.AutomationHost::verify_before_deletehook (crates/automation, 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 to:delete_recordingpath, limited to the recordings folders.Save to location never copies a file onto itself or onto a link to it (device and inode,
same-fileon Windows, as the CLI host does), so the original capture cannot be truncated.Settings shows under a Delete step whether it will delete, and an amber note when nothing will (no Export to another folder or Save to location right above it).
Compared with 0.6.0
feat/gpui-screenshot-ocr-text), which adds the native recognizer. Settings labels it, and the commit that wires it in is ready to add once that PR is on main. 0.6.0 never ran it on Linux either.remove_dir_allwith no checksProof
The mini (Apple Silicon) could not capture its screen during this work (pending system prompts), so the proof comes from CI:
The reported rule, as saved (Export to a folder, then Delete local files, editor left at its default). A 6 s Studio recording of a window; the terminal lists the recordings folder and the compressed folder throughout. The rule exported a 5.3 s, 1280x686 H.264 copy into the chosen folder and removed the recording (video).
Settings > Automations. The copy now says Cap runs enabled rules. Delete local files explains when it deletes; with no copy to another folder right above it, the note turns amber and says nothing will be deleted (that variant is covered by tests; it falls below the fold in the dark still).
Notify on macOS: two rules (recording started, Studio recording finished) each delivered a notification titled "Cap automation" with the filled-in body, recorded in Notification Center under Terminal because Cap is not installed on the runner; screenshots showed no banner, so the on-screen banner itself is not proven. On Linux CI the X server has no notification service and the action failed with that reason.
Not proven here: Windows (covered by the GPUI unit tests in CI only; Run command uses
cmd /Cas 0.6.0 did, and same-file checks usesame-file).Tests
crates/automation: the delete hook sees the preceding action and its result, a refusal keeps files, the hook runs only after the upload checks.apps/desktop-gpui/src/automation/tests.rs: a store written by 0.6.0 (every action type, the reported rule) parses and matches; disabled rules never run; event hold and release; editor choice (skip wins, delete keeps the editor closed); every delete refusal (no or failed preceding action, missing, empty, in-folder, truncated or non-media export, short copy, in progress, open in an editor, unfinished upload, outside the library); save onto itself, a hard link and a symlink; blank and relative folders; render-before-upload; notification text; Run command, Webhook, Apply preset.apps/desktop-gpui/src/upload/real_app_tests.rs(real app against the mock server, run by the macOS Instant reliability workflow, which now also triggers on automation changes):real_app_automation_compresses_then_deletes_a_studio_recording: the reported rule as saved, plus a second rule on the same trigger, plus a disabled rule.real_app_automation_keeps_the_recording_when_the_copy_is_not_safe: export inside the recording, and an export that fails mid-chain; a later rule still runs.real_app_automation_quit_mid_rule_keeps_the_recording: the app is killed while a rule runs; the recording stays and the next launch does not rerun it.real_app_automation_upload_rules_finish_before_cleanup: Instant share link reaches the rule, and the folder stays until the upload rule that copies it is done.real_app_automation_runs_for_every_screenshot: two captures, both run, both saved copies made, both captures removed.

Confidence Score: 5/5
The reviewed changes appear safe to merge; no blocking issue remains.Summary
The PR restores saved desktop automation rules through the shared engine. This update fixes how Instant recording rules hold their files during upload cleanup.
Reviews (15) · Last reviewed commit: "fix(desktop-gpui): key Instant rule hold..." · Reviewed by Greptile