fix: keep selected project visible in session selector

This commit is contained in:
777genius 2026-04-14 17:10:23 +03:00
parent 0dfd2fc610
commit 36a79f2586

View file

@ -301,12 +301,36 @@ export const DateGroupedSessions = (): React.JSX.Element => {
fetchProjects, fetchProjects,
]); ]);
const effectiveSelectedWorktreeId =
selectedWorktreeId ?? activeProjectId ?? selectedProjectId ?? null;
const effectiveSelectedRepositoryId = useMemo(
() =>
resolveEffectiveSelectedRepositoryId({
repositoryGroups,
selectedRepositoryId,
effectiveSelectedWorktreeId,
}),
[effectiveSelectedWorktreeId, repositoryGroups, selectedRepositoryId]
);
const activeProjectValue =
viewMode === 'grouped'
? effectiveSelectedRepositoryId
: (activeProjectId ?? selectedProjectId ?? null);
// Project combobox options // Project combobox options
const projectComboboxOptions = useMemo((): ComboboxOption[] => { const projectComboboxOptions = useMemo((): ComboboxOption[] => {
const items = const items =
viewMode === 'grouped' viewMode === 'grouped'
? repositoryGroups.filter((r) => r.totalSessions > 0) ? repositoryGroups.filter(
: projects.filter((p) => (p.totalSessions ?? p.sessions.length) > 0); (repo) => repo.totalSessions > 0 || repo.id === effectiveSelectedRepositoryId
)
: projects.filter(
(project) =>
(project.totalSessions ?? project.sessions.length) > 0 ||
project.id === activeProjectValue
);
return items.map((item) => { return items.map((item) => {
const sessionCount = const sessionCount =
viewMode === 'grouped' viewMode === 'grouped'
@ -324,24 +348,7 @@ export const DateGroupedSessions = (): React.JSX.Element => {
meta: { sessionCount, path }, meta: { sessionCount, path },
}; };
}); });
}, [viewMode, repositoryGroups, projects]); }, [activeProjectValue, effectiveSelectedRepositoryId, projects, repositoryGroups, viewMode]);
const effectiveSelectedWorktreeId =
selectedWorktreeId ?? activeProjectId ?? selectedProjectId ?? null;
const effectiveSelectedRepositoryId = useMemo(
() =>
resolveEffectiveSelectedRepositoryId({
repositoryGroups,
selectedRepositoryId,
effectiveSelectedWorktreeId,
}),
[effectiveSelectedWorktreeId, repositoryGroups, selectedRepositoryId]
);
const activeProjectValue =
viewMode === 'grouped'
? effectiveSelectedRepositoryId
: (activeProjectId ?? selectedProjectId ?? null);
const handleProjectValueChange = (id: string): void => { const handleProjectValueChange = (id: string): void => {
if (viewMode === 'grouped') selectRepository(id); if (viewMode === 'grouped') selectRepository(id);