@@ -5,6 +5,7 @@ import { saveCredentials } from '../../auth/credentials';
55import { startBrowserFlow , startDeviceCodeFlow } from '../../auth/oauth' ;
66import { requestJson } from '../../client/http' ;
77import { quotaEndpoint } from '../../client/endpoints' ;
8+ import { renderQuotaTable } from '../../output/quota-table' ;
89
910import { getConfigPath } from '../../config/paths' ;
1011import { readConfigFile , writeConfigFile } from '../../config/loader' ;
@@ -13,7 +14,21 @@ import { maskToken } from '../../utils/token';
1314import type { Config } from '../../config/schema' ;
1415import type { GlobalFlags } from '../../types/flags' ;
1516import type { CredentialFile } from '../../auth/types' ;
16- import type { QuotaResponse } from '../../types/api' ;
17+ import type { QuotaResponse , QuotaModelRemain } from '../../types/api' ;
18+
19+ interface QuotaApiResponse {
20+ model_remains : QuotaModelRemain [ ] ;
21+ }
22+
23+ async function showQuotaAfterLogin ( config : Config ) : Promise < void > {
24+ try {
25+ const url = quotaEndpoint ( config . baseUrl ) ;
26+ const response = await requestJson < QuotaApiResponse > ( config , { url } ) ;
27+ renderQuotaTable ( response . model_remains || [ ] , config ) ;
28+ } catch {
29+ // Non-fatal — login succeeded, quota display is best-effort
30+ }
31+ }
1732
1833export default defineCommand ( {
1934 name : 'auth login' ,
@@ -83,6 +98,8 @@ export default defineCommand({
8398 existing . api_key = key ;
8499 await writeConfigFile ( existing ) ;
85100 process . stderr . write ( `API key saved to ${ getConfigPath ( ) } \n` ) ;
101+
102+ await showQuotaAfterLogin ( { ...config , apiKey : key } ) ;
86103 } else {
87104 console . log ( 'Would validate and save API key.' ) ;
88105 }
@@ -112,5 +129,7 @@ export default defineCommand({
112129 await saveCredentials ( creds ) ;
113130 process . stderr . write ( 'Logged in successfully.\n' ) ;
114131 process . stderr . write ( 'Credentials saved to ~/.mmx/credentials.json\n' ) ;
132+
133+ await showQuotaAfterLogin ( { ...config , apiKey : creds . access_token } ) ;
115134 } ,
116135} ) ;
0 commit comments