diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b59ae53019..727e181fa5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -280,6 +280,7 @@ jobs: - name: Test desktop regressions run: | cargo test --locked -p cap-utils -p cap-cli-install --lib + cargo test --locked -p cap-automation cargo test --locked -p cap --bin cap record::tests cargo test --locked -p cap --bin cap recordings::tests cargo test --locked -p cap --bin cap automation::tests::cli_save_to_location diff --git a/.github/workflows/instant-reliability.yml b/.github/workflows/instant-reliability.yml index 227cec6771d..23922766cbe 100644 --- a/.github/workflows/instant-reliability.yml +++ b/.github/workflows/instant-reliability.yml @@ -15,6 +15,9 @@ on: paths: - "apps/desktop-gpui/src/upload.rs" - "apps/desktop-gpui/src/upload/**" + - "apps/desktop-gpui/src/automation.rs" + - "apps/desktop-gpui/src/automation/**" + - "crates/automation/**" - "apps/desktop-gpui/src/recording.rs" - "apps/desktop-gpui/src/session.rs" - "apps/desktop-gpui/src/library.rs" diff --git a/apps/desktop-gpui/Cargo.lock b/apps/desktop-gpui/Cargo.lock index e67b4e0d3dd..cc5a99a2873 100644 --- a/apps/desktop-gpui/Cargo.lock +++ b/apps/desktop-gpui/Cargo.lock @@ -1397,6 +1397,21 @@ dependencies = [ "workspace-hack", ] +[[package]] +name = "cap-automation" +version = "0.1.0" +dependencies = [ + "cap-project", + "serde", + "serde_json", + "specta", + "thiserror 1.0.69", + "tokio", + "tracing", + "uuid", + "workspace-hack", +] + [[package]] name = "cap-camera" version = "0.1.0" @@ -1544,6 +1559,7 @@ dependencies = [ "block2 0.6.2", "bytes", "cap-audio", + "cap-automation", "cap-camera", "cap-camera-effects", "cap-cli-install", @@ -1585,6 +1601,7 @@ dependencies = [ "libc", "lyon_tessellation", "minisign-verify", + "notify-rust", "objc2 0.6.5", "objc2-app-kit 0.3.2", "objc2-core-graphics", @@ -1597,6 +1614,7 @@ dependencies = [ "resvg 0.45.1", "rfd", "rodio", + "same-file", "sanitize-filename", "scap-targets", "semver", diff --git a/apps/desktop-gpui/Cargo.toml b/apps/desktop-gpui/Cargo.toml index a39d6dc923a..a43c648d607 100644 --- a/apps/desktop-gpui/Cargo.toml +++ b/apps/desktop-gpui/Cargo.toml @@ -57,6 +57,7 @@ cap-enc-ffmpeg = { path = "../../crates/enc-ffmpeg" } cap-timestamp = { path = "../../crates/timestamp" } cap-utils = { path = "../../crates/utils" } cap-project = { path = "../../crates/project" } +cap-automation = { path = "../../crates/automation" } # The cursor style picker draws the same SVG assets the renderer composites. # gpui's `svg()` keeps only a glyph's alpha, so the two-tone cursor art has to # be rasterised instead: `resvg` at the pin cap-rendering already builds, into @@ -94,6 +95,7 @@ cap-export = { path = "../../crates/export" } # workspace pins, and cap-recording already builds it, so this is an import, # not an extra dependency tree. ffmpeg = { package = "ffmpeg-next", git = "https://github.com/CapSoftware/rust-ffmpeg", rev = "49db1fede112" } +notify-rust = "4.18" # Camera preview frames and Recents thumbnails both become gpui `RenderImage`s, # and the frame container type must match gpui's image crate version exactly # (`image = "0.25.1"` in the zed fork's workspace) or `Frame` would be two @@ -207,6 +209,7 @@ libc = "0.2" [target.'cfg(windows)'.dependencies] clipboard-rs = "0.2.4" raw-window-handle = "0.6" +same-file = "1.0.6" tray-icon = { version = "0.21.1", default-features = false } windows-sys = { version = "0.59", features = [ "Win32_Foundation", diff --git a/apps/desktop-gpui/locales/de.toml b/apps/desktop-gpui/locales/de.toml index 7ec8d9f5529..b133a1bd897 100644 --- a/apps/desktop-gpui/locales/de.toml +++ b/apps/desktop-gpui/locales/de.toml @@ -740,17 +740,22 @@ working_for = "Die Google-Drive-Verbindung funktioniert für {email}" [settings.automations] action_no_effect = "Diese Aktion hat beim gewählten Auslöser keine Wirkung." +action_unsupported = "Cap führt diese Aktion noch nicht aus, daher wird sie übersprungen." add_action = "Aktion hinzufügen" add_condition = "Bedingung hinzufügen" auto_name_empty = "Automatisierung: {trigger}" browse = "Durchsuchen" check_compatibility = "Kompatibilität prüfen" -compatibility_checked = "Kompatibilität geprüft: Diese Automatisierung läuft noch nicht in Cap. Gespeicherte Regeln bleiben für die Cap-CLI verfügbar. Es wurden keine Aktionen ausgeführt." +compatibility_checked = "Kompatibilität geprüft: Jede Aktion dieser Automatisierung läuft in Cap. Es wurden keine Aktionen ausgeführt." +compatibility_unsupported = "Kompatibilität geprüft: Texterkennung läuft noch nicht in Cap und wird übersprungen. Die übrigen Aktionen laufen. Es wurden keine Aktionen ausgeführt." condition_never_matches = "Diese Bedingung trifft beim gewählten Auslöser nie zu." copy_link = "Link in die Zwischenablage kopieren" -dangerous = "In der Cap-CLI führt diese Automatisierung Befehle aus oder sendet Netzwerkanfragen mit Ihren Berechtigungen. Verwenden Sie nur Werte, denen Sie vertrauen." +dangerous = "Diese Automatisierung führt Befehle aus oder sendet Netzwerkanfragen mit Ihren Berechtigungen. Verwenden Sie nur Werte, denen Sie vertrauen." delete = "Löschen" -description = "Regeln werden mit der Cap-CLI geteilt. Cap speichert diese Regeln, führt Automatisierungen aber noch nicht aus." +delete_guarded = "Löscht die Aufnahme erst, wenn der Schritt darüber gelingt und seine Datei geprüft ist, und lässt den Editor dafür geschlossen. Andernfalls bleibt alles erhalten." +delete_needs_copy = "Es wird nichts gelöscht. Setze direkt über diesen Schritt „Mit Profil exportieren“ in einen Ordner deiner Wahl oder „Am gewählten Ort speichern“." +notify_needs_setting = "Wird nur angezeigt, solange Systembenachrichtigungen in den allgemeinen Einstellungen aktiviert sind." +description = "Regeln werden mit der Cap-CLI geteilt. Cap führt aktivierte Regeln automatisch aus." empty_description = "Wählen Sie unten eine Vorlage, um mit einem Klick zu starten, oder erstellen Sie Ihre eigene von Grund auf." empty_title = "Noch keine Automatisierungen" enabled = "Aktiviert" diff --git a/apps/desktop-gpui/locales/en.toml b/apps/desktop-gpui/locales/en.toml index 09db6d59673..84a31e6c100 100644 --- a/apps/desktop-gpui/locales/en.toml +++ b/apps/desktop-gpui/locales/en.toml @@ -742,17 +742,22 @@ working_for = { text = "Google Drive connection is working for {email}", context [settings.automations] action_no_effect = "This action has no effect for the selected trigger." +action_unsupported = "Cap doesn't run this action yet, so it is skipped." add_action = "Add action" add_condition = "Add condition" auto_name_empty = { text = "{trigger} automation", context = "{trigger} is a settings.automations.trigger.*.noun." } browse = "Browse" check_compatibility = "Check compatibility" -compatibility_checked = "Compatibility checked: this automation doesn't run in Cap yet. Saved rules remain available to the Cap CLI. No actions were run." +compatibility_checked = "Compatibility checked: every action in this automation runs in Cap. No actions were run." +compatibility_unsupported = "Compatibility checked: text recognition doesn't run in Cap yet and will be skipped. The other actions run. No actions were run." condition_never_matches = "This condition never matches for the selected trigger." copy_link = "Copy link to clipboard" -dangerous = "In the Cap CLI, this automation runs commands or sends network requests with your permissions. Only use values you trust." +dangerous = "This automation runs commands or sends network requests with your permissions. Only use values you trust." delete = "Delete" -description = "Rules are shared with the Cap CLI. Cap saves these rules but does not run automations yet." +delete_guarded = "Deletes the recording only once the step above succeeds and its file is checked, and keeps the editor closed so it can. Otherwise everything is kept." +delete_needs_copy = "Nothing will be deleted. Put an Export with profile to a folder you choose, or a Save to location, right above this step." +notify_needs_setting = "Shows only while System notifications is on in General settings." +description = "Rules are shared with the Cap CLI. Cap runs enabled rules automatically." empty_description = "Pick a template below to get started in one click, or build your own from scratch." empty_title = "No automations yet" enabled = "Enabled" diff --git a/apps/desktop-gpui/locales/es.toml b/apps/desktop-gpui/locales/es.toml index 3bc7f030c36..e47aaa02153 100644 --- a/apps/desktop-gpui/locales/es.toml +++ b/apps/desktop-gpui/locales/es.toml @@ -740,17 +740,22 @@ working_for = "La conexión de Google Drive funciona para {email}" [settings.automations] action_no_effect = "Esta acción no tiene efecto con el disparador seleccionado." +action_unsupported = "Cap todavía no ejecuta esta acción, así que se omite." add_action = "Añadir acción" add_condition = "Añadir condición" auto_name_empty = "Automatización: {trigger}" browse = "Examinar" check_compatibility = "Comprobar compatibilidad" -compatibility_checked = "Compatibilidad comprobada: esta automatización todavía no se ejecuta en Cap. Las reglas guardadas siguen disponibles para la CLI de Cap. No se ejecutó ninguna acción." +compatibility_checked = "Compatibilidad comprobada: todas las acciones de esta automatización se ejecutan en Cap. No se ejecutó ninguna acción." +compatibility_unsupported = "Compatibilidad comprobada: el reconocimiento de texto todavía no se ejecuta en Cap y se omitirá. Las demás acciones se ejecutan. No se ejecutó ninguna acción." condition_never_matches = "Esta condición nunca se cumple con el disparador seleccionado." copy_link = "Copiar el enlace al portapapeles" -dangerous = "En la CLI de Cap, esta automatización ejecuta comandos o envía solicitudes de red con tus permisos. Usa solo valores de confianza." +dangerous = "Esta automatización ejecuta comandos o envía solicitudes de red con tus permisos. Usa solo valores de confianza." delete = "Eliminar" -description = "Las reglas se comparten con la CLI de Cap. Cap guarda estas reglas, pero todavía no ejecuta automatizaciones." +delete_guarded = "Elimina la grabación solo cuando el paso anterior termina bien y se comprueba su archivo, y deja el editor cerrado para poder hacerlo. Si no, se conserva todo." +delete_needs_copy = "No se eliminará nada. Coloca justo encima de este paso «Exportar con un perfil» a una carpeta que elijas o «Guardar en una ubicación»." +notify_needs_setting = "Solo se muestra mientras las notificaciones del sistema estén activadas en los ajustes generales." +description = "Las reglas se comparten con la CLI de Cap. Cap ejecuta automáticamente las reglas activadas." empty_description = "Elige una plantilla de abajo para empezar con un clic o crea la tuya desde cero." empty_title = "Aún no hay automatizaciones" enabled = "Activada" diff --git a/apps/desktop-gpui/locales/fr.toml b/apps/desktop-gpui/locales/fr.toml index 7d32287f919..130e417653d 100644 --- a/apps/desktop-gpui/locales/fr.toml +++ b/apps/desktop-gpui/locales/fr.toml @@ -740,17 +740,22 @@ working_for = "La connexion Google Drive fonctionne pour {email}" [settings.automations] action_no_effect = "Cette action n'a aucun effet avec le déclencheur sélectionné." +action_unsupported = "Cap n'exécute pas encore cette action, elle est donc ignorée." add_action = "Ajouter une action" add_condition = "Ajouter une condition" auto_name_empty = "Automatisation {trigger}" browse = "Parcourir" check_compatibility = "Vérifier la compatibilité" -compatibility_checked = "Compatibilité vérifiée : cette automatisation ne s'exécute pas encore dans Cap. Les règles enregistrées restent disponibles pour la CLI Cap. Aucune action n'a été exécutée." +compatibility_checked = "Compatibilité vérifiée : toutes les actions de cette automatisation s'exécutent dans Cap. Aucune action n'a été exécutée." +compatibility_unsupported = "Compatibilité vérifiée : la reconnaissance de texte ne s'exécute pas encore dans Cap et sera ignorée. Les autres actions s'exécutent. Aucune action n'a été exécutée." condition_never_matches = "Cette condition ne correspond jamais au déclencheur sélectionné." copy_link = "Copier le lien dans le presse-papiers" -dangerous = "Dans la CLI Cap, cette automatisation exécute des commandes ou envoie des requêtes réseau avec vos autorisations. N'utilisez que des valeurs de confiance." +dangerous = "Cette automatisation exécute des commandes ou envoie des requêtes réseau avec vos autorisations. N'utilisez que des valeurs de confiance." delete = "Supprimer" -description = "Les règles sont partagées avec la CLI Cap. Cap enregistre ces règles mais n'exécute pas encore les automatisations." +delete_guarded = "Supprime l'enregistrement seulement si l'étape au-dessus réussit et que son fichier est vérifié, et garde l'éditeur fermé pour cela. Sinon, tout est conservé." +delete_needs_copy = "Rien ne sera supprimé. Placez juste au-dessus de cette étape « Exporter avec un profil » vers un dossier de votre choix ou « Enregistrer à un emplacement »." +notify_needs_setting = "S'affiche seulement si les notifications système sont activées dans les réglages généraux." +description = "Les règles sont partagées avec la CLI Cap. Cap exécute automatiquement les règles activées." empty_description = "Choisissez un modèle ci-dessous pour démarrer en un clic, ou créez la vôtre de zéro." empty_title = "Aucune automatisation pour l'instant" enabled = "Activée" diff --git a/apps/desktop-gpui/locales/hi.toml b/apps/desktop-gpui/locales/hi.toml index c01b160cd3c..679436881aa 100644 --- a/apps/desktop-gpui/locales/hi.toml +++ b/apps/desktop-gpui/locales/hi.toml @@ -740,17 +740,22 @@ working_for = "{email} के लिए Google Drive कनेक्शन क [settings.automations] action_no_effect = "चुने गए ट्रिगर के लिए इस कार्रवाई का कोई असर नहीं होता।" +action_unsupported = "Cap अभी यह कार्रवाई नहीं चलाता, इसलिए इसे छोड़ दिया जाता है।" add_action = "कार्रवाई जोड़ें" add_condition = "शर्त जोड़ें" auto_name_empty = "{trigger} ऑटोमेशन" browse = "ब्राउज़ करें" check_compatibility = "कम्पैटिबिलिटी जाँचें" -compatibility_checked = "कम्पैटिबिलिटी जाँची गई: यह ऑटोमेशन अभी Cap में नहीं चलता। सेव किए गए नियम Cap CLI के लिए उपलब्ध रहते हैं। कोई कार्रवाई नहीं चलाई गई।" +compatibility_checked = "कम्पैटिबिलिटी जाँची गई: इस ऑटोमेशन की हर कार्रवाई Cap में चलती है। कोई कार्रवाई नहीं चलाई गई।" +compatibility_unsupported = "कम्पैटिबिलिटी जाँची गई: टेक्स्ट पहचान अभी Cap में नहीं चलती और छोड़ दी जाएगी। बाकी कार्रवाइयाँ चलती हैं। कोई कार्रवाई नहीं चलाई गई।" condition_never_matches = "चुने गए ट्रिगर के लिए यह शर्त कभी पूरी नहीं होती।" copy_link = "लिंक क्लिपबोर्ड पर कॉपी करें" -dangerous = "Cap CLI में यह ऑटोमेशन आपकी अनुमतियों से कमांड चलाता है या नेटवर्क अनुरोध भेजता है। सिर्फ़ भरोसेमंद वैल्यू इस्तेमाल करें।" +dangerous = "यह ऑटोमेशन आपकी अनुमतियों से कमांड चलाता है या नेटवर्क अनुरोध भेजता है। सिर्फ़ भरोसेमंद वैल्यू इस्तेमाल करें।" delete = "हटाएँ" -description = "नियम Cap CLI के साथ साझा होते हैं। Cap इन नियमों को सेव करता है, लेकिन अभी ऑटोमेशन नहीं चलाता।" +delete_guarded = "ऊपर वाला चरण सफल होने और उसकी फ़ाइल जाँचे जाने के बाद ही रिकॉर्डिंग हटाई जाती है, और इसके लिए एडिटर बंद रहता है। वरना सब कुछ रखा जाता है।" +delete_needs_copy = "कुछ भी नहीं हटाया जाएगा। इस चरण के ठीक ऊपर अपने चुने फ़ोल्डर में \"प्रोफ़ाइल के साथ एक्सपोर्ट करें\" या \"किसी जगह पर सेव करें\" रखें।" +notify_needs_setting = "यह तभी दिखता है जब सामान्य सेटिंग्स में सिस्टम नोटिफ़िकेशन चालू हों।" +description = "नियम Cap CLI के साथ साझा होते हैं। Cap चालू नियमों को अपने-आप चलाता है।" empty_description = "एक क्लिक में शुरू करने के लिए नीचे कोई टेम्पलेट चुनें, या शुरुआत से अपना बनाएँ।" empty_title = "अभी कोई ऑटोमेशन नहीं" enabled = "चालू" diff --git a/apps/desktop-gpui/locales/ja.toml b/apps/desktop-gpui/locales/ja.toml index 5ae6a6237cd..13b8e54ec74 100644 --- a/apps/desktop-gpui/locales/ja.toml +++ b/apps/desktop-gpui/locales/ja.toml @@ -740,17 +740,22 @@ working_for = "{email}のGoogle Drive接続は正常です" [settings.automations] action_no_effect = "このアクションは選択したトリガーでは効果がありません。" +action_unsupported = "このアクションはまだ Cap で実行されないため、スキップされます。" add_action = "アクションを追加" add_condition = "条件を追加" auto_name_empty = "{trigger}のオートメーション" browse = "参照" check_compatibility = "互換性を確認" -compatibility_checked = "互換性を確認しました:このオートメーションはまだCapでは実行されません。保存したルールはCap CLIで引き続き使えます。アクションは実行されていません。" +compatibility_checked = "互換性を確認しました:このオートメーションのすべてのアクションはCapで実行されます。アクションは実行されていません。" +compatibility_unsupported = "互換性を確認しました:テキスト認識はまだCapでは実行されないため、スキップされます。そのほかのアクションは実行されます。アクションは実行されていません。" condition_never_matches = "この条件は選択したトリガーでは一致しません。" copy_link = "リンクをクリップボードにコピー" -dangerous = "Cap CLIでは、このオートメーションはあなたの権限でコマンドを実行したりネットワークリクエストを送信したりします。信頼できる値だけを使ってください。" +dangerous = "このオートメーションはあなたの権限でコマンドを実行したりネットワークリクエストを送信したりします。信頼できる値だけを使ってください。" delete = "削除" -description = "ルールはCap CLIと共有されます。Capはこれらのルールを保存しますが、オートメーションはまだ実行しません。" +delete_guarded = "上のステップが成功し、そのファイルを確認できた場合にのみ録画を削除します。そのためエディターは開きません。それ以外はすべて残します。" +delete_needs_copy = "何も削除されません。このステップのすぐ上に、選んだフォルダーへの「プロファイルで書き出し」か「指定の場所に保存」を置いてください。" +notify_needs_setting = "一般設定でシステム通知がオンのときだけ表示されます。" +description = "ルールはCap CLIと共有されます。有効なルールはCapが自動で実行します。" empty_description = "下のテンプレートを選べばワンクリックで始められます。一から自分で作ることもできます。" empty_title = "オートメーションはまだありません" enabled = "有効" diff --git a/apps/desktop-gpui/locales/zh-CN.toml b/apps/desktop-gpui/locales/zh-CN.toml index 19c4fba9dfc..f71059f3cf5 100644 --- a/apps/desktop-gpui/locales/zh-CN.toml +++ b/apps/desktop-gpui/locales/zh-CN.toml @@ -740,17 +740,22 @@ working_for = "{email} 的 Google Drive 连接正常" [settings.automations] action_no_effect = "对所选触发器而言,此操作没有效果。" +action_unsupported = "Cap 暂不运行此操作,因此会跳过。" add_action = "添加操作" add_condition = "添加条件" auto_name_empty = "{trigger}自动化" browse = "浏览" check_compatibility = "检查兼容性" -compatibility_checked = "已检查兼容性:此自动化暂时还不会在 Cap 中运行。已保存的规则仍可供 Cap CLI 使用。未执行任何操作。" +compatibility_checked = "已检查兼容性:此自动化中的每个操作都会在 Cap 中运行。未执行任何操作。" +compatibility_unsupported = "已检查兼容性:文字识别暂时还不会在 Cap 中运行,将被跳过。其他操作会运行。未执行任何操作。" condition_never_matches = "对所选触发器而言,此条件永远不会满足。" copy_link = "将链接复制到剪贴板" -dangerous = "在 Cap CLI 中,此自动化会以你的权限运行命令或发送网络请求。请只使用你信任的值。" +dangerous = "此自动化会以你的权限运行命令或发送网络请求。请只使用你信任的值。" delete = "删除" -description = "规则与 Cap CLI 共享。Cap 会保存这些规则,但暂时还不会运行自动化。" +delete_guarded = "只有在上一步成功且其文件通过检查后才会删除录制,为此编辑器不会打开,否则全部保留。" +delete_needs_copy = "不会删除任何内容。请在此步骤正上方放置导出到所选文件夹的“按配置导出”或“保存到指定位置”。" +notify_needs_setting = "仅在通用设置中开启系统通知时显示。" +description = "规则与 Cap CLI 共享。Cap 会自动运行已启用的规则。" empty_description = "选择下方的模板一键开始,或从头创建你自己的自动化。" empty_title = "还没有自动化" enabled = "已启用" diff --git a/apps/desktop-gpui/src/app_windows.rs b/apps/desktop-gpui/src/app_windows.rs index 472964ca556..846a861a3b1 100644 --- a/apps/desktop-gpui/src/app_windows.rs +++ b/apps/desktop-gpui/src/app_windows.rs @@ -634,10 +634,11 @@ pub fn init(main: WindowHandle, session: Entity, c if !restore_clean_capture_ui(cx) { return; } - let (finished_studio, preparing_editor, finished_instant, deleted) = + let (finished_studio, studio_behaviour, preparing_editor, finished_instant, deleted) = session.update(cx, |session, _| { ( session.finished_studio.take(), + session.studio_behaviour.take(), session.take_preparing_studio_editor(), std::mem::take(&mut session.finished_instant), std::mem::take(&mut session.deleted_recording), @@ -687,7 +688,8 @@ pub fn init(main: WindowHandle, session: Entity, c // deleted from the bar reshows it only for "Reopen recording // window", as the Tauri `delete_recording` did. let settings = crate::store::GeneralSettings::load(); - let behaviour = settings.post_studio_recording_behaviour; + let behaviour = + studio_behaviour.unwrap_or(settings.post_studio_recording_behaviour); // Linux restores the main window through the clean-capture // lease before this runs, so it keeps reshowing as before. A // main window reopened mid-recording (even if minimized since) @@ -767,8 +769,7 @@ fn open_preparing_studio_editor(session: &Entity, cx: &mut App if !pending.capture_stopped || pending.presentation != StudioEditorPresentation::Pending || !pending.finalization.is_finalizing() - || crate::store::GeneralSettings::load().post_studio_recording_behaviour - != crate::store::PostStudioBehaviour::OpenEditor + || session.read(cx).studio_behaviour != Some(crate::store::PostStudioBehaviour::OpenEditor) { return; } @@ -7497,7 +7498,7 @@ pub fn empty_overlays_for_screenshot(cx: &mut App) -> Option