Skip to content

Commit f1ada04

Browse files
committed
.
1 parent 276f22c commit f1ada04

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

src/lib/sessions.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,28 @@ export function sessionBarQuery(
226226
// How many rows the session list fetches to fill its screen from.
227227
export const SESSION_BAR_FETCH = 50
228228

229+
// The picker header's description of the bar's active filters — the answer to
230+
// "where are the rest of my sessions?". Mirrors sessionBarQuery exactly: a
231+
// clause appears here iff the matching filter went into the query. null when
232+
// the list is unfiltered.
233+
export function sessionBarFilterLabel(
234+
bar: {
235+
days: number
236+
repo: 'cwd' | 'any'
237+
statuses: 'all' | 'unfinished'
238+
sources: string[] | undefined
239+
},
240+
detectedRepo: string | null,
241+
): string | null {
242+
const clauses: string[] = []
243+
if (bar.repo === 'cwd' && detectedRepo) clauses.push(detectedRepo)
244+
if (bar.days > 0) clauses.push(`last ${bar.days === 1 ? 'day' : `${bar.days} days`}`)
245+
if (bar.statuses === 'unfinished') clauses.push('unfinished')
246+
if (bar.sources) clauses.push(`source ${bar.sources.join('/')}`)
247+
if (clauses.length === 0) return null
248+
return `filtering to ${clauses.join(' · ')}`
249+
}
250+
229251
// Attention transitions: a session that WAS in flight and now waits for a
230252
// human (waiting/sleeping/idle) deserves the sidebar dot. Pure step function
231253
// over consecutive poll snapshots.

src/ui/SessionsApp.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
rowMeta,
3636
rowStatusWord,
3737
navSlice,
38+
sessionBarFilterLabel,
3839
sessionBarQuery,
3940
sessionSource,
4041
SELECTION_GLYPH,
@@ -494,6 +495,10 @@ export function SessionsApp(props: SessionsAppProps): React.ReactElement {
494495
const whoText = props.ghLogin
495496
? `@${props.ghLogin} in ${customerLogin}`
496497
: customerLogin
498+
// Over the picker the right edge answers "why is this list short?" instead
499+
// of carrying the focused session's meta: the filters are why sessions are
500+
// missing, and the list is the one screen where that question comes up.
501+
const filterText = navOpen ? sessionBarFilterLabel(sessionBar, props.detectedRepo) : null
497502
const header = (
498503
// Unpainted, like every other surface: its own blank rows above and below
499504
// are what set the title apart, not a tint.
@@ -524,7 +529,7 @@ export function SessionsApp(props: SessionsAppProps): React.ReactElement {
524529
{/* Armed, the bar carries the ctrl+c prompt: the nav and the
525530
new-session form have no notice line of their own, and the
526531
header is the one band always on screen. */}
527-
{navArmed || paneArmed ? CTRL_C_QUIT_HINT : (metaText ?? whoText)}
532+
{navArmed || paneArmed ? CTRL_C_QUIT_HINT : (filterText ?? metaText ?? whoText)}
528533
</Text>
529534
</Box>
530535
</Box>

0 commit comments

Comments
 (0)