Repository navigation
Conversation
There was a problem hiding this comment.
This repository has used its 100 free open-source review credits for this billing period. An organization admin can enable additional billed reviews, or reviews resume next period.
📝 WalkthroughWalkthroughAdds subagent panes to the workspace dashboard, including pane state, placement and stacking, chat-history resolution, rendering, titles, registry integration, and automatic opening from active chat subagents. ChangesSubagent pane placement
Subagent resolution and rendering
Chat auto-open wiring
Estimated code review effort: 4 (Complex) | ~45 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useAutoOpenSubagentPanes/useAutoOpenSubagentPanes.ts (1)
1-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDeep relative imports instead of tsconfig path aliases across the new subagent-pane wiring. As per coding guidelines,
apps/desktop/**/*.{ts,tsx}should "Use the path aliases defined in tsconfig.json whenever possible." Several new/changed files reach the sharedtypes.ts/utilsmodules via long relative chains (up to 6 levels) instead of an alias, which breaks silently on file moves. Same root cause at every site below.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useAutoOpenSubagentPanes/useAutoOpenSubagentPanes.ts#L1-L6: replace../../../../../../typesand../../../../../../utils/openSubagentPanewith the tsconfig alias equivalents.apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/ChatPane.tsx#L1-L4: replace../../../../typeswith the alias.apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/WorkspaceChatInterface/types.ts#L1-L4: replace../../../../../../typeswith the alias.apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/openSubagentPane/openSubagentPane.ts#L7-L7: replace../../typeswith the alias.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useAutoOpenSubagentPanes/useAutoOpenSubagentPanes.ts around lines 1 - 6, Replace the deep relative imports with the configured tsconfig path aliases for shared types and openSubagentPane. Apply this in useAutoOpenSubagentPanes.ts, ChatPane.tsx, WorkspaceChatInterface/types.ts, and utils/openSubagentPane/openSubagentPane.ts, preserving the imported symbols and behavior.Source: Coding guidelines
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/openSubagentPane/openSubagentPane.test.ts (1)
117-143: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winStrengthen the "focuses an existing pane" test to assert the actual focus side effect.
This test checks the return value (
"focused") and pane count, but never assertstab.activePaneId/activeTabIdafter the second call. Given the "existing pane" branch's focus behavior is exactly what's implicated in the auto-open focus-stealing concern (seeuseAutoOpenSubagentPanes.ts), adding an assertion here would guard against regressions in either direction.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/utils/openSubagentPane/openSubagentPane.test.ts around lines 117 - 143, Strengthen the existing “focuses an existing pane” test around the second openSubagentPane call by asserting the tab’s activePaneId and the workspace’s activeTabId reflect the existing pane and tab after the call. Preserve the current return-value and single-pane assertions.apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/utils/resolveSubagentEntries/resolveSubagentEntries.test.ts (1)
31-62: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the
isErrorbranch.Tests cover the "completed" message-history path but not
isError: true, which drives theerror/"Failed" status shown in the UI. Worth adding a case to lock in that behavior.✅ Suggested additional test
it("marks the subagent as errored when the tool result failed", () => { const entries = resolveSubagentEntries({ toolCallId: "tool-4", activeSubagents: new Map(), messages: [ { id: "msg-2", role: "assistant", content: [ { type: "tool_call", id: "tool-4", name: "subagent", args: { task: "Explore", agentType: "explore" }, }, { type: "tool_result", id: "tool-4", result: "Not logged in", isError: true, }, ], createdAt: new Date(), }, ] as never, fallback: {}, }); expect((entries[0]?.[1] as { status: string }).status).toBe("error"); expect((entries[0]?.[1] as { error?: string }).error).toBe( "Not logged in", ); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/hooks/usePaneRegistry/components/SubagentPane/utils/resolveSubagentEntries/resolveSubagentEntries.test.ts around lines 31 - 62, Add a test alongside the existing “falls back to message history” case in resolveSubagentEntries tests that supplies a failed tool_result with isError: true, then assert the returned entry has status "error" and preserves the result text in its error field.apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/SubagentPane.tsx (1)
4-5: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPromote
ChatPane's subagent rendering/hook out ofChatPane— now used by 2+ sibling panes.SubagentExecutionMessage,toSubagentViewModels, anduseWorkspaceChatDisplayare all still nested underChatPane/..., butSubagentPaneandSubagentPaneTitlenow depend on them too, creating fragile coupling across pane-module boundaries.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/SubagentPane.tsx#L4-L5: importSubagentExecutionMessage/useChatDisplayfrom their new shared location instead of../ChatPane/....apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/utils/resolveSubagentEntries/resolveSubagentEntries.ts#L3-L7: same fortoSubagentViewModels/UseChatDisplayReturn.apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/components/SubagentPaneTitle/SubagentPaneTitle.tsx#L5: same foruseChatDisplay.As per path instructions: "Co-locate components, hooks, utilities, constants, configuration, tests, and stories with their usage; nest single-use items under the parent and promote items used two or more times to the highest shared parent." Relocate these to the shared parent directory (e.g.
usePaneRegistry/components/orusePaneRegistry/hooks/) and update the three import sites above.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/hooks/usePaneRegistry/components/SubagentPane/SubagentPane.tsx around lines 4 - 5, Promote SubagentExecutionMessage, toSubagentViewModels, useWorkspaceChatDisplay, and UseChatDisplayReturn from ChatPane into the shared usePaneRegistry parent, then update imports in apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/SubagentPane.tsx (lines 4-5), apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/utils/resolveSubagentEntries/resolveSubagentEntries.ts (lines 3-7), and apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/components/SubagentPaneTitle/SubagentPaneTitle.tsx (line 5) to use the new shared locations.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useAutoOpenSubagentPanes/useAutoOpenSubagentPanes.ts:
- Around line 70-85: The initialization logic in useAutoOpenSubagentPanes must
account for subagent panes that already exist before opening active entries, so
the initial effect does not refocus them. Reuse the pane registry’s
existing-pane lookup or non-focusing ensure-exists path to mark existing
toolCallIds without calling the focusing openSubagentPane; only genuinely new
subagents should be opened and focused.
---
Nitpick comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useAutoOpenSubagentPanes/useAutoOpenSubagentPanes.ts:
- Around line 1-6: Replace the deep relative imports with the configured
tsconfig path aliases for shared types and openSubagentPane. Apply this in
useAutoOpenSubagentPanes.ts, ChatPane.tsx, WorkspaceChatInterface/types.ts, and
utils/openSubagentPane/openSubagentPane.ts, preserving the imported symbols and
behavior.
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/hooks/usePaneRegistry/components/SubagentPane/SubagentPane.tsx:
- Around line 4-5: Promote SubagentExecutionMessage, toSubagentViewModels,
useWorkspaceChatDisplay, and UseChatDisplayReturn from ChatPane into the shared
usePaneRegistry parent, then update imports in
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/SubagentPane.tsx
(lines 4-5),
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/utils/resolveSubagentEntries/resolveSubagentEntries.ts
(lines 3-7), and
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/components/SubagentPaneTitle/SubagentPaneTitle.tsx
(line 5) to use the new shared locations.
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/hooks/usePaneRegistry/components/SubagentPane/utils/resolveSubagentEntries/resolveSubagentEntries.test.ts:
- Around line 31-62: Add a test alongside the existing “falls back to message
history” case in resolveSubagentEntries tests that supplies a failed tool_result
with isError: true, then assert the returned entry has status "error" and
preserves the result text in its error field.
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/utils/openSubagentPane/openSubagentPane.test.ts:
- Around line 117-143: Strengthen the existing “focuses an existing pane” test
around the second openSubagentPane call by asserting the tab’s activePaneId and
the workspace’s activeTabId reflect the existing pane and tab after the call.
Preserve the current return-value and single-pane assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 66665c87-6cda-43c9-b78d-6032683cef0c
📒 Files selected for processing (17)
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/ChatPane.tsxapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/WorkspaceChatInterface/ChatPaneInterface.tsxapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/components/WorkspaceChatInterface/types.tsapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useAutoOpenSubagentPanes/index.tsapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/hooks/useAutoOpenSubagentPanes/useAutoOpenSubagentPanes.tsapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/SubagentPane.tsxapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/components/SubagentPaneTitle/SubagentPaneTitle.tsxapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/components/SubagentPaneTitle/index.tsapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/index.tsapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/utils/resolveSubagentEntries/index.tsapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/utils/resolveSubagentEntries/resolveSubagentEntries.test.tsapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/SubagentPane/utils/resolveSubagentEntries/resolveSubagentEntries.tsapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/usePaneRegistry.tsxapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/types.tsapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/openSubagentPane/index.tsapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/openSubagentPane/openSubagentPane.test.tsapps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/openSubagentPane/openSubagentPane.ts
What & why
When a Mastra chat agent spawns subagents, their activity was only visible inline in the parent chat (or after navigating into nested tool UI). This adds automatic side panes so you can watch the parent and each subagent at once — first subagent opens to the right of the parent chat; later ones stack underneath that column.
subagentpane kind bound to{ parentSessionId, toolCallId }activeSubagentsentries (idempotent pertoolCallId)Addresses the “display subagent activity in a new pane” request (#5077).
How I tested it
openSubagentPane(open right / stack / focus existing)resolveSubagentEntries(live map vs message history vs fallback)+→ ChatChecklist
type(scope): subject)bun run lintandbun run typecheckpass (CI fails on lint warnings too)Summary by cubic
Chat subagents now open in stacked right panes so you can watch the parent chat and each subagent at the same time. First opens to the right; later ones stack in the same column, and we don’t refocus if the pane already exists. Addresses #5077.
subagentpane keyed by{ parentSessionId, toolCallId }with live updates and message-history fallback.activeSubagents; idempotent pertoolCallId; skips existing panes (no focus steal).useAutoOpenSubagentPanes,openSubagentPane, andSubagentPane/SubagentPaneTitlewith tests for open/stack/no-refocus and entry/title resolution.Written for commit d6b0db9. Summary will update on new commits.
Summary by CodeRabbit