forked from CodebuffAI/codebuff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit-app.ts
More file actions
37 lines (32 loc) · 1.2 KB
/
Copy pathinit-app.ts
File metadata and controls
37 lines (32 loc) · 1.2 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
import {
getClaudeOAuthCredentials,
getValidClaudeOAuthCredentials,
} from '@codebuff/sdk'
import { enableMapSet } from 'immer'
import { initializeThemeStore } from '../hooks/use-theme'
import { setProjectRoot } from '../project-files'
import { initTimestampFormatter } from '../utils/helpers'
import { enableManualThemeRefresh } from '../utils/theme-system'
import { initializeDirenv } from './init-direnv'
export async function initializeApp(params: { cwd?: string }): Promise<void> {
if (params.cwd) {
process.chdir(params.cwd)
}
const baseCwd = process.cwd()
setProjectRoot(baseCwd)
// Initialize direnv environment before anything else
initializeDirenv()
enableMapSet()
initializeThemeStore()
enableManualThemeRefresh()
initTimestampFormatter()
// Refresh Claude OAuth credentials in the background if they exist
// This ensures the subscription status is up-to-date on startup
const claudeCredentials = getClaudeOAuthCredentials()
if (claudeCredentials) {
getValidClaudeOAuthCredentials().catch((error) => {
// Log refresh errors at debug level - will be retried on next API call
console.debug('Failed to refresh Claude OAuth credentials:', error)
})
}
}