Skip to content

fix(cli): memoize useHistory() return to avoid unnecessary re-renders#3547

Merged
wenshao merged 1 commit into
QwenLM:mainfrom
qqqys:fix/memo-his
Apr 24, 2026
Merged

fix(cli): memoize useHistory() return to avoid unnecessary re-renders#3547
wenshao merged 1 commit into
QwenLM:mainfrom
qqqys:fix/memo-his

Conversation

@qqqys

@qqqys qqqys commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

Backport: gemini-cli#10820 — memoize useHistory() return

Motivation

Originated from QwenLM/qwen-code#3530: on 0.15.0, typing /model repeatedly throws Maximum update depth exceeded.

While investigating, we found that upstream Gemini CLI had already fixed the same instability at the hook boundary ~6 months earlier. This repo missed the fix because the Sync upstream Gemini-CLI v0.8.2 (#838) synced against a v0.8.2 tag cut from a commit that did not include it. This change backports it.

Upstream PR Reference

google-gemini/gemini-cli#10820Fix hooks to avoid unnecessary re-renders

  • commit cd354aebe
  • author Tommaso Sciortino (scidomino)
  • merged on 2025-10-09

TLDR

These hooks were not properly memoized and it was causing unnecessary re-renders.

Dive Deeper

Normally, this is not a super big deal but I spotted it while investigating #10517

Reviewer Test Plan

Basic smoke test is sufficient. This is a pure refactor.

Linked issues / bugs

Contributes to #10517

Comment thread claude-code Outdated
@@ -0,0 +1 @@
Subproject commit 4b9d30f7953273e567a18eb819f4eddd45fcc877

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Critical] This PR adds a top-level claude-code gitlink (mode 160000) without a corresponding .gitmodules entry. Consumers cannot initialize or update it as a normal submodule because Git has no URL/path mapping, and the external repository reference appears unrelated to the useHistory() memoization change.

Suggested change
Subproject commit 4b9d30f7953273e567a18eb819f4eddd45fcc877

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — thanks. The claude-code gitlink was an accidental stray from a local reference directory; it has nothing to do with the useHistory() memoization fix. Dropped it via git rm --cached claude-code and force-pushed (8446cf8ac...9f2b3c01e), so the PR now only touches packages/cli/src/ui/hooks/useHistoryManager.ts.

@LaZzyMan LaZzyMan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No issues found. LGTM! ✅ — gpt-5.5 via Qwen Code /review

@wenshao wenshao merged commit 3a2ee4a into QwenLM:main Apr 24, 2026
13 checks passed
xaelistic pushed a commit to xaelistic/qwen-code that referenced this pull request Jun 7, 2026
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.

3 participants