Skip to content

Conversation

@logonoff
Copy link
Member

@logonoff logonoff commented Jan 6, 2026

Changes:

  • registerYAMLinMonaco returns a pointer to the monaco yaml.configure function, so that we can update the monaco integration at a later time
  • CodeEditor now saves the yaml.configure pointer and will always update monaco YAML definitions on mount
  • We introduce a console_swagger_refresh window event whenever swagger refreshes, and CodeEditor will listen to it on mount, calling yaml.configure whenever there is a change to the swagger definitions (which refresh every 5 minutes)

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

@logonoff: This pull request references Jira Issue OCPBUGS-70340, 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.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

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

Details

In response to this:

Changes:

  • yaml-editor-utils returns a pointer to the monaco yaml.configure function, so that we can update swagger at a later time
  • CodeEditor now saves the yaml.configure pointer and will always update monaco YAML definitions on mount
  • We introduce a console_swagger_refresh window event whenever swagger refreshes, and CodeEditor will listen to it on mount, calling yaml.configure whenever there is a change to the swagger definitions (which refresh every 5 minutes)

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 requested a review from yapei January 6, 2026 03:13
@coderabbitai
Copy link

coderabbitai bot commented Jan 6, 2026

Walkthrough

Adds a function to build Monaco YAML schemas, refactors Monaco YAML registration to return a shared instance, updates the code editor to store and refresh that instance and subscribe to a refresh event, and emits a DOM event when swagger definitions update to trigger schema refreshes.

Changes

Cohort / File(s) Summary
YAML Schema Management
frontend/packages/console-shared/src/components/editor/yaml-editor-utils.ts
Added getConsoleYamlSchemas(): SchemasSettings[]. Refactored registerYAMLinMonaco to use those schemas, call configureMonacoYaml, guard re-registration, maintain a shared currentMonacoYamlInstance, and return that instance.
Editor Component Integration
frontend/packages/console-shared/src/components/editor/CodeEditor.tsx
Added monacoYAML state to store the returned Monaco YAML instance. On YAML language init, save the instance. Added updateSwaggerDefinitions() to retrieve schemas and call monacoYAML.update({ schemas }). Subscribed to console_swagger_refresh via a useEffect with cleanup.
Event Dispatch
frontend/public/module/k8s/swagger.ts
After assigning swaggerDefinitions from OpenAPI, dispatches window.dispatchEvent(new Event('console_swagger_refresh')) to notify listeners and trigger schema updates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing touches
  • 📝 Generate docstrings

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

@openshift-ci openshift-ci bot requested review from jhadvig and rhamilto January 6, 2026 03:13
@openshift-ci openshift-ci bot added the component/core Related to console core functionality label Jan 6, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 6, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: logonoff

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

The pull request process is described here

Details 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 openshift-ci bot added component/shared Related to console-shared approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 6, 2026
@openshift-ci-robot
Copy link
Contributor

@logonoff: This pull request references Jira Issue OCPBUGS-70340, which is valid.

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

Requesting review from QA contact:
/cc @yapei

Details

In response to this:

Changes:

  • registerYAMLinMonaco returns a pointer to the monaco yaml.configure function, so that we can update the monaco integration at a later time
  • CodeEditor now saves the yaml.configure pointer and will always update monaco YAML definitions on mount
  • We introduce a console_swagger_refresh window event whenever swagger refreshes, and CodeEditor will listen to it on mount, calling yaml.configure whenever there is a change to the swagger definitions (which refresh every 5 minutes)

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.

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 (1)
frontend/packages/console-shared/src/components/editor/CodeEditor.tsx (1)

61-68: LGTM!

The effect correctly initializes YAML schemas and listens for swagger refresh events. The cleanup ensures no memory leaks.

The effect re-runs when monacoYaml changes, causing the event listener to be removed and re-added. While this works correctly, you could optimize by separating concerns:

🔎 Optional optimization to separate initial update from event listener setup
+  useEffect(() => {
+    updateSwaggerDefinitions();
+  }, [updateSwaggerDefinitions]);
+
-  useEffect(() => {
-    updateSwaggerDefinitions();
-
+  useEffect(() => {
     window.addEventListener('console_swagger_refresh', updateSwaggerDefinitions);
     return () => {
       window.removeEventListener('console_swagger_refresh', updateSwaggerDefinitions);
     };
   }, [updateSwaggerDefinitions]);
📜 Review details

Configuration used: Organization 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 24830e3 and 14ae623.

📒 Files selected for processing (3)
  • frontend/packages/console-shared/src/components/editor/CodeEditor.tsx
  • frontend/packages/console-shared/src/components/editor/yaml-editor-utils.ts
  • frontend/public/module/k8s/swagger.ts
🧰 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/packages/console-shared/src/components/editor/yaml-editor-utils.ts
  • frontend/public/module/k8s/swagger.ts
  • frontend/packages/console-shared/src/components/editor/CodeEditor.tsx
🧬 Code graph analysis (2)
frontend/packages/console-shared/src/components/editor/yaml-editor-utils.ts (1)
frontend/public/module/k8s/swagger.ts (1)
  • getSwaggerDefinitions (26-26)
frontend/packages/console-shared/src/components/editor/CodeEditor.tsx (2)
frontend/packages/console-dynamic-plugin-sdk/src/extensions/console-types.ts (2)
  • CodeEditorRef (692-695)
  • CodeEditorProps (680-690)
frontend/packages/console-shared/src/components/editor/yaml-editor-utils.ts (2)
  • registerYAMLinMonaco (118-141)
  • getConsoleYamlSchemas (95-109)
🔇 Additional comments (9)
frontend/public/module/k8s/swagger.ts (1)

40-40: LGTM!

The event dispatch is correctly placed after successful swagger definition assignment, enabling listeners to reactively update YAML schemas.

frontend/packages/console-shared/src/components/editor/CodeEditor.tsx (4)

8-13: LGTM!

The import additions correctly support the new YAML schema synchronization workflow.


21-23: LGTM!

The state correctly captures the YAML Monaco instance for subsequent schema updates.


38-38: LGTM!

Correctly stores the YAML Monaco instance returned by registerYAMLinMonaco for later schema updates.


53-59: LGTM!

The callback correctly fetches fresh YAML schemas and updates the Monaco YAML instance. The null check ensures safe operation before the editor mounts.

frontend/packages/console-shared/src/components/editor/yaml-editor-utils.ts (4)

3-3: LGTM!

The SchemasSettings type import is correctly added to support the new schema configuration functionality.


116-116: LGTM!

The module-level variable correctly maintains a singleton instance of the Monaco YAML configuration, preventing duplicate registrations.


118-141: LGTM!

The function correctly returns the Monaco YAML instance for later schema updates. The check on line 128 prevents duplicate language registrations.

Note: This function depends on getConsoleYamlSchemas() which should be updated to handle null swagger definitions (see previous comment).


95-109: openAPItoJSONSchema already handles null input gracefully.

The concern about passing null to openAPItoJSONSchema() without validation is not applicable here. The function already includes a null check (lines 93-94 of openapi-to-json-schema.ts) that returns null if the input is falsy, preventing any runtime errors.

However, returning a schema object with a null schema property when swagger definitions haven't loaded yet is suboptimal. Returning an empty array would be preferable to avoid registering an incomplete schema.

Likely an incorrect or invalid review comment.

@logonoff logonoff force-pushed the OCPBUGS-70340-yolo-swagger branch from 14ae623 to 32493e3 Compare January 6, 2026 03:21
@logonoff logonoff force-pushed the OCPBUGS-70340-yolo-swagger branch from 32493e3 to f7ba996 Compare January 7, 2026 17:00
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 (1)
frontend/packages/console-shared/src/components/editor/yaml-editor-utils.ts (1)

115-115: Initialize currentMonacoYamlInstance explicitly.

The variable is typed as | null but is implicitly undefined initially. For type consistency, explicitly initialize it to match the type annotation.

♻️ Proposed fix
-let currentMonacoYamlInstance: ReturnType<typeof configureMonacoYaml> | null = null;
+let currentMonacoYamlInstance: ReturnType<typeof configureMonacoYaml> | null = null;

Actually, looking more carefully at the existing code, it appears the initialization is missing. Add = null:

-let currentMonacoYamlInstance: ReturnType<typeof configureMonacoYaml> | null;
+let currentMonacoYamlInstance: ReturnType<typeof configureMonacoYaml> | null = null;
📜 Review details

Configuration used: Organization 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 32493e3 and f7ba996.

📒 Files selected for processing (3)
  • frontend/packages/console-shared/src/components/editor/CodeEditor.tsx
  • frontend/packages/console-shared/src/components/editor/yaml-editor-utils.ts
  • frontend/public/module/k8s/swagger.ts
🧰 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/module/k8s/swagger.ts
  • frontend/packages/console-shared/src/components/editor/yaml-editor-utils.ts
  • frontend/packages/console-shared/src/components/editor/CodeEditor.tsx
🧬 Code graph analysis (2)
frontend/packages/console-shared/src/components/editor/yaml-editor-utils.ts (1)
frontend/public/module/k8s/swagger.ts (1)
  • getSwaggerDefinitions (26-26)
frontend/packages/console-shared/src/components/editor/CodeEditor.tsx (3)
frontend/packages/console-dynamic-plugin-sdk/src/extensions/console-types.ts (2)
  • CodeEditorRef (692-695)
  • CodeEditorProps (680-690)
frontend/packages/console-shared/src/components/editor/yaml-editor-utils.ts (2)
  • registerYAMLinMonaco (117-139)
  • getConsoleYamlSchemas (95-109)
frontend/public/module/auth.js (1)
  • window (5-12)
🔇 Additional comments (8)
frontend/public/module/k8s/swagger.ts (1)

40-40: LGTM!

The event dispatch is correctly placed after updating swaggerDefinitions and uses a standard DOM event pattern. This enables other components to react to swagger definition updates.

frontend/packages/console-shared/src/components/editor/CodeEditor.tsx (5)

8-13: LGTM!

The additional imports from yaml-editor-utils are necessary for the YAML schema refresh functionality and are all properly utilized in the component.


21-23: LGTM!

The monacoYAML state correctly stores the Monaco YAML instance with proper typing, enabling schema updates after initialization.


38-38: LGTM!

Storing the Monaco YAML instance enables dynamic schema updates. The placement within the YAML language case is correct.


53-59: LGTM!

The callback correctly guards against null monacoYAML and fetches fresh schemas on each invocation. The dependency array is accurate.


61-68: LGTM!

The effect correctly:

  • Updates schemas on mount (when swagger may already be loaded)
  • Subscribes to the console_swagger_refresh event
  • Cleans up the listener on unmount
  • Re-runs when monacoYAML becomes available, ensuring proper subscription timing
frontend/packages/console-shared/src/components/editor/yaml-editor-utils.ts (2)

3-3: LGTM!

The SchemasSettings import is necessary for the new getConsoleYamlSchemas function.


117-139: LGTM!

The singleton pattern is correctly implemented:

  • The guard prevents re-registration by checking YAML language count
  • The function returns the shared instance for later updates
  • The logic handles both initial registration and subsequent calls appropriately

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 7, 2026

@logonoff: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/okd-scos-images f7ba996 link true /test okd-scos-images
ci/prow/e2e-gcp-console f7ba996 link true /test e2e-gcp-console
ci/prow/backend f7ba996 link true /test backend

Full PR test history. Your PR dashboard.

Details

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

logonoff commented Jan 7, 2026

/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 component/shared Related to console-shared 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants