Communicate rendering credit usage in the TUI - #254
Merged
Conversation
Add a live credit-usage line (functionalities / used credits / render
time) beneath the render status, shown while rendering and frozen on
success, failure, and cancellation. Wording matches the console
post-render summary.
- New root module usage_summary.py as the single source of truth for the
usage line, shared by the console summary and the TUI. Kept at root so
the TUI stays independent of cli_output/the renderer.
- Elapsed render time is read from a single RunState.get_live_render_time()
accessor, reused by the log timestamps (previously duplicated in
ElapsedTimeFormatter and LoggingHandler), the TUI usage line, and the
summary. add_to_render_time resets the segment start after banking so the
value is not re-counted once a render completes.
- The TUI owns only the refresh cadence: it reads get_live_render_time() and
freezes the line while paused so it is never sampled inside the pause loop.
On every terminal path it captures the live value onto run_state so the TUI
line and console summary agree even when the render machine does not
finalize its own time (fixes render time reporting 0 on failure and
cancellation).
- Fix format_duration_hms mangling whole-second inputs (10s rendered as
"1s"); reuse it for the substate timers.
- Reword the TUI success line to match the design and console
("rendering completed!", "generated code folder:").
pedjaradenkovic
force-pushed
the
feat/communicate-rendering-credits
branch
from
July 19, 2026 10:12
cdc778d to
a493264
Compare
NejcS
reviewed
Jul 21, 2026
NejcS
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements Codeplain-ai/next-microsoft#13 — communicate rendering credit usage in the TUI.
What it does
Adds a credit-usage line beneath the render status —
functionalities N used credits N render time T— matching the Figma design:rendering in progress ...; render time ticks each second, counts update as functionalities complete.✓ rendering completed!/generated code folder: …(wording synced to the console summary).used credits == functionalities— 1 credit is charged per functional requirement.Key design points
usage_summary.py(new, root): single source of truth for the line's wording/markup, shared by the console summary (cli_output) and the TUI. Kept at root sotuistays independent ofcli_output/the renderer.RunState.get_live_render_time(): the render time is computed in exactly one place and reused by the log timestamps (previously duplicated inElapsedTimeFormatterandLoggingHandler), the TUI usage line, and the post-render summary.add_to_render_timeresets the segment start after banking so the value isn't re-counted once a render completes.get_live_render_time()and freezes the line while paused so it's never sampled inside the render machine's pause loop. On every terminal path it captures the live value ontorun_state, so the TUI line and the console summary always agree.Bug fixes included
format_duration_hmsmangled whole-second inputs (10→"1s") — this also affected the existing console summary and log timestamps.Tests
New:
tests/test_usage_summary.py,tests/test_plain2code_utils.py,tests/test_plain2code_state.py(elapsed-time accounting), andtests/test_tui_usage.py(headless Textualrun_testcovering the live line, success/failure/cancel states, and pause-freeze).black / isort / flake8 / mypy all clean. One pre-existing, unrelated failure remains on
main(tests/test_plainfileparser.py::test_code_variables).Open question for review
The
generated code folder:path is currently shown absolute (pre-existing behavior, unchanged here); the mockup shows it relative. Left as-is per discussion — to be decided separately.