diff --git a/apps/desktop/src/lib/navigation/Branches.svelte b/apps/desktop/src/lib/navigation/Branches.svelte index 2b577e3e8..3ed8529e6 100644 --- a/apps/desktop/src/lib/navigation/Branches.svelte +++ b/apps/desktop/src/lib/navigation/Branches.svelte @@ -5,7 +5,11 @@ import { getGitHostListingService } from '$lib/gitHost/interface/gitHostListingService'; import BranchListingSidebarEntry from '$lib/navigation/BranchListingSidebarEntry.svelte'; import PullRequestSidebarEntry from '$lib/navigation/PullRequestSidebarEntry.svelte'; - import { getEntryUpdatedDate, type SidebarEntrySubject } from '$lib/navigation/types'; + import { + getEntryUpdatedDate, + getEntryWorkspaceStatus, + type SidebarEntrySubject + } from '$lib/navigation/types'; import { persisted } from '$lib/persisted/persisted'; import ScrollableContainer from '$lib/shared/ScrollableContainer.svelte'; import { getContext } from '$lib/utils/context'; @@ -53,8 +57,12 @@ const oneDay = 1000 * 60 * 60 * 24; - function groupByDate(branches: SidebarEntrySubject[]) { - const grouped: Record<'today' | 'yesterday' | 'lastWeek' | 'older', SidebarEntrySubject[]> = { + function groupBranches(branches: SidebarEntrySubject[]) { + const grouped: Record< + 'applied' | 'today' | 'yesterday' | 'lastWeek' | 'older', + SidebarEntrySubject[] + > = { + applied: [], today: [], yesterday: [], lastWeek: [], @@ -71,7 +79,9 @@ const msSinceLastCommit = now - getEntryUpdatedDate(b).getTime(); - if (msSinceLastCommit < oneDay) { + if (getEntryWorkspaceStatus(b)) { + grouped.applied.push(b); + } else if (msSinceLastCommit < oneDay) { grouped.today.push(b); } else if (msSinceLastCommit < 2 * oneDay) { grouped.yesterday.push(b); @@ -145,7 +155,7 @@ return filtered; } }); - const groupedBranches = $derived(groupByDate(searchedBranches)); + const groupedBranches = $derived(groupBranches(searchedBranches)); function handleSearchKeyDown(e: KeyboardEvent) { if (e.key === 'Escape') { @@ -242,6 +252,7 @@ {/each} {:else} + {@render branchGroup({ title: 'Applied', children: groupedBranches.applied })} {@render branchGroup({ title: 'Today', children: groupedBranches.today })} {@render branchGroup({ title: 'Yesterday', children: groupedBranches.yesterday })} {@render branchGroup({ title: 'Last week', children: groupedBranches.lastWeek })} diff --git a/apps/desktop/src/lib/navigation/types.ts b/apps/desktop/src/lib/navigation/types.ts index f74df024b..12383ac99 100644 --- a/apps/desktop/src/lib/navigation/types.ts +++ b/apps/desktop/src/lib/navigation/types.ts @@ -14,3 +14,7 @@ export type SidebarEntrySubject = export function getEntryUpdatedDate(entry: SidebarEntrySubject) { return entry.type === 'branchListing' ? entry.subject.updatedAt : entry.subject.modifiedAt; } + +export function getEntryWorkspaceStatus(entry: SidebarEntrySubject) { + return entry.type === 'branchListing' ? entry.subject.virtualBranch?.inWorkspace : undefined; +}