Skip to content

Conversation

@senithkay
Copy link
Contributor

@senithkay senithkay commented Dec 2, 2025

Purpose

The value serializer dropdown in kafka:Producer was missing several serializer options.
This prevented users from selecting certain serializer types (e.g., SER_AVRO) when typing prefixes such as SER_.

This PR resolves wso2/product-ballerina-integrator#1983

Goals

  • Ensure that valid serializer options appear in the value serializer dropdown.
  • Improve the accuracy and completeness of the completion suggestions.

Approach

The issue was caused by the completion filtering logic excluding valid completion types.
To fix this, the filter was updated to allow completions where:

  • completion.kind === 'enum-member'

This ensures that serializer-related suggestions are included in the completions.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced autocomplete suggestions in the expression editor to include enum members when a prefix is provided during code editing.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

Walkthrough

The change modifies the completion filter logic in ChipExpressionEditor to include enum-member kinds when a prefix is provided. Previously, enum-members were excluded from completions; now they are treated alongside functions, variables, and fields during prefix matching.

Changes

Cohort / File(s) Change Summary
Completion Filter Enhancement
workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/utils.ts
Modified the completion filter to include enum-member kinds when a prefix is supplied, allowing enum values to appear in filtered completions alongside functions, variables, and fields.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify that the enum-member kind addition doesn't introduce unintended completions in other contexts
  • Confirm the filter logic correctly handles empty prefix scenarios (should return only fields as before)
  • Validate that the change resolves the kafka:Producer value serializer dropdown issue mentioned in #1983

Possibly related PRs

Suggested reviewers

  • hevayo
  • gigara
  • kanushka

Poem

🐰 A humble enum hid in the shadows, unseen,
Until the filter's heart grew keen,
Now SER_AVRO dances in the dropdown's light,
The rabbit's fix makes the serializer right! ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the main change: enabling kafka producer serializer completions by fixing the filter logic.
Description check ✅ Passed The description includes Purpose, Goals, and Approach sections as required by template, though most optional sections are omitted.
Linked Issues check ✅ Passed The PR directly addresses issue #1983 by allowing enum-member completions for kafka producer serializers, matching the reported requirement.
Out of Scope Changes check ✅ Passed The change is narrowly scoped to fixing the completion filter for enum-member kinds in kafka producer serializer dropdowns, aligning with the linked issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

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

🧹 Nitpick comments (1)
workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/utils.ts (1)

145-150: Re-evaluate whether enum members should also appear when no prefix is present

When prefix is falsy, the filter still returns only kind === 'field'. For the value serializer dropdown, that means enum members won’t show up until the user starts typing. If the UX expectation is to see all serializer options immediately on opening the dropdown (even before typing), consider including enum-member in the no-prefix branch as well.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a333bcf and 2a9b951.

📒 Files selected for processing (1)
  • workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/utils.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-24T22:16:28.380Z
Learnt from: dan-niles
Repo: wso2/vscode-extensions PR: 980
File: workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/RichTextTemplateEditor/RichTextTemplateEditor.tsx:384-412
Timestamp: 2025-11-24T22:16:28.380Z
Learning: In the RichTextTemplateEditor component (workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/RichTextTemplateEditor/RichTextTemplateEditor.tsx), token fetching on external `value` prop changes is intentionally disabled. Users cannot edit both the minimized and expanded editors simultaneously, so tokens only need to be generated based on user typing in the expanded editor view, not on external prop updates.

Applied to files:

  • workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/utils.ts
🔇 Additional comments (1)
workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/utils.ts (1)

152-155: Enum-member inclusion in prefix-based filtering looks correct

Allowing completion.kind === 'enum-member' in the prefix filter aligns with the goal of surfacing enum-based serializers (e.g., SER_AVRO) when the user types a prefix like SER_. The case-insensitive startsWith check is consistent with the existing pattern and should cover the reported kafka:Producer scenario.

Please double-check that the completion items for Kafka serializer values actually come through with kind === 'enum-member' (and not e.g. enumMember or another variant) in the @wso2/ui-toolkit CompletionItem type, just to avoid a silent mismatch.

@kanushka kanushka merged commit 0b34d17 into wso2:main Dec 3, 2025
6 checks passed
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.

Value serializer dropdown in kafka:Producer is missing some values

2 participants