fix: remove project dependency from settings controller and onboarding

This commit is contained in:
Haileyesus
2026-04-11 12:15:01 +03:00
parent e2459cb0f8
commit cd16e0cfce
6 changed files with 17 additions and 60 deletions

View File

@@ -11,7 +11,6 @@ import {
createInitialProviderStatuses,
gitEmailPattern,
readErrorMessageFromResponse,
selectedProject,
} from './utils';
type OnboardingProps = {
@@ -279,7 +278,6 @@ export default function Onboarding({ onComplete }: OnboardingProps) {
isOpen={Boolean(activeLoginProvider)}
onClose={() => setActiveLoginProvider(null)}
provider={activeLoginProvider}
project={selectedProject}
onComplete={handleLoginComplete}
/>
)}

View File

@@ -1,17 +1,9 @@
import { IS_PLATFORM } from '../../../constants/config';
import type { CliProvider, ProviderStatusMap } from './types';
export const cliProviders: CliProvider[] = ['claude', 'cursor', 'codex', 'gemini'];
export const gitEmailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
export const selectedProject = {
name: 'default',
displayName: 'default',
fullPath: IS_PLATFORM ? '/workspace' : '',
path: IS_PLATFORM ? '/workspace' : '',
};
export const createInitialProviderStatuses = (): ProviderStatusMap => ({
claude: { authenticated: false, email: null, loading: true, error: null },
cursor: { authenticated: false, email: null, loading: true, error: null },

View File

@@ -1,21 +1,12 @@
import { ExternalLink, KeyRound, X } from 'lucide-react';
import StandaloneShell from '../../standalone-shell/view/StandaloneShell';
import { IS_PLATFORM } from '../../../constants/config';
import { DEFAULT_PROJECT_FOR_EMPTY_SHELL, IS_PLATFORM } from '../../../constants/config';
import type { CliProvider } from '../types';
type LoginModalProject = {
name?: string;
displayName?: string;
fullPath?: string;
path?: string;
[key: string]: unknown;
};
type ProviderLoginModalProps = {
isOpen: boolean;
onClose: () => void;
provider?: CliProvider;
project?: LoginModalProject | null;
onComplete?: (exitCode: number) => void;
customCommand?: string;
isAuthenticated?: boolean;
@@ -56,23 +47,10 @@ const getProviderTitle = (provider: CliProvider) => {
return 'Gemini CLI Configuration';
};
const normalizeProject = (project?: LoginModalProject | null) => {
const normalizedName = project?.name || 'default';
const normalizedFullPath = project?.fullPath ?? project?.path ?? (IS_PLATFORM ? '/workspace' : '');
return {
name: normalizedName,
displayName: project?.displayName || normalizedName,
fullPath: normalizedFullPath,
path: project?.path ?? normalizedFullPath,
};
};
export default function ProviderLoginModal({
isOpen,
onClose,
provider = 'claude',
project = null,
onComplete,
customCommand,
isAuthenticated = false,
@@ -83,7 +61,6 @@ export default function ProviderLoginModal({
const command = getProviderCommand({ provider, customCommand, isAuthenticated });
const title = getProviderTitle(provider);
const shellProject = normalizeProject(project);
const handleComplete = (exitCode: number) => {
onComplete?.(exitCode);
@@ -158,7 +135,7 @@ export default function ProviderLoginModal({
</button>
</div>
) : (
<StandaloneShell project={shellProject} command={command} onComplete={handleComplete} minimal={true} />
<StandaloneShell project={DEFAULT_PROJECT_FOR_EMPTY_SHELL} command={command} onComplete={handleComplete} minimal={true} />
)}
</div>
</div>

View File

@@ -23,7 +23,6 @@ import type {
NotificationPreferencesState,
ProjectSortOrder,
SettingsMainTab,
SettingsProject,
} from '../types/types';
type ThemeContextValue = {
@@ -34,7 +33,6 @@ type ThemeContextValue = {
type UseSettingsControllerArgs = {
isOpen: boolean;
initialTab: string;
projects: SettingsProject[];
onClose: () => void;
};
@@ -166,20 +164,6 @@ const mapCliServersToMcpServers = (servers: McpCliServer[] = []): McpServer[] =>
}))
);
const getDefaultProject = (projects: SettingsProject[]): SettingsProject => {
if (projects.length > 0) {
return projects[0];
}
const cwd = typeof process !== 'undefined' && process.cwd ? process.cwd() : '';
return {
name: 'default',
displayName: 'default',
fullPath: cwd,
path: cwd,
};
};
const toResponseJson = async <T>(response: Response): Promise<T> => response.json() as Promise<T>;
const createEmptyClaudePermissions = (): ClaudePermissionsState => ({
@@ -204,7 +188,7 @@ const createDefaultNotificationPreferences = (): NotificationPreferencesState =>
},
});
export function useSettingsController({ isOpen, initialTab, projects, onClose }: UseSettingsControllerArgs) {
export function useSettingsController({ isOpen, initialTab }: UseSettingsControllerArgs) {
const { isDarkMode, toggleDarkMode } = useTheme() as ThemeContextValue;
const closeTimerRef = useRef<number | null>(null);
@@ -242,7 +226,6 @@ export function useSettingsController({ isOpen, initialTab, projects, onClose }:
const [showLoginModal, setShowLoginModal] = useState(false);
const [loginProvider, setLoginProvider] = useState<ActiveLoginProvider>('');
const [selectedProject, setSelectedProject] = useState<SettingsProject | null>(null);
const [claudeAuthStatus, setClaudeAuthStatus] = useState<AuthStatus>(DEFAULT_AUTH_STATUS);
const [cursorAuthStatus, setCursorAuthStatus] = useState<AuthStatus>(DEFAULT_AUTH_STATUS);
@@ -724,9 +707,8 @@ export function useSettingsController({ isOpen, initialTab, projects, onClose }:
const openLoginForProvider = useCallback((provider: AgentProvider) => {
setLoginProvider(provider);
setSelectedProject(getDefaultProject(projects));
setShowLoginModal(true);
}, [projects]);
}, []);
const handleLoginComplete = useCallback((exitCode: number) => {
if (exitCode !== 0 || !loginProvider) {
@@ -945,7 +927,6 @@ export function useSettingsController({ isOpen, initialTab, projects, onClose }:
showLoginModal,
setShowLoginModal,
loginProvider,
selectedProject,
handleLoginComplete,
};
}

View File

@@ -66,12 +66,10 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'agents' }: Set
showLoginModal,
setShowLoginModal,
loginProvider,
selectedProject,
handleLoginComplete,
} = useSettingsController({
isOpen,
initialTab,
projects,
onClose,
});
@@ -219,7 +217,6 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'agents' }: Set
isOpen={showLoginModal}
onClose={() => setShowLoginModal(false)}
provider={loginProvider || 'claude'}
project={selectedProject}
onComplete={handleLoginComplete}
isAuthenticated={isAuthenticated}
/>

View File

@@ -2,4 +2,16 @@
* Environment Flag: Is Platform
* Indicates if the app is running in Platform mode (hosted) or OSS mode (self-hosted)
*/
export const IS_PLATFORM = import.meta.env.VITE_IS_PLATFORM === 'true';
export const IS_PLATFORM = import.meta.env.VITE_IS_PLATFORM === 'true';
/**
* For empty shell instances where no project is provided,
* we use a default project object to ensure the shell can still function.
* This prevents errors related to missing project data.
*/
export const DEFAULT_PROJECT_FOR_EMPTY_SHELL = {
name: 'default',
displayName: 'default',
fullPath: IS_PLATFORM ? '/workspace' : '',
path: IS_PLATFORM ? '/workspace' : '',
};