Skip to content

Feat/process monitor enhancements#1718

Open
RosheshChaware wants to merge 2 commits into
Karanjot786:mainfrom
RosheshChaware:feat/process-monitor-enhancements
Open

Feat/process monitor enhancements#1718
RosheshChaware wants to merge 2 commits into
Karanjot786:mainfrom
RosheshChaware:feat/process-monitor-enhancements

Conversation

@RosheshChaware

@RosheshChaware RosheshChaware commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #1717

Description

This PR enhances the examples/process-monitor dashboard by improving visibility and usability of system monitoring information.

Changes included:

  • Added a system summary header displaying CPU usage, memory usage, process count, and uptime.
  • Added a process search/filter feature for quickly locating processes by name.
  • Added a statistics panel showing total, running, and sleeping process counts.

These improvements utilize previously unused dashboard space while maintaining the existing terminal-style design and functionality.

Which package(s)?

  • examples/process-monitor

Type of Change

  • 🐛 Bug fix (type:bug)
  • ✨ Feature (type:feature)
  • 📝 Docs (type:docs)
  • 🧪 Tests (type:testing)
  • ♻️ Refactor (type:refactor)
  • 🎨 Design / UX (type:design)
  • ♿ Accessibility (type:accessibility)
  • ⚡ Performance (type:performance)
  • 🔧 DevOps / CI (type:devops)
  • 🔒 Security (type:security)

Checklist

  • ⭐ You starred the repo. The needs-star check blocks your merge otherwise.
  • Tests pass locally: bun vitest run
  • Build passes: bun run build
  • Typecheck passes: bun run typecheck
  • You read [CONTRIBUTING.md](https://chatgpt.com/c/CONTRIBUTING.md).
  • Your PR title follows type: short description.
  • Widget state mutators call markDirty() (if your change affects rendering).
  • No new any types without an inline comment explaining why.
  • No unrelated refactors bundled into this PR.

GSSoC 2026 Participation

  • You are a GSSoC 2026 contributor.
  • Your GSSoC profile: https://gssoc.girlscript.org/profile/79bbc5b9-0fdc-457e-b8cb-23220ab16312

Screenshots / Recordings (UI changes)

Screenshot 2026-06-21 140330

Before

  • Existing Process Monitor dashboard

After

  • System Summary Header
  • Process Search Bar
  • Process Statistics Panel

(Add screenshots here)

Notes for the Reviewer

  • Changes are limited to examples/process-monitor.
  • No external dependencies were introduced.
  • Existing monitoring functionality remains unchanged.
  • The implementation focuses on improving usability and dashboard visibility while preserving the terminal-first experience.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added inline search/filter functionality to process monitor with keyboard shortcuts (/ to search, escape to clear).
    • Added per-question explanations and progress bar to quiz app.
    • Introduced streak tracking and status indicators for quiz answers.
  • Enhancements

    • Improved process monitor visuals with text-based percentage bars.
    • Updated keyboard controls for better workflow.
  • Chores

    • Added diagnostic utilities for process monitoring and layout testing.

@github-actions github-actions Bot added the area:examples Example apps. label Jun 21, 2026
@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR enhances two examples: the process monitor gains an inline search/filter mode with TextInputJSX, gauge bar helpers, process name filtering, a stats card, and a dynamic table; the quiz app gains per-question explanation fields, a progress bar, streak tracking, and split feedback widgets. Two scratch diagnostic scripts (scratch_status.ts, test_layout.ts) are also added.

Changes

Process Monitor: search, filter, and stats panel

Layer / File(s) Summary
TextInputJSX wrapper, helpers, key bindings, and state
examples/process-monitor/src/index.tsx
Adds useInput import, TextInputJSX wrapper gated by isFocused, gaugeBar and formatUptime helpers, expanded top-process count to 30, filterText/filter-focus state, and updates q///escape keybindings for search mode.
Process filtering logic and updated layout
examples/process-monitor/src/index.tsx
Derives filteredProcs from filterText, rebuilds tableRows from the filtered subset, computes totalProcs; updates header/summary with gaugeBar and formatUptime; adds a "Process Stats" card; replaces the static "Top Processes" card with a filter input, match count, and dynamically titled table card; updates footer text.

Quiz App: explanations, progress bar, and streak

Layer / File(s) Summary
Question explanation field and data
examples/quiz-app/src/index.tsx
Adds optional explanation?: string to the Question type and populates it for HTML, const/let/var, binary search, LIFO/stack, and CSS questions.
Progress bar, streak state, split feedback widgets, and export
examples/quiz-app/src/index.tsx
Introduces getProgressBar helper; increases WIDGET_HEIGHT; adds _progressBar, _feedbackStatus, _feedbackDetails widgets (replacing single _feedback); adds streak and userChoiceIndex state; wires new widgets into the constructor layout; exports QuizApp.
Answer handling, advance, summary, and restart
examples/quiz-app/src/index.tsx
headerText includes a streak indicator; progressBarText computes completion; handleAnswer stores userChoiceIndex, updates streak/score, sets _feedbackStatus/_feedbackDetails with optional explanation; advance clears feedback and updates _progressBar; showSummary sets score/grade; restart resets streak and all feedback widgets.

Scratch/diagnostic scripts

Layer / File(s) Summary
scratch_status.ts and test_layout.ts
scratch_status.ts, test_layout.ts
scratch_status.ts runs tasklist synchronously and logs the derived process count. test_layout.ts instantiates QuizApp and logs each layout child's id, style.visible, and style.height.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

type:feature, level:intermediate, quality:clean

Suggested reviewers

  • Karanjot786

Poem

🐇 Hop hop, the terminal gleams,
A search bar typed where nothing seems,
Gauge bars fill with CPU hue,
Quiz streaks tracked in green and blue,
Scratch scripts peek at children's height—
The rabbit checks each layout right! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning PR includes out-of-scope changes: quiz-app enhancements and utility scripts unrelated to process-monitor objectives in issue #1717. Remove unrelated changes to quiz-app and utility scripts; focus only on process-monitor enhancements from issue #1717.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive PR title 'Feat/process monitor enhancements' is vague and does not follow the required 'type: short description' format. Update title to follow template format, e.g., 'feat: add process search, system summary, and statistics panel'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed PR description includes all required sections: description, related issue, packages, type of change, checklist, GSSoC participation, and reviewer notes.
Linked Issues check ✅ Passed PR successfully implements all three objectives from issue #1717: system summary header, process search/filter functionality, and statistics panel.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/process-monitor/src/index.tsx`:
- Around line 125-129: The gaugeBar function can receive percent values outside
the 0-100 range, causing the filled or empty calculation to be negative and
crashing the repeat() calls. At the start of the gaugeBar function, clamp the
percent parameter to ensure it stays within the valid 0 to 100 range using
Math.max and Math.min before calculating filled and empty values.
- Line 121: The TextInputJSX function contains an unnecessary `as any` type
assertion on the return statement which violates repository TypeScript strict
mode rules. Remove the `as any` type assertion from the return statement and
instead ensure the function has a properly typed return value that matches the
concrete type of ref.current (such as TextInput). Update the function signature
to explicitly declare the return type rather than relying on type assertions.

In `@scratch_status.ts`:
- Line 3: The execFileSync call that invokes tasklist needs timeout and
maxBuffer options to prevent indefinite blocking. Modify the options object
passed to execFileSync by adding a timeout property (in milliseconds, e.g., 5000
for 5 seconds) and a maxBuffer property (in bytes, e.g., 1024 * 1024 for 1MB) to
ensure the command completes within a reasonable timeframe and handles large
outputs gracefully, preventing the diagnostics from stalling if tasklist hangs.
- Around line 4-5: The hardcoded magic number subtraction (lines.length - 3) in
the console.log statement for calculating total processes is brittle and will
break if the output format or localization changes. Instead of subtracting a
fixed number from the line count, parse the actual process count directly from
the output by identifying and extracting the numeric value from the line that
contains the actual process count information, making the parsing resilient to
formatting variations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 609b35e0-a7df-4c1f-866a-259c4d177186

📥 Commits

Reviewing files that changed from the base of the PR and between 35c2213 and 327fe9a.

📒 Files selected for processing (4)
  • examples/process-monitor/src/index.tsx
  • examples/quiz-app/src/index.tsx
  • scratch_status.ts
  • test_layout.ts

}
});

return ref.current as any;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove as any type assertion in TextInputJSX return

Line 121 violates repo TS rules (any + assertion without justification). Return a concrete type instead (e.g., make the function return TextInput and return ref.current directly).

Suggested fix
-function TextInputJSX({ value, onChange, placeholder, isFocused }: {
+function TextInputJSX({ value, onChange, placeholder, isFocused }: {
     value: string;
     onChange: (val: string) => void;
     placeholder?: string;
     isFocused: boolean;
-}) {
+}): TextInput {
@@
-    return ref.current as any;
+    return ref.current;
 }

As per coding guidelines: "**/*.{ts,tsx}: Use TypeScript strict mode. No any without an inline comment explaining why... No type assertions without an inline comment explaining why."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/process-monitor/src/index.tsx` at line 121, The TextInputJSX
function contains an unnecessary `as any` type assertion on the return statement
which violates repository TypeScript strict mode rules. Remove the `as any` type
assertion from the return statement and instead ensure the function has a
properly typed return value that matches the concrete type of ref.current (such
as TextInput). Update the function signature to explicitly declare the return
type rather than relying on type assertions.

Source: Coding guidelines

Comment on lines +125 to +129
function gaugeBar(percent: number, width: number): string {
const filled = Math.round((percent / 100) * width);
const empty = width - filled;
const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(empty);
return `[${bar}] ${percent.toFixed(0)}%`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Clamp gauge percent before building the bar

gaugeBar can crash if percent is < 0 or > 100 ('░'.repeat(empty) gets a negative count). Clamp first to keep rendering safe under noisy metric values.

Suggested fix
 function gaugeBar(percent: number, width: number): string {
-    const filled = Math.round((percent / 100) * width);
+    const safePercent = Math.max(0, Math.min(100, percent));
+    const filled = Math.round((safePercent / 100) * width);
     const empty = width - filled;
     const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(empty);
-    return `[${bar}] ${percent.toFixed(0)}%`;
+    return `[${bar}] ${safePercent.toFixed(0)}%`;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function gaugeBar(percent: number, width: number): string {
const filled = Math.round((percent / 100) * width);
const empty = width - filled;
const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(empty);
return `[${bar}] ${percent.toFixed(0)}%`;
function gaugeBar(percent: number, width: number): string {
const safePercent = Math.max(0, Math.min(100, percent));
const filled = Math.round((safePercent / 100) * width);
const empty = width - filled;
const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(empty);
return `[${bar}] ${safePercent.toFixed(0)}%`;
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/process-monitor/src/index.tsx` around lines 125 - 129, The gaugeBar
function can receive percent values outside the 0-100 range, causing the filled
or empty calculation to be negative and crashing the repeat() calls. At the
start of the gaugeBar function, clamp the percent parameter to ensure it stays
within the valid 0 to 100 range using Math.max and Math.min before calculating
filled and empty values.

Comment thread scratch_status.ts
@@ -0,0 +1,8 @@
import { execFileSync } from 'node:child_process';
try {
const output = execFileSync('tasklist', [], { encoding: 'utf-8' });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add a timeout/maxBuffer to execFileSync to avoid hangs.

This synchronous external call can block indefinitely and stall diagnostics if tasklist hangs.

Suggested fix
-    const output = execFileSync('tasklist', [], { encoding: 'utf-8' });
+    const output = execFileSync('tasklist', [], {
+        encoding: 'utf-8',
+        timeout: 3000,
+        maxBuffer: 10 * 1024 * 1024,
+    });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const output = execFileSync('tasklist', [], { encoding: 'utf-8' });
const output = execFileSync('tasklist', [], {
encoding: 'utf-8',
timeout: 3000,
maxBuffer: 10 * 1024 * 1024,
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scratch_status.ts` at line 3, The execFileSync call that invokes tasklist
needs timeout and maxBuffer options to prevent indefinite blocking. Modify the
options object passed to execFileSync by adding a timeout property (in
milliseconds, e.g., 5000 for 5 seconds) and a maxBuffer property (in bytes,
e.g., 1024 * 1024 for 1MB) to ensure the command completes within a reasonable
timeframe and handles large outputs gracefully, preventing the diagnostics from
stalling if tasklist hangs.

Comment thread scratch_status.ts
Comment on lines +4 to +5
const lines = output.trim().split('\n');
console.log('Total processes:', lines.length - 3);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Process count parsing is brittle with lines.length - 3.

The hardcoded subtraction can drift with format/localization changes and return wrong counts.

Suggested fix
-    const lines = output.trim().split('\n');
-    console.log('Total processes:', lines.length - 3);
+    const lines = output.split(/\r?\n/).map(l => l.trim()).filter(Boolean);
+    const dataRows = lines.slice(3); // header block
+    console.log('Total processes:', dataRows.length);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const lines = output.trim().split('\n');
console.log('Total processes:', lines.length - 3);
const lines = output.split(/\r?\n/).map(l => l.trim()).filter(Boolean);
const dataRows = lines.slice(3); // header block
console.log('Total processes:', dataRows.length);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scratch_status.ts` around lines 4 - 5, The hardcoded magic number subtraction
(lines.length - 3) in the console.log statement for calculating total processes
is brittle and will break if the output format or localization changes. Instead
of subtracting a fixed number from the line count, parse the actual process
count directly from the output by identifying and extracting the numeric value
from the line that contains the actual process count information, making the
parsing resilient to formatting variations.

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

Labels

area:examples Example apps.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: (process-monitor) add system summary, process search, and statistics panel

1 participant