mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-02-20 15:47:36 +00:00
refactor(sidebar): update sessionMeta handling for session loading logic
- This fixes an issue where the sidebar was showing 6+ even when there were only 5 sessions, due to the hasMore logic not accounting for the case where there are exactly 6 sessions. It was also showing "Show more sessions" even where there were no more sessions to load. - This was because `hasMore` was sometimes `undefined` and the logic checked for hasMore !== false, which treated undefined as true. Now we explicitly check for hasMore === true to determine if there are more sessions to load.
This commit is contained in:
@@ -434,7 +434,11 @@ async function getProjects(progressCallback = null) {
|
|||||||
displayName: customName || autoDisplayName,
|
displayName: customName || autoDisplayName,
|
||||||
fullPath: fullPath,
|
fullPath: fullPath,
|
||||||
isCustomName: !!customName,
|
isCustomName: !!customName,
|
||||||
sessions: []
|
sessions: [],
|
||||||
|
sessionMeta: {
|
||||||
|
hasMore: false,
|
||||||
|
total: 0
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Try to get sessions for this project (just first 5 for performance)
|
// Try to get sessions for this project (just first 5 for performance)
|
||||||
@@ -447,6 +451,10 @@ async function getProjects(progressCallback = null) {
|
|||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(`Could not load sessions for project ${entry.name}:`, e.message);
|
console.warn(`Could not load sessions for project ${entry.name}:`, e.message);
|
||||||
|
project.sessionMeta = {
|
||||||
|
hasMore: false,
|
||||||
|
total: 0
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also fetch Cursor sessions for this project
|
// Also fetch Cursor sessions for this project
|
||||||
@@ -526,7 +534,7 @@ async function getProjects(progressCallback = null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const project = {
|
const project = {
|
||||||
name: projectName,
|
name: projectName,
|
||||||
path: actualProjectDir,
|
path: actualProjectDir,
|
||||||
displayName: projectConfig.displayName || await generateDisplayName(projectName, actualProjectDir),
|
displayName: projectConfig.displayName || await generateDisplayName(projectName, actualProjectDir),
|
||||||
@@ -534,9 +542,13 @@ async function getProjects(progressCallback = null) {
|
|||||||
isCustomName: !!projectConfig.displayName,
|
isCustomName: !!projectConfig.displayName,
|
||||||
isManuallyAdded: true,
|
isManuallyAdded: true,
|
||||||
sessions: [],
|
sessions: [],
|
||||||
|
sessionMeta: {
|
||||||
|
hasMore: false,
|
||||||
|
total: 0
|
||||||
|
},
|
||||||
cursorSessions: [],
|
cursorSessions: [],
|
||||||
codexSessions: []
|
codexSessions: []
|
||||||
};
|
};
|
||||||
|
|
||||||
// Try to fetch Cursor sessions for manual projects too
|
// Try to fetch Cursor sessions for manual projects too
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export default function SidebarProjectItem({
|
|||||||
}: SidebarProjectItemProps) {
|
}: SidebarProjectItemProps) {
|
||||||
const isSelected = selectedProject?.name === project.name;
|
const isSelected = selectedProject?.name === project.name;
|
||||||
const isEditing = editingProject === project.name;
|
const isEditing = editingProject === project.name;
|
||||||
const hasMoreSessions = project.sessionMeta?.hasMore !== false;
|
const hasMoreSessions = project.sessionMeta?.hasMore === true;
|
||||||
const sessionCountDisplay = getSessionCountDisplay(sessions, hasMoreSessions);
|
const sessionCountDisplay = getSessionCountDisplay(sessions, hasMoreSessions);
|
||||||
const sessionCountLabel = `${sessionCountDisplay} session${sessions.length === 1 ? '' : 's'}`;
|
const sessionCountLabel = `${sessionCountDisplay} session${sessions.length === 1 ? '' : 's'}`;
|
||||||
const taskStatus = getTaskIndicatorStatus(project, mcpServerStatus);
|
const taskStatus = getTaskIndicatorStatus(project, mcpServerStatus);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export default function SidebarProjectSessions({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const hasSessions = sessions.length > 0;
|
const hasSessions = sessions.length > 0;
|
||||||
const hasMoreSessions = project.sessionMeta?.hasMore !== false;
|
const hasMoreSessions = project.sessionMeta?.hasMore === true;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ml-3 space-y-1 border-l border-border pl-3">
|
<div className="ml-3 space-y-1 border-l border-border pl-3">
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ export function useSidebarController({
|
|||||||
|
|
||||||
const loadMoreSessions = useCallback(
|
const loadMoreSessions = useCallback(
|
||||||
async (project: Project) => {
|
async (project: Project) => {
|
||||||
const canLoadMore = project.sessionMeta?.hasMore !== false;
|
const canLoadMore = project.sessionMeta?.hasMore === true;
|
||||||
if (!canLoadMore || loadingSessions[project.name]) {
|
if (!canLoadMore || loadingSessions[project.name]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user