-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Expand file tree
/
Copy pathinitializer.ts
More file actions
70 lines (63 loc) · 1.89 KB
/
Copy pathinitializer.ts
File metadata and controls
70 lines (63 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {
IdeClient,
IdeConnectionEvent,
IdeConnectionType,
logIdeConnection,
type Config,
StartSessionEvent,
logCliConfiguration,
startupProfiler,
} from '@google/gemini-cli-core';
import { type LoadedSettings } from '../config/settings.js';
import { performInitialAuth } from './auth.js';
import { validateTheme } from './theme.js';
import type { AccountSuspensionInfo } from '../ui/contexts/UIStateContext.js';
export interface InitializationResult {
authError: string | null;
accountSuspensionInfo: AccountSuspensionInfo | null;
themeError: string | null;
shouldOpenAuthDialog: boolean;
geminiMdFileCount: number;
}
/**
* Orchestrates the application's startup initialization.
* This runs BEFORE the React UI is rendered.
* @param config The application config.
* @param settings The loaded application settings.
* @returns The results of the initialization.
*/
export async function initializeApp(
config: Config,
settings: LoadedSettings,
): Promise<InitializationResult> {
const authHandle = startupProfiler.start('authenticate');
const { authError, accountSuspensionInfo } = await performInitialAuth(
config,
settings.merged.security.auth.selectedType,
);
authHandle?.end();
const themeError = validateTheme(settings);
const shouldOpenAuthDialog =
settings.merged.security.auth.selectedType === undefined || !!authError;
logCliConfiguration(
config,
new StartSessionEvent(config, config.getToolRegistry()),
);
if (config.getIdeMode()) {
const ideClient = await IdeClient.getInstance();
await ideClient.connect();
logIdeConnection(config, new IdeConnectionEvent(IdeConnectionType.START));
}
return {
authError,
accountSuspensionInfo,
themeError,
shouldOpenAuthDialog,
geminiMdFileCount: config.getGeminiMdFileCount(),
};
}