Skip to content

Commit 78cdcca

Browse files
Copilotmatt-pharr
andauthored
fix: address secondary code review suggestions - add safety comment for release!, document makeModalKeyboardHandler memoization note
Agent-Logs-Url: https://github.com/matt-pharr/physics-data-viewer/sessions/72507e62-4c26-4717-a751-9a80af82cba5 Co-authored-by: matt-pharr <25289941+matt-pharr@users.noreply.github.com>
1 parent 004422d commit 78cdcca

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

electron/main/ipc-register-kernels.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ export function registerKernelIpcHandlers(
136136
*/
137137
async function acquireMutex(operation: string): Promise<() => void> {
138138
const previous = startMutex;
139+
// `release` is assigned synchronously inside the Promise executor (before
140+
// the executor returns), so the definite-assignment assertion is safe.
139141
let release!: () => void;
140142
startMutex = new Promise<void>((r) => { release = r; });
141143
try {

electron/renderer/src/hooks/makeModalKeyboardHandler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
* `onCancel`. Used by every PDV dialog with a single text input
77
* (CreateScriptDialog, CreateNoteDialog, CreateGuiDialog, SaveAsDialog,
88
* etc.) to remove the duplicated inline handler.
9+
*
10+
* Note: The returned function is a new reference on every call. If passing it
11+
* as a prop to a memoized child component, wrap the call in `useCallback` at
12+
* the call site to avoid unnecessary re-renders.
913
*/
1014

1115
import type React from 'react';

0 commit comments

Comments
 (0)