refactor(recent): replace active-now tracking with recent session window

Replace persisted 'active now' tracking with 48-hour recency window
Remove Zustand ActiveNowStore and localStorage persistence
Simplify session sidebar data flow
This commit is contained in:
Bohdan Triapitsyn
2026-06-12 14:34:33 +03:00
parent 28aeb4950b
commit c281937406
5 changed files with 50 additions and 212 deletions
@@ -42,29 +42,6 @@ export function SidebarActivitySections({
const [visibleCountBySection, setVisibleCountBySection] = React.useState<Map<string, number>>(new Map());
const flatVariant = variant === 'flat';
const toggleSection = React.useCallback((key: string) => {
setCollapsed((prev) => {
const next = new Set(prev);
if (next.has(key)) {
next.delete(key);
} else {
next.add(key);
}
return next;
});
}, []);
const showMoreSessions = React.useCallback((key: string, currentVisibleCount: number, totalCount: number) => {
setVisibleCountBySection((prev) => {
const nextVisibleCount = flatVariant
? Math.min(totalCount, currentVisibleCount + batchSize)
: totalCount;
const next = new Map(prev);
next.set(key, nextVisibleCount);
return next;
});
}, [batchSize, flatVariant]);
const resetSectionLimit = React.useCallback((key: string) => {
setVisibleCountBySection((prev) => {
if (!prev.has(key)) {
@@ -76,6 +53,30 @@ export function SidebarActivitySections({
});
}, []);
const toggleSection = React.useCallback((key: string) => {
// Collapsing/expanding resets any "show more" batches, matching the
// worktree/project group behavior.
resetSectionLimit(key);
setCollapsed((prev) => {
const next = new Set(prev);
if (next.has(key)) {
next.delete(key);
} else {
next.add(key);
}
return next;
});
}, [resetSectionLimit]);
const showMoreSessions = React.useCallback((key: string, currentVisibleCount: number, totalCount: number) => {
setVisibleCountBySection((prev) => {
const nextVisibleCount = Math.min(totalCount, currentVisibleCount + batchSize);
const next = new Map(prev);
next.set(key, nextVisibleCount);
return next;
});
}, [batchSize]);
const visibleSections = sections.filter((section) => section.items.length > 0);
if (visibleSections.length === 0) {
return null;
@@ -132,9 +133,7 @@ export function SidebarActivitySections({
onClick={() => showMoreSessions(section.key, visibleItems.length, section.items.length)}
className="mt-0.5 flex items-center justify-start rounded-md px-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline"
>
{remainingCount === 1
? t('sessions.sidebar.group.showMoreSingle', { count: remainingCount })
: t('sessions.sidebar.group.showMorePlural', { count: remainingCount })}
{t('sessions.sidebar.group.showMore')}
</button>
) : null}
{canShowFewer ? (