Skip to content
Merged
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

### Added

- **Tell topology sessions and subagents apart.** Session cards show the git
branch (new `sessions.git_branch`, migration 057, from `session.start`; never
stored for `private` sessions) in place of the developer name the parent node
already shows. Subagent cards show what they were asked to do and their model
(`description` / `model` on `agent.start`, sent by plugin 0.31.0+, returned on
`activeAgents`; activity-only viewers still get no agents).

- **Topology shows what each session is actually doing.** A session whose turn
finished reads "Your turn" instead of "Idle", turns a dimmed "Inactive" after
2 minutes without events, and shows "active 3m ago" instead of its start time.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Git branch a session runs on, from the session.start payload, so the
-- topology can tell two sessions in the same project apart. Not stored for
-- `private` sessions. Updated on a later session.start (resume after a
-- checkout) and kept when that event has no branch.

ALTER TABLE sessions
ADD COLUMN IF NOT EXISTS git_branch TEXT;
8 changes: 6 additions & 2 deletions packages/backend/src/db/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export async function createSession(
privacyMode: string | null = null,
saltVersion: number = 1,
model: string | null = null,
gitBranch: string | null = null,
) {
// DEV-76: salt_version is set on first INSERT and intentionally NOT
// updated on conflict — once a session has been stamped with a version,
Expand All @@ -67,12 +68,13 @@ export async function createSession(
// conflict so a later session.start without `model` (older plugin) does
// not blank out a previously-stamped value.
await sql`
INSERT INTO sessions (id, developer_id, project_path, project_name, permission_mode, privacy_mode, salt_version, model)
VALUES (${id}, ${developerId}, ${projectPath}, ${projectName}, ${permissionMode}, ${privacyMode}, ${saltVersion}, ${model})
INSERT INTO sessions (id, developer_id, project_path, project_name, permission_mode, privacy_mode, salt_version, model, git_branch)
VALUES (${id}, ${developerId}, ${projectPath}, ${projectName}, ${permissionMode}, ${privacyMode}, ${saltVersion}, ${model}, ${gitBranch})
ON CONFLICT(id) DO UPDATE SET
permission_mode = COALESCE(EXCLUDED.permission_mode, sessions.permission_mode),
privacy_mode = COALESCE(EXCLUDED.privacy_mode, sessions.privacy_mode),
model = COALESCE(EXCLUDED.model, sessions.model),
git_branch = COALESCE(EXCLUDED.git_branch, sessions.git_branch),
status = 'active',
ended_at = NULL
WHERE sessions.developer_id = EXCLUDED.developer_id`;
Expand Down Expand Up @@ -117,6 +119,8 @@ export async function getActiveAgents(sql: SQL) {
SELECT
e.payload->>'agentId' AS agent_id,
e.payload->>'agentType' AS agent_type,
e.payload->>'description' AS description,
e.payload->>'model' AS model,
e.session_id,
e.created_at AS started_at
FROM events e
Expand Down
29 changes: 29 additions & 0 deletions packages/backend/src/routes/__tests__/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ describe("POST /events", () => {
null, // privacyMode not set in default payload
1, // DEV-76: CURRENT_SALT_VERSION stamped on the session row
null, // DEV-93: model not set in default payload
null, // git branch not set in default payload
);
});

Expand All @@ -401,6 +402,7 @@ describe("POST /events", () => {
"private",
1, // DEV-76: CURRENT_SALT_VERSION
null, // DEV-93: model not set in this payload
null, // private sessions never store the git branch
);
});

Expand All @@ -426,9 +428,36 @@ describe("POST /events", () => {
null,
1,
"claude-sonnet-4-20250514", // DEV-93: model id round-trips from payload to createSession
null,
);
});

test("passes gitBranch from session.start payload to createSession", async () => {
const sql = makeMockSql([], []);
const app = buildApp(sql);

await app.request("/", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(validEvent({ payload: { gitBranch: "feat/topology" } })),
});

expect(mockCreateSession.mock.calls.at(-1)?.[9]).toBe("feat/topology");
});

test("drops gitBranch from a private session.start", async () => {
const sql = makeMockSql([], []);
const app = buildApp(sql);

await app.request("/", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(validEvent({ payload: { gitBranch: "feat/secret", privacyMode: "private" } })),
});

expect(mockCreateSession.mock.calls.at(-1)?.[9]).toBeNull();
});

// -----------------------------------------------------------------------
// DEV-76: salt distribution on session.start
// -----------------------------------------------------------------------
Expand Down
21 changes: 21 additions & 0 deletions packages/backend/src/routes/__tests__/sessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ describe("GET /sessions", () => {
permissionMode: "default",
privacyMode: "standard",
model: null,
gitBranch: null,
developerName: "Alice",
developerEmail: "alice@example.com",
eventCount: 5,
Expand Down Expand Up @@ -273,6 +274,8 @@ describe("GET /sessions/active", () => {
expect(s1.activeAgents[0]).toEqual({
agentId: "agent-1",
agentType: "sub",
description: null,
model: null,
sessionId: "sess-1",
startedAt: "2026-03-01T10:05:00Z",
});
Expand Down Expand Up @@ -304,6 +307,24 @@ describe("GET /sessions/active", () => {
expect(s2.projectName).toBeNull();
});

test("returns agent description and model, but no agents for an activity-only session", async () => {
const own = makeSessionRow({ id: "sess-1" });
const teammate = makeSessionRow({ id: "sess-2", developer_id: "dev-bbb", owner_share_details: false });
mockGetActiveSessions.mockImplementation(() => Promise.resolve([own, teammate]));
mockGetActiveAgents.mockImplementation(() => Promise.resolve([
{ agent_id: "a1", agent_type: "Explore", description: "Map the code", model: "haiku", session_id: "sess-1", started_at: "2026-03-01T10:05:00Z" },
{ agent_id: "a2", agent_type: "Explore", description: "Their task", model: "haiku", session_id: "sess-2", started_at: "2026-03-01T10:05:00Z" },
]));
mockGetAllDeveloperIdsForUser.mockImplementation(() => Promise.resolve(["dev-aaa"]));

const app = buildApp({ orgDeveloperIds: ["dev-aaa", "dev-bbb"], user: { id: "user-1" } });
const body = await (await app.request("/sessions/active")).json();

const s1 = body.find((s: any) => s.id === "sess-1");
expect(s1.activeAgents[0]).toMatchObject({ description: "Map the code", model: "haiku" });
expect(body.find((s: any) => s.id === "sess-2").activeAgents).toEqual([]);
});

test("passes orgDeveloperIds to getActiveSessions", async () => {
const devIds = ["dev-aaa"];
const app = buildApp({ orgDeveloperIds: devIds });
Expand Down
5 changes: 4 additions & 1 deletion packages/backend/src/routes/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,12 @@ export function eventsRoutes(sql: SQL) {
const model = event.eventType === "session.start"
? (event.payload as { model?: string }).model ?? null
: null;
const gitBranch = event.eventType === "session.start" && privacyMode !== "private"
? (event.payload as { gitBranch?: string }).gitBranch ?? null
: null;
const shouldCreateOrReactivate = !existingSession || wasEnded || event.eventType === "session.start";
if (shouldCreateOrReactivate) {
await createSession(sql, event.sessionId, event.developerId, event.projectPath, event.projectName, permissionMode, privacyMode, CURRENT_SALT_VERSION, model);
await createSession(sql, event.sessionId, event.developerId, event.projectPath, event.projectName, permissionMode, privacyMode, CURRENT_SALT_VERSION, model, gitBranch);
}

// DEV-76: Defense-in-depth — never persist a `salt` value into events.payload.
Expand Down
3 changes: 3 additions & 0 deletions packages/backend/src/routes/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function mapSession(row: any) {
permissionMode: row.permission_mode ?? null,
privacyMode: row.privacy_mode ?? null,
model: row.model ?? null,
gitBranch: row.git_branch ?? null,
developerName: row.developer_name,
developerEmail: row.developer_email,
eventCount: row.event_count ?? 0,
Expand Down Expand Up @@ -86,6 +87,8 @@ export function sessionsRoutes(sql: SQL) {
const agents = (agentsRaw as any[]).map((row) => ({
agentId: row.agent_id,
agentType: row.agent_type,
description: row.description ?? null,
model: row.model ?? null,
sessionId: row.session_id,
startedAt: row.started_at,
}));
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/src/utils/eventSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ const agentEventPayloadSchema = z
agentType: z.string(),
agentId: z.string(),
parentAgentId: z.string().nullable().optional(),
description: z.string().max(500).optional(),
model: z.string().max(100).optional(),
lastMessageLength: z.number().int().nonnegative().optional(),
transcriptPath: z.string().optional(),
...privacyAnnotations,
})
.strict();
Expand Down
10 changes: 8 additions & 2 deletions packages/dashboard/src/components/flow/AgentNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const EVENT_COLORS: Record<string, string> = {
};

export function AgentNode({ data }: NodeProps & { data: AgentNodeData }) {
const { agentId, agentType, startedAt, latestEvent, isToolRunning, currentToolName } = data;
const { agentId, agentType, description, model, startedAt, latestEvent, isToolRunning, currentToolName } = data;

const debounced = useDebouncedToolState(isToolRunning, currentToolName, latestEvent);

Expand Down Expand Up @@ -86,8 +86,14 @@ export function AgentNode({ data }: NodeProps & { data: AgentNodeData }) {
</span>
</div>

{description ? (
<div className="mt-0.5 truncate text-xs text-gray-300" title={description}>
{description}
</div>
) : null}

<div className="mt-1 flex items-center justify-between text-xs text-gray-500">
<span className="font-mono">{agentId?.slice(0, 8) ?? "—"}</span>
<span className="font-mono">{model ?? agentId?.slice(0, 8) ?? "—"}</span>
<span>{startedAt ? timeAgo(startedAt) : ""}</span>
</div>

Expand Down
13 changes: 8 additions & 5 deletions packages/dashboard/src/components/flow/SessionNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { navigate } from "wouter/use-browser-location";
import type { SessionNodeData } from "./flowTypes";
import type { SessionActivityState } from "./flowTypes";
import type { PromptEventPayload, AgentEventPayload } from "@devscope/shared";
import { ShieldOff, Lock } from "lucide-react";
import { ShieldOff, Lock, GitBranch } from "lucide-react";
import { ActivityBadge } from "./ActivityBadge";
import { useDebouncedToolState } from "@/hooks/useDebouncedToolState";
import { timeAgo } from "@/lib/utils";
Expand Down Expand Up @@ -116,7 +116,7 @@ const STATE_PULSE_COLORS: Record<string, string> = {
};

export function SessionNode({ data }: NodeProps & { data: SessionNodeData }) {
const { session, developerName, latestEvent, isToolRunning, currentToolName, activityState, lastActivityAt } = data;
const { session, latestEvent, isToolRunning, currentToolName, activityState, lastActivityAt } = data;
const isDangerousMode = session.permissionMode === "dangerously-skip-permissions";
const isRedactedMode = session.privacyMode === "private";

Expand Down Expand Up @@ -180,9 +180,12 @@ export function SessionNode({ data }: NodeProps & { data: SessionNodeData }) {
{session.currentTitle}
</div>
) : null}
<div className="truncate text-xs text-gray-500">
{developerName}
</div>
{session.gitBranch ? (
<div className="flex min-w-0 items-center gap-1 text-xs text-gray-500" title={session.gitBranch}>
<GitBranch className="h-3 w-3 shrink-0" />
<span className="truncate font-mono">{session.gitBranch}</span>
</div>
) : null}
</div>
<span
className={`flex shrink-0 items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium ${stateConfig.badgeClass}`}
Expand Down
3 changes: 2 additions & 1 deletion packages/dashboard/src/components/flow/flowTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export interface DeveloperNodeData {
export interface SessionNodeData {
[key: string]: unknown;
session: Session;
developerName: string;
recentEvents: FeedEvent[];
latestEvent: FeedEvent | null;
isToolRunning: boolean;
Expand All @@ -35,6 +34,8 @@ export interface AgentNodeData {
[key: string]: unknown;
agentId: string;
agentType: string;
description: string | null;
model: string | null;
sessionId: string;
startedAt: string;
latestEvent: FeedEvent | null;
Expand Down
4 changes: 2 additions & 2 deletions packages/dashboard/src/components/flow/useFlowLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,9 @@ export function useFlowLayout(): { nodes: Node[]; edges: Edge[] } {
// Session + agent nodes (placeholder event data — filled in stage 2)
for (const session of activeSessions) {
const devId = session.developerId;
const dev = developers.find((d) => d.id === devId);

const data: SessionNodeData = {
session,
developerName: dev?.name ?? "Unknown",
recentEvents: [],
latestEvent: null,
isToolRunning: false,
Expand Down Expand Up @@ -244,6 +242,8 @@ export function useFlowLayout(): { nodes: Node[]; edges: Edge[] } {
const agentData: AgentNodeData = {
agentId: agent.agentId,
agentType: agent.agentType,
description: agent.description ?? null,
model: agent.model ?? null,
sessionId: agent.sessionId,
startedAt: agent.startedAt,
latestEvent: null,
Expand Down
19 changes: 10 additions & 9 deletions packages/dashboard/src/components/landing/demoTopologyData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ interface SessionDef {
}

const sessionDefs: SessionDef[] = [
{ session: { id: "s1", developerId: "alice", projectPath: "/app/frontend", projectName: "frontend", startedAt: minutesAgo(45), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "alice", devName: "Alice Chen" },
{ session: { id: "s2", developerId: "alice", projectPath: "/app/api", projectName: "api-service", startedAt: minutesAgo(20), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "alice", devName: "Alice Chen" },
{ session: { id: "s3", developerId: "bob", projectPath: "/app/backend", projectName: "backend", startedAt: minutesAgo(30), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "bob", devName: "Bob Martinez" },
{ session: { id: "s4", developerId: "carol", projectPath: "/app/ml", projectName: "ml-pipeline", startedAt: minutesAgo(60), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "carol", devName: "Carol Singh" },
{ session: { id: "s5", developerId: "carol", projectPath: "/app/infra", projectName: "infra", startedAt: minutesAgo(15), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "carol", devName: "Carol Singh" },
{ session: { id: "s6", developerId: "carol", projectPath: "/app/docs", projectName: "docs", startedAt: minutesAgo(8), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "carol", devName: "Carol Singh" },
{ session: { id: "s7", developerId: "dave", projectPath: "/app/mobile", projectName: "mobile-app", startedAt: minutesAgo(25), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "dave", devName: "Dave Kim" },
{ session: { id: "s1", gitBranch: "feat/auth-form", developerId: "alice", projectPath: "/app/frontend", projectName: "frontend", startedAt: minutesAgo(45), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "alice", devName: "Alice Chen" },
{ session: { id: "s2", gitBranch: "fix/rate-limit", developerId: "alice", projectPath: "/app/api", projectName: "api-service", startedAt: minutesAgo(20), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "alice", devName: "Alice Chen" },
{ session: { id: "s3", gitBranch: "main", developerId: "bob", projectPath: "/app/backend", projectName: "backend", startedAt: minutesAgo(30), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "bob", devName: "Bob Martinez" },
{ session: { id: "s4", gitBranch: "exp/embeddings", developerId: "carol", projectPath: "/app/ml", projectName: "ml-pipeline", startedAt: minutesAgo(60), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "carol", devName: "Carol Singh" },
{ session: { id: "s5", gitBranch: "chore/terraform", developerId: "carol", projectPath: "/app/infra", projectName: "infra", startedAt: minutesAgo(15), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "carol", devName: "Carol Singh" },
{ session: { id: "s6", gitBranch: "docs/onboarding", developerId: "carol", projectPath: "/app/docs", projectName: "docs", startedAt: minutesAgo(8), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "carol", devName: "Carol Singh" },
{ session: { id: "s7", gitBranch: "feat/offline-mode", developerId: "dave", projectPath: "/app/mobile", projectName: "mobile-app", startedAt: minutesAgo(25), endedAt: null, status: "active", permissionMode: null, privacyMode: null }, devId: "dave", devName: "Dave Kim" },
];

const agentDefs = [
{ agentId: "agent-1", agentType: "general-purpose", sessionId: "s1", startedAt: minutesAgo(5) },
{ agentId: "agent-1", agentType: "general-purpose", description: "Refactor the auth form", model: "sonnet", sessionId: "s1", startedAt: minutesAgo(5) },
];

const doneAgentDefs: AgentSummaryNodeData[] = [
Expand Down Expand Up @@ -130,7 +130,6 @@ export function buildDemoLayout(): { nodes: Node[]; edges: Edge[] } {
for (const s of sessionDefs) {
const data: SessionNodeData = {
session: s.session,
developerName: s.devName,
recentEvents: [],
latestEvent: null,
isToolRunning: false,
Expand All @@ -153,6 +152,8 @@ export function buildDemoLayout(): { nodes: Node[]; edges: Edge[] } {
const data: AgentNodeData = {
agentId: a.agentId,
agentType: a.agentType,
description: a.description,
model: a.model,
sessionId: a.sessionId,
startedAt: a.startedAt,
latestEvent: null,
Expand Down
2 changes: 2 additions & 0 deletions packages/dashboard/src/hooks/useWebSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export function useDevscopeSocket() {
store.addActiveAgent({
agentId: msg.data.payload.agentId,
agentType: msg.data.payload.agentType || "agent",
description: msg.data.payload.description ?? null,
model: msg.data.payload.model ?? null,
sessionId: msg.data.sessionId,
startedAt: msg.data.timestamp,
});
Expand Down
3 changes: 3 additions & 0 deletions packages/dashboard/src/stores/activityStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { parseUTC } from "@/lib/utils";
export interface ActiveAgent {
agentId: string;
agentType: string;
/** The Agent tool call's description; plugin 0.31.0+, never for private sessions. */
description?: string | null;
model?: string | null;
sessionId: string;
startedAt: string;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/shared/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ export interface AgentEventPayload {
agentType: string;
agentId: string;
parentAgentId?: string | null;
// SubagentStart only (plugin 0.31.0+): what the Agent tool call asked for.
// `description` is never sent from private sessions.
description?: string;
model?: string;
// SubagentStop only: length of the agent's last assistant message in chars.
// We never store the raw message body — privacy-preserving signal that lets
// us reason about subagent verbosity/output volume without surfacing content.
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export interface Session {
status: "active" | "ended";
permissionMode: string | null;
privacyMode: PrivacyMode;
/** Branch at session start; null for private sessions and older plugins. */
gitBranch?: string | null;
currentTitle?: string | null;
totalInputTokens?: number;
totalOutputTokens?: number;
Expand Down