Skip to content

Commit a0ce56c

Browse files
claudeivyleavedtoadflax
authored andcommitted
fix: Set expand=False on all Rich Panels to prevent full-width expansion
All Panel components in the codebase were expanding to fill the terminal width instead of fitting their content. This fixes recurring issues with overly wide panels in instance status, config validate, and launch commands. Changes: - instance.py: Fixed _build_status_table and launch panels - config.py: Fixed validate command panel - ami.py: Fixed launch command panel - Added test for panel expand=False property Fixes #43 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> (cherry picked from commit f02aff2)
1 parent 15ec8b7 commit a0ce56c

File tree

6 files changed

+58
-9
lines changed

6 files changed

+58
-9
lines changed

remote/ami.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def launch(
291291
"\n".join(summary_lines),
292292
title="[green]Instance Launched[/green]",
293293
border_style="green",
294+
expand=False,
294295
)
295296
console.print(panel)
296297
except ValidationError as e:

remote/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ def validate(
596596

597597
# Display as Rich panel
598598
panel_content = "\n".join(output_lines)
599-
panel = Panel(panel_content, title="Config Validation", border_style=border_style)
599+
panel = Panel(panel_content, title="Config Validation", border_style=border_style, expand=False)
600600
console.print(panel)
601601

602602
if not result.is_valid:

remote/instance.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def _build_status_table(instance_name: str, instance_id: str) -> Panel | str:
291291
"\n".join(lines),
292292
title="[bold]Instance Details[/bold]",
293293
border_style="blue",
294+
expand=False,
294295
)
295296
return panel
296297

@@ -1049,6 +1050,7 @@ def launch(
10491050
"\n".join(summary_lines),
10501051
title="[green]Instance Launched[/green]",
10511052
border_style="green",
1053+
expand=False,
10521054
)
10531055
console.print(panel)
10541056
except ValidationError as e:

specs/issue-43-panel-width-fix.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Issue 43: Fix Rich Panel Width Globally
22

3-
**Status:** TODO
3+
**Status:** COMPLETED
44
**Priority:** Medium
55
**Target Version:** v1.2.0
66
**Files:** Multiple files in `remotepy/`
@@ -67,12 +67,12 @@ def create_panel(content: str, title: str, **kwargs) -> Panel:
6767

6868
## Acceptance Criteria
6969

70-
- [ ] Audit all `Panel(` usage in codebase
71-
- [ ] Fix all panels to use `expand=False` or appropriate width
72-
- [ ] Verify `instance status` panel fits content
73-
- [ ] Verify no other panels are overly wide
74-
- [ ] Add tests to verify panel width behavior
75-
- [ ] Consider helper function for consistent Panel creation
70+
- [x] Audit all `Panel(` usage in codebase
71+
- [x] Fix all panels to use `expand=False` or appropriate width
72+
- [x] Verify `instance status` panel fits content
73+
- [x] Verify no other panels are overly wide
74+
- [x] Add tests to verify panel width behavior
75+
- [x] Consider helper function for consistent Panel creation (not needed for 4 usages)
7676

7777
## Testing
7878

specs/plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ Features and improvements for future releases.
7777
| 23 | 40 | Standardize console output styles | Align all command output to match `config show` style for consistency | [issue-40](./issue-40-console-output-consistency.md) | COMPLETED |
7878
| 24 | 41 | Fix instance cost integration | Cost not displaying, panel too wide, integrate into `instance ls` instead of separate command | [issue-41](./issue-41-instance-cost-fixes.md) | COMPLETED |
7979
| 25 | 42 | Clarify instance ls vs status | Evaluate overlap between commands; ensure distinct purposes or consolidate | [issue-42](./issue-42-ls-vs-status.md) | COMPLETED |
80-
| 26 | 43 | Fix Rich Panel width globally | Panels expand to full terminal width; audit all Panel usage and set expand=False | [issue-43](./issue-43-panel-width-fix.md) | TODO |
80+
| 26 | 43 | Fix Rich Panel width globally | Panels expand to full terminal width; audit all Panel usage and set expand=False | [issue-43](./issue-43-panel-width-fix.md) | COMPLETED |
8181
| 27 | 44 | Validate tests against real API formats | Mocked tests can pass while real API fails; add validation against actual AWS response formats | [issue-44](./issue-44-test-api-validation.md) | TODO |
8282
| 28 | 45 | v1.1.0 release preparation | Update changelog, version bump, final testing | [issue-45](./issue-45-v1.1-release-preparation.md) | TODO |

tests/test_instance.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,52 @@ def test_should_return_panel_for_running_instance(self, mocker):
329329

330330
assert isinstance(result, Panel)
331331

332+
def test_should_return_panel_with_expand_false(self, mocker):
333+
"""Panel should not expand to full terminal width."""
334+
from rich.panel import Panel
335+
336+
from remote.instance import _build_status_table
337+
338+
mocker.patch(
339+
"remote.instance.get_instance_status",
340+
return_value={
341+
"InstanceStatuses": [
342+
{
343+
"InstanceId": "i-0123456789abcdef0",
344+
"InstanceState": {"Name": "running"},
345+
"SystemStatus": {"Status": "ok"},
346+
"InstanceStatus": {"Status": "ok", "Details": [{"Status": "passed"}]},
347+
}
348+
]
349+
},
350+
)
351+
mock_ec2_client = mocker.patch("remote.instance.get_ec2_client")
352+
mock_ec2_client.return_value.describe_instances.return_value = {
353+
"Reservations": [
354+
{
355+
"Instances": [
356+
{
357+
"InstanceId": "i-0123456789abcdef0",
358+
"State": {"Name": "running"},
359+
"InstanceType": "t2.micro",
360+
"PublicIpAddress": "1.2.3.4",
361+
"PrivateIpAddress": "10.0.0.1",
362+
"PublicDnsName": "ec2-1-2-3-4.compute-1.amazonaws.com",
363+
"KeyName": "my-key",
364+
"Placement": {"AvailabilityZone": "us-east-1a"},
365+
"SecurityGroups": [{"GroupName": "default"}],
366+
"Tags": [{"Key": "Name", "Value": "test-instance"}],
367+
}
368+
]
369+
}
370+
]
371+
}
372+
373+
result = _build_status_table("test-instance", "i-0123456789abcdef0")
374+
375+
assert isinstance(result, Panel)
376+
assert result.expand is False
377+
332378
def test_should_return_panel_for_stopped_instance(self, mocker):
333379
"""Should return a Panel for stopped instances (without health section)."""
334380
from rich.panel import Panel

0 commit comments

Comments
 (0)