@@ -23,6 +23,7 @@ import {
2323 listPromptHistory,
2424 listSessions,
2525 loadMessages,
26+ type SessionListEntry,
2627 undoLastTurn,
2728 } from "../session.ts";
2829 import { updateSettings } from "../settings.ts";
@@ -135,6 +136,80 @@ export function formatPromptHistoryPreview(text: string): string {
135136 return text.replace(/\s+/g, " ").trim();
136137 }
137138
139+const HISTORY_PREVIEW_MAX_CHARS = 32;
140+const HISTORY_CWD_MAX_CHARS = 18;
141+const SESSION_PREVIEW_MAX_CHARS = 27;
142+const SESSION_MODEL_MAX_CHARS = 17;
143+
144+function truncateTrailingText(text: string, maxChars: number): string {
145+ if (text.length <= maxChars) {
146+ return text;
147+ }
148+ if (maxChars <= 1) {
149+ return "…";
150+ }
151+ return `${text.slice(0, maxChars - 1)}…`;
152+}
153+
154+function truncateLeadingText(text: string, maxChars: number): string {
155+ if (text.length <= maxChars) {
156+ return text;
157+ }
158+ if (maxChars <= 1) {
159+ return "…";
160+ }
161+ return `…${text.slice(text.length - (maxChars - 1))}`;
162+}
163+
164+/**
165+ * Format a prompt-history row for the Select overlay.
166+ *
167+ * @param text - Raw prompt text.
168+ * @param cwd - Prompt working directory.
169+ * @param date - Relative date label.
170+ * @returns A single-line prompt-history label with stable metadata suffixes.
171+ */
172+export function formatPromptHistoryLabel(
173+ text: string,
174+ cwd: string,
175+ date: string,
176+): string {
177+ const preview = truncateTrailingText(
178+ formatPromptHistoryPreview(text),
179+ HISTORY_PREVIEW_MAX_CHARS,
180+ );
181+ const displayCwd = truncateLeadingText(
182+ abbreviatePath(cwd),
183+ HISTORY_CWD_MAX_CHARS,
184+ );
185+ return `${preview} · ${displayCwd} · ${date}`;
186+}
187+
188+/**
189+ * Format a session-picker row for the Select overlay.
190+ *
191+ * @param session - Session metadata and first-user preview.
192+ * @param date - Relative date label.
193+ * @param isCurrent - Whether this is the active session.
194+ * @returns A single-line session label with readable preview and metadata.
195+ */
196+export function formatSessionLabel(
197+ session: Pick<SessionListEntry, "model" | "firstUserPreview">,
198+ date: string,
199+ isCurrent: boolean,
200+): string {
201+ const preview = truncateTrailingText(
202+ session.firstUserPreview ?? "No messages yet",
203+ SESSION_PREVIEW_MAX_CHARS,
204+ );
205+ const model = truncateTrailingText(
206+ session.model ?? "no model",
207+ SESSION_MODEL_MAX_CHARS,
208+ );
209+ const current = isCurrent ? " · current" : "";
210+ return `${preview} · ${model} · ${date}${current}`;
211+}
212+
138213 /** Lightweight item shape used by the shared Select-overlay helper. */
139214 interface OverlayItem {
140215 /** Label shown in the Select list. */
@@ -201,10 +276,9 @@ export function createCommandController(
201276 }
202277
203278 const items = history.map((entry) => {
204- const preview = formatPromptHistoryPreview(entry.text);
205279 const date = formatRelativeDate(new Date(entry.createdAt));
206280 return {
207- label: `${preview} · ${abbreviatePath(entry.cwd)} · ${date}`,
281+ label: formatPromptHistoryLabel(entry.text, entry.cwd, date),
208282 value: String(entry.id),
209283 filterText: `${entry.text} ${entry.cwd}`,
210284 };
@@ -293,11 +367,14 @@ export function createCommandController(
293367 const items = sessions.map((session) => {
294368 const dateStr = formatRelativeDate(new Date(session.updatedAt));
295369 const model = session.model ?? "no model";
296- const current = session.id === currentSessionId ? " (current)" : "";
297370 return {
298- label: `${dateStr} ${model}${current}`,
371+ label: formatSessionLabel(
372+ session,
373+ dateStr,
374+ session.id === currentSessionId,
375+ ),
299376 value: session.id,
300- filterText: `${dateStr} ${model}`,
377+ filterText: `${session.firstUserPreview ?? ""} ${model} ${dateStr}`,
301378 };
302379 });