From 4c387808eddcb285d2f587e92feba7c8d1315c32 Mon Sep 17 00:00:00 2001 From: Haileyesus Date: Thu, 12 Feb 2026 22:07:18 +0300 Subject: [PATCH] refactor(SidebarModals): move normalizeProjectForSettings into utils file --- src/components/sidebar/types/types.ts | 2 ++ src/components/sidebar/utils/utils.ts | 23 ++++++++++++++++ .../view/subcomponents/SidebarModals.tsx | 27 ++++++++++++++++--- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/components/sidebar/types/types.ts b/src/components/sidebar/types/types.ts index fcf563d..b2fa98d 100644 --- a/src/components/sidebar/types/types.ts +++ b/src/components/sidebar/types/types.ts @@ -58,3 +58,5 @@ export type MCPServerStatus = { export type TouchHandlerFactory = ( callback: () => void, ) => (event: React.TouchEvent) => void; + +export type SettingsProject = Pick; diff --git a/src/components/sidebar/utils/utils.ts b/src/components/sidebar/utils/utils.ts index 348d78f..62c9ce3 100644 --- a/src/components/sidebar/utils/utils.ts +++ b/src/components/sidebar/utils/utils.ts @@ -3,6 +3,7 @@ import type { Project } from '../../../types/app'; import type { AdditionalSessionsByProject, ProjectSortOrder, + SettingsProject, SessionViewModel, SessionWithProvider, } from '../types/types'; @@ -198,3 +199,25 @@ export const getTaskIndicatorStatus = ( return 'not-configured'; }; + +export const normalizeProjectForSettings = (project: Project): SettingsProject => { + const fallbackPath = + typeof project.fullPath === 'string' && project.fullPath.length > 0 + ? project.fullPath + : typeof project.path === 'string' + ? project.path + : ''; + + return { + name: project.name, + displayName: + typeof project.displayName === 'string' && project.displayName.trim().length > 0 + ? project.displayName + : project.name, + fullPath: fallbackPath, + path: + typeof project.path === 'string' && project.path.length > 0 + ? project.path + : fallbackPath, + }; +}; diff --git a/src/components/sidebar/view/subcomponents/SidebarModals.tsx b/src/components/sidebar/view/subcomponents/SidebarModals.tsx index b51060f..312f389 100644 --- a/src/components/sidebar/view/subcomponents/SidebarModals.tsx +++ b/src/components/sidebar/view/subcomponents/SidebarModals.tsx @@ -1,3 +1,4 @@ +import { useMemo } from 'react'; import ReactDOM from 'react-dom'; import { AlertTriangle, Trash2 } from 'lucide-react'; import type { TFunction } from 'i18next'; @@ -7,7 +8,8 @@ import Settings from '../../../Settings'; import VersionUpgradeModal from '../../../modals/VersionUpgradeModal'; import type { Project } from '../../../../types/app'; import type { ReleaseInfo } from '../../../../types/sharedTypes'; -import type { DeleteProjectConfirmation, SessionDeleteConfirmation } from '../../types/types'; +import { normalizeProjectForSettings } from '../../utils/utils'; +import type { DeleteProjectConfirmation, SessionDeleteConfirmation, SettingsProject } from '../../types/types'; type SidebarModalsProps = { projects: Project[]; @@ -31,6 +33,19 @@ type SidebarModalsProps = { t: TFunction; }; +type TypedSettingsProps = { + isOpen: boolean; + onClose: () => void; + projects: SettingsProject[]; + initialTab: string; +}; + +const SettingsComponent = Settings as (props: TypedSettingsProps) => JSX.Element; + +function TypedSettings(props: TypedSettingsProps) { + return ; +} + export default function SidebarModals({ projects, showSettings, @@ -52,6 +67,12 @@ export default function SidebarModals({ latestVersion, t, }: SidebarModalsProps) { + // Settings expects project identity/path fields to be present for dropdown labels and local-scope MCP config. + const settingsProjects = useMemo( + () => projects.map(normalizeProjectForSettings), + [projects], + ); + return ( <> {showNewProject && @@ -63,10 +84,10 @@ export default function SidebarModals({ document.body, )} -