Skip to content

Conversation

@logonoff
Copy link
Member

@logonoff logonoff commented Nov 19, 2025

Previously, the connect useCallback had obj in the dependency array, which caused unnecessary rerenders of the terminal. Now, the dependency array is made more specific to reduce the need for rerendering.

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Nov 19, 2025
@openshift-ci-robot
Copy link
Contributor

@logonoff: This pull request references Jira Issue OCPBUGS-65776, which is invalid:

  • expected the bug to target the "4.21.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Previously, the useCallback hook had obj in the dependency array, which caused unnecessary rerenders of the terminal. Now, we make the dependency array more specific to reduce the need for

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link

coderabbitai bot commented Nov 19, 2025

Walkthrough

Refactors pod-connect.tsx to extract pod metadata (name, namespace) and platform information into memoized values, restructures connect command construction to use these extracted values, updates WebSocket factory naming conventions, and expands effect dependencies to include the memoized values.

Changes

Cohort / File(s) Change Summary
Pod Connect Component Refactoring
frontend/public/components/pod-connect.tsx
Introduced memoized extraction of podName and namespace from obj; added memoized isWindows computation via isWindowsPod(obj). Reworked connect command construction to reference extracted values instead of local extraction. Updated WSFactory naming from name-terminal to podName-terminal. Expanded effect dependencies to include podName, namespace, and isWindows. Added minor comments and lint suppressions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Memoization correctness: Verify dependency arrays are complete and appropriate for useMemo hooks to prevent unnecessary recalculations or stale closures.
  • Command construction logic: Review the conditional logic for cmd vs sh invocation based on isWindows flag to ensure correctness across platform cases.
  • Effect dependencies: Confirm all expanded dependencies in the main effect are accurate and necessary to avoid infinite loops or missed updates.
  • WebSocket initialization: Validate that podName-terminal naming references are consistent and properly propagated throughout the component.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 5bde0aa and a1982e0.

📒 Files selected for processing (1)
  • frontend/public/components/pod-connect.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/public/components/pod-connect.tsx
🔇 Additional comments (4)
frontend/public/components/pod-connect.tsx (4)

82-85: LGTM! Clean usage of memoized values.

The command construction and params setup now use the memoized isWindows, namespace, and podName values, which is consistent with the rerender optimization goal.


108-108: LGTM! Correct usage of memoized podName.

The WSFactory identifier now correctly uses the memoized podName value.


149-149: LGTM! This is the core optimization.

The dependency array now includes the specific memoized values (podName, namespace, isWindows) instead of the entire obj, which will significantly reduce unnecessary rerenders when unrelated fields in obj change. This aligns with the PR objective.


78-78: No issues found—memoization dependency is correct.

The isWindowsPod function (at frontend/public/module/k8s/pods.ts:311-312) only accesses pod?.spec?.tolerations to check for Windows OS tolerance. The dependency array [obj?.spec?.tolerations] in the memoization is therefore correct and sufficient.


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

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Nov 19, 2025
@openshift-ci-robot
Copy link
Contributor

@logonoff: This pull request references Jira Issue OCPBUGS-65776, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.21.0) matches configured target version for branch (4.21.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

In response to this:

Previously, the connect useCallback had obj in the dependency array, which caused unnecessary rerenders of the terminal. Now, the dependency array is made more specific to reduce the need for rerendering.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the component/core Related to console core functionality label Nov 19, 2025
@logonoff
Copy link
Member Author

/cherry-pick release-4.20 release-4.19

@openshift-cherrypick-robot

@logonoff: once the present PR merges, I will cherry-pick it on top of release-4.20 in a new PR and assign it to you.

In response to this:

/cherry-pick release-4.20 release-4.19

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 19, 2025
Copy link
Member

@rhamilto rhamilto left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 19, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 19, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: logonoff, rhamilto

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 20, 2025

@logonoff: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@logonoff
Copy link
Member Author

/assign @yapei

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants