mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-03-05 14:07:40 +00:00
* feat: implement session rename with SQLite storage (closes #72, fixes #358) - Add session_names table to store custom display names per provider - Add PUT /api/sessions/:sessionId/rename endpoint - Replace stub updateSessionSummary with real API call - Apply custom names across all providers (Claude, Codex, Cursor) - Fix project rename destroying config (spread merge instead of overwrite) - Thread provider parameter through sidebar component chain - Add i18n error messages for rename failures (en, ja, ko, zh-CN) * fix: address CodeRabbit review feedback for session rename - Log migration errors instead of swallowing them silently (db.js) - Add try/catch to applyCustomSessionNames to prevent getProjects abort - Move applyCustomSessionNames to db.js as shared helper (DRY) - Fix Cursor getSessionName to check session.summary for custom names - Move edit state clearing to finally block in updateSessionSummary - Sanitize sessionId, add 500-char summary limit, validate provider whitelist - Remove dead applyCustomSessionNames call on empty manual project sessions * fix: reject sessionId on mismatch instead of silent normalization Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix: enable rename for all providers, add Gemini support, clean up orphans - Enable rename UI (pencil icon) for Codex, Cursor, and Gemini sessions - Keep delete button hidden for Cursor (no backend delete endpoint) - Add 'gemini' to VALID_PROVIDERS and hoist to module scope - Add sessionNamesDb.deleteName on session delete (claude, codex, gemini) - Fix token-usage endpoint sessionId mismatch validation - Remove redundant try/catch in sessionNamesDb methods - Let session_names migration errors propagate to outer handler --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Haileyesus <118998054+blackmammoth@users.noreply.github.com>
247 lines
7.2 KiB
TypeScript
247 lines
7.2 KiB
TypeScript
import { useEffect } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useDeviceSettings } from '../../../hooks/useDeviceSettings';
|
|
import { useVersionCheck } from '../../../hooks/useVersionCheck';
|
|
import { useUiPreferences } from '../../../hooks/useUiPreferences';
|
|
import { useSidebarController } from '../hooks/useSidebarController';
|
|
import { useTaskMaster } from '../../../contexts/TaskMasterContext';
|
|
import { useTasksSettings } from '../../../contexts/TasksSettingsContext';
|
|
import SidebarCollapsed from './subcomponents/SidebarCollapsed';
|
|
import SidebarContent from './subcomponents/SidebarContent';
|
|
import SidebarModals from './subcomponents/SidebarModals';
|
|
import type { Project, SessionProvider } from '../../../types/app';
|
|
import type { SidebarProjectListProps } from './subcomponents/SidebarProjectList';
|
|
import type { MCPServerStatus, SidebarProps } from '../types/types';
|
|
|
|
type TaskMasterSidebarContext = {
|
|
setCurrentProject: (project: Project) => void;
|
|
mcpServerStatus: MCPServerStatus;
|
|
};
|
|
|
|
function Sidebar({
|
|
projects,
|
|
selectedProject,
|
|
selectedSession,
|
|
onProjectSelect,
|
|
onSessionSelect,
|
|
onNewSession,
|
|
onSessionDelete,
|
|
onProjectDelete,
|
|
isLoading,
|
|
loadingProgress,
|
|
onRefresh,
|
|
onShowSettings,
|
|
showSettings,
|
|
settingsInitialTab,
|
|
onCloseSettings,
|
|
isMobile,
|
|
}: SidebarProps) {
|
|
const { t } = useTranslation(['sidebar', 'common']);
|
|
const { isPWA } = useDeviceSettings({ trackMobile: false });
|
|
const { updateAvailable, latestVersion, currentVersion, releaseInfo, installMode } = useVersionCheck(
|
|
'siteboon',
|
|
'claudecodeui',
|
|
);
|
|
const { preferences, setPreference } = useUiPreferences();
|
|
const { sidebarVisible } = preferences;
|
|
const { setCurrentProject, mcpServerStatus } = useTaskMaster() as TaskMasterSidebarContext;
|
|
const { tasksEnabled } = useTasksSettings();
|
|
|
|
const {
|
|
isSidebarCollapsed,
|
|
expandedProjects,
|
|
editingProject,
|
|
showNewProject,
|
|
editingName,
|
|
loadingSessions,
|
|
initialSessionsLoaded,
|
|
currentTime,
|
|
isRefreshing,
|
|
editingSession,
|
|
editingSessionName,
|
|
searchFilter,
|
|
deletingProjects,
|
|
deleteConfirmation,
|
|
sessionDeleteConfirmation,
|
|
showVersionModal,
|
|
filteredProjects,
|
|
handleTouchClick,
|
|
toggleProject,
|
|
handleSessionClick,
|
|
toggleStarProject,
|
|
isProjectStarred,
|
|
getProjectSessions,
|
|
startEditing,
|
|
cancelEditing,
|
|
saveProjectName,
|
|
showDeleteSessionConfirmation,
|
|
confirmDeleteSession,
|
|
requestProjectDelete,
|
|
confirmDeleteProject,
|
|
loadMoreSessions,
|
|
handleProjectSelect,
|
|
refreshProjects,
|
|
updateSessionSummary,
|
|
collapseSidebar: handleCollapseSidebar,
|
|
expandSidebar: handleExpandSidebar,
|
|
setShowNewProject,
|
|
setEditingName,
|
|
setEditingSession,
|
|
setEditingSessionName,
|
|
setSearchFilter,
|
|
setDeleteConfirmation,
|
|
setSessionDeleteConfirmation,
|
|
setShowVersionModal,
|
|
} = useSidebarController({
|
|
projects,
|
|
selectedProject,
|
|
selectedSession,
|
|
isLoading,
|
|
isMobile,
|
|
t,
|
|
onRefresh,
|
|
onProjectSelect,
|
|
onSessionSelect,
|
|
onSessionDelete,
|
|
onProjectDelete,
|
|
setCurrentProject,
|
|
setSidebarVisible: (visible) => setPreference('sidebarVisible', visible),
|
|
sidebarVisible,
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (typeof document === 'undefined') {
|
|
return;
|
|
}
|
|
|
|
document.documentElement.classList.toggle('pwa-mode', isPWA);
|
|
document.body.classList.toggle('pwa-mode', isPWA);
|
|
}, [isPWA]);
|
|
|
|
const handleProjectCreated = () => {
|
|
if (window.refreshProjects) {
|
|
void window.refreshProjects();
|
|
return;
|
|
}
|
|
|
|
window.location.reload();
|
|
};
|
|
|
|
const projectListProps: SidebarProjectListProps = {
|
|
projects,
|
|
filteredProjects,
|
|
selectedProject,
|
|
selectedSession,
|
|
isLoading,
|
|
loadingProgress,
|
|
expandedProjects,
|
|
editingProject,
|
|
editingName,
|
|
loadingSessions,
|
|
initialSessionsLoaded,
|
|
currentTime,
|
|
editingSession,
|
|
editingSessionName,
|
|
deletingProjects,
|
|
tasksEnabled,
|
|
mcpServerStatus,
|
|
getProjectSessions,
|
|
isProjectStarred,
|
|
onEditingNameChange: setEditingName,
|
|
onToggleProject: toggleProject,
|
|
onProjectSelect: handleProjectSelect,
|
|
onToggleStarProject: toggleStarProject,
|
|
onStartEditingProject: startEditing,
|
|
onCancelEditingProject: cancelEditing,
|
|
onSaveProjectName: (projectName) => {
|
|
void saveProjectName(projectName);
|
|
},
|
|
onDeleteProject: requestProjectDelete,
|
|
onSessionSelect: handleSessionClick,
|
|
onDeleteSession: showDeleteSessionConfirmation,
|
|
onLoadMoreSessions: (project) => {
|
|
void loadMoreSessions(project);
|
|
},
|
|
onNewSession,
|
|
onEditingSessionNameChange: setEditingSessionName,
|
|
onStartEditingSession: (sessionId, initialName) => {
|
|
setEditingSession(sessionId);
|
|
setEditingSessionName(initialName);
|
|
},
|
|
onCancelEditingSession: () => {
|
|
setEditingSession(null);
|
|
setEditingSessionName('');
|
|
},
|
|
onSaveEditingSession: (projectName: string, sessionId: string, summary: string, provider: SessionProvider) => {
|
|
void updateSessionSummary(projectName, sessionId, summary, provider);
|
|
},
|
|
touchHandlerFactory: handleTouchClick,
|
|
t,
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<SidebarModals
|
|
projects={projects}
|
|
showSettings={showSettings}
|
|
settingsInitialTab={settingsInitialTab}
|
|
onCloseSettings={onCloseSettings}
|
|
showNewProject={showNewProject}
|
|
onCloseNewProject={() => setShowNewProject(false)}
|
|
onProjectCreated={handleProjectCreated}
|
|
deleteConfirmation={deleteConfirmation}
|
|
onCancelDeleteProject={() => setDeleteConfirmation(null)}
|
|
onConfirmDeleteProject={confirmDeleteProject}
|
|
sessionDeleteConfirmation={sessionDeleteConfirmation}
|
|
onCancelDeleteSession={() => setSessionDeleteConfirmation(null)}
|
|
onConfirmDeleteSession={confirmDeleteSession}
|
|
showVersionModal={showVersionModal}
|
|
onCloseVersionModal={() => setShowVersionModal(false)}
|
|
releaseInfo={releaseInfo}
|
|
currentVersion={currentVersion}
|
|
latestVersion={latestVersion}
|
|
installMode={installMode}
|
|
t={t}
|
|
/>
|
|
|
|
{isSidebarCollapsed ? (
|
|
<SidebarCollapsed
|
|
onExpand={handleExpandSidebar}
|
|
onShowSettings={onShowSettings}
|
|
updateAvailable={updateAvailable}
|
|
onShowVersionModal={() => setShowVersionModal(true)}
|
|
t={t}
|
|
/>
|
|
) : (
|
|
<>
|
|
<SidebarContent
|
|
isPWA={isPWA}
|
|
isMobile={isMobile}
|
|
isLoading={isLoading}
|
|
projects={projects}
|
|
searchFilter={searchFilter}
|
|
onSearchFilterChange={setSearchFilter}
|
|
onClearSearchFilter={() => setSearchFilter('')}
|
|
onRefresh={() => {
|
|
void refreshProjects();
|
|
}}
|
|
isRefreshing={isRefreshing}
|
|
onCreateProject={() => setShowNewProject(true)}
|
|
onCollapseSidebar={handleCollapseSidebar}
|
|
updateAvailable={updateAvailable}
|
|
releaseInfo={releaseInfo}
|
|
latestVersion={latestVersion}
|
|
onShowVersionModal={() => setShowVersionModal(true)}
|
|
onShowSettings={onShowSettings}
|
|
projectListProps={projectListProps}
|
|
t={t}
|
|
/>
|
|
</>
|
|
)}
|
|
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default Sidebar;
|