fix: keep team project selection as sort priority

This commit is contained in:
777genius 2026-04-14 18:18:52 +03:00
parent 43f2426a9b
commit 0bbeac8c84
2 changed files with 16 additions and 12 deletions

View file

@ -42,9 +42,8 @@ export const TeamListFilterPopover = ({
const activeCount = useMemo(() => {
let count = 0;
if (filter.selectedStatuses.size > 0) count += 1;
if (selectedProjectPath) count += 1;
return count;
}, [filter.selectedStatuses, selectedProjectPath]);
}, [filter.selectedStatuses]);
const uniqueProjects = useMemo(() => {
const paths = new Set<string>();
@ -73,7 +72,6 @@ export const TeamListFilterPopover = ({
const handleClearAll = (): void => {
onFilterChange(EMPTY_TEAM_FILTER);
onProjectChange(null);
};
const aliveSet = useMemo(() => new Set(aliveTeams), [aliveTeams]);
@ -146,7 +144,7 @@ export const TeamListFilterPopover = ({
{uniqueProjects.length > 0 && (
<div className="border-b border-[var(--color-border)] p-3">
<p className="mb-2 text-[11px] font-medium uppercase tracking-wider text-[var(--color-text-muted)]">
Project
Project priority
</p>
<div className="max-h-40 space-y-1.5 overflow-y-auto">
{uniqueProjects.map((project) => (

View file

@ -421,11 +421,10 @@ export const TeamListView = (): React.JSX.Element => {
});
}
if (currentProjectPath) {
result = result.filter((team) => teamMatchesProjectSelection(team, currentProjectPath));
}
const aliveSet = new Set(aliveTeams);
const matchesCurrentProject = currentProjectPath
? (team: TeamSummary): boolean => teamMatchesProjectSelection(team, currentProjectPath)
: null;
result = [...result].sort((a, b) => {
// 1. Alive (running) teams first
@ -433,12 +432,19 @@ export const TeamListView = (): React.JSX.Element => {
const aliveB = aliveSet.has(b.teamName) ? 0 : 1;
if (aliveA !== aliveB) return aliveA - aliveB;
// 2. Most recently active teams first (stable secondary sort)
// 2. Teams related to the selected project are prioritized next
if (matchesCurrentProject) {
const projectA = matchesCurrentProject(a) ? 0 : 1;
const projectB = matchesCurrentProject(b) ? 0 : 1;
if (projectA !== projectB) return projectA - projectB;
}
// 3. Most recently active teams first (stable secondary sort)
const tsA = a.lastActivity ? new Date(a.lastActivity).getTime() : 0;
const tsB = b.lastActivity ? new Date(b.lastActivity).getTime() : 0;
if (tsA !== tsB) return tsB - tsA;
// 3. Fallback: alphabetical by team name for deterministic order
// 4. Fallback: alphabetical by team name for deterministic order
return a.teamName.localeCompare(b.teamName);
});
@ -770,7 +776,7 @@ export const TeamListView = (): React.JSX.Element => {
className="mt-1 truncate text-xs text-[var(--color-text-muted)]"
title={currentProjectPath}
>
{currentProjectPath}
Prioritizing teams related to this project - not hiding the rest
</p>
</div>
<Button
@ -848,7 +854,7 @@ export const TeamListView = (): React.JSX.Element => {
);
}
const hasActiveFilters = filter.selectedStatuses.size > 0 || currentProjectPath != null;
const hasActiveFilters = filter.selectedStatuses.size > 0;
if (filteredTeams.length === 0 && (searchQuery.trim() || hasActiveFilters)) {
return (
<div className="flex items-center justify-center py-12 text-sm text-[var(--color-text-muted)]">