8000 Full-screen flahax mix in the terminal (standard library only) by rafatahmed · Pull Request #124 · rafatahmed/Flahax · GitHub
[go: up one dir, main page]

Skip to content

Full-screen flahax mix in the terminal (standard library only) - #124

Merged
rafatahmed merged 11 commits into
mainfrom
feat/mix-tui
Oct 23, 2026
Merged

rafatahmed merged 11 commits into
mainfrom
feat/mix-tui

Conversation

@rafatahmed
@rafatahmed rafatahmed commented Oct 23, 2026 •
Copy link
Copy Markdown
Owner

flahax mix opens a full-screen, keyboard-driven wizard and results screen in a real terminal (owner design, 2026-10-23). It uses Python's standard library only and adds no dependencies.

What a grower sees

  • Five steps, forward only.
    • Arrow keys and Enter choose; typing filters long lists (crop formulas, chemicals); Space ticks the fertilizers available; Esc asks before quitting.
    • At 100 columns or more the answers so far stay in a "Your batch" pane on the left; narrower windows get one column with a step bar.
    • Below 80 x 24 the screen asks for a larger window.
  • Calculating: a spinner while the batch runs. Keys typed meanwhile are kept for the results screen.
  • Results: they open on Tanks (tank A, tank B, the acid or pH-reagent card); Tab shows Nutrients (Target, From water, Required, Achieved, Final, Diff, then the pH path) and Notes (each review note once). A blocked batch opens on Notes and exits with code 3.
  • Sheets: written before the results appear, exactly as before.

What does not change

  • Line mode: flahax mix --plain, scripts, pipes, editor output panels and the tests keep the line-by-line questions. A recorded transcript of the owner's session shows the line-mode output is byte-identical.
  • Fallback: a console that cannot switch on ANSI falls back to the line mode automatically.
  • Recipes: chemistry, tank rules, saved files and sheets are unchanged. The 97-result behaviour baseline is identical to main.

Structure

  • flahax.terminal: the console layer.
    • Windows: msvcrt for keys, ctypes to switch on ANSI.
    • Linux and macOS: termios, tty and select.
    • The console is always restored, including on Ctrl+C and errors.
    • Characters the console cannot print fall back to ASCII or become ?.
  • flahax.mix_tui: the widgets and frame (pure functions) and TuiPrompts, a subclass of the line-mode Prompts, so questions, defaults and validation are shared.
  • flahax.mix_results: the three views. They are drawn from the same summary, helpers and rounding as the batch sheet; tests check every weight, acid volume, pH and nutrient cell against the sheet.

Evidence

  • Tests and checks:

    • full suite including PHREEQC: OK;
    • ruff check and ruff format --check;
    • tools/verify_distribution.py: PASS;
    • strict Sphinx build;
    • LF line endings.
  • Independent review of the whole branch: no critical findings. Four findings were fixed with tests that failed first:

    • no ANSI → line mode;
    • complete ASCII fallback;
    • a long product name no longer hides its weight;
    • a base reagent is no longer labelled "Acid".

    The minor findings were opened as issues and are now fixed in this PR, each with a test that failed first.

Owner's manual check (please run before merging)

  • Windows Terminal at about 120 x 30: the two-pane wizard, then Tanks / Nutrients / Notes with Tab
  • Windows Terminal at 80 x 24: the one-column layout
  • Classic console (conhost, for example cmd started from Win+R)
  • Resize the window below 80 x 24 during a question, then back: the answer is kept
  • Ctrl+C at step 2: the terminal comes back normal and says "Stopped; nothing saved."
  • flahax mix --plain: the old line-by-line questions
  • flahax mix sessions/<name>: straight to the results

Issues

Closes #125
Closes #126
Closes #127
Closes #128
Closes #129
Closes #130
Closes #131
Closes #132

@read-the-docs-community
read-the-docs-community Bot commented Oct 23, 2026 •
Copy link
Copy Markdown

Documentation build overview

📚 Flahax | 🛠️ Build #35358689 | 📁 Comparing 4e11451 against latest (616c63b)

  🔍 Preview build  

2 files changed
± changelog.html
± growers.html

The golden transcript was recorded on Windows, so its two saved-path lines had backslashes and failed on the Linux CI runners. Paths under the temporary folder are now written with / on every system.
@codecov-commenter
codecov-commenter commented Oct 23, 2026 •
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.52174% with 93 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.78%. Comparing base (887846d) to head (4e11451).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
src/flahax/terminal.py 56.05% 69 Missing ⚠️
src/flahax/mix_tui.py 96.39% 12 Missing ⚠️
src/flahax/mix_cli.py 89.74% 8 Missing ⚠️
src/flahax/mix_results.py 96.72% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #124      +/-   ##
==========================================
- Coverage   89.95%   89.78%   -0.18%     
==========================================
  Files          51       54       +3     
  Lines        6630     7281     +651     
==========================================
+ Hits         5964     6537     +573     
- Misses        666      744      +78     
Flag Coverage Δ
unittests 89.78% <86.52%> (-0.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Two-pane messages wrap at the width they are painted at (#125).
- Long prompts wrap instead of being cut, so the lab-value syntax shows (#126).
- Windows: a lone U+00E0 is the letter a-grave, not an arrow-key prefix (#127).
- Ctrl+C on the results screen is the same as Q: the sheets exist (#128).
- After the answers are saved the quit question says the sheets will not be written (#129).
- No "pH:" line when there is no pH path (#130).
- The quit question redraws, and ignores Y while the window is too small (#131).
- Unchanged screens are not redrawn; console functions have ctypes types; the status is
  coloured by meaning; the real cursor shows in text fields (#132).
@rafatahmed
rafatahmed merged commit ac68c01 into main Oct 23, 2026
8 checks passed
@rafatahmed
rafatahmed deleted the feat/mix-tui branch October 23, 2026 15:58
rafatahmed added a commit that referenced this pull request Nov 7, 2026
Full-screen flahax mix in the terminal (standard library only)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
0