Skip to content

refactor(agentflow): enhance ESLint configuration and improve test coverage#5866

Merged
jocelynlin-wd merged 3 commits intomainfrom
refactor/agentflow-sdk-tests-lint=docs-update
Mar 2, 2026
Merged

refactor(agentflow): enhance ESLint configuration and improve test coverage#5866
jocelynlin-wd merged 3 commits intomainfrom
refactor/agentflow-sdk-tests-lint=docs-update

Conversation

@jocelynlin-wd
Copy link
Contributor

  • Updated ESLint configuration to include TypeScript resolver for improved import handling.
  • Added restrictions on importing from features to enforce architectural boundaries.
  • Enhanced test coverage for various components (tier 2 & 3), including ConnectionLine and NodeOutputHandles.
  • Updated architecture documentation to reflect recent changes in file structure and component organization.

…verage

- Updated ESLint configuration to include TypeScript resolver for improved import handling.
- Added restrictions on importing from features to enforce architectural boundaries.
- Enhanced test coverage for various components, including ConnectionLine and NodeOutputHandles.
- Updated architecture documentation to reflect recent changes in file structure and component organization.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 significantly enhances the agentflow package by focusing on code quality, maintainability, and test reliability. It introduces stricter ESLint rules to enforce architectural boundaries and improve TypeScript import resolution, preventing common development issues. Concurrently, the test suite has been expanded with new tests for critical UI components and hooks, ensuring greater stability and correctness of the application logic. These structural and testing improvements are also reflected in the updated architectural documentation.

Highlights

  • ESLint Configuration Enhancement: Enhanced ESLint configuration by integrating a TypeScript resolver for improved import handling and introduced a new rule to prevent direct imports from the 'features' layer, thereby enforcing architectural boundaries.
  • Test Coverage Expansion: Significantly improved test coverage across various components and hooks, including ConnectionLine, NodeOutputHandles, useDragAndDrop, useFlowNodes, useNodeColors, useOpenNodeEditor, GenerateFlowDialog, EditNodeDialog, ApiContext, and ConfigContext.
  • Architectural Documentation Update: Updated the ARCHITECTURE.md file to reflect current file organization, component structure, and the addition of a new theme directory.
  • Core Type Refactoring: Refactored the EditDialogProps interface within core/types to decouple core state definitions from feature-specific component props, improving modularity.
Changelog
  • packages/agentflow/.eslintrc.js
    • Added TypeScript resolver to ESLint settings for better import resolution.
    • Introduced a 'no-restricted-imports' rule to prevent direct imports from the '@/features' alias, enforcing architectural boundaries.
  • packages/agentflow/ARCHITECTURE.md
    • Updated directory structure examples for 'atoms', 'features', 'core', and 'infrastructure' to be more concise.
    • Replaced specific file listings with ellipses to indicate other components, hooks, or modules.
    • Added a new 'theme' directory to the 'core' section.
  • packages/agentflow/README.md
    • Added getReactFlowInstance() to the list of imperative methods available via ref.
  • packages/agentflow/TESTS.md
    • Updated test coverage status for several Tier 2 and Tier 3 components and hooks from 'Not yet' to 'Done'.
    • Simplified the description of coverage thresholds, referencing jest.config.js for the full list.
    • Added src/infrastructure/store/ApiContext.tsx to Tier 2 test coverage.
  • packages/agentflow/jest.config.js
    • Modified coverage thresholds to include new test files and adjust existing ones, adding entries for ConnectionLine.tsx, NodeOutputHandles.tsx, features/canvas/hooks/, GenerateFlowDialog.tsx, node-editor/, and consolidating infrastructure/api/ and infrastructure/store/AgentflowContext.tsx into a broader infrastructure/ entry.
  • packages/agentflow/package.json
    • Added eslint-import-resolver-typescript as a development dependency.
  • packages/agentflow/src/test_utils/jest-environment-jsdom.js
    • Added a mock Image class to the JSDOM environment to prevent errors during testing of components that use Image objects.
  • packages/agentflow/src/core/types/index.ts
    • Removed direct import of EditNodeDialogProps from the features layer.
    • Defined a new EditDialogProps interface within core/types to decouple core state from feature-specific component props.
    • Updated AgentflowState and AgentflowAction interfaces to use the new EditDialogProps.
  • packages/agentflow/src/features/canvas/components/ConnectionLine.test.tsx
    • Added new test file for ConnectionLine component, covering edge label visibility, content, and color determination.
  • packages/agentflow/src/features/canvas/components/NodeOutputHandles.test.ts
    • Added new test file for NodeOutputHandles, specifically testing the getMinimumNodeHeight utility function.
  • packages/agentflow/src/features/canvas/hooks/useDragAndDrop.test.tsx
    • Added new test file for useDragAndDrop hook, covering drag/drop functionality, node creation, and error handling.
  • packages/agentflow/src/features/canvas/hooks/useDragAndDrop.ts
    • Exported DROP_OFFSET_X and DROP_OFFSET_Y constants for testing purposes.
  • packages/agentflow/src/features/canvas/hooks/useFlowNodes.test.tsx
    • Added new test file for useFlowNodes hook, covering node filtering, loading states, and API error handling.
  • packages/agentflow/src/features/canvas/hooks/useNodeColors.test.tsx
    • Added new test file for useNodeColors hook, covering color calculations based on node state (selected, hovered, dark mode).
  • packages/agentflow/src/features/canvas/hooks/useOpenNodeEditor.test.tsx
    • Added new test file for useOpenNodeEditor hook, covering logic for opening the node editor with correct data and schema.
  • packages/agentflow/src/features/generator/GenerateFlowDialog.test.tsx
    • Added new test file for GenerateFlowDialog, covering chat model loading, flow generation, error handling, and UI state management.
  • packages/agentflow/src/features/node-editor/EditNodeDialog.test.tsx
    • Added new test file for EditNodeDialog, covering name editing, input handling, and hint display.
  • packages/agentflow/src/features/node-editor/EditNodeDialog.tsx
    • Updated EditNodeDialogProps to use the new EditDialogProps interface from core/types.
  • packages/agentflow/src/infrastructure/store/ApiContext.test.tsx
    • Added new test file for ApiContext, covering provider functionality, API client creation, and memoization.
  • packages/agentflow/src/infrastructure/store/ConfigContext.test.tsx
    • Added new test file for ConfigContext, covering provider functionality and context value provision.
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.

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 delivers a significant improvement to the agentflow package by enhancing the ESLint configuration to enforce architectural boundaries, massively increasing test coverage across components, hooks, and contexts, and updating the corresponding documentation. The changes are of high quality, with well-written and comprehensive tests. A notable architectural improvement is the refactoring to remove a core to features dependency, strengthening the modular design. The documentation updates in ARCHITECTURE.md, TESTS.md, and README.md are clear and align perfectly with the code changes. Overall, this is an excellent contribution that greatly improves the project's quality and maintainability.


import type { AxiosInstance } from 'axios'

import { EditNodeDialogProps } from '@/features/node-editor/EditNodeDialog'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

core should not access anything in features

},
'import/resolver': {
typescript: {
project: './tsconfig.json'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

allow lint to check imports with alias

- manually resolve conflict in pnpm-lock.yaml
@jocelynlin-wd jocelynlin-wd merged commit 86e9fae into main Mar 2, 2026
7 checks passed
@jocelynlin-wd jocelynlin-wd deleted the refactor/agentflow-sdk-tests-lint=docs-update branch March 2, 2026 17:58
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.

2 participants