Skip to content

Render an environment as text, with an example console application - #59

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/text-renderer
Nov 6, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/text-renderer

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • text_renderer.py is added, with renderLocations(locations, filled, empty), which turns locations into a text grid. Pygame is not imported, and the grid is sized from the locations themselves.
  • console_view.py is added as the example console application that Add text-based UI support to library for users #11 asks for. python console_view.py <environmentId> prints an environment that already exists in Viron. Nothing is created in Viron, no file is written and no usage is reported.
  • The README documents both, under a new Text rendering section, and its test-suite paragraphs are updated.

An environment ID was chosen as the argument over a grid size so that the example needs no copy of main.py's cache and creation logic, which cannot be imported without Pygame. The url and port constants are duplicated for the same reason.

main.py, render_window.py, graphik.py, the Viron pin and the workflow file are unchanged.

Closes #11

Test plan

  • python3 -m unittest discover -s tests: 192 tests executed, all passing, 22 of them new
  • python3 -m py_compile on every top-level module, including the two new ones
  • python3 headless_run.py: all three scenarios PASS, so the Pygame path is unaffected
  • console_view.py run unmodified on Python 3.8 against the real LocationService and Location model over real HTTP, using a local stand-in server on :9999. Exit statuses were 0 for a 3x3 environment, 1 for an empty list, 1 for a 500, 1 for a refused connection, 2 for a missing argument and 0 for --help
  • Mutation check: swapping x and y and adding import pygame to text_renderer.py failed 5 of its 9 tests. The source was then restored
  • Live Viron: UNVERIFIED-not-applicable. The anchor cannot run here (Python 3.8, gated Docker) and it exercises main.py, which is unchanged. The stand-in server's JSON and its empty-list answer were taken from Location and LocationController in the pinned submodule, not observed from a running Viron

Notes for review

  • console_view.py and text_renderer.py are not added to the py_compile step in .github/workflows/tests.yml, since workflow files are on the do-not-auto-merge list. The suite imports both modules, so a syntax error still fails CI, and the README says so.
  • Viron gives every grid the same coordinates, so an environment with several grids is drawn overlapping. The README states this; multi-grid drawing remains Support drawing environments with multiple grids #2.

Issues not picked

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

Patchwork could only show an environment through Pygame. text_renderer
turns locations into a grid of text without importing Pygame, and
console_view prints an existing environment from its ID, so it needs no
display, creates nothing in Viron and writes no file.

Closes #11

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric, scored against head cb9d0fc, on which CI (test) is green:

  • Scope: PASS. All five changed files serve Add text-based UI support to library for users #11. main.py, render_window.py, graphik.py, the Viron pin and the workflow are unchanged, as git diff --name-only origin/main shows.
  • Tests-new: PASS. renderLocations, parseEnvironmentId, main and the entry point are each exercised, by 22 new tests.
  • Tests-fix: not applicable, since no bug is fixed. As a substitute, a mutation of text_renderer.py (swapped x/y, added import pygame) failed 5 of its 9 tests. console_view.py itself was not mutated, so its tests have not been shown to fail.
  • Sibling structure: PASS. Top-level modules use snake_case filenames, camelCase functions and Args/Returns docstrings, and test files are named test_<module>.py. The argument handling matches headless_run.py (exit status 2) and main.py (--help and -h).
  • Sibling renames: not applicable, since nothing is renamed.
  • Docs: PASS. README.md covers the library function, the application, its exit statuses, and the test-suite paragraphs. The .bat scripts are unaffected, as main.py's arguments did not change.
  • Issue resolution: PASS. Add text-based UI support to library for users #11 asks for text visualization in the library and an example console application, and both are added.
  • Manual validation: PASS for what can run here. The suite ran 192 tests, all passing, and headless_run.py passed all three scenarios. console_view.py ran over real HTTP through the real LocationService, on Python 3.8, for all six outcomes in the test plan. Live Viron remains UNVERIFIED-not-applicable: the anchor exercises main.py, which is unchanged.

Findings:

  • console_view.py:18 — judgment call, left as is: url and port duplicate main.py:25-26, because importing main pulls in Pygame. A follow-up issue was filed for making the Viron address configurable in one place.
  • README.md:248 — the wording has to name two exceptions to the py_compile step, because .github/workflows/tests.yml was left alone (it is on the do-not-auto-merge list). A follow-up issue was filed. No coverage is lost, since a syntax error fails the suite's import.
  • console_view.py:65 — confirmed against source: LocationRepositoryImpl.findByEnvironmentId returns an empty list for an unknown ID, and the controller answers 200, so this comment is accurate for the pinned Viron.
  • The real requests call was served by a stand-in, so a response shape that differs from the pinned Location model would not have been detected. The JSON keys were taken from that model's constructor.

Do-not-auto-merge check: no .github/workflows/*, security/ or .gitmodules path is modified, and no file loses more than 50 lines.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit a179b40 into main Nov 6, 2026
1 check passed
@dmccoystephenson
dmccoystephenson deleted the feature/text-renderer branch November 6, 2026 11:11
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.

Add text-based UI support to library for users

1 participant