Skip to content

fix(ai-setting): scope org store subscription to curOrg - #2040

Merged
openai0229 merged 2 commits into
OtterMind:mainfrom
Aias00:fix/2031-aisetting-store-sub
Jul 24, 2026
Merged

openai0229 merged 2 commits into
OtterMind:mainfrom
Aias00:fix/2031-aisetting-store-sub

Conversation

@Aias00

@Aias00 Aias00 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Related issue

Closes #2031

Summary

AISetting read const { curOrg } = useOrgStore();, subscribing to the entire org store. The component re-rendered on every org-store change instead of only when curOrg changed. Changed to a scoped selector: const curOrg = useOrgStore((s) => s.curOrg);. Downstream usage (curOrg?.roleCodes) is unchanged.

Affected surfaces

  • Frontend / Web
  • Backend / API / Storage
  • Database plugin / Driver
  • JCEF / Desktop packaging
  • CI / Build / Release
  • Documentation only

Verification

  • Commands and results: npx tsc --noEmit -p chat2db-community-client/tsconfig.json — no errors for AISetting/index.tsx.
  • Manual verification: A selector swap; curOrg is a direct field on the org store.
  • UI evidence: N/A

Risk and compatibility

  • Public API or stored data: N/A.
  • Database or driver compatibility: N/A.
  • Network, privacy, or security: N/A.
  • Community / Local / Pro boundary: N/A.
  • Backward compatibility: Strictly fewer re-renders; behavior unchanged.

Reviewer map

  • Start here: blocks/Setting/AISetting/index.tsx:24const { curOrg } = useOrgStore(); -> const curOrg = useOrgStore((s) => s.curOrg);.
  • Failure condition: Component still re-renders on unrelated org-store changes.
  • Rollback or disable path: Revert this single commit.

Contributor declaration

  • I linked the Issue that defines this change.
  • I tested the affected behavior and reported the actual results above.
  • I did not include credentials, private data, or generated build output.
  • I disclosed substantial AI assistance below, or this PR contains no substantial AI-generated code.

AI assistance: The fix, verification, and PR description were produced with Claude Code assistance.

useOrgStore() subscribed to the whole org store. Use a scoped selector.

Fixes OtterMind#2031

Co-Authored-By: Claude <noreply@anthropic.com>
@Aias00
Aias00 requested a review from openai0229 as a code owner July 24, 2026 09:10
Copilot AI review requested due to automatic review settings July 24, 2026 09:10

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Reviewed the scoped org-store selector. It preserves the value contract and removes unrelated store subscriptions; no blocking issue found.

@openai0229
openai0229 merged commit 762cd69 into OtterMind:main Jul 24, 2026
15 of 16 checks passed
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

AISetting subscribes to the entire org store

3 participants