Skip to content

Refactor monitor UI components#522

Open
rasika2012 wants to merge 2 commits intowso2:mainfrom
rasika2012:fix-minor-issues-eval
Open

Refactor monitor UI components#522
rasika2012 wants to merge 2 commits intowso2:mainfrom
rasika2012:fix-minor-issues-eval

Conversation

@rasika2012
Copy link
Contributor

@rasika2012 rasika2012 commented Mar 11, 2026

This pull request introduces several improvements and fixes across the monitor creation and evaluation UI, focusing on validation, user experience, and consistency. The most important changes are the addition of duplicate monitor name validation, updates to form labels and error messages, enhancements to tooltip and chart labeling, and UI refinements for action buttons and layout.

Monitor Name Validation & Form Improvements:

  • Added duplicate monitor name validation in both the create and edit monitor flows, preventing users from creating a monitor with a name that already exists (excluding the one being edited). The validation is performed both during field changes and on form submission, with appropriate error messaging. (CreateMonitor.Component.tsx, EditMonitor.Component.tsx, MonitorFormWizard.tsx) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
  • Updated monitor form field labels and error messages for clarity and consistency, changing "Monitor Title" to "Name" and simplifying helper texts. (schema.ts, CreateMonitorForm.tsx) [1] [2] [3] [4]

Chart & Tooltip Enhancements:

  • Improved metrics tooltips to display the formatted timestamp label, and updated chart data rows to include both formatted and raw timestamps for more precise labeling. (MetricsTooltip.tsx, PerformanceByEvaluatorCard.tsx) [1] [2] [3] [4]

UI & Layout Refinements:

  • Changed action button layouts in monitor tables and run lists for better alignment and clarity, including switching icon positions and replacing icon-only buttons with labeled buttons. (EvalMonitors.Component.tsx, MonitorTable.tsx, MonitorRunList.tsx) [1] [2] [3] [4] [5]
  • Removed the calendar icon for past monitors, displaying nothing instead of a disabled button. (MonitorStartStopButton.tsx) [1] [2]

Build Logs Display Fix:

  • Fixed build logs ordering by reversing the logs array before display, ensuring the newest logs appear first. (BuildLogs.tsx) [1] [2]

These changes collectively improve validation, usability, and visual consistency throughout the monitor management and evaluation interfaces.

Purpose

Describe the problems, issues, or needs driving this feature/fix and include links to related issues in the following format: Resolves issue1, issue2, etc.

Goals

Describe the solutions that this feature/fix will introduce to resolve the problems described above

Approach

Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter �N/A� plus brief explanation of why there�s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type �Sent� when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type �N/A� and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

Summary by CodeRabbit

  • New Features

    • Duplicate-name validation prevents creating or saving monitors with an existing name.
  • Bug Fixes

    • Build logs now display in reversed (chronological) order.
  • UI Improvements

    • Chart timestamps and axis labels improved for clarity.
    • "Monitor Title" relabeled to "Name" with updated validation messages.
    • Re-run action now shows a labeled button.
    • Past monitors no longer show disabled controls.
    • Actions column right-aligned; Add Monitor plus icon repositioned.
    • Tooltips may show an explicit timestamp label.

- Improve UX/UI in create monitor and graph views
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 34bf2507-1fa1-4139-a643-d896da8bf881

📥 Commits

Reviewing files that changed from the base of the PR and between f701a84 and 80c0205.

📒 Files selected for processing (1)
  • console/workspaces/libs/shared-component/src/components/BuildLogs.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • console/workspaces/libs/shared-component/src/components/BuildLogs.tsx

📝 Walkthrough

Walkthrough

Adds duplicate-name validation to monitor create/edit flows, updates form labels and select sentinel handling, reverses build log order, refactors several monitor UI buttons/layouts, and enhances chart X-axis formatting and tooltip payload handling across eval workspace components.

Changes

Cohort / File(s) Summary
Monitor creation & edit flows
console/workspaces/pages/eval/src/CreateMonitor.Component.tsx, console/workspaces/pages/eval/src/EditMonitor.Component.tsx, console/workspaces/pages/eval/src/subComponents/MonitorFormWizard.tsx
Fetches existing monitors, derives existingMonitorNames, passes it (and editingMonitorName) into MonitorFormWizard; adds duplicate-name checks on field change and on submit, and updates props/type signatures.
Form label & helpers
console/workspaces/pages/eval/src/form/schema.ts, console/workspaces/pages/eval/src/subComponents/CreateMonitorForm.tsx
Renames user-facing label/messages from "Monitor title" to "Name" and removes some non-error helper texts for displayName and intervalMinutes.
Chart & tooltip adjustments
console/workspaces/pages/eval/src/subComponents/PerformanceByEvaluatorCard.tsx, console/workspaces/pages/eval/src/subComponents/MetricsTooltip.tsx
Adds date-fns formatting, explicit numeric XAxis with tick formatter and timestamps, enables dots on lines; MetricsTooltipEntry gains optional payload and renders an extracted xLabel when present.
Monitor UI refactor & layout
console/workspaces/pages/eval/src/subComponents/MonitorRunList.tsx, console/workspaces/pages/eval/src/subComponents/MonitorStartStopButton.tsx, console/workspaces/pages/eval/src/subComponents/MonitorTable.tsx
Replaces rerun IconButton with a textual Button (Play startIcon); removes Calendar button for past monitors (renders null); right-aligns Actions column and its content.
Misc UI/state tweaks
console/workspaces/libs/shared-component/src/components/BuildLogs.tsx, console/workspaces/pages/eval/src/EvalMonitors.Component.tsx, console/workspaces/pages/eval/src/subComponents/EvaluatorLlmProviderSection.tsx
Memoizes and reverses build logs display; moves Plus icon from endIcon to startIcon on Add button; changes Select empty sentinel from "" to "_empty" affecting placeholder and truthiness handling.

Sequence Diagram

sequenceDiagram
    participant User
    participant CreateEditComp as Create/Edit Component
    participant ListHook as useListMonitors
    participant API
    participant FormWizard as MonitorFormWizard

    User->>CreateEditComp: Open create/edit monitor UI
    CreateEditComp->>ListHook: invoke useListMonitors(org,proj,agent)
    ListHook->>API: GET /monitors
    API-->>ListHook: monitors data
    ListHook-->>CreateEditComp: monitorsData
    CreateEditComp->>CreateEditComp: derive existingMonitorNames
    CreateEditComp->>FormWizard: render with existingMonitorNames & editingMonitorName
    User->>FormWizard: type displayName
    FormWizard->>FormWizard: check name against existingMonitorNames (exclude editingMonitorName)
    alt name duplicate
        FormWizard-->>User: show "A monitor with this name already exists" error
    else unique
        FormWizard-->>User: allow progression
    end
    User->>FormWizard: submit
    FormWizard->>FormWizard: duplicate check on submit
    alt duplicate
        FormWizard-->>User: set field error, reset to page 1
    else valid
        FormWizard->>API: POST/PUT monitor
        API-->>FormWizard: success
        FormWizard-->>User: saved confirmation
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I fetched names beneath the moonlit logs,
I nudged the charts and chased the fogs,
Buttons now hop with clearer rhyme,
Duplicates stopped, one at a time,
A carrot-coded, tidy thrum of logs. 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description includes a detailed summary of changes and rationale but does not adequately complete the required template sections for Purpose, Goals, Approach, User stories, Release note, Documentation, Training, Certification, Marketing, Testing, Security, Samples, Related PRs, Migrations, Test environment, and Learning. Complete all required template sections including Purpose, Goals, Approach with UI evidence, User stories, Release note, Documentation links, Certification status, Testing details, Security checks, and Test environment information.
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.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Refactor monitor UI components' is partially related to the changeset. While the PR includes UI component changes, it encompasses much broader scope including validation logic, form improvements, chart enhancements, and bug fixes beyond just refactoring.

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

✨ Finishing Touches
🧪 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: 2

🧹 Nitpick comments (3)
console/workspaces/pages/eval/src/subComponents/MonitorStartStopButton.tsx (1)

99-102: Dead code remains in tooltipTitle calculation.

Since isPastMonitor now causes an early return of null, the branch handling isPastMonitor in the tooltipTitle ternary (lines 60-61) is never reached and can be removed.

♻️ Suggested cleanup

Simplify tooltipTitle and the early return:

-  const tooltipTitle = isActive
-    ? "Stop Monitor"
-    : isPastMonitor
-      ? "Past monitors cannot be started"
-      : "Start Monitor";
+  const tooltipTitle = isActive ? "Stop Monitor" : "Start Monitor";
   if (isPastMonitor) {
-    return (
-      null
-    );
+    return null;
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@console/workspaces/pages/eval/src/subComponents/MonitorStartStopButton.tsx`
around lines 99 - 102, The tooltipTitle calculation contains a dead branch for
isPastMonitor because MonitorStartStopButton now returns null early when
isPastMonitor is true; remove the isPastMonitor case from the tooltipTitle
ternary and simplify tooltipTitle accordingly, and keep the existing early
return (return null) guarded by isPastMonitor in the MonitorStartStopButton
component so the tooltip logic only handles the remaining states.
console/workspaces/pages/eval/src/subComponents/PerformanceByEvaluatorCard.tsx (2)

123-127: Sort the merged timestamps by epoch, not raw string.

This now depends on p.timestamp being lexicographically sortable. Since the chart renders on xTimestamp, sorting with new Date(...).getTime() will keep the series chronological even if the API returns offsets or another valid timestamp string shape.

Suggested change
     const allTimestamps = Array.from(
       new Set(
         Object.values(seriesMap).flatMap((pts) => pts.map((p) => p.timestamp)),
       ),
-    ).sort();
+    ).sort((a, b) => new Date(a).getTime() - new Date(b).getTime());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@console/workspaces/pages/eval/src/subComponents/PerformanceByEvaluatorCard.tsx`
around lines 123 - 127, The current allTimestamps aggregation uses default
string sort which assumes lexicographic timestamp order; update the deduped
timestamps built from seriesMap (from p.timestamp) so they are sorted by epoch
milliseconds instead: when creating allTimestamps (used to drive xTimestamp),
convert each p.timestamp to a Date and sort by date.getTime() to ensure
chronological order regardless of timestamp string format, then map back to the
original string/ISO form expected by the chart.

271-274: Replace the hardcoded tick font size with a theme token.

fontSize: 12 can drift from the console typography scale. Reuse theme.typography.caption.fontSize here instead.

Suggested change
                 tick={{
-                  fontSize: 12,
+                  fontSize: theme.typography.caption.fontSize,
                 }}
As per coding guidelines, `console/**/*.{ts,tsx,js,jsx}` should "Use theme tokens via the `sx` prop instead of hardcoded colors and spacing values".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@console/workspaces/pages/eval/src/subComponents/PerformanceByEvaluatorCard.tsx`
around lines 271 - 274, Replace the hardcoded tick font size in
PerformanceByEvaluatorCard by reading the theme token instead of using 12;
import and call useTheme() (from `@mui/material/styles`) inside
PerformanceByEvaluatorCard and replace tick={{ fontSize: 12 }} with tick={{
fontSize: theme.typography.caption.fontSize }} (or apply the value via an
sx-based style if your chart wrapper supports sx), referencing the tick prop in
the component to ensure the console typography token is used.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@console/workspaces/libs/shared-component/src/components/BuildLogs.tsx`:
- Line 81: In BuildLogs.tsx the line creating reversedBuildLogs uses
buildLogs.reverse(), which mutates the React Query cached array from
useGetBuildLogs/getBuildLogs; replace this with a non-mutating reversal (e.g.,
create a copy via spread or slice and then reverse, or use toReversed() if
targeting ES2023+) so reversedBuildLogs is a new array and the cache isn't
mutated.

In `@console/workspaces/pages/eval/src/subComponents/MonitorFormWizard.tsx`:
- Around line 108-120: The duplicate-check is comparing next.name
(slug/identifier) against existingMonitorNames (MonitorResponse.name) instead of
comparing the user-facing displayName; update the logic in MonitorFormWizard to
compare normalized displayName values end-to-end: derive namesToCheck from
existing monitors' displayName (e.g., existingMonitorDisplayNames), exclude the
current monitor by monitorData?.displayName or editingDisplayName (instead of
editingMonitorName), and test next.displayName.trim().length and normalized
next.displayName against namesToCheck; apply the same change to the second
occurrence (lines ~212-223) and ensure callers provide m.displayName and
monitorData?.displayName where relevant so the component gets displayName values
to compare.

---

Nitpick comments:
In `@console/workspaces/pages/eval/src/subComponents/MonitorStartStopButton.tsx`:
- Around line 99-102: The tooltipTitle calculation contains a dead branch for
isPastMonitor because MonitorStartStopButton now returns null early when
isPastMonitor is true; remove the isPastMonitor case from the tooltipTitle
ternary and simplify tooltipTitle accordingly, and keep the existing early
return (return null) guarded by isPastMonitor in the MonitorStartStopButton
component so the tooltip logic only handles the remaining states.

In
`@console/workspaces/pages/eval/src/subComponents/PerformanceByEvaluatorCard.tsx`:
- Around line 123-127: The current allTimestamps aggregation uses default string
sort which assumes lexicographic timestamp order; update the deduped timestamps
built from seriesMap (from p.timestamp) so they are sorted by epoch milliseconds
instead: when creating allTimestamps (used to drive xTimestamp), convert each
p.timestamp to a Date and sort by date.getTime() to ensure chronological order
regardless of timestamp string format, then map back to the original string/ISO
form expected by the chart.
- Around line 271-274: Replace the hardcoded tick font size in
PerformanceByEvaluatorCard by reading the theme token instead of using 12;
import and call useTheme() (from `@mui/material/styles`) inside
PerformanceByEvaluatorCard and replace tick={{ fontSize: 12 }} with tick={{
fontSize: theme.typography.caption.fontSize }} (or apply the value via an
sx-based style if your chart wrapper supports sx), referencing the tick prop in
the component to ensure the console typography token is used.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4e13f046-5e86-4bfe-a4ca-95574e47cb8c

📥 Commits

Reviewing files that changed from the base of the PR and between 0e8fd12 and f701a84.

📒 Files selected for processing (13)
  • console/workspaces/libs/shared-component/src/components/BuildLogs.tsx
  • console/workspaces/pages/eval/src/CreateMonitor.Component.tsx
  • console/workspaces/pages/eval/src/EditMonitor.Component.tsx
  • console/workspaces/pages/eval/src/EvalMonitors.Component.tsx
  • console/workspaces/pages/eval/src/form/schema.ts
  • console/workspaces/pages/eval/src/subComponents/CreateMonitorForm.tsx
  • console/workspaces/pages/eval/src/subComponents/EvaluatorLlmProviderSection.tsx
  • console/workspaces/pages/eval/src/subComponents/MetricsTooltip.tsx
  • console/workspaces/pages/eval/src/subComponents/MonitorFormWizard.tsx
  • console/workspaces/pages/eval/src/subComponents/MonitorRunList.tsx
  • console/workspaces/pages/eval/src/subComponents/MonitorStartStopButton.tsx
  • console/workspaces/pages/eval/src/subComponents/MonitorTable.tsx
  • console/workspaces/pages/eval/src/subComponents/PerformanceByEvaluatorCard.tsx

"displayName",
"A monitor with this name already exists.",
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The duplicate-check here compares next.name (the auto-generated slug) against existingMonitorNames (also slugs from MonitorResponse.name). But the field being validated is displayName, not the slug.

This means:

  • A displayName rename that happens to produce a colliding slug will be incorrectly blocked
  • Two monitors with identical displayName but different slugs will pass validation (false negative)

Should compare normalized displayName values end-to-end instead. Callers (CreateMonitor.Component.tsx, EditMonitor.Component.tsx) should pass m.displayName and monitorData?.displayName.

Same issue applies to the submit-time check at lines ~212-223.

</IconButton>
</span>
</Tooltip>
null
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Since isPastMonitor now triggers an early return null, the isPastMonitor branch in the tooltipTitle ternary (around line 60) is unreachable dead code. Should simplify to:

const tooltipTitle = isActive ? "Stop Monitor" : "Start Monitor";

Also, the return ( null ); can be simplified to just return null;.

@@ -125,16 +126,16 @@ const PerformanceByEvaluatorCard: React.FC<PerformanceByEvaluatorCardProps> = ({
),
).sort();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Default .sort() uses string comparison which is fragile for timestamps. Since the chart now renders on xTimestamp (epoch), sort by epoch to be safe:

).sort((a, b) => new Date(a).getTime() - new Date(b).getTime());

tickFormatter={formatTickTimestamp}

tick={{
fontSize: 12,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Hardcoded fontSize: 12 should use a theme token per project guidelines:

tick={{
  fontSize: theme.typography.caption.fontSize,
}}

useTheme() is already imported in this component.

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