Skip to content

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.

feat(sidebar): show running/attention/unread badges per canvas frame

Fabricio Casali6a20f57072d0
diff --git a/src/renderer/components/SessionsSidebar.tsx b/src/renderer/components/SessionsSidebar.tsx
index 55c1befff..4bcf3ba6e 100644
--- a/src/renderer/components/SessionsSidebar.tsx
+++ b/src/renderer/components/SessionsSidebar.tsx
@@ -5,6 +5,7 @@ import {
groupCollapseKey,
groupSessionCount,
groupSessionRows,
+ groupSignalCounts,
isGroupCollapsed,
liveCollapseKeys,
projectCollapseKey,
@@ -15,6 +16,7 @@ import {
type GroupBucket,
type SessionNodeInput,
type SessionRowVM,
+ type SignalCounts,
type StatusSection
} from '../lib/sessionList'
import { sidebarEmptyState, sidebarFilterKeyAction } from '../lib/sidebarFilter'
@@ -30,6 +32,63 @@ import { ProjectBranch } from './ProjectBranch'
const HISTORY_COLLAPSE_KEY = 'history'
+/**
+ * Titles per scope. Spelled out rather than composed from a fragment: the group's `working` badge
+ * answers a different question from the project's ("is this delegated task still moving?"), and a
+ * concatenated suffix would bury that difference.
+ */
+const SIGNAL_TITLES = {
+ project: {
+ attention: 'Sessions that need you',
+ unread: 'Finished — new for you',
+ working: 'Sessions running right now'
+ },
+ group: {
+ attention: 'Sessions in this group that need you',
+ unread: 'Finished in this group — new for you',
+ working: 'CLIs running in this group right now'
+ }
+} as const
+
+/**
+ * The three header badges, rendered identically for a project and for a canvas frame. ONE
+ * component on purpose: the project header and the frame headers below it are read as one column,
+ * so a badge that means "running" in one row and something subtly else in the next is worse than
+ * no badge at all. A zero count renders nothing (that is the badges' whole grammar) — which is
+ * also why the ABSENCE of the working badge is what says "this group is waiting for you".
+ */
+function SignalBadges({
+ counts,
+ scope
+}: {
+ counts: SignalCounts
+ scope: 'project' | 'group'
+}): JSX.Element {
+ const titles = SIGNAL_TITLES[scope]
+ return (
+ <>
+ {counts.attention > 0 && (
+ <span className="ss-group__sig ss-group__sig--attention" title={titles.attention}>
+ <IconBellFilled />
+ {counts.attention}
+ </span>
+ )}
+ {counts.unread > 0 && (
+ <span className="ss-group__sig ss-group__sig--unread" title={titles.unread}>
+ <IconCircleCheck />
+ {counts.unread}
+ </span>
+ )}
+ {counts.working > 0 && (
+ <span className="ss-group__sig ss-group__sig--working" title={titles.working}>
+ <span className="ss-group__sig-spin" />
+ {counts.working}
+ </span>
+ )}
+ </>
+ )
+}
+
export interface SessionsSidebarProps {
open: boolean
pinned: boolean
@@ -361,7 +420,12 @@ export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | null
{bucket.title}
</span>
)}
- <span className="ss-group__count">{groupSessionCount(bucket)}</span>
+ {/* Badges + count are one right-aligned tail: the name is `flex: 0 1 auto` and the
+ tail must not be split across the free space between them. */}
+ <span className="ss-subgroup__tail">
+ <SignalBadges counts={groupSignalCounts(bucket)} scope="group" />
+ <span className="ss-group__count">{groupSessionCount(bucket)}</span>
+ </span>
{members.length > 0 && (
<button
className="ss-subgroup__ai"
@@ -635,24 +699,7 @@ export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | null
/>
<span className="ss-group__name" title={g.projectName}>{g.projectName}</span>
<ProjectBranch project={projects.find((p) => p.id === g.projectId)!} />
- {signals.attention > 0 && (
- <span className="ss-group__sig ss-group__sig--attention" title="Sessions that need you">
- <IconBellFilled />
- {signals.attention}
- </span>
- )}
- {signals.unread > 0 && (
- <span className="ss-group__sig ss-group__sig--unread" title="Finished — new for you">
- <IconCircleCheck />
- {signals.unread}
- </span>
- )}
- {signals.working > 0 && (
- <span className="ss-group__sig ss-group__sig--working" title="Sessions running right now">
- <span className="ss-group__sig-spin" />
- {signals.working}
- </span>
- )}
+ <SignalBadges counts={signals} scope="project" />
<span className="ss-group__count">{projectCount(g)}</span>
<button
className="ss-group__add"
diff --git a/src/renderer/lib/sessionList.test.ts b/src/renderer/lib/sessionList.test.ts
index 67b47789d..413eb8025 100644
--- a/src/renderer/lib/sessionList.test.ts
+++ b/src/renderer/lib/sessionList.test.ts
@@ -12,6 +12,7 @@ import {
projectIdAtIndex,
isGroupCollapsed,
projectHeadClickAction,
+ groupSignalCounts,
projectSignalCounts,
type ProjectInput,
type SessionRowVM,
@@ -432,6 +433,69 @@ describe('projectSignalCounts', () => {
})
})
+describe('groupSignalCounts', () => {
+ // One frame holding a nested frame, so the subtree walk is exercised rather than assumed:
+ // g1 { a1 blocked, g2 { c1 working } } plus an ungrouped working session in the project.
+ const proj: ProjectInput[] = [
+ {
+ id: 'p1',
+ name: 'Alpha',
+ color: '#111',
+ nodes: [
+ node('g1', { kind: 'group', title: 'Team A', color: '#abc' }),
+ node('g2', { kind: 'group', title: 'Sub', color: '#abc', parentId: 'g1' }),
+ node('a1', { agentId: 'claude', parentId: 'g1' }),
+ node('c1', { agentId: 'claude', parentId: 'g2' }),
+ node('t1', { agentId: 'claude' })
+ ]
+ }
+ ]
+ const status: Record<string, AgentNodeStatus> = {
+ a1: { unread: true, state: 'blocked' }, // attention wins over unread
+ c1: { unread: true, state: 'working' }, // working is not counted as unread
+ t1: { unread: false, state: 'working' } // outside the frame entirely
+ }
+
+ it('counts the frame whole subtree, nested frames included', () => {
+ const [g] = buildSessionList(proj, null, 'p1', status, '')
+ expect(groupSignalCounts(g.groups[0])).toEqual({ attention: 1, unread: 0, working: 1 })
+ })
+
+ it('counts only its own subtree, not the rest of the project', () => {
+ const [g] = buildSessionList(proj, null, 'p1', status, '')
+ // The inner frame sees only c1; the ungrouped t1 belongs to no frame and is the difference
+ // between the frame totals and the project total.
+ expect(groupSignalCounts(g.groups[0].children[0])).toEqual({
+ attention: 0,
+ unread: 0,
+ working: 1
+ })
+ expect(projectSignalCounts(g)).toEqual({ attention: 1, unread: 0, working: 2 })
+ })
+
+ it('is zero for a frame with nothing running or waiting', () => {
+ const quiet: ProjectInput[] = [
+ {
+ id: 'p1',
+ name: 'Alpha',
+ color: '#111',
+ nodes: [node('g1', { kind: 'group', title: 'Team A', color: '#abc' }), node('x', { parentId: 'g1' })]
+ }
+ ]
+ // The absence of a working badge is what tells the user the task is waiting for them, so a
+ // quiet frame must report zeros rather than anything the header could render.
+ const [g] = buildSessionList(quiet, null, 'p1', {}, '')
+ expect(groupSignalCounts(g.groups[0])).toEqual({ attention: 0, unread: 0, working: 0 })
+ })
+
+ it('counts the rows the sidebar is showing, so an active filter narrows it', () => {
+ const [g] = buildSessionList(proj, null, 'p1', status, 'c1')
+ // a1 is filtered out of the tree, so the badge must not claim an attention the user cannot
+ // see or click — the same rule the project badge already follows.
+ expect(groupSignalCounts(g.groups[0])).toEqual({ attention: 0, unread: 0, working: 1 })
+ })
+})
+
describe('buildStatusList', () => {
// Two projects, sessions in various states spread across them.
const status: Record<string, AgentNodeStatus> = {
diff --git a/src/renderer/lib/sessionList.ts b/src/renderer/lib/sessionList.ts
index 97960b05b..974420f0e 100644
--- a/src/renderer/lib/sessionList.ts
+++ b/src/renderer/lib/sessionList.ts
@@ -180,11 +180,22 @@ export function projectHeadClickAction(isActive: boolean): ProjectHeadAction {
* Mirrors the row glyph's precedence — an attention session is never double-counted as unread,
* and a working one isn't unread yet (a new turn is running; the old mark resurfaces when it ends).
*/
-export function projectSignalCounts(group: SessionGroup): { attention: number; unread: number; working: number } {
+export interface SignalCounts {
+ attention: number
+ unread: number
+ working: number
+}
+
+/**
+ * The counting rule itself, over an already-resolved set of rows. It is ONE definition because the
+ * project header and each frame header show the SAME three badges: two copies of this loop is how
+ * a frame starts disagreeing with the project that contains it about what "running" means.
+ */
+export function signalCounts(rows: SessionRowVM[]): SignalCounts {
let attention = 0
let unread = 0
let working = 0
- for (const s of [...group.ungrouped, ...group.groups.flatMap(groupSessionRows)]) {
+ for (const s of rows) {
if (s.statusKind === 'attention') attention++
else if (s.unread && s.statusKind !== 'working') unread++
if (s.statusKind === 'working') working++
@@ -192,6 +203,21 @@ export function projectSignalCounts(group: SessionGroup): { attention: number; u
return { attention, unread, working }
}
+export function projectSignalCounts(group: SessionGroup): SignalCounts {
+ return signalCounts([...group.ungrouped, ...group.groups.flatMap(groupSessionRows)])
+}
+
+/**
+ * The same badges for ONE canvas frame, over its whole subtree (`groupSessionRows`, which is what
+ * the project count already sums). A frame is how a delegated task is held together, so `working`
+ * answers the question the project badge cannot: is THIS task still moving, or is it waiting for
+ * me? Counted over the rows the sidebar is actually showing, so an active filter narrows the
+ * badges exactly as it narrows the project's — never a hidden session the user cannot reach.
+ */
+export function groupSignalCounts(group: GroupBucket): SignalCounts {
+ return signalCounts(groupSessionRows(group))
+}
+
export function sessionStatusKind(state: AgentNodeStatus['state']): StatusKind {
switch (state) {
case 'working':
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index cb660db8b..6d2761e02 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -9348,7 +9348,10 @@ button.group-node__setup:disabled {
/* Content-sized (not flex:1): the row click navigates to the group on the canvas, so the
rename target must be only as wide as the name itself. */
.ss-subgroup__name { flex: 0 1 auto; min-width: 0; font-size: 11.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.ss-subgroup__head .ss-group__count { margin-left: auto; }
+/* Signal badges + count ride together at the right edge of a frame row. The count alone used to
+ carry `margin-left: auto`; with badges beside it that would strand them against the (truncating)
+ name, so the whole tail is one shrink-to-fit block instead. */
+.ss-subgroup__tail { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; margin-left: auto; }
.ss-subgroup__ai { opacity: 0; border: none; background: transparent; color: var(--text); cursor: pointer; font-size: 12px; line-height: 1; padding: 0 2px; flex: 0 0 auto; }
.ss-subgroup__head:hover .ss-subgroup__ai { opacity: 0.6; }
.ss-subgroup__ai:hover { opacity: 1 !important; color: var(--accent); }