UX-13 P1: page shell and Home screen on a structured /status
checks / unit (pull_request) Successful in 9m37s
infra-pin / fresh (pull_request) Successful in 2s

- app/static/{index.html,app.css,app.js}: tabs (Home, Batteries, Settings,
  Setup), hash routes, phone bottom tabs, light/dark. Served inlined at "/";
  the route list is unchanged, and every URL is relative.
- app/homeview.py: /status gains state, now, batteries, plan, attention,
  month_peak and control beside the old fields. The plan is what the add-on
  does today: the arbitrage verdict (the same plan.arbitrage() call as the
  cycle), the monthly cycle, the peak limit, "follows the house".
- The Home plan chart has hover, tap and keyboard-focus tooltips: price bar =
  hour and price; block = what, when, why, kWh and EUR.
- Region preset and year: in config/model (for P2) and on the Home price line.
- test_home.py; test_messages part 8 scans every Home sentence; STYLE plan line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LyR88rXETvwhTgx6yHE39p
This commit is contained in:
Claude
2026-09-28 00:45:01 +02:00
parent afd6af068d
commit f8d63cc614
12 changed files with 2388 additions and 81 deletions
+63
View File
@@ -1817,6 +1817,69 @@ check("the action log counts 'engagements' with a real plural and the "
and messages.count(25, "engagement") == "25 engagements"
and messages.count(1, "engagement") == "1 engagement")
# ============================================================================== #
print("\n8. the Home screen's sentences (UX-13 P1)")
# app/homeview.py builds every sentence the Home screen shows. Each is rendered
# with real values by `text_samples()` and held to STYLE.md: a title at most 5
# words, a plan line at most 2 sentences of at most 12 words each (the design
# note's new row type), any other line 1 sentence of at most 25 words.
from app import homeview # noqa: E402
PLAN_SENTENCE_WORDS, PLAN_SENTENCES = 12, 2
def home_problems(kind, text):
if kind == "title":
return title_problems(text)
out = text_problems(text, keys=False, entities=False)
if ";" in text:
out.append("semicolon")
if kind == "line":
if sentences(text) > 1:
out.append(f"over 1 sentence ({sentences(text)})")
if len(words(text)) > 25:
out.append(f"over 25 words ({len(words(text))})")
return out
if sentences(text) > PLAN_SENTENCES:
out.append(f"plan line over {PLAN_SENTENCES} sentences")
long = [x for x in re.split(r"(?<=[.!?])\s+", text)
if len(words(x)) > PLAN_SENTENCE_WORDS]
if long:
out.append(f"plan sentence over {PLAN_SENTENCE_WORDS} words "
f"({len(words(long[0]))}): {long[0]!r}")
return out
_home = homeview.text_samples()
_home_bad = [(k, t, p) for k, t in _home for p in [home_problems(k, t)] if p]
for k, t, p in _home_bad:
print(f" {k}: {t!r}: {p}")
check(f"every Home sentence obeys its STYLE limit ({len(_home)} rendered, "
f"{len(_home_bad)} over)", len(_home) > 80 and not _home_bad)
_shadowed = [t for k, t in homeview.text_samples() if "ould" in t]
check("in shadow mode the Home plan says what the add-on WOULD do: every "
"shadow variant of a plan text carries 'would'",
all("ould" in f(True) for f in (
lambda sh: homeview.run_grid_what(2.5, sh),
lambda sh: homeview.run_give_what(2.5, sh),
lambda sh: homeview.run_cycle_what("idle", sh),
lambda sh: homeview.run_cycle_why(sh),
lambda sh: homeview.run_peak_what(3500, sh),
lambda sh: homeview.run_house_what(sh),
lambda sh: homeview.run_house_why(sh),
lambda sh: homeview.plan_head("house", sh),
lambda sh: homeview.plan_head("trade", sh),
lambda sh: homeview.line_peak_limit(3500, sh)))
and not any("ould" in f(False) for f in (
lambda sh: homeview.run_grid_what(2.5, sh),
lambda sh: homeview.run_house_what(sh),
lambda sh: homeview.plan_head("house", sh)))
and len(_shadowed) > 10)
check("mutation: a 13-word plan sentence and a 6-word title are caught",
home_problems("plan", "One two three four five six seven eight nine "
"ten eleven twelve thirteen.")
and home_problems("title", "One two three four five six"))
print()
if fails:
print(f"{len(fails)} FAILED")