Skip to content

Commit 32383d0

Browse files
committed
fix: store extracted tasks per-recording in backend
- Update uploadDesktopRecordingTranscript to accept extracted_tasks - Save extracted tasks to backend RecordingTranscript model - Fetch tasks from backend transcript instead of mutation state - Each recording now has its own tasks properly isolated This fixes the bug where all recordings were showing the same tasks.
1 parent a243bef commit 32383d0

File tree

4 files changed

+41
-17
lines changed

4 files changed

+41
-17
lines changed

src/api/posthogClient.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ export class PostHogAPIClient {
413413
text: string;
414414
confidence: number | null;
415415
}>;
416+
extracted_tasks?: Array<{
417+
title: string;
418+
description: string;
419+
}>;
416420
},
417421
) {
418422
this.validateRecordingId(recordingId);

src/renderer/features/notetaker/components/LiveTranscriptView.tsx

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { useEffect, useRef, useState } from "react";
1414
import { useAuthStore } from "../../../stores/authStore";
1515
import { useExtractTasks } from "../hooks/useExtractTasks";
16-
import { useLiveTranscript } from "../hooks/useTranscript";
16+
import { useLiveTranscript, useTranscript } from "../hooks/useTranscript";
1717

1818
interface LiveTranscriptViewProps {
1919
posthogRecordingId: string; // PostHog UUID
@@ -29,6 +29,7 @@ export function LiveTranscriptView({
2929
const { segments, addSegment, forceUpload, pendingCount } =
3030
useLiveTranscript(posthogRecordingId);
3131

32+
const { data: transcriptData } = useTranscript(posthogRecordingId);
3233
const extractTasksMutation = useExtractTasks();
3334

3435
const handleExtractTasks = () => {
@@ -246,24 +247,18 @@ export function LiveTranscriptView({
246247
</Button>
247248
</Flex>
248249

249-
{!openaiApiKey && (
250+
{!openaiApiKey && !transcriptData?.extracted_tasks && (
250251
<Card>
251252
<Text size="2" color="gray">
252253
Add OpenAI API key in settings to extract tasks
253254
</Text>
254255
</Card>
255256
)}
256257

257-
{extractTasksMutation.isSuccess && extractTasksMutation.data && (
258-
<Flex direction="column" gap="2">
259-
{extractTasksMutation.data.tasks.length === 0 ? (
260-
<Card>
261-
<Text size="2" color="gray">
262-
No tasks found in transcript
263-
</Text>
264-
</Card>
265-
) : (
266-
extractTasksMutation.data.tasks.map((task, idx) => (
258+
{transcriptData?.extracted_tasks &&
259+
transcriptData.extracted_tasks.length > 0 && (
260+
<Flex direction="column" gap="2">
261+
{transcriptData.extracted_tasks.map((task, idx) => (
267262
<Card key={`${task.title}-${idx}`}>
268263
<Flex direction="column" gap="1">
269264
<Text size="2" weight="medium">
@@ -274,10 +269,18 @@ export function LiveTranscriptView({
274269
</Text>
275270
</Flex>
276271
</Card>
277-
))
278-
)}
279-
</Flex>
280-
)}
272+
))}
273+
</Flex>
274+
)}
275+
276+
{transcriptData?.extracted_tasks &&
277+
transcriptData.extracted_tasks.length === 0 && (
278+
<Card>
279+
<Text size="2" color="gray">
280+
No tasks found in transcript
281+
</Text>
282+
</Card>
283+
)}
281284

282285
{extractTasksMutation.isError && (
283286
<Card>

src/renderer/features/notetaker/hooks/useExtractTasks.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface ExtractedTask {
88

99
export function useExtractTasks() {
1010
const openaiApiKey = useAuthStore((state) => state.openaiApiKey);
11+
const { client } = useAuthStore();
1112
const queryClient = useQueryClient();
1213

1314
return useMutation({
@@ -22,15 +23,27 @@ export function useExtractTasks() {
2223
throw new Error("OpenAI API key not configured");
2324
}
2425

26+
if (!client) {
27+
throw new Error("Not authenticated");
28+
}
29+
30+
// Extract tasks using AI
2531
const tasks = await window.electronAPI.notetakerExtractTasks(
2632
transcriptText,
2733
openaiApiKey,
2834
);
2935

36+
// Upload tasks to backend
37+
await client.uploadDesktopRecordingTranscript(recordingId, {
38+
full_text: transcriptText,
39+
segments: [], // Segments already uploaded
40+
extracted_tasks: tasks,
41+
});
42+
3043
return { tasks, recordingId };
3144
},
3245
onSuccess: (data) => {
33-
// Invalidate recording query to refetch with new tasks
46+
// Invalidate queries to refetch with new tasks from backend
3447
queryClient.invalidateQueries({
3548
queryKey: ["notetaker-recording", data.recordingId],
3649
});

src/renderer/features/notetaker/hooks/useTranscript.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export interface TranscriptSegment {
1212
interface TranscriptData {
1313
full_text: string;
1414
segments: TranscriptSegment[];
15+
extracted_tasks?: Array<{
16+
title: string;
17+
description: string;
18+
}>;
1519
}
1620

1721
export function useTranscript(recordingId: string | null) {

0 commit comments

Comments
 (0)