diff --git a/apps/desktop/src/components/ProjectSettingsMenuAction.svelte b/apps/desktop/src/components/ProjectSettingsMenuAction.svelte index 187503b8b5..c1e4859528 100644 --- a/apps/desktop/src/components/ProjectSettingsMenuAction.svelte +++ b/apps/desktop/src/components/ProjectSettingsMenuAction.svelte @@ -6,7 +6,7 @@ import { ShortcutService } from '$lib/shortcuts/shortcutService.svelte'; import * as events from '$lib/utils/events'; import { unsubscribe } from '$lib/utils/unsubscribe'; - import { getEditorUri, openExternalUrl } from '$lib/utils/url'; + import { getEditorUri, openExternalFile, openExternalUrl } from '$lib/utils/url'; import { getContextStoreBySymbol } from '@gitbutler/shared/context'; import { getContext } from '@gitbutler/shared/context'; import { onMount } from 'svelte'; @@ -30,6 +30,10 @@ openExternalUrl(path); }); + shortcutService.on('open-in-finder', () => { + openExternalFile(project.path); + }); + shortcutService.on('history', () => { $showHistoryView = !$showHistoryView; }); diff --git a/apps/desktop/src/lib/utils/url.ts b/apps/desktop/src/lib/utils/url.ts index 2049723f1c..2c48d1b9c6 100644 --- a/apps/desktop/src/lib/utils/url.ts +++ b/apps/desktop/src/lib/utils/url.ts @@ -22,6 +22,25 @@ export async function openExternalUrl(href: string) { } } +export async function openExternalFile(path: string) { + try { + // Use the Opener plugin to reveal the folder in the native file explorer + await invoke('plugin:opener|reveal_item_in_dir', { path: path }); + } catch (e) { + if (typeof e === 'string' || e instanceof String) { + const message = ` + Failed to reveal directory in file explorer: + + ${path} + `; + showToast({ title: 'Explorer error', message, style: 'error' }); + } + + // Rethrowing for sentry and posthog + throw e; + } +} + // turn a git remote url into a web url (github, gitlab, bitbucket, etc) export function convertRemoteToWebUrl(url: string): string { const gitRemote = GitUrlParse(url); diff --git a/crates/gitbutler-tauri/src/menu.rs b/crates/gitbutler-tauri/src/menu.rs index 13ddd0066f..68e2ffb7a4 100644 --- a/crates/gitbutler-tauri/src/menu.rs +++ b/crates/gitbutler-tauri/src/menu.rs @@ -172,6 +172,7 @@ pub fn build(handle: &AppHandle) -> tauri::Result anyhow::Result<()> { "zed", "windsurf", "cursor", + "file", ] .contains(&target_url.scheme()) {