Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/coding-agent/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [Unreleased]

### Added

- Session selector (`/resume`) now supports named-only filter toggle (default `Ctrl+N`, configurable via `toggleSessionNamedFilter`) to show only named sessions ([#862](https://github.com/badlogic/pi-mono/issues/862))

## [0.50.3] - 2026-01-29

### New Features
Expand Down
4 changes: 3 additions & 1 deletion packages/coding-agent/src/cli/session-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

import { ProcessTerminal, TUI } from "@mariozechner/pi-tui";
import { KeybindingsManager } from "../core/keybindings.js";
import type { SessionInfo, SessionListProgress } from "../core/session-manager.js";
import { SessionSelectorComponent } from "../modes/interactive/components/session-selector.js";

Expand All @@ -15,6 +16,7 @@ export async function selectSession(
): Promise<string | null> {
return new Promise((resolve) => {
const ui = new TUI(new ProcessTerminal());
const keybindings = KeybindingsManager.create();
let resolved = false;

const selector = new SessionSelectorComponent(
Expand All @@ -39,7 +41,7 @@ export async function selectSession(
process.exit(0);
},
() => ui.requestRender(),
{ showRenameHint: false },
{ showRenameHint: false, keybindings },
);

ui.addChild(selector);
Expand Down
5 changes: 5 additions & 0 deletions packages/coding-agent/src/core/keybindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export type AppAction =
| "selectModel"
| "expandTools"
| "toggleThinking"
// Session selector-only action. Intentionally not treated as a globally reserved shortcut for
// extension shortcut conflict checks, since it only applies inside the /resume picker
| "toggleSessionNamedFilter"
| "externalEditor"
| "followUp"
| "dequeue"
Expand Down Expand Up @@ -56,6 +59,7 @@ export const DEFAULT_APP_KEYBINDINGS: Record<AppAction, KeyId | KeyId[]> = {
selectModel: "ctrl+l",
expandTools: "ctrl+o",
toggleThinking: "ctrl+t",
toggleSessionNamedFilter: "ctrl+n",
externalEditor: "ctrl+g",
followUp: "alt+enter",
dequeue: "alt+up",
Expand All @@ -82,6 +86,7 @@ const APP_ACTIONS: AppAction[] = [
"selectModel",
"expandTools",
"toggleThinking",
"toggleSessionNamedFilter",
"externalEditor",
"followUp",
"dequeue",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { SessionInfo } from "../../../core/session-manager.js";

export type SortMode = "recent" | "relevance";

export type NameFilter = "all" | "named";

export interface ParsedSearchQuery {
mode: "tokens" | "regex";
tokens: { kind: "fuzzy" | "phrase"; value: string }[];
Expand All @@ -25,6 +27,15 @@ function getSessionSearchText(session: SessionInfo): string {
return `${session.id} ${session.name ?? ""} ${session.allMessagesText} ${session.cwd}`;
}

function hasSessionName(session: SessionInfo): boolean {
return !!session.name?.trim();
}

function matchesNameFilter(session: SessionInfo, filter: NameFilter): boolean {
if (filter === "all") return true;
return hasSessionName(session);
}

export function parseSearchQuery(query: string): ParsedSearchQuery {
const trimmed = query.trim();
if (!trimmed) {
Expand Down Expand Up @@ -142,17 +153,25 @@ export function matchSession(session: SessionInfo, parsed: ParsedSearchQuery): M
return { matches: true, score: totalScore };
}

export function filterAndSortSessions(sessions: SessionInfo[], query: string, sortMode: SortMode): SessionInfo[] {
export function filterAndSortSessions(
sessions: SessionInfo[],
query: string,
sortMode: SortMode,
nameFilter: NameFilter = "all",
): SessionInfo[] {
// Apply name filter first.
const nameFiltered = nameFilter === "all" ? sessions : sessions.filter((s) => matchesNameFilter(s, nameFilter));

const trimmed = query.trim();
if (!trimmed) return sessions;
if (!trimmed) return nameFiltered;

const parsed = parseSearchQuery(query);
if (parsed.error) return [];

// Recent mode: filter only, keep incoming order.
if (sortMode === "recent") {
const filtered: SessionInfo[] = [];
for (const s of sessions) {
for (const s of nameFiltered) {
const res = matchSession(s, parsed);
if (res.matches) filtered.push(s);
}
Expand All @@ -161,7 +180,7 @@ export function filterAndSortSessions(sessions: SessionInfo[], query: string, so

// Relevance mode: sort by score, tie-break by modified desc.
const scored: { session: SessionInfo; score: number }[] = [];
for (const s of sessions) {
for (const s of nameFiltered) {
const res = matchSession(s, parsed);
if (!res.matches) continue;
scored.push({ session: s, score: res.score });
Expand Down
Loading