Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(desktop/spaces): mark spaces holding sessions that want attention (#79997)

Adam Leith3b27bd2be4b8
diff --git a/products/desktop/packages/core/src/archive/archiveOrchestration.test.ts b/products/desktop/packages/core/src/archive/archiveOrchestration.test.ts
index 1adc51d91995..c7d289786637 100644
--- a/products/desktop/packages/core/src/archive/archiveOrchestration.test.ts
+++ b/products/desktop/packages/core/src/archive/archiveOrchestration.test.ts
@@ -27,6 +27,7 @@ class Harness {
getFocusedWorktreePath: vi.fn().mockReturnValue(null),
disableFocus: vi.fn().mockResolvedValue(undefined),
stopCloudRun: vi.fn().mockResolvedValue(true),
+ cancelPendingPermissions: vi.fn().mockResolvedValue(undefined),
disconnectFromTask: vi.fn().mockResolvedValue(undefined),
archive: vi.fn().mockResolvedValue(undefined),
clearViewedState: vi.fn(),
@@ -178,6 +179,22 @@ describe("archiveTask", () => {
);
});
+ // A prompt left open is re-derived from the run log on the next launch, so it
+ // comes back on a task every list has dropped. Cancelling has to happen while
+ // the agent is still connected.
+ it("closes the task's open prompts before disconnecting from it", async () => {
+ await archiveTask(TASK_ID, harness.deps);
+
+ expect(harness.deps.cancelPendingPermissions).toHaveBeenCalledWith(TASK_ID);
+ expect(
+ vi.mocked(harness.deps.cancelPendingPermissions).mock
+ .invocationCallOrder[0],
+ ).toBeLessThan(
+ vi.mocked(harness.deps.disconnectFromTask).mock.invocationCallOrder[0] ??
+ Infinity,
+ );
+ });
+
it("does not archive when a running cloud task cannot be stopped", async () => {
harness.deps.stopCloudRun = vi.fn().mockResolvedValue(false);
diff --git a/products/desktop/packages/core/src/archive/archiveOrchestration.ts b/products/desktop/packages/core/src/archive/archiveOrchestration.ts
index db07d59adc20..8771b03b1a75 100644
--- a/products/desktop/packages/core/src/archive/archiveOrchestration.ts
+++ b/products/desktop/packages/core/src/archive/archiveOrchestration.ts
@@ -37,6 +37,8 @@ export interface ArchiveOrchestrationDeps {
getFocusedWorktreePath(): string | null | undefined;
disableFocus(): Promise<void>;
stopCloudRun(taskId: string, runId?: string): Promise<boolean>;
+ /** Answer nothing and close every prompt the task's session is holding. */
+ cancelPendingPermissions(taskId: string): Promise<void>;
disconnectFromTask(taskId: string): Promise<void>;
archive(taskId: string): Promise<void>;
clearViewedState(taskId: string): void;
@@ -112,6 +114,11 @@ export async function archiveTask(
}
try {
+ // Before disconnecting, while the agent is still reachable. A prompt left
+ // open outlives the archive: it is re-derived from the run log on the next
+ // bootstrap, so the task comes back asking a question from a list it has
+ // been removed from, with nothing anywhere pointing at it.
+ await deps.cancelPendingPermissions(taskId);
await deps.disconnectFromTask(taskId);
await deps.archive(taskId);
deps.clearTerminalStates(taskId);
diff --git a/products/desktop/packages/core/src/canvas/channelUnread.test.ts b/products/desktop/packages/core/src/canvas/channelUnread.test.ts
index 8e0f50169e9c..e4eb3584d6b5 100644
--- a/products/desktop/packages/core/src/canvas/channelUnread.test.ts
+++ b/products/desktop/packages/core/src/canvas/channelUnread.test.ts
@@ -1,4 +1,6 @@
import {
+ type ChannelScopedTask,
+ countSessionsByChannel,
latestActivityForChannel,
unreadChannelIds,
} from "@posthog/core/canvas/channelUnread";
@@ -82,6 +84,37 @@ describe("unreadChannelIds", () => {
});
});
+describe("countSessionsByChannel", () => {
+ const counted = new Set(["a", "b", "unfiled"]);
+ const tasks: ChannelScopedTask[] = [
+ { id: "a", channel: "c1" },
+ { id: "b", channel: "c1" },
+ { id: "quiet", channel: "c1" },
+ { id: "unfiled", channel: null },
+ { id: "other", channel: "c2" },
+ ];
+
+ it("counts a channel's sessions and leaves out the ones that don't count", () => {
+ const byChannel = countSessionsByChannel(tasks, (t) => counted.has(t.id));
+ expect(byChannel.get("c1")).toBe(2);
+ });
+
+ // A zero would render an empty dot slot; the row has to be able to ask "is
+ // there anything here" and get nothing back.
+ it("leaves a channel with nothing counted out of the map entirely", () => {
+ const byChannel = countSessionsByChannel(tasks, (t) => counted.has(t.id));
+ expect(byChannel.has("c2")).toBe(false);
+ });
+
+ it("skips sessions filed nowhere, however they count", () => {
+ const byChannel = countSessionsByChannel(tasks, () => true);
+ expect([...byChannel]).toEqual([
+ ["c1", 3],
+ ["c2", 1],
+ ]);
+ });
+});
+
describe("latestActivityForChannel", () => {
it("returns the newest timestamp for that channel only", () => {
const items = [
diff --git a/products/desktop/packages/core/src/canvas/channelUnread.ts b/products/desktop/packages/core/src/canvas/channelUnread.ts
index 1c7fafe7ba24..3daecb61c526 100644
--- a/products/desktop/packages/core/src/canvas/channelUnread.ts
+++ b/products/desktop/packages/core/src/canvas/channelUnread.ts
@@ -31,6 +31,37 @@ export function latestActivityByChannel(
return latest;
}
+/**
+ * The fields this module needs off a task to place it. Structural, so the full
+ * `Task` DTO and anything narrower both satisfy it.
+ */
+export interface ChannelScopedTask {
+ id: string;
+ /** Backend channel UUID; absent for a task filed nowhere. */
+ channel?: string | null;
+}
+
+/**
+ * How many sessions each channel holds that the caller counts — the number
+ * behind a space row's dots.
+ *
+ * What counts is the caller's to decide, because the answer is the sidebar's
+ * status vocabulary and that lives in the UI. This owns only the grouping: one
+ * pass, tasks filed nowhere skipped, channels with none left out rather than
+ * carrying a zero.
+ */
+export function countSessionsByChannel<T extends ChannelScopedTask>(
+ tasks: readonly T[],
+ counts: (task: T) => boolean,
+): Map<string, number> {
+ const byChannel = new Map<string, number>();
+ for (const task of tasks) {
+ if (!task.channel || !counts(task)) continue;
+ byChannel.set(task.channel, (byChannel.get(task.channel) ?? 0) + 1);
+ }
+ return byChannel;
+}
+
/**
* Channel ids whose newest activity postdates the viewer's last visit. A
* channel never visited is unread as soon as it has any activity.
diff --git a/products/desktop/packages/core/src/sidebar/buildSidebarData.ts b/products/desktop/packages/core/src/sidebar/buildSidebarData.ts
index 42469076c1e6..13d650131bb8 100644
--- a/products/desktop/packages/core/src/sidebar/buildSidebarData.ts
+++ b/products/desktop/packages/core/src/sidebar/buildSidebarData.ts
@@ -159,21 +159,48 @@ export interface DeriveTaskDataContext {
slackThreadUrlByTaskId: ReadonlyMap<string, string>;
}
+/**
+ * When a task last moved: the backend's `updated_at`, or local activity where
+ * that has run ahead of it (the renderer sees a session change before the next
+ * poll reports it).
+ */
+export function taskLastActivityAt(
+ updatedAt: string,
+ timestamp: TaskTimestamp | undefined,
+): number {
+ const apiUpdatedAt = new Date(updatedAt).getTime();
+ const localActivity = timestamp?.lastActivityAt;
+ return localActivity ? Math.max(apiUpdatedAt, localActivity) : apiUpdatedAt;
+}
+
+/**
+ * Is there activity on this task the viewer hasn't seen — the rule behind the
+ * yellow dot on a task row. A task never opened is NOT unread: everything in a
+ * fresh list would be, which says nothing.
+ *
+ * Exported because the sidebar's rows and any list that counts them have to
+ * agree. Two implementations of this rule would show a count that doesn't match
+ * the rows it counts.
+ */
+export function isTaskUnread(
+ updatedAt: string,
+ timestamp: TaskTimestamp | undefined,
+): boolean {
+ const lastViewedAt = timestamp?.lastViewedAt;
+ return (
+ lastViewedAt != null &&
+ taskLastActivityAt(updatedAt, timestamp) > lastViewedAt
+ );
+}
+
export function deriveTaskData(
task: SidebarTask,
ctx: DeriveTaskDataContext,
): TaskData {
const { session, workspace, timestamp } = ctx;
- const apiUpdatedAt = new Date(task.updated_at).getTime();
- const localActivity = timestamp?.lastActivityAt;
- const lastActivityAt = localActivity
- ? Math.max(apiUpdatedAt, localActivity)
- : apiUpdatedAt;
+ const lastActivityAt = taskLastActivityAt(task.updated_at, timestamp);
const createdAt = new Date(task.created_at).getTime();
-
- const taskLastViewedAt = timestamp?.lastViewedAt;
- const isUnread =
- taskLastViewedAt != null && lastActivityAt > taskLastViewedAt;
+ const isUnread = isTaskUnread(task.updated_at, timestamp);
const cloudPrUrl =
readPrUrls(task.latest_run?.output)[0] ??
diff --git a/products/desktop/packages/ui/src/features/archive/useArchiveTask.ts b/products/desktop/packages/ui/src/features/archive/useArchiveTask.ts
index 847fc5775c24..3d5887110225 100644
--- a/products/desktop/packages/ui/src/features/archive/useArchiveTask.ts
+++ b/products/desktop/packages/ui/src/features/archive/useArchiveTask.ts
@@ -11,6 +11,7 @@ import {
SESSION_SERVICE,
type SessionService,
} from "@posthog/core/sessions/sessionService";
+import { sessionStoreSetters } from "@posthog/core/sessions/sessionStore";
import { resolveService } from "@posthog/di/container";
import {
HOST_TRPC_CLIENT,
@@ -143,6 +144,23 @@ function makeOrchestrationDeps(
taskId,
runId,
),
+ cancelPendingPermissions: async (taskId) => {
+ const sessionService = resolveService<SessionService>(SESSION_SERVICE);
+ const session = sessionStoreSetters.getSessionByTaskId(taskId);
+ if (!session) return;
+ // Snapshot the ids first: cancelling resolves them out of the map the
+ // loop would otherwise be walking.
+ for (const toolCallId of [...session.pendingPermissions.keys()]) {
+ try {
+ await sessionService.cancelPermission(taskId, toolCallId);
+ } catch (error) {
+ // An unanswerable prompt is better than a failed archive: the task is
+ // going away either way, so this is worth a line in the log and
+ // nothing more.
+ log.error("Failed to cancel a prompt while archiving", error);
+ }
+ }
+ },
disconnectFromTask: (taskId) =>
resolveService<SessionService>(SESSION_SERVICE).disconnectFromTask(
taskId,
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityHoverCard.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityHoverCard.tsx
index cbc0e08a7076..771347a777a1 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityHoverCard.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityHoverCard.tsx
@@ -13,6 +13,7 @@ import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";
import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";
import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";
import { ActivityRow } from "@posthog/ui/features/canvas/components/ActivityView";
+import { useBlockedTaskIds } from "@posthog/ui/features/canvas/hooks/useBlockedSessionCount";
import { useMarkTaskActivityRead } from "@posthog/ui/features/canvas/hooks/useMarkTaskActivityRead";
import { useTaskActivity } from "@posthog/ui/features/canvas/hooks/useTaskActivity";
import { useCommentsEnabled } from "@posthog/ui/features/sessions/useCommentsEnabled";
@@ -46,6 +47,8 @@ export function ActivityHoverCard({
isFetchingNextPage,
fetchNextPage,
} = useTaskActivity();
+ // Selected once for the feed, not once per row.
+ const blockedTaskIds = useBlockedTaskIds();
const [scrollRoot, setScrollRoot] = useState<HTMLDivElement | null>(null);
const [loadMoreRef, loadMoreInView] = useInView<HTMLDivElement>({
root: scrollRoot,
@@ -124,6 +127,7 @@ export function ActivityHoverCard({
onOpen={markRead}
onMarkRead={markRead}
currentUser={currentUser}
+ blockedTaskIds={blockedTaskIds}
surface="activity_panel"
onNavigate={onClose}
compact
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityView.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityView.test.tsx
index 31783ba01539..5acda4b8639f 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityView.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityView.test.tsx
@@ -40,6 +40,8 @@ function item(overrides: Partial<TaskActivityItem>): TaskActivityItem {
};
}
+const NO_BLOCKED_TASKS: ReadonlySet<string> = new Set();
+
describe("activityHeadline", () => {
beforeEach(() => {
commentsFlag.enabled = true;
@@ -137,6 +139,7 @@ describe("activityHeadline", () => {
channelId="channel-1"
onOpen={vi.fn()}
onMarkRead={vi.fn()}
+ blockedTaskIds={NO_BLOCKED_TASKS}
/>,
);
const activityButton = screen.getByText("mentioned you").closest("button");
@@ -172,6 +175,7 @@ describe("activityHeadline", () => {
channelId="channel-1"
onOpen={vi.fn()}
onMarkRead={vi.fn()}
+ blockedTaskIds={NO_BLOCKED_TASKS}
/>,
);
const activityButton = screen
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityView.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityView.tsx
index 50df665cd4d8..a22ce08ea3cd 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityView.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityView.tsx
@@ -25,6 +25,7 @@ import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authCl
import { UserAvatar } from "@posthog/ui/features/auth/UserAvatar";
import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";
import { MentionText } from "@posthog/ui/features/canvas/components/MentionText";
+import { useBlockedTaskIds } from "@posthog/ui/features/canvas/hooks/useBlockedSessionCount";
import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";
import { useMarkTaskActivityRead } from "@posthog/ui/features/canvas/hooks/useMarkTaskActivityRead";
import { useTaskActivity } from "@posthog/ui/features/canvas/hooks/useTaskActivity";
@@ -34,6 +35,7 @@ import { copyChannelLink } from "@posthog/ui/features/canvas/utils/copyChannelLi
import { userDisplayName } from "@posthog/ui/features/canvas/utils/userDisplay";
import { useCommentNavigationStore } from "@posthog/ui/features/sessions/commentNavigationStore";
import { useCommentsEnabled } from "@posthog/ui/features/sessions/useCommentsEnabled";
+import { DOT_TONE_VAR } from "@posthog/ui/features/sidebar/components/items/taskStatusVocabulary";
import {
PageHeader,
PageHeaderActions,
@@ -161,6 +163,7 @@ export function ActivityRow({
onOpen,
onMarkRead,
currentUser,
+ blockedTaskIds,
surface = "activity",
onNavigate,
compact = false,
@@ -171,6 +174,12 @@ export function ActivityRow({
onOpen: (item: TaskActivityItem) => void;
onMarkRead: (item: TaskActivityItem) => void;
currentUser?: UserBasic | null;
+ /**
+ * Tasks whose session is waiting on you. Passed in rather than selected here:
+ * the feed renders one of these per item, and the selector behind it scans and
+ * sorts every live session on each store notification.
+ */
+ blockedTaskIds: ReadonlySet<string>;
surface?: "activity" | "activity_panel";
onNavigate?: () => void;
compact?: boolean;
@@ -180,6 +189,16 @@ export function ActivityRow({
item.activityKind === "awaiting_input" ||
item.activityKind === "completed" ||
(item.activityKind === "message" && !item.author);
+ // The one row here that is blocked on you, and the sidebar's session rows
+ // already say that in blue. Yellow is everything else the feed carries:
+ // something happened that you haven't read.
+ //
+ // Read against the live sessions rather than the row's kind alone, so this is
+ // the same fact the sidebar's blue dot is drawn from. The row records that the
+ // agent asked at a moment in time; whether it is still waiting is a question
+ // only the session can answer, and answering the prompt has to clear the dot.
+ const awaitsReply =
+ item.activityKind === "awaiting_input" && blockedTaskIds.has(item.taskId);
const openTask = () => {
track(ANALYTICS_EVENTS.CHANNEL_ACTION, {
action_type: "open_task",
@@ -232,10 +251,20 @@ export function ActivityRow({
) : (
<UserAvatar user={item.author ?? currentUser} size="xs" />
)}
- {item.isUnread && (
+ {/* Unread is a fact about the feed: you haven't looked at this yet.
+ Waiting on you is a fact about the session, and reading the row
+ doesn't answer the prompt — so it keeps its dot until you do. */}
+ {(item.isUnread || awaitsReply) && (
<span
- className="-top-0.5 -right-0.5 absolute h-2 w-2 rounded-full bg-primary"
- title="New activity"
+ className="-top-0.5 -right-0.5 absolute h-2 w-2 rounded-full"
+ // Off the table the status dots read, so a row that says the agent
+ // is waiting is the same blue as the session it is waiting in.
+ style={{
+ backgroundColor: awaitsReply
+ ? DOT_TONE_VAR.blue
+ : "var(--primary)",
+ }}
+ title={awaitsReply ? "Waiting on you" : "New activity"}
/>
)}
</span>
@@ -320,6 +349,8 @@ export function ActivityView() {
isFetchingNextPage,
fetchNextPage,
} = useTaskActivity();
+ // Selected once for the feed, not once per row.
+ const blockedTaskIds = useBlockedTaskIds();
const { mutate: markTasksRead, isPending: isMarkingRead } =
useMarkTaskActivityRead();
const visibleItems = useMemo(
@@ -402,6 +433,7 @@ export function ActivityView() {
onOpen={markRead}
onMarkRead={markRead}
currentUser={currentUser}
+ blockedTaskIds={blockedTaskIds}
/>
))}
{hasNextPage && (
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemHoverCard.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemHoverCard.tsx
index 9bc5d8ca9b4a..d19690ea4528 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemHoverCard.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemHoverCard.tsx
@@ -108,7 +108,7 @@ export function ChannelItemHoverCard({
<PreviewCard.Trigger
delay={400}
closeDelay={100}
- render={<div className="min-w-0">{children}</div>}
+ render={<div className="flex min-w-0">{children}</div>}
/>
<PreviewCard.Portal>
<PreviewCard.Positioner
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.test.tsx
index be776c0ba1d1..426504cb923e 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelItemRow.test.tsx
@@ -71,11 +71,7 @@ describe("ChannelItemRow", () => {
// run mechanics (queued, failed) resolve to a dot that describes the work
// rather than the status: starting, live but stalled, or something to read.
it.each([
- [
- "a permission prompt",
- { needsPermission: true },
- "Needs permission — blocked on you",
- ],
+ ["a permission prompt", { needsPermission: true }, "Needs your input"],
["a streaming agent", { isGenerating: true }, "Working"],
[
// A background run is one-shot and unattended, so its in_progress really
@@ -190,11 +186,30 @@ describe("ChannelItemRow", () => {
renderRow(item());
- expect(screen.getByRole("img", { name: "Cloud" })).not.toBeNull();
expect(screen.getByRole("img", { name: "Merged" })).not.toBeNull();
expect(screen.queryByText(formatRelativeTimeShort(item().ts))).toBeNull();
});
+ // Running in the cloud is the default, so it gets no badge of its own — and a
+ // row with nothing else to say carries no stack at all rather than a laptop
+ // that would claim the opposite of where it ran.
+ it("leaves a cloud task with nothing else to say unbadged", () => {
+ mocks.status = { workspaceMode: "cloud" };
+
+ renderRow(item());
+
+ expect(screen.queryByRole("img", { name: "Cloud" })).toBeNull();
+ expect(screen.queryByRole("img", { name: "Local" })).toBeNull();
+ });
+
+ it("marks a local task with the laptop badge", () => {
+ mocks.status = { workspaceMode: "local" };
+
+ renderRow(item());
+
+ expect(screen.getByRole("img", { name: "Local" })).not.toBeNull();
+ });
+
it("renders a canvas like a quiet task with its glyph in the badge stack", () => {
renderRow(
item({
@@ -212,12 +227,12 @@ describe("ChannelItemRow", () => {
});
it("marks a pinned row with the pin badge, alongside its status badges", () => {
- mocks.status = { workspaceMode: "cloud" };
+ mocks.status = { workspaceMode: "cloud", prState: "merged" };
renderRow(item({ pinned: true }));
expect(screen.getByRole("img", { name: "Pinned" })).not.toBeNull();
- expect(screen.getByRole("img", { name: "Cloud" })).not.toBeNull();
+ expect(screen.getByRole("img", { name: "Merged" })).not.toBeNull();
});
it("leaves an unpinned row without one", () => {
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.test.tsx
index e17a0ef1f5da..ceef53dce551 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.test.tsx
@@ -17,6 +17,8 @@ const mocks = vi.hoisted(() => ({
updated_at: string;
}[],
totals: {} as Record<string, number>,
+ unreadSessions: {} as Record<string, number>,
+ blockedSessions: {} as Record<string, number>,
channelsLayout: true,
navigate: vi.fn(),
}));
@@ -41,6 +43,18 @@ vi.mock("@posthog/ui/features/canvas/hooks/useDashboards", () => ({
vi.mock("@posthog/ui/features/canvas/hooks/useUnreadChannels", () => ({
useIsChannelUnread: () => () => false,
}));
+// Reads the task list and the viewed timestamps, and the timestamps come over
+// tRPC — which this file renders without, like the other data hooks it stubs.
+vi.mock("@posthog/ui/features/canvas/hooks/useUnreadSessionCount", () => ({
+ useUnreadSessionCount: () => (channelId: string | undefined) =>
+ mocks.unreadSessions[channelId ?? ""] ?? 0,
+}));
+// Reads the live session store and the task list, neither of which this file
+// mounts.
+vi.mock("@posthog/ui/features/canvas/hooks/useBlockedSessionCount", () => ({
+ useBlockedSessionCount: () => (channelId: string | undefined) =>
+ mocks.blockedSessions[channelId ?? ""] ?? 0,
+}));
vi.mock("@posthog/ui/features/canvas/hooks/useRecentSpaceTasks", () => ({
NO_TASKS: { items: [], total: 0 },
usePrefetchSpaceTasks: () => () => undefined,
@@ -142,6 +156,8 @@ describe("ChannelsList", () => {
beforeEach(() => {
vi.clearAllMocks();
mocks.channels = [ME, ENG, DESIGN];
+ mocks.unreadSessions = {};
+ mocks.blockedSessions = {};
mocks.channelsLayout = true;
// The pane store is module state: reset to its resting value so a test that
// slides the slider can't hand the next one a pre-focused search box.
@@ -323,27 +339,30 @@ describe("ChannelsList", () => {
renderList();
await user.click(screen.getByLabelText("Search spaces"));
- await user.keyboard("{ArrowDown}{Enter}");
+ // Nothing is highlighted until a key moves it, and the headings are rows
+ // of their own: Starred, #me, Spaces, then the space below it.
+ await user.keyboard(
+ "{ArrowDown}{ArrowDown}{ArrowDown}{ArrowDown}{Enter}",
+ );
expect(useCurrentChannelStore.getState().currentChannelId).toBe(ENG.id);
expect(mocks.navigate).not.toHaveBeenCalled();
});
- // Base UI resets the highlight when the pointer leaves a row, and
- // `autoHighlight="always"` then snaps it back to the top — so drifting the
- // mouse across the gap between two rows threw the keyboard back to #me.
- it("keeps the highlight when the pointer leaves a row", async () => {
+ // The heading is a row of the tree, so it answers the tree's keys. A
+ // heading missing from the flat node list would leave the highlight index
+ // and the rendered rows disagreeing from there down.
+ it("folds a section from its heading and opens it again", async () => {
const user = userEvent.setup();
renderList();
await user.click(screen.getByLabelText("Search spaces"));
- const row = screen.getByText("engineering");
- await user.hover(row);
- await user.unhover(row);
- await user.keyboard("{Enter}");
+ // Onto the Spaces heading: Starred, #me, Spaces.
+ await user.keyboard("{ArrowDown}{ArrowDown}{ArrowDown}{ArrowLeft}");
+ expect(screen.queryByText("engineering")).toBeNull();
- expect(useCurrentChannelStore.getState().currentChannelId).toBe(ENG.id);
- expect(mocks.navigate).not.toHaveBeenCalled();
+ await user.keyboard("{ArrowRight}");
+ expect(screen.getByText("engineering")).toBeTruthy();
});
// A kept-mounted collapsed row would still be an option, so ↓ would walk
@@ -367,8 +386,11 @@ describe("ChannelsList", () => {
renderList();
await user.click(screen.getByLabelText("Search spaces"));
- // #me is highlighted to begin with, so one press down is "engineering".
- await user.keyboard("{ArrowDown}{ArrowRight}");
+ // Nothing is highlighted to begin with: down through the Starred heading,
+ // #me and the Spaces heading reaches "engineering".
+ await user.keyboard(
+ "{ArrowDown}{ArrowDown}{ArrowDown}{ArrowDown}{ArrowRight}",
+ );
expect(screen.getByText("Ship the tree")).toBeTruthy();
expect(screen.getByText("Write the tests")).toBeTruthy();
@@ -383,7 +405,9 @@ describe("ChannelsList", () => {
renderList();
await user.click(screen.getByLabelText("Search spaces"));
- await user.keyboard("{ArrowDown}{ArrowRight}{ArrowDown}{ArrowDown}");
+ await user.keyboard(
+ "{ArrowDown}{ArrowDown}{ArrowDown}{ArrowDown}{ArrowRight}{ArrowDown}{ArrowDown}",
+ );
// On the second task, two rows below its space.
await user.keyboard("{ArrowLeft}");
@@ -439,8 +463,10 @@ describe("ChannelsList", () => {
renderList();
await user.click(screen.getByLabelText("Search spaces"));
- await user.keyboard("{ArrowDown}{ArrowRight}");
- expect(screen.getByText("View all")).toBeTruthy();
+ await user.keyboard(
+ "{ArrowDown}{ArrowDown}{ArrowDown}{ArrowDown}{ArrowRight}",
+ );
+ expect(screen.getByText("view all")).toBeTruthy();
// Past both sessions and onto the row below them.
await user.keyboard("{ArrowDown}{ArrowDown}{ArrowDown}{Enter}");
@@ -506,9 +532,10 @@ describe("ChannelsList", () => {
);
mocks.navigate.mockClear();
- // From the top, one press down is "engineering" again. Left where it was,
- // it would have been the row after it.
- await user.keyboard("{ArrowDown}{Enter}");
+ // From the top, three presses down is "engineering" again — the two
+ // headings are rows too. Left where it was, this would have landed on the
+ // row after it.
+ await user.keyboard("{ArrowDown}{ArrowDown}{ArrowDown}{Enter}");
expect(useCurrentChannelStore.getState().currentChannelId).toBe(ENG.id);
expect(mocks.navigate).not.toHaveBeenCalled();
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx
index bb58f867fa74..b01597aca909 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx
@@ -1,12 +1,11 @@
import { Collapsible } from "@base-ui/react/collapsible";
import {
+ ArrowRightIcon,
CaretDownIcon,
CaretRightIcon,
ChartBarIcon,
- CubeFocusIcon,
DotsThreeIcon,
FileTextIcon,
- HashIcon,
LinkIcon,
PencilSimpleIcon,
PlusIcon,
@@ -58,6 +57,7 @@ import {
type TaskRowMenuProps,
} from "@posthog/ui/features/canvas/components/TaskRowMenu";
import { trackAndCreateCanvas } from "@posthog/ui/features/canvas/createCanvasAnalytics";
+import { useBlockedSessionCount } from "@posthog/ui/features/canvas/hooks/useBlockedSessionCount";
import { useChannelStarToggle } from "@posthog/ui/features/canvas/hooks/useChannelStars";
import {
type Channel,
@@ -81,6 +81,7 @@ import {
import { useStarredChannelSlots } from "@posthog/ui/features/canvas/hooks/useStarredChannelSlots";
import { PERSONAL_CHANNEL_NAME } from "@posthog/ui/features/canvas/hooks/useTaskChannels";
import { useIsChannelUnread } from "@posthog/ui/features/canvas/hooks/useUnreadChannels";
+import { useUnreadSessionCount } from "@posthog/ui/features/canvas/hooks/useUnreadSessionCount";
import {
keepListForNextRoute,
showChannelPane,
@@ -101,7 +102,10 @@ import {
TaskStatusDot,
TaskStatusTooltips,
} from "@posthog/ui/features/sidebar/components/items/TaskStatusDot";
-import { taskDot } from "@posthog/ui/features/sidebar/components/items/taskStatusVocabulary";
+import {
+ DOT_TONE_VAR,
+ taskDot,
+} from "@posthog/ui/features/sidebar/components/items/taskStatusVocabulary";
import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";
import {
OverflowTickerText,
@@ -156,7 +160,7 @@ function SpaceRowSurface({
size="default"
left
className={cn(
- "w-full min-w-0 justify-start gap-2 data-selected:bg-fill-selected data-selected:text-foreground",
+ "w-full min-w-0 justify-start gap-2 data-selected:text-foreground",
className,
)}
{...rest}
@@ -205,7 +209,14 @@ function SpaceRowSurface({
* parent each task hangs off and the space each row belongs to.
*/
type SpaceTreeNode =
- | { kind: "space"; value: string; spaceId: string | undefined }
+ | { kind: "section"; value: string; sectionId: string }
+ | {
+ kind: "space";
+ value: string;
+ spaceId: string | undefined;
+ /** The heading above it, absent while searching — there are none then. */
+ parentValue: string | undefined;
+ }
| { kind: "task"; value: string; spaceId: string; parentValue: string };
/** How long the pointer has to rest on a space before its sessions are warmed. */
@@ -257,6 +268,66 @@ function moveHighlight(
}
}
+/**
+ * There are sessions in this space that want something from you. Sits after the
+ * name, and is the same 8px yellow the session rows' own dots are: it stands for
+ * those rows, so it has to look like one of them rather than a badge about them.
+ *
+ * One dot however many sessions, because the row's job here is to say "there is
+ * something in here", and a count you can't act on without opening the space is
+ * a number for its own sake. Nothing at all when the space is quiet — the only
+ * mark on the row allowed to be absent, which is what makes it worth a glance.
+ */
+function SpaceAttentionDot({
+ count,
+ tone = "attention",
+ faded,
+ className,
+}: {
+ count: number;
+ /**
+ * Which of the two things the space is saying. Blue is the session rows' own
+ * "blocked on you", so a space whose sessions are waiting on an answer shows
+ * that alongside the yellow rather than folding it in — one of these you can
+ * clear from here, the other you have to go in and read.
+ */
+ tone?: "attention" | "blocked";
+ /**
+ * The sessions it stands for are on screen, wearing dots of their own. It
+ * still marks which space they belong to, so it stays — at a weight that
+ * leaves the ones you can act on the brighter of the two.
+ */
+ faded?: boolean;
+ /** The row's hover margin, when the dot is what ends its content. */
+ className?: string;
+}) {
+ if (count === 0) return null;
+ const sessions = `${count} ${count === 1 ? "session" : "sessions"}`;
+ return (
+ <span
+ // The dot is one mark whatever the number, but the number is still the
+ // useful fact for anyone who can't see it.
+ aria-label={
+ tone === "blocked"
+ ? `${sessions} waiting on you`
+ : `${sessions} waiting`
+ }
+ role="img"
+ className={cn(
+ "size-2 shrink-0 rounded-full",
+ faded && "opacity-40",
+ className,
+ )}
+ // The session rows' own tone, off the one table that decides what a dot's
+ // colour means, so the space and the rows inside it can't drift.
+ style={{
+ backgroundColor:
+ tone === "blocked" ? DOT_TONE_VAR.blue : "var(--primary)",
+ }}
+ />
+ );
+}
+
/**
* The tree's disclosure caret, in its own fixed slot ahead of the space glyph.
* Always drawn: a control that only appears on hover moves the row's contents
@@ -300,21 +371,21 @@ function SpaceDisclosure({
}}
className={cn(
"relative flex size-3.5 shrink-0 items-center justify-center",
- // Half-lit at rest, open or closed, because a column of carets down the
- // list would out-draw the names beside it. It brightens for its own
- // hover only, which is what says it opens the tree rather than the row's
- // space.
+ // Barely lit while closed, because a column of carets down the list
+ // would out-draw the names beside it. Open, it comes up to full: it is
+ // the only thing saying this space is the one the rows below belong to.
//
// Forced, and aimed at the glyph's descendants, because quill repaints
// a highlighted option's contents (see `ROW_LABEL_TONE`) and that rule's
// `*` reaches the icon's `<path>`, which is what `fill: currentColor`
// resolves against, so a colour on this span or on the `<svg>` still
// leaves the mark drawn in the row's colour.
- "**:text-muted-foreground/50! hover:**:text-foreground!",
+ expanded ? "**:text-foreground!" : "**:text-muted-foreground/30!",
+ "hover:**:text-foreground!",
// A 24px hit target on a 14px mark, hung off the caret's left so it
// reaches the row's edge and stops before the name. Absolute rather than
// padding, so the caret keeps its slot and nothing in the row moves.
- "before:-left-1.5 before:absolute before:inset-auto before:size-6 before:content-['']",
+ "before:-left-8 before:absolute before:inset-auto before:size-6 before:content-['']",
"before:-translate-y-1/2 before:top-1/2 before:rounded-[calc(var(--radius)-5px)]",
"hover:before:bg-fill-hover",
)}
@@ -400,9 +471,9 @@ const SpaceTaskRow = memo(function SpaceTaskRow({
optionValue={item.key}
data-selected={isActive || undefined}
onClick={() => openTask(spaceId, item.id)}
- // A step in from its space's name, so the depth reads off that column
- // without a guide line to draw it.
- className="pl-6"
+ // A step in from its space's name, clear of the guide that runs between
+ // the two columns.
+ className="pl-8"
>
{/* The dot belongs to the title, not to the row: its own tighter gap
keeps them one mark rather than two columns. */}
@@ -480,13 +551,18 @@ function ViewAllRow({
asOption={asOption}
optionValue={viewAllValue(spaceId)}
onClick={onOpenSpace}
- className={cn("pl-6.5 text-[13px]", ROW_LABEL_TONE)}
+ className={cn("pl-8 text-[13px]", ROW_LABEL_TONE)}
>
- {/* An empty slot the width of a session's status dot, so the label starts
- in the same column as the titles above it. */}
- <span className="flex min-w-0 items-center gap-1.5">
- <span aria-hidden className="size-2 shrink-0" />
- <span className="truncate">View all</span>
+ {/* The arrow takes the slot a session's status dot has, so the guide's
+ turn lands on that column and the label starts where the titles above
+ it do. */}
+ <span className="flex min-w-0 items-center gap-0.5">
+ <ArrowRightIcon
+ aria-hidden
+ size={10}
+ className="relative top-[-0.5px] left-[-3px] shrink-0 text-foreground/20"
+ />
+ <span className="truncate">view all</span>
</span>
<span className="shrink-0 text-muted-foreground/50 text-xxs">
{remaining}
@@ -495,6 +571,43 @@ function ViewAllRow({
);
}
+/**
+ * Runs from the space's caret down the sessions beneath it, so a long list still
+ * reads as belonging to the space above rather than to the list at large.
+ *
+ * Positioned rather than a border, on the caret's own centre: it lines up with
+ * the glyph that opened the space, not the text beside it, and it costs the rows
+ * none of their width. The half-pixel is the centre — a 1px line either side of
+ * it would sit off the glyph by the same amount.
+ */
+function SpaceTreeGuide() {
+ return (
+ <span
+ aria-hidden
+ className="pointer-events-none absolute inset-y-0 left-[14.5px] w-px bg-foreground/20"
+ />
+ );
+}
+
+/**
+ * How the guide ends when the space has more than the tree is showing: it turns
+ * into the "View all" row instead of running past it. The turn says this is the
+ * end of the branch, and points at the row that leads out of it.
+ *
+ * `-top-px` and the matching height close the flex gap above, so the turn reads
+ * as the same line rather than a mark that starts below it. The width carries it
+ * from the guide's column to the one the status dots keep, where the row's arrow
+ * picks it up.
+ */
+function SpaceTreeGuideEnd() {
+ return (
+ <span
+ aria-hidden
+ className="-top-px pointer-events-none absolute left-[14.5px] h-[calc(50%+1px)] w-[16.5px] rounded-bl-md border-foreground/20 border-b border-l"
+ />
+ );
+}
+
/**
* The sessions under one expanded space, or the fact that it has none. The
* empty line is not an option: ↓ walking onto "No sessions yet" would be a dead
@@ -514,30 +627,43 @@ function SpaceTaskRows({
}) {
if (tasks.items.length === 0) {
return (
- <div className="py-1 pl-12 text-subtle-foreground text-xs">
- No sessions yet
+ <div className="relative">
+ <SpaceTreeGuide />
+ <div className="py-1 pl-12 text-subtle-foreground text-xs">
+ No sessions yet
+ </div>
</div>
);
}
return (
- <>
- {tasks.items.map((item) => (
- <SpaceTaskRow
- key={item.key}
- item={item}
- spaceId={spaceId}
- asOption={asOption}
- />
- ))}
+ // The rows were siblings in the list's own flex column, so the wrappers that
+ // give the guide something to hang off have to keep their spacing. The
+ // sessions get their own, because the guide runs their full height and stops
+ // where the turn into "View all" begins.
+ <div className="flex flex-col gap-px">
+ <div className="relative flex flex-col gap-px">
+ <SpaceTreeGuide />
+ {tasks.items.map((item) => (
+ <SpaceTaskRow
+ key={item.key}
+ item={item}
+ spaceId={spaceId}
+ asOption={asOption}
+ />
+ ))}
+ </div>
{hasViewAllRow(tasks) && (
- <ViewAllRow
- spaceId={spaceId}
- remaining={tasks.total - tasks.items.length}
- asOption={asOption}
- onOpenSpace={onOpenSpace}
- />
+ <div className="relative">
+ <SpaceTreeGuideEnd />
+ <ViewAllRow
+ spaceId={spaceId}
+ remaining={tasks.total - tasks.items.length}
+ asOption={asOption}
+ onOpenSpace={onOpenSpace}
+ />
+ </div>
)}
- </>
+ </div>
);
}
@@ -776,6 +902,8 @@ const ChannelSection = memo(
function ChannelSection({
channel,
isUnread,
+ unreadSessions = 0,
+ blockedSessions = 0,
hotkeySlot,
expanded = false,
tasks,
@@ -784,6 +912,10 @@ const ChannelSection = memo(
channel: Channel;
/** Bolds the name: activity here the viewer hasn't seen. */
isUnread?: boolean;
+ /** How many sessions inside are unread. A number, so the memo can compare it. */
+ unreadSessions?: number;
+ /** How many sessions inside are waiting on an answer from you. */
+ blockedSessions?: number;
/** ⌘1-9 slot, shown as a hint while the row isn't hovered. */
hotkeySlot?: number;
expanded?: boolean;
@@ -809,6 +941,7 @@ const ChannelSection = memo(
// while open.
const [newMenuOpen, setNewMenuOpen] = useState(false);
const { reveal, hoverProps, focusProps } = useOverflowTickerReveal();
+ const hasAttention = unreadSessions > 0 || blockedSessions > 0;
const prefetchSessions = usePrefetchSpaceTasks();
const prefetchTimer = useRef<ReturnType<typeof setTimeout> | undefined>(
undefined,
@@ -877,7 +1010,7 @@ const ChannelSection = memo(
data-selected={(isActive && !expanded) || undefined}
onClick={() => openChannel(channel)}
{...focusProps}
- className={spacesLayout ? "pl-4" : undefined}
+ className={spacesLayout ? "pl-2" : undefined}
>
{onToggleExpanded && (
<SpaceDisclosure
@@ -892,19 +1025,45 @@ const ChannelSection = memo(
className={cn(
"text-[13px]",
// mr-11 clears the two icon-xs hover buttons pinned at
- // right-1. With a count beside it, that margin moves to
- // the count, which is the one nearer the buttons.
- "group-hover/chan:mr-11",
+ // right-1. It belongs on whatever ends the row's content —
+ // put it on the name while the dot is there and the gap
+ // opens between them, carrying the dot off to the buttons.
+ !hasAttention && "group-hover/chan:mr-11",
// Bold is unread's alone; full contrast is shared with the
// channel you're in. Either way there's no hover brighten
// left to do, so those rows skip it.
isUnread ? "font-bold" : "font-medium",
isUnread || isActive ? "text-foreground" : ROW_LABEL_TONE,
- menuOpen && "mr-11",
+ menuOpen && !hasAttention && "mr-11",
)}
>
{channel.name}
</OverflowTickerText>
+ {/* Both dots in one slot, so the hover margin belongs to the
+ pair rather than to whichever of them happens to end the
+ row. */}
+ {hasAttention && (
+ <span
+ className={cn(
+ "flex shrink-0 items-center gap-1",
+ "group-hover/chan:mr-11",
+ menuOpen && "mr-11",
+ )}
+ >
+ {/* Blue first, because the rows below are sorted with
+ what wants you at the top — the pair reads as a
+ summary of that list, in its order. */}
+ <SpaceAttentionDot
+ count={blockedSessions}
+ tone="blocked"
+ faded={expanded}
+ />
+ <SpaceAttentionDot
+ count={unreadSessions}
+ faded={expanded}
+ />
+ </span>
+ )}
{/* `!mr-0` undoes quill's `.quill-button kbd { margin-right: -4px }`,
which is meant to let a shortcut hang into a button's own
padding. Here `ml-auto` takes every pixel of slack, so the
@@ -1070,6 +1229,8 @@ const ChannelSection = memo(
(prev, next) =>
prev.expanded === next.expanded &&
prev.isUnread === next.isUnread &&
+ prev.unreadSessions === next.unreadSessions &&
+ prev.blockedSessions === next.blockedSessions &&
prev.hotkeySlot === next.hotkeySlot &&
prev.tasks === next.tasks &&
prev.onToggleExpanded === next.onToggleExpanded &&
@@ -1171,6 +1332,8 @@ const PersonalChannelRow = memo(function PersonalChannelRow({
// is fetched; `undefined` just means the list hasn't loaded it yet.
const meChannel = channels.find((c) => c.channelType === "personal");
const isUnread = useIsChannelUnread()(meChannel?.id);
+ const unreadSessions = useUnreadSessionCount()(meChannel?.id);
+ const blockedSessions = useBlockedSessionCount()(meChannel?.id);
const createAndOpenCanvas = useCreateAndOpenDashboard(meChannel?.id);
const isActive =
!!meChannel &&
@@ -1230,7 +1393,7 @@ const PersonalChannelRow = memo(function PersonalChannelRow({
onClick={openPersonalChannel}
// "me" is a starred space among the others now, so it takes the same
// inset rather than sitting out at the heading's margin.
- className={spacesLayout ? "pl-4" : undefined}
+ className={spacesLayout ? "pl-2" : undefined}
>
{onToggleExpanded && meChannel && (
<SpaceDisclosure
@@ -1249,6 +1412,14 @@ const PersonalChannelRow = memo(function PersonalChannelRow({
>
{PERSONAL_CHANNEL_NAME}
</span>
+ <span className="mt-[2px] flex shrink-0 items-center gap-1">
+ <SpaceAttentionDot
+ count={blockedSessions}
+ tone="blocked"
+ faded={expanded}
+ />
+ <SpaceAttentionDot count={unreadSessions} faded={expanded} />
+ </span>
{hotkeySlot != null && (
<Kbd className="!mr-0 ml-auto shrink-0 opacity-50 group-hover/chan:opacity-0">
{formatHotkey(`mod+${hotkeySlot}`)}
@@ -1317,21 +1488,24 @@ const PersonalChannelRow = memo(function PersonalChannelRow({
const STARRED_SECTION_ID = "channels:starred";
const CHANNELS_SECTION_ID = "channels:all";
+/** A heading's identity in the flat list, kept clear of any channel's id. */
+const sectionValue = (sectionId: string) => `section:${sectionId}`;
+
// A collapsible sidebar group ("Starred" / "Channels"). Base UI directly rather
// than quill's Collapsible: quill styles its trigger as a button (which fought
// the label styling) and animates the panel height (which janked on a list this
// long). Unstyled parts give a plain label row that snaps.
//
-// The whole header row is the trigger. Its section glyph swaps to a down/right
-// disclosure caret on hover or keyboard focus while keeping Starred and Spaces
-// distinct at rest.
+// The whole header row is the trigger, and the label is all of it: the headings
+// are two, named, and always in the same order, so a glyph beside each was
+// decoration rather than a way of telling them apart.
function ChannelGroup({
sectionId,
label,
className,
flat,
keepMounted = true,
- icon,
+ asOption = false,
children,
}: {
sectionId: string;
@@ -1345,7 +1519,12 @@ function ChannelGroup({
* rebuild on expand is better than highlighting a row nobody can see.
*/
keepMounted?: boolean;
- icon: ReactNode;
+ /**
+ * Under the layout the heading is a row of the tree like any other: ↑/↓ walk
+ * onto it, → opens the section, ← closes it. Off the layout there is no search
+ * box driving a list, so it stays a plain label you click.
+ */
+ asOption?: boolean;
children: ReactNode;
}) {
const collapsedSections = useSidebarStore((s) => s.collapsedSections);
@@ -1364,28 +1543,39 @@ function ChannelGroup({
className={cn(className, "mb-2")}
>
{/* MenuLabel carries the sidebar's label styling; `render` keeps it a
- real button so the whole row is clickable. */}
+ real button so the whole row is clickable. Wrapped in an option when
+ the keyboard walks the list, so the heading is a stop on the way down
+ rather than a gap the highlight jumps over. */}
<Collapsible.Trigger
- className="group/group-trigger flex w-full items-center gap-2"
- render={<MenuLabel render={<button type="button" />} />}
- >
- <span className="relative flex size-3.5 shrink-0 items-center justify-center">
- <span className="group-hover/group-trigger:hidden group-focus-visible/group-trigger:hidden">
- {icon}
- </span>
- {isOpen ? (
- <CaretDownIcon
- size={14}
- className="hidden group-hover/group-trigger:block group-focus-visible/group-trigger:block"
+ className={cn(
+ "group/group-trigger flex w-full items-center gap-2 py-1",
+ // quill wraps an option's children in its own flex row, so the caret's
+ // `ml-auto` has nothing to push against until that row is full width.
+ // The highlight is the rows' own hover fill rather than quill's focus
+ // ring, for the reason SpaceRowSurface gives.
+ asOption &&
+ "rounded-sm ring-offset-0 data-highlighted:bg-fill-hover data-highlighted:ring-0 [&>span]:w-full [&>span]:items-center",
+ )}
+ render={
+ asOption ? (
+ <AutocompleteItem
+ value={sectionValue(sectionId)}
+ render={<MenuLabel render={<button type="button" />} />}
/>
) : (
- <CaretRightIcon
- size={14}
- className="hidden group-hover/group-trigger:block group-focus-visible/group-trigger:block"
- />
- )}
- </span>
+ <MenuLabel render={<button type="button" />} />
+ )
+ }
+ >
{label}
+ {/* On the right, because the heading's name is the left edge every row
+ beneath it lines up to. Always drawn: which way the section is, is
+ the one thing this row has to say. */}
+ {isOpen ? (
+ <CaretDownIcon size={12} className="shrink-0" />
+ ) : (
+ <CaretRightIcon size={12} className="shrink-0" />
+ )}
</Collapsible.Trigger>
{/* Stay mounted while collapsed. Every row builds a context menu, a
dropdown, a tooltip and two dialogs up front, so unmounting on close
@@ -1415,6 +1605,8 @@ export function ChannelsList() {
const channelsLayout = useChannelsLayout();
const isUnread = useIsChannelUnread();
+ const unreadSessions = useUnreadSessionCount();
+ const blockedSessions = useBlockedSessionCount();
const [query, setQuery] = useState("");
const normalizedQuery = channelsLayout ? query.trim().toLowerCase() : "";
@@ -1471,14 +1663,18 @@ export function ChannelsList() {
// it already shows — and ArrowLeft needs to know which space a task hangs off.
// A collapsed group or space renders no rows, so it contributes none.
const collapsedSections = useSidebarStore((s) => s.collapsedSections);
+ const toggleSection = useSidebarStore((s) => s.toggleSection);
// "me" is provisioned server-side with the first list fetch; before it loads
// it has no id to go by.
const meValue = me?.id ?? PERSONAL_CHANNEL_NAME;
+ const starredValue = sectionValue(STARRED_SECTION_ID);
+ const channelsValue = sectionValue(CHANNELS_SECTION_ID);
const spaceNodes = (
value: string,
spaceId: string | undefined,
+ parentValue?: string,
): SpaceTreeNode[] => {
- const space: SpaceTreeNode = { kind: "space", value, spaceId };
+ const space: SpaceTreeNode = { kind: "space", value, spaceId, parentValue };
if (!isExpanded(spaceId) || !spaceId) return [space];
const tasks = tasksOf(spaceId);
return [
@@ -1513,20 +1709,31 @@ export function ChannelsList() {
),
]
: [
+ // A heading is a row of the tree, so it is a node whether or not its
+ // section is open — a folded section is still somewhere ↓ can land and
+ // → can open.
+ { kind: "section", value: starredValue, sectionId: STARRED_SECTION_ID },
// "me" leads the starred section rather than floating above it: it is
// the space you always keep, so it belongs with the ones you chose to
// keep. Folding the section away takes it with them.
...(collapsedSections.has(STARRED_SECTION_ID)
? []
: [
- ...spaceNodes(meValue, me?.id),
+ ...spaceNodes(meValue, me?.id, starredValue),
...starred.flatMap((channel) =>
- spaceNodes(channel.id, channel.id),
+ spaceNodes(channel.id, channel.id, starredValue),
),
]),
+ {
+ kind: "section",
+ value: channelsValue,
+ sectionId: CHANNELS_SECTION_ID,
+ },
...(collapsedSections.has(CHANNELS_SECTION_ID)
? []
- : others.flatMap((channel) => spaceNodes(channel.id, channel.id))),
+ : others.flatMap((channel) =>
+ spaceNodes(channel.id, channel.id, channelsValue),
+ )),
];
const optionValues = nodes.map((node) => node.value);
@@ -1576,7 +1783,17 @@ export function ChannelsList() {
if (!node) return;
if (event.key === "ArrowRight") {
- if (!atEnd || node.kind !== "space" || !node.spaceId) return;
+ if (!atEnd) return;
+ if (node.kind === "section") {
+ event.preventDefault();
+ if (collapsedSections.has(node.sectionId)) {
+ toggleSection(node.sectionId);
+ return;
+ }
+ moveHighlight(input, "ArrowDown", 1);
+ return;
+ }
+ if (node.kind !== "space" || !node.spaceId) return;
event.preventDefault();
if (!expandedSpaceIds.has(node.spaceId)) {
expandSpace(node.spaceId);
@@ -1589,6 +1806,13 @@ export function ChannelsList() {
}
if (!atStart) return;
+ // A heading has nothing above it to step to, so ← only ever folds it.
+ if (node.kind === "section") {
+ if (collapsedSections.has(node.sectionId)) return;
+ event.preventDefault();
+ toggleSection(node.sectionId);
+ return;
+ }
if (node.kind === "task") {
event.preventDefault();
// Move first, while the children are still rendered — the highlight is an
@@ -1604,7 +1828,17 @@ export function ChannelsList() {
if (node.spaceId && expandedSpaceIds.has(node.spaceId)) {
event.preventDefault();
collapseSpace(node.spaceId);
+ return;
}
+ // Closed already, so ← does what it does from a session: steps up to the
+ // row this one hangs off, which for a space is its heading.
+ if (!node.parentValue) return;
+ event.preventDefault();
+ moveHighlight(
+ input,
+ "ArrowUp",
+ optionValues.indexOf(node.value) - optionValues.indexOf(node.parentValue),
+ );
};
const rows = normalizedQuery ? (
@@ -1615,6 +1849,8 @@ export function ChannelsList() {
key={channel.id}
channel={channel}
isUnread={isUnread(channel.id)}
+ unreadSessions={unreadSessions(channel.id)}
+ blockedSessions={blockedSessions(channel.id)}
/>
))}
{noMatches && (
@@ -1633,7 +1869,7 @@ export function ChannelsList() {
label="Starred"
flat={channelsLayout}
keepMounted={!channelsLayout}
- icon={<StarIcon size={14} />}
+ asOption={channelsLayout}
>
<PersonalChannelRow
hotkeySlot={channelsLayout && me ? slotFor(me) : undefined}
@@ -1646,6 +1882,8 @@ export function ChannelsList() {
key={channel.id}
channel={channel}
isUnread={isUnread(channel.id)}
+ unreadSessions={unreadSessions(channel.id)}
+ blockedSessions={blockedSessions(channel.id)}
hotkeySlot={channelsLayout ? slotFor(channel) : undefined}
expanded={isExpanded(channel.id)}
tasks={tasksOf(channel.id)}
@@ -1659,9 +1897,7 @@ export function ChannelsList() {
label={channelsLayout ? "Spaces" : "Channels"}
flat={channelsLayout}
keepMounted={!channelsLayout}
- icon={
- channelsLayout ? <CubeFocusIcon size={14} /> : <HashIcon size={14} />
- }
+ asOption={channelsLayout}
>
{!isLoading && channels.length === 0 && (
<Empty className="px-2 py-1 text-subtle-foreground text-xs">
@@ -1675,6 +1911,8 @@ export function ChannelsList() {
key={channel.id}
channel={channel}
isUnread={isUnread(channel.id)}
+ unreadSessions={unreadSessions(channel.id)}
+ blockedSessions={blockedSessions(channel.id)}
expanded={isExpanded(channel.id)}
tasks={tasksOf(channel.id)}
onToggleExpanded={toggleSpace}
@@ -1707,7 +1945,7 @@ export function ChannelsList() {
placeholder="Search spaces…"
aria-label="Search spaces"
showSearchIcon={false}
- className="h-7 text-[13px]"
+ className="h-7 text-[13px] hover:bg-fill-hover"
onKeyDown={(event) => {
onTreeKeyDown(event);
// Base UI's clear is a tabIndex=-1 decoration, so Escape is the
@@ -1724,7 +1962,7 @@ export function ChannelsList() {
It gives way to the clear button once there's a query — by then
you are in the box and clearing is the useful action. */}
{query === "" ? (
- <Kbd className="!mr-0 shrink-0 opacity-50">
+ <Kbd className="-mr-0.5 shrink-0">
{formatHotkey(SHORTCUTS.FOCUS_SPACE_SEARCH)}
</Kbd>
) : (
@@ -1773,11 +2011,6 @@ export function ChannelsList() {
items={optionValues}
filter={null}
value={query}
- autoHighlight="always"
- // Without this the highlight resets on pointer-leave, and "always"
- // then snaps it back to the first row — so drifting the mouse across
- // the gap between two rows threw the keyboard back to the top.
- keepHighlight
// ArrowRight / ArrowLeft act on the row the keyboard is on, and this
// is the only way to know which one that is.
onItemHighlighted={(value, eventDetails) => {
diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useBlockedSessionCount.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useBlockedSessionCount.ts
new file mode 100644
index 000000000000..354898284d09
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useBlockedSessionCount.ts
@@ -0,0 +1,64 @@
+import { countSessionsByChannel } from "@posthog/core/canvas/channelUnread";
+import { useArchivedTaskIds } from "@posthog/ui/features/archive/useArchivedTaskIds";
+import { useSessionStore } from "@posthog/ui/features/sessions/sessionStore";
+import { useTasks } from "@posthog/ui/features/tasks/useTasks";
+import { useMemo } from "react";
+
+const NO_BLOCKED: ReadonlySet<string> = new Set();
+
+/**
+ * The tasks whose session is waiting on an answer from you — what turns a row
+ * blue, and what puts it at the top of its space.
+ *
+ * Blue is the one state a polled task can't report. "Blocked on you" is a
+ * permission prompt an agent raised mid-turn, which lives in the session store
+ * and nowhere else, so this reads the live sessions rather than the task list
+ * the yellow count comes from. A session running somewhere else is therefore
+ * never blue here — the app that holds the prompt is the app that can answer it.
+ *
+ * Selected as a sorted key rather than the session map: the store's sessions
+ * change identity on every streamed event, and this runs in the sidebar's own
+ * render, so the projection has to settle to a value that only changes when the
+ * set of blocked tasks does. The set is then built off that key, which keeps it
+ * one object across renders — the space tree memoizes on its identity.
+ */
+export function useBlockedTaskIds(): ReadonlySet<string> {
+ const blockedKey = useSessionStore((state) =>
+ Object.values(state.sessions)
+ .filter((session) => session.pendingPermissions.size > 0)
+ .map((session) => session.taskId)
+ .sort()
+ .join(","),
+ );
+ return useMemo(
+ () => (blockedKey ? new Set(blockedKey.split(",")) : NO_BLOCKED),
+ [blockedKey],
+ );
+}
+
+/**
+ * How many sessions in a channel are waiting on an answer from you, by channel
+ * id — the blue dot a space row wears beside its yellow one.
+ */
+export function useBlockedSessionCount(): (
+ channelId: string | undefined,
+) => number {
+ // Everyone's, for the reason `useUnreadSessionCount` gives: the space is
+ // shared and its rows carry no author filter.
+ const { data: tasks } = useTasks({ showAllUsers: true });
+ const blocked = useBlockedTaskIds();
+ const archivedTaskIds = useArchivedTaskIds();
+ const counts = useMemo(() => {
+ if (blocked.size === 0) return new Map<string, number>();
+ // Archived alongside the yellow count, for the same reason: a space's
+ // lists drop them, so a dot for one points at a row you cannot reach.
+ return countSessionsByChannel(
+ tasks ?? [],
+ (task) => blocked.has(task.id) && !archivedTaskIds.has(task.id),
+ );
+ }, [blocked, tasks, archivedTaskIds]);
+ return useMemo(
+ () => (channelId) => (channelId ? (counts.get(channelId) ?? 0) : 0),
+ [counts],
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts
index f34dc468a65c..d6b83ca19693 100644
--- a/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts
+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useRecentSpaceTasks.ts
@@ -6,7 +6,13 @@ import type { Task } from "@posthog/shared/domain-types";
import { useArchivedTaskIds } from "@posthog/ui/features/archive/useArchivedTaskIds";
import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";
import { AUTH_SCOPED_QUERY_META } from "@posthog/ui/features/auth/useCurrentUser";
+import { useBlockedTaskIds } from "@posthog/ui/features/canvas/hooks/useBlockedSessionCount";
+import {
+ type TaskTimestamps,
+ wantsAttention,
+} from "@posthog/ui/features/canvas/hooks/useUnreadSessionCount";
import { usePinnedTasks } from "@posthog/ui/features/sidebar/usePinnedTasks";
+import { useTaskViewed } from "@posthog/ui/features/sidebar/useTaskViewed";
import { useQueries, useQueryClient } from "@tanstack/react-query";
import { useCallback, useMemo, useRef } from "react";
import {
@@ -58,9 +64,60 @@ interface CachedSpaceTasks {
page: SpaceTaskPage;
archivedTaskIds: ReadonlySet<string>;
pinnedTaskIds: ReadonlySet<string>;
+ viewedAt: TaskTimestamps;
+ blockedTaskIds: ReadonlySet<string>;
built: SpaceTasks;
}
+/**
+ * What a session is asking of you: blocked on you, then merely unread or
+ * working, then quiet.
+ *
+ * Blue is its own tier rather than part of the yellow one, because the two are
+ * cleared differently. `wantsAttention` is the space dot's yellow predicate, and
+ * reading a session clears it: open a blocked session and its row would fall
+ * past the unread rows above it while the prompt it is blocked on is still
+ * sitting there unanswered. A permission prompt only goes away when answered, so
+ * a blue row holds its place until it is.
+ */
+const ATTENTION_TIERS = 3;
+
+function attentionTier(
+ item: ChannelItemModel,
+ viewedAt: TaskTimestamps,
+ blockedTaskIds: ReadonlySet<string>,
+): number {
+ if (item.task && blockedTaskIds.has(item.task.id)) return 0;
+ if (item.task && wantsAttention(item.task, viewedAt)) return 1;
+ return 2;
+}
+
+/**
+ * The order a space's rows are cut to five in: pinned sessions, then the rest,
+ * each run ordered by what it wants from you and still newest first inside that.
+ *
+ * Two keys rather than one, because they answer different questions. Pinning is
+ * the reader's own filing and outranks everything, the way it does in the Code
+ * sidebar's list. Within a run, a space that shows a dot has to show the row
+ * behind it: by recency alone the session its dot is counting can sit below the
+ * cut, leaving a marked space that opens onto five quiet rows.
+ *
+ * Buckets rather than a comparator: the list arrives newest first, and pushing
+ * in order keeps that inside each run without a second sort key.
+ */
+function spaceTreeOrder(
+ items: ChannelItemModel[],
+ viewedAt: TaskTimestamps,
+ blockedTaskIds: ReadonlySet<string>,
+): ChannelItemModel[] {
+ const runs: ChannelItemModel[][] = [[], [], [], [], [], []];
+ for (const item of items) {
+ const tier = attentionTier(item, viewedAt, blockedTaskIds);
+ runs[(item.pinned ? 0 : ATTENTION_TIERS) + tier]?.push(item);
+ }
+ return runs.flat();
+}
+
/**
* Module-level so `useQueries` can memoize on it: an inline combine is a new
* function every render, which makes every render rebuild the lists — and with
@@ -92,6 +149,8 @@ export function useRecentSpaceTasks(
const client = useOptionalAuthenticatedClient();
const archivedTaskIds = useArchivedTaskIds();
const { pinnedTaskIds } = usePinnedTasks();
+ const { timestamps: viewedAt } = useTaskViewed();
+ const blockedTaskIds = useBlockedTaskIds();
const pagePerSpace = useQueries({
queries: spaceIds.map((spaceId) => ({
@@ -127,7 +186,9 @@ export function useRecentSpaceTasks(
cached &&
cached.page === page &&
cached.archivedTaskIds === archivedTaskIds &&
- cached.pinnedTaskIds === pinnedTaskIds
+ cached.pinnedTaskIds === pinnedTaskIds &&
+ cached.viewedAt === viewedAt &&
+ cached.blockedTaskIds === blockedTaskIds
) {
bySpace.set(spaceId, cached.built);
return;
@@ -145,7 +206,10 @@ export function useRecentSpaceTasks(
// once the archived ones are dropped. A full page falls back to the
// server's total, which still counts anything archived in it.
const built: SpaceTasks = {
- items: available.slice(0, RECENT_TASKS_PER_SPACE),
+ items: spaceTreeOrder(available, viewedAt, blockedTaskIds).slice(
+ 0,
+ RECENT_TASKS_PER_SPACE,
+ ),
total:
page.tasks.length < TREE_FETCH_LIMIT ? available.length : page.count,
};
@@ -153,12 +217,21 @@ export function useRecentSpaceTasks(
page,
archivedTaskIds,
pinnedTaskIds,
+ viewedAt,
+ blockedTaskIds,
built,
});
bySpace.set(spaceId, built);
});
return bySpace;
- }, [spaceIds, pagePerSpace, archivedTaskIds, pinnedTaskIds]);
+ }, [
+ spaceIds,
+ pagePerSpace,
+ archivedTaskIds,
+ pinnedTaskIds,
+ viewedAt,
+ blockedTaskIds,
+ ]);
}
/**
diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useUnreadSessionCount.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useUnreadSessionCount.ts
new file mode 100644
index 000000000000..9bc68960e907
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useUnreadSessionCount.ts
@@ -0,0 +1,92 @@
+import { countSessionsByChannel } from "@posthog/core/canvas/channelUnread";
+import {
+ isTaskUnread,
+ readRunMode,
+} from "@posthog/core/sidebar/buildSidebarData";
+import { readPrUrls } from "@posthog/shared";
+import type { Task } from "@posthog/shared/domain-types";
+import { useArchivedTaskIds } from "@posthog/ui/features/archive/useArchivedTaskIds";
+import { taskDot } from "@posthog/ui/features/sidebar/components/items/taskStatusVocabulary";
+import { useTaskViewed } from "@posthog/ui/features/sidebar/useTaskViewed";
+import { useTasks } from "@posthog/ui/features/tasks/useTasks";
+import { useMemo } from "react";
+
+/**
+ * Does this session want something from you — the question a row's status dot
+ * answers, asked of a task we only have the polled DTO for.
+ *
+ * Grey is the vocabulary's "nothing owed", so anything else is a dot worth
+ * counting: blue is blocked on you, yellow is working, pending, or unread.
+ * Running it through `taskDot` rather than re-deriving the rule is the point —
+ * the space's dots have to mean what the session rows' dots mean, and there is
+ * one function that decides that.
+ *
+ * The renderer-only inputs (a live session's streaming and permission prompts)
+ * are absent here, and can only turn a row yellow or blue that this already
+ * counts for another reason, or that is genuinely quiet in the poll. So this
+ * can undercount a session that started moving since the last poll, never
+ * overcount one.
+ */
+export function wantsAttention(
+ task: Task,
+ lastViewedAt: TaskTimestamps,
+): boolean {
+ const { tone } = taskDot({
+ isUnread: isTaskUnread(task.updated_at, lastViewedAt[task.id]),
+ taskRunStatus: task.latest_run?.status ?? undefined,
+ // A run's mode decides whether its status is a claim about work at all, so
+ // without it the "Pending" rows never count. It rides on the run's state,
+ // which the poll already carries.
+ runMode: readRunMode(task.latest_run?.state),
+ workspaceMode:
+ task.latest_run?.environment === "cloud" ? "cloud" : undefined,
+ prUrl: readPrUrls(task.latest_run?.output)[0] ?? null,
+ });
+ return tone !== "gray";
+}
+
+export type TaskTimestamps = ReturnType<typeof useTaskViewed>["timestamps"];
+
+/**
+ * How many sessions in a channel want attention, by channel id — what a space
+ * row draws its dots from.
+ *
+ * Counts what the rows inside would show, off the same two inputs a session
+ * row's own dot comes from, so the space's count and the rows under it can't
+ * disagree. The mentions feed behind `useIsChannelUnread` answers a different
+ * question — someone named you — which is why a bold channel name and these dots
+ * are not the same signal.
+ *
+ * Everyone's sessions, not just yours. A space is shared, its rows come from
+ * `getTasksPage({ channel })` with no author filter, and the channel view reads
+ * the same list this way — so counting only your own left a teammate's unread
+ * session showing a dot on its row and none on the space above it.
+ *
+ * Built once for the whole list and returned as a lookup, so a sidebar of dozens
+ * of spaces is one pass over the task list rather than a pass per row. The
+ * answer is a number, which is what lets the memoized space rows compare it and
+ * skip re-rendering on a poll that changed nothing.
+ */
+export function useUnreadSessionCount(): (
+ channelId: string | undefined,
+) => number {
+ const { data: tasks } = useTasks({ showAllUsers: true });
+ const { timestamps } = useTaskViewed();
+ const archivedTaskIds = useArchivedTaskIds();
+ const counts = useMemo(
+ () =>
+ countSessionsByChannel(
+ tasks ?? [],
+ // Archived sessions are dropped from every list a space can show, so
+ // counting them marks a space with a dot that nothing behind it
+ // explains: open the space and the row it stands for isn't there.
+ (task) =>
+ !archivedTaskIds.has(task.id) && wantsAttention(task, timestamps),
+ ),
+ [tasks, timestamps, archivedTaskIds],
+ );
+ return useMemo(
+ () => (channelId) => (channelId ? (counts.get(channelId) ?? 0) : 0),
+ [counts],
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/sidebar/components/items/TaskIcon.tsx b/products/desktop/packages/ui/src/features/sidebar/components/items/TaskIcon.tsx
index 864dabc3ee67..1e2443125226 100644
--- a/products/desktop/packages/ui/src/features/sidebar/components/items/TaskIcon.tsx
+++ b/products/desktop/packages/ui/src/features/sidebar/components/items/TaskIcon.tsx
@@ -312,7 +312,7 @@ export function TaskIcon({
if (needsPermission) {
return (
- <Tooltip content="Needs permission" side="right">
+ <Tooltip content="Needs your input" side="right">
<span className="flex items-center justify-center">
<HandPalm size={size} color="var(--blue-11)" />
</span>
diff --git a/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.tsx b/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.tsx
index 5bba6e83cde0..3e9c5614f11a 100644
--- a/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.tsx
+++ b/products/desktop/packages/ui/src/features/sidebar/components/items/TaskStatusDot.tsx
@@ -131,9 +131,12 @@ export function PinnedBadge() {
}
/**
- * A task's identity as stacked avatars: the pin, then source, cloud, and
- * PR/branch. The pin goes first, which in a reversed stack puts it leftmost and
- * underneath — it says how the row got here, not what came out of it.
+ * A task's identity as stacked avatars: the pin, then source and PR/branch. The
+ * pin goes first, which in a reversed stack puts it leftmost and underneath — it
+ * says how the row got here, not what came out of it.
+ *
+ * A row with nothing to say gets no stack at all, rather than an empty group
+ * whose padding would still push the row's other content around.
*/
export function TaskBadgeStack({
status,
@@ -142,10 +145,14 @@ export function TaskBadgeStack({
status: TaskStatusInput;
pinned?: boolean;
}) {
+ const badges = taskBadges(status);
+ if (!pinned && badges.length === 0) {
+ return null;
+ }
return (
<AvatarGroup stacked reverse size="xs" className="shrink-0">
{pinned ? <PinnedBadge /> : null}
- {taskBadges(status).map(({ key, Icon, label, tone }) => (
+ {badges.map(({ key, Icon, label, tone }) => (
<RowTooltip key={key} label={label} side="top">
{/* The tooltip names the badge on hover; `aria-label` is what names it
for everyone else — without it the stack is a row of blank avatars
diff --git a/products/desktop/packages/ui/src/features/sidebar/components/items/taskStatusVocabulary.ts b/products/desktop/packages/ui/src/features/sidebar/components/items/taskStatusVocabulary.ts
index e2afb9b45ebf..4633a71f0df3 100644
--- a/products/desktop/packages/ui/src/features/sidebar/components/items/taskStatusVocabulary.ts
+++ b/products/desktop/packages/ui/src/features/sidebar/components/items/taskStatusVocabulary.ts
@@ -1,6 +1,5 @@
import {
ArrowSquareIn,
- Cloud,
GitBranch,
GitMerge,
GitPullRequest,
@@ -56,7 +55,7 @@ export const DOT_TONE_VAR: Record<DotTone, string> = {
yellow: "var(--primary)",
red: "var(--red-9)",
blue: "var(--blue-9)",
- gray: "var(--gray-8)",
+ gray: "var(--muted-foreground)",
};
/**
@@ -125,11 +124,18 @@ export interface TaskDot {
*/
export function taskDot(props: TaskStatusInput): TaskDot {
if (props.needsPermission) {
+ // Not flashing. Blue already reads as the one thing in the list that is
+ // yours to answer, and a blink on top of that argues with every quiet row
+ // around it — in a sidebar of a dozen spaces it is the whole tree moving.
return {
tone: "blue",
style: "solid",
- pulse: true,
- label: "Needs permission — blocked on you",
+ pulse: false,
+ // What the agent is asking for varies: permission to run a tool, an
+ // answer to a question it asked with one. Both reach the reader as the
+ // same prompt in the same place, so the row names the ask rather than the
+ // mechanism behind it.
+ label: "Needs your input",
};
}
// Spinning means something is moving on its own: a prompt in flight, or a
@@ -210,8 +216,13 @@ export interface TaskBadge {
/**
* Identity → badges, widest context first so the stack reads left-to-right as
- * "who asked, where it runs, what came out of it". Always returns at least one
- * badge: an empty slot where every other row has an avatar reads as a bug.
+ * "who asked, where it runs, what came out of it".
+ *
+ * Only the local case says where it runs. Running in the cloud is what a task
+ * does by default, and a badge on the majority of rows is a badge nobody reads —
+ * so cloud is silent and the laptop marks the exception. A cloud row with
+ * nothing else to say carries no badges at all, which is the honest shape:
+ * nothing has happened to it yet.
*
* Origins deliberately share ONE glyph. Eight product marks at avatar size is a
* vocabulary nobody learns — and the badge's job in a nav row is "this didn't
@@ -232,9 +243,6 @@ export function taskBadges(props: TaskStatusInput): TaskBadge[] {
label: `Source: ${origin.label}`,
});
}
- if (props.workspaceMode === "cloud") {
- badges.push({ key: "cloud", Icon: Cloud, label: "Cloud" });
- }
if (props.prState === "merged") {
badges.push({
key: "pr",
@@ -280,7 +288,11 @@ export function taskBadges(props: TaskStatusInput): TaskBadge[] {
tone: "yellow",
});
}
- if (badges.length === 0) {
+ // Only when we actually know it runs on this machine. An unset mode is
+ // unknown, not local, and claiming a laptop for it would be a guess.
+ const runsLocally =
+ props.workspaceMode === "local" || props.workspaceMode === "worktree";
+ if (badges.length === 0 && runsLocally) {
badges.push({ key: "local", Icon: Laptop, label: "Local" });
}
return badges;