diff --git a/src/lib/config.ts b/src/lib/config.ts index 2ef1016..0c2ce44 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -44,9 +44,9 @@ export interface SessionBarConfig { // "unfinished" drops the sessions that completed, errored, or were stopped, // leaving the conversations still going. "all" keeps them. statuses?: 'all' | 'unfinished' - // Only sessions started these ways, e.g. ["cli", "manual"]. Omit for all of - // them. Laptop sessions never appear whatever this says: there is nothing in - // the cloud to open. + // Only sessions started these ways, e.g. ["cli", "manual"]. An empty list + // means every source. Laptop sessions never appear whatever this says: there + // is nothing in the cloud to open. sources?: string[] } @@ -234,6 +234,8 @@ export function clearAllTokens(): void { // standing in and the last week, which is short enough to read at a glance // without hiding a session you are likely to reopen. `repo: 'cwd'` falls back // to every repository outside a repo, so the bar is never mysteriously empty. +// The default sources are the ones a person started; `react` and `cron` fire on +// their own and would bury the sessions you are actually working in. export const SESSION_BAR_DEFAULTS: Required> & { sources: string[] | undefined } = { @@ -241,7 +243,7 @@ export const SESSION_BAR_DEFAULTS: Required> & days: 7, repo: 'cwd', statuses: 'all', - sources: undefined, + sources: ['manual', 'cli', 'mention'], } export type ResolvedSessionBar = typeof SESSION_BAR_DEFAULTS @@ -257,7 +259,7 @@ export function sessionBar(): ResolvedSessionBar { if (!raw || typeof raw !== 'object') return { ...SESSION_BAR_DEFAULTS } const sources = Array.isArray(raw.sources) ? raw.sources.filter((s) => SESSION_SOURCES.includes(s)) - : undefined + : null return { hidden: raw.hidden === true, days: @@ -269,9 +271,10 @@ export function sessionBar(): ResolvedSessionBar { raw.statuses === 'unfinished' || raw.statuses === 'all' ? raw.statuses : SESSION_BAR_DEFAULTS.statuses, - // An explicit [] would list nothing at all, which no one means; treat it - // as "every source", the same as leaving the key out. - sources: sources && sources.length > 0 ? sources : undefined, + // An explicit [] would list nothing at all, which no one means; treat it as + // "every source" — the only way to ask for the automated ones too. Leaving + // the key out keeps the human-started default. + sources: sources === null ? SESSION_BAR_DEFAULTS.sources : sources.length > 0 ? sources : undefined, } } diff --git a/src/lib/sessions.ts b/src/lib/sessions.ts index 9e187cd..e211914 100644 --- a/src/lib/sessions.ts +++ b/src/lib/sessions.ts @@ -1,5 +1,6 @@ import { sessionStatusWord } from '@ellipsis-dev/sdk/stream' import type { Session as FrameSession } from '@ellipsis-dev/sdk' +import { SESSION_BAR_DEFAULTS } from './config' import { theme } from './theme' import type { AgentSession, @@ -212,9 +213,9 @@ export function sessionBarQuery( export const SESSION_BAR_FETCH = 50 // The picker header's description of the bar's active filters — the answer to -// "where are the rest of my sessions?". Mirrors sessionBarQuery exactly: a -// clause appears here iff the matching filter went into the query. null when -// the list is unfiltered. +// "where are the rest of my sessions?". Mirrors sessionBarQuery, with one +// exception: the default sources are not named, since "manual/cli/mention" is +// what everyone sees and answers no question. null when there is nothing to say. export function sessionBarFilterLabel( bar: { days: number @@ -228,7 +229,10 @@ export function sessionBarFilterLabel( if (bar.repo === 'cwd' && detectedRepo) clauses.push(detectedRepo) if (bar.days > 0) clauses.push(`last ${bar.days === 1 ? 'day' : `${bar.days} days`}`) if (bar.statuses === 'unfinished') clauses.push('unfinished') - if (bar.sources) clauses.push(`source ${bar.sources.join('/')}`) + const sources = bar.sources?.join('/') + if (sources && sources !== SESSION_BAR_DEFAULTS.sources?.join('/')) { + clauses.push(`source ${sources}`) + } if (clauses.length === 0) return null return `filtering to ${clauses.join(' · ')}` } diff --git a/test/config.test.ts b/test/config.test.ts index 6601149..dc5e643 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -260,6 +260,11 @@ describe('sessionBar', () => { expect(sessionBar().sources).toBeUndefined() }) + it('defaults to the human-started sources when the key is absent', () => { + writeConfig({ version: 2, hosts: {}, sessionBar: { days: 3 } }) + expect(sessionBar().sources).toEqual(['manual', 'cli', 'mention']) + }) + it('takes days 0 as "no age cutoff", not as a missing value', () => { writeConfig({ version: 2, hosts: {}, sessionBar: { days: 0 } }) expect(sessionBar().days).toBe(0)