mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-20 11:52:28 +01:00
A star button beside the log button sends the typed text to estimate_meal and logs the result like a typed meal: the locked slot, source "claude", food bank, unlock. Icon states only (idle star, spinner, warning); no visible text. It is composed (ClaudeFlow), not a new MRO class, since the gate chain is at pylint's max-parents cap. Idle uses U+2726, not the sparkles emoji: U+2728 is only in FreeSerif and Noto Color Emoji here, and a colour-emoji fallback can crash Tk 8.6. Failure paths (all fail-closed: never unlock, block or freeze): - estimator error, no login, bad JSON, any exception: warning icon, nothing logged, manual log path untouched. - no answer in 45 s: the poll gives up (warning icon); a late answer is discarded. - slot already logged by hand meanwhile: the result is dropped. - empty description: error status, no call. - seam: the estimator name is patched to a raising stub in conftest; a mistyped target errors every test at setup (verified once). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWZHWP4KZ6x5TcXDBFC
99 lines
3.1 KiB
Python
99 lines
3.1 KiB
Python
"""The PC gate's glyph vocabulary: one shape per concept, no words.
|
|
|
|
kuhy's textgate rule (2026-11-08): nothing the gate paints carries a word.
|
|
Every Tk surface draws from this one table so a concept looks the same on the
|
|
Log Meal, History and Body tabs. Plain geometric BMP characters only, all in
|
|
DejaVu Sans: colour emoji can crash Tk 8.6 and the gate is the one window
|
|
that must never fail to draw. ``test_gate_no_words`` is the guard.
|
|
|
|
The macro shapes match the phone app's ``MacroKind`` (protein circle, carbs
|
|
triangle, fat square), so one vocabulary reads the same on both devices.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Final
|
|
|
|
# Status cues: the status line shows one of these instead of a sentence.
|
|
OK: Final = "✓"
|
|
ERROR: Final = "✗"
|
|
BUSY: Final = "⋯"
|
|
EMPTY: Final = "∅"
|
|
DEMO_ONLY: Final = "⊘"
|
|
WARN: Final = "⚠"
|
|
|
|
# Fields and concepts.
|
|
FOOD: Final = "✎"
|
|
AMOUNT: Final = "⚖"
|
|
PROTEIN: Final = "●"
|
|
CARBS: Final = "▲"
|
|
FAT: Final = "■"
|
|
MACRO_COLORS: Final = {"protein": "#6abf69", "carbs": "#e0a33a", "fat": "#6b9bef"}
|
|
BUDGET: Final = "⚑"
|
|
CLOCK: Final = "◷"
|
|
AVERAGE: Final = "⌀"
|
|
BIRTH: Final = "✱"
|
|
RESTING: Final = "☾"
|
|
IDEAL: Final = "◎"
|
|
STEPS: Final = "⇶"
|
|
MEASURED: Final = "◉"
|
|
TIMES: Final = "\N{MULTIPLICATION SIGN}"
|
|
ITEMS: Final = TIMES
|
|
GRAMS: Final = "g"
|
|
|
|
# Actions.
|
|
SUBMIT: Final = "✓"
|
|
EDIT: Final = "✎"
|
|
SAVE: Final = "✓"
|
|
DELETE: Final = "⌫"
|
|
CLOSE: Final = "✕"
|
|
SYNC: Final = "⟳"
|
|
DELIVERY: Final = "▣"
|
|
FILL_ALL: Final = "⇊"
|
|
INFINITE: Final = "∞"
|
|
UNLOCKING: Final = "⇥"
|
|
|
|
# The Claude estimate button: idle, one frame per poll tick while working
|
|
# (the spinner), and the error state it rests in until the next click. Idle is
|
|
# the monochrome four-pointed star, not the sparkles emoji (U+2728): that one
|
|
# is only in FreeSerif and Noto Color Emoji here, and a colour-emoji fallback
|
|
# can crash Tk 8.6 -- the one window that must never fail to draw.
|
|
CLAUDE: Final = "✦"
|
|
CLAUDE_BUSY: Final = "◐◓◑◒"
|
|
CLAUDE_FAILED: Final = "⚠"
|
|
|
|
# Notebook tabs.
|
|
TAB_LOG: Final = "✚"
|
|
TAB_HISTORY: Final = "▦"
|
|
TAB_BODY: Final = "♙"
|
|
|
|
# Profile sex, goal direction and goal span.
|
|
MALE: Final = "♂"
|
|
FEMALE: Final = "♀"
|
|
DIRECTION: Final = {"lose": "↓", "maintain": "=", "gain": "↑"}
|
|
SPAN: Final = {"day": "◔", "week": "◑", "month": "◕", "year": "●"}
|
|
|
|
# Summaries: the year's tally, an empty value, and how an average compared
|
|
# with its budget (``AverageBand`` values; shape and fill grow with the excess).
|
|
YEAR_TOTAL: Final = "Σ"
|
|
DASH: Final = "\N{EN DASH}"
|
|
NO_VALUE: Final = DASH
|
|
BAND: Final = {"under": "✓", "slightly_over": "△", "very_over": "▲"}
|
|
|
|
# Weekday header: weekdays small, the weekend larger (no day names).
|
|
WEEKDAY: Final = "•"
|
|
WEEKEND: Final = "●"
|
|
WEEKDAY_DOTS: Final = (WEEKDAY,) * 5 + (WEEKEND,) * 2
|
|
|
|
|
|
def source_glyph(source: str) -> str:
|
|
"""Where a nutrition came from: food bank, staple, catering, typed, looked up."""
|
|
head = source.split(":", 1)[0].strip()
|
|
return {
|
|
"food bank": "▤",
|
|
"staple": "★",
|
|
"catering": DELIVERY,
|
|
"claude": CLAUDE,
|
|
"manual": FOOD,
|
|
}.get(head, "≈")
|