Skip to content

Commit ba82db1

Browse files
kapelamekapelame
authored andcommitted
fix(auth): drop MiniMaxCN label, show full dashboard after login
- Both OAuth options labelled 'MiniMax', region in parens - After any login (OAuth or API key), print the same dashboard as bare 'mmx' (help panel + quota table) so the user lands on a useful view instead of returning to a blank shell prompt
1 parent a8c7dee commit ba82db1

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

src/auth/setup.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ import { saveCredentials, loadCredentials } from './credentials';
1111
interface AuthChoice {
1212
value: 'oauth-global' | 'oauth-cn' | 'api-key';
1313
label: string;
14-
hint: string;
1514
}
1615

1716
const AUTH_CHOICES: AuthChoice[] = [
18-
{ value: 'oauth-global', label: 'MiniMax', hint: 'OAuth login (Global)' },
19-
{ value: 'oauth-cn', label: 'MiniMaxCN', hint: 'OAuth login (China)' },
20-
{ value: 'api-key', label: 'API key', hint: 'Paste sk-cp-... or sk-...' },
17+
{ value: 'oauth-global', label: 'MiniMax (OAuth login, Global)' },
18+
{ value: 'oauth-cn', label: 'MiniMax (OAuth login, China)' },
19+
{ value: 'api-key', label: 'API key' },
2120
];
2221

2322
export async function ensureAuth(config: Config): Promise<void> {
@@ -61,7 +60,7 @@ export async function pickAuthMethod(): Promise<AuthChoice['value']> {
6160
const { select, isCancel } = await import('@clack/prompts');
6261
const value = await select({
6362
message: 'How would you like to authenticate?',
64-
options: AUTH_CHOICES.map(c => ({ value: c.value, label: `${c.label} · ${c.hint}` })),
63+
options: AUTH_CHOICES.map(c => ({ value: c.value, label: c.label })),
6564
});
6665
if (isCancel(value)) throw new CLIError('Authentication cancelled.', ExitCode.AUTH);
6766
return value as AuthChoice['value'];

src/commands/auth/login.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { readConfigFile, writeConfigFile } from '../../config/loader';
1111
import { isInteractive } from '../../utils/env';
1212
import { maskToken } from '../../utils/token';
1313
import type { Config, Region } from '../../config/schema';
14+
import { REGIONS } from '../../config/schema';
1415
import type { GlobalFlags } from '../../types/flags';
1516
import type { QuotaResponse, QuotaModelRemain } from '../../types/api';
1617

@@ -28,6 +29,17 @@ async function showQuotaAfterLogin(config: Config): Promise<void> {
2829
}
2930
}
3031

32+
/**
33+
* Mirrors the `mmx` (no-args) dashboard: prints the help panel
34+
* followed by the quota snapshot. Used right after a successful
35+
* login so the user lands somewhere useful instead of an empty prompt.
36+
*/
37+
async function showDashboardAfterLogin(config: Config): Promise<void> {
38+
const { registry } = await import('../../registry');
39+
registry.printHelp([], process.stderr, config.region);
40+
await showQuotaAfterLogin(config);
41+
}
42+
3143
export default defineCommand({
3244
name: 'auth login',
3345
description: 'Authenticate via OAuth or API key',
@@ -92,9 +104,14 @@ export default defineCommand({
92104
const region: Region = (flags.region as Region) || (choice === 'oauth-cn' ? 'cn' : 'global');
93105
await runOAuthLogin(region);
94106

95-
// Best-effort quota snapshot — derive an effective baseUrl from the OAuth region.
96-
const cfg: Config = { ...config, region, baseUrl: config.baseUrl };
97-
await showQuotaAfterLogin(cfg);
107+
// Reload config so the OAuth subobject (and its resource_url) are picked up.
108+
const fresh = readConfigFile();
109+
const cfg: Config = {
110+
...config,
111+
region,
112+
baseUrl: fresh.oauth?.resource_url || REGIONS[region],
113+
};
114+
await showDashboardAfterLogin(cfg);
98115
},
99116
});
100117

@@ -122,5 +139,5 @@ async function loginWithApiKey(config: Config, key: string): Promise<void> {
122139
await writeConfigFile(existing);
123140
process.stderr.write(`API key saved to ${getConfigPath()}\n`);
124141

125-
await showQuotaAfterLogin({ ...config, apiKey: key });
142+
await showDashboardAfterLogin({ ...config, apiKey: key });
126143
}

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async function main() {
7575
await quotaCmd.execute(config, flags);
7676
} else {
7777
process.stderr.write(' Not logged in.\n');
78-
process.stderr.write(' mmx auth login Choose MiniMax / MiniMaxCN OAuth or paste an API key\n');
78+
process.stderr.write(' mmx auth login Choose MiniMax OAuth (Global/China) or paste an API key\n');
7979
process.stderr.write(' mmx auth login --api-key Save an API key directly\n\n');
8080
}
8181
process.exit(0);

0 commit comments

Comments
 (0)