Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions packages/components/src/components/archive/archive-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from 'lucide-react';
import type { LucideIcon } from 'lucide-react';
import { cn } from '@/lib/utils';
import { useAppCapability } from '@/lib/app-platform';
import { Button } from '@/ui/button';
import { Checkbox } from '@/ui/checkbox';
import {
Expand Down Expand Up @@ -314,17 +315,24 @@ type ArchivedSessionItemViewModel = {
prTooltipLabel: string;
};

/**
* @param gitHubIntegrationAvailable - The `githubIntegration` platform
* capability. With it off there is no GitHub App behind the row's PR badge, so
* the pull request is dropped here rather than at each of the four values it
* feeds — the same shape `getSessionGitHubState` uses.
*/
function getArchivedSessionItemViewModel(
session: SessionMeta,
now: Date
now: Date,
gitHubIntegrationAvailable = true
): ArchivedSessionItemViewModel {
const title = session.title?.trim() || 'Untitled session';
const relativeTime = formatRelativeTime(session.lastMessageAt, now);
const branchName = session.branchName?.trim() || '';
const diffStats = session.diffStats ?? { allChange: { add: 0, del: 0 } };
const hasChanges = diffStats.allChange.add !== 0 || diffStats.allChange.del !== 0;

const pullRequests = session.pullRequests ?? [];
const pullRequests = gitHubIntegrationAvailable ? session.pullRequests ?? [] : [];
const latestPr =
pullRequests.length > 0
? pullRequests.some((pr) => getSessionPullRequestLegacyFields(pr).reportedAt)
Expand Down Expand Up @@ -401,6 +409,7 @@ function DesktopArchivedSessionItem({
onEnterMultiSelect,
owner,
}: ArchivedSessionItemBaseProps) {
const gitHubIntegrationAvailable = useAppCapability('githubIntegration');
const {
title,
relativeTime,
Expand All @@ -411,7 +420,7 @@ function DesktopArchivedSessionItem({
prStatusMeta,
PrIcon,
prTooltipLabel,
} = getArchivedSessionItemViewModel(session, now);
} = getArchivedSessionItemViewModel(session, now, gitHubIntegrationAvailable);

const handleRowClick = useCallback(() => {
if (isMultiSelectMode) {
Expand Down Expand Up @@ -618,6 +627,7 @@ function MobileArchivedSessionItem({
onEnterMultiSelect,
owner,
}: MobileArchivedSessionItemProps) {
const gitHubIntegrationAvailable = useAppCapability('githubIntegration');
const {
title,
relativeTime,
Expand All @@ -628,7 +638,7 @@ function MobileArchivedSessionItem({
prStatusMeta,
PrIcon,
prTooltipLabel,
} = getArchivedSessionItemViewModel(session, now);
} = getArchivedSessionItemViewModel(session, now, gitHubIntegrationAvailable);

const longPressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const longPressFiredRef = useRef(false);
Expand Down