feat(cli): run kimi web and the TUI /web command in the foreground by default#1853
feat(cli): run kimi web and the TUI /web command in the foreground by default#1853wbxl2000 wants to merge 5 commits into
Conversation
… default kimi web and /web now start the server attached to the terminal (Ctrl+C stops it) instead of backgrounding a daemon; --background opts back into the daemon behavior. kimi server run is unchanged. A foreground kimi web reuses an already-running server instead of failing to bind, the /web handoff prints the same ready banner as kimi web (plus the session deep link), and the banner Stop hint adapts to the hosting mode.
🦋 Changeset detectedLatest commit: decab3a 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 |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2eba4ae8d5
ℹ️ 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".
| // and token in green under the status line so they can be copied before the | ||
| // terminal exits. Best-effort: an older/never-started server has no token | ||
| // file, so we fall back to the plain URL and skip the token line. | ||
| const token = tryResolveServerToken(getDataDir()); |
There was a problem hiding this comment.
Resolve the server token after first-time startup
When /web is run with a fresh KIMI_CODE_HOME, this lookup occurs before either ensureDaemon() or startServerForeground() creates server.token, so token remains undefined and the browser opens without the required #token= credential. This affects both /web --background and the new foreground default, leaving first-time users at the authentication gate after the TUI has exited; resolve the token after ensureDaemon() returns or inside the foreground onReady callback.
Useful? React with 👍 / 👎.
The token lookup had moved ahead of ensureDaemon()/startServerForeground() during the foreground-default refactor, so a first-time start (no server.token on disk yet) opened the browser without the #token= fragment and left the user at the auth gate. Resolve the token after the daemon is healthy, and inside the foreground ready hook.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cc9267cbbc
ℹ️ 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".
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "@moonshot-ai/kimi-code": minor | |||
There was a problem hiding this comment.
Obtain approval for the required major version bump
For scripts or launchers that invoke kimi web expecting it to return after starting a daemon, this change makes the command block until the foreground server is interrupted, so it is an incompatible behavior-semantic change. The root AGENTS.md explicitly requires such changes to use a major bump only after user confirmation; publishing this as minor would unexpectedly break those callers. Obtain that confirmation and change the bump to major, or preserve the previous default behavior.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Acknowledged that this is a behavior-semantics change — that is intentional and was explicitly discussed before opening the PR. The maintainers' decision for this release line is to keep the bump at minor while flagging the break prominently instead of withholding the change behind a major: the changeset entry is now prefixed with Breaking and spells out both the new default (foreground until Ctrl+C) and the mitigation for scripts/launchers (--background restores the previous immediate-return daemon behavior). Anyone calling kimi web non-interactively gets a documented, one-flag migration path. @codex
There was a problem hiding this comment.
To use Codex here, create a Codex account and connect to github.
…hangelog The bump stays minor, but the entry now calls out the behavior break and the --background mitigation for scripts that expect kimi web to return immediately.
…r CLI After an upgrade, an older still-running server is reused as-is. The lock's host_version is now surfaced: kimi web / server run print a version-mismatch line next to the reuse notice, /web shows the same as a status warning, and the docs plus changeset tell users a single kimi server kill switches them onto the new version.
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
Related Issue
No prior issue — the problem is explained below.
Problem
kimi weband the TUI/webcommand both started the Kimi server as a background daemon and returned/exited immediately. The desired default is the opposite: keep the server in the foreground (terminal stays attached, Ctrl+C stops it) and make background operation an explicit opt-in.What changed
kimi webdefaults to foreground. It shares the samebuildRunCommand/handleRunCommandimplementation askimi server run; a newdefaultForegroundoption flips only thewebalias, and a new--backgroundflag (registered only onweb) restores the old daemon behavior.kimi server runis untouched — still background by default with--foregroundto attach.kimi webreuses a running server. Binding the default port while a daemon already runs would fail, so the command probes the live lock first (via the samefindReusableDaemoncheckensureDaemonuses) and opens the browser against the existing server instead./webdefaults to foreground too. After confirmation it shuts the TUI down and hands the terminal to an in-process foreground server via a newexitForegroundTaskhook in the exit path (the old flow always ended inprocess.exit)./web --backgroundkeeps the previous daemon behavior. When a server is already running it is reused in both modes.Stop: Ctrl+C(including in the danger notice), while background/reused servers keepkimi server kill. The/webhandoff prints the same ready banner askimi webplus the session deep link.--background, the reuse path, and the TUI handoff; docs (EN/ZH) updated forkimi weband a previously missing/webentry was added. Ship decision: the bump staysminor, but the changeset entry is flagged Breaking —kimi webno longer returns immediately; scripts and launchers that depend on that must pass--background. Upgrade note: an already-running server is reused as-is across upgrades; when its recorded version differs from the CLI, a "Server version mismatch" line is printed (and shown as a/webstatus warning) —kimi server killonce restarts on the new version.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.