Skip to content

feat: enhance agent components and workflows#36

Merged
ssdeanx merged 1 commit intomainfrom
develop
Dec 11, 2025
Merged

feat: enhance agent components and workflows#36
ssdeanx merged 1 commit intomainfrom
develop

Conversation

@ssdeanx
Copy link
Owner

@ssdeanx ssdeanx commented Dec 11, 2025

  • 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.

- 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.
Copilot AI review requested due to automatic review settings December 11, 2025 16:36
@continue
Copy link

continue bot commented Dec 11, 2025

All Green - Keep your PRs mergeable

Learn more

All Green is an AI agent that automatically:

✅ Addresses code review comments

✅ Fixes failing CI checks

✅ Resolves merge conflicts

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @ssdeanx, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@github-actions
Copy link

🤖 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.

@coderabbitai
Copy link

coderabbitai bot commented Dec 11, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Agent model display now handles both string and object formats with provider information
    • Enhanced tool labeling and display in agent configurations
    • Added new governance workflow
  • Refactor

    • Updated workflow identifier names across all workflows
  • Deprecation

    • SQL agent module removed

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

This 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

Cohort / File(s) Summary
Tool and Helper Refactoring
app/chat/helpers/tool-part-transform.ts
Refactored mapToToolState from function declaration to arrow function; behavior unchanged.
Agent Components Enhancement
app/dashboard/agents/_components/agent-details.tsx
Enhanced agent.model rendering to conditionally handle both string and object shapes, formatting as provider + " / " + name for objects.
app/dashboard/agents/_components/agent-tab.tsx
app/dashboard/agents/_components/agent-tools-tab.tsx
app/dashboard/agents/_components/index.ts
Workflow ID Normalization (Kebab-case to camelCase)
src/mastra/workflows/changelog.ts, content-review-workflow.ts, content-studio-workflow.ts, document-processing-workflow.ts, financial-report-workflow.ts, governed-rag-answer.workflow.ts, governed-rag-index.workflow.ts, learning-extraction-workflow.ts, repo-ingestion-workflow.ts, research-synthesis-workflow.ts, spec-generation-workflow.ts, stock-analysis-workflow.ts, telephone-game.ts, weather-workflow.ts
Updated workflow id values from kebab-case strings (e.g., 'content-review-workflow') to camelCase (e.g., 'contentReviewWorkflow').
Module Deletion and Workflow Registration
src/mastra/agents/sql.ts
Deleted entire SQL agent module, removing sqlAgent export, UserTier type, and SqlAgentRuntimeContext interface.
src/mastra/index.ts

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

  • Agent components (agent-details.tsx, agent-tab.tsx, agent-tools-tab.tsx): Heterogeneous logic changes requiring careful verification of type handling and edge cases for string vs. object shapes
  • Workflow ID normalization (14 files): Homogeneous, repetitive changes that are straightforward but benefit from spot-checking consistency and verifying no downstream references break
  • Module deletion (src/mastra/agents/sql.ts): Verify all references and dependents are removed or updated
  • Export change in index.ts: Confirm AgentTab vs. AgentEvalsTab usage across codebase

Possibly related PRs

Suggested reviewers

  • sourcery-ai

Poem

🐰 A rabbit hops through workflow lines,
From dashes bold to camelCase divine,
Agent tools now flex both shapes with grace,
While SQL hops off to another place,
IDs normalized, refactored clean,
The finest workflow change we've seen!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'feat: enhance agent components and workflows' is vague and overly broad, using generic phrasing that doesn't convey specific information about the main changes despite the PR covering refactoring, updates, removals, and renames across multiple files. Consider a more specific title that highlights the primary change, such as 'feat: refactor agent components and standardize workflow IDs' or similar, to better reflect the scope and main objective of the changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description comprehensively covers the changes made across all modified files and is directly related to the changeset, including refactoring, logic updates, exports, removals, and workflow ID standardization.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch develop

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.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Agent UI Enhancements: Improved the display logic for agent models and tools within the dashboard, ensuring robust handling of various data types and proper rendering of tool names.
  • Code Refactoring: Refactored the mapToToolState function to use modern arrow function syntax, enhancing code readability and consistency.
  • Workflow Management: Standardized workflow IDs across multiple files for better consistency and maintainability. Additionally, an unused SQL agent file was removed.
  • New Workflow Integration: Integrated a new governedRagIndex workflow into the main system, expanding the platform's capabilities.
  • Export Correction: Corrected an export name in the agent components index file to ensure proper module resolution.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

🤖 I'm sorry @ssdeanx, but I was unable to process your request. Please see the logs for more details.

@ssdeanx ssdeanx merged commit e603cbe into main Dec 11, 2025
17 of 21 checks passed
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 governedRagIndex into the workflows map 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 and allowedRoles.

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 id to 'governedRagIndex' matches the exported constant and the new registration in mastra/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 with classification, allowedRoles, and tenant, consider threading requestContext into 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

📥 Commits

Reviewing files that changed from the base of the PR and between bb4a128 and 34729ce.

📒 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}: Use next/dynamic for dynamic imports to load components only when needed, improving initial load time.
Use next/image component 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.
Use react-hook-form for 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 use setState or hooks to update state instead of mutating state directly.
Include a complete dependency array in useEffect hooks to prevent unexpected behavior.
Avoid writing server-side code in client components to prevent exposing secrets or causing unexpected behavior.
Use try...catch blocks for handling errors in asynchronous operations.
Implement error boundary components using getDerivedStateFromError or componentDidCatch lifecycle 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 in useEffect hooks 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.ts
  • app/dashboard/agents/_components/agent-tab.tsx
  • src/mastra/workflows/telephone-game.ts
  • src/mastra/workflows/learning-extraction-workflow.ts
  • src/mastra/index.ts
  • src/mastra/workflows/governed-rag-answer.workflow.ts
  • app/dashboard/agents/_components/index.ts
  • app/dashboard/agents/_components/agent-details.tsx
  • src/mastra/workflows/document-processing-workflow.ts
  • src/mastra/workflows/weather-workflow.ts
  • src/mastra/workflows/changelog.ts
  • src/mastra/workflows/repo-ingestion-workflow.ts
  • src/mastra/workflows/stock-analysis-workflow.ts
  • app/dashboard/agents/_components/agent-tools-tab.tsx
  • src/mastra/workflows/content-studio-workflow.ts
  • app/chat/helpers/tool-part-transform.ts
  • src/mastra/workflows/financial-report-workflow.ts
  • src/mastra/workflows/governed-rag-index.workflow.ts
  • src/mastra/workflows/spec-generation-workflow.ts
  • src/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.ts
  • src/mastra/workflows/telephone-game.ts
  • src/mastra/workflows/learning-extraction-workflow.ts
  • src/mastra/index.ts
  • src/mastra/workflows/governed-rag-answer.workflow.ts
  • app/dashboard/agents/_components/index.ts
  • src/mastra/workflows/document-processing-workflow.ts
  • src/mastra/workflows/weather-workflow.ts
  • src/mastra/workflows/changelog.ts
  • src/mastra/workflows/repo-ingestion-workflow.ts
  • src/mastra/workflows/stock-analysis-workflow.ts
  • src/mastra/workflows/content-studio-workflow.ts
  • app/chat/helpers/tool-part-transform.ts
  • src/mastra/workflows/financial-report-workflow.ts
  • src/mastra/workflows/governed-rag-index.workflow.ts
  • src/mastra/workflows/spec-generation-workflow.ts
  • src/mastra/workflows/research-synthesis-workflow.ts
src/mastra/{tools,workflows}/**/*.ts

📄 CodeRabbit inference engine (src/mastra/AGENTS.md)

Use RuntimeContext to enforce access control in tools and workflows

Files:

  • src/mastra/workflows/content-review-workflow.ts
  • src/mastra/workflows/telephone-game.ts
  • src/mastra/workflows/learning-extraction-workflow.ts
  • src/mastra/workflows/governed-rag-answer.workflow.ts
  • src/mastra/workflows/document-processing-workflow.ts
  • src/mastra/workflows/weather-workflow.ts
  • src/mastra/workflows/changelog.ts
  • src/mastra/workflows/repo-ingestion-workflow.ts
  • src/mastra/workflows/stock-analysis-workflow.ts
  • src/mastra/workflows/content-studio-workflow.ts
  • src/mastra/workflows/financial-report-workflow.ts
  • src/mastra/workflows/governed-rag-index.workflow.ts
  • src/mastra/workflows/spec-generation-workflow.ts
  • src/mastra/workflows/research-synthesis-workflow.ts
src/mastra/workflows/**/*.ts

📄 CodeRabbit inference engine (src/mastra/AGENTS.md)

Add new workflow definitions under src/mastra/workflows to orchestrate multi-step flows

Use Mastra DSL for multi-step workflow definitions in src/mastra/workflows

Files:

  • src/mastra/workflows/content-review-workflow.ts
  • src/mastra/workflows/telephone-game.ts
  • src/mastra/workflows/learning-extraction-workflow.ts
  • src/mastra/workflows/governed-rag-answer.workflow.ts
  • src/mastra/workflows/document-processing-workflow.ts
  • src/mastra/workflows/weather-workflow.ts
  • src/mastra/workflows/changelog.ts
  • src/mastra/workflows/repo-ingestion-workflow.ts
  • src/mastra/workflows/stock-analysis-workflow.ts
  • src/mastra/workflows/content-studio-workflow.ts
  • src/mastra/workflows/financial-report-workflow.ts
  • src/mastra/workflows/governed-rag-index.workflow.ts
  • src/mastra/workflows/spec-generation-workflow.ts
  • src/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.ts
  • app/dashboard/agents/_components/agent-tab.tsx
  • src/mastra/workflows/telephone-game.ts
  • src/mastra/workflows/learning-extraction-workflow.ts
  • src/mastra/index.ts
  • src/mastra/workflows/governed-rag-answer.workflow.ts
  • app/dashboard/agents/_components/index.ts
  • app/dashboard/agents/_components/agent-details.tsx
  • src/mastra/workflows/document-processing-workflow.ts
  • src/mastra/workflows/weather-workflow.ts
  • src/mastra/workflows/changelog.ts
  • src/mastra/workflows/repo-ingestion-workflow.ts
  • src/mastra/workflows/stock-analysis-workflow.ts
  • app/dashboard/agents/_components/agent-tools-tab.tsx
  • src/mastra/workflows/content-studio-workflow.ts
  • app/chat/helpers/tool-part-transform.ts
  • src/mastra/workflows/financial-report-workflow.ts
  • src/mastra/workflows/governed-rag-index.workflow.ts
  • src/mastra/workflows/spec-generation-workflow.ts
  • src/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 the next-devtools-mcp server for all Next.js related queries

Files:

  • src/mastra/workflows/content-review-workflow.ts
  • app/dashboard/agents/_components/agent-tab.tsx
  • src/mastra/workflows/telephone-game.ts
  • src/mastra/workflows/learning-extraction-workflow.ts
  • src/mastra/index.ts
  • src/mastra/workflows/governed-rag-answer.workflow.ts
  • app/dashboard/agents/_components/index.ts
  • app/dashboard/agents/_components/agent-details.tsx
  • src/mastra/workflows/document-processing-workflow.ts
  • src/mastra/workflows/weather-workflow.ts
  • src/mastra/workflows/changelog.ts
  • src/mastra/workflows/repo-ingestion-workflow.ts
  • src/mastra/workflows/stock-analysis-workflow.ts
  • app/dashboard/agents/_components/agent-tools-tab.tsx
  • src/mastra/workflows/content-studio-workflow.ts
  • app/chat/helpers/tool-part-transform.ts
  • src/mastra/workflows/financial-report-workflow.ts
  • src/mastra/workflows/governed-rag-index.workflow.ts
  • src/mastra/workflows/spec-generation-workflow.ts
  • src/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.ts
  • app/dashboard/agents/_components/agent-tab.tsx
  • src/mastra/workflows/telephone-game.ts
  • src/mastra/workflows/learning-extraction-workflow.ts
  • src/mastra/index.ts
  • src/mastra/workflows/governed-rag-answer.workflow.ts
  • app/dashboard/agents/_components/index.ts
  • app/dashboard/agents/_components/agent-details.tsx
  • src/mastra/workflows/document-processing-workflow.ts
  • src/mastra/workflows/weather-workflow.ts
  • src/mastra/workflows/changelog.ts
  • src/mastra/workflows/repo-ingestion-workflow.ts
  • src/mastra/workflows/stock-analysis-workflow.ts
  • app/dashboard/agents/_components/agent-tools-tab.tsx
  • src/mastra/workflows/content-studio-workflow.ts
  • app/chat/helpers/tool-part-transform.ts
  • src/mastra/workflows/financial-report-workflow.ts
  • src/mastra/workflows/governed-rag-index.workflow.ts
  • src/mastra/workflows/spec-generation-workflow.ts
  • src/mastra/workflows/research-synthesis-workflow.ts
src/mastra/**/*

📄 CodeRabbit inference engine (src/AGENTS.md)

mastra modules can import from utils, but must not import from app or cli (except types)

Files:

  • src/mastra/workflows/content-review-workflow.ts
  • src/mastra/workflows/telephone-game.ts
  • src/mastra/workflows/learning-extraction-workflow.ts
  • src/mastra/index.ts
  • src/mastra/workflows/governed-rag-answer.workflow.ts
  • src/mastra/workflows/document-processing-workflow.ts
  • src/mastra/workflows/weather-workflow.ts
  • src/mastra/workflows/changelog.ts
  • src/mastra/workflows/repo-ingestion-workflow.ts
  • src/mastra/workflows/stock-analysis-workflow.ts
  • src/mastra/workflows/content-studio-workflow.ts
  • src/mastra/workflows/financial-report-workflow.ts
  • src/mastra/workflows/governed-rag-index.workflow.ts
  • src/mastra/workflows/spec-generation-workflow.ts
  • src/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.ts
  • app/dashboard/agents/_components/agent-tab.tsx
  • src/mastra/workflows/telephone-game.ts
  • src/mastra/workflows/learning-extraction-workflow.ts
  • src/mastra/index.ts
  • src/mastra/workflows/governed-rag-answer.workflow.ts
  • app/dashboard/agents/_components/index.ts
  • app/dashboard/agents/_components/agent-details.tsx
  • src/mastra/workflows/document-processing-workflow.ts
  • src/mastra/workflows/weather-workflow.ts
  • src/mastra/workflows/changelog.ts
  • src/mastra/workflows/repo-ingestion-workflow.ts
  • src/mastra/workflows/stock-analysis-workflow.ts
  • app/dashboard/agents/_components/agent-tools-tab.tsx
  • src/mastra/workflows/content-studio-workflow.ts
  • app/chat/helpers/tool-part-transform.ts
  • src/mastra/workflows/financial-report-workflow.ts
  • src/mastra/workflows/governed-rag-index.workflow.ts
  • src/mastra/workflows/spec-generation-workflow.ts
  • src/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.ts
  • src/mastra/workflows/telephone-game.ts
  • src/mastra/workflows/learning-extraction-workflow.ts
  • src/mastra/workflows/governed-rag-answer.workflow.ts
  • src/mastra/workflows/document-processing-workflow.ts
  • src/mastra/workflows/weather-workflow.ts
  • src/mastra/workflows/changelog.ts
  • src/mastra/workflows/repo-ingestion-workflow.ts
  • src/mastra/workflows/stock-analysis-workflow.ts
  • src/mastra/workflows/content-studio-workflow.ts
  • src/mastra/workflows/financial-report-workflow.ts
  • src/mastra/workflows/governed-rag-index.workflow.ts
  • src/mastra/workflows/spec-generation-workflow.ts
  • src/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 the pages/ directory for new projects.

Files:

  • app/dashboard/agents/_components/agent-tab.tsx
  • app/dashboard/agents/_components/index.ts
  • app/dashboard/agents/_components/agent-details.tsx
  • app/dashboard/agents/_components/agent-tools-tab.tsx
  • app/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.tsx
  • app/dashboard/agents/_components/index.ts
  • app/dashboard/agents/_components/agent-details.tsx
  • app/dashboard/agents/_components/agent-tools-tab.tsx
  • app/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 from lib/hooks/use-mastra.ts to 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.tsx
  • app/dashboard/agents/_components/index.ts
  • app/dashboard/agents/_components/agent-details.tsx
  • app/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.tsx
  • app/dashboard/agents/_components/index.ts
  • app/dashboard/agents/_components/agent-details.tsx
  • app/dashboard/agents/_components/agent-tools-tab.tsx
  • app/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.tsx
  • app/dashboard/agents/_components/agent-details.tsx
  • app/dashboard/agents/_components/agent-tools-tab.tsx
src/mastra/index.ts

📄 CodeRabbit inference engine (src/AGENTS.md)

Enforce registration pattern in mastra/index.ts for 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 references

Renaming 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: Standardized weatherWorkflow id; confirm callers are updated

Switching 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 consumers

Using 'changelogWorkflow' as the id aligns with the exported changelogWorkflow. 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 sync

The 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 points

Updating the workflow id to 'governedRagAnswer' matches the exported governedRagAnswer symbol 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 lookups

Changing 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 updates

The 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 consumers

Using '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 id to 'specGenerationWorkflow' aligns with the new camelCase convention, but any clients that reference this workflow by id (e.g., via /workflow/:workflowId or 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 id to '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 pass workflowId have 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 in mastra/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 AgentTab from 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 toolName and toolId along with the index provides better uniqueness, and adding the data-testid attribute improves testability. These are good practices for component identification.

Comment on lines +13 to +17
const tools = Array.isArray(agent.tools)
? agent.tools
: agent.tools
? [agent.tools]
: []
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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.

Comment on lines +32 to +33
const toolId = typeof tool === "string" ? tool : (tool as any).id
const toolName = typeof tool === "string" ? tool : tool.name || (tool as any).id
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.tsx that could be refactored.
  • The agent-tools-tab.tsx component doesn't correctly handle all possible shapes of the agent.tools property, leading to as any casts. I've suggested a fix to normalize the data structure.
  • A minor improvement in agent-tab.tsx to use a more stable key for 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.

Comment on lines +13 to +17
const tools = Array.isArray(agent.tools)
? agent.tools
: agent.tools
? [agent.tools]
: []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Comment on lines 82 to 87
{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>
)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
<Badge key={index} variant="secondary">{label}</Badge>
<Badge key={typeof tool === "string" ? tool : tool.id} variant="secondary">{label}</Badge>

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-workflowweatherWorkflow)
  • Updates agent UI components to handle both string and object types for models and tools
  • Refactors mapToToolState from 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}` : ""}`}
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
{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>

Copilot uses AI. Check for mistakes.
<Badge key={index} variant="secondary">{tool.name}</Badge>
))}
{agent.tools.map((tool, index) => {
const label = typeof tool === "string" ? tool : (tool.name ?? tool.id)
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
const label = typeof tool === "string" ? tool : (tool.name ?? tool.id)
const label = typeof tool === "string" ? tool : (tool.name ?? (tool as any).id)

Copilot uses AI. Check for mistakes.
repoIngestionWorkflow,
specGenerationWorkflow,
governedRagIndex,

Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +13 to +17
const tools = Array.isArray(agent.tools)
? agent.tools
: agent.tools
? [agent.tools]
: []
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +45
{typeof tool === "string"
? tool
: String(tool.name ?? (tool as any).id ?? JSON.stringify(tool))}
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
{typeof tool === "string"
? tool
: String(tool.name ?? (tool as any).id ?? JSON.stringify(tool))}
{toolName}

Copilot uses AI. Check for mistakes.
return (
<div
key={`${toolId}-${index}`}
key={`${toolName}-${toolId}-${index}`}
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'}}

Suggested change
key={`${toolName}-${toolId}-${index}`}
key={`${index}-${toolId || 'unknown'}`}

Copilot uses AI. Check for mistakes.
@greptile-apps
Copy link

greptile-apps bot commented Dec 11, 2025

Greptile Overview

Greptile Summary

Improved agent component type handling and standardized workflow naming conventions. The PR refactors dashboard agent components to handle polymorphic agent.model and agent.tools types, fixes an incorrect export name, removes an unused SQL agent file, and renames 14 workflow IDs from kebab-case to camelCase for consistency.

  • Enhanced type safety in agent-details.tsx and agent-tools-tab.tsx to handle both string and object formats for model and tools
  • Added governedRagIndex workflow to the registry
  • Standardized all workflow IDs to use camelCase convention (e.g., weather-workflowweatherWorkflow)
  • Fixed export name from AgentEvalsTab to AgentTab in index.ts
  • Removed unused sql.ts agent file (114 lines)
  • Refactored mapToToolState to arrow function syntax for consistency

Critical Issue: agent-tab.tsx at line 49 has a type safety bug that will cause runtime errors when agent.model is a string rather than an object.

Confidence Score: 3/5

  • This PR requires one critical fix before merging - runtime error will occur in agent-tab.tsx when model is a string
  • Score reflects mostly safe refactoring work (workflow renaming, type handling improvements, cleanup) but includes one critical bug in agent-tab.tsx that will cause crashes when agent.model is a string instead of an object. The bug is easily fixable with proper type checking like the pattern used in agent-details.tsx.
  • Pay close attention to app/dashboard/agents/_components/agent-tab.tsx - line 49 needs the same type checking pattern used in agent-details.tsx

Important Files Changed

File Analysis

Filename Score Overview
app/dashboard/agents/_components/agent-details.tsx 5/5 Added proper type checking for agent.model to handle both string and object formats, preventing potential rendering issues
app/dashboard/agents/_components/agent-tab.tsx 2/5 Improved tools rendering with better type checking, but model display logic has a critical bug that will cause runtime errors when model is a string
app/dashboard/agents/_components/agent-tools-tab.tsx 5/5 Enhanced tools array handling to support non-array tool formats, added test IDs, and improved label extraction logic
app/dashboard/agents/_components/index.ts 5/5 Fixed incorrect export name from AgentEvalsTab to AgentTab to match actual component name
src/mastra/index.ts 5/5 Added governedRagIndex workflow import and registration

Sequence Diagram

sequenceDiagram
    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
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (1)

  1. app/dashboard/agents/_components/agent-tab.tsx, line 49 (link)

    logic: This assumes agent.model is always an object, but it can be a string according to the type definition. This will cause a runtime error if agent.model is a string.

21 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant