Skip to content

Commit 0813cc0

Browse files
committed
add reveal session in finder
1 parent e200ebb commit 0813cc0

File tree

9 files changed

+97
-4
lines changed

9 files changed

+97
-4
lines changed

apps/desktop/src/components/main/sidebar/timeline/item.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { memo, useCallback, useMemo } from "react";
22

3+
import { commands as miscCommands } from "@hypr/plugin-misc";
34
import { Spinner } from "@hypr/ui/components/ui/spinner";
45
import {
56
Tooltip,
@@ -12,6 +13,7 @@ import { useListener } from "../../../../contexts/listener";
1213
import { useIsSessionEnhancing } from "../../../../hooks/useEnhancedNotes";
1314
import { deleteSessionCascade } from "../../../../store/tinybase/store/deleteSession";
1415
import * as main from "../../../../store/tinybase/store/main";
16+
import { save } from "../../../../store/tinybase/store/save";
1517
import { getOrCreateSessionForEventId } from "../../../../store/tinybase/store/sessions";
1618
import { type TabInput, useTabs } from "../../../../store/zustand/tabs";
1719
import {
@@ -245,9 +247,21 @@ const SessionItem = memo(
245247
void deleteSessionCascade(store, indexes, sessionId);
246248
}, [store, indexes, sessionId, invalidateResource]);
247249

250+
const handleRevealInFinder = useCallback(async () => {
251+
await save();
252+
await miscCommands.revealSessionInFinder(sessionId);
253+
}, [sessionId]);
254+
248255
const contextMenu = useMemo(
249-
() => [{ id: "delete", text: "Delete Completely", action: handleDelete }],
250-
[handleCmdClick, handleDelete],
256+
() => [
257+
{
258+
id: "reveal",
259+
text: "Reveal in Finder",
260+
action: handleRevealInFinder,
261+
},
262+
{ id: "delete", text: "Delete Completely", action: handleDelete },
263+
],
264+
[handleRevealInFinder, handleDelete],
251265
);
252266

253267
return (

plugins/misc/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const COMMANDS: &[&str] = &[
99
"audio_delete",
1010
"audio_path",
1111
"audio_import",
12+
"reveal_session_in_finder",
1213
];
1314

1415
fn main() {

plugins/misc/js/bindings.gen.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ async deleteSessionFolder(sessionId: string) : Promise<Result<null, string>> {
4141
async parseMeetingLink(text: string) : Promise<string | null> {
4242
return await TAURI_INVOKE("plugin:misc|parse_meeting_link", { text });
4343
},
44+
async revealSessionInFinder(sessionId: string) : Promise<Result<null, string>> {
45+
try {
46+
return { status: "ok", data: await TAURI_INVOKE("plugin:misc|reveal_session_in_finder", { sessionId }) };
47+
} catch (e) {
48+
if(e instanceof Error) throw e;
49+
else return { status: "error", error: e as any };
50+
}
51+
},
4452
async audioExist(sessionId: string) : Promise<Result<boolean, string>> {
4553
try {
4654
return { status: "ok", data: await TAURI_INVOKE("plugin:misc|audio_exist", { sessionId }) };
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Automatically generated - DO NOT EDIT!
2+
3+
"$schema" = "../../schemas/schema.json"
4+
5+
[[permission]]
6+
identifier = "allow-reveal-session-in-finder"
7+
description = "Enables the reveal_session_in_finder command without any pre-configured scope."
8+
commands.allow = ["reveal_session_in_finder"]
9+
10+
[[permission]]
11+
identifier = "deny-reveal-session-in-finder"
12+
description = "Denies the reveal_session_in_finder command without any pre-configured scope."
13+
commands.deny = ["reveal_session_in_finder"]

plugins/misc/permissions/autogenerated/reference.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Default permissions for the plugin
1414
- `allow-audio-exist`
1515
- `allow-audio-delete`
1616
- `allow-audio-import`
17+
- `allow-reveal-session-in-finder`
1718

1819
## Permission Table
1920

@@ -281,6 +282,32 @@ Enables the parse_meeting_link command without any pre-configured scope.
281282

282283
Denies the parse_meeting_link command without any pre-configured scope.
283284

285+
</td>
286+
</tr>
287+
288+
<tr>
289+
<td>
290+
291+
`misc:allow-reveal-session-in-finder`
292+
293+
</td>
294+
<td>
295+
296+
Enables the reveal_session_in_finder command without any pre-configured scope.
297+
298+
</td>
299+
</tr>
300+
301+
<tr>
302+
<td>
303+
304+
`misc:deny-reveal-session-in-finder`
305+
306+
</td>
307+
<td>
308+
309+
Denies the reveal_session_in_finder command without any pre-configured scope.
310+
284311
</td>
285312
</tr>
286313
</table>

plugins/misc/permissions/default.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ permissions = [
1111
"allow-audio-exist",
1212
"allow-audio-delete",
1313
"allow-audio-import",
14+
"allow-reveal-session-in-finder",
1415
]

plugins/misc/permissions/schemas/schema.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,22 @@
415415
"markdownDescription": "Denies the parse_meeting_link command without any pre-configured scope."
416416
},
417417
{
418-
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-get-git-hash`\n- `allow-get-fingerprint`\n- `allow-opinionated-md-to-html`\n- `allow-delete-session-folder`\n- `allow-parse-meeting-link`\n- `allow-audio-open`\n- `allow-audio-path`\n- `allow-audio-exist`\n- `allow-audio-delete`\n- `allow-audio-import`",
418+
"description": "Enables the reveal_session_in_finder command without any pre-configured scope.",
419+
"type": "string",
420+
"const": "allow-reveal-session-in-finder",
421+
"markdownDescription": "Enables the reveal_session_in_finder command without any pre-configured scope."
422+
},
423+
{
424+
"description": "Denies the reveal_session_in_finder command without any pre-configured scope.",
425+
"type": "string",
426+
"const": "deny-reveal-session-in-finder",
427+
"markdownDescription": "Denies the reveal_session_in_finder command without any pre-configured scope."
428+
},
429+
{
430+
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-get-git-hash`\n- `allow-get-fingerprint`\n- `allow-opinionated-md-to-html`\n- `allow-delete-session-folder`\n- `allow-parse-meeting-link`\n- `allow-audio-open`\n- `allow-audio-path`\n- `allow-audio-exist`\n- `allow-audio-delete`\n- `allow-audio-import`\n- `allow-reveal-session-in-finder`",
419431
"type": "string",
420432
"const": "default",
421-
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-get-git-hash`\n- `allow-get-fingerprint`\n- `allow-opinionated-md-to-html`\n- `allow-delete-session-folder`\n- `allow-parse-meeting-link`\n- `allow-audio-open`\n- `allow-audio-path`\n- `allow-audio-exist`\n- `allow-audio-delete`\n- `allow-audio-import`"
433+
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-get-git-hash`\n- `allow-get-fingerprint`\n- `allow-opinionated-md-to-html`\n- `allow-delete-session-folder`\n- `allow-parse-meeting-link`\n- `allow-audio-open`\n- `allow-audio-path`\n- `allow-audio-exist`\n- `allow-audio-delete`\n- `allow-audio-import`\n- `allow-reveal-session-in-finder`"
422434
}
423435
]
424436
}

plugins/misc/src/commands.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,19 @@ pub async fn parse_meeting_link<R: tauri::Runtime>(
174174
) -> Option<String> {
175175
app.misc().parse_meeting_link(&text)
176176
}
177+
178+
#[tauri::command]
179+
#[specta::specta]
180+
pub async fn reveal_session_in_finder<R: tauri::Runtime>(
181+
app: tauri::AppHandle<R>,
182+
session_id: String,
183+
) -> Result<(), String> {
184+
let base = app.path2().base().map_err(|e| e.to_string())?;
185+
let session_dir = find_session_dir(&base.join("sessions"), &session_id);
186+
187+
app.opener()
188+
.reveal_item_in_dir(session_dir)
189+
.map_err(|e| e.to_string())?;
190+
191+
Ok(())
192+
}

plugins/misc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fn make_specta_builder<R: tauri::Runtime>() -> tauri_specta::Builder<R> {
1616
commands::opinionated_md_to_html::<tauri::Wry>,
1717
commands::delete_session_folder::<tauri::Wry>,
1818
commands::parse_meeting_link::<tauri::Wry>,
19+
commands::reveal_session_in_finder::<tauri::Wry>,
1920
commands::audio_exist::<tauri::Wry>,
2021
commands::audio_path::<tauri::Wry>,
2122
commands::audio_open::<tauri::Wry>,

0 commit comments

Comments
 (0)