Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/tray menu/shortcut recording #552

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions screenpipe-app-tauri/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ ffmpeg*
*src-tauri/tesseract*
*src-tauri/bun*
*src-tauri/ollama*
*src-tauri/deno-*-apple-darwin
*src-tauri/deno-*-*

39 changes: 34 additions & 5 deletions screenpipe-app-tauri/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "@/components/ui/card";
import { Skeleton } from "@/components/ui/skeleton";

import React, { useEffect, useState } from "react";
import React, { useEffect, useState, useCallback } from "react";
import NotificationHandler from "@/components/notification-handler";
import ScreenpipeInstanceChecker from "@/components/screenpipe-instance-checker";
import Header from "@/components/header";
Expand All @@ -26,18 +26,47 @@ import { Separator } from "@/components/ui/separator";
import Onboarding from "@/components/onboarding";
import { useOnboarding } from "@/lib/hooks/use-onboarding";
import { registerShortcuts } from "@/lib/shortcuts";
import { debounce } from 'lodash';

export default function Home() {
const { settings } = useSettings();
const posthog = usePostHog();
const { toast } = useToast();
const { showOnboarding, setShowOnboarding } = useOnboarding();

// Create a debounced version of registerShortcuts
const debouncedRegisterShortcuts = useCallback(
debounce(async (config) => {
try {
await registerShortcuts(config);
} catch (error) {
console.error('Failed to register shortcuts:', error);
}
}, 1000),
[]
);

useEffect(() => {
registerShortcuts({
showScreenpipeShortcut: settings.showScreenpipeShortcut,
});
}, [settings.showScreenpipeShortcut]);
if (!settings.isLoading) {
const config = {
show_screenpipe_shortcut: settings.showScreenpipeShortcut,
toggle_recording_shortcut: settings.recordingShortcut,
Copy link
Collaborator

Choose a reason for hiding this comment

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

does it save now? let me know

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it does. I'll make a demo video in an hour or so.

};

console.log("Page: Registering shortcuts with config:", config);

// Only register if we have valid shortcuts
if (config.show_screenpipe_shortcut && config.toggle_recording_shortcut) {
debouncedRegisterShortcuts(config);
} else {
console.warn("Invalid shortcut configuration:", config);
}

return () => {
debouncedRegisterShortcuts.cancel();
};
}
}, [settings.showScreenpipeShortcut, settings.recordingShortcut, settings.isLoading, debouncedRegisterShortcuts]);

useEffect(() => {
if (settings.userId) {
Expand Down
24 changes: 24 additions & 0 deletions screenpipe-app-tauri/components/notification-handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,30 @@ const NotificationHandler: React.FC = () => {
});
};

listen<string>("recording_failed", (event) => {
console.log(`recording failed ${event.payload}`);
sendNotification({
title: "Screenpipe",
body: event.payload,
});
});

listen<string>("recording_started", (event) => {
console.log(`recording started ${event.payload}`);
sendNotification({
title: "Screenpipe",
body: event.payload,
});
});

listen<string>("recording_stopped", (event) => {
console.log(`recording stopped ${event.payload}`);
sendNotification({
title: "Screenpipe",
body: event.payload,
});
});

checkAndRequestPermission();
}, []);

Expand Down
Loading
Loading