Skip to content

Commit b5b5c03

Browse files
committed
refactor: remove noise comments and move SDK init to auth store
1. Remove redundant comments from recallRecording.ts that just restate what the code already says clearly 2. Move Recall SDK initialization from React useEffect to zustand auth store, where it naturally belongs alongside credential management. SDK now initializes automatically when credentials are set or retrieved, without React lifecycle coupling.
1 parent 7c52f9b commit b5b5c03

File tree

3 files changed

+21
-55
lines changed

3 files changed

+21
-55
lines changed

src/main/services/recallRecording.ts

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ const activeSessions = new Map<string, RecordingSession>();
1212
let posthogClient: PostHogAPIClient | null = null;
1313
let sdkInitialized = false;
1414

15-
/**
16-
* Check if Recall SDK has already been initialized
17-
*/
1815
export function isRecallSDKInitialized(): boolean {
1916
return sdkInitialized;
2017
}
@@ -24,17 +21,14 @@ export function initializeRecallSDK(
2421
posthogKey: string,
2522
posthogHost: string,
2623
) {
27-
// Guard: Prevent multiple initializations
2824
if (sdkInitialized) {
2925
return;
3026
}
3127

3228
console.log("[Recall SDK] Initializing...");
3329

34-
// Create PostHog API client for making API calls
3530
posthogClient = new PostHogAPIClient(posthogKey, posthogHost);
3631

37-
// Initialize Recall SDK
3832
RecallAiSdk.init({
3933
apiUrl: recallApiUrl,
4034
acquirePermissionsOnStartup: [
@@ -45,7 +39,6 @@ export function initializeRecallSDK(
4539
restartOnError: true,
4640
});
4741

48-
// Mark as initialized
4942
sdkInitialized = true;
5043

5144
console.log("[Recall SDK] Ready. Listening for meetings...");
@@ -72,17 +65,14 @@ export function initializeRecallSDK(
7265
throw new Error("PostHog client not initialized");
7366
}
7467

75-
// Create upload token via PostHog API
7668
const { upload_token, recording_id } =
7769
await posthogClient.createDesktopRecordingUpload(platform);
7870

79-
// Start recording with Recall SDK
8071
await RecallAiSdk.startRecording({
8172
windowId: evt.window.id,
8273
uploadToken: upload_token,
8374
});
8475

85-
// Store session info
8676
activeSessions.set(evt.window.id, {
8777
windowId: evt.window.id,
8878
recordingId: recording_id,
@@ -97,21 +87,15 @@ export function initializeRecallSDK(
9787

9888
RecallAiSdk.addEventListener("sdk-state-change", async (evt) => {
9989
const state = evt.sdk.state.code;
100-
// Only log non-recording states for debugging
10190
if (state !== "recording") {
10291
console.log(`[Recall SDK] State: ${state}`);
10392
}
10493
});
10594

106-
RecallAiSdk.addEventListener("recording-started", async (_evt) => {
107-
// Handled by meeting-detected event
108-
});
109-
11095
RecallAiSdk.addEventListener("recording-ended", async (evt) => {
11196
try {
11297
console.log("[Recall SDK] Recording ended, uploading...");
11398

114-
// Upload the recording
11599
await RecallAiSdk.uploadRecording({
116100
windowId: evt.window.id,
117101
});
@@ -124,25 +108,18 @@ export function initializeRecallSDK(
124108
if (evt.progress === 100) {
125109
console.log("[Recall SDK] Upload complete");
126110
}
127-
// TODO: Send progress to renderer for UI updates
128111
});
129112

130113
RecallAiSdk.addEventListener("meeting-closed", async (evt) => {
131114
console.log("[Recall SDK] Meeting closed");
132115
activeSessions.delete(evt.window.id);
133116
});
134117

135-
RecallAiSdk.addEventListener("meeting-updated", async (_evt) => {
136-
// Metadata updates are too frequent to log
137-
});
118+
RecallAiSdk.addEventListener("meeting-updated", async (_evt) => {});
138119

139-
RecallAiSdk.addEventListener("media-capture-status", async (_evt) => {
140-
// Capture status changes are too frequent to log
141-
});
120+
RecallAiSdk.addEventListener("media-capture-status", async (_evt) => {});
142121

143-
RecallAiSdk.addEventListener("realtime-event", async (_evt) => {
144-
// TODO: Handle real-time transcript segments (Phase 2)
145-
});
122+
RecallAiSdk.addEventListener("realtime-event", async (_evt) => {});
146123

147124
RecallAiSdk.addEventListener("error", async (evt) => {
148125
console.error(
@@ -160,9 +137,6 @@ export function initializeRecallSDK(
160137
});
161138
}
162139

163-
/**
164-
* Detect meeting platform from window metadata
165-
*/
166140
function detectPlatform(window: { url?: string; title?: string }): string {
167141
const url = window.url?.toLowerCase() || "";
168142
const title = window.title?.toLowerCase() || "";
@@ -186,32 +160,20 @@ function detectPlatform(window: { url?: string; title?: string }): string {
186160
return "desktop_audio";
187161
}
188162

189-
/**
190-
* Request a specific permission
191-
*/
192163
export function requestRecallPermission(
193164
permission: "accessibility" | "screen-capture" | "microphone",
194165
) {
195166
RecallAiSdk.requestPermission(permission);
196167
}
197168

198-
/**
199-
* Shutdown the Recall SDK
200-
*/
201169
export function shutdownRecallSDK() {
202170
RecallAiSdk.shutdown();
203171
}
204172

205-
/**
206-
* Get active recording sessions
207-
*/
208173
export function getActiveSessions() {
209174
return Array.from(activeSessions.values());
210175
}
211176

212-
/**
213-
* Register IPC handlers for Recall SDK
214-
*/
215177
export function registerRecallIPCHandlers() {
216178
ipcMain.handle(
217179
"recall:initialize",

src/renderer/App.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,14 @@ import { AuthScreen } from "./components/AuthScreen";
44
import { MainLayout } from "./components/MainLayout";
55
import { useAuthStore } from "./stores/authStore";
66

7-
const RECALL_API_URL = "https://us-west-2.recall.ai";
8-
97
function App() {
10-
const { isAuthenticated, checkAuth, apiKey, apiHost } = useAuthStore();
8+
const { isAuthenticated, checkAuth } = useAuthStore();
119
const [isLoading, setIsLoading] = useState(true);
1210

1311
useEffect(() => {
1412
checkAuth().finally(() => setIsLoading(false));
1513
}, [checkAuth]);
1614

17-
// Initialize Recall SDK when authenticated (main process prevents duplicate inits)
18-
useEffect(() => {
19-
if (isAuthenticated && apiKey && apiHost) {
20-
window.electronAPI
21-
.recallInitialize(RECALL_API_URL, apiKey, apiHost)
22-
.catch((error) => {
23-
console.error("[App] Failed to initialize Recall SDK:", error);
24-
});
25-
}
26-
}, [isAuthenticated, apiKey, apiHost]);
27-
2815
if (isLoading) {
2916
return (
3017
<Flex align="center" justify="center" minHeight="100vh">

src/renderer/stores/authStore.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { PostHogAPIClient } from "@api/posthogClient";
22
import { create } from "zustand";
33
import { persist } from "zustand/middleware";
44

5+
const RECALL_API_URL = "https://us-west-2.recall.ai";
6+
57
interface AuthState {
68
apiKey: string | null;
79
apiHost: string;
@@ -43,6 +45,12 @@ export const useAuthStore = create<AuthState>()(
4345
isAuthenticated: true,
4446
client,
4547
});
48+
49+
window.electronAPI
50+
.recallInitialize(RECALL_API_URL, apiKey, apiHost)
51+
.catch((error) => {
52+
console.error("[Auth] Failed to initialize Recall SDK:", error);
53+
});
4654
} catch (_error) {
4755
throw new Error("Invalid API key or host");
4856
}
@@ -75,6 +83,15 @@ export const useAuthStore = create<AuthState>()(
7583
isAuthenticated: true,
7684
client,
7785
});
86+
87+
window.electronAPI
88+
.recallInitialize(RECALL_API_URL, decryptedKey, state.apiHost)
89+
.catch((error) => {
90+
console.error(
91+
"[Auth] Failed to initialize Recall SDK:",
92+
error,
93+
);
94+
});
7895
} catch {
7996
set({ encryptedKey: null, isAuthenticated: false });
8097
}

0 commit comments

Comments
 (0)