Skip to content

Commit 72c8600

Browse files
committed
fix: skip empty tiers when expanding old workspaces
If all workspaces are older than 30 days, show 'Older than 30 days' directly instead of requiring clicks through empty 1-day and 7-day tiers.
1 parent 61af200 commit 72c8600

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/browser/components/ProjectSidebar.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,17 @@ const ProjectSidebarInner: React.FC<ProjectSidebarProps> = ({
581581
/>
582582
);
583583

584+
// Find the next tier with workspaces (skip empty tiers)
585+
const findNextNonEmptyTier = (startIndex: number): number => {
586+
for (let i = startIndex; i < buckets.length; i++) {
587+
if (buckets[i].length > 0) return i;
588+
}
589+
return -1;
590+
};
591+
584592
// Render a tier and all subsequent tiers recursively
585593
// Each tier only shows if the previous tier is expanded
594+
// Empty tiers are skipped automatically
586595
const renderTier = (tierIndex: number): React.ReactNode => {
587596
const bucket = buckets[tierIndex];
588597
// Sum remaining workspaces from this tier onward
@@ -627,18 +636,23 @@ const ProjectSidebarInner: React.FC<ProjectSidebarProps> = ({
627636
{isExpanded && (
628637
<>
629638
{bucket.map(renderWorkspace)}
630-
{tierIndex + 1 < buckets.length &&
631-
renderTier(tierIndex + 1)}
639+
{(() => {
640+
const nextTier = findNextNonEmptyTier(tierIndex + 1);
641+
return nextTier !== -1 ? renderTier(nextTier) : null;
642+
})()}
632643
</>
633644
)}
634645
</>
635646
);
636647
};
637648

649+
// Find first non-empty tier to start rendering
650+
const firstTier = findNextNonEmptyTier(0);
651+
638652
return (
639653
<>
640654
{recent.map(renderWorkspace)}
641-
{renderTier(0)}
655+
{firstTier !== -1 && renderTier(firstTier)}
642656
</>
643657
);
644658
})()}

0 commit comments

Comments
 (0)