Skip to content

fix(tui): honor the auto_session_title experimental flag - #3169

Open
iosmanthus wants to merge 1 commit into
MoonshotAI:mainfrom
iosmanthus:fix/tui-auto-session-title
Open

fix(tui): honor the auto_session_title experimental flag#3169
iosmanthus wants to merge 1 commit into
MoonshotAI:mainfrom
iosmanthus:fix/tui-auto-session-title

Conversation

@iosmanthus

Copy link
Copy Markdown

Related Issue

Related to #2963 — this covers the AI-session-title part of that report. The two other
asks in it (hiding the third-party-provider OAuth error toast, and picking the node used
for titles) are out of scope here.

Note on process: #2963 has no maintainer /approve yet. Happy to wait for one, or to
split this into a separate bug issue first if you would rather have it filed that way —
the patch is small and can sit here in the meantime.

Problem

auto_session_title generation is on demand only: the engine never starts one by itself,
a client has to ask. kimi web asks every time a turn settles, with
generateSessionTitle(sessionId, { source: 'first_turn' }) and a 3-attempt-per-session
cap. The TUI never asks — there is no generateTitle / generateSessionTitle call site
anywhere under apps/kimi-code, only the kap-server route and the klient facade.

The TUI does list the flag in /experiments, description included:

 ❯ AI session titles  disabled
   id auto_session_title · default · KIMI_CODE_EXPERIMENTAL_AUTO_SESSION_TITLE
   Generate concise session titles from the conversation through the managed chat_title
   tool: clients auto-generate once the first turn completes and offer on-demand
   regeneration in the rename field.

So a CLI user reads "clients auto-generate once the first turn completes", turns the
switch on, and nothing happens. The session keeps the titleKind: 'replaceable' title
that applyPromptMetadataUpdate derived from the first prompt, which the terminal title
then truncates to 32 characters.

What changed

KimiTUI.handleTurnEnded now asks the engine for a title, with the same policy the web
client uses:

  • only after a turn that ended completed, so the first_turn excerpt has both a user
    prompt and an assistant reply (the web client asks on any settle; restricting it to
    completed turns keeps a cancelled first turn from naming the session)
  • source: 'first_turn'
  • at most 3 attempts per session, and none once a title lands
  • fire and forget: a rejected request leaves the prompt-derived title in place

Nothing downstream needed changing. The engine already refuses to overwrite a custom or
generated title, skips the platform call entirely without a managed OAuth login, and
publishes session.meta.updated, which handleSessionMetaChanged already turns into the
status-panel title and the terminal title.

Also adds the missing KIMI_CODE_EXPERIMENTAL_AUTO_SESSION_TITLE row to the env-var
reference (en + zh), which listed the other two KIMI_CODE_EXPERIMENTAL_* flags but not
this one.

Verification

  • 4 new tests in test/tui/kimi-tui-message-flow.test.ts: asks once on a completed turn
    and not again after a title lands, stays quiet while the flag is off, ignores a
    cancelled turn, gives up after 3 unproductive attempts. Reverting the kimi-tui.ts
    change fails 2 of them.
  • apps/kimi-code suite: 3136 passed, 2 skipped, no regressions.
  • tsc -p apps/kimi-code/tsconfig.json --noEmit clean; oxlint reports no new findings.
  • End to end against a real managed login: with
    KIMI_CODE_EXPERIMENTAL_AUTO_SESSION_TITLE=1, a fresh session's terminal title changed
    from the truncated prompt to TypeScript readonly 数组与普通数组区别说明, and its
    state.json went from titleKind: 'replaceable' to 'generated'.

Not included, happy to add if you want it in the same PR: the "on-demand regeneration in
the rename field" half of the flag description — a /title --regenerate (or bare /title
on an already-titled session) that calls generateSessionTitle({ force: true }).

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

The engine only generates an AI session title when a client asks for one.
`kimi web` asks each time a turn settles; the TUI never asked. So "AI
session titles" shows up in the TUI's /experiments panel, with a
description promising that "clients auto-generate once the first turn
completes", and turning it on there changes nothing — the session keeps
the truncated first prompt as its name.

Ask from `handleTurnEnded`, with the web client's policy: the `first_turn`
excerpt, at most three attempts per session, and no further attempts once a
title lands. Everything downstream is already wired — the engine refuses to
overwrite a renamed or already generated title, and the `session.meta.updated`
it publishes reaches the status panel and the terminal title through
`handleSessionMetaChanged`.

Also documents `KIMI_CODE_EXPERIMENTAL_AUTO_SESSION_TITLE`, which the env-var
reference was missing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 501841d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant