Skip to content

feat(desktop-gpui): run saved automation rules - #4059

Merged
richiemcilroy merged 21 commits into
mainfrom
feat/gpui-run-automations
Nov 16, 2026
Merged

richiemcilroy merged 21 commits into
mainfrom
feat/gpui-run-automations

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

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, same automations key, 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]
Loading

Triggers

Trigger Where it fires
Recording started RecordingSession::activate once capture is live
Studio recording finished after Studio finalization succeeds
Instant recording finished when the share link is handed out
Upload completed Instant queue after verification, Studio share (upload_exported_video, editor or Upload action), screenshot share (editor or Upload action)
Video imported end of run_video_import
Recording deleted upload::queue::delete_recording (library, settings, editor)
Screenshot taken screenshot capture completion

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

  • A matching rule that deletes the recording keeps the editor closed. The delete is refused while an editor has the recording open, so without this a saved "Export, then Delete local files" rule (the reported one) would never delete. The same applies to screenshots. If the export fails, nothing is deleted and the recording stays in the library.
  • Skip editor and Open editor decide the editor once, when the recording stops or the screenshot lands; Skip wins. A rule's own Open editor action does nothing for those two triggers, so they cannot disagree.
  • An event's rules run once per event: an event is held while its run lasts, so a nested report (an upload finishing inside an Upload action) is dropped, and a later capture that reuses a path runs again.
  • Upload of 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 preset goes 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.
  • With "delete after upload" on, the Instant folder is removed only after the upload-completed rules finish, and kept if one of them opened it in an editor. The queue job does not wait.
  • Notify shows a native notification through notify-rust (as 0.6.0 did via tauri-plugin-notification and its Linux helper), only while System notifications is on, as 0.6.0 did.
  • Upload of a screenshot sends the team chosen in the rule.

Delete local files: when it deletes

DeleteLocalFiles deletes only when every check holds; otherwise every file is kept and the reason is logged.

  1. The engine's upload checks pass. The desktop host does not claim remote verification, so a delete after an Upload is refused, as in 0.6.0.
  2. New AutomationHost::verify_before_delete hook (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:
    • exist, be non-empty, and resolve outside the folder being deleted (symlinks are resolved);
    • for an Export, open as media with a video track and a duration;
    • for a Save to location, be the same size as the original.
  3. Folders in rules must be absolute; a blank or relative folder is refused rather than resolved against the launch directory.
  4. The recording is not being recorded or finalized, not open in an editor, and has no unfinished Instant upload. The delete itself is the library's delete_recording path, limited to the recordings folders.
  5. Screenshots are deleted on the main thread after checking no screenshot editor has the bundle open.

Save to location never copies a file onto itself or onto a link to it (device and inode, same-file on 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

Action 0.6.0 This PR
Copy, Save, Export, Upload, Reveal, Open, Run command, Webhook, Open/Skip editor, Apply preset ran run
Notify ran (when notifications on) runs (when notifications on)
Recognize text ran on macOS and Windows not run yet: it waits for the GPUI screenshot OCR PR (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.
Delete local files remove_dir_all with no checks the guarded delete above
Copy rendered screenshot rendered via the screenshot editor returns an error asking for the original capture (no headless screenshot renderer in GPUI yet)

Proof

The mini (Apple Silicon) could not capture its screen during this work (pending system prompts), so the proof comes from CI:

What Where Result
The five real-app automation tests below macOS job of the Instant reliability (real app) workflow, on this branch's head all pass, next to the 11 existing real-app tests (16/16)
Every GPUI unit test, clippy, fmt CI on this branch's head green
Video and stills of the reported flow and the settings page Linux, real app under Xvfb, a throwaway CI job below
Automation, upload queue, settings and i18n unit tests Mac mini, debug build pass
Notify on a real desktop Real app on a macOS 15 CI runner with System notifications on both notifications reached Notification Center with the rules' text (record); no banner was captured on screen

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).

While recording After stop
recording listed compressed copy, recording gone

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).

Light Dark
settings light settings dark
compress rule expanded compress rule expanded, dark

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 /C as 0.6.0 did, and same-file checks use same-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.

RetriggerView in GreptileConfidence 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.

  • The desktop app runs enabled saved rules when recording and sharing events happen.
  • Delete local files removes a capture only after its replacement passes checks.
  • Instant upload cleanup waits for the rules that still need the recording.
  • Automation settings explain which steps run and when deletion is allowed.

Reviews (15) · Last reviewed commit: "fix(desktop-gpui): key Instant rule hold..." · Reviewed by Greptile

@sandchest-com

sandchest-com Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Sandchest

Sandchest reviewed 5e7a6d5: nothing exploitable found in this change.

Sandchest reviews every change for vulnerabilities an attacker could use · 7 credits · Review details

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found 4 potential issues (1 high, 3 medium).

Open in Capy

Comment thread apps/desktop-gpui/src/automation.rs Resolved
Comment thread apps/desktop-gpui/src/upload/queue.rs Resolved
Comment thread apps/desktop-gpui/src/automation.rs Resolved
Comment thread apps/desktop-gpui/src/automation.rs Resolved
Comment thread apps/desktop-gpui/src/automation.rs Resolved
Comment thread apps/desktop-gpui/src/upload/queue.rs Resolved
Comment thread apps/desktop-gpui/src/upload/queue.rs Resolved
Comment thread apps/desktop-gpui/src/automation.rs Resolved
Comment thread apps/desktop-gpui/src/automation.rs Resolved
Comment thread apps/desktop-gpui/src/automation.rs Resolved
Comment thread apps/desktop-gpui/src/automation.rs Resolved
Comment thread apps/desktop-gpui/src/session.rs Resolved
@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Nov 16, 2026 1:11pm UTC

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

View 2 other findings in Capy.

Open in Capy

@vercel
vercel Bot temporarily deployed to Preview – cap-status November 14, 2026 15:53 Inactive

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found 1 potential issue (1 medium).

View 1 other finding in Capy.

Open in Capy

Comment thread apps/desktop-gpui/src/automation.rs Resolved
@vercel
vercel Bot temporarily deployed to Preview – cap-status November 14, 2026 17:57 Inactive

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

Comment thread apps/desktop-gpui/src/upload/queue.rs Resolved
Comment thread apps/desktop-gpui/src/settings_pages.rs Resolved
@vercel
vercel Bot temporarily deployed to Preview – cap-status November 15, 2026 12:31 Inactive

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

Open in Capy

Comment thread apps/desktop-gpui/src/automation.rs Resolved
Comment thread apps/desktop-gpui/src/editor_window.rs Resolved
Comment thread apps/desktop-gpui/src/automation.rs Resolved
Comment thread apps/desktop-gpui/src/upload/queue.rs Resolved
@vercel
vercel Bot temporarily deployed to Preview – cap-status November 16, 2026 10:23 Inactive
@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

Comment thread apps/desktop-gpui/src/automation.rs Resolved
@vercel
vercel Bot temporarily deployed to Preview – cap-status November 16, 2026 10:41 Inactive
@vercel
vercel Bot temporarily deployed to Preview – cap-status November 16, 2026 10:42 Inactive
@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

@vercel
vercel Bot temporarily deployed to Preview – cap-status November 16, 2026 13:11 Inactive
@richiemcilroy
richiemcilroy merged commit c8b63e8 into main Nov 16, 2026
68 checks passed

This branch was successfully deployed

1 active (outdated) and 1 inactive deployments
Preview – cap-status — 5e7a6d56 Deployed Nov 16, 2026 by vercel[bot]
Preview – cap-web — da40378e Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants