Skip to content

Commit 4d37c93

Browse files
RyanLee-Devclaude
andcommitted
feat: show quota dashboard after successful auth login
Gives immediate feedback on account status after first login, matching the behavior of running `mmx` with no arguments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 551f020 commit 4d37c93

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/commands/auth/login.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { saveCredentials } from '../../auth/credentials';
55
import { startBrowserFlow, startDeviceCodeFlow } from '../../auth/oauth';
66
import { requestJson } from '../../client/http';
77
import { quotaEndpoint } from '../../client/endpoints';
8+
import { renderQuotaTable } from '../../output/quota-table';
89

910
import { getConfigPath } from '../../config/paths';
1011
import { readConfigFile, writeConfigFile } from '../../config/loader';
@@ -13,7 +14,21 @@ import { maskToken } from '../../utils/token';
1314
import type { Config } from '../../config/schema';
1415
import type { GlobalFlags } from '../../types/flags';
1516
import 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

1833
export 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

Comments
 (0)