Bugfix/inaccurate process metrics#6257
Conversation
- Replace tabs with dropdown selector for process filtering - Add per-process view with same card layout as cumulative view - Implement VS Code-style process monitoring using app.getAppMetrics() - Add process details including PID, CPU, memory, and uptime - Update memory formatting to handle bytes correctly - Improve UI with styled dropdown and consistent card ordering
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughAdds per-process metrics emission in the system-monitor backend and a process-select UI in the DevTools Performance panel, enabling cumulative or per-process views; includes extensive presentational styling for the new Performance panel. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
| { value: 'cumulative', label: 'Cumulative (All Processes)' }, | ||
| ...processes.map((process) => ({ | ||
| value: String(process.pid), | ||
| label: `PID ${process.pid}${process.title ? ` - ${process.title}` : ''}${process.type ? ` (${process.type})` : ''}` | ||
| })) | ||
| ]; |
There was a problem hiding this comment.
Can we make this a little more readable by moving it to a function outside the react component that takes in the process obj
There was a problem hiding this comment.
Changed. Moved the code outside the component
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-electron/src/app/system-monitor.js (1)
63-72: Normalize memory units between main metrics and fallbackThe main path derives
totalMemoryandprocesses[i].memoryfrommetric.memory.workingSetSize(returned by Electron'sapp.getAppMetrics()in kilobytes), while the fallback path usesprocess.memoryUsage().rss(which is in bytes). Both values flow into the samesystemResources.memoryfield consumed by the UI.Since the frontend multiplies
systemResources.memoryby 1024 before formatting, it expects kilobytes. When the fallback path triggers, memory readings will be approximately 1024 times larger than normal, causing incorrect display values and breaking any memory-based thresholds.Normalize both code paths to use the same unit (recommend converting
workingSetSizeto bytes to matchrss), and update the frontend to treatsystemResources.memoryandprocess.memoryconsistently.
🧹 Nitpick comments (2)
packages/bruno-app/src/components/Devtools/Performance/StyledWrapper.js (1)
119-348: New performance header and processes-table styling look consistentThe new header, selector, and table styles align with the markup in
Performance/index.jsand fit the existing theming approach. Only minor nit: the hard-coded badge/CPU colors (#ef4444,#f59e0b, etc.) could be moved into the theme later for easier theming, but that’s optional.packages/bruno-app/src/components/Devtools/Performance/index.js (1)
65-83: Remove or wire up unusedtrend/IconChartLineinSystemResourceCard
SystemResourceCardaccepts atrendprop and renders an<IconChartLine />, but:
IconChartLineis not imported.- None of the current call sites pass
trend, so this code is effectively dead but will break as soon as someone starts using that prop.I’d either import
IconChartLineand start usingtrend, or simplify the card by dropping thetrendprop and the extra markup until it’s needed.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/bruno-app/src/components/Devtools/Performance/StyledWrapper.js(1 hunks)packages/bruno-app/src/components/Devtools/Performance/index.js(2 hunks)packages/bruno-electron/src/app/system-monitor.js(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/bruno-electron/src/app/system-monitor.js (1)
packages/bruno-app/src/components/StopWatch/index.js (1)
currentTime(4-4)
packages/bruno-app/src/components/Devtools/Performance/index.js (1)
packages/bruno-app/src/components/Devtools/Performance/StyledWrapper.js (1)
StyledWrapper(3-349)
- Convert memory from KB to bytes in system-monitor.js (workingSetSize * 1024) - Remove incorrect multiplication in Performance component (memory already in bytes) - Ensure all memory values are consistently normalized to bytes throughout the app - Fix memory comparison thresholds to use bytes consistently
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-app/src/components/Devtools/Performance/index.js (1)
83-92: Missing import:IconChartLinewill cause a runtime error.
IconChartLineis used on line 85 but not imported. Iftrendis ever truthy, this throws aReferenceError.Add the missing import:
import { IconCpu, IconDatabase, IconClock, IconServer, - IconChevronDown + IconChevronDown, + IconChartLine } from '@tabler/icons';Or remove the trend section if it's unused:
- {trend && ( - <div className={`resource-trend ${trend > 0 ? 'up' : trend < 0 ? 'down' : 'stable'}`}> - <IconChartLine size={12} strokeWidth={1.5} /> - <span> - {trend > 0 ? '+' : ''} - {trend.toFixed(1)} - % - </span> - </div> - )}
🧹 Nitpick comments (2)
packages/bruno-app/src/components/Devtools/Performance/index.js (1)
57-73: Consider hoisting pure utility functions outside the component.
formatBytesandformatUptimehave no dependencies on component state or props. Moving them outsidePerformanceavoids recreating them on each render.+const formatBytes = (bytes) => { + if (bytes === 0) return '0 Bytes'; + const k = 1024; + const sizes = ['Bytes', 'KB', 'MB', 'GB']; + const i = Math.floor(Math.log(bytes) / Math.log(k)); + return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; +}; + +const formatUptime = (seconds) => { + const hours = Math.floor(seconds / 3600); + const minutes = Math.floor((seconds % 3600) / 60); + const secs = Math.floor(seconds % 60); + + if (hours > 0) return `${hours}h ${minutes}m ${secs}s`; + if (minutes > 0) return `${minutes}m ${secs}s`; + return `${secs}s`; +}; + const Performance = () => { // ...remove formatBytes and formatUptime from herepackages/bruno-electron/src/app/system-monitor.js (1)
71-87: Useconstinstead ofvarforprocesses
processesis never reassigned, soconstcommunicates intent better and avoids accidental mutation; everything else in this block looks consistent and well‑structured.- const uptime = (currentTime - this.startTime) / 1000; - var processes = metrics.map((metric) => ({ + const uptime = (currentTime - this.startTime) / 1000; + const processes = metrics.map((metric) => ({ pid: metric.pid, title: metric.title, memory: metric.memory.workingSetSize * 1024, cpu: metric.cpu.percentCPUUsage, type: metric.type || 'unknown', creationTime: metric.creationTime }));
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/bruno-app/src/components/Devtools/Performance/index.js(2 hunks)packages/bruno-electron/src/app/system-monitor.js(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CODING_STANDARDS.md)
**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single parameters
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses. Keep 'em tight
Space before and after the arrow in arrow functions.() => {}is good
No space between function name and parentheses.func()notfunc ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Avoid single line abstractions where all that's being done is increasing the call stack with one additional function
Add in meaningful comments instead of obvious ones where complex code flow is explained properly
Files:
packages/bruno-electron/src/app/system-monitor.jspackages/bruno-app/src/components/Devtools/Performance/index.js
🧬 Code graph analysis (1)
packages/bruno-app/src/components/Devtools/Performance/index.js (1)
packages/bruno-app/src/components/Devtools/Performance/StyledWrapper.js (1)
StyledWrapper(3-349)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Playwright E2E Tests
- GitHub Check: SSL Tests - macOS
- GitHub Check: Unit Tests
- GitHub Check: SSL Tests - Linux
- GitHub Check: SSL Tests - Windows
- GitHub Check: CLI Tests
🔇 Additional comments (8)
packages/bruno-app/src/components/Devtools/Performance/index.js (6)
1-10: LGTM on imports structure.Imports are clean and properly organized.
12-20: LGTM on process options extraction.Clean extraction of label logic outside the component, addressing prior feedback.
22-55: LGTM on component setup and IPC lifecycle.Proper initialization, error handling, and cleanup.
96-113: LGTM on memoization and PID reset logic.Correct dependencies and defensive reset when the selected process disappears.
174-180: Same memory unit verification applies here.Ensure
process.memoryis in bytes from the backend. The threshold comparisonprocess.memory > (500 * 1024 * 1024)andformatBytes(process.memory)assume bytes.
205-229: LGTM on the main render and dropdown implementation.Clean, accessible dropdown with proper label association and conditional view rendering.
packages/bruno-electron/src/app/system-monitor.js (2)
63-69: Memory unit conversion aligns totals with process memory usageSwitching
totalMemoryto usemetric.memory.workingSetSize * 1024keeps it in the same unit asmemory.rssfromprocess.memoryUsage()(bytes) and makes aggregated vs fallback memory comparable. This is a solid, low‑risk fix.
100-108: Fallback payload shape matches primary payloadAdding
timestampand an emptyprocesses: []tofallbackStatskeeps the schema consistent withsystemResources, which should simplify the consumer UI logic and avoid null/undefined checks. Looks good.
Description
This PR addresses https://usebruno.atlassian.net/browse/BRU-2192 and tries to provide a detailed view of Process metrics (Main and Sub Processes)
Screen.Recording.2025-11-18.at.1.50.26.PM.1.mov
Contribution Checklist:
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.