Skip to content

DOPE-60 | DOPE-61#285

Merged
Gustavohsdp merged 3 commits into
developmentfrom
feature/dope-60-and-dope-61/allow-more-types
Jul 22, 2025
Merged

DOPE-60 | DOPE-61#285
Gustavohsdp merged 3 commits into
developmentfrom
feature/dope-60-and-dope-61/allow-more-types

Conversation

@Gustavohsdp
Copy link
Copy Markdown
Contributor

@Gustavohsdp Gustavohsdp commented Jul 16, 2025

Pull request info

Link to Jira task

jira task DOPE-60

jira task DOPE-61

Description of the changes proposed

  • Improves the data type selection by adding search filters for base types, user-defined types, and libraries, following the TypeDropdownSelector pattern. Enhances UX and keeps selection logic consistent.

DOD checklist

  • The code is complete and according to developers’ standards.
  • I have performed a self-review of my code.
  • Meet the acceptance criteria.
  • Unit tests are written and green.
  • Test coverage: __ %.
  • Integration tests are written and green.
  • Changes were communicated and updated in the ticket description.
  • Reviewed and accepted by the Product Owner.
  • End-to-end test are successful.

Summary by CodeRabbit

  • New Features

    • Introduced a categorized dropdown selector for type selection, enabling users to browse and filter variable and library types separately.
    • Added search inputs within dropdown submenus for dynamic, case-insensitive filtering of type options.
  • Refactor

    • Replaced flat type lists with structured categories in modals and selectors to improve clarity.
    • Enhanced array and variable modals to organize selectable types into variable and library groups for better usability.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 16, 2025

"""

Walkthrough

The changes refactor type selection UIs in various components by replacing flat dropdowns with a new TypeDropdownSelector component. This component organizes types into variable and library categories, each supporting independent filtering. Related prop and state management logic is updated throughout affected components to accommodate the new structured approach.

Changes

Files/Groups Change Summary
src/renderer/components/_atoms/type-dropdown-selector/index.tsx Introduced new TypeDropdownSelector React component for categorized type selection with search/filtering for each category.
src/renderer/components/_atoms/dimensions-modal/index.tsx Refactored to use TypeDropdownSelector instead of flat Select; updated props to accept structured variableTypes and libraryTypes arrays.
src/renderer/components/_molecules/data-types/array/index.tsx Replaced flat type dropdown with TypeDropdownSelector; updated type option preparation and selection handling.
src/renderer/components/_molecules/data-types/structure/table/elements/array-modal.tsx Refactored type option preparation to provide categorized variableTypes and libraryTypes for modal; updated prop passing and added supporting type definitions.
src/renderer/components/_molecules/variables-table/elements/array-modal.tsx Updated to generate and pass variableTypes and libraryTypes for modal; added library-related type definitions and logic.
src/renderer/components/_molecules/data-types/structure/table/selectable-cell.tsx,
src/renderer/components/_molecules/variables-table/selectable-cell.tsx
Enhanced dropdowns to support independent filtering for variable and library types; refactored filter state and rendering logic for improved usability.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant TypeDropdownSelector
  participant ParentComponent

  User->>TypeDropdownSelector: Clicks dropdown trigger
  TypeDropdownSelector->>User: Shows categorized type menus with search inputs
  User->>TypeDropdownSelector: Types in search input (per category)
  TypeDropdownSelector->>User: Filters and displays matching types
  User->>TypeDropdownSelector: Selects a type
  TypeDropdownSelector->>ParentComponent: Calls onSelect(definition, value)
  ParentComponent->>ParentComponent: Updates state with selected type
Loading

Suggested labels

enhancement

Suggested reviewers

  • JoaoGSP

Poem

In dropdown fields where types abound,
A rabbit hopped and looked around.
With filters new and menus neat,
Each type now sorted, oh what a treat!
Through variable and library rows,
The bunny dances—UI flows!
🐇✨
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-18T00_02_14_895Z-debug-0.log

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (2)
  • DOPE-60: Entity not found: Issue - Could not find referenced Issue.
  • DOPE-61: Entity not found: Issue - Could not find referenced Issue.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f6f879 and 1b888e9.

📒 Files selected for processing (1)
  • src/renderer/components/_atoms/type-dropdown-selector/index.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/renderer/components/_atoms/type-dropdown-selector/index.tsx (6)
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#265
File: src/renderer/components/_atoms/graphical-editor/ladder/block.tsx:149-153
Timestamp: 2025-06-16T14:31:51.786Z
Learning: In src/renderer/components/_atoms/graphical-editor/ladder/block.tsx, the libraries.system data is dynamic and imported from JSON with varying structure, making proper static typing infeasible. The @ts-expect-error and eslint-disable comments are justified when dynamically probing the structure at runtime.
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#218
File: src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx:73-73
Timestamp: 2025-03-14T14:46:03.671Z
Learning: Empty useEffect hooks in the VariableElement component (src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx) are intentional placeholders that will be implemented later as they depend on other logic.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#223
File: src/renderer/components/_atoms/graphical-editor/fbd/block.tsx:380-407
Timestamp: 2025-04-10T18:29:20.310Z
Learning: In the BlockNodeElement component's useEffect for handling variable input focus and initialization, the effect should only run when the data prop changes, not when other referenced variables change. This is an intentional design decision.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#250
File: src/utils/PLC/xml-generator/old-editor/data-type-xml.ts:21-26
Timestamp: 2025-06-04T18:43:50.030Z
Learning: In src/utils/PLC/xml-generator/old-editor/data-type-xml.ts, the team prefers to keep complex nested ternary operators for type determination rather than refactoring them into helper functions, to avoid introducing additional functions.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#223
File: src/renderer/components/_atoms/graphical-editor/fbd/block.tsx:118-252
Timestamp: 2025-04-10T18:26:04.469Z
Learning: The handleNameInputOnBlur function in the FBD block component needs to remain as a single large function due to React Flow's logic requirements, which constrain how node and edge operations can be structured.
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#242
File: src/renderer/components/_features/[workspace]/editor/device/configuration/components/modbus-tcp.tsx:54-56
Timestamp: 2025-05-19T21:46:07.790Z
Learning: In src/renderer/components/_features/[workspace]/editor/device/configuration/components/modbus-tcp.tsx, the `enableDHCPHost` state is currently only used for local rendering logic, but it should be persisted in the global store in future implementations.
🧬 Code Graph Analysis (1)
src/renderer/components/_atoms/type-dropdown-selector/index.tsx (1)
src/renderer/components/_atoms/index.ts (1)
  • InputWithRef (8-8)
⏰ 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). (4)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: test (windows-latest)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@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: 0

🔭 Outside diff range comments (2)
src/renderer/components/_molecules/data-types/array/index.tsx (1)

107-112: Remove redundant forEach loops in dimension updates.

The forEach loops are causing redundant calls to updateDatatype. Each iteration calls the update function with the same data, which is inefficient and could impact performance.

-newRows.forEach(() => {
-  const optionalSchema = {
-    dimensions: newRows.map((row) => ({ dimension: row?.dimension })),
-  }
-  updateDatatype(data.name, optionalSchema as PLCArrayDatatype)
-})
+const optionalSchema = {
+  dimensions: newRows.map((row) => ({ dimension: row?.dimension })),
+}
+updateDatatype(data.name, optionalSchema as PLCArrayDatatype)

Also applies to: 130-136, 153-159

src/renderer/components/_molecules/variables-table/elements/array-modal.tsx (1)

16-54: Centralize type extraction logic to avoid duplication.

The type definitions and library extraction logic are duplicated across multiple files. This makes maintenance difficult and increases the risk of inconsistencies.

Consider creating a utility module:

// src/utils/type-selectors.ts
export const extractTypeCategories = (
  dataTypes: DataType[],
  libraries: Libraries,
  currentEditorName?: string
) => {
  const baseTypes = baseTypeSchema.options.filter(type => type.toUpperCase() !== 'ARRAY')
  
  const userDataTypes = dataTypes
    .map(type => type.name)
    .filter(name => name !== currentEditorName && name.toUpperCase() !== 'ARRAY')
  
  const systemFunctionBlocks = extractSystemFunctionBlocks(libraries.system)
  const userFunctionBlocks = extractUserFunctionBlocks(libraries.user)
  
  return {
    variableTypes: [
      { definition: 'base-type', values: baseTypes },
      { definition: 'user-data-type', values: userDataTypes },
    ],
    libraryTypes: [
      { definition: 'system', values: systemFunctionBlocks },
      { definition: 'user', values: userFunctionBlocks },
    ],
  }
}

This would eliminate duplication and ensure consistent type categorization across all components.

🧹 Nitpick comments (5)
src/renderer/components/_molecules/data-types/array/index.tsx (1)

15-43: Consider improving type safety for library data structures.

The ad-hoc type definitions and complex type assertions in the user library extraction logic could be improved. Consider defining proper types in a shared location or using discriminated unions to handle the different library formats more safely.

Example approach using discriminated unions:

-type Pou = { type: string; name: string }
-type UserLibWithPous = { pous: Pou[] }
-type UserLibFunctionBlock = { type: string; name: string }
+type LibraryPou = {
+  type: 'function' | 'function-block' | 'program'
+  name: string
+}
+
+type UserLibrary = 
+  | { type: 'library'; name: string; pous: LibraryPou[] }
+  | { type: 'function-block'; name: string }

Then simplify the extraction logic:

-const userFunctionBlocks = sliceLibraries.user.flatMap((userLib: UserLibWithPous | UserLibFunctionBlock) =>
-  'pous' in userLib && Array.isArray(userLib.pous)
-    ? userLib.pous.filter((pou) => pou.type === 'function-block').map((pou) => pou.name.toUpperCase())
-    : (userLib as UserLibFunctionBlock).type === 'function-block'
-      ? [(userLib as UserLibFunctionBlock).name.toUpperCase()]
-      : [],
-)
+const userFunctionBlocks = sliceLibraries.user.flatMap((userLib: UserLibrary) => {
+  if (userLib.type === 'library') {
+    return userLib.pous
+      .filter(pou => pou.type === 'function-block')
+      .map(pou => pou.name.toUpperCase())
+  }
+  return userLib.type === 'function-block' ? [userLib.name.toUpperCase()] : []
+})
src/renderer/components/_molecules/data-types/structure/table/selectable-cell.tsx (2)

48-54: Improve readability of nested conditionals.

The deeply nested conditionals and type assertions make this code difficult to maintain. Consider extracting the logic into a helper function or using the same type improvements suggested for the array component.

-'pous' in userLibrary && Array.isArray((userLibrary as { pous: { type: string; name: string }[] }).pous)
-  ? (userLibrary as { pous: { type: string; name: string }[] }).pous
-      .filter((pou) => pou.type === 'function-block')
-      .map((pou) => pou.name.toUpperCase())
-  : userLibrary.type === 'function-block'
-    ? [userLibrary.name.toUpperCase()]
-    : [],
+const extractFunctionBlocks = (lib: UserLibrary): string[] => {
+  if ('pous' in lib && Array.isArray(lib.pous)) {
+    return lib.pous
+      .filter(pou => pou.type === 'function-block')
+      .map(pou => pou.name.toUpperCase())
+  }
+  return lib.type === 'function-block' ? [lib.name.toUpperCase()] : []
+}

120-220: Reduce code duplication in dropdown rendering.

The dropdown structure for variable types and library types is nearly identical. Consider extracting a reusable component or helper to reduce duplication.

Create a reusable dropdown section:

const TypeDropdownSection = ({
  scopes,
  filters,
  onFilterChange,
  onSelect,
  filterKey = 'default'
}: {
  scopes: Array<{ definition: string; values: string[] }>
  filters: Record<string, string> | string
  onFilterChange: (value: string, key?: string) => void
  onSelect: (definition: string, value: string) => void
  filterKey?: string
}) => (
  <>
    {scopes.map((scope) => {
      const filterValue = typeof filters === 'string' ? filters : filters[scope.definition]
      return (
        <PrimitiveDropdown.Sub
          key={scope.definition}
          onOpenChange={() => onFilterChange('', scope.definition)}
        >
          {/* Dropdown content */}
        </PrimitiveDropdown.Sub>
      )
    })}
  </>
)

Then use it for both sections:

-{filteredVariableValues.map((scope) => (
-  // ... duplicate dropdown structure
-))}
-{filteredLibraryValues.map((scope) => (
-  // ... duplicate dropdown structure
-))}
+<TypeDropdownSection
+  scopes={filteredVariableValues}
+  filters={variableFilters}
+  onFilterChange={(value, key) => setVariableFilters(prev => ({ ...prev, [key]: value }))}
+  onSelect={(def, val) => onSelect(def as PLCStructureVariable['type']['definition'], val)}
+/>
+<TypeDropdownSection
+  scopes={filteredLibraryValues}
+  filters={inputFilter}
+  onFilterChange={setInputFilter}
+  onSelect={(_, val) => onSelect('derived', val)}
+/>
src/renderer/components/_molecules/variables-table/selectable-cell.tsx (1)

241-362: Consider extracting common dropdown filtering logic.

This component has the same dropdown structure duplication as the structure table's selectable cell. Consider creating a shared component or hook that both files can use to reduce code duplication across the codebase.

src/renderer/components/_atoms/type-dropdown-selector/index.tsx (1)

24-24: Fix typo in state variable name.

There's a typo in the state variable name that should be corrected for consistency and readability.

-  const [poppoverIsOpen, setPoppoverIsOpen] = useState(false)
+  const [popoverIsOpen, setPopoverIsOpen] = useState(false)

And update the usage in line 42:

-    <PrimitiveDropdown.Root onOpenChange={setPoppoverIsOpen} open={poppoverIsOpen}>
+    <PrimitiveDropdown.Root onOpenChange={setPopoverIsOpen} open={popoverIsOpen}>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 54485fa and 6842bca.

📒 Files selected for processing (7)
  • src/renderer/components/_atoms/dimensions-modal/index.tsx (5 hunks)
  • src/renderer/components/_atoms/type-dropdown-selector/index.tsx (1 hunks)
  • src/renderer/components/_molecules/data-types/array/index.tsx (4 hunks)
  • src/renderer/components/_molecules/data-types/structure/table/elements/array-modal.tsx (3 hunks)
  • src/renderer/components/_molecules/data-types/structure/table/selectable-cell.tsx (5 hunks)
  • src/renderer/components/_molecules/variables-table/elements/array-modal.tsx (3 hunks)
  • src/renderer/components/_molecules/variables-table/selectable-cell.tsx (5 hunks)
🧰 Additional context used
🧠 Learnings (7)
src/renderer/components/_atoms/dimensions-modal/index.tsx (4)
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#265
File: src/renderer/components/_atoms/graphical-editor/ladder/block.tsx:149-153
Timestamp: 2025-06-16T14:31:51.786Z
Learning: In src/renderer/components/_atoms/graphical-editor/ladder/block.tsx, the libraries.system data is dynamic and imported from JSON with varying structure, making proper static typing infeasible. The @ts-expect-error and eslint-disable comments are justified when dynamically probing the structure at runtime.
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#218
File: src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx:73-73
Timestamp: 2025-03-14T14:46:03.671Z
Learning: Empty useEffect hooks in the VariableElement component (src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx) are intentional placeholders that will be implemented later as they depend on other logic.
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#251
File: src/renderer/components/_atoms/dimensions-modal/index.tsx:1-1
Timestamp: 2025-05-23T14:11:13.511Z
Learning: The Radix UI library in this codebase supports named exports such as `import { ScrollArea } from '@radix-ui/react-scroll-area'` rather than requiring namespace imports like `import * as ScrollArea`.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#274
File: src/types/PLC/devices/configuration.ts:0-0
Timestamp: 2025-07-04T15:13:57.599Z
Learning: In src/types/PLC/devices/configuration.ts, the team prefers to handle IP address validation at the local store level when passing values from frontend to backend, rather than adding additional validation at the schema level.
src/renderer/components/_molecules/data-types/array/index.tsx (6)
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#265
File: src/renderer/components/_atoms/graphical-editor/ladder/block.tsx:149-153
Timestamp: 2025-06-16T14:31:51.786Z
Learning: In src/renderer/components/_atoms/graphical-editor/ladder/block.tsx, the libraries.system data is dynamic and imported from JSON with varying structure, making proper static typing infeasible. The @ts-expect-error and eslint-disable comments are justified when dynamically probing the structure at runtime.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#250
File: src/utils/PLC/xml-generator/old-editor/data-type-xml.ts:21-26
Timestamp: 2025-06-04T18:43:50.030Z
Learning: In src/utils/PLC/xml-generator/old-editor/data-type-xml.ts, the team prefers to keep complex nested ternary operators for type determination rather than refactoring them into helper functions, to avoid introducing additional functions.
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#251
File: src/renderer/components/_atoms/dimensions-modal/index.tsx:1-1
Timestamp: 2025-05-23T14:11:13.511Z
Learning: The Radix UI library in this codebase supports named exports such as `import { ScrollArea } from '@radix-ui/react-scroll-area'` rather than requiring namespace imports like `import * as ScrollArea`.
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#218
File: src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx:73-73
Timestamp: 2025-03-14T14:46:03.671Z
Learning: Empty useEffect hooks in the VariableElement component (src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx) are intentional placeholders that will be implemented later as they depend on other logic.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#223
File: src/renderer/components/_atoms/graphical-editor/fbd/block.tsx:126-129
Timestamp: 2025-04-10T18:27:32.877Z
Learning: In the OpenPLC Editor project, the team avoids using TypeScript's `any` type even when dealing with dynamic data structures.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#274
File: src/types/PLC/devices/configuration.ts:0-0
Timestamp: 2025-07-04T15:13:57.599Z
Learning: In src/types/PLC/devices/configuration.ts, the team prefers to handle IP address validation at the local store level when passing values from frontend to backend, rather than adding additional validation at the schema level.
src/renderer/components/_molecules/variables-table/elements/array-modal.tsx (5)
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#265
File: src/renderer/components/_atoms/graphical-editor/ladder/block.tsx:149-153
Timestamp: 2025-06-16T14:31:51.786Z
Learning: In src/renderer/components/_atoms/graphical-editor/ladder/block.tsx, the libraries.system data is dynamic and imported from JSON with varying structure, making proper static typing infeasible. The @ts-expect-error and eslint-disable comments are justified when dynamically probing the structure at runtime.
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#218
File: src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx:73-73
Timestamp: 2025-03-14T14:46:03.671Z
Learning: Empty useEffect hooks in the VariableElement component (src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx) are intentional placeholders that will be implemented later as they depend on other logic.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#250
File: src/utils/PLC/xml-generator/old-editor/data-type-xml.ts:21-26
Timestamp: 2025-06-04T18:43:50.030Z
Learning: In src/utils/PLC/xml-generator/old-editor/data-type-xml.ts, the team prefers to keep complex nested ternary operators for type determination rather than refactoring them into helper functions, to avoid introducing additional functions.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#223
File: src/renderer/components/_atoms/graphical-editor/fbd/block.tsx:126-129
Timestamp: 2025-04-10T18:27:32.877Z
Learning: In the OpenPLC Editor project, the team avoids using TypeScript's `any` type even when dealing with dynamic data structures.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#274
File: src/types/PLC/devices/configuration.ts:0-0
Timestamp: 2025-07-04T15:13:57.599Z
Learning: In src/types/PLC/devices/configuration.ts, the team prefers to handle IP address validation at the local store level when passing values from frontend to backend, rather than adding additional validation at the schema level.
src/renderer/components/_molecules/variables-table/selectable-cell.tsx (5)
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#218
File: src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx:73-73
Timestamp: 2025-03-14T14:46:03.671Z
Learning: Empty useEffect hooks in the VariableElement component (src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx) are intentional placeholders that will be implemented later as they depend on other logic.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#265
File: src/renderer/components/_atoms/graphical-editor/ladder/block.tsx:149-153
Timestamp: 2025-06-16T14:31:51.786Z
Learning: In src/renderer/components/_atoms/graphical-editor/ladder/block.tsx, the libraries.system data is dynamic and imported from JSON with varying structure, making proper static typing infeasible. The @ts-expect-error and eslint-disable comments are justified when dynamically probing the structure at runtime.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#223
File: src/renderer/components/_atoms/graphical-editor/fbd/block.tsx:380-407
Timestamp: 2025-04-10T18:29:20.310Z
Learning: In the BlockNodeElement component's useEffect for handling variable input focus and initialization, the effect should only run when the data prop changes, not when other referenced variables change. This is an intentional design decision.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#250
File: src/utils/PLC/xml-generator/old-editor/data-type-xml.ts:21-26
Timestamp: 2025-06-04T18:43:50.030Z
Learning: In src/utils/PLC/xml-generator/old-editor/data-type-xml.ts, the team prefers to keep complex nested ternary operators for type determination rather than refactoring them into helper functions, to avoid introducing additional functions.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#223
File: src/renderer/components/_atoms/graphical-editor/fbd/block.tsx:126-129
Timestamp: 2025-04-10T18:27:32.877Z
Learning: In the OpenPLC Editor project, the team avoids using TypeScript's `any` type even when dealing with dynamic data structures.
src/renderer/components/_molecules/data-types/structure/table/selectable-cell.tsx (4)
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#265
File: src/renderer/components/_atoms/graphical-editor/ladder/block.tsx:149-153
Timestamp: 2025-06-16T14:31:51.786Z
Learning: In src/renderer/components/_atoms/graphical-editor/ladder/block.tsx, the libraries.system data is dynamic and imported from JSON with varying structure, making proper static typing infeasible. The @ts-expect-error and eslint-disable comments are justified when dynamically probing the structure at runtime.
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#251
File: src/renderer/components/_atoms/dimensions-modal/index.tsx:1-1
Timestamp: 2025-05-23T14:11:13.511Z
Learning: The Radix UI library in this codebase supports named exports such as `import { ScrollArea } from '@radix-ui/react-scroll-area'` rather than requiring namespace imports like `import * as ScrollArea`.
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#218
File: src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx:73-73
Timestamp: 2025-03-14T14:46:03.671Z
Learning: Empty useEffect hooks in the VariableElement component (src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx) are intentional placeholders that will be implemented later as they depend on other logic.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#223
File: src/renderer/components/_atoms/graphical-editor/fbd/block.tsx:126-129
Timestamp: 2025-04-10T18:27:32.877Z
Learning: In the OpenPLC Editor project, the team avoids using TypeScript's `any` type even when dealing with dynamic data structures.
src/renderer/components/_molecules/data-types/structure/table/elements/array-modal.tsx (5)
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#265
File: src/renderer/components/_atoms/graphical-editor/ladder/block.tsx:149-153
Timestamp: 2025-06-16T14:31:51.786Z
Learning: In src/renderer/components/_atoms/graphical-editor/ladder/block.tsx, the libraries.system data is dynamic and imported from JSON with varying structure, making proper static typing infeasible. The @ts-expect-error and eslint-disable comments are justified when dynamically probing the structure at runtime.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#250
File: src/utils/PLC/xml-generator/old-editor/data-type-xml.ts:21-26
Timestamp: 2025-06-04T18:43:50.030Z
Learning: In src/utils/PLC/xml-generator/old-editor/data-type-xml.ts, the team prefers to keep complex nested ternary operators for type determination rather than refactoring them into helper functions, to avoid introducing additional functions.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#223
File: src/renderer/components/_atoms/graphical-editor/fbd/block.tsx:126-129
Timestamp: 2025-04-10T18:27:32.877Z
Learning: In the OpenPLC Editor project, the team avoids using TypeScript's `any` type even when dealing with dynamic data structures.
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#274
File: src/types/PLC/devices/configuration.ts:0-0
Timestamp: 2025-07-04T15:13:57.599Z
Learning: In src/types/PLC/devices/configuration.ts, the team prefers to handle IP address validation at the local store level when passing values from frontend to backend, rather than adding additional validation at the schema level.
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#218
File: src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx:73-73
Timestamp: 2025-03-14T14:46:03.671Z
Learning: Empty useEffect hooks in the VariableElement component (src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx) are intentional placeholders that will be implemented later as they depend on other logic.
src/renderer/components/_atoms/type-dropdown-selector/index.tsx (3)
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#265
File: src/renderer/components/_atoms/graphical-editor/ladder/block.tsx:149-153
Timestamp: 2025-06-16T14:31:51.786Z
Learning: In src/renderer/components/_atoms/graphical-editor/ladder/block.tsx, the libraries.system data is dynamic and imported from JSON with varying structure, making proper static typing infeasible. The @ts-expect-error and eslint-disable comments are justified when dynamically probing the structure at runtime.
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#218
File: src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx:73-73
Timestamp: 2025-03-14T14:46:03.671Z
Learning: Empty useEffect hooks in the VariableElement component (src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx) are intentional placeholders that will be implemented later as they depend on other logic.
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#251
File: src/renderer/components/_atoms/dimensions-modal/index.tsx:1-1
Timestamp: 2025-05-23T14:11:13.511Z
Learning: The Radix UI library in this codebase supports named exports such as `import { ScrollArea } from '@radix-ui/react-scroll-area'` rather than requiring namespace imports like `import * as ScrollArea`.
🧬 Code Graph Analysis (4)
src/renderer/components/_molecules/data-types/array/index.tsx (1)
src/renderer/components/_atoms/type-dropdown-selector/index.tsx (1)
  • TypeDropdownSelector (16-173)
src/renderer/components/_molecules/variables-table/elements/array-modal.tsx (3)
src/renderer/store/index.ts (1)
  • useOpenPLCStore (64-64)
src/shared/data/common.ts (1)
  • baseTypes (35-35)
src/types/PLC/open-plc.ts (1)
  • baseTypeSchema (290-290)
src/renderer/components/_molecules/variables-table/selectable-cell.tsx (1)
src/renderer/components/_atoms/index.ts (1)
  • InputWithRef (8-8)
src/renderer/components/_atoms/type-dropdown-selector/index.tsx (1)
src/renderer/components/_atoms/index.ts (1)
  • InputWithRef (8-8)
⏰ 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). (4)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: test (windows-latest)
🔇 Additional comments (8)
src/renderer/components/_atoms/dimensions-modal/index.tsx (1)

77-82: Clean integration of TypeDropdownSelector.

The refactoring properly replaces the Select component with TypeDropdownSelector and correctly handles the new API by ignoring the definition parameter since only the value is needed here.

src/renderer/components/_atoms/type-dropdown-selector/index.tsx (3)

26-29: Good design choice for separate filtering approaches.

The implementation correctly uses individual filters for variable types (allowing independent search per category) while sharing a single filter for library types. This provides a good balance between functionality and simplicity.


89-89: Proper event propagation handling.

Good use of stopPropagation() to prevent the dropdown from closing when typing in the search input fields.


96-96: No runtime validation needed for definition cast

The scope.definition passed into this component is already constrained by your upstream Zod schemas to only 'base-type' or 'user-data-type' (see src/types/PLC/units/variable.ts and how variableTypes is built in src/utils/generate-iec-string-to-variables.ts). As such:

  • variableTypes never contains a 'derived' definition here
  • The cast to as 'base-type' | 'user-data-type' is safe
  • Your onSelect prop signature allows 'derived' for other contexts but isn’t used in this dropdown

No additional runtime checks are required. If you prefer stricter typing, you could narrow the onSelect parameter to exclude 'derived', but it’s not necessary for correctness.

src/renderer/components/_molecules/data-types/structure/table/elements/array-modal.tsx (4)

16-18: Well-defined types for library data structures.

The type definitions appropriately handle the different shapes of library data, enabling proper type safety for the extraction logic below.


47-53: Robust handling of heterogeneous user library structures.

The type guard logic effectively handles different user library shapes (arrays vs single objects) while maintaining type safety. The nested conditionals properly extract function blocks from both structures.


37-42: Consistent filtering logic for array base types.

Good implementation that filters out 'ARRAY' from both base types and user data types, and excludes the current type name to prevent recursive references.


204-205: DimensionsModal prop compatibility verified
The DimensionsModalProps interface now declares both variableTypes and libraryTypes and no longer includes allTypes. No further updates are needed.

Copy link
Copy Markdown
Contributor

@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: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6842bca and 4f6f879.

📒 Files selected for processing (1)
  • src/renderer/components/_atoms/type-dropdown-selector/index.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/renderer/components/_atoms/type-dropdown-selector/index.tsx (2)
Learnt from: vmleroy
PR: Autonomy-Logic/openplc-editor#265
File: src/renderer/components/_atoms/graphical-editor/ladder/block.tsx:149-153
Timestamp: 2025-06-16T14:31:51.786Z
Learning: In src/renderer/components/_atoms/graphical-editor/ladder/block.tsx, the libraries.system data is dynamic and imported from JSON with varying structure, making proper static typing infeasible. The @ts-expect-error and eslint-disable comments are justified when dynamically probing the structure at runtime.
Learnt from: JoaoGSP
PR: Autonomy-Logic/openplc-editor#218
File: src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx:73-73
Timestamp: 2025-03-14T14:46:03.671Z
Learning: Empty useEffect hooks in the VariableElement component (src/renderer/components/_atoms/graphical-editor/fbd/variable.tsx) are intentional placeholders that will be implemented later as they depend on other logic.
🧬 Code Graph Analysis (1)
src/renderer/components/_atoms/type-dropdown-selector/index.tsx (1)
src/renderer/components/_atoms/index.ts (1)
  • InputWithRef (8-8)
🔇 Additional comments (3)
src/renderer/components/_atoms/type-dropdown-selector/index.tsx (3)

29-36: LGTM! Well-structured dropdown with proper accessibility and styling.

The dropdown trigger implementation is solid with proper disabled state handling, responsive styling, and dark mode support.


37-42: LGTM! Proper portal implementation with good styling.

The portal and content structure follows Radix UI best practices with appropriate positioning and styling.


157-161: LGTM! Proper component structure completion.

The component is properly closed with correct Radix UI component hierarchy.

Comment thread src/renderer/components/_atoms/type-dropdown-selector/index.tsx Outdated
Comment thread src/renderer/components/_atoms/type-dropdown-selector/index.tsx
Comment thread src/renderer/components/_atoms/type-dropdown-selector/index.tsx
Comment thread src/renderer/components/_atoms/type-dropdown-selector/index.tsx
Copy link
Copy Markdown
Contributor

@JulioSergioFS JulioSergioFS left a comment

Choose a reason for hiding this comment

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

Review coderabbit suggestions and mine to be approved.

Comment thread src/renderer/components/_atoms/type-dropdown-selector/index.tsx Outdated
Comment thread src/renderer/components/_atoms/type-dropdown-selector/index.tsx Outdated
@JulioSergioFS JulioSergioFS self-requested a review July 18, 2025 14:23
Copy link
Copy Markdown
Contributor

@JulioSergioFS JulioSergioFS left a comment

Choose a reason for hiding this comment

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

lgtm

@Gustavohsdp Gustavohsdp merged commit 9058deb into development Jul 22, 2025
8 checks passed
@Gustavohsdp Gustavohsdp deleted the feature/dope-60-and-dope-61/allow-more-types branch July 22, 2025 15:16
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.

3 participants