refactor(documents-sidebar): convert discarded isExportingKB state to ref#1267
Conversation
|
@mvanhorn is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Review by RecurseML
🔍 Review performed on 2b2453e..c2e52fb
✨ No bugs found, your code is sparkling clean
✅ Files analyzed, no issues (1)
• surfsense_web/components/layout/ui/sidebar/DocumentsSidebar.tsx
Description
Converts the discarded
isExportingKBstate inDocumentsSidebar.tsxto auseRef— Option A from the issue. The value was never read (no spinner, no disabled-button, no UI consumer), so every setter call was scheduling a re-render of the entire sidebar for no visible change.Motivation and Context
FIX #1250
The issue laid this out exactly:
surfsense_web/components/layout/ui/sidebar/DocumentsSidebar.tsx:481declaresconst [, setIsExportingKB] = useState(false);— tuple position 0 destructured into_— with the setter called in two export callbacks (handleExportWarningConfirm,handleExportFolder) and reset in theirfinallyblocks. GrepingisExportingKBoutside this file returns nothing, confirming there's no consumer. That makesuseRefa one-for-one swap that preserves the runtime tracking and skips the wasted renders.Shipping Option A (not Option B) per the issue's explicit preference: "Pick one path — prefer Option A unless you intend to ship loading UX in the same PR."
Screenshots
N/A — behavior-preserving refactor, no UI change.
API Changes
Change Type
Testing Performed
grep -n "isExportingKB" surfsense_web/components/layout/ui/sidebar/DocumentsSidebar.tsx— confirms 5 occurrences (1 ref declaration, 4 mutations at lines 511, 527, 563, 579), zero leftoversetIsExportingKB.grep -rn "isExportingKBRef" surfsense_web/— confirmed no unintended call sites elsewhere.useRefwas already imported in the existingreactimport (line 21); no import changes needed.finally, matching the pre-refactor behavior exactly.Checklist
Closes #1250
This contribution was developed with AI assistance (Codex).
High-level PR Summary