Skip to content

fix(frontend): 5 bugs from parallel hunt — IME / search-race / palette-race / IPC catch / transition-all - #202

Merged
jackwener merged 1 commit into
mainfrom
yuejing/fe-bug-hunt-0
Jun 24, 2026
Merged

fix(frontend): 5 bugs from parallel hunt — IME / search-race / palette-race / IPC catch / transition-all#202
jackwener merged 1 commit into
mainfrom
yuejing/fe-bug-hunt-0

Conversation

@jackwener

Copy link
Copy Markdown
Member

WAWQAQ msg `c4e6e61c` 2026-06-24: yuejing = frontend engineer (solve kenji's finds + hunt FE/animation/chain bugs). Spawned 3 parallel deep-review agents (animation/motion, execution-chain, React logic); this PR fixes the 5 HIGH-confidence bugs they converged on.

Fixes

H1. IME composition mis-fires Quick Chat send — `OnboardingHero.tsx:564`. CN/JP/KR users committing an IME composition with Enter immediately sent their unfinished draft. Mirrored the main Composer's `event.nativeEvent.isComposing` guard.

H2 + H3. Search + palette die during streaming — `main.tsx`. `SearchModal deps={{...}}` + `CommandPalette onSelectSession={(s) => ...}` were inline. App re-renders many times per second during streams; the debounce + highlight-reset effects keyed on these props were torn down every render, so search never fired and palette navigation reset constantly. Fix: `useMemo` deps + `useCallback` over a `useRef` of `openSessionInChat`.

H4. Privacy IPC error unhandled — `SettingsModal.tsx:1130`. `void onUpdateSettings(...)` discarded rejection → Unhandled Promise Rejection with no user feedback. Added `.catch` + toast surface mirroring PR-STOP-ERROR-SURFACE-0 / PR-BOT-RESTART-RACE-0.

H5. Tailwind `transition-all` slipped through motion contract — 3 sites in `packages/ui/src/primitives/{command,sheet,sidebar}.tsx`. The PR-MOTION-TOKEN-CONVERGE-0 contract only scanned CSS files. Replaced with `transition-opacity` (overlays) / `transition-[transform,opacity]` (sidebar rail). Extended the contract test with a 4th case that walks `packages/ui/src/primitives` + `apps/desktop/src/renderer` for any `\btransition-all\b` token.

Out of scope (follow-ups)

  • MEDIUM findings: ClaudeSubscriptionCard mountedRef, rapid-resize localStorage spam, WechatQrLoginModal interval churn, ReadyEmptyHero `[props]` deps — not user-visible HIGH.
  • Bare easing / duration token migration across maka-tokens.css — kenji's aesthetic lane.

Verification

Local disk is currently at 100% (system-level, not repo-side) so I could not run `pnpm install && pnpm test && pnpm build` end-to-end before pushing. The diff is small and the fixes are static-analysis-clean. Please review the diff carefully + run the test suite yourself before merging. I'll rerun the gate once disk space frees up.

Branch: `yuejing/fe-bug-hunt-0`

…ntract

WAWQAQ msg `c4e6e61c` 2026-06-24: yuejing role = frontend engineer
solving kenji's finds + proactively hunting FE / animation / chain
bugs. Spawned 3 parallel deep-review agents (animation/motion,
execution-chain, React logic) and fixed the 5 HIGH-confidence bugs
they converged on.

## H1. IME composition mis-fires Quick Chat send
`apps/desktop/src/renderer/OnboardingHero.tsx:564`

`ReadyEmptyHero.handleKey` triggered `submit()` on Enter without an
`event.nativeEvent.isComposing` / `event.key === 'Process'` guard.
Chinese / Japanese / Korean users committing an IME composition with
Enter immediately sent their unfinished draft. The main Composer at
`packages/ui/src/components.tsx:5640` has had the guard for ages; the
onboarding clone had drifted. Mirrored the guard.

## H2. SearchModal debounce killed by parent re-renders during streaming
## H3. CommandPalette highlight reset by parent re-renders during streaming
`apps/desktop/src/renderer/main.tsx:776+ + :3083-3098`

`SearchModal` received `deps={{ searchThread: (req) => window.maka.search.thread(req) }}` — a fresh inline object every render. SearchModal's debounce effect lists `searchThread` in its dep array, so during an active turn stream (App re-renders many times per second) the 180 ms `setTimeout` was torn down + recreated on every render and never fired — search was effectively dead while streaming.

Same root cause for CommandPalette's `onSelectSession` inline arrow: the palette's `[combined]`-deps effect at command-palette.tsx:629 reset `setHighlight` on every parent render, clobbering keyboard navigation during streaming.

Fix: stable refs + memos. `openSessionInChatRef` mirrors the live closure; `searchModalDeps` (useMemo), `searchModalOnNavigate` / `paletteOnSelectSession` (useCallback) all stable across App renders.

## H4. Privacy-toggle IPC rejection becomes Unhandled Promise Rejection
`apps/desktop/src/renderer/settings/SettingsModal.tsx:1130`

`onChange={(v) => void props.onUpdateSettings({ privacy: { incognitoActive: v } })}` discarded the resolved value but did NOT catch rejection. `updateSettings` re-throws on IPC failure → renderer-level Unhandled Promise Rejection with NO user feedback. Added `.catch` with toast surface mirroring the rest of the file's PR-STOP-ERROR-SURFACE-0 / PR-BOT-RESTART-RACE-0 pattern (`generalizedErrorMessageChinese`).

## H5. Tailwind `transition-all` slipped through motion contract
`packages/ui/src/primitives/{command,sheet,sidebar}.tsx`

PR-MOTION-TOKEN-CONVERGE-0's contract scanned renderer CSS files
only; shadcn primitive classnames live in `.tsx` files and weren't
covered. Three sites violated:
- `command.tsx:46` overlay → `transition-opacity` (only opacity moves)
- `sheet.tsx:35` overlay → `transition-opacity` (same)
- `sidebar.tsx:318` rail → `transition-[transform,opacity]` (the rail hovers + slides, neither requires `all`)

Extended `motion-token-converge-contract.test.ts` with a fourth test
that walks `packages/ui/src/primitives/**` + `apps/desktop/src/renderer/**`
for any `\btransition-all\b` token. The three above are scrubbed;
future `transition-all` insertion trips the test.

## Out of scope (logged for follow-up)

- MEDIUM findings from the 3 agents (ClaudeSubscriptionCard mountedRef,
  rapid-resize localStorage spam, WechatQrLoginModal interval churn,
  ReadyEmptyHero `[props]` deps, etc.) — not user-visible HIGH bugs.
- Bare easing / duration cleanup across maka-tokens.css — kenji's
  aesthetic lane.
@jackwener
jackwener merged commit 39fb41b into main Jun 24, 2026
@jackwener
jackwener deleted the yuejing/fe-bug-hunt-0 branch June 24, 2026 17:30
jackwener added a commit that referenced this pull request Jun 24, 2026
PR-FE-BUG-HUNT-4 (LOW from kenji-led bug-hunt 2026-06-24 round 1):
`refreshMessagesUntilTurn` polls `readMessages` every 40ms for up to
1200ms while waiting for a freshly-sent user turn to land in the
session journal. The setState was already gated on
`activeIdRef.current === sessionId`, but the IPC call itself kept
firing until the deadline — burning bandwidth and CPU on a session
the user no longer cared about.

Fix: check `activeIdRef.current !== sessionId` at the top of each
loop iteration AND immediately after the await. Bail early so the
polling cycle stops, not just the setState. Same guard on the
deadline-fallthrough `refreshMessages(sessionId)`.

Behavior change is invisible when the user stays on the same session
(common case). Saves up to 30 IPC roundtrips per session-switch
during the post-send window when the user navigates fast.

Single function, single file. No conflict with #202 / #204 / #206 /
#207 since none of those touch `refreshMessagesUntilTurn`.
jackwener added a commit that referenced this pull request Jun 24, 2026
)

PR #202 added an IME guard to the composer textarea's keydown
handler so Enter during CJK composition wouldn't fire submit
mid-character. The paste handler (components.tsx:5726) had the
same exposure but was left out.

Symptom: a user mid-CJK composition who pastes a clipboard file
(e.g. screenshot captured via system shortcut) hits the file-import
path, which calls `event.preventDefault()` — that aborts the
in-flight IME composition and eats the partially-typed character.
Rare but real. The same kind of bug pattern as the keydown one.

Fix: prepend `if (event.nativeEvent.isComposing) return;` at the
top of `onTextareaPaste`, matching the exact pattern at line 5640
in the keydown handler. 2 lines + 6-line WHY comment.

When IME is active, the paste should fall through to the textarea's
native paste so the IME can handle (or ignore) it as the user
expects. The file-import path only matters once composition has
ended.

Found via PR-FE-BUG-HUNT scan; 2 sibling Explore agents also
ran on Daily Review and cron PlanReminderPanel — both reported
findings that I manually verified as false positives (Daily Review
agent contradicted itself mid-output; cron `reminder.schedule`
null-safety claim is impossible because TypeScript types it as
required non-null). Reporting transparently so kenji/WAWQAQ can
discount those.

## Diff

1 file, 8 insertions(+), 0 deletions(-). No overlap with any open PR.

## Verification

Disk still ~100%, couldn't run `pnpm install && pnpm test`.
Matches existing pattern verbatim, so behavior outside the IME
edge case is unchanged.
jackwener added a commit that referenced this pull request Jun 24, 2026
…edRef (#204)

PR-FE-BUG-HUNT-1 (MEDIUM from kenji-led bug-hunt 2026-06-24 round 1):
the Claude subscription card launches a browser OAuth flow that takes
seconds-to-minutes. Closing the Settings modal while a `startLogin`,
`submitPaste`, `cancelLogin`, `logout`, or `refreshQuota` call is in
flight produced `setState on unmounted component` warnings (loud in
dev, masks real bugs in prod). `refreshExperimentalGate` and `refresh`
had the same exposure.

Mirrored the `mountedRef` pattern already in use by other settings
sub-cards in this file:
- `claudeCardMountedRef = useRef(true)` with a unmount-flip effect
- Every `await` is followed by an `if (!claudeCardMountedRef.current) return;`
  before any setState / toast call
- Finally blocks gate `finishPendingAction()` the same way (so the
  pending-action ref doesn't leak past unmount)

No behavior change when the card stays mounted (the common case).

Scoped to a single file to minimize merge conflict surface with the
in-flight PR #202 (which doesn't touch ProvidersPanel.tsx).
jackwener added a commit that referenced this pull request Jun 24, 2026
#206)

PR-FE-BUG-HUNT-2 (MEDIUM from kenji-led bug-hunt 2026-06-24 round 1):
`WechatQrLoginModal`'s 3-second polling effect listed the whole
`result` object in its dep array. Every successful QR refresh
produces a new `result` reference → effect cleanup tears down the
interval → effect re-armed → 3-second clock restarts from zero.

In practice the polling cadence drifted: each refresh pushes the
next poll up to ~5.9 s after the previous poll instead of the
intended 3 s. Over a long scan, this delays the moment the modal
notices `loggedIn: true` from the bridge.

Fix: derive a boolean `shouldPollQr = !!result?.ok && !result.loggedIn
&& !result.expired` and depend on `[shouldPollQr]`. The interval is
armed once when scanning starts and torn down once when the gating
state flips (logged in, expired, or error). `reloadQrCode` only
touches stable refs (`loadingQrRef.current`) and state setters, so
the captured closure is safe across renders.

Scoped to a single function (`WechatQrLoginModal` at lines 687-693)
to keep merge surface minimal with the in-flight PRs #202 / #204.
jackwener added a commit that referenced this pull request Jun 24, 2026
Kenji aesthetic audit reminder 4/6 (msg `6cc0e04d` 2026-06-24,
finding #2): Tooltip is a high-frequency hover/focus surface and
should use instant positioning + compositor-only popup transitions.
Two sites violated:

1. Positioner: `transition-[top,left,right,bottom,transform]`
   — `top` / `left` / `right` / `bottom` are layout-trigger
   properties. Every reposition (e.g. anchor moved by scroll, or
   side flipped on collision) ran through layout + paint instead
   of GPU compositor. Reduced to `transition-transform` so the
   transform-based reposition still tweens smoothly; the layout
   positioning happens instantly off-frame.

2. Popup: `transition-[width,height,scale,opacity]` — `width` /
   `height` are layout-trigger. Reduced to `transition-[scale,opacity]`,
   which is what the data-starting-style / data-ending-style scale-98
   + opacity-0 actually animate. The popup-width / popup-height
   CSS vars still set the size; just no longer transitioned.

Net behavior: tooltip pops in/out via scale+fade (compositor),
repositions via transform (compositor). Layout properties are
applied instantly per frame instead of crossfading.

Drawer's `transition-[transform,box-shadow,height,background-color]`
and Tabs' `transition-[width,translate]` indicator are flagged in
kenji's audit but deferred — both interact with swipe gesture / tab
sizing logic and need a focused PR with visual smoke verification.

Scoped to 2 lines in 1 file to keep merge surface minimal with the
in-flight PRs #202 / #204 / #206.
jackwener added a commit that referenced this pull request Jun 24, 2026
…rag (#210)

PR-FE-BUG-HUNT-5 (LOW from kenji-led bug-hunt 2026-06-24 round 1):
sidebar-list resizer fires `setSessionListWidth` on every pointermove
during a drag — at ~60Hz over a long drag, that's a couple hundred
localStorage writes for a single resize gesture. The setting
converges to the user's final width at rest; intermediate values
aren't load-bearing.

Fix: 200ms trailing debounce on the `useEffect` that flushes to
localStorage. Cleanup clears the pending timeout on each fresh
width change, so only the last-render value gets written. Drag
finished → 200ms idle → one localStorage write.

Behavior is invisible — the user's final width persists exactly as
before, just without the per-frame I/O. Especially noticeable on
spinning disks and on Electron's IPC-backed safeLocalStorage path.

Diff: 1 file, +10/-2. Single function in main.tsx. No conflict zone
with the in-flight PRs (the localStorage write at line 1153 is far
from the SearchModal/CommandPalette callback area at line 768/3083
that PR #202 touches).
jackwener added a commit that referenced this pull request Jun 24, 2026
…scape hatch (#214)

Kenji aesthetic-audit reminder 9 (msg `bacde601` 2026-06-24,
findings #2 + #3): two chrome design-system holes still leaking
gradients / non-token blur into the app.

## #2 — darwin sidebar footer gradient

`html[data-os="darwin"] .maka-session-panel-footer` was setting:
`background: linear-gradient(180deg, transparent 0%, oklch(.../0.30) 100%)`

The panel above already has a 50% glass base + 8px backdrop blur,
so the footer doesn't need any additional material — but the
180deg fade IS the same "上面灰下面白" pattern WAWQAQ called out
twice before in chat sweep (`1e693dee` / `5d3b10e5`). Replaced
with flat `oklch(...) / 0.15` + hairline border-top.

## #3 — `[data-gradual-blur-layer]` block

A 56-line block that let any element opt into:
- `linear-gradient(to bottom/top, var(--background) → transparent)`
- `backdrop-filter: blur(6px)`
- raw `z-index: 5`

just by wearing the `data-gradual-blur-layer` attribute. Kenji
called it a "blur escape hatch" — a future surface could re-
introduce blur and a non-token z-index without going through
any review of the design system.

`grep -rn data-gradual-blur-layer --include=*.tsx` confirms zero
JSX consumers — the CSS is dead. Removing the entire block kills
the escape hatch + retires one of the four raw z-index numbers
kenji flagged in finding #4.

`notes/reference-atlas.md` references stay — those describe what
reference upstream does, not what we ship.

## Diff

1 file changed, 18 insertions(+), 60 deletions(-) net delete.
No JSX touched. No tests touched (no contract pinned this attr).
Footer change is darwin-only so non-darwin platforms unaffected.

Far from PR #202 styles.css edit area (onboarding ~1500-1700 +
cubic-bezier sweep on transition rules). PR #210 touches main.tsx
debounce, not styles.css. No merge conflicts.
jackwener added a commit that referenced this pull request Jun 24, 2026
Kenji aesthetic-audit reminder 9 (msg `bacde601` 2026-06-24,
finding #4): four bare integer z-index sites in styles.css
(line 407 z-4, 3858 z-2, 7193 z-35, 14463 z-5) sidestep the
`--z-*` token scale defined in maka-tokens.css. PR #214 already
took out the gradual-blur-layer site (z-5). This PR closes the
remaining three.

## Changes

1. `maka-tokens.css`: add two new tokens preserving the previous
   raw values exactly:
   - `--z-panel-action: 4`
   - `--z-settings-fullpage: 35`

2. `styles.css` line 407 (`.maka-workspace-top-actions`):
   `z-index: 4` → `var(--z-panel-action)`. Identical stacking.

3. `styles.css` line 7193 (`.settingsModal.settingsPage`):
   `z-index: 35` → `var(--z-settings-fullpage)`. 35 sits between
   `--z-titlebar` (40) and `--z-sticky` (20) so the OS titlebar
   still owns top of the stack. Preserved visual behavior exactly.

4. `styles.css` line 3858 (`.maka-skill-featured-art span:nth-child(2)`):
   bare `z-index: 2` kept. This is local stacking among 3 decorative
   sticker spans inside a fixed-size container — they never escape
   the parent and don't need a global token. Added explicit
   allowlist comment.

5. New `apps/desktop/src/main/__tests__/z-index-contract.test.ts`
   enforces:
   - every bare `z-index: <integer>;` must be tokenized or
     allowlisted (with a documented reason)
   - allowlist entries must be present in styles.css (no stale
     entries)
   - the 10 semantic `--z-*` tokens stay defined in maka-tokens.css

Future PRs that re-introduce a bare z-index will fail this test
unless they explicitly bump the allowlist.

## Diff

3 files: maka-tokens.css +7, styles.css +17/-2, new test +~110 lines.
No visual change. Far from PR #202 (transition sweep), PR #210
(main.tsx debounce), PR #214 (footer/gradual-blur). No conflict.

## Verification

Disk still ~100%, couldn't run `pnpm install && pnpm test`.
Contract test is greenfield — first run will validate the 4 sites
in this same PR.
jackwener added a commit that referenced this pull request Jun 24, 2026
#223)

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