Skip to content

fix(chat): add missing useCallback import to main.tsx (hotfix PR #202) - #223

Merged
jackwener merged 1 commit into
mainfrom
yuejing/hotfix-usecallback-import
Jun 24, 2026
Merged

fix(chat): add missing useCallback import to main.tsx (hotfix PR #202)#223
jackwener merged 1 commit into
mainfrom
yuejing/hotfix-usecallback-import

Conversation

@jackwener

Copy link
Copy Markdown
Member

🚨 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.

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.
@jackwener
jackwener merged commit 9be177d into main Jun 24, 2026
@jackwener
jackwener deleted the yuejing/hotfix-usecallback-import branch June 24, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant