Skip to content

feat(coding-agent): auto-generate session title via /rename#837

Open
MikeeI wants to merge 1 commit intocan1357:mainfrom
MikeeI:feat/rename-auto-generate
Open

feat(coding-agent): auto-generate session title via /rename#837
MikeeI wants to merge 1 commit intocan1357:mainfrom
MikeeI:feat/rename-auto-generate

Conversation

@MikeeI
Copy link
Copy Markdown
Contributor

@MikeeI MikeeI commented Apr 27, 2026

Summary

/rename now accepts an optional argument. When called without one, it auto-generates a session title using the smol model (commit/smol role) based on recent conversation context. Manual /rename <title> continues to work as before.

Related: #658, #680

How it works

  1. /rename builds a compact context summary from the session:
    • Last 5 user + assistant (first line) message pairs
    • Deduplicated tool names used in the session
    • Compaction shortSummary if available
    • Project name (cwd basename)
  2. Sends the summary to the smol model via completeSimple with a unified Handlebars prompt
  3. Sets the generated title with source: "auto" — no accent coloring, no auto-title lock
  4. Manual /rename <title> sets source: "user" as before

Changes

File Change
title-system.md Unified Handlebars prompt with {{currentTitle}} and {{projectName}} template vars
title-generator.ts Extracted shared callTitleModel() helper; added regenerateSessionTitle() accepting a context summary string; cleanTitle() strips # heading markers
command-controller.ts /rename without arg builds context summary, shows loading spinner, generates title; same-title guard prevents unnecessary updates; extractMessageText() helper for content extraction
builtin-registry.ts /rename hint changed to [title] (optional); handler delegates to controller for both modes
types.ts / interactive-mode.ts handleRenameCommand(title?: string) signature
CHANGELOG.md Documented under [Unreleased]

Design decisions

  • source: "auto" for generated titles — no accent color, auto-title not locked. User can always override with /rename <title> (source: "user").
  • Assistant first-line only — full assistant messages are too verbose for title context. First non-heading line captures the response summary without token waste.
  • No per-message truncation — smol models have large context windows and we send maxTokens: 30 output. The context cost is negligible.
  • Compaction-aware — after compaction, messages may be sparse. The shortSummary from the last compaction entry fills the gap.
  • Same-title guard — if the generated title matches the current one (case-insensitive), shows "Title unchanged" instead of a redundant update.

  • bun check passes (pre-existing ajv version mismatch in validation.ts is unrelated)
  • Tested locally
  • CHANGELOG updated

…rgument

- /rename [title] now accepts optional argument
- empty /rename triggers smol model to generate title from recent messages
- unified title-system.md prompt with Handlebars (currentTitle, projectName)
- shared callTitleModel() helper eliminates code duplication
- shortSummary from compaction used as LLM context (not as title)
- same-title guard prevents unnecessary updates
- source set to 'auto' for generated titles (no accent color, no lock)
- loading spinner while LLM generates title
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 034e4f786c

ℹ️ 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".

Comment on lines +823 to 826
const source = wasManual ? "user" : "auto";
const stored = await this.ctx.sessionManager.setSessionName(title, source);
if (!stored) {
this.ctx.showError("Session name cannot be empty.");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Distinguish locked auto-title from empty title

This branch treats any setSessionName() failure as an empty title, but SessionManager.setSessionName also returns false when source === "auto" and the current title was set by the user. Because /rename without args now always uses source: "auto", a user who previously ran /rename <title> cannot regenerate a title with /rename; they get the misleading Session name cannot be empty. error instead. Handle the user-locked case explicitly (or treat this user-invoked regeneration as a user-source rename) so the command behaves correctly.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Autofix?

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