Skip to content

feat(preview): Pass version actions into the comparison banner - #4900

Open
zhirongwang wants to merge 1 commit into
box:masterfrom
zhirongwang:comparison-banner-version-actions
Open

zhirongwang wants to merge 1 commit into
box:masterfrom
zhirongwang:comparison-banner-version-actions

Conversation

@zhirongwang

@zhirongwang zhirongwang commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The versions sidebar registers download, make current, and delete for the compared version.
  • Those handlers are merged onto the existing comparison banner that the preview already reads.
  • If the sidebar loads after the compared pane opens, the banner updates without reloading the file.

Test Plan

  • With version history open, Make Current, Download, and Delete on the compared pane run the same actions as the version row menu for that version.
  • Download fetches that version, not the current file.
  • Open full preview from the host is still available on the banner.
  • Closing version history removes those three actions.

Made with Cursor

Summary by CodeRabbit

  • New Features
    • Comparison previews can display actions for the selected version, including download, make current, or delete when permitted and applicable.
    • Version sidebar actions reflect permissions, download availability, retention, archive status, and version limits, keeping available actions consistent with each version’s state.
  • Bug Fixes
    • Comparison banners and preview modes update in an open preview without reloading, while retaining other banner information and clearing stale version selections when comparison starts.

@zhirongwang zhirongwang self-assigned this Oct 13, 2026
@zhirongwang
zhirongwang marked this pull request as ready for review October 14, 2026 02:02
@zhirongwang
zhirongwang requested review from a team as code owners October 14, 2026 02:02
@box box deleted a comment from coderabbitai Bot Oct 14, 2026
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dbad1c63-3f74-40ad-a7cb-ceef7f428860
📥 Commits

Reviewing files that changed from the base of the PR and between 47e799b and afbaf83.

📒 Files selected for processing: 1
  • src/elements/content-preview/ContentPreview.js

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Walkthrough

The versions sidebar registers version actions and state with the comparison preview. The preview selects eligible actions for the compared version, combines them with host banner data, and passes the banner to both panes. It also updates comparison mode and banner props when supported without reloading the preview.

Changes

Comparison Banner Actions

Layer / File(s) Summary
Version visibility and comparison action selection
src/elements/content-sidebar/versions/flowTypes.js, src/elements/content-sidebar/versions/versionItemActionVisibility.js, src/elements/content-sidebar/versions/VersionsItem.js, src/elements/content-sidebar/versions/__tests__/versionItemActionVisibility.test.js
A shared helper derives version-item action visibility and selects eligible delete, download, and promote actions for a compared version. Tests cover missing, current, restricted, deleted, archived, retained, and over-limit versions.
Sidebar action registration
src/elements/content-sidebar/versions/VersionsSidebarContainer.js, src/elements/content-sidebar/versions/__tests__/VersionsSidebarContainer.test.js
The sidebar publishes its version handlers and state on mount and when relevant state changes. It clears registration on unmount. Tests cover default state, loaded versions, and cleanup.
Comparison preview banner and mode updates
src/elements/content-preview/ContentPreview.js
The comparison preview combines host banner data with selected version actions and passes the banner to both panes. It updates comparison mode and banner props when supported and no reload is needed.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant VersionsSidebarContainer
  participant ContentPreviewWithComparison
  participant selectComparisonBannerActions
  participant PreviewPanes
  VersionsSidebarContainer->>ContentPreviewWithComparison: register version actions
  ContentPreviewWithComparison->>selectComparisonBannerActions: select actions for compared version ID
  selectComparisonBannerActions-->>ContentPreviewWithComparison: eligible version actions
  ContentPreviewWithComparison->>PreviewPanes: pass combined comparison banner
Loading

Suggested reviewers: abhishek1128, ahorowitz123

Merge Risk: ⚪ Minimal · up to afbaf

No actionable merge-blocking issue is established. Confirm that late sidebar registration updates the banner in the supported preview before release.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: passing version actions into the comparison banner.
Description check Passed The description explains the change and includes a focused test plan covering the main objectives. The listed test items are unchecked, but the description is otherwise complete and relevant.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks each version's role
Then sends the actions down the scroll
The banner keeps its host details
Both panes receive the chosen trails
The sidebar clears when it departs

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]

This comment was marked as outdated.

The versions sidebar registers download, make current, and delete for
the compared version on the existing comparison banner.
@zhirongwang
zhirongwang force-pushed the comparison-banner-version-actions branch from 2ec8f0c to b916b80 Compare October 16, 2026 23:02

// Sidebar handlers override the host's; a handler the sidebar withholds keeps the host's.
return {
...hostComparisonBanner,

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.

Once the sidebar has registered, drop the host's onDownload, onDelete, and onMakeCurrent before applying selectComparisonBannerActions. A withheld action currently leaves the host handler in place, so the compared-pane menu can still download or delete a version the row would not allow.

Comment on lines +2015 to +2016
...hostComparisonBanner,
...selectComparisonBannerActions(versionActions, comparedVersionId),

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.

saw this after leaving my comment above - did we address this? I don't see the changes made in commit d26c70a, they seem to have been removed

This branch has not been deployed

No deployments
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