fix(chat): add missing useCallback import to main.tsx (hotfix PR #202) - #223
Merged
Conversation
WAWQAQ reported a runtime crash: ReferenceError: useCallback is not defined at q80 (dist/renderer/assets/index-D4LgUpob.js:128:31343) PR #202 added stable-ref refs for SearchModal / CommandPalette via `useCallback` at main.tsx:794 + main.tsx:797, but the React import on line 1 was not updated to bring `useCallback` in: import { StrictMode, useEffect, useMemo, useRef, useState, ... } from 'react'; ^ no useCallback This survived the build because esbuild / Vite don't fail on undeclared identifiers in source — only at runtime when the function is actually called. Same root cause as PR #221 (paste IME isComposing): I didn't run `tsc --noEmit` against the affected package before pushing. Fix: add `useCallback` to the named imports on line 1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚨 hotfix — renderer crashes at startup
WAWQAQ reports a runtime crash:
```
ReferenceError: useCallback is not defined
at q80 (dist/renderer/assets/index-D4LgUpob.js:128:31343)
```
Root cause
PR #202 added two `useCallback`-wrapped callbacks in `apps/desktop/src/renderer/main.tsx` (lines 794 + 797 — `searchModalOnNavigate` and `paletteOnSelectSession`), but the React named imports on line 1 were not updated:
```tsx
import { StrictMode, useEffect, useMemo, useRef, useState, ... } from 'react';
// ↑ no useCallback
```
esbuild / Vite don't fail on undeclared identifiers in source code — they only break at runtime when the call site is hit. `useCallback` is referenced inside a function body, so the bundle built successfully but crashed on first render.
Same root cause as PR #221 (paste IME `isComposing`): I didn't run `tsc --noEmit` against the affected package before pushing. Saved memory `feedback_tsc_before_ship.md` after #221; doubling down on it after this.
Fix
Add `useCallback` to the named imports on line 1.
Verification
Local disk still ~96%; couldn't run a full build. Single-line import fix; reading the change confirms it.