Skip to content

refactor(documents-sidebar): convert discarded isExportingKB state to ref#1267

Merged
MODSetter merged 1 commit intoMODSetter:devfrom
mvanhorn:osc/1250-isexportingkb-ref
Apr 21, 2026
Merged

refactor(documents-sidebar): convert discarded isExportingKB state to ref#1267
MODSetter merged 1 commit intoMODSetter:devfrom
mvanhorn:osc/1250-isexportingkb-ref

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

@mvanhorn mvanhorn commented Apr 19, 2026

Description

Converts the discarded isExportingKB state in DocumentsSidebar.tsx to a useRef — 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:481 declares const [, setIsExportingKB] = useState(false); — tuple position 0 destructured into _ — with the setter called in two export callbacks (handleExportWarningConfirm, handleExportFolder) and reset in their finally blocks. Greping isExportingKB outside this file returns nothing, confirming there's no consumer. That makes useRef a 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

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

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 leftover setIsExportingKB.
  • grep -rn "isExportingKBRef" surfsense_web/ — confirmed no unintended call sites elsewhere.
  • useRef was already imported in the existing react import (line 21); no import changes needed.
  • Both export paths still set the flag true before the request and reset it to false in finally, matching the pre-refactor behavior exactly.

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

Closes #1250

This contribution was developed with AI assistance (Codex).

High-level PR Summary

Analyze latest changes

Need help? Join our Discord

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 19, 2026

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 19dc1950-bf11-49f1-8fed-3a5e06d0c278

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

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

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

@MODSetter MODSetter merged commit d744cb4 into MODSetter:dev Apr 21, 2026
8 of 11 checks passed
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.

2 participants