Skip to content

Conversation

@sigmaaa
Copy link
Collaborator

@sigmaaa sigmaaa commented Jan 5, 2026

Description

Added a search field to the Component Manager to allow users to quickly find components. Also edited the loaded components method to avoid issues with encoding.

image

Fixes # (IEP-1674)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How has this been tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • ESP-IDF Version:
  • OS (Windows,Linux and macOS):

Dependent components impacted by this PR:

  • Component 1
  • Component 2

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a search and filter field to the components installer interface, enabling users to quickly discover and locate specific components by name with case-insensitive text matching for improved efficiency.
  • Improvements

    • Enhanced component visibility controls and layout responsiveness to provide a better user experience during component selection and management workflows.

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 5, 2026

📝 Walkthrough

Walkthrough

The changes introduce a search/filter feature to the Install Components editor, refactor the layout system from FillLayout to GridLayout, and enhance component visibility control with improved resource lifecycle management across the UI editor.

Changes

Cohort / File(s) Summary
Layout & Search Feature
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/InstallComponentsEditor.java
Replaced FillLayout with GridLayout for better resizing behavior. Added search Text field with filter styling above scrolled content. Introduced resize listener to dynamically adjust scrolled content minimum size based on parent width. Search field wired to filter components list on text change.
Component Visibility & Lifecycle
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/container/ComponentContainer.java
Added public methods getComponentVO() and setVisible(boolean) for visibility control. Refactored member fields to local scope for improved resource management. Hardened dispose() logic with isDisposed checks. Enhanced UI element lifecycle with READ_ONLY text styling and safer resource cleanup.
Component Filtering & State Management
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/container/InstallComponentsCompositePage.java
Added public filterComponents(String query) method for case-insensitive name-based filtering. Introduced UI state fields (scrolledParent, containerComposite) for dynamic layout updates. Improved JSON loading with try-with-resources and configurable charset.
Resource Messages
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/Messages.java, messages.properties
Added new message key InstallComponentsEditor_SearchComponentMsg with value "Filter components..." for search field label.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A search field hops into the scene,
With filters and layouts so clean,
Components now hide and appear,
As the editor's purpose grows clear,
Fine-tuned resource management—hooray!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding a search field to the Component Manager for filtering components.
✨ 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

Comment @coderabbitai help to get the list of available commands and usage tips.

@sigmaaa sigmaaa changed the title feat: adding search field to the manager IEP-1674 Add Search Field to Component Manager Jan 5, 2026
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: 0

🧹 Nitpick comments (5)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/container/InstallComponentsCompositePage.java (2)

81-85: Potential StringIndexOutOfBoundsException on empty line.

StringUtil.isEmpty() returns false for a non-null empty string "" (since "".trim().length() is 0, it should return true). However, if a line contains only whitespace (e.g., " "), after trim() the length becomes 0, so it would pass isEmpty. But the issue is ymlEntry itself is not trimmed before the check—so a line like "" would fail isEmpty() (wait, actually "".trim().length() == 0 so it returns true).

Let me re-check: Looking at the provided StringUtil.isEmpty(): it returns true if text == null || text.trim().length() == 0. So an empty string "" would return true and be caught. However, a string with only a space " " would also return true.

The logic appears safe, but the inline comment // $NON-NLS-1$ is malformed (should be inside a string literal or removed).

🔎 Suggested cleanup
-				if ((!StringUtil.isEmpty(ymlEntry)) && ymlEntry.charAt(0) == '#') // $NON-NLS-1$
+				if ((!StringUtil.isEmpty(ymlEntry)) && ymlEntry.charAt(0) == '#')

The $NON-NLS-1$ comment is not associated with any string literal on this line and should be removed.


113-117: Raw type usage causes unchecked assignment.

gson.fromJson(reader, ArrayList.class) returns a raw ArrayList, leading to an unchecked assignment to List<ComponentVO>. Consider using a TypeToken to preserve generic type information.

🔎 Suggested fix using TypeToken
+import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
-			componentVOs = gson.fromJson(reader, ArrayList.class);
+			Type listType = new TypeToken<ArrayList<ComponentVO>>(){}.getType();
+			componentVOs = gson.fromJson(reader, listType);

This ensures type-safe deserialization and eliminates the unchecked cast warning.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/InstallComponentsEditor.java (1)

89-95: setLayout() on ScrolledComposite is unnecessary.

ScrolledComposite manages its own internal layout for the scrolled content. Setting a GridLayout on it (line 92) has no effect since ScrolledComposite ignores the layout manager—it uses setContent() and setMinSize() to control its child. This line can be safely removed.

🔎 Suggested fix
 		ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
 		scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
-		scrolledComposite.setLayout(new GridLayout());
 		scrolledComposite.setAlwaysShowScrollBars(true);
 		scrolledComposite.setExpandHorizontal(true);
 		scrolledComposite.setExpandVertical(true);
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/container/ComponentContainer.java (2)

93-94: Hardcoded font name may not be available on all platforms.

"Arial" is not guaranteed to exist on Linux systems. Consider using a system font or the control's default font with only the style modified.

🔎 Suggested fix using system font
-		boldFont = new Font(controlGroup.getDisplay(), new FontData("Arial", 8, SWT.BOLD)); //$NON-NLS-1$
+		FontData[] fontData = controlGroup.getFont().getFontData();
+		for (FontData fd : fontData) {
+			fd.setStyle(SWT.BOLD);
+		}
+		boldFont = new Font(controlGroup.getDisplay(), fontData);

This preserves the system's default font family while applying the bold style, ensuring cross-platform compatibility.


130-152: Redundant empty check for readme URL.

The outer condition on line 130 already verifies !StringUtil.isEmpty(componentDetailsVO.getReadMe()), making the inner check on lines 142-143 unreachable under normal circumstances. The inner check could only be useful if getReadMe() returned different values between calls, which is unlikely.

🔎 Suggested simplification
 			openReadMe.addSelectionListener(new SelectionAdapter()
 			{
 				@Override
 				public void widgetSelected(SelectionEvent e)
 				{
 					String url = componentDetailsVO.getReadMe();
 					try
 					{
-						if (StringUtil.isEmpty(url))
-							return;
 						org.eclipse.swt.program.Program.launch(url);
 					}
 					catch (Exception e1)
 					{
 						Logger.log(e1);
 					}
 				}
 			});

If there's a concern about the value changing between button creation and click, consider capturing the URL in a final variable when creating the button.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 51ab80e and 47a88fd.

📒 Files selected for processing (5)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/InstallComponentsEditor.java
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/Messages.java
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/container/ComponentContainer.java
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/container/InstallComponentsCompositePage.java
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/messages.properties
🧰 Additional context used
🧬 Code graph analysis (2)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/InstallComponentsEditor.java (1)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/Messages.java (1)
  • Messages (16-34)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/container/InstallComponentsCompositePage.java (1)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/StringUtil.java (1)
  • StringUtil (11-25)
⏰ 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). (2)
  • GitHub Check: build_linux
  • GitHub Check: build_windows
🔇 Additional comments (8)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/messages.properties (1)

4-4: LGTM!

The new message key follows the existing naming convention and provides an appropriate placeholder text for the search field.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/Messages.java (1)

23-24: LGTM!

The new message field follows the standard Eclipse NLS pattern and correctly corresponds to the entry in messages.properties.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/container/InstallComponentsCompositePage.java (1)

128-160: LGTM!

The filterComponents method is well-implemented with proper null handling, case-insensitive matching, and efficient layout updates only when visibility actually changes. The ScrolledComposite resizing logic correctly adjusts the minimum size based on the client area width.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/InstallComponentsEditor.java (2)

83-87: LGTM!

The search field is properly configured with appropriate SWT styles (SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL) and uses the localized message for the placeholder. The ModifyListener correctly triggers filtering on each text change.


141-146: LGTM!

The dispose() method properly invokes super.dispose() before disposing of the child composite page, following the correct SWT resource cleanup pattern.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/installcomponents/container/ComponentContainer.java (3)

54-57: LGTM!

Simple accessor method for the component value object, enabling filtering logic in InstallComponentsCompositePage.


59-82: LGTM!

The setVisible method correctly manages both the control visibility and GridData.exclude property, ensuring hidden components don't consume layout space. The return value indicating whether state changed enables efficient layout updates in the caller.


194-208: LGTM!

The dispose() method properly guards against already-disposed resources and nulls out references after disposal, following SWT best practices for resource management.

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