diff --git a/src/web-server/file-watcher.ts b/src/web-server/file-watcher.ts index a57bce39..90de9027 100644 --- a/src/web-server/file-watcher.ts +++ b/src/web-server/file-watcher.ts @@ -22,7 +22,8 @@ export function createFileWatcher(onChange: FileChangeCallback): FSWatcher { const watcher = chokidar.watch( [ - path.join(ccsDir, 'config.json'), + path.join(ccsDir, 'config.json'), // Legacy config + path.join(ccsDir, 'config.yaml'), // Unified config path.join(ccsDir, '*.settings.json'), path.join(ccsDir, 'profiles.json'), path.join(ccsDir, 'cliproxy', 'sessions.json'), // Proxy session tracking @@ -41,7 +42,7 @@ export function createFileWatcher(onChange: FileChangeCallback): FSWatcher { const basename = path.basename(filePath); let type: FileChangeEvent['type']; - if (basename === 'config.json') { + if (basename === 'config.json' || basename === 'config.yaml') { type = 'config-changed'; } else if (basename === 'profiles.json') { type = 'profiles-changed'; diff --git a/src/web-server/overview-routes.ts b/src/web-server/overview-routes.ts index 0ddaf1da..b2cd6525 100644 --- a/src/web-server/overview-routes.ts +++ b/src/web-server/overview-routes.ts @@ -5,12 +5,11 @@ */ import { Router, Request, Response } from 'express'; -import * as fs from 'fs'; -import * as path from 'path'; -import { getCcsDir, loadConfig } from '../utils/config-manager'; +import { loadConfig } from '../utils/config-manager'; import { runHealthChecks } from './health-service'; import { getAllAuthStatus, initializeAccounts } from '../cliproxy/auth-handler'; import { getVersion } from '../utils/version'; +import ProfileRegistry from '../auth/profile-registry'; export const overviewRoutes = Router(); @@ -64,12 +63,16 @@ overviewRoutes.get('/', async (_req: Request, res: Response) => { function getAccountCount(): number { try { - const profilesPath = path.join(getCcsDir(), 'profiles.json'); + const registry = new ProfileRegistry(); - if (!fs.existsSync(profilesPath)) return 0; + // Merge legacy (profiles.json) and unified (config.yaml) accounts + const legacyProfiles = registry.getAllProfiles(); + const unifiedAccounts = registry.getAllAccountsUnified(); - const data = JSON.parse(fs.readFileSync(profilesPath, 'utf8')); - return Object.keys(data.profiles || {}).length; + // Count unique accounts (unified takes precedence for duplicates) + const allNames = new Set([...Object.keys(legacyProfiles), ...Object.keys(unifiedAccounts)]); + + return allNames.size; } catch { return 0; }