Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(sidebar): clear the sessions filter in one action
enese29c8e5e29d0
diff --git a/src/renderer/components/SessionsSidebar.tsx b/src/renderer/components/SessionsSidebar.tsxindex 3a6a7b645..3a9f6907e 100644--- a/src/renderer/components/SessionsSidebar.tsx+++ b/src/renderer/components/SessionsSidebar.tsx@@ -1,4 +1,4 @@-import { useEffect, useMemo, useState } from 'react'+import { useCallback, useEffect, useMemo, useState } from 'react'import {buildSessionList,buildStatusList,@@ -17,6 +17,7 @@ import {type SessionRowVM,type StatusSection} from '../lib/sessionList'+import { sidebarEmptyState, sidebarFilterKeyAction } from '../lib/sidebarFilter'import { SessionRow } from './SessionRow'import { ProjectGlyph } from './ProjectGlyph'import { ClosedHistorySection } from './ClosedHistorySection'@@ -158,6 +159,15 @@ export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | null: [],[open, grouping, projects, liveActiveNodes, activeProjectId, statusById, filter])+ /**+ * The list came back with nothing in it — in EITHER grouping mode. "Nothing here" and "nothing+ * matched" are different facts (issue #505): the filter persists while you work, so half an hour+ * after finding one session the sidebar was still filtered, still empty, and still saying "No+ * sessions yet." — which reads as a broken sidebar rather than a stale filter.+ */+ const noRows = grouping === 'status' ? statusSections.length === 0 : groups.length === 0+ const emptyState = sidebarEmptyState(noRows, filter, grouping)+ const clearFilter = useCallback(() => setFilter(''), [])// Relative state ages need to advance even when no hook event arrives. Keep the clock dormant// unless the status view is visible; 30s catches minute boundaries without per-row timers.@@ -515,7 +525,27 @@ export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | nullplaceholder="Filter sessions…"value={filter}onChange={(e) => setFilter(e.target.value)}+ // Escape clears the filter in ONE action (issue #505) instead of select-all-delete.+ // The refusal on an empty field lives in `sidebarFilterKeyAction`, so Escape still+ // reaches whatever owns it next and never becomes a dead end inside this input.+ onKeyDown={(e) => {+ if (sidebarFilterKeyAction(e.key, filter) !== 'clear') return+ e.preventDefault()+ e.stopPropagation()+ clearFilter()+ }}/>+ {filter !== '' && (+ <button+ type="button"+ className="sessions-sidebar__search-clear"+ title="Clear filter (Esc)"+ aria-label="Clear filter"+ onClick={clearFilter}+ >+ ×+ </button>+ )}</div><div@@ -535,7 +565,17 @@ export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | nullsetDropProj(null)}}>- {groups.length === 0 && grouping !== 'status' && (+ {emptyState === 'no-matches' && (+ // A filtered list that came back empty says so — and offers the one action that undoes+ // it, in both grouping modes (status mode had no empty state at all).+ <div className="sessions-sidebar__empty">+ <div>No sessions match “{filter.trim()}”.</div>+ <button type="button" className="sessions-sidebar__empty-clear" onClick={clearFilter}>+ Clear filter+ </button>+ </div>+ )}+ {emptyState === 'no-sessions' && (<div className="sessions-sidebar__empty">No sessions yet.</div>)}{grouping === 'status' ? (diff --git a/src/renderer/lib/sidebarFilter.test.ts b/src/renderer/lib/sidebarFilter.test.tsnew file mode 100644index 000000000..31ff63bfd--- /dev/null+++ b/src/renderer/lib/sidebarFilter.test.ts@@ -0,0 +1,42 @@+import { describe, it, expect } from 'vitest'+import { sidebarEmptyState, sidebarFilterKeyAction } from './sidebarFilter'++describe('sidebarFilterKeyAction — Escape clears the filter (issue #505)', () => {+ it('clears in one action while the field holds text', () => {+ expect(sidebarFilterKeyAction('Escape', 'api')).toBe('clear')+ })++ it('leaves Escape alone on an empty field, so the key is never a dead end here', () => {+ expect(sidebarFilterKeyAction('Escape', '')).toBe('ignore')+ })++ it('ignores every other key', () => {+ expect(sidebarFilterKeyAction('Enter', 'api')).toBe('ignore')+ expect(sidebarFilterKeyAction('a', 'api')).toBe('ignore')+ expect(sidebarFilterKeyAction('Backspace', 'api')).toBe('ignore')+ })+})++describe('sidebarEmptyState — "nothing matched" is not "nothing here"', () => {+ it('says nothing while the list has rows', () => {+ expect(sidebarEmptyState(false, '', 'project')).toBe('none')+ expect(sidebarEmptyState(false, 'api', 'project')).toBe('none')+ expect(sidebarEmptyState(false, 'api', 'status')).toBe('none')+ })++ it('reports no-matches in BOTH grouping modes when a filter is active', () => {+ expect(sidebarEmptyState(true, 'api', 'project')).toBe('no-matches')+ // Status mode renders only non-empty sections, so this used to be a blank panel with no+ // sentence at all — the case that read as "no sessions".+ expect(sidebarEmptyState(true, 'api', 'status')).toBe('no-matches')+ })++ it('treats a whitespace-only filter as no filter (it matches everything)', () => {+ expect(sidebarEmptyState(true, ' ', 'project')).toBe('no-sessions')+ })++ it('keeps the unfiltered empty state exactly where it was: project mode only', () => {+ expect(sidebarEmptyState(true, '', 'project')).toBe('no-sessions')+ expect(sidebarEmptyState(true, '', 'status')).toBe('none')+ })+})diff --git a/src/renderer/lib/sidebarFilter.ts b/src/renderer/lib/sidebarFilter.tsnew file mode 100644index 000000000..435c5ce83--- /dev/null+++ b/src/renderer/lib/sidebarFilter.ts@@ -0,0 +1,43 @@+import type { SidebarGrouping } from './sessionList'++/**+ * Pure decisions behind the sessions sidebar's filter field (issue #505). The field was quick to+ * type into and slow to get out of: no clear button, no `type="search"` ✕, and Escape did nothing+ * — so going back to the full list meant select-all-delete. The filter also persists while you+ * work, so a list filtered half an hour ago was still filtered, still empty, and still saying+ * "No sessions yet.", which reads as a broken sidebar rather than a stale filter.+ */++/** What a keydown inside the filter field means. */+export type SidebarFilterKeyAction = 'clear' | 'ignore'++/**+ * Escape clears the filter in ONE action — but ONLY while there is text to clear. On an empty+ * field it is `ignore`, so the key is left alone and still reaches whatever owns it next (the+ * dialog stack, the drawer); a field that swallowed Escape unconditionally would be a dead end+ * for the one key users reach for to back out of things.+ */+export function sidebarFilterKeyAction(key: string, filter: string): SidebarFilterKeyAction {+ return key === 'Escape' && filter !== '' ? 'clear' : 'ignore'+}++/** Which sentence (if any) an empty sessions list should show. */+export type SidebarEmptyState = 'none' | 'no-sessions' | 'no-matches'++/**+ * "Nothing here" and "nothing matched" are different facts, and only the second one has an undo.+ *+ * `no-matches` is reported in BOTH grouping modes: status mode renders only non-empty sections,+ * so a filter that matched nothing there used to produce a completely blank panel with no+ * sentence at all. `no-sessions` stays project-mode-only, exactly as before — status mode has+ * never had an unfiltered empty state and this is not the change that adds one.+ */+export function sidebarEmptyState(+ noRows: boolean,+ filter: string,+ grouping: SidebarGrouping+): SidebarEmptyState {+ if (!noRows) return 'none'+ if (filter.trim() !== '') return 'no-matches'+ return grouping === 'status' ? 'none' : 'no-sessions'+}diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 03ee692ba..e2218f961 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -7292,10 +7292,44 @@ button.group-node__setup:disabled {.sessions-sidebar__head-actions button { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: none; color: var(--text); cursor: pointer; border-radius: 6px; }.sessions-sidebar__head-actions button:hover { background: var(--panel-header); }.sessions-sidebar__head-actions button.is-on { color: var(--accent); }-.sessions-sidebar__search { margin: 8px 10px 4px; }-.sessions-sidebar__search input { width: 100%; box-sizing: border-box; font-size: 12px; padding: 5px 8px; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 7px; }+.sessions-sidebar__search { margin: 8px 10px 4px; position: relative; }+/* Right padding leaves room for the clear button, which overlays the field's trailing edge. */+.sessions-sidebar__search input { width: 100%; box-sizing: border-box; font-size: 12px; padding: 5px 24px 5px 8px; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 7px; }+/* Issue #505: one action back to the full list. Quiet until hovered — it is an escape hatch,+ not a control competing with the field. */+.sessions-sidebar__search-clear {+ position: absolute;+ top: 50%;+ right: 4px;+ transform: translateY(-50%);+ width: 18px;+ height: 18px;+ display: flex;+ align-items: center;+ justify-content: center;+ padding: 0;+ border: none;+ border-radius: 5px;+ background: transparent;+ color: var(--muted);+ font-size: 14px;+ line-height: 1;+ cursor: pointer;+}+.sessions-sidebar__search-clear:hover { color: var(--text); background: var(--panel-header); }.sessions-sidebar__body { overflow-y: auto; padding: 4px 6px 8px; }.sessions-sidebar__empty { padding: 18px 12px; text-align: center; font-size: 12px; color: var(--muted); }+.sessions-sidebar__empty-clear {+ margin-top: 8px;+ padding: 3px 10px;+ border: 1px solid var(--border);+ border-radius: 6px;+ background: transparent;+ color: var(--text);+ font-size: 11px;+ cursor: pointer;+}+.sessions-sidebar__empty-clear:hover { border-color: var(--accent); color: var(--accent); }/* "Recently closed" — merged closed-projects/closed-sessions history at the bottom of thesidebar. Same head layout as .sessions-sidebar__head, just smaller/muted (it is a secondary