Skip to content

Conversation

@senithkay
Copy link
Contributor

@senithkay senithkay commented Jan 20, 2026

Purpose

Purpose of this PR is to address comments in older PRs

Summary by CodeRabbit

  • Refactor

    • Adjusted how completion data is synchronized in the expression editor, simplifying internal update behavior.
    • Narrowed/relaxed some internal type/signature expectations to allow undefined where appropriate.
  • Style

    • Minor comment wording/formatting cleanup with no behavior change.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

Walkthrough

Removed a useEffect that synced completionsRef with props.completions in ChipExpressionEditor; adjusted two function signatures to allow/reflect undefined returns; a minor comment wrap change in ArrayEditor.

Changes

Cohort / File(s) Summary
Chip expression editor — completion ref removal
workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/components/ChipExpressionEditor.tsx
Deleted the useEffect that assigned completionsRef.current = props.completions and reset completionsFetchScheduledRef.current (removes automatic prop→ref sync).
Token utility signature change
workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/CodeUtils.ts
Changed isSelectionOnToken return type to `ParsedToken
Input mode util signature change
workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/utils.ts
Changed getInputModeFromTypes return type to `InputMode
Minor comment formatting
workspaces/ballerina/ballerina-side-panel/src/components/editors/ArrayEditor.tsx
Non-functional comment line reflow/grammar adjustment.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nibbled code in morning light,
One effect hopped off out of sight.
Types stretched their paws, now optional, too,
Small tidy hops — a clearer view. ✨

🚥 Pre-merge checks | ❌ 3
❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is severely incomplete. Only the 'Purpose' section is minimally filled with a generic statement. All other required sections (Goals, Approach, UI Component Development, Icons, User Stories, Release Notes, Documentation, etc.) are missing or empty. Complete the PR description by filling in all required template sections, particularly Goals, Approach, and explain which specific PR comments are being addressed and why.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Fix PR comments' is too vague and generic. It does not clearly describe the specific technical changes made (ref updates, type signatures, comment fixes) or which PR comments are being addressed. Provide a more specific title that describes the main technical change, e.g., 'Update type signatures and remove completion ref sync effect' or 'Address PR review comments on type definitions'.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

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

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: 1

🤖 Fix all issues with AI agents
In
`@workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/utils.ts`:
- Around line 44-45: Change the return types of getDefaultExpressionMode and
getSecondaryMode from InputMode to InputMode | undefined to match
getInputModeFromTypes which can return undefined; update their function
signatures (getDefaultExpressionMode, getSecondaryMode) and then audit callers
(notably ModeSwitcher) to handle the undefined case (provide a fallback or
guard) so no undefined is passed where a concrete InputMode is required.

Comment on lines +44 to 45
export const getInputModeFromTypes = (inputType: InputType): InputMode | undefined => {
if (!inputType) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, locate and examine the utils.ts file
fd "utils.ts" -p "workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor"

Repository: wso2/vscode-extensions

Length of output: 311


🏁 Script executed:

# Search for the relevant functions in the file
rg -n "getInputModeFromTypes|getDefaultExpressionMode|getSecondaryMode" --type=ts -A 5 -B 1

Repository: wso2/vscode-extensions

Length of output: 10419


🏁 Script executed:

# Search for all usages of these functions across the codebase
rg -n "getDefaultExpressionMode|getSecondaryMode" --type=ts --type=tsx -B 2 -A 2

Repository: wso2/vscode-extensions

Length of output: 93


🏁 Script executed:

# Examine the exact implementations and return statements in utils.ts
cat -n workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/utils.ts | sed -n '44,87p'

Repository: wso2/vscode-extensions

Length of output: 1836


🏁 Script executed:

# Check how ModeSwitcher uses these functions - check for any fallback logic
cat -n workspaces/ballerina/ballerina-side-panel/src/components/ModeSwitcher/index.tsx | sed -n '33,45p'

Repository: wso2/vscode-extensions

Length of output: 600


🏁 Script executed:

# Look for tsconfig to understand strict type checking settings
fd tsconfig.json -x cat {}

Repository: wso2/vscode-extensions

Length of output: 42315


Update return types of getDefaultExpressionMode and getSecondaryMode to reflect that they can return undefined.

Both functions declare return type InputMode but call getInputModeFromTypes() which can return undefined. When getInputModeFromTypes returns undefined (e.g., when the input type is missing or unmapped), these wrapper functions pass that undefined to callers that expect a concrete InputMode value.

Update the return types to InputMode | undefined and review callers in ModeSwitcher to ensure they handle the undefined case properly.

Proposed fix
-export const getDefaultExpressionMode = (inputTypes: InputType[]): InputMode => {
+export const getDefaultExpressionMode = (inputTypes: InputType[]): InputMode | undefined => {
     const primaryInputType = getPrimaryInputType(inputTypes);
     return getInputModeFromTypes(primaryInputType);
 }
-export const getSecondaryMode = (inputTypes: InputType[]): InputMode => {
+export const getSecondaryMode = (inputTypes: InputType[]): InputMode | undefined => {
     const secondaryInputType = inputTypes?.length ? inputTypes[inputTypes.length - 1] : undefined;
     return getInputModeFromTypes(secondaryInputType);
 }
🤖 Prompt for AI Agents
In
`@workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/utils.ts`
around lines 44 - 45, Change the return types of getDefaultExpressionMode and
getSecondaryMode from InputMode to InputMode | undefined to match
getInputModeFromTypes which can return undefined; update their function
signatures (getDefaultExpressionMode, getSecondaryMode) and then audit callers
(notably ModeSwitcher) to handle the undefined case (provide a fallback or
guard) so no undefined is passed where a concrete InputMode is required.

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