Skip to content
Merged

. #114

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
22 changes: 22 additions & 0 deletions src/lib/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,28 @@ export function sessionBarQuery(
// How many rows the session list fetches to fill its screen from.
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.
export function sessionBarFilterLabel(
bar: {
days: number
repo: 'cwd' | 'any'
statuses: 'all' | 'unfinished'
sources: string[] | undefined
},
detectedRepo: string | null,
): string | null {
const clauses: string[] = []
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('/')}`)
if (clauses.length === 0) return null
return `filtering to ${clauses.join(' · ')}`
}

// Attention transitions: a session that WAS in flight and now waits for a
// human (waiting/sleeping/idle) deserves the sidebar dot. Pure step function
// over consecutive poll snapshots.
Expand Down
7 changes: 6 additions & 1 deletion src/ui/SessionsApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
rowMeta,
rowStatusWord,
navSlice,
sessionBarFilterLabel,
sessionBarQuery,
sessionSource,
SELECTION_GLYPH,
Expand Down Expand Up @@ -494,6 +495,10 @@ export function SessionsApp(props: SessionsAppProps): React.ReactElement {
const whoText = props.ghLogin
? `@${props.ghLogin} in ${customerLogin}`
: customerLogin
// Over the picker the right edge answers "why is this list short?" instead
// of carrying the focused session's meta: the filters are why sessions are
// missing, and the list is the one screen where that question comes up.
const filterText = navOpen ? sessionBarFilterLabel(sessionBar, props.detectedRepo) : null
const header = (
// Unpainted, like every other surface: its own blank rows above and below
// are what set the title apart, not a tint.
Expand Down Expand Up @@ -524,7 +529,7 @@ export function SessionsApp(props: SessionsAppProps): React.ReactElement {
{/* Armed, the bar carries the ctrl+c prompt: the nav and the
new-session form have no notice line of their own, and the
header is the one band always on screen. */}
{navArmed || paneArmed ? CTRL_C_QUIT_HINT : (metaText ?? whoText)}
{navArmed || paneArmed ? CTRL_C_QUIT_HINT : (filterText ?? metaText ?? whoText)}
</Text>
</Box>
</Box>
Expand Down