# Session Title Authority

CTM has one product-facing session name: `title`.

`label` is a legacy transport/storage alias that remains in `startup_tasks.label` and a few websocket payloads for compatibility. New application logic should read and write `title`; when a legacy `label` must be sent, it should mirror `title`.

## Precedence

1. Explicit user title wins.
2. A user-looking active `startup_tasks.label` is promoted into `ctm_sessions.title` with `user_renamed=1`.
3. AI-generated titles may fill `ctm_sessions.title` only when no user title exists.
4. Runtime generated titles such as `Codex: ~/repo`, `Claude Code: ~/repo`, `Shell: /path`, branch/worktree leaf names, and `Wall-E session` are not user titles.

## Why

Active sessions have two historical data paths:

- `startup_tasks.label`: crash-safe restore state for running tabs.
- `ctm_sessions.title`: durable catalog title used by recent sessions, review, and search.

If a user names a running Wall-E session `202612-trip`, that title may first live in `startup_tasks.label`. The auto-title job can later write an AI summary such as `Travel planning from cruise plan and conversation` into `ctm_sessions.title`. Without promotion, the browser sees two names for the same tab and different surfaces disagree.

The fix is architectural: promote the user runtime title into the durable title row and mark it user-owned. After that, existing `user_renamed` guards naturally prevent AI title generation from overwriting it.

## Implementation Rules

- Session create/rename should send `title`; `label` may be included only as a compatibility mirror.
- Rename writes must update both `ctm_sessions.title` and `startup_tasks.label`.
- Non-user title writers must call through `setSessionTitleNew`; it protects active user startup titles before accepting an AI title.
- Browser active-session chrome should prefer `meta.title`/user-looking runtime title before recent-session AI fields.
- Branch-only runtime labels are not user titles unless `userRenamed=1` is explicit. A worktree branch named `evaluation` should render as `Codex session` with an `evaluation` branch badge, not as a user title.
- New uses of `startup_tasks.label` should be commented as legacy schema compatibility.
