Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat: claude agent teams UI support #1145

ClosedJustYannicc(GitHub profile, opens in a new tab)wants to merge 11 commits intomain fromrefs/pull/1145/headopened View on GitHub

What Changed

Adds comprehensive UI support for Claude Code's experimental Agent Teams feature.

Status Tracking

  • Correct agent status transitions (running → idle → completed/failed/stopped) with terminal status guards preventing regression
  • tool.completed → idle mapping, task.progress/task.completed tracking via teammateTaskIds
  • Run-level status accounts for endedAt — ended runs show terminal status and zero active count

Team Lifecycle

  • Proper shutdown detection via TeamDelete and team.run.ended signals
  • Lead coordination tools (TeamCreate/TeamDelete/SendMessage/TaskCreate/TaskUpdate/TaskDelete) excluded from member creation
  • SendMessage activities routed to target member's activity feed

Panel UI

  • Dense master-detail layout replacing the previous card grid + sidebar
  • Left column: clickable agent rows with name, status icon, and current tool
  • Right column: identity header + unified activity feed merging activities and tasks chronologically
  • Color name resolution via explicit map (red→rose, blue→sky, etc.)
  • Max-height scroll constraints; panel detaches from top when team ends

Settings

  • Teammate mode selector (Auto / In-process / Tmux)
  • Agent teams enable toggle and progress summaries toggle

Adapter (teams-specific)

  • in_process_teammate task type recognition in ingestion pipeline
  • Teammate name extraction from detail prefix pattern
  • Team tool classification and enriched summaries

Why

The agent teams feature was released in Claude Code v2.1.32 but the T3 Code UI had no support for visualizing team activity, tracking agent status, or managing team lifecycle. This PR adds that support, validated against the reverse-engineered Claude Code CLI v2.1.76 event protocol.

Depends on: #179 and #1146 being merged first.

UI Changes

  • New expandable agent teams panel below the chat header (only visible during active team sessions)
  • Team-run timeline entries showing team name, summary, member count, and duration
  • Agent list with colored dots, status icons, and current tool names
  • Unified activity feed with relative timestamps and vertical timeline

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • 62 unit tests + 3 E2E tests with real Claude API (Haiku 4.5)
  • Type checks clean across web, server, and contracts
  • 3 independent code reviews completed
    1. Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: bebf225d-2380-468d-9ff9-d278f15f6828

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Post copyable unit tests in a comment
      📝 Coding Plan
      • Generate coding plan for human review comments

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands and usage tips.

      Tip

      You can disable sequence diagrams in the walkthrough.

      Disable the reviews.sequence_diagrams setting to disable sequence diagrams in the walkthrough.

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. JustYannicc(GitHub profile, opens in a new tab)commented

      I am still working on the UI. Will update with screenshots. But filed for now since I was asked to split it out in #179

    4. @@ -0,0 +2154,21 @@
      2154+ },
      2155+ createdAt: startedAt,
      2156+ updatedAt: startedAt,
      2157+ };
      2158+
      2159+ const context: ClaudeSessionContext = {
      2160+ session,
      2161+ promptQueue,
      2162+ query: queryRuntime,
      2163+ startedAt,
      2164+ resumeSessionId: resumeState?.resume,
      2165+ pendingApprovals,
      2166+ turns: [],
      2167+ inFlightTools,
      2168+ turnState: undefined,
      2169+ lastAssistantUuid: resumeState?.resumeSessionAt,
      2170+ lastThreadStartedId: undefined,
      2171+ stopped: false,
      2172+ };
      2173+ yield* Ref.set(contextRef, context);
      2174+ sessions.set(threadId, context);
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Layers/ClaudeCodeAdapter.ts:2174

      sessions.set(threadId, context) at line 2174 silently overwrites any existing session with the same threadId. The previous session's resources—the forked runSdkStream fiber, promptQueue, and queryRuntime—become orphaned and continue running indefinitely, and the finalizer only cleans up sessions still present in the sessions map. Consider either rejecting duplicate threadIds with an error, or explicitly stopping the existing session before overwriting it.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file apps/server/src/provider/Layers/ClaudeCodeAdapter.ts around line 2174:
      
      `sessions.set(threadId, context)` at line 2174 silently overwrites any existing session with the same `threadId`. The previous session's resources—the forked `runSdkStream` fiber, `promptQueue`, and `queryRuntime`—become orphaned and continue running indefinitely, and the finalizer only cleans up sessions still present in the `sessions` map. Consider either rejecting duplicate `threadId`s with an error, or explicitly stopping the existing session before overwriting it.
      
      Evidence trail:
      apps/server/src/provider/Layers/ClaudeCodeAdapter.ts line 864 (sessions map declaration), lines 1920-1924 (startSession using threadId without checking existing sessions), line 2174 (`sessions.set(threadId, context)` without has() check), line 2228 (`Effect.runFork(runSdkStream(context))` forking detached fiber), line 1884 (`sessions.delete(context.session.threadId)` cleanup only for sessions in map). git_grep for `sessions.has` returned no results, confirming no duplicate check exists.
      @@ -0,0 +162,21 @@
      162+ const parsed = Date.parse(value);
      163+ if (Number.isNaN(parsed)) {
      164+ return value;
      165+ }
      166+ return new Intl.DateTimeFormat(undefined, {
      167+ month: "short",
      168+ day: "numeric",
      169+ hour: "numeric",
      170+ minute: "2-digit",
      171+ }).format(parsed);
      172+}
      173+
      174+function formatRelativeTime(iso: string): string {
      175+ const diff = Date.now() - new Date(iso).getTime();
      176+ const minutes = Math.floor(diff / 60_000);
      177+ if (minutes < 1) return "just now";
      178+ if (minutes < 60) return `${minutes}m ago`;
      179+ const hours = Math.floor(minutes / 60);
      180+ if (hours < 24) return `${hours}h ago`;
      181+ return `${Math.floor(hours / 24)}d ago`;
      182+}
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟢 Low chat/AgentTeamsPanel.tsx:174

      When formatRelativeTime receives an invalid date string (e.g., empty string or malformed), new Date(iso).getTime() returns NaN. Since NaN < 1, NaN < 60, and NaN < 24 are all false, the function falls through to return "NaNd ago". Consider adding a Number.isNaN guard to match the pattern used in formatTimestamp.

      function formatRelativeTime(iso: string): string {
      +  const time = new Date(iso).getTime();
      +  if (Number.isNaN(time)) return iso;
      +  const diff = Date.now() - time;
      -  const diff = Date.now() - new Date(iso).getTime();
         const minutes = Math.floor(diff / 60_000);
      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file apps/web/src/components/chat/AgentTeamsPanel.tsx around lines 174-182:
      
      When `formatRelativeTime` receives an invalid date string (e.g., empty string or malformed), `new Date(iso).getTime()` returns `NaN`. Since `NaN < 1`, `NaN < 60`, and `NaN < 24` are all `false`, the function falls through to return `"NaNd ago"`. Consider adding a `Number.isNaN` guard to match the pattern used in `formatTimestamp`.
      
      Evidence trail:
      apps/web/src/components/chat/AgentTeamsPanel.tsx lines 160-181 at REVIEWED_COMMIT: `formatTimestamp` (lines 160-171) has `Number.isNaN` guard at line 162-164, while `formatRelativeTime` (lines 173-181) lacks this guard. JavaScript specification: NaN comparisons with any number return false, causing the function to fall through all conditionals.
      @@ -0,0 +261,21 @@
      261+ const agentColor =
      262+ asTrimmedString(value?.agent_color) ??
      263+ asTrimmedString(value?.agentColor) ??
      264+ asTrimmedString(
      265+ value?.routing && typeof value.routing === "object"
      266+ ? (value.routing as Record<string, unknown>).senderColor
      267+ : undefined,
      268+ );
      269+ const agentType = asTrimmedString(value?.agent_type) ?? asTrimmedString(value?.agentType);
      270+ const teamName = asTrimmedString(value?.team_name) ?? asTrimmedString(value?.teamName);
      271+ const teammateName =
      272+ asTrimmedString(value?.teammate_name) ?? asTrimmedString(value?.teammateName);
      273+ const parentSessionId =
      274+ asTrimmedString(value?.parent_session_id) ?? asTrimmedString(value?.parentSessionId);
      275+ const teammateMode =
      276+ asTrimmedString(value?.teammate_mode) ?? asTrimmedString(value?.teammateMode);
      277+ const toolUseId = asTrimmedString(value?.tool_use_id) ?? asTrimmedString(value?.toolUseId);
      278+ const planModeRequired =
      279+ asBoolean(value?.plan_mode_required) ?? asBoolean(value?.planModeRequired);
      280+ const awaitingLeaderApproval =
      281+ asBoolean(value?.awaitingLeaderApproval) ?? asBoolean(value?.awaiting_leader_approval);
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟢 Low Layers/ClaudeCodeAdapter.ts:280

      The property access order for awaitingLeaderApproval at line 280 is inverted: it checks camelCase first (value?.awaitingLeaderApproval) then falls back to snake_case, while every other field checks snake_case first. If input contains both naming conventions with different values, this field resolves to a different value than all others.

      -  const awaitingLeaderApproval =
      -    asBoolean(value?.awaitingLeaderApproval) ?? asBoolean(value?.awaiting_leader_approval);
      +  const awaitingLeaderApproval =
      +    asBoolean(value?.awaiting_leader_approval) ?? asBoolean(value?.awaitingLeaderApproval);
      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file apps/server/src/provider/Layers/ClaudeCodeAdapter.ts around lines 280-281:
      
      The property access order for `awaitingLeaderApproval` at line 280 is inverted: it checks `camelCase` first (`value?.awaitingLeaderApproval`) then falls back to `snake_case`, while every other field checks `snake_case` first. If input contains both naming conventions with different values, this field resolves to a different value than all others.
      
      Evidence trail:
      apps/server/src/provider/Layers/ClaudeCodeAdapter.ts lines 270-281 at REVIEWED_COMMIT showing:
      - Lines 270-279: All other fields check snake_case first, then camelCase (e.g., `value?.team_name ?? value?.teamName`)
      - Lines 280-281: `awaitingLeaderApproval` checks camelCase first, then snake_case (`value?.awaitingLeaderApproval ?? value?.awaiting_leader_approval`)
      @@ -607,0 +925,21 @@
      925+ ? { statusSource: asTrimmedString(payload?.statusSource)! }
      926+ : existing?.statusSource
      927+ ? { statusSource: existing.statusSource }
      928+ : {}),
      929+ ...(asTrimmedString(payload?.teamName)
      930+ ? { teamName: asTrimmedString(payload?.teamName)! }
      931+ : existing?.teamName
      932+ ? { teamName: existing.teamName }
      933+ : {}),
      934+ ...(asTrimmedString(payload?.teammateMode)
      935+ ? { teammateMode: asTrimmedString(payload?.teammateMode)! }
      936+ : existing?.teammateMode
      937+ ? { teammateMode: existing.teammateMode }
      938+ : {}),
      939+ ...(members && members.length > 0 ? { members } : {}),
      940+ ...(tasks && tasks.length > 0 ? { tasks } : {}),
      941+ };
      942+ byRunId.set(runId, snapshot);
      943+ if (teamKey) {
      944+ byTeamKey.set(teamKey, snapshot);
      945+ }
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟢 Low src/session-logic.ts:943

      When a runId's teamKey changes from "A" to "B" across activities, line 944 only sets byTeamKey.set("B", snapshot) without removing the stale entry for "A". The old byTeamKey.get("A") still returns the outdated snapshot, leaving the index in an inconsistent state where both keys reference different versions of the same run. Consider deleting the old teamKey entry when it differs from the current one, or rebuild the index differently.

      -    if (teamKey) {
      +    if (teamKey && teamKey !== existing?.teamKey) {
      +      if (existing?.teamKey) {
      +        byTeamKey.delete(existing.teamKey);
      +      }
             byTeamKey.set(teamKey, snapshot);
           }
      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file apps/web/src/session-logic.ts around lines 943-945:
      
      When a `runId`'s `teamKey` changes from "A" to "B" across activities, line 944 only sets `byTeamKey.set("B", snapshot)` without removing the stale entry for "A". The old `byTeamKey.get("A")` still returns the outdated snapshot, leaving the index in an inconsistent state where both keys reference different versions of the same run. Consider deleting the old `teamKey` entry when it differs from the current one, or rebuild the index differently.
      
      Evidence trail:
      apps/web/src/session-logic.ts lines 830-835 (Map creation and teamKey determination), lines 942-945 (setting entries without deleting old teamKey). The existing?.teamKey is retrieved at line 835 but there's no comparison or deletion of the old key when teamKey changes before lines 942-945.
      @@ -0,0 +396,21 @@
      396+ ) {
      397+ return "command_execution";
      398+ }
      399+ if (
      400+ normalized.includes("edit") ||
      401+ normalized.includes("write") ||
      402+ normalized.includes("file") ||
      403+ normalized.includes("patch") ||
      404+ normalized.includes("replace") ||
      405+ normalized.includes("create") ||
      406+ normalized.includes("delete")
      407+ ) {
      408+ return "file_change";
      409+ }
      410+ if (normalized.includes("mcp")) {
      411+ return "mcp_tool_call";
      412+ }
      413+ return "dynamic_tool_call";
      414+}
      415+
      416+function classifyRequestType(toolName: string): CanonicalRequestType {
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟢 Low Layers/ClaudeCodeAdapter.ts:416

      classifyRequestType returns "file_change_approval" as the fallback for any tool that isn't a read operation or command execution. This incorrectly classifies MCP tools, collab agent tools, and dynamic tool calls as file change approvals. For example, a tool named "mcp_weather" gets classifyToolItemType return of "mcp_tool_call", which is not "command_execution", so classifyRequestType returns "file_change_approval" — semantically incorrect since an MCP weather call is not a file change. Consider adding explicit cases for MCP tools and collab agent tools, or mapping each CanonicalItemType to its corresponding CanonicalRequestType instead of defaulting to file change approval.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file apps/server/src/provider/Layers/ClaudeCodeAdapter.ts around line 416:
      
      `classifyRequestType` returns `"file_change_approval"` as the fallback for any tool that isn't a read operation or command execution. This incorrectly classifies MCP tools, collab agent tools, and dynamic tool calls as file change approvals. For example, a tool named `"mcp_weather"` gets `classifyToolItemType` return of `"mcp_tool_call"`, which is not `"command_execution"`, so `classifyRequestType` returns `"file_change_approval"` — semantically incorrect since an MCP weather call is not a file change. Consider adding explicit cases for MCP tools and collab agent tools, or mapping each `CanonicalItemType` to its corresponding `CanonicalRequestType` instead of defaulting to file change approval.
      
      Evidence trail:
      apps/server/src/provider/Layers/ClaudeCodeAdapter.ts lines 375-424 (REVIEWED_COMMIT): `classifyToolItemType` returns "mcp_tool_call" for tools containing "mcp" and "collab_agent_tool_call" for team/agent tools. `classifyRequestType` (lines 417-424) only checks for "command_execution" and falls back to "file_change_approval" for all other types, including "mcp_tool_call", "collab_agent_tool_call", and "dynamic_tool_call".
      @@ -392,0 +599,21 @@
      599+ provider: CLAUDE_PROVIDER,
      600+ status: "error" as const,
      601+ available: false,
      602+ authStatus: "unknown" as const,
      603+ checkedAt,
      604+ ...(parsedVersion ? { version: parsedVersion } : {}),
      605+ message: detail
      606+ ? `Claude Code runtime is installed but failed to run. ${detail}`
      607+ : "Claude Code runtime is installed but failed to run.",
      608+ capabilities: {
      609+ agentTeams: buildClaudeAgentTeamsCapability(parsedVersion),
      610+ },
      611+ };
      612+ }
      613+
      614+ const authProbe = yield* runClaudeCommand(["auth", "status", "--json"]).pipe(
      615+ Effect.timeoutOption(DEFAULT_TIMEOUT_MS),
      616+ Effect.result,
      617+ );
      618+
      619+ if (Result.isFailure(authProbe)) {
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High Layers/ProviderHealth.ts:619

      When the auth probe fails or times out, checkClaudeProviderStatus returns a ServerProviderStatus that omits the capabilities field, while all other return paths include it. Since parsedVersion is already extracted at line 595, the capabilities object can be populated in these branches as well.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file apps/server/src/provider/Layers/ProviderHealth.ts around line 619:
      
      When the auth probe fails or times out, `checkClaudeProviderStatus` returns a `ServerProviderStatus` that omits the `capabilities` field, while all other return paths include it. Since `parsedVersion` is already extracted at line 595, the capabilities object can be populated in these branches as well.
      
      Evidence trail:
      apps/server/src/provider/Layers/ProviderHealth.ts lines 595, 619-631, 634-643, 562-577, 579-592, 596-612, 645-657 (at REVIEWED_COMMIT). packages/contracts/src/server.ts lines 56-66 for ServerProviderStatus schema definition.
      @@ -26,3 +28,10 @@
      2628
      2729 const DEFAULT_TIMEOUT_MS = 4_000;
      2830 const CODEX_PROVIDER = "codex" as const;
      31+const CLAUDE_PROVIDER = "claudeCode" as const;
      32+const MIN_CLAUDE_AGENT_TEAMS_VERSION = "2.1.32";
      33+const require = createRequire(import.meta.url);
      34+export const CLAUDE_CLI_PATH = path.join(
      35+ path.dirname(require.resolve("@anthropic-ai/claude-agent-sdk")),
      36+ "cli.js",
      37+);
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Layers/ProviderHealth.ts:34

      CLAUDE_CLI_PATH is evaluated at module load time via require.resolve, so a missing @anthropic-ai/claude-agent-sdk package throws before checkClaudeProviderStatus runs and causes the entire server process to crash. The error handling that reports "Claude Code runtime is not available" is unreachable because the module fails to load first. Consider wrapping the resolution in a try/catch or moving it into checkClaudeProviderStatus so the health check can gracefully report the provider as unavailable.

      -export const CLAUDE_CLI_PATH = path.join(
      -  path.dirname(require.resolve("@anthropic-ai/claude-agent-sdk")),
      -  "cli.js",
      -);
      +export let CLAUDE_CLI_PATH: string | undefined;
      +try {
      +  CLAUDE_CLI_PATH = path.join(
      +    path.dirname(require.resolve("@anthropic-ai/claude-agent-sdk")),
      +    "cli.js",
      +  );
      +} catch {
      +  CLAUDE_CLI_PATH = undefined;
      +}
      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file apps/server/src/provider/Layers/ProviderHealth.ts around lines 34-37:
      
      `CLAUDE_CLI_PATH` is evaluated at module load time via `require.resolve`, so a missing `@anthropic-ai/claude-agent-sdk` package throws before `checkClaudeProviderStatus` runs and causes the entire server process to crash. The error handling that reports "Claude Code runtime is not available" is unreachable because the module fails to load first. Consider wrapping the resolution in a try/catch or moving it into `checkClaudeProviderStatus` so the health check can gracefully report the provider as unavailable.
      
      Evidence trail:
      apps/server/src/provider/Layers/ProviderHealth.ts lines 32-35: `const require = createRequire(import.meta.url); export const CLAUDE_CLI_PATH = path.join(path.dirname(require.resolve("@anthropic-ai/claude-agent-sdk")), "cli.js");` - module-level code that calls require.resolve at load time.
      
      apps/server/src/provider/Layers/ProviderHealth.ts lines 455-466: `checkClaudeProviderStatus` contains the error handling that reports "Claude Code runtime is not available" but this code is unreachable if the module fails to load.
      
      Node.js documentation on require.resolve: throws MODULE_NOT_FOUND if the module cannot be found.
    5. we should find a more generic solution to subagent as a whole. this is currently very claude focus and we'd like the frontend to be as agnostic as possible

    6. Can you share some screenshots/videos of how your implementation looks?

    7. maria-rcks assignedJustYannicc

    8. i will work on the implementation to make it compatible with claudes sub agents and teams, as well as codex's sub agents

    9. Closing as part of an open-PR triage — main has moved a lot since this was opened (the branch conflicts and the files it touches have been substantially reworked), so it's no longer reviewable as-is. If you're still interested, please feel free to resubmit against current main. Thanks!

    10. juliusmarminge closed this

Sign in to join this conversation.