Conversation
- Refactor `mapToToolState` function to use arrow function syntax in `tool-part-transform.ts`. - Update agent model display logic in `agent-details.tsx` to handle different data types. - Improve tools rendering logic in `agent-tab.tsx` to ensure proper display of tool names. - Modify `AgentToolsTab` to ensure tools are correctly processed as an array in `agent-tools-tab.tsx`. - Update exports in `index.ts` to correct the export name for `AgentTab`. - Remove unused `sql.ts` file from `mastra/agents`. - Add `governedRagIndex` workflow to `mastra/index.ts`. - Rename workflow IDs for consistency across multiple workflow files.
Learn moreAll Green is an AI agent that automatically: ✅ Addresses code review comments ✅ Fixes failing CI checks ✅ Resolves merge conflicts |
|
🤖 Hi @ssdeanx, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
Summary by CodeRabbitRelease Notes
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughThis PR normalizes workflow identifiers from kebab-case to camelCase across 14+ workflow files, removes the SQL agent module, adds the governedRagIndex workflow to Mastra configuration, and enhances agent dashboard components to handle both string and object shapes for models and tools. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 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 |
Summary of ChangesHello @ssdeanx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request streamlines and enhances various agent-related functionalities, primarily focusing on improving the user interface for agent details and tools, modernizing underlying code structures, and refining workflow definitions. These changes aim to provide a more consistent and robust experience for managing agents and their associated workflows, including the addition of a new indexing workflow and the removal of deprecated components. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
🤖 I'm sorry @ssdeanx, but I was unable to process your request. Please see the logs for more details. |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
src/mastra/index.ts (1)
91-112: governedRagIndex registration matches existing pattern; be aware of newly exposed workflow.Importing and wiring
governedRagIndexinto theworkflowsmap is consistent with the existing Mastra registration pattern, so this looks good. Now that this governed indexing workflow is reachable via the generic workflow API, just ensure your routing/runtime-context layer enforces the intended tenant/role constraints for who can index documents with specific classifications andallowedRoles.src/mastra/workflows/governed-rag-index.workflow.ts (1)
132-159: Id/name alignment looks good; verify callers and consider RuntimeContext-based guardrails.Setting the workflow
idto'governedRagIndex'matches the exported constant and the new registration inmastra/index.ts, which is tidy. As with the other id renames, please confirm no external clients still expect'governed-rag-index'. Also, given this workflow indexes documents withclassification,allowedRoles, andtenant, consider threadingrequestContextinto the step and enforcing any role/tenant checks there if you’re not already doing so upstream.app/chat/helpers/tool-part-transform.ts (1)
131-167: Unnecessary refactor from function declaration to arrow function.This change from a function declaration to an arrow function is purely stylistic and provides no functional benefit. The function is a local helper that's defined before use, so hoisting is not a concern. This type of change adds noise to the PR without improving readability, maintainability, or correctness.
Consider reverting this change to keep the PR focused on meaningful improvements.
app/dashboard/agents/_components/agent-tab.tsx (1)
49-49: Type safety violation with 'as any' casts.Using
(agent.model as any)bypasses TypeScript's type checking and can lead to runtime errors if the model structure doesn't match expectations. This is inconsistent with the defensive coding approach used elsewhere in this file (e.g., lines 65, 70).Apply a similar defensive approach as used in
agent-details.tsx:- <Badge variant="outline">{(agent.model as any).provider}/{(agent.model as any).name}</Badge> + <Badge variant="outline"> + {typeof agent.model === "string" + ? agent.model + : `${agent.model.provider}${agent.model.name ? ` / ${agent.model.name}` : ""}`} + </Badge>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (21)
app/chat/helpers/tool-part-transform.ts(2 hunks)app/dashboard/agents/_components/agent-details.tsx(2 hunks)app/dashboard/agents/_components/agent-tab.tsx(1 hunks)app/dashboard/agents/_components/agent-tools-tab.tsx(2 hunks)app/dashboard/agents/_components/index.ts(1 hunks)src/mastra/agents/sql.ts(0 hunks)src/mastra/index.ts(2 hunks)src/mastra/workflows/changelog.ts(1 hunks)src/mastra/workflows/content-review-workflow.ts(1 hunks)src/mastra/workflows/content-studio-workflow.ts(1 hunks)src/mastra/workflows/document-processing-workflow.ts(1 hunks)src/mastra/workflows/financial-report-workflow.ts(1 hunks)src/mastra/workflows/governed-rag-answer.workflow.ts(1 hunks)src/mastra/workflows/governed-rag-index.workflow.ts(1 hunks)src/mastra/workflows/learning-extraction-workflow.ts(1 hunks)src/mastra/workflows/repo-ingestion-workflow.ts(1 hunks)src/mastra/workflows/research-synthesis-workflow.ts(1 hunks)src/mastra/workflows/spec-generation-workflow.ts(1 hunks)src/mastra/workflows/stock-analysis-workflow.ts(1 hunks)src/mastra/workflows/telephone-game.ts(1 hunks)src/mastra/workflows/weather-workflow.ts(1 hunks)
💤 Files with no reviewable changes (1)
- src/mastra/agents/sql.ts
🧰 Additional context used
📓 Path-based instructions (16)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
**/*.{js,jsx,ts,tsx}: Usenext/dynamicfor dynamic imports to load components only when needed, improving initial load time.
Usenext/imagecomponent for automatic image optimization, including lazy loading and responsive images.
Use React.memo to prevent unnecessary re-renders of components.
Use the<Link prefetch>tag to prefetch pages that are likely to be visited.
Use getServerSideProps, getStaticProps, or server components for fetching data on the server-side.
Use SWR or React Query for client-side data fetching and caching.
Use CSS Modules, Styled Components, or Tailwind CSS for component-level styling. Prefer Tailwind CSS for rapid development.
Use React Context, Zustand, Jotai, or Recoil for managing global state. Avoid Redux unless necessary.
Usereact-hook-formfor managing forms and validation.
Only fetch the data that is needed by the component to avoid over-fetching.
Avoid long-running synchronous operations in the main thread to prevent blocking.
Always usesetStateor hooks to update state instead of mutating state directly.
Include a complete dependency array inuseEffecthooks to prevent unexpected behavior.
Avoid writing server-side code in client components to prevent exposing secrets or causing unexpected behavior.
Usetry...catchblocks for handling errors in asynchronous operations.
Implement error boundary components usinggetDerivedStateFromErrororcomponentDidCatchlifecycle methods.
Sanitize user input to prevent Cross-Site Scripting (XSS) attacks. Be especially careful when rendering HTML directly from user input.
Store authentication tokens in HTTP-only cookies or local storage securely.
Implement role-based access control to restrict access to sensitive resources.
Clean up event listeners and timers inuseEffecthooks to avoid memory leaks.
Only update state when necessary to reduce the number of re-renders and improve performance.
Use immutable data structures and avoid mutating data directly to prevent unexpected...
Files:
src/mastra/workflows/content-review-workflow.tsapp/dashboard/agents/_components/agent-tab.tsxsrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/learning-extraction-workflow.tssrc/mastra/index.tssrc/mastra/workflows/governed-rag-answer.workflow.tsapp/dashboard/agents/_components/index.tsapp/dashboard/agents/_components/agent-details.tsxsrc/mastra/workflows/document-processing-workflow.tssrc/mastra/workflows/weather-workflow.tssrc/mastra/workflows/changelog.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/workflows/stock-analysis-workflow.tsapp/dashboard/agents/_components/agent-tools-tab.tsxsrc/mastra/workflows/content-studio-workflow.tsapp/chat/helpers/tool-part-transform.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/workflows/governed-rag-index.workflow.tssrc/mastra/workflows/spec-generation-workflow.tssrc/mastra/workflows/research-synthesis-workflow.ts
**/*.{js,ts}
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Use parameterized queries or an ORM to prevent SQL injection attacks.
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/learning-extraction-workflow.tssrc/mastra/index.tssrc/mastra/workflows/governed-rag-answer.workflow.tsapp/dashboard/agents/_components/index.tssrc/mastra/workflows/document-processing-workflow.tssrc/mastra/workflows/weather-workflow.tssrc/mastra/workflows/changelog.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/workflows/stock-analysis-workflow.tssrc/mastra/workflows/content-studio-workflow.tsapp/chat/helpers/tool-part-transform.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/workflows/governed-rag-index.workflow.tssrc/mastra/workflows/spec-generation-workflow.tssrc/mastra/workflows/research-synthesis-workflow.ts
src/mastra/{tools,workflows}/**/*.ts
📄 CodeRabbit inference engine (src/mastra/AGENTS.md)
Use
RuntimeContextto enforce access control in tools and workflows
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/learning-extraction-workflow.tssrc/mastra/workflows/governed-rag-answer.workflow.tssrc/mastra/workflows/document-processing-workflow.tssrc/mastra/workflows/weather-workflow.tssrc/mastra/workflows/changelog.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/workflows/stock-analysis-workflow.tssrc/mastra/workflows/content-studio-workflow.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/workflows/governed-rag-index.workflow.tssrc/mastra/workflows/spec-generation-workflow.tssrc/mastra/workflows/research-synthesis-workflow.ts
src/mastra/workflows/**/*.ts
📄 CodeRabbit inference engine (src/mastra/AGENTS.md)
Add new workflow definitions under
src/mastra/workflowsto orchestrate multi-step flowsUse Mastra DSL for multi-step workflow definitions in src/mastra/workflows
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/learning-extraction-workflow.tssrc/mastra/workflows/governed-rag-answer.workflow.tssrc/mastra/workflows/document-processing-workflow.tssrc/mastra/workflows/weather-workflow.tssrc/mastra/workflows/changelog.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/workflows/stock-analysis-workflow.tssrc/mastra/workflows/content-studio-workflow.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/workflows/governed-rag-index.workflow.tssrc/mastra/workflows/spec-generation-workflow.tssrc/mastra/workflows/research-synthesis-workflow.ts
**/*.{ts,tsx,js,jsx,py,java,cs,rb,go,rs,cpp,c,h,hpp,swift,kotlin,php,scala,clj,groovy,lua,sh,bash}
📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)
**/*.{ts,tsx,js,jsx,py,java,cs,rb,go,rs,cpp,c,h,hpp,swift,kotlin,php,scala,clj,groovy,lua,sh,bash}: Write code that speaks for itself. Comment only when necessary to explain WHY, not WHAT. Avoid obvious comments that state what the code literally does.
Avoid redundant comments that simply repeat what the code is doing
Keep comments accurate and up-to-date with code changes. Remove or update outdated comments that no longer match the implementation.
Write comments for complex business logic that explain the WHY behind specific calculations or business rules
Document non-obvious algorithms with comments explaining the algorithm choice and its reasoning
Add comments explaining what regex patterns match, especially for complex patterns
Document API constraints, rate limits, gotchas, and external dependencies with explanatory comments
Avoid commenting out dead code. Use version control instead of maintaining commented code blocks.
Do not maintain code change history or modification logs as comments. Rely on git history and commit messages instead.
Avoid decorative divider comments (e.g., lines of equals signs or asterisks) for section separation
Ensure comments are placed appropriately above or adjacent to the code they describe
Write comments using proper grammar, spelling, and professional language
Prefer self-documenting code with clear variable/function names over adding comments to explain unclear code
Files:
src/mastra/workflows/content-review-workflow.tsapp/dashboard/agents/_components/agent-tab.tsxsrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/learning-extraction-workflow.tssrc/mastra/index.tssrc/mastra/workflows/governed-rag-answer.workflow.tsapp/dashboard/agents/_components/index.tsapp/dashboard/agents/_components/agent-details.tsxsrc/mastra/workflows/document-processing-workflow.tssrc/mastra/workflows/weather-workflow.tssrc/mastra/workflows/changelog.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/workflows/stock-analysis-workflow.tsapp/dashboard/agents/_components/agent-tools-tab.tsxsrc/mastra/workflows/content-studio-workflow.tsapp/chat/helpers/tool-part-transform.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/workflows/governed-rag-index.workflow.tssrc/mastra/workflows/spec-generation-workflow.tssrc/mastra/workflows/research-synthesis-workflow.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)
**/*.{ts,tsx,js,jsx}: Document public APIs with TSDoc/JSDoc comments including parameter descriptions, return types, examples, and thrown exceptions
Add TSDoc comments to configuration constants and environment variables explaining their source, reasoning, or constraints
Use TSDoc annotation tags (TODO, FIXME, HACK, NOTE, WARNING, PERF, SECURITY, BUG, REFACTOR, DEPRECATED) to mark special comments
Include file headers with @fileoverview, @author, @copyright, and @license tags to document file purpose and ownership
Document function parameters with @param tags, return values with @returns tags, and exceptions with @throws tags in TSDoc comments
Use @see tags in TSDoc comments to reference related functions, methods, or documentation
Include @example tags in public API documentation with code examples showing typical usage
**/*.{ts,tsx,js,jsx}: Use Mastra mcp tools (#mastradocs,#mastraChanges,#mastraexamples,#mastraBlog) for Mastra framework development to stay updated with latest features and best practices
When working with Next.js projects, always utilize thenext-devtools-mcpserver for all Next.js related queries
Files:
src/mastra/workflows/content-review-workflow.tsapp/dashboard/agents/_components/agent-tab.tsxsrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/learning-extraction-workflow.tssrc/mastra/index.tssrc/mastra/workflows/governed-rag-answer.workflow.tsapp/dashboard/agents/_components/index.tsapp/dashboard/agents/_components/agent-details.tsxsrc/mastra/workflows/document-processing-workflow.tssrc/mastra/workflows/weather-workflow.tssrc/mastra/workflows/changelog.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/workflows/stock-analysis-workflow.tsapp/dashboard/agents/_components/agent-tools-tab.tsxsrc/mastra/workflows/content-studio-workflow.tsapp/chat/helpers/tool-part-transform.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/workflows/governed-rag-index.workflow.tssrc/mastra/workflows/spec-generation-workflow.tssrc/mastra/workflows/research-synthesis-workflow.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)
**/*.{ts,tsx}: Document interface and type definitions with TSDoc comments explaining their purpose and usage context
Document interface properties with /** */ comments explaining each field's purpose and constraints
Document generic type parameters with @template tags explaining what each type parameter represents
Use type guards with comments explaining the runtime validation logic being performed
Document advanced/complex TypeScript types with explanatory comments about their purpose and use cases
Files:
src/mastra/workflows/content-review-workflow.tsapp/dashboard/agents/_components/agent-tab.tsxsrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/learning-extraction-workflow.tssrc/mastra/index.tssrc/mastra/workflows/governed-rag-answer.workflow.tsapp/dashboard/agents/_components/index.tsapp/dashboard/agents/_components/agent-details.tsxsrc/mastra/workflows/document-processing-workflow.tssrc/mastra/workflows/weather-workflow.tssrc/mastra/workflows/changelog.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/workflows/stock-analysis-workflow.tsapp/dashboard/agents/_components/agent-tools-tab.tsxsrc/mastra/workflows/content-studio-workflow.tsapp/chat/helpers/tool-part-transform.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/workflows/governed-rag-index.workflow.tssrc/mastra/workflows/spec-generation-workflow.tssrc/mastra/workflows/research-synthesis-workflow.ts
src/mastra/**/*
📄 CodeRabbit inference engine (src/AGENTS.md)
mastramodules can import fromutils, but must not import fromapporcli(excepttypes)
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/learning-extraction-workflow.tssrc/mastra/index.tssrc/mastra/workflows/governed-rag-answer.workflow.tssrc/mastra/workflows/document-processing-workflow.tssrc/mastra/workflows/weather-workflow.tssrc/mastra/workflows/changelog.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/workflows/stock-analysis-workflow.tssrc/mastra/workflows/content-studio-workflow.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/workflows/governed-rag-index.workflow.tssrc/mastra/workflows/spec-generation-workflow.tssrc/mastra/workflows/research-synthesis-workflow.ts
**/*.{css,tsx,ts}
📄 CodeRabbit inference engine (AGENTS.md)
Use Tailwind CSS 4 with oklch color variables for styling
Files:
src/mastra/workflows/content-review-workflow.tsapp/dashboard/agents/_components/agent-tab.tsxsrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/learning-extraction-workflow.tssrc/mastra/index.tssrc/mastra/workflows/governed-rag-answer.workflow.tsapp/dashboard/agents/_components/index.tsapp/dashboard/agents/_components/agent-details.tsxsrc/mastra/workflows/document-processing-workflow.tssrc/mastra/workflows/weather-workflow.tssrc/mastra/workflows/changelog.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/workflows/stock-analysis-workflow.tsapp/dashboard/agents/_components/agent-tools-tab.tsxsrc/mastra/workflows/content-studio-workflow.tsapp/chat/helpers/tool-part-transform.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/workflows/governed-rag-index.workflow.tssrc/mastra/workflows/spec-generation-workflow.tssrc/mastra/workflows/research-synthesis-workflow.ts
src/mastra/{tools,agents,workflows}/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use Zod schemas for strict input/output validation in tools, agents, and workflows
Files:
src/mastra/workflows/content-review-workflow.tssrc/mastra/workflows/telephone-game.tssrc/mastra/workflows/learning-extraction-workflow.tssrc/mastra/workflows/governed-rag-answer.workflow.tssrc/mastra/workflows/document-processing-workflow.tssrc/mastra/workflows/weather-workflow.tssrc/mastra/workflows/changelog.tssrc/mastra/workflows/repo-ingestion-workflow.tssrc/mastra/workflows/stock-analysis-workflow.tssrc/mastra/workflows/content-studio-workflow.tssrc/mastra/workflows/financial-report-workflow.tssrc/mastra/workflows/governed-rag-index.workflow.tssrc/mastra/workflows/spec-generation-workflow.tssrc/mastra/workflows/research-synthesis-workflow.ts
**/app/**
📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Use the
app/directory structure for route handlers, server components, and client components (Next.js 13+). Prefer this over thepages/directory for new projects.
Files:
app/dashboard/agents/_components/agent-tab.tsxapp/dashboard/agents/_components/index.tsapp/dashboard/agents/_components/agent-details.tsxapp/dashboard/agents/_components/agent-tools-tab.tsxapp/chat/helpers/tool-part-transform.ts
app/**/*.{tsx,ts}
📄 CodeRabbit inference engine (app/AGENTS.md)
app/**/*.{tsx,ts}: Use Tailwind CSS 4 with oklch color variables for styling in Next.js App Router pages and layouts
Use React 19 latest features in component implementations within the app directory
Files:
app/dashboard/agents/_components/agent-tab.tsxapp/dashboard/agents/_components/index.tsapp/dashboard/agents/_components/agent-details.tsxapp/dashboard/agents/_components/agent-tools-tab.tsxapp/chat/helpers/tool-part-transform.ts
app/dashboard/**/*.{ts,tsx}
📄 CodeRabbit inference engine (app/dashboard/AGENTS.md)
app/dashboard/**/*.{ts,tsx}: Use custom React hooks fromlib/hooks/use-mastra.tsto wrap MastraClient for data fetching (e.g.,useAgents(),useAgent(id),useWorkflows(),useTools(), etc.) in dashboard pages
Use action hooks for dashboard mutations (e.g.,useExecuteTool(),useCreateMemoryThread(),useUpdateWorkingMemory(),useVectorQuery(),useScoreTraces()) instead of direct MastraClient calls
Files:
app/dashboard/agents/_components/agent-tab.tsxapp/dashboard/agents/_components/index.tsapp/dashboard/agents/_components/agent-details.tsxapp/dashboard/agents/_components/agent-tools-tab.tsx
app/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Frontend uses Next.js 16 App Router with React 19; use shadcn/ui base components (34 components) from ui/ directory
Files:
app/dashboard/agents/_components/agent-tab.tsxapp/dashboard/agents/_components/index.tsapp/dashboard/agents/_components/agent-details.tsxapp/dashboard/agents/_components/agent-tools-tab.tsxapp/chat/helpers/tool-part-transform.ts
app/**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Use @ai-sdk/react for streaming and AI interactions in React components
Files:
app/dashboard/agents/_components/agent-tab.tsxapp/dashboard/agents/_components/agent-details.tsxapp/dashboard/agents/_components/agent-tools-tab.tsx
src/mastra/index.ts
📄 CodeRabbit inference engine (src/AGENTS.md)
Enforce registration pattern in
mastra/index.tsfor AI orchestration modules composition
Files:
src/mastra/index.ts
🧬 Code graph analysis (1)
app/dashboard/agents/_components/agent-details.tsx (1)
ui/badge.tsx (1)
Badge(46-46)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: CodeQL analysis (javascript-typescript)
- GitHub Check: Agent
- GitHub Check: Codacy Security Scan
🔇 Additional comments (17)
src/mastra/workflows/content-studio-workflow.ts (1)
417-423: Workflow id rename looks good; verify external referencesRenaming the workflow id to
'contentStudioWorkflow'keeps it consistent with the exported constant and other workflows in this PR. Please double‑check any places that reference the old'content-studio-workflow'id (CLI configs, registry lookups, tests) to avoid runtime lookup issues.src/mastra/workflows/weather-workflow.ts (1)
206-214: StandardizedweatherWorkflowid; confirm callers are updatedSwitching the id to
'weatherWorkflow'matches the exported constant and other workflows. Make sure any code or config that previously referenced'weather-workflow'is updated so workflow resolution doesn’t silently fail.src/mastra/workflows/changelog.ts (1)
281-289: Changelog workflow id now matches export; check consumersUsing
'changelogWorkflow'as the id aligns with the exportedchangelogWorkflow. Please confirm any orchestrators, dashboards, or tests that look up the workflow by id have been migrated off'changelog'.src/mastra/workflows/stock-analysis-workflow.ts (1)
552-560: Renamed stock analysis workflow id; ensure registry/clients are in syncThe id
'stockAnalysisWorkflow'is consistent with the exported constant and naming across workflows. Please verify that any workflow registry entries, triggers, or UI code that referenced'stock-analysis-workflow'are updated accordingly.src/mastra/workflows/governed-rag-answer.workflow.ts (1)
598-606: Governed RAG answer id normalized; check integration pointsUpdating the workflow id to
'governedRagAnswer'matches the exportedgovernedRagAnswersymbol and the new naming scheme. Please confirm that any policies, routes, or orchestration config that referenced'governed-rag-answer'have been adjusted to prevent lookup failures.src/mastra/workflows/telephone-game.ts (1)
106-112: Telephone game workflow id aligned with export; verify any lookupsChanging the id to
'telephoneGameWorkflow'brings it in sync with the exported constant name. Please double‑check any code that referenced the previous'telephoneGame'id so the workflow still registers and runs as expected.src/mastra/workflows/learning-extraction-workflow.ts (1)
760-765: Learning extraction workflow id standardized; confirm ecosystem updatesThe id
'learningExtractionWorkflow'now matches the exported workflow and the rest of the naming scheme. Please ensure any callers, configs, or stored references using'learning-extraction-workflow'are updated to keep executions wired correctly.src/mastra/workflows/financial-report-workflow.ts (1)
995-1002: Financial report workflow id renamed; check id-based consumersUsing
'financialReportWorkflow'as the id is consistent with the exported constant and other workflows. Please audit any orchestration, scheduling, or UI code that keys off'financial-report-workflow'to avoid subtle breakages after deploy.src/mastra/workflows/spec-generation-workflow.ts (1)
261-265: Workflow id rename is consistent; confirm all callers use the new id.Changing the workflow
idto'specGenerationWorkflow'aligns with the new camelCase convention, but any clients that reference this workflow by id (e.g., via/workflow/:workflowIdor UI configs) must be updated, otherwise calls using the old'spec-generation-workflow'id will fail to resolve.src/mastra/workflows/repo-ingestion-workflow.ts (1)
221-225: Repo ingestion workflow id renamed; double-check external references.Updating the
idto'repoIngestionWorkflow'keeps naming consistent, but any callers that previously invoked'repo-ingestion-workflow'(e.g., via REST, UI config, or tests) will no longer match. Please confirm all such references have been updated or that you’re comfortable with this breaking change.src/mastra/workflows/research-synthesis-workflow.ts (1)
561-567: researchSynthesisWorkflow id rename is consistent; ensure external workflowId usage is updated.The
id: 'researchSynthesisWorkflow'change brings the workflow id in line with the exported name and other camelCase ids. Please verify that any callers (routes, dashboards, tests) that passworkflowIdhave been updated from'research-synthesis-workflow'to the new value.src/mastra/workflows/content-review-workflow.ts (1)
702-707: contentReviewWorkflow id updated; confirm any external ids are migrated.Using
'contentReviewWorkflow'for the workflow id matches the exported symbol and the registration inmastra/index.ts. Just make sure any clients or configs that previously referenced'content-review-workflow'are migrated, since the server routes will now expect the new id.src/mastra/workflows/document-processing-workflow.ts (1)
691-696: documentProcessingWorkflow id renamed; check for any remaining kebab-case references.The new
id: 'documentProcessingWorkflow'matches the export and registration and fits the overall naming cleanup. Please confirm that no API clients, jobs, or UI components still reference'document-processing-workflow', otherwise those calls will stop resolving this workflow.app/dashboard/agents/_components/agent-tab.tsx (1)
65-77: Excellent defensive tool rendering.The use of
Array.isArray()to guard the Tools section and the robust label extraction logic that handles both string and object tool shapes is well-implemented. This prevents runtime errors and ensures consistent display regardless of the tool data structure.app/dashboard/agents/_components/agent-details.tsx (1)
45-51: Well-implemented defensive model rendering.The type checking and conditional rendering logic properly handles both string and object model shapes. The template literal formatting with optional name field (
${agent.model.provider}${agent.model.name ? \/ ${agent.model.name}` : ""}`) is clean and prevents undefined display issues. The implementation is consistent across both the header badge and the Details tab.Also applies to: 85-85
app/dashboard/agents/_components/index.ts (1)
5-5: Correct export name alignment.This change properly aligns the export name with the actual component name
AgentTabfrom the source module, fixing a naming inconsistency in the public API.app/dashboard/agents/_components/agent-tools-tab.tsx (1)
36-38: Improved element identification with composite keys and test IDs.The updated key using both
toolNameandtoolIdalong with the index provides better uniqueness, and adding thedata-testidattribute improves testability. These are good practices for component identification.
| const tools = Array.isArray(agent.tools) | ||
| ? agent.tools | ||
| : agent.tools | ||
| ? [agent.tools] | ||
| : [] |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Simplify redundant tools normalization logic.
The current ternary chain checks Array.isArray(agent.tools) as the first condition, but then the else branch checks agent.tools again before wrapping it in an array. This can be simplified for better readability.
Apply this diff to simplify the logic:
- const tools = Array.isArray(agent.tools)
- ? agent.tools
- : agent.tools
- ? [agent.tools]
- : []
+ const tools = Array.isArray(agent.tools)
+ ? agent.tools
+ : agent.tools != null
+ ? [agent.tools]
+ : []Or more concisely:
- const tools = Array.isArray(agent.tools)
- ? agent.tools
- : agent.tools
- ? [agent.tools]
- : []
+ const tools = agent.tools
+ ? Array.isArray(agent.tools)
+ ? agent.tools
+ : [agent.tools]
+ : []🤖 Prompt for AI Agents
In app/dashboard/agents/_components/agent-tools-tab.tsx around lines 13-17, the
ternary chain redundantly checks agent.tools twice; replace it with a single
conditional that returns agent.tools if it's an array, wraps it in an array if
it's a truthy non-array, or returns an empty array otherwise (e.g., use a single
ternary or concat/Array.isArray approach) so the logic is simpler and more
readable.
| const toolId = typeof tool === "string" ? tool : (tool as any).id | ||
| const toolName = typeof tool === "string" ? tool : tool.name || (tool as any).id |
There was a problem hiding this comment.
Type safety violations with multiple 'as any' casts.
Multiple uses of (tool as any) bypass TypeScript's type checking (lines 32, 33, 45), which can lead to runtime errors if tool structures don't match expectations. This undermines the benefits of TypeScript and makes the code fragile.
Consider defining proper types for tools in @/lib/types/mastra-api and using type guards instead:
// In @/lib/types/mastra-api
export type Tool = string | { id: string; name?: string; [key: string]: any }
// Then in the component:
const toolId = typeof tool === "string" ? tool : tool.id
const toolName = typeof tool === "string" ? tool : (tool.name ?? tool.id)
// And in rendering:
<span className="text-sm font-medium">
{typeof tool === "string" ? tool : (tool.name ?? tool.id ?? JSON.stringify(tool))}
</span>This maintains type safety while still handling both shapes defensively.
Also applies to: 42-46
🤖 Prompt for AI Agents
In app/dashboard/agents/_components/agent-tools-tab.tsx around lines 32-33 (and
similarly 42-46), replace the unsafe (tool as any) casts by introducing a proper
Tool type (e.g., string | { id: string; name?: string; [key: string]: any }) in
@/lib/types/mastra-api, import that type here, and use a simple type guard
(typeof tool === "string") to access id and name; compute toolId = typeof tool
=== "string" ? tool : tool.id and toolName = typeof tool === "string" ? tool :
(tool.name ?? tool.id), and in JSX render use the same guard with nullish
coalescing or JSON.stringify fallback to avoid runtime errors instead of casting
to any.
There was a problem hiding this comment.
Code Review
This pull request introduces several enhancements and refactorings across agent components and workflows. The changes to handle different data structures for agent models and tools are good for robustness. I've pointed out a few areas for improvement:
- There's some code duplication in
agent-details.tsxthat could be refactored. - The
agent-tools-tab.tsxcomponent doesn't correctly handle all possible shapes of theagent.toolsproperty, leading toas anycasts. I've suggested a fix to normalize the data structure. - A minor improvement in
agent-tab.tsxto use a more stablekeyfor rendered list items.
The rest of the changes, like renaming workflow IDs for consistency and removing an unused file, look good and improve the codebase.
| const tools = Array.isArray(agent.tools) | ||
| ? agent.tools | ||
| : agent.tools | ||
| ? [agent.tools] | ||
| : [] |
There was a problem hiding this comment.
This logic for normalizing agent.tools into an array doesn't correctly handle the case where agent.tools is a record of tools (e.g., Record<string, Tool>), which is allowed by the type definition in lib/types/mastra-api.ts. When it is a record, [agent.tools] creates an array with a single element which is the entire record, causing issues in the rendering logic below. This is likely the reason for the (tool as any).id casts later on.
To fix this, you should convert the record into an array of tool objects. For example:
const tools = Array.isArray(agent.tools)
? agent.tools
: agent.tools && typeof agent.tools === 'object'
? Object.entries(agent.tools).map(([id, toolData]) => ({ id, ...(toolData as object) }))
: [];This will create a consistent data structure and allow you to remove the as any type assertions in the map function below.
| {agent.model && ( | ||
| <div> | ||
| <h4 className="text-sm font-medium mb-2">Model</h4> | ||
| <p className="text-sm text-muted-foreground">{agent.model}</p> | ||
| {typeof agent.model === "string" ? agent.model : `${agent.model.provider}${agent.model.name ? ` / ${agent.model.name}` : ""}`} | ||
| </div> | ||
| )} |
There was a problem hiding this comment.
The logic to format the agent model display string is duplicated here and on lines 47-49. To improve maintainability and follow the DRY principle, you could extract this logic into a variable within the component.
For example:
const modelDisplayString = agent.model
? typeof agent.model === "string"
? agent.model
: `${agent.model.provider}${agent.model.name ? ` / ${agent.model.name}` : ""}`
: null;Then you can use modelDisplayString in both places.
| {agent.tools.map((tool, index) => { | ||
| const label = typeof tool === "string" ? tool : (tool.name ?? tool.id) | ||
| return ( | ||
| <Badge key={index} variant="secondary">{label}</Badge> |
There was a problem hiding this comment.
Using the array index as a key for list items is not recommended if the list can change, as it can lead to performance issues and bugs with component state. It's better to use a unique and stable identifier from the data itself. In this case, you can use the tool string or the tool's id.
| <Badge key={index} variant="secondary">{label}</Badge> | |
| <Badge key={typeof tool === "string" ? tool : tool.id} variant="secondary">{label}</Badge> |
There was a problem hiding this comment.
Pull request overview
This PR standardizes workflow naming conventions and enhances agent component handling across the codebase. The primary focus is converting workflow IDs from kebab-case to camelCase for consistency, while also improving how agent components handle dynamic model and tool data types.
Key Changes:
- Standardizes 13 workflow IDs to camelCase format (e.g.,
weather-workflow→weatherWorkflow) - Updates agent UI components to handle both string and object types for models and tools
- Refactors
mapToToolStatefrom function declaration to arrow function syntax
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| weather-workflow.ts | Rename workflow ID from kebab-case to camelCase |
| telephone-game.ts | Rename workflow ID to telephoneGameWorkflow |
| stock-analysis-workflow.ts | Rename workflow ID to stockAnalysisWorkflow |
| spec-generation-workflow.ts | Rename workflow ID to specGenerationWorkflow |
| research-synthesis-workflow.ts | Rename workflow ID to researchSynthesisWorkflow |
| repo-ingestion-workflow.ts | Rename workflow ID to repoIngestionWorkflow |
| learning-extraction-workflow.ts | Rename workflow ID to learningExtractionWorkflow |
| governed-rag-index.workflow.ts | Rename workflow ID to governedRagIndex |
| governed-rag-answer.workflow.ts | Rename workflow ID to governedRagAnswer |
| financial-report-workflow.ts | Rename workflow ID to financialReportWorkflow |
| document-processing-workflow.ts | Rename workflow ID to documentProcessingWorkflow |
| content-studio-workflow.ts | Rename workflow ID to contentStudioWorkflow |
| content-review-workflow.ts | Rename workflow ID to contentReviewWorkflow |
| changelog.ts | Rename workflow ID to changelogWorkflow |
| mastra/index.ts | Add governedRagIndex workflow import and registration |
| mastra/agents/sql.ts | Remove unused SQL agent file |
| agent-details.tsx | Add type checking for model display to handle string or object types |
| agent-tab.tsx | Update tools rendering with type-safe property access |
| agent-tools-tab.tsx | Add logic to convert tools to array and improve tool name display |
| index.ts | Correct export name from AgentEvalsTab to AgentTab |
| tool-part-transform.ts | Convert mapToToolState function to arrow function syntax |
| <div> | ||
| <h4 className="text-sm font-medium mb-2">Model</h4> | ||
| <p className="text-sm text-muted-foreground">{agent.model}</p> | ||
| {typeof agent.model === "string" ? agent.model : `${agent.model.provider}${agent.model.name ? ` / ${agent.model.name}` : ""}`} |
There was a problem hiding this comment.
Missing text styling wrapper. The model display text on line 85 is not wrapped in a paragraph or span element, making it inconsistent with other text elements in the component and potentially causing layout issues. It should be wrapped in a
tag with appropriate text styling classes.
| {typeof agent.model === "string" ? agent.model : `${agent.model.provider}${agent.model.name ? ` / ${agent.model.name}` : ""}`} | |
| <p className="text-sm text-muted-foreground"> | |
| {typeof agent.model === "string" ? agent.model : `${agent.model.provider}${agent.model.name ? ` / ${agent.model.name}` : ""}`} | |
| </p> |
| <Badge key={index} variant="secondary">{tool.name}</Badge> | ||
| ))} | ||
| {agent.tools.map((tool, index) => { | ||
| const label = typeof tool === "string" ? tool : (tool.name ?? tool.id) |
There was a problem hiding this comment.
The tool.id access is unsafe. On line 70, when tool is not a string, you access tool.id without type assertion, but this property may not exist on the tool object type. Use optional chaining or type assertion: (tool as any).id to match the pattern used elsewhere in this file.
| const label = typeof tool === "string" ? tool : (tool.name ?? tool.id) | |
| const label = typeof tool === "string" ? tool : (tool.name ?? (tool as any).id) |
| repoIngestionWorkflow, | ||
| specGenerationWorkflow, | ||
| governedRagIndex, | ||
|
|
There was a problem hiding this comment.
Trailing comma with blank line. Line 111 has a trailing comma followed by an empty line, which is inconsistent with the formatting pattern in the rest of the workflows object. Either remove the blank line or remove the trailing comma for consistency.
| const tools = Array.isArray(agent.tools) | ||
| ? agent.tools | ||
| : agent.tools | ||
| ? [agent.tools] | ||
| : [] |
There was a problem hiding this comment.
The logic for converting agent.tools to an array is redundant. Lines 14-15 both return agent.tools when it's truthy - if it's already an array (line 13), line 14 returns it; but if it's not an array and is truthy, line 15 still returns the same agent.tools unchanged, not wrapped in an array. The correct logic should wrap non-array truthy values in an array.
| const toolId = typeof tool === "string" ? tool : tool.id | ||
| const toolName = typeof tool === "string" ? tool : tool.name || tool.id | ||
| const toolId = typeof tool === "string" ? tool : (tool as any).id | ||
| const toolName = typeof tool === "string" ? tool : tool.name || (tool as any).id |
There was a problem hiding this comment.
The tool.name access on line 33 is not type-safe. After checking that tool is not a string, you're accessing tool.name without any type assertion, but then immediately fall back to (tool as any).id. For consistency and clarity, either use type assertions for both accesses or use optional chaining: (tool as any).name || (tool as any).id
| {typeof tool === "string" | ||
| ? tool | ||
| : String(tool.name ?? (tool as any).id ?? JSON.stringify(tool))} |
There was a problem hiding this comment.
The display logic on lines 43-45 is redundant with the toolName variable calculated on line 33. You're recalculating the same display value (tool.name ?? tool.id) twice. Consider reusing the toolName variable instead of this complex ternary with String() and JSON.stringify() fallback, which could expose raw object structure to users.
| {typeof tool === "string" | |
| ? tool | |
| : String(tool.name ?? (tool as any).id ?? JSON.stringify(tool))} | |
| {toolName} |
| return ( | ||
| <div | ||
| key={`${toolId}-${index}`} | ||
| key={`${toolName}-${toolId}-${index}`} |
There was a problem hiding this comment.
The key prop uses toolName which may be undefined if the tool object has neither name nor id properties. This could lead to React key warnings or duplicate key issues. Consider using a more defensive key construction or ensuring index is included as primary identifier: key={${index}-${toolId || 'unknown'}}
| key={`${toolName}-${toolId}-${index}`} | |
| key={`${index}-${toolId || 'unknown'}`} |
Greptile OverviewGreptile SummaryImproved agent component type handling and standardized workflow naming conventions. The PR refactors dashboard agent components to handle polymorphic
Critical Issue: Confidence Score: 3/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Dev as Developer
participant IDE as IDE/Editor
participant Component as Agent Components
participant Type as Type System
participant Workflow as Workflow Registry
Note over Dev,Workflow: PR Changes Flow
Dev->>IDE: Refactor mapToToolState to arrow function
IDE->>Component: Update tool-part-transform.ts
Dev->>IDE: Fix agent.model type handling
IDE->>Component: Update agent-details.tsx
Note over Component: Added type checking for<br/>string | object model
Dev->>IDE: Improve tools rendering
IDE->>Component: Update agent-tab.tsx
Note over Component: Added Array.isArray check<br/>Better label extraction
Dev->>IDE: Enhance tools array handling
IDE->>Component: Update agent-tools-tab.tsx
Note over Component: Support non-array tools<br/>Added test IDs
Dev->>IDE: Fix export name
IDE->>Component: Update index.ts
Note over Component: AgentEvalsTab → AgentTab
Dev->>IDE: Remove unused SQL agent
IDE->>Type: Delete sql.ts
Dev->>IDE: Standardize workflow IDs
IDE->>Workflow: Rename 14 workflow IDs
Note over Workflow: kebab-case → camelCase
Dev->>IDE: Add governedRagIndex workflow
IDE->>Workflow: Register in mastra/index.ts
Type-->>Component: Type validation
Component-->>Dev: Components ready for use
Workflow-->>Dev: Workflows registered
|
There was a problem hiding this comment.
Additional Comments (1)
-
app/dashboard/agents/_components/agent-tab.tsx, line 49 (link)logic: This assumes
agent.modelis always an object, but it can be a string according to the type definition. This will cause a runtime error ifagent.modelis a string.
21 files reviewed, 1 comment

mapToToolStatefunction to use arrow function syntax intool-part-transform.ts.agent-details.tsxto handle different data types.agent-tab.tsxto ensure proper display of tool names.AgentToolsTabto ensure tools are correctly processed as an array inagent-tools-tab.tsx.index.tsto correct the export name forAgentTab.sql.tsfile frommastra/agents.governedRagIndexworkflow tomastra/index.ts.