Skip to content

feat: replace polling log spam with progress bar#5

Merged
joshkotrous merged 1 commit intomainfrom
feat/polling-progress-bar
Mar 12, 2026
Merged

feat: replace polling log spam with progress bar#5
joshkotrous merged 1 commit intomainfrom
feat/polling-progress-bar

Conversation

@joshkotrous
Copy link
Copy Markdown
Contributor

@joshkotrous joshkotrous commented Mar 12, 2026

Summary

  • Adds progress (optional) field to the ScanStatusResponseObject Zod schema to consume new server-side data
  • Replaces the repeated console.log polling message with an in-place terminal progress bar (█░) that updates on a single line using \r
  • Falls back to a simple status line when progress data isn't available yet (e.g. while queued)

Depends on: pensarai/console PR adding progress to /ci/status response

Test plan

  • Run pensar scan against a project and verify progress bar renders and updates in-place
  • Verify terminal output is clean on completion (newline printed after bar)
  • Verify error/pause states still print the newline before throwing
  • Verify backwards compatibility when server doesn't return progress field yet

Made with Cursor


Note

Low Risk
CLI-output-only changes plus an optional response field; low risk aside from minor terminal formatting/compatibility edge cases.

Overview
Adds an optional progress object (completedEndpoints/totalEndpoints) to the ScanStatus Zod schema to consume new /ci/status response data.

Updates pollScanStatus to render an in-place █░ progress bar (or a single-line status fallback when progress is unavailable) and ensures a trailing newline is printed before returning or throwing on completed/failed/paused states.

Written by Cursor Bugbot for commit 9e1194a. This will update automatically on new commits. Configure here.

Consume the new progress field from the /ci/status endpoint and
render an in-place terminal progress bar showing completed vs
total scan endpoints, instead of printing a new line every poll.

Made-with: Cursor
@joshkotrous joshkotrous merged commit 5df2e6c into main Mar 12, 2026
4 checks passed
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issues.

Comment thread src/lib/ci.ts
}

if (status.status === "paused") {
if (progressShown) process.stdout.write("\n");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing newline when fallback status line was written

Medium Severity

When the scan completes without ever receiving progress data (e.g., goes directly from queued to completed), the fallback status line is written via process.stdout.write with \r but no trailing newline. Since progressShown stays false, no \n is emitted before returning or throwing. The caller (runScan) then calls console.log, which appends to the same line, producing garbled output like my-scan status: completed...Pentest my-scan completed with 0 issues.

Additional Locations (1)
Fix in Cursor Fix in Web

Comment thread src/lib/ci.ts
const percent = Math.round(ratio * 100);
const filled = Math.round(ratio * barWidth);
const empty = barWidth - filled;
const bar = "█".repeat(filled) + "░".repeat(empty);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Progress bar crashes when completed exceeds total endpoints

Medium Severity

If the server returns completedEndpoints > totalEndpoints (a plausible race condition or data inconsistency), filled exceeds barWidth, making empty negative. Calling "░".repeat(negative) throws a RangeError, crashing the entire polling loop. Clamping filled to [0, barWidth] would prevent this.

Fix in Cursor Fix in Web

Comment thread src/lib/ci.ts
}

if (status.status === "paused") {
if (progressShown) process.stdout.write("\n");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No terminal cleanup when getScanStatus throws mid-polling

Low Severity

If getScanStatus throws on a subsequent loop iteration (e.g., network timeout, HTTP 500), the exception propagates out of pollScanStatus without writing a newline. The previous process.stdout.write with \r left the cursor at the end of a partial line (either the progress bar or the fallback status). The caller's error output then renders on that same line, producing garbled terminal output. A try/finally around the loop body that emits \n when output has been written would handle this.

Fix in Cursor Fix in Web

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.

1 participant