feat(tui): include session name in the terminal titlebar (#43188)
The terminal/console titlebar was composed from status marker + model + cwd only; the session's (auto-)title never appeared, even though the TUI already knows it. Change the format to `<marker> <session name> · <model> · <cwd>`, with the session name and cwd each omitted when absent so single-segment titles stay clean. The current session's live title is pulled from the existing session.active_list poll (which already carries each session's current flag and title), so there's no extra round-trip; UiState gains a sessionTitle field updated only when it actually changes, preserving the existing idle-flicker guard. Extract the join logic into a pure composeTabTitle() helper in domain/paths and cover its edge cases (name omitted, cwd omitted, whitespace-only name, marker-only fallback, truncation, boundary length) in paths.test.ts.
This commit is contained in:
@@ -14,3 +14,27 @@ export const fmtCwdBranch = (cwd: string, branch: null | string, max = 40) => {
|
||||
|
||||
return `${shortCwd(cwd, Math.max(8, max - tag.length))}${tag}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Compose the terminal titlebar string:
|
||||
* `<marker> <session name> · <model> · <cwd>`
|
||||
*
|
||||
* The session name and cwd are each omitted when empty, and a long session
|
||||
* name is truncated. The marker is always glued to the first present segment
|
||||
* with a plain space (not a ` · ` separator). When no model is known yet the
|
||||
* caller should fall back to a plain brand string instead of calling this.
|
||||
*/
|
||||
export const composeTabTitle = (
|
||||
marker: string,
|
||||
sessionName: string,
|
||||
model: string,
|
||||
cwd: string,
|
||||
maxName = 28
|
||||
): string => {
|
||||
const name = sessionName.trim()
|
||||
const shortName = name.length > maxName ? `${name.slice(0, maxName - 1)}…` : name
|
||||
|
||||
const segments = [shortName, model, cwd].filter(Boolean)
|
||||
|
||||
return segments.length ? `${marker} ${segments.join(' · ')}` : marker
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user