Skip to content

Conversation

@shahzadaziz
Copy link
Collaborator

@shahzadaziz shahzadaziz commented Dec 31, 2025

Summary

Adds deferDataFetch prop support to defer sidebar panel API calls until preview loads. File metadata is always fetched immediately (needed for sidebar structure), while heavier panel data (activity feed, comments, tasks, versions) is deferred when the prop is true.

Changes made.

  • ContentSidebar.js - Always fetch file metadata on mount (fast, needed for sidebar structure); removed deferDataFetch check from componentDidMount/componentDidUpdate; passes prop through to Sidebar

  • Sidebar.js / SidebarPanels.js - Prop drilling: passes deferDataFetch through to LoadableActivitySidebar
    ActivitySidebar.js - Honors deferDataFetch prop: skips fetchFeedItems() on mount when true; fetches when prop changes from true → false (deferral lifted)

  • ActivitySidebar.test.js - Added tests covering: deferred mount behavior, non-deferred mount, and componentDidUpdate transitions for deferral state changes

Summary by CodeRabbit

  • New Features

    • Added a configurable sidebar flag to control whether heavier sidebar data is fetched, allowing prioritized preview loading and deferring expensive API calls and updates.
  • Tests

    • Added unit tests covering initial and update-triggered sidebar fetch behavior to ensure the configurable loading flag behaves correctly.

✏️ Tip: You can customize this high-level summary in your review settings.

@shahzadaziz shahzadaziz requested review from a team as code owners December 31, 2025 00:15
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 31, 2025

Walkthrough

Added a new public prop shouldFetchSidebarData?: boolean and propagated it through ContentSidebar → Sidebar → SidebarPanels → ActivitySidebar. ActivitySidebar now conditionally fetches activity feed on mount and when the prop transitions from false → true. Unit tests added for the new behavior.

Changes

Cohort / File(s) Summary
Prop propagation chain
src/elements/content-sidebar/ContentSidebar.js, src/elements/content-sidebar/Sidebar.js, src/elements/content-sidebar/SidebarPanels.js
Added shouldFetchSidebarData?: boolean to Props, destructured it in renders, and forwarded it downstream to panels.
Deferred fetch logic
src/elements/content-sidebar/ActivitySidebar.js
Added shouldFetchSidebarData?: boolean to ExternalProps; componentDidMount now calls fetchFeedItems(true) only when the flag is true (defaults to true). Added componentDidUpdate to call fetchFeedItems(true) on false→true transition.
Tests
src/elements/content-sidebar/__tests__/ActivitySidebar.test.js
Added unit tests verifying fetch behavior on mount and on prop transitions (false→true, true→false, and stable cases).

Sequence Diagram

sequenceDiagram
    participant User
    participant ContentSidebar
    participant Sidebar
    participant SidebarPanels
    participant ActivitySidebar
    participant FetchService

    User->>ContentSidebar: Mount (with shouldFetchSidebarData)
    ContentSidebar->>Sidebar: forward shouldFetchSidebarData
    Sidebar->>SidebarPanels: forward shouldFetchSidebarData
    SidebarPanels->>ActivitySidebar: render with shouldFetchSidebarData

    alt shouldFetchSidebarData = false
        ActivitySidebar->>ActivitySidebar: componentDidMount (no fetch)
    else shouldFetchSidebarData = true
        rect rgb(200,230,200)
            ActivitySidebar->>FetchService: fetchFeedItems(true)
            FetchService-->>ActivitySidebar: activity data
        end
    end

    User->>ContentSidebar: Update props (shouldFetchSidebarData false→true)
    ContentSidebar->>SidebarPanels: prop flows
    SidebarPanels->>ActivitySidebar: prop updated
    rect rgb(200,220,250)
        ActivitySidebar->>ActivitySidebar: componentDidUpdate (detect transition)
        ActivitySidebar->>FetchService: fetchFeedItems(true)
        FetchService-->>ActivitySidebar: activity data
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • jpan-box
  • bfoxx1906
  • tjuanitas

Poem

🐰 A little flag hopped down the line,
Quiet at first, then woke in time.
When it turns on, the fetches play,
When it rests, the calls delay—
Hooray for tidy, timely rhyme! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding ability to defer sidebar data fetching requests, which aligns with the changeset.
Description check ✅ Passed The description provides a clear summary, lists changes across files, and explains the implementation. However, it does not follow the repository's provided template structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 42a8813 and 55304d8.

📒 Files selected for processing (1)
  • src/elements/content-sidebar/ContentSidebar.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/elements/content-sidebar/ContentSidebar.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: lint_test_build
  • GitHub Check: Summary

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.

jmcbgaston
jmcbgaston previously approved these changes Jan 2, 2026
bfoxx1906
bfoxx1906 previously approved these changes Jan 5, 2026
tjuanitas
tjuanitas previously approved these changes Jan 5, 2026
@shahzadaziz shahzadaziz dismissed stale reviews from tjuanitas and bfoxx1906 via 42a8813 January 6, 2026 00:01
@mergify mergify bot added the queued label Jan 6, 2026
@mergify mergify bot merged commit 69be418 into box:master Jan 6, 2026
9 checks passed
@mergify
Copy link
Contributor

mergify bot commented Jan 6, 2026

Merge Queue Status

✅ The pull request has been merged at 55304d8

This pull request spent 6 seconds in the queue, with no time running CI.
The checks were run in-place.

Required conditions to merge

@mergify mergify bot removed the queued label Jan 6, 2026
@shahzadaziz shahzadaziz deleted the defer-sidebar-requests branch January 6, 2026 00:28
shahzadaziz added a commit that referenced this pull request Jan 8, 2026
…uests (#4410)

* feat(content-sidebar): add ability to defer sidebar data fetching requests

* fix: address comments

* fix: address comments

* fix: address comments

* fix: address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants