Skip to content

Use Rich trees for rhiza tree output#436

Merged
tschm merged 2 commits intomainfrom
copilot/use-rich-trees
Mar 12, 2026
Merged

Use Rich trees for rhiza tree output#436
tschm merged 2 commits intomainfrom
copilot/use-rich-trees

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

The tree command was hand-rolling ASCII tree rendering (├──, └──, ) via custom _build_tree / _render_tree helpers instead of delegating to Rich's Tree component.

Changes

  • src/rhiza/commands/tree.py: Deleted _build_tree (nested dict) and _render_tree (ASCII line renderer). Replaced with _build_rich_tree which constructs a rich.tree.Tree directly, and uses rich.console.Console for output.
  • tests/test_commands/test_tree.py: Replaced TestBuildTree / TestRenderTree with TestBuildRichTree targeting the new helper; integration tests unchanged.
  • pyproject.toml: Added rich as an explicit dependency (was previously only a transitive dep via typer).
# Before
tree = _build_tree(lock.files)       # → nested dict
lines = _render_tree(tree)           # → list[str] with manual connectors
print(".")
for line in lines:
    print(line)

# After
rich_tree = _build_rich_tree(lock.files)   # → rich.tree.Tree
console = Console()
console.print(rich_tree)
Original prompt

This section details on the original issue you should resolve

<issue_title>Use rich trees</issue_title>
<issue_description>Do not try to implement your own tree treatment with display etc. Use them off the shelf</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: tschm <2046079+tschm@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix implementation to use rich trees Use Rich trees for rhiza tree output Mar 12, 2026
@tschm tschm marked this pull request as ready for review March 12, 2026 08:23
@tschm tschm merged commit b328663 into main Mar 12, 2026
15 checks passed
@tschm tschm deleted the copilot/use-rich-trees branch March 12, 2026 08:25
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.

Use rich trees

2 participants