mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 06:04:05 +00:00
feat(coding-agent): add session naming via /name command and extension API
- Add SessionInfoEntry type for session metadata - Add /name <name> command to set session display name - Add pi.setSessionName() and pi.getSessionName() extension API - Session selector shows name (in warning color) instead of first message when set - Session name included in fuzzy search - /session command displays name when set closes #650
This commit is contained in:
parent
7a41975e9e
commit
8f95a13e07
14 changed files with 173 additions and 5 deletions
|
|
@ -130,7 +130,7 @@ class SessionList implements Component {
|
|||
this.filteredSessions = fuzzyFilter(
|
||||
this.allSessions,
|
||||
query,
|
||||
(session) => `${session.id} ${session.allMessagesText} ${session.cwd}`,
|
||||
(session) => `${session.id} ${session.name ?? ""} ${session.allMessagesText} ${session.cwd}`,
|
||||
);
|
||||
this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredSessions.length - 1));
|
||||
}
|
||||
|
|
@ -167,14 +167,24 @@ class SessionList implements Component {
|
|||
const session = this.filteredSessions[i];
|
||||
const isSelected = i === this.selectedIndex;
|
||||
|
||||
// Normalize first message to single line
|
||||
const normalizedMessage = session.firstMessage.replace(/\n/g, " ").trim();
|
||||
// Use session name if set, otherwise first message
|
||||
const hasName = !!session.name;
|
||||
const displayText = session.name ?? session.firstMessage;
|
||||
const normalizedMessage = displayText.replace(/\n/g, " ").trim();
|
||||
|
||||
// First line: cursor + message (truncate to visible width)
|
||||
// Use warning color for custom names to distinguish from first message
|
||||
const cursor = isSelected ? theme.fg("accent", "› ") : " ";
|
||||
const maxMsgWidth = width - 2; // Account for cursor (2 visible chars)
|
||||
const truncatedMsg = truncateToWidth(normalizedMessage, maxMsgWidth, "...");
|
||||
const messageLine = cursor + (isSelected ? theme.bold(truncatedMsg) : truncatedMsg);
|
||||
let styledMsg = truncatedMsg;
|
||||
if (hasName) {
|
||||
styledMsg = theme.fg("warning", truncatedMsg);
|
||||
}
|
||||
if (isSelected) {
|
||||
styledMsg = theme.bold(styledMsg);
|
||||
}
|
||||
const messageLine = cursor + styledMsg;
|
||||
|
||||
// Second line: metadata (dimmed) - also truncate for safety
|
||||
const modified = formatSessionDate(session.modified);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue