Skip to content

Commit fc0f3d0

Browse files
Merge pull request #21 from ivyleavedtoadflax/fix/issue-36-config-validate-output
fix: Remove hardcoded console width and simplify validate output
2 parents 55af72a + acd655a commit fc0f3d0

File tree

4 files changed

+68
-13
lines changed

4 files changed

+68
-13
lines changed

remote/config.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from remote.utils import get_instance_ids, get_instance_info, get_instances
1616

1717
app = typer.Typer()
18-
console = Console(force_terminal=True, width=200)
18+
console = Console(force_terminal=True)
1919

2020
# Valid configuration keys with descriptions
2121
VALID_KEYS: dict[str, str] = {
@@ -586,23 +586,17 @@ def validate(
586586
for warning in result.warnings:
587587
output_lines.append(f"[yellow]⚠ WARNING:[/yellow] {warning}")
588588

589-
# Determine status
589+
# Determine status and border style
590590
if not result.is_valid:
591-
status = "[red]Status: Invalid - errors must be fixed[/red]"
591+
output_lines.append("[red]✗ Configuration is invalid[/red]")
592592
border_style = "red"
593593
elif result.warnings:
594-
status = "[yellow]Status: Has warnings but usable[/yellow]"
594+
output_lines.append("[yellow]⚠ Configuration has warnings[/yellow]")
595595
border_style = "yellow"
596596
else:
597-
output_lines.append("[green]✓ All checks passed[/green]")
598-
status = "[green]Status: Valid[/green]"
597+
output_lines.append("[green]✓ Configuration is valid[/green]")
599598
border_style = "green"
600599

601-
# Add status line
602-
if output_lines:
603-
output_lines.append("")
604-
output_lines.append(status)
605-
606600
# Display as Rich panel
607601
panel_content = "\n".join(output_lines)
608602
panel = Panel(panel_content, title="Config Validation", border_style=border_style)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Issue 36: Config Validate Panel Too Wide
2+
3+
**Status:** COMPLETED
4+
**Priority:** Low
5+
**Target Version:** v1.1.0
6+
**Files:** `remote/config.py`, `tests/test_config.py`
7+
8+
## Problem
9+
10+
The `remote config validate` command had two issues:
11+
12+
1. **Panel stretches beyond console width**: The Rich Console was created with a hardcoded `width=200`, causing the validation panel to stretch beyond the actual terminal width.
13+
14+
2. **Redundant output messages**: When config is valid, the output showed both:
15+
- "All checks passed"
16+
- "Status: Valid"
17+
18+
This was redundant - only one success message is needed.
19+
20+
## Solution
21+
22+
### 1. Remove hardcoded console width
23+
24+
Changed from:
25+
```python
26+
console = Console(force_terminal=True, width=200)
27+
```
28+
29+
To:
30+
```python
31+
console = Console(force_terminal=True)
32+
```
33+
34+
This allows Rich to automatically detect and use the terminal's actual width.
35+
36+
### 2. Simplify validation output
37+
38+
Replaced the redundant output with a single, clear status message:
39+
40+
- Invalid: "Configuration is invalid" (red)
41+
- Warnings: "Configuration has warnings" (yellow)
42+
- Valid: "Configuration is valid" (green)
43+
44+
## Changes Made
45+
46+
### `remote/config.py`
47+
- Line 18: Removed `width=200` from Console initialization
48+
- Lines 589-604: Simplified validation output to show single status message
49+
50+
### `tests/test_config.py`
51+
- Line 616: Updated test assertion from "Status: Valid" to "Configuration is valid"
52+
53+
## Acceptance Criteria
54+
55+
- [x] Console uses terminal's actual width instead of hardcoded 200
56+
- [x] Valid config shows single "Configuration is valid" message
57+
- [x] Invalid config shows errors plus "Configuration is invalid" message
58+
- [x] Config with warnings shows warnings plus "Configuration has warnings" message
59+
- [x] All tests pass
60+
- [x] Type check passes
61+
- [x] Linter passes

specs/plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ Features and improvements for future releases.
7070
| Order | ID | Issue | Rationale | Spec | Status |
7171
|-------|-----|-------|-----------|------|--------|
7272
| 18 | 35 | Built-in watch mode | Fix garbled output when using `watch` command with Rich | [issue-35](./issue-35-watch-mode.md) | COMPLETED |
73-
| 19 | 36 | Config validate panel too wide | Panel stretches beyond console width; also redundant "All checks passed" and "Status: Valid" | [issue-36](./issue-36-config-validate-output.md) | TODO |
73+
| 19 | 36 | Config validate panel too wide | Panel stretches beyond console width; also redundant "All checks passed" and "Status: Valid" | [issue-36](./issue-36-config-validate-output.md) | COMPLETED |
7474
| 20 | 37 | Pricing API region fallback | Pricing API only works in us-east-1; fallback to us-east-1 pricing for other regions | [issue-37](./issue-37-pricing-region-fallback.md) | TODO |
7575
| 21 | 38 | Instance cost command | Add command to show estimated cost of instance based on uptime | [issue-38](./issue-38-instance-cost-command.md) | TODO |

tests/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ def test_validate_valid_config(self, tmpdir):
613613
assert result.exit_code == 0
614614
# Rich panel displays validation result
615615
assert "Config Validation" in result.stdout
616-
assert "Status: Valid" in result.stdout
616+
assert "Configuration is valid" in result.stdout
617617

618618
def test_validate_missing_config(self, tmpdir):
619619
"""Should report missing config file."""

0 commit comments

Comments
 (0)