-
Notifications
You must be signed in to change notification settings - Fork 892
/
Copy pathrecording-settings.tsx
1549 lines (1450 loc) · 54.7 KB
/
recording-settings.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"use client";
import React, { useEffect, useState } from "react";
import { Label } from "@/components/ui/label";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "./ui/select";
import { Button } from "@/components/ui/button";
import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
import {
Check,
ChevronsUpDown,
Eye,
HelpCircle,
Languages,
Mic,
Monitor,
Folder,
AppWindowMac,
EyeOff,
Key,
Terminal,
Asterisk,
} from "lucide-react";
import { cn } from "@/lib/utils";
import {
Command,
CommandInput,
CommandList,
CommandEmpty,
CommandGroup,
CommandItem,
} from "./ui/command";
import {
Settings,
useSettings,
VadSensitivity,
} from "@/lib/hooks/use-settings";
import { useToast } from "@/components/ui/use-toast";
import { useHealthCheck } from "@/lib/hooks/use-health-check";
import { invoke } from "@tauri-apps/api/core";
import { Badge } from "./ui/badge";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "./ui/tooltip";
import { Switch } from "./ui/switch";
import { Input } from "./ui/input";
import { Slider } from "./ui/slider";
import { platform } from "@tauri-apps/plugin-os";
import posthog from "posthog-js";
import { Language } from "@/lib/language";
import { open } from "@tauri-apps/plugin-dialog";
import { exists } from "@tauri-apps/plugin-fs";
import { Command as ShellCommand } from "@tauri-apps/plugin-shell";
import { ToastAction } from "@/components/ui/toast";
import { open as openUrl } from "@tauri-apps/plugin-shell";
import { Separator } from "./ui/separator";
import { MultiSelect } from "@/components/ui/multi-select";
import { Alert, AlertDescription, AlertTitle } from "./ui/alert";
import { useSqlAutocomplete } from "@/lib/hooks/use-sql-autocomplete";
import * as Sentry from "@sentry/react";
import { defaultOptions } from "tauri-plugin-sentry-api";
type PermissionsStatus = {
screenRecording: string;
microphone: string;
accessibility: string;
};
interface AudioDevice {
name: string;
is_default: boolean;
}
interface MonitorDevice {
id: string;
name: string;
is_default: boolean;
width: number;
height: number;
}
const createWindowOptions = (
windowItems: { name: string }[],
existingPatterns: string[]
) => {
const windowOptions = windowItems
.sort((a, b) => a.name.localeCompare(b.name))
.map((item) => ({
value: item.name,
label: item.name,
icon: AppWindowMac,
}));
// Only add custom patterns that aren't already in windowItems
const customOptions = existingPatterns
.filter((pattern) => !windowItems.some((item) => item.name === pattern))
.map((pattern) => ({
value: pattern,
label: pattern,
icon: Asterisk,
}));
return [...windowOptions, ...customOptions];
};
export function RecordingSettings() {
const { settings, updateSettings, getDataDir } = useSettings();
const [openAudioDevices, setOpenAudioDevices] = React.useState(false);
const [openMonitors, setOpenMonitors] = React.useState(false);
const [openLanguages, setOpenLanguages] = React.useState(false);
const [dataDirInputVisible, setDataDirInputVisible] = React.useState(false);
const [clickTimeout, setClickTimeout] = useState<ReturnType<
typeof setTimeout
> | null>(null);
const [windowsForIgnore, setWindowsForIgnore] = useState("");
const [windowsForInclude, setWindowsForInclude] = useState("");
const { items: windowItems, isLoading: isWindowItemsLoading } =
useSqlAutocomplete("window");
const [availableMonitors, setAvailableMonitors] = useState<MonitorDevice[]>(
[]
);
const [availableAudioDevices, setAvailableAudioDevices] = useState<
AudioDevice[]
>([]);
const { toast } = useToast();
const [isUpdating, setIsUpdating] = useState(false);
const { health } = useHealthCheck();
const isDisabled = health?.status_code === 500;
const [isMacOS, setIsMacOS] = useState(false);
const [isSetupRunning, setIsSetupRunning] = useState(false);
const [showApiKey, setShowApiKey] = useState(false);
const { credits } = settings.user || {};
// Add new state to track if settings have changed
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
// Modify setLocalSettings to track changes
const handleSettingsChange = (
newSettings: Partial<Settings>,
restart: boolean = true
) => {
updateSettings(newSettings);
if (restart) {
setHasUnsavedChanges(true);
}
};
// Show toast when settings change
useEffect(() => {
if (hasUnsavedChanges && !settings.devMode) {
toast({
title: "settings changed",
description: "restart required to apply changes",
action: (
<ToastAction
altText="restart now"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
// Wrap in setTimeout to ensure event handling is complete
setTimeout(() => {
handleUpdate();
}, 0);
return false;
}}
onMouseDown={(e) => {
e.preventDefault();
e.stopPropagation();
}}
onMouseUp={(e) => {
e.preventDefault();
e.stopPropagation();
}}
>
restart now
</ToastAction>
),
duration: 50000,
});
}
}, [hasUnsavedChanges]);
useEffect(() => {
const checkPlatform = async () => {
const currentPlatform = platform();
setIsMacOS(currentPlatform === "macos");
};
checkPlatform();
}, []);
useEffect(() => {
const loadDevices = async () => {
try {
// Fetch monitors
const monitorsResponse = await fetch(
"http://localhost:3030/vision/list"
);
if (!monitorsResponse.ok) {
throw new Error("Failed to fetch monitors");
}
const monitors: MonitorDevice[] = await monitorsResponse.json();
console.log("monitors", monitors);
setAvailableMonitors(monitors);
// Fetch audio devices
const audioDevicesResponse = await fetch(
"http://localhost:3030/audio/list"
);
if (!audioDevicesResponse.ok) {
throw new Error("Failed to fetch audio devices");
}
const audioDevices: AudioDevice[] = await audioDevicesResponse.json();
console.log("audioDevices", audioDevices);
setAvailableAudioDevices(audioDevices);
console.log("settings", settings);
// Update monitors
const availableMonitorIds = monitors.map((monitor) =>
monitor.id.toString()
);
let updatedMonitorIds = settings.monitorIds.filter((id) =>
availableMonitorIds.includes(id)
);
if (
updatedMonitorIds.length === 0 ||
(settings.monitorIds.length === 1 &&
settings.monitorIds[0] === "default" &&
monitors.length > 0)
) {
updatedMonitorIds = [
monitors.find((monitor) => monitor.is_default)!.id!.toString(),
];
}
// Update audio devices
const availableAudioDeviceNames = audioDevices.map(
(device) => device.name
);
let updatedAudioDevices = settings.audioDevices.filter((device) =>
availableAudioDeviceNames.includes(device)
);
if (
updatedAudioDevices.length === 0 ||
(settings.audioDevices.length === 1 &&
settings.audioDevices[0] === "default" &&
audioDevices.length > 0)
) {
updatedAudioDevices = audioDevices
.filter((device) => device.is_default)
.map((device) => device.name);
}
handleSettingsChange(
{
monitorIds: updatedMonitorIds,
audioDevices: updatedAudioDevices,
},
false
);
} catch (error) {
console.error("Failed to load devices:", error);
}
};
loadDevices();
}, []);
const handleUpdate = async () => {
setIsUpdating(true);
toast({
title: "Updating screenpipe recording settings",
description: "This may take a few moments...",
});
try {
console.log("settings", settings);
if (!settings.analyticsEnabled) {
posthog.capture("telemetry", {
enabled: false,
});
// disable opentelemetry
posthog.opt_out_capturing();
// disable sentry
Sentry.close();
console.log("telemetry disabled");
} else {
const isDebug = process.env.TAURI_ENV_DEBUG === "true";
if (!isDebug) {
posthog.opt_in_capturing();
posthog.capture("telemetry", {
enabled: true,
});
// enable opentelemetry
console.log("telemetry enabled");
// enable sentry
Sentry.init({
...defaultOptions,
});
}
}
await invoke("stop_screenpipe");
await new Promise((resolve) => setTimeout(resolve, 1000));
// Start a new instance with updated settings
await invoke("spawn_screenpipe");
await new Promise((resolve) => setTimeout(resolve, 2000));
// await relaunch();
toast({
title: "settings updated successfully",
description: "screenpipe has been restarted with new settings.",
});
window.location.reload();
} catch (error) {
console.error("failed to update settings:", error);
toast({
title: "error updating settings",
description: "please try again or check the logs for more information.",
variant: "destructive",
});
} finally {
setIsUpdating(false);
}
};
const handleAudioTranscriptionModelChange = (value: string) => {
if (value === "screenpipe-cloud" && !settings.user?.cloud_subscribed) {
openUrl("https://buy.stripe.com/7sIdRzbym4RA98c7sX");
return;
}
if (value === "screenpipe-cloud") {
handleSettingsChange({
audioTranscriptionEngine: value,
});
} else {
handleSettingsChange({ audioTranscriptionEngine: value });
}
};
const handleOcrModelChange = (value: string) => {
handleSettingsChange({ ocrEngine: value });
};
const handleLanguageChange = (currentValue: Language) => {
const updatedLanguages = settings.languages.includes(currentValue)
? settings.languages.filter((id) => id !== currentValue)
: [...settings.languages, currentValue];
handleSettingsChange({ languages: updatedLanguages });
};
const handleAudioDeviceChange = (currentValue: string) => {
const updatedDevices = settings.audioDevices.includes(currentValue)
? settings.audioDevices.filter((device) => device !== currentValue)
: [...settings.audioDevices, currentValue];
handleSettingsChange({ audioDevices: updatedDevices });
};
const handlePiiRemovalChange = (checked: boolean) => {
handleSettingsChange({ usePiiRemoval: checked });
};
const handleDisableAudioChange = (checked: boolean) => {
handleSettingsChange({ disableAudio: checked });
};
const handleFpsChange = (value: number[]) => {
handleSettingsChange({ fps: value[0] });
};
const handleVadSensitivityChange = (value: number[]) => {
const sensitivityMap: { [key: number]: VadSensitivity } = {
2: "high",
1: "medium",
0: "low",
};
handleSettingsChange({
vadSensitivity: sensitivityMap[value[0]],
});
};
const vadSensitivityToNumber = (sensitivity: VadSensitivity): number => {
const sensitivityMap: { [key in VadSensitivity]: number } = {
high: 2,
medium: 1,
low: 0,
};
return sensitivityMap[sensitivity];
};
const handleAudioChunkDurationChange = (value: number[]) => {
handleSettingsChange({ audioChunkDuration: value[0] });
};
const renderOcrEngineOptions = () => {
const currentPlatform = platform();
return (
<>
{currentPlatform === "linux" && (
<SelectItem value="tesseract">tesseract</SelectItem>
)}
{currentPlatform === "windows" && (
<SelectItem value="windows-native">windows native</SelectItem>
)}
{currentPlatform === "macos" && (
<SelectItem value="apple-native">apple native</SelectItem>
)}
</>
);
};
const handleAnalyticsToggle = (checked: boolean) => {
const newValue = checked;
handleSettingsChange({ analyticsEnabled: newValue });
};
const handleChineseMirrorToggle = async (checked: boolean) => {
handleSettingsChange({ useChineseMirror: checked });
if (checked) {
// Trigger setup when the toggle is turned on
await runSetup();
}
};
const handleDataDirChange = async () => {
if (clickTimeout) {
// Double Click
clearTimeout(clickTimeout);
setClickTimeout(null);
setDataDirInputVisible(true);
} else {
const timeout = setTimeout(() => {
// Single Click
selectDataDir();
setClickTimeout(null);
}, 250);
setClickTimeout(timeout);
}
async function selectDataDir() {
try {
const dataDir = await getDataDir();
const selected = await open({
directory: true,
multiple: false,
defaultPath: dataDir,
});
// TODO: check permission of selected dir for server to write into
if (selected) {
handleSettingsChange({ dataDir: selected });
} else {
console.log("canceled");
}
} catch (error) {
console.error("failed to change data directory:", error);
toast({
title: "error",
description: "failed to change data directory.",
variant: "destructive",
duration: 3000,
});
}
}
};
const handleDataDirInputChange = async (
e: React.ChangeEvent<HTMLInputElement>
) => {
const newValue = e.target.value;
handleSettingsChange({ dataDir: newValue });
};
const handleDataDirInputBlur = () => {
console.log("wcw blur");
setDataDirInputVisible(false);
validateDataDirInput();
};
const handleDataDirInputKeyDown = (
e: React.KeyboardEvent<HTMLInputElement>
) => {
if (e.key === "Enter") {
setDataDirInputVisible(false);
validateDataDirInput();
}
};
const validateDataDirInput = async () => {
try {
if (await exists(settings.dataDir)) {
return;
}
} catch (err) {}
toast({
title: "error",
description: "failed to change data directory.",
variant: "destructive",
duration: 3000,
});
handleSettingsChange({ dataDir: settings.dataDir });
};
const runSetup = async () => {
setIsSetupRunning(true);
try {
const command = ShellCommand.sidecar("screenpipe", ["setup"]);
const child = await command.spawn();
toast({
title: "Setting up Chinese mirror",
description: "This may take a few minutes...",
});
const outputPromise = new Promise<string>((resolve, reject) => {
command.on("close", (data) => {
if (data.code !== 0) {
reject(new Error(`Command failed with code ${data.code}`));
}
});
command.on("error", (error) => reject(new Error(error)));
command.stdout.on("data", (line) => {
console.log(line);
if (line.includes("screenpipe setup complete")) {
resolve("ok");
}
});
});
const timeoutPromise = new Promise(
(_, reject) =>
setTimeout(() => reject(new Error("Setup timed out")), 900000) // 15 minutes
);
const result = await Promise.race([outputPromise, timeoutPromise]);
if (result === "ok") {
toast({
title: "Chinese mirror setup complete",
description: "You can now use the Chinese mirror for downloads.",
});
} else {
throw new Error("Setup failed or timed out");
}
} catch (error) {
console.error("Error setting up Chinese mirror:", error);
toast({
title: "Error setting up Chinese mirror",
description: "Please try again or check the logs for more information.",
variant: "destructive",
});
// Revert the toggle if setup fails
handleSettingsChange({ useChineseMirror: false });
} finally {
setIsSetupRunning(false);
}
};
const handleFrameCacheToggle = (checked: boolean) => {
handleSettingsChange({
enableFrameCache: checked,
});
};
const handleUiMonitoringToggle = async (checked: boolean) => {
try {
if (checked) {
// Check accessibility permissions first
const perms = await invoke<PermissionsStatus>("do_permissions_check", {
initialCheck: false,
});
if (!perms.accessibility) {
toast({
title: "accessibility permission required",
description:
"please grant accessibility permission in system preferences",
action: (
<ToastAction
altText="open preferences"
onClick={() => invoke("open_accessibility_preferences")}
>
open preferences
</ToastAction>
),
variant: "destructive",
});
return;
}
}
// Just update the local setting - the update button will handle the restart
handleSettingsChange({ enableUiMonitoring: checked });
} catch (error) {
console.error("failed to toggle ui monitoring:", error);
toast({
title: "error checking accessibility permissions",
description: "please try again or check the logs",
variant: "destructive",
});
}
};
const handleIgnoredWindowsChange = (values: string[]) => {
// Convert all values to lowercase for comparison
const lowerCaseValues = values.map((v) => v.toLowerCase());
const currentLowerCase = settings.ignoredWindows.map((v) =>
v.toLowerCase()
);
// Find added values (in values but not in current)
const addedValues = values.filter(
(v) => !currentLowerCase.includes(v.toLowerCase())
);
// Find removed values (in current but not in values)
const removedValues = settings.ignoredWindows.filter(
(v) => !lowerCaseValues.includes(v.toLowerCase())
);
if (addedValues.length > 0) {
// Handle adding new value
const newValue = addedValues[0];
handleSettingsChange({
ignoredWindows: [...settings.ignoredWindows, newValue],
// Remove from included windows if present
includedWindows: settings.includedWindows.filter(
(w) => w.toLowerCase() !== newValue.toLowerCase()
),
});
} else if (removedValues.length > 0) {
// Handle removing value
const removedValue = removedValues[0];
handleSettingsChange({
ignoredWindows: settings.ignoredWindows.filter(
(w) => w !== removedValue
),
});
}
};
const handleIncludedWindowsChange = (values: string[]) => {
// Convert all values to lowercase for comparison
const lowerCaseValues = values.map((v) => v.toLowerCase());
const currentLowerCase = settings.includedWindows.map((v) =>
v.toLowerCase()
);
// Find added values (in values but not in current)
const addedValues = values.filter(
(v) => !currentLowerCase.includes(v.toLowerCase())
);
// Find removed values (in current but not in values)
const removedValues = settings.includedWindows.filter(
(v) => !lowerCaseValues.includes(v.toLowerCase())
);
if (addedValues.length > 0) {
// Handle adding new value
const newValue = addedValues[0];
handleSettingsChange({
includedWindows: [...settings.includedWindows, newValue],
// Remove from ignored windows if present
ignoredWindows: settings.ignoredWindows.filter(
(w) => w.toLowerCase() !== newValue.toLowerCase()
),
});
} else if (removedValues.length > 0) {
// Handle removing value
const removedValue = removedValues[0];
handleSettingsChange({
includedWindows: settings.includedWindows.filter(
(w) => w !== removedValue
),
});
}
};
return (
<div className="w-full space-y-6 py-4">
<h1 className="text-2xl font-bold mb-4">recording</h1>
{settings.devMode || (!isUpdating && isDisabled) ? (
<Alert>
<Terminal className="h-4 w-4" />
<AlertTitle>heads up!</AlertTitle>
<AlertDescription>
make sure to turn off dev mode and start screenpipe recorder first
(go to status)
</AlertDescription>
</Alert>
) : (
<></>
)}
<div
className={cn(
isDisabled && "opacity-50 pointer-events-none cursor-not-allowed"
)}
>
<h4 className="text-lg font-semibold my-4">video</h4>
<div className="space-y-6">
<div className="flex items-center justify-between">
<div className="space-y-1">
<h4 className="font-medium">disable video recording</h4>
<p className="text-sm text-muted-foreground">
useful if you don't need screen recording or if you have
memory/cpu issues
</p>
</div>
<Switch
id="disableVision"
checked={settings.disableVision}
onCheckedChange={(checked) =>
handleSettingsChange({ disableVision: checked })
}
/>
</div>
{!settings.disableVision && (
<>
{/* <div className="flex items-center justify-between mb-4">
<div className="space-y-1">
<h4 className="font-medium">use all monitors</h4>
<p className="text-sm text-muted-foreground">
automatically detect and record all monitors, including
newly connected ones
</p>
</div>
<Switch
id="useAllMonitors"
checked={settings.useAllMonitors}
onCheckedChange={(checked) =>
handleSettingsChange({ useAllMonitors: checked })
}
/>
</div> */}
<div className="flex flex-col space-y-6">
<div className="flex flex-col space-y-2">
<Label
htmlFor="monitorIds"
className="flex items-center space-x-2"
>
<Monitor className="h-4 w-4" />
<span>monitors</span>
</Label>
<MultiSelect
options={availableMonitors.map((monitor) => ({
value: monitor.id.toString(),
label: `${monitor.id}. ${monitor.name} - ${
monitor.width
}x${monitor.height} ${
monitor.is_default ? "(default)" : ""
}`,
}))}
defaultValue={settings.monitorIds}
onValueChange={(values) =>
values.length === 0
? handleSettingsChange({ disableVision: true })
: handleSettingsChange({ monitorIds: values })
}
placeholder={
settings.useAllMonitors
? "all monitors will be used"
: "select monitors"
}
variant="default"
modalPopover={true}
animation={2}
disabled={settings.useAllMonitors}
/>
</div>
<div className="flex flex-col space-y-2">
<Label
htmlFor="ocrModel"
className="flex items-center space-x-2"
>
<Eye className="h-4 w-4" />
<span>ocr model</span>
</Label>
<Select
onValueChange={handleOcrModelChange}
defaultValue={settings.ocrEngine}
>
<SelectTrigger>
<SelectValue
className="capitalize"
placeholder="select ocr engine"
/>
</SelectTrigger>
<SelectContent className="capitalize">
{renderOcrEngineOptions()}
</SelectContent>
</Select>
</div>
<div className="flex flex-col space-y-2">
<Label htmlFor="fps" className="flex items-center space-x-2">
<span>frames per second (fps)</span>
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<HelpCircle className="h-4 w-4 cursor-default" />
</TooltipTrigger>
<TooltipContent side="right">
<p>
adjust the recording frame rate. lower values save
<br />
resources, higher values provide smoother
recordings, less likely to miss activity.
<br />
(we do not use resources if your screen does not
change much)
</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</Label>
<div className="flex items-center space-x-4">
<Slider
id="fps"
min={0.1}
max={10}
step={0.1}
value={[settings.fps]}
onValueChange={handleFpsChange}
className="flex-grow"
/>
<span className="w-12 text-right">
{settings.fps.toFixed(1)}
</span>
</div>
</div>
<div className="space-y-6">
<div className="flex flex-col space-y-2">
<Label
htmlFor="ignoredWindows"
className="flex items-center space-x-2"
>
<span>ignored windows</span>
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<HelpCircle className="h-4 w-4 cursor-default" />
</TooltipTrigger>
<TooltipContent side="right">
<p>
windows to ignore during screen recording
(case-insensitive), example:
<br />
- "bit" will ignore
"Bitwarden" and "bittorrent"
<br />- "incognito" will ignore tabs,
windows that contains the word
"incognito"
</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</Label>
<MultiSelect
options={createWindowOptions(
windowItems,
settings.ignoredWindows
)}
defaultValue={settings.ignoredWindows}
onValueChange={handleIgnoredWindowsChange}
placeholder="add windows to ignore"
variant="default"
modalPopover={true}
animation={2}
allowCustomValues={true}
validateCustomValue={(value) => value.length >= 2}
/>
</div>
<div className="flex flex-col space-y-2">
<Label
htmlFor="includedWindows"
className="flex items-center space-x-2"
>
<span>included windows</span>
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<HelpCircle className="h-4 w-4 cursor-default" />
</TooltipTrigger>
<TooltipContent side="right">
<p>
windows to include during screen recording
(case-insensitive), example:
<br />
- "chrome" will match "Google
Chrome"
<br />- "bitwarden" will match
"Bitwarden" and "bittorrent"
</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</Label>
<MultiSelect
options={createWindowOptions(
windowItems,
settings.includedWindows
)}
defaultValue={settings.includedWindows}
onValueChange={handleIncludedWindowsChange}
placeholder="add window to include"
variant="default"
modalPopover={true}
animation={2}
allowCustomValues={true}
validateCustomValue={(value) => value.length >= 2}
/>
</div>
</div>
{/* */}
</div>
<Separator className="my-6" />
</>
)}
</div>
<h4 className="text-lg font-semibold my-4">audio</h4>
<div className="space-y-6">
<div className="flex items-center justify-between">
<div className="space-y-1">
<h4 className="font-medium">disable audio recording</h4>
<p className="text-sm text-muted-foreground">
useful if you don't need audio or if you have memory/cpu
issues
</p>
</div>
<Switch
id="disableAudio"
checked={settings.disableAudio}
onCheckedChange={handleDisableAudioChange}
/>
</div>
{!settings.disableAudio && (
<>
<div className="flex items-center justify-between">
<div className="space-y-1">
<h4 className="font-medium">
enable realtime audio transcription
</h4>
<p className="text-sm text-muted-foreground">
transcribe audio in real-time as you speak (dev preview) -{" "}
<a
href="https://github.com/mediar-ai/screenpipe/blob/main/screenpipe-js/examples/basic-transcription/index.ts"
target="_blank"
rel="noopener noreferrer"
className="text-primary hover:underline"
>
view example
</a>
</p>
</div>
<div className="flex items-center gap-2">
<Switch
id="enableRealtimeAudio"
checked={settings.enableRealtimeAudioTranscription}
onCheckedChange={(checked) =>
handleSettingsChange({
enableRealtimeAudioTranscription: checked,
})
}
/>
</div>
</div>
{settings.enableRealtimeAudioTranscription && (
<div className="flex flex-col space-y-2">
<Label
htmlFor="realtimeAudioTranscriptionEngine"
className="flex items-center space-x-2"
>