feat(cli): add custom session id startup flag#924
Conversation
🦋 Changeset detectedLatest commit: 927ec4b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 927ec4ba70
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| session = await this.harness.createSession({ | ||
| ...createSessionOptions, | ||
| id: startup.sessionIdFlag, | ||
| }); |
There was a problem hiding this comment.
Preserve custom session IDs after OAuth login
When kimi --session-id foo is started with a missing or expired OAuth login, this initial createSession call can throw isOAuthLoginRequiredError and init() enters the login-required state. After the user completes /login, AuthFlowController.activateModelAfterLogin() creates the session without passing startup.sessionIdFlag, so the eventual session gets a generated id instead of the user-specified foo. This breaks the create-with-stable-id path specifically for first-time/expired-login startup; carry the pending custom id into the post-login create path.
Useful? React with 👍 / 👎.
Summary
Fixes #820.
Adds a new
--session-id <id>startup flag for callers that want a stable session id:--sessionresume-only--session_idalias for compatibility with the issue requestAlso updates EN/ZH docs, CLI validation, tests, and the changeset.
Validation
pnpm --filter @moonshot-ai/kimi-code exec vitest run test/cli/options.test.ts test/cli/session-flag-picker.test.ts test/cli/run-prompt.test.ts test/tui/kimi-tui-startup.test.tspnpm --filter @moonshot-ai/kimi-code exec vitest runpnpm --filter @moonshot-ai/kimi-code run typecheckpnpm exec oxlint --type-aware apps/kimi-code/src/cli/commands.ts apps/kimi-code/src/cli/options.ts apps/kimi-code/src/cli/run-prompt.ts apps/kimi-code/src/main.ts apps/kimi-code/src/tui/kimi-tui.ts apps/kimi-code/src/tui/types.ts apps/kimi-code/test/cli/options.test.ts apps/kimi-code/test/cli/run-prompt.test.ts apps/kimi-code/test/cli/session-flag-picker.test.ts apps/kimi-code/test/tui/kimi-tui-startup.test.ts --quietpnpm --filter @moonshot-ai/kimi-code run buildgit diff --checkChecklist
AI Assistance Disclosure
I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.