feat(web): fade non-resident session rows alongside the presence badge (#2362)

832c5922f moved liveness onto the agent icon and dropped the row fade; #2296
then gave every state its own mark, so stopped is no longer shown by an absence.
That fixes identity. It doesn't fix scale.

The badge answers "what state is this row in?" once you look at it. It can't
answer "which of these sessions is still held in memory?" across a long list,
because that's a whole-list scan and a 10px mark doesn't survive one. At a
handful of sessions the badge covers both jobs. At ~30 active, a stopped row and
a resident idle row are the same shape of row until you inspect each badge.

So restore the fade on `!active` — the same predicate the stopped badge uses,
rendered at the other scale. Shape carries which state; dimming carries which
rows.

The fade covers the title line only. The presence badge and the attached-job
meter sit outside it deliberately: a job outliving its agent is exactly the case
where the row is non-resident but the work is live, and both facts have to stay
readable at once. #2296 already marks that session's badge as working; this
keeps the row dim underneath it.

via [HAPI](https://hapi.run)

Co-authored-by: HAPI <noreply@hapi.run>
This commit is contained in:
HeavyGee
2026-11-11 08:58:25 +08:00
committed by GitHub
co-authored by HAPI
parent ac82d2d8d6
commit a29fe7b32f
2 changed files with 43 additions and 7 deletions
+31 -3
View File
@@ -81,17 +81,31 @@ describe('SessionRowSummary background status', () => {
expect(idleBadge).not.toHaveClass('bg-[var(--app-badge-success-text)]')
})
it('does not dim disconnected rows and gives them a stopped badge instead of nothing', () => {
it('dims disconnected rows and gives them a stopped badge instead of nothing', () => {
const { container } = render(
<I18nProvider>
<SessionRowSummary session={makeSummary({ active: false, backgroundTaskCount: 0 })} />
</I18nProvider>
)
expect(container.querySelector('.opacity-50')).toBeNull()
// Two scales of the same fact: the badge names the state on inspection,
// the row fade makes it legible while scanning a long list.
const faded = container.querySelector('.opacity-50')
expect(faded).not.toBeNull()
const badge = container.querySelector('[data-testid="session-presence"]')
expect(badge).toHaveAttribute('data-presence', 'stopped')
expect(badge).not.toHaveClass('animate-pulse')
expect(badge?.querySelector('svg')).not.toBeNull()
// The mark must not be dimmed along with the title line.
expect(faded!.contains(badge)).toBe(false)
})
it('keeps resident rows at full strength', () => {
const { container } = render(
<I18nProvider>
<SessionRowSummary session={makeSummary({ active: true, backgroundTaskCount: 0 })} />
</I18nProvider>
)
expect(container.querySelector('.opacity-50')).toBeNull()
})
it('shows a detailed background tooltip on the agent icon in Extended mode', () => {
@@ -271,7 +285,7 @@ describe('SessionRowSummary attached job progress', () => {
vi.useRealTimers()
})
it('keeps a pulsing working badge for a running attached job after the agent stops', () => {
it('fades the row but keeps a pulsing working badge and job meter after the agent stops', () => {
const { container } = render(
<I18nProvider>
<SessionRowSummary
@@ -282,6 +296,9 @@ describe('SessionRowSummary attached job progress', () => {
key: 'import',
label: 'beets import',
status: 'running',
remaining: 3_600,
total: 172_800,
unit: 's',
heartbeatAt: 1_000_000,
startedAt: 1_000_000 - 60_000,
updatedAt: 1_000_000,
@@ -292,9 +309,20 @@ describe('SessionRowSummary attached job progress', () => {
</I18nProvider>
)
// A job outliving its agent is the case where the two signals must say
// different things at once: nothing holds this session in memory, and
// the work is still running.
const badge = container.querySelector('[data-testid="session-presence"]')
expect(badge).toHaveAttribute('data-presence', 'working')
expect(badge).toHaveClass('animate-pulse')
const faded = container.querySelector('.opacity-50')
expect(faded).not.toBeNull()
// The job's own affordances stay outside the faded subtree.
const jobLabel = screen.getByText('beets import')
expect(faded!.contains(jobLabel)).toBe(false)
expect(screen.getByTestId('attached-job-progress-bar')).toBeInTheDocument()
expect(faded!.contains(badge)).toBe(false)
})
it('renders a subtle indeterminate striped bar (no %) when fraction is unknown', () => {
+12 -4
View File
@@ -85,9 +85,9 @@ const PRESENCE_BADGE_CLASS = {
* Presentational session row — same chrome as the sidebar SessionItem body
* (flavor icon with presence badge, title, request/schedule symbols, todos,
* relative time, path, optional attached-job meter). Visual language matches
* the native apps: no dimmed rows or spinners; unread sessions have a
* separate accent dot. Used by the session list and by rich-composer
* mention chip tooltips.
* the native apps: no row spinners, and unread sessions have a separate accent
* dot. The title line dims when the session is not resident. Used by the
* session list and by rich-composer mention chip tooltips.
*/
export function SessionRowSummary(props: {
session: SessionSummary
@@ -184,6 +184,9 @@ export function SessionRowSummary(props: {
// connected and waiting, power mark = stopped or archived. Blue is the
// existing background-work state. An outliving attached job counts as
// working even when the agent itself is idle or disconnected.
// The badge carries *which* state on inspection; the row-level residency
// fade below carries *which rows* at a glance. Same predicate (!active),
// two scales — a 10px mark doesn't survive a long-list scan on its own.
const isRunning = s.active && s.thinking
const isBackgroundOnly = s.active && !s.thinking && (s.backgroundTaskCount ?? 0) > 0
const presence: 'working' | 'background' | 'waiting' | 'stopped' = isBackgroundOnly
@@ -227,7 +230,12 @@ export function SessionRowSummary(props: {
/>
) : agentIcon}
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
<div className="grid grid-cols-[minmax(9rem,1fr)_minmax(0,max-content)] items-center gap-2">
{/* Residency fade: a non-resident session reads as a dimmer row, so
"who is still in memory" survives a whole-list scan. It covers the
title line only — the presence badge and the attached-job meter sit
outside it and stay at full strength, because a job outliving its
agent is exactly the case where the row is dim but the work is live. */}
<div className={`grid grid-cols-[minmax(9rem,1fr)_minmax(0,max-content)] items-center gap-2 ${!s.active ? 'opacity-50' : ''}`}>
<div className="flex min-w-0 items-center gap-2">
<div
className={`min-w-0 flex-1 truncate text-sm text-[var(--app-fg)] ${isUnread ? 'font-semibold' : 'font-normal'}`}