Fix workout flow for text-free app and picker
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run

The settings row is now labelled "Sync settings", and Google sign-in
shows the AccountManager picker, whose OK is android:id/button2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-16 09:10:19 +01:00
parent e559b3e165
commit e4790975ad
4 changed files with 90 additions and 42 deletions

View File

@ -1,39 +0,0 @@
{
"intent": "The i3blocks shutdown and gaming_budget blocks render from the daily-limits cache ($XDG_RUNTIME_DIR/daily-limits.json), so the earner list, sizes and ceiling come from the earned_time registry instead of being duplicated in shell; left-click opens daily-limits --gui.",
"scope": [
"linux_configuration/i3blocks/gaming_budget.sh, shutdown_countdown.sh",
"linux_configuration/tests/test_i3blocks_{gaming_budget,shutdown_hint,efficiency}.sh",
"Non-goal: changing the shutdown enforcement itself (screen-locker / digital-wellbeing)"
],
"changes": [
"gaming_budget.sh: drop the curl to the enforcer /api/budget, the config.json read and the fallback bonus sizes; read gaming budget/used/day and the not-done earners from the cache",
"shutdown_countdown.sh: replace earner_hint() with render_limits/load_limits fed by todo[]; →max from shutdown_after reaching the ceiling; unknown earners shown with '?'",
"Both: a cache older than 180 s (or from the future) shows a ⏱? marker and never stale numbers; jq runs only when the cache mtime changes (rendered line cached in $XDG_RUNTIME_DIR)",
"Tests rewritten from the curl stub to DAILY_LIMITS_CACHE fixtures; the shutdown exec bound drops from 2 to 1"
],
"verification": [
{
"command": "bash linux_configuration/i3blocks/gaming_budget.sh; bash linux_configuration/i3blocks/shutdown_countdown.sh (live, daily-limits timer running)",
"result": "pass",
"evidence": "🎮 0h43 left · 2h17/3h00 +💪2h +🧩1h +📖1h +🗂30m +⚙30m / ⏻ 20:00 +💪2h +🧩1h +📖1h +🗂30m +⚙30m →max 23:00 — same format as before the change"
},
{
"command": "capped.sh bash tests/test_i3blocks_gaming_budget.sh; test_i3blocks_shutdown_hint.sh; test_i3blocks_efficiency.sh",
"result": "pass",
"evidence": "All gaming_budget checks passed. / All shutdown hint tests passed. / All i3blocks efficiency regression tests passed."
},
{
"command": "strace -f -c (clone+execve per tick)",
"result": "pass",
"evidence": "gaming steady state 0 clone + 1 execve (was 4 + 3 with curl and jq); shutdown 3 clone + 1 execve (was 8 + 3)"
}
],
"risks": [
"If the daily-limits user timer stops, both blocks show ⏱? (shutdown falls back to the local config time, which is still correct)",
"daily-limits must be on PATH for left-click; otherwise the click does nothing"
],
"rollback": [
"git revert this commit; the blocks go back to the enforcer API and the in-script earner table",
"After a rollback, check the bar shows numbers again with the enforcer running"
]
}

View File

@ -0,0 +1,46 @@
{
"intent": "workout_firebase_flow reaches the connected state again on the current workout_app: the text-free settings screen and Android's AccountManager account picker broke the 2026-11-08 version.",
"scope": [
"python_pkg/android_ui/workout_firebase_flow.py and its test only",
"No change to the MCP server, the CLI or the driver"
],
"changes": [
"SYNC_ROW is now 'Sync settings' (the cloud icon's semanticLabel); the 'Firebase sync' subtitle was removed by screen-locker's textgate commit b584c04",
"The account chooser is also recognised as a CheckedTextView list of e-mails (AccountManager picker); after tapping the account the flow re-dumps and taps OK (android:id/button2, measured: button1 is Cancel) only if the picker is still up"
],
"verification": [
{
"command": "python -m pytest -q python_pkg/android_ui/tests/test_workout_firebase_flow.py --cov=python_pkg.android_ui.workout_firebase_flow --cov-branch",
"result": "pass",
"evidence": "red first: 2 failed (AccountManager picker tests); then 16 passed, workout_firebase_flow.py 100% line+branch"
},
{
"command": "workout_firebase_flow --serial 23181JEGR08034 --display self --account <linked account> (slot com.kuhy.slot1, current layout)",
"result": "pass",
"evidence": "exit 0 'workout-firebase-flow: connected'; screenshot shows the account row with the unlink icon and the synced cloud"
},
{
"command": "same command, after swapping _SyncSection and _OfflineBackupSection in settings_screen.dart, rebuilding and reinstalling the slot",
"result": "pass",
"evidence": "exit 0 'connected'; dump shows OFFLINE BACKUP at y=1452 above SYNC at y=2178. Script unchanged between runs"
},
{
"command": "workout_firebase_flow --serial 23181JEGR08034 --display self --negative",
"result": "pass",
"evidence": "exit 1; stderr: waited 3.0s for 'No Such Button': no element matches 'No Such Button'. On screen now: ..."
},
{
"command": "android-ui --display self tap Back (on Settings)",
"result": "pass",
"evidence": "error, nothing tapped: 2 elements match 'Back': 'Back' <Button>; 'OFFLINE BACKUP' <View> (C4 on the phone)"
}
],
"risks": [
"--account must name the Google account linked to the sync data; another account gets the app's 'signed in as the wrong account' error and the flow times out naming 'Disconnect'",
"button2-as-OK is measured on this Pixel's Android build; a different picker layout falls back to the timeout error, never a wrong success"
],
"rollback": [
"git revert the commit; the 2026-11-08 flow returns (it fails on the current app at the 'Firebase sync' scroll)",
"Re-run test_workout_firebase_flow.py"
]
}

View File

@ -80,6 +80,31 @@ class TestFlow:
assert flow.run_flow(ui, account="me@example.com", timeout=5) == "connected"
ui.tap.assert_called_with("me@example.com", exact=True)
def test_account_manager_chooser_picks_account_then_confirms(self) -> None:
"""Android's AccountManager picker: a checked list plus an OK button."""
picker = [
_el("Wybierz konto"),
_el("me@example.com", cls="android.widget.CheckedTextView"),
_el("OK", cls="android.widget.Button", res="android:id/button2"),
]
ui = _ui(SIGN_IN, picker, picker, CONNECTED)
assert flow.run_flow(ui, account="me@example.com", timeout=5) == "connected"
taps = [c.args[0] for c in ui.tap.call_args_list]
assert taps[-2:] == ["me@example.com", "android:id/button2"]
def test_picker_closed_by_the_account_tap_is_not_confirmed(self) -> None:
picker = [_el("me@example.com", cls="android.widget.CheckedTextView")]
ui = _ui(SIGN_IN, picker, [], CONNECTED)
assert flow.run_flow(ui, account="me@example.com", timeout=5) == "connected"
taps = [c.args[0] for c in ui.tap.call_args_list]
assert taps[-1] == "me@example.com"
def test_account_manager_chooser_without_account_hands_over(self) -> None:
picker = [_el("me@example.com", cls="android.widget.CheckedTextView")]
ui = _ui(SIGN_IN, picker)
with pytest.raises(flow.HandOverError, match="--account"):
flow.run_flow(ui, account=None, timeout=5)
def test_account_chooser_without_account_hands_over(self) -> None:
ui = _ui(SIGN_IN, [_el("Wybierz konto", res=_CHOOSER_ID)])
with pytest.raises(flow.HandOverError, match="--account"):

View File

@ -4,7 +4,7 @@
[--display self] [--account EMAIL]
python3 -m python_pkg.android_ui.workout_firebase_flow --serial ... --negative
Home -> Settings (gear tooltip) -> scroll to the "Firebase sync" row -> Sync
Home -> Settings (gear tooltip) -> scroll to the "Sync settings" row -> Sync
settings -> "Sign in with Google" -> wait for "Disconnect". Every workout_app
label lives in this file and nowhere else, so a layout change (reordering the
SYNC and OFFLINE BACKUP sections) needs no edit here -- only a renamed label
@ -34,12 +34,16 @@ if TYPE_CHECKING:
# workout_app / sync_settings_ui labels (sync_settings_ui-v0.5.2).
SETTINGS = "Settings" # home_screen.dart: the gear's tooltip
SYNC_ROW = "Firebase sync" # settings_screen_sections.dart: the row's subtitle
SYNC_ROW = "Sync settings" # settings_screen_sections.dart: cloud icon semanticLabel
SIGN_IN = "Sign in with Google"
CONNECTED = "Disconnect" # only rendered while Firebase is connected
# Google's account chooser: its title follows the phone's locale ("Wybierz
# konto" on the Pixel), so it is found by its GMS container id instead.
CHOOSER = "com.google.android.gms:id/google_sign_in_container"
# Android's AccountManager picker (seen 2026-11-16) has no GMS container: it is
# a checked list of account e-mails plus OK; tapping a row only checks it.
CHOOSER_ROW_CLASS = "CheckedTextView"
CHOOSER_OK = "android:id/button2" # OK; button1 is Cancel (measured)
NEGATIVE = "No Such Button"
# Text that means a screen wants a secret. Matched on editable fields only, so
# a label such as "Use the account password instead" does not trip it.
@ -70,6 +74,15 @@ def _asks_for_secret(screen: list[UiElement]) -> bool:
return False
def _chooser_up(screen: list[UiElement]) -> bool:
for element in screen:
if element.matches(CHOOSER, exact=True):
return True
if element.class_name.endswith(CHOOSER_ROW_CLASS) and "@" in element.text:
return True
return False
def run_flow(ui: AndroidUi, *, account: str | None, timeout: float) -> str:
"""Run the flow from the home screen; return how it ended."""
ui.tap(SETTINGS, exact=True)
@ -88,11 +101,14 @@ def run_flow(ui: AndroidUi, *, account: str | None, timeout: float) -> str:
if _asks_for_secret(screen):
msg = "the sign-in asks for a password or 2FA code (a secret)"
raise HandOverError(msg)
if any(e.matches(CHOOSER, exact=True) for e in screen):
if _chooser_up(screen):
if account is None:
msg = "the Google account chooser is up: pass --account <email>"
raise HandOverError(msg)
ui.tap(account, exact=True)
# A single tap closes some pickers; only confirm one still up.
if any(e.matches(CHOOSER_OK, exact=True) for e in ui.dump()):
ui.tap(CHOOSER_OK, exact=True)
time.sleep(_POLL_S)
msg = f"waited {timeout}s for {CONNECTED!r} after tapping {SIGN_IN!r}"
raise ElementNotFoundError(msg)