Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

refactor(app): drop reset-on-prop effects, rely on key remount (#4891)

Ansh Grover55ac7b11af4f
diff --git a/apps/screenpipe-app-tauri/components/meeting-notes/note-view.tsx b/apps/screenpipe-app-tauri/components/meeting-notes/note-view.tsx
index 242110732..1e4d1713a 100644
--- a/apps/screenpipe-app-tauri/components/meeting-notes/note-view.tsx
+++ b/apps/screenpipe-app-tauri/components/meeting-notes/note-view.tsx
@@ -361,25 +361,13 @@ export function NoteView({
[meeting.id],
);
- // Reset draft when meeting changes
- useEffect(() => {
- setTitle(meeting.title ?? "");
- setAttendees(meeting.attendees ?? "");
- setNote(meeting.note ?? "");
- setSaveState({ kind: "idle" });
- setMeetingCtx(null);
- setTranscriptOpenState(
- initialTranscriptOpen || readTranscriptOpenPreference(meeting.id),
- );
- setTranscriptRefreshKey(0);
- setInactivityPrompt(false);
- setDismissedJoinUrl(null);
- lastSavedRef.current = {
- title: meeting.title ?? "",
- attendees: meeting.attendees ?? "",
- note: meeting.note ?? "",
- };
- }, [meeting.id, initialTranscriptOpen]);
+ // Draft state resets when the meeting changes because the parent already
+ // remounts this component per meeting: `<NoteView key={selected.id} ... />`
+ // in components/meeting-notes/index.tsx (selected === the `meeting` prop).
+ // A fresh mount re-runs the useState initializers and lastSavedRef above,
+ // which reproduce exactly what a reset effect would set — so no reset effect
+ // is needed. (A dedicated effect below opens the transcript when
+ // initialTranscriptOpen is requested.)
useEffect(() => {
posthog.capture("meeting_note_opened", {
diff --git a/apps/screenpipe-app-tauri/components/rewind/search-modal.tsx b/apps/screenpipe-app-tauri/components/rewind/search-modal.tsx
index 91eebe264..bdce12719 100644
--- a/apps/screenpipe-app-tauri/components/rewind/search-modal.tsx
+++ b/apps/screenpipe-app-tauri/components/rewind/search-modal.tsx
@@ -290,12 +290,9 @@ const FrameThumbnail = ({ frameId, alt }: { frameId: number; alt: string }) => {
const [src, setSrc] = useState(appendAuthToken(`${getApiBaseUrl()}/frames/${frameId}`));
const retryCount = useRef(0);
- useEffect(() => {
- setSrc(appendAuthToken(`${getApiBaseUrl()}/frames/${frameId}`));
- setIsLoading(true);
- setHasError(false);
- retryCount.current = 0;
- }, [frameId]);
+ // State resets on a new frameId via `key={frameId}` at each render site —
+ // the initializers above already produce the correct fresh values, so no
+ // reset effect is needed.
return (
<div className="aspect-video bg-muted relative overflow-hidden">
@@ -1486,6 +1483,7 @@ export function SearchModal({ isOpen, onClose, onNavigateToTimestamp, embedded =
>
{frameId ? (
<FrameThumbnail
+ key={frameId}
frameId={frameId}
alt={t.transcription || t.speaker_name}
/>
@@ -1610,6 +1608,7 @@ export function SearchModal({ isOpen, onClose, onNavigateToTimestamp, embedded =
className="cursor-pointer rounded overflow-hidden border border-border hover:border-foreground/50 transition-all duration-150"
>
<FrameThumbnail
+ key={frame.frame_id}
frameId={frame.frame_id}
alt={frame.tag_names.join(", ")}
/>
@@ -2048,6 +2047,7 @@ export function SearchModal({ isOpen, onClose, onNavigateToTimestamp, embedded =
>
<div className="relative">
<FrameThumbnail
+ key={result.frame_id}
frameId={result.frame_id}
alt={`${result.app_name} - ${result.window_name}`}
/>