Skip to content

Conversation

mlhv
Copy link
Contributor

@mlhv mlhv commented Aug 11, 2025

Solves #428

Enabled use of the --width CLI flag to set the console width in the HTML formatter. (For better html browser viewing experience)

Before: the HTML formatter console would auto detect terminal widths leading to an exported HTML file with squished table widths; which is very hard to read.

Copy link

coderabbitai bot commented Aug 11, 2025

Caution

Review failed

An error occurred during the review process. Please try again later.

Walkthrough

Adds an optional width configuration to the HTML formatter by reading settings.width and passing it to the Console. Updates README to document the new optional --width flag (example uses 250) for Azure Blob Storage export with Microsoft Teams notifications. No public API signatures change.

Changes

Cohort / File(s) Summary of changes
Documentation
README.md
Documents new optional CLI flag --width (example: 250) for better HTML viewing; adds note recommending adjusting width. No code changes.
HTML Formatter Config
robusta_krr/formatters/html.py
Reads settings.width and applies it to Console(width=...). Adds import of settings. Keeps function signature and rendering/export logic unchanged.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant HTMLFormatter as html(result)
  participant Settings as settings.width
  participant Console

  Caller->>HTMLFormatter: html(result)
  HTMLFormatter->>Settings: read width
  alt width is set
    HTMLFormatter->>Console: create Console(width=width, force_terminal=False)
  else
    HTMLFormatter->>Console: create Console(width=None, force_terminal=False)
  end
  HTMLFormatter->>Console: render table
  HTMLFormatter-->>Caller: return HTML with inline styles
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • aantn
  • arikalon1
✨ Finishing Touches
🧪 Generate unit tests
  • 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

@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

🔭 Outside diff range comments (1)
README.md (1)

711-718: Fix command: make it copy-paste safe and keep line continuation

The current example breaks when copied: parentheses become part of the command, and the previous line lacks a trailing backslash. Suggested fix:

   krr simple -f html \
     --azurebloboutput "https://yourstorageaccount.blob.core.windows.net/fileuploads?sv=..." \
     --teams-webhook "https://your-teams-webhook-url" \
     --azure-subscription-id "your-subscription-id" \
-    --azure-resource-group "your-resource-group"
-    --width 250 (optional but HIGHLY RECOMMENDED)
+    --azure-resource-group "your-resource-group" \
+    --width 250 # optional but HIGHLY RECOMMENDED
🧹 Nitpick comments (2)
README.md (1)

751-752: Nit: grammar tweak

Use plural “browsers”.

-Note: Consider adjusting the `--width` CLI flag for a better HTML viewing experience in browser.
+Note: Consider adjusting the `--width` CLI flag for a better HTML viewing experience in browsers.
robusta_krr/formatters/html.py (1)

10-11: Simplify width handling and guard bad values; avoid forcing non-terminal unless intentional

  • The explicit None check is redundant.
  • Guard against non-positive widths to prevent odd wrapping.
  • Consider omitting force_terminal so Rich can auto-detect; forcing non-terminal may subtly change styling/wrapping in HTML export.
-    html_width = settings.width if settings.width is not None else None
-    console = Console(record=True, width=html_width, force_terminal=False)
+    width = settings.width
+    if width is not None and width < 1:
+        width = None
+    # Let Rich auto-detect terminal behavior; recorded HTML will still capture styles.
+    console = Console(record=True, width=width)

Please verify that removing force_terminal=False preserves expected HTML styling and wrapping. If there’s a known reason to force non-terminal here, add a short code comment.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 54ab6ef and 3042a01.

📒 Files selected for processing (2)
  • README.md (2 hunks)
  • robusta_krr/formatters/html.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
robusta_krr/formatters/html.py (3)
robusta_krr/formatters/table.py (1)
  • table (64-125)
robusta_krr/core/abstract/formatters.py (1)
  • register (24-48)
robusta_krr/core/models/result.py (1)
  • Result (62-115)
🔇 Additional comments (1)
robusta_krr/formatters/html.py (1)

5-5: Width flag wiring verified
Both the settings.width field and the --width CLI option are correctly defined and connected:

  • In robusta_krr/core/models/config.py,
    width: Optional[int] = pd.Field(None, ge=1) provides the configuration field with proper validation (must be ≥ 1).
  • In robusta_krr/main.py,
    width: Optional[int] = typer.Option(None, "--width", …) exposes the flag and populates settings.width.

No further changes are required.

@villisco villisco mentioned this pull request Aug 26, 2025
@mlhv mlhv changed the title Added option to pass in console output width into HTML export Fixed HTML Rendering - Added option to pass in console output width into HTML export Sep 8, 2025
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