Skip to content

fix: stabilize real-time search during IME input#235

Merged
AmintaCCCP merged 2 commits into
mainfrom
fix/ime-realtime-search
Jul 6, 2026
Merged

fix: stabilize real-time search during IME input#235
AmintaCCCP merged 2 commits into
mainfrom
fix/ime-realtime-search

Conversation

@AmintaCCCP

@AmintaCCCP AmintaCCCP commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix real-time repository-name search so IME composition pauses preedit matching and resumes after composition ends
  • Reset stale real-time results when the search input becomes whitespace-only
  • Add SearchBar regression tests for IME preedit and whitespace-only input cases
  • Clean up existing React warnings in MarkdownRenderer/ForkTimeline tests and VectorSearchSettings hook deps

Testing

  • npm run test:run -- SearchBar.test.tsx
  • npm run test:run -- MarkdownRenderer.test.tsx ForkTimeline.test.tsx
  • npm run test:run
  • npm run lint
  • npm run build

Notes

  • Browser-driven verification was intentionally skipped per maintainer instruction.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Search now behaves better with IME input, pausing live results while composing text and resuming afterward.
    • Clearing a search back to whitespace now restores the full repository list instead of leaving stale results.
  • Bug Fixes

    • Improved Markdown image rendering consistency, including loading/error states and zoom/hover presentation.

Fixes #232

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c97ec50f-3d26-4b5f-8ba1-2f31aa1b805d

📥 Commits

Reviewing files that changed from the base of the PR and between 476c86a and b54213a.

📒 Files selected for processing (2)
  • src/components/MarkdownRenderer.tsx
  • src/components/SearchBar.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/SearchBar.test.tsx

📝 Walkthrough

Walkthrough

This PR updates SearchBar to pause real-time search during IME composition and adds tests for composition and whitespace transitions. It also refactors MarkdownRenderer image wrappers, adjusts a paragraph renderer return path, fixes one ForkTimeline test, and removes a VectorSearchSettings callback dependency.

Changes

SearchBar IME Composition Handling

Layer / File(s) Summary
IME composition state and real-time search debounce logic
src/components/SearchBar.tsx
Adds isComposing state, updates the real-time search effect to skip searching while composing and reset to basic filter on empty input, and updates handleInputChange to call updateRealTimeSearchState.
SearchBar test helpers and new IME/reset tests
src/components/SearchBar.test.tsx
Adds Repository type import and createRepository helper, plus tests covering IME-pause and whitespace-reset behaviors.

MarkdownRenderer Image Markup Refactor

Layer / File(s) Summary
Image error, loading, and hover markup refactor
src/components/MarkdownRenderer.tsx
Converts image error, loading, zoom overlay, and hover caption wrappers from div to span elements.
Paragraph renderer adjustment
src/components/MarkdownRenderer.tsx
Applies a minimal adjustment in the p renderer around the hasImagesOnly return block.

Miscellaneous Fixes

Layer / File(s) Summary
ForkTimeline async test fix
src/components/ForkTimeline.test.tsx
Converts the personal-account forks default test to async and awaits the owner selector before assertions.
VectorSearchSettings callback dependency update
src/components/settings/VectorSearchSettings.tsx
Removes embeddingFormatVersion from handleRebuildIndex's dependency array.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SearchBarInput
  participant SearchBar
  User->>SearchBarInput: compositionStart
  SearchBarInput->>SearchBar: set isComposing = true
  User->>SearchBarInput: type preedit text
  SearchBar->>SearchBar: skip performRealTimeSearch (isComposing)
  User->>SearchBarInput: compositionEnd
  SearchBarInput->>SearchBar: set isComposing = false
  SearchBar->>SearchBar: updateRealTimeSearchState(value)
  SearchBar->>SearchBar: performRealTimeSearch (if armed)
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The MarkdownRenderer, ForkTimeline test, and VectorSearchSettings cleanup changes are unrelated to the linked search issue. Move the MarkdownRenderer, ForkTimeline, and VectorSearchSettings cleanup into a separate PR unless they are required for the search fix.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: stabilizing real-time search during IME input.
Linked Issues check ✅ Passed The SearchBar IME and whitespace handling changes plus tests align with restoring non-AI repository-name search behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ime-realtime-search

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several key improvements: it enhances the SearchBar component with IME composition support (pausing real-time search during active input) and better whitespace handling; it updates MarkdownRenderer to use valid HTML nesting (replacing block-level divs with inline spans and using a div instead of a p tag when rendering only images); it updates tests to cover these new behaviors; and it cleans up a dependency array in VectorSearchSettings. As there are no review comments, no additional feedback is provided.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/MarkdownRenderer.tsx (1)

838-863: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep the <p> wrapper for image-only paragraphs
Switching this branch to a <div> bypasses the .prose p > ... image selectors in src/index.css, so standalone images lose the custom hover/max-width styling. Render the flex classes on <p> instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/MarkdownRenderer.tsx` around lines 838 - 863, The image-only
paragraph branch in MarkdownRenderer should keep using the existing p wrapper
instead of switching to a div, since the .prose p > ... selectors in
src/index.css depend on that structure for image styling. Update the
hasImagesOnly render path in MarkdownRenderer so the flex/layout classes are
applied directly to the p element while preserving the current children
rendering.
🧹 Nitpick comments (1)
src/components/SearchBar.test.tsx (1)

182-193: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Misleading currentTarget override in fireEvent.compositionEnd.

@testing-library/dom's fireEvent only special-cases the target property to assign onto the real DOM node before dispatch; currentTarget is not overridable this way. When an event is dispatched on an element, the event has the subjected element on a property called target, and if you provide a target property in the eventProperties, those properties will be assigned to the node which is receiving the event. The currentTarget: { value: 'rain' } } passed here is a no-op — the test only passes because the prior fireEvent.change already set the real input's DOM value to 'rain', which is what e.currentTarget.value actually reads in handleCompositionEnd.

This makes the test's intent misleading and fragile to future edits (e.g., if the preceding change value diverges from this one).

♻️ Proposed fix: drop the no-op override, rely on real DOM state instead
-      fireEvent.compositionEnd(input, { currentTarget: { value: 'rain' } });
+      fireEvent.compositionEnd(input);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/SearchBar.test.tsx` around lines 182 - 193, The
composition-end test in SearchBar.test.tsx is relying on a misleading no-op
`currentTarget` override in `fireEvent.compositionEnd`, since only the real DOM
input value is used by `handleCompositionEnd`. Update the test near the
composition event flow to remove the `currentTarget` override and let the event
read from the actual input state set by the prior `fireEvent.change`, keeping
the assertion aligned with real DOM behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/components/MarkdownRenderer.tsx`:
- Around line 838-863: The image-only paragraph branch in MarkdownRenderer
should keep using the existing p wrapper instead of switching to a div, since
the .prose p > ... selectors in src/index.css depend on that structure for image
styling. Update the hasImagesOnly render path in MarkdownRenderer so the
flex/layout classes are applied directly to the p element while preserving the
current children rendering.

---

Nitpick comments:
In `@src/components/SearchBar.test.tsx`:
- Around line 182-193: The composition-end test in SearchBar.test.tsx is relying
on a misleading no-op `currentTarget` override in `fireEvent.compositionEnd`,
since only the real DOM input value is used by `handleCompositionEnd`. Update
the test near the composition event flow to remove the `currentTarget` override
and let the event read from the actual input state set by the prior
`fireEvent.change`, keeping the assertion aligned with real DOM behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc337bce-3d20-4a7d-96a9-34875b18ba9e

📥 Commits

Reviewing files that changed from the base of the PR and between 80f056e and 476c86a.

📒 Files selected for processing (5)
  • src/components/ForkTimeline.test.tsx
  • src/components/MarkdownRenderer.tsx
  • src/components/SearchBar.test.tsx
  • src/components/SearchBar.tsx
  • src/components/settings/VectorSearchSettings.tsx

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@AmintaCCCP AmintaCCCP merged commit eb1e4d0 into main Jul 6, 2026
5 checks passed
@AmintaCCCP AmintaCCCP deleted the fix/ime-realtime-search branch July 6, 2026 13:21
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.

如何使用 非AI搜索,现在是否强制使用AI搜索

1 participant