Back out to Home before the workout flow taps Settings
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 slot app reopened into an in-progress workout, which has no gear,
so the Firebase flow failed on its first tap. AndroidUi.back() plus a
bounded _reach_home step fix it; verified live on the Pixel slot on the
current and the reordered settings layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-16 12:00:16 +01:00
parent 17708963a6
commit 40becf498d
7 changed files with 106 additions and 47 deletions

View File

@ -0,0 +1,15 @@
{
"title": "workout flow reaches Home before Settings",
"objective": "The workout_app Firebase flow starts from wherever the app reopens (e.g. an in-progress workout) by pressing BACK until Home's Settings gear shows, bounded to 3 presses.",
"acceptance_criteria": [
"AndroidUi.back sends keyevent 4 to its display (test_driver.py)",
"run_flow presses BACK only while Settings is absent and at most MAX_BACKS times (test_workout_firebase_flow.py)",
"Live slot run on the Pixel exits 0 on the current and the reordered layout",
"100% branch coverage of python_pkg/android_ui"
],
"out_of_scope": [
"A new MCP tool for back",
"Any committed screen-locker change"
],
"verifier": "python_pkg/android_ui/tests under pytest --cov-branch, plus the live flow run on slot com.kuhy.slot1"
}

View File

@ -1,41 +0,0 @@
{
"intent": "Give the daily-limits phone app an on-style launcher icon: an hourglass (a daily allowance that runs out) in the shared accent on the family charcoal.",
"scope": [
"python_pkg/app_icons/_glyph_art_more.py, glyphs.py: the `hourglass` glyph",
"python_pkg/app_icons/apps.py: the `daily_limits` registry entry",
"python_pkg/app_icons/tests/test_registry.py: no glyph reused across apps; hourglass sand takes the accent marker"
],
"changes": [
"New `hourglass` glyph: capped bars, crossed sides, sand filled in the accent so the monochrome layer recolours it",
"daily_limits registered with accent #B8862E and the default style.BACKGROUND field",
"Invariant test: apps are told apart by glyph, so a new app may not reuse one (track-bars is the pre-existing exception)"
],
"verification": [
{
"command": "PATH=~/sdk/fvm/versions/3.47.7/bin:$PATH python3 -m python_pkg.app_icons generate --app daily_limits --android",
"result": "pass",
"evidence": "daily_limits: wrote 6 asset files; regenerated Android mipmaps; ic_launcher_background #211D1B"
},
{
"command": "phone_deploy.sh ~/src/daily-limits/app (adb install -r on 23181JEGR08034)",
"result": "pass",
"evidence": "Install Success; the APK's mipmap-xxxhdpi ic_launcher.png is byte-identical to the generated one (hourglass in #B8862E on #211D1B); confirmed by kuhy"
},
{
"command": ".venv/bin/python -m pytest -q python_pkg/app_icons --cov=python_pkg/app_icons --cov-branch",
"result": "pass",
"evidence": "47 passed; every python_pkg/app_icons module 100% line and branch"
},
{
"command": "git diff python_pkg/app_icons | grep -c '^-[^-]'",
"result": "pass",
"evidence": "0 removed lines: renderer and other registry entries untouched, so other apps' icons are byte-identical"
}
],
"risks": [
"`generate` runs `dart run`, which needs a Dart SDK satisfying the app's ^3.13.5; the system dart 3.13.3 fails, so put the fvm 3.47.7 SDK first on PATH"
],
"rollback": [
"git revert this commit; daily_limits disappears from the registry and the glyph library"
]
}

View File

@ -0,0 +1,48 @@
{
"intent": "workout_firebase_flow passes on the Pixel slot even when workout_app reopens into an in-progress workout instead of Home.",
"scope": [
"python_pkg/android_ui/driver.py (new AndroidUi.back)",
"python_pkg/android_ui/workout_firebase_flow.py (bounded _reach_home before tapping Settings)",
"No screen-locker source change; the SYNC/OFFLINE BACKUP reorder was a throwaway worktree edit, reverted and rebuilt"
],
"changes": [
"Root cause: the slot app resumed into the workout screen, which has no Settings gear, so tap('Settings') failed after 15 s",
"AndroidUi.back() sends KEYCODE_BACK (4) to the driver's own display",
"run_flow first presses BACK up to MAX_BACKS=3 times until Home's 'Settings' gear is on screen; if it never appears, tap('Settings') still fails naming the query"
],
"verification": [
{
"command": "pytest python_pkg/android_ui/tests --cov=python_pkg.android_ui --cov-branch",
"result": "pass",
"evidence": "143 passed, 100.00% branch coverage; 3 new tests were red first (no back(), no MAX_BACKS)"
},
{
"command": "workout_firebase_flow --serial 23181JEGR08034 --display self --account <linked account> (slot com.kuhy.slot1 v37, current layout, app reopened mid-workout)",
"result": "pass",
"evidence": "workout-firebase-flow: connected, exit 0 (the other account was rejected by the app as the wrong uid, flow timed out exit 1 as designed)"
},
{
"command": "same flow on slot v38 with SYNC and OFFLINE BACKUP swapped in settings_screen.dart",
"result": "pass",
"evidence": "dump shows OFFLINE BACKUP at y=1452 above SYNC at y=2178; flow: already connected, exit 0"
},
{
"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'"
},
{
"command": "git checkout settings_screen.dart, rebuild slot v39, rerun flow",
"result": "pass",
"evidence": "already connected, exit 0; screen-locker worktree removed, slot released, com.kuhy.workout_app untouched"
}
],
"risks": [
"BACK on an in-progress workout leaves that screen; workout_screen.dart allows the pop outside lock mode and the state persists (the slot reopened into it)",
"An unexpected route deeper than 3 levels still fails, naming 'Settings'"
],
"rollback": [
"git revert this commit",
"Rerun pytest python_pkg/android_ui/tests"
]
}

View File

@ -191,6 +191,11 @@ class AndroidUi(ScrollMixin, TextEntryMixin):
time.sleep(self._settle)
return element
def back(self) -> None:
"""Press BACK on this driver's display (Flutter pops the top route)."""
self._input("keyevent", "4")
time.sleep(self._settle)
def type_into(
self,
query: str,

View File

@ -159,6 +159,10 @@ class TestTap:
]
assert keyevents, "expected the keyboard to be dismissed first"
def test_back_sends_keycode_back_to_its_display(self, ui: Harness) -> None:
ui.ui.back()
assert ("shell", "input", "-d", "0", "keyevent", "4") in ui.device.calls
def test_hint_names_an_empty_material_field() -> None:
"""A Flutter/Material field publishes its label only as ``hint``.

View File

@ -68,6 +68,22 @@ class TestFlow:
assert taps == [flow.SETTINGS, flow.SYNC_ROW, flow.SIGN_IN]
ui.scroll_to.assert_called_once_with(flow.SYNC_ROW)
def test_backs_out_of_a_workout_to_home_before_settings(self) -> None:
# The app reopens into an in-progress workout, which has no gear.
ui = _ui(CONNECTED)
ui.find_all.side_effect = [[], [], [_el(desc="Settings")]]
flow.run_flow(ui, account=None, timeout=5)
assert ui.back.call_count == 2
ui.find_all.assert_called_with(flow.SETTINGS, exact=True)
def test_gives_up_backing_out_and_lets_the_tap_name_settings(self) -> None:
ui = _ui(CONNECTED)
ui.find_all.return_value = []
ui.tap.side_effect = ElementNotFoundError("no element matches 'Settings'")
with pytest.raises(ElementNotFoundError, match="Settings"):
flow.run_flow(ui, account=None, timeout=5)
assert ui.back.call_count == flow.MAX_BACKS
def test_already_connected_taps_nothing_on_the_sync_screen(self) -> None:
ui = _ui(CONNECTED)
assert flow.run_flow(ui, account=None, timeout=5) == "already connected"

View File

@ -4,11 +4,11 @@
[--display self] [--account EMAIL]
python3 -m python_pkg.android_ui.workout_firebase_flow --serial ... --negative
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
does, and then the run fails naming it.
[BACK to Home] -> Settings (gear semanticLabel) -> 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 does, and then the run fails naming it.
Exit codes: 0 connected (or already was), 1 an element was missing or
ambiguous (stderr names the query), 4 bad device/display/lease, 6 a screen
@ -53,6 +53,9 @@ EXIT_ELEMENT = 1
EXIT_TARGET = 4
EXIT_HAND_OVER = 6
_POLL_S = 1.0
# Routes stacked over Home when the app reopens (an in-progress workout, a
# summary); more than this means the app is somewhere unexpected.
MAX_BACKS = 3
_NEGATIVE_TIMEOUT_S = 3.0
@ -83,8 +86,17 @@ def _chooser_up(screen: list[UiElement]) -> bool:
return False
def _reach_home(ui: AndroidUi) -> None:
"""Pop routes until Home's gear shows; the app may reopen mid-workout."""
for _ in range(MAX_BACKS):
if ui.find_all(SETTINGS, exact=True):
return
ui.back()
def run_flow(ui: AndroidUi, *, account: str | None, timeout: float) -> str:
"""Run the flow from the home screen; return how it ended."""
"""Run the flow from wherever the app is; return how it ended."""
_reach_home(ui)
ui.tap(SETTINGS, exact=True)
# Below the fold on a phone; scrolling to it is what makes the run survive
# a section reorder without a coordinate.