mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-24 18:16:19 +01:00
Compare commits
2 Commits
4c3a135faa
...
ed9fb48c51
| Author | SHA1 | Date | |
|---|---|---|---|
| ed9fb48c51 | |||
| ce97db9e13 |
@ -128,5 +128,3 @@ N/A below with spot-checks noted instead.
|
||||
- **Primary structural finding**: introduce a shared token source (CSS custom properties in a `src/theme.css` imported by `index.css`, or a TS `theme.ts`) before doing any rule-by-rule fix — otherwise each violation below has to be independently re-fixed per `*.module.css` file, and new files will keep reintroducing the same drift (as the reversed-gradient-stop-order bug on `PuzzleResult.module.css:25` already shows).
|
||||
- Once tokens exist, Rules 9 and 18 become checkable as whole-palette rules and should be re-audited.
|
||||
- The 4-gray inconsistency (Rule 2) and the duplicated-gradient literals (Rule 4) are the same underlying fix — collapsing to a `theme.css` resolves both simultaneously.
|
||||
|
||||
REMOVE ME AFTER FINISH
|
||||
@ -1,12 +1,13 @@
|
||||
{
|
||||
"intent": "kuhy sees the active focus project in i3bar: a focus_project block renders the focus field daily-limits now writes to its cache.",
|
||||
"intent": "kuhy sees the active focus project in i3bar: a focus_project block renders the focus field daily-limits now writes to its cache. A click takes him to the work: left opens the tutor focus screen plus the work URL (focus_project.open), middle only the tutor, right daily-limits --gui.",
|
||||
"scope": [
|
||||
"linux_configuration/i3blocks/focus_project.sh, the [focus_project] stanza in linux_configuration/i3blocks/config, linux_configuration/tests/test_i3blocks_focus_project.sh",
|
||||
"Non-goal: no focus logic here (focus_project.status() decides); daily-limits owns the cache"
|
||||
],
|
||||
"changes": [
|
||||
"New block: `🎯 <name> <minutes>/<daily_minutes>`, green at the daily target, hidden with no project or a missing/stale/garbage cache; jq re-parse only on cache mtime change",
|
||||
"Stanza has signal=11 so daily-limits can refresh it with pkill -RTMIN+11 -x i3blocks"
|
||||
"Stanza has signal=11 so daily-limits can refresh it with pkill -RTMIN+11 -x i3blocks",
|
||||
"Clicks: left `python3 -m focus_project.open`, middle `--no-site`, right `daily-limits --gui`"
|
||||
],
|
||||
"verification": [
|
||||
{
|
||||
@ -18,10 +19,16 @@
|
||||
"command": "bash ~/.config/i3blocks/focus_project.sh (live cache after daily-limits.service)",
|
||||
"result": "pass",
|
||||
"evidence": "🎯 HackerRank prep 0/120, #F1FA8C"
|
||||
},
|
||||
{
|
||||
"command": "bash linux_configuration/tests/test_i3blocks_focus_project.sh",
|
||||
"result": "pass",
|
||||
"evidence": "clicks section: all checks passed (red first: left click ran '--gui')"
|
||||
}
|
||||
],
|
||||
"risks": [
|
||||
"The running i3bar loads the stanza only after its next restart; until then the poke is harmless (i3blocks 1.5 survived an unconfigured RTMIN+11)"
|
||||
"The running i3bar loads the stanza only after its next restart; until then the poke is harmless (i3blocks 1.5 survived an unconfigured RTMIN+11)",
|
||||
"A click needs focus_project >= 0.5.0 in the system python user site"
|
||||
],
|
||||
"rollback": [
|
||||
"git revert the commit and remove the symlink ~/.config/i3blocks/focus_project.sh"
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
# Live-verify phone recovery workflow (Chunk 8 of the original plan)
|
||||
|
||||
## what
|
||||
Chunks 1-7 of the plan are built and now live in `~/src/phone-focus-mode`
|
||||
(`run_phone.sh`, `lib/{adb_common,monitor,backup,restore}.sh`,
|
||||
`backup_manifest.sh`, `systemd/phone-auto-sync.*`, README). The visible
|
||||
wrapper moved: the entry point is `~/src/phone-focus-mode/run_phone.sh`. What
|
||||
is left is the one-off run against the real, rooted phone.
|
||||
|
||||
## done
|
||||
With the phone connected over ADB, from `~/src/phone-focus-mode`:
|
||||
`./run_phone.sh --help`, `monitor`, `backup` and `auto` all exit 0, `backup`
|
||||
writes under `~/phone_backups/`, and a temporary extra entry in
|
||||
`FORMAT_INDICATORS` (`backup_manifest.sh`, reverted afterwards) makes `auto`
|
||||
print the formatted-phone warning and stop without doing anything else.
|
||||
|
||||
## verify
|
||||
Needs kuhy: phone attached (`adb devices` lists it, none was attached on
|
||||
2026-11-02). Library tests already pass: `lib/tests/test_adb_common.sh`
|
||||
(10 passed) and `lib/tests/test_monitor.sh` (82 passed).
|
||||
|
||||
## read first
|
||||
- `~/src/phone-focus-mode/README.md`
|
||||
- `~/src/phone-focus-mode/CLAUDE.md`
|
||||
|
||||
REMOVE ME AFTER FINISH
|
||||
@ -16,7 +16,13 @@
|
||||
#
|
||||
# A missing, garbage or >180 s old cache hides the block: the neighbouring
|
||||
# gaming_budget block already says "⏱?" for the same cache, and old minutes
|
||||
# must never be shown. Left-click opens `daily-limits --gui`.
|
||||
# must never be shown.
|
||||
#
|
||||
# Clicks (the block says what to do, so a click goes where the work is):
|
||||
# left `python3 -m focus_project.open`: the tutor focus screen (starts the
|
||||
# focus timer if it is not running) and the project's work URL
|
||||
# middle the same with --no-site (the focus screen only)
|
||||
# right `daily-limits --gui`, the day's detail
|
||||
# ============================================================================
|
||||
|
||||
set -euo pipefail
|
||||
@ -36,9 +42,13 @@ emit() {
|
||||
|
||||
# i3blocks' PATH has no ~/.local/bin, where daily-limits' install.sh puts it.
|
||||
readonly DAILY_LIMITS_BIN=${DAILY_LIMITS_BIN:-$HOME/.local/bin/daily-limits}
|
||||
if [[ ${BLOCK_BUTTON:-0} -eq 1 && -x $DAILY_LIMITS_BIN ]]; then
|
||||
setsid -f "$DAILY_LIMITS_BIN" --gui >/dev/null 2>&1
|
||||
fi
|
||||
# The system python: focus_project is installed in its user site (install.sh).
|
||||
readonly FOCUS_OPEN_PYTHON=${FOCUS_OPEN_PYTHON:-/usr/bin/python3}
|
||||
case ${BLOCK_BUTTON:-0} in
|
||||
1) setsid -f "$FOCUS_OPEN_PYTHON" -m focus_project.open >/dev/null 2>&1 ;;
|
||||
2) setsid -f "$FOCUS_OPEN_PYTHON" -m focus_project.open --no-site >/dev/null 2>&1 ;;
|
||||
3) [[ -x $DAILY_LIMITS_BIN ]] && setsid -f "$DAILY_LIMITS_BIN" --gui >/dev/null 2>&1 ;;
|
||||
esac
|
||||
|
||||
hide() {
|
||||
emit '' '' "$YELLOW"
|
||||
|
||||
@ -93,14 +93,23 @@ printf '%s\n' "$NOW" '🎯 CACHED 1/1' '🎯 1/1' '#50FA7B' >"$RENDER"
|
||||
touch -d '+1 second' "$RENDER"
|
||||
assert_eq '🎯 CACHED 1/1' "$(line 1 "$(run_block)")" 'unchanged cache is not re-parsed'
|
||||
|
||||
printf 'Checking a click opens the GUI...\n'
|
||||
printf 'Checking the clicks...\n'
|
||||
# Stubs record their argv: the block must never open anything for real.
|
||||
printf '#!/bin/bash\necho "$*" >>"%s/clicks"\n' "$TMP_DIR" >"$TMP_DIR/dl"
|
||||
chmod +x "$TMP_DIR/dl"
|
||||
BLOCK_BUTTON=1 run_block >/dev/null
|
||||
for _ in 1 2 3 4 5 6 7 8 9 10; do
|
||||
[[ -s "$TMP_DIR/clicks" ]] && break
|
||||
sleep 0.1
|
||||
done
|
||||
assert_eq '--gui' "$(cat "$TMP_DIR/clicks" 2>/dev/null)" 'click runs daily-limits --gui'
|
||||
printf '#!/bin/bash\necho "py $*" >>"%s/clicks"\n' "$TMP_DIR" >"$TMP_DIR/py"
|
||||
chmod +x "$TMP_DIR/dl" "$TMP_DIR/py"
|
||||
click() { # BUTTON -> what the stubs recorded (empty if nothing ran)
|
||||
rm -f "$TMP_DIR/clicks"
|
||||
BLOCK_BUTTON="$1" FOCUS_OPEN_PYTHON="$TMP_DIR/py" run_block >/dev/null
|
||||
for _ in 1 2 3 4 5 6 7 8 9 10; do
|
||||
[[ -s "$TMP_DIR/clicks" ]] && break
|
||||
sleep 0.1
|
||||
done
|
||||
cat "$TMP_DIR/clicks" 2>/dev/null || true
|
||||
}
|
||||
assert_eq 'py -m focus_project.open' "$(click 1)" 'left click opens the tutor and the work site'
|
||||
assert_eq 'py -m focus_project.open --no-site' "$(click 2)" 'middle click opens only the tutor'
|
||||
assert_eq '--gui' "$(click 3)" 'right click opens daily-limits --gui'
|
||||
assert_eq '' "$(click 0)" 'no click opens nothing'
|
||||
|
||||
printf 'focus_project block: all checks passed\n'
|
||||
|
||||
41
python_pkg/android_ui/DOCS-android-ui-rationale.md
Normal file
41
python_pkg/android_ui/DOCS-android-ui-rationale.md
Normal file
@ -0,0 +1,41 @@
|
||||
# Android UI automation: rationale and Flutter pitfalls
|
||||
|
||||
## why this is not a nicety
|
||||
|
||||
Observed in one session (2026-08-10, workout_app Firebase verification):
|
||||
|
||||
- **Silent mis-taps.** A tap at `(540, 1705)` intended for the password field
|
||||
landed with the field unfocused. The typed password went nowhere. Nothing
|
||||
errored — the next screenshot just showed an empty box. A no-op and a hit are
|
||||
indistinguishable without dumping the tree and diffing.
|
||||
- **Layout shift invalidates every coordinate.** Opening the soft keyboard moved
|
||||
the email field from y=1572 to y=1319. Coordinates captured one step earlier
|
||||
were already wrong.
|
||||
- **Screenshot scaling is a manual multiply.** The harness renders 1080x2400 at
|
||||
900x2000, so every read coordinate needs `* 1.20`. One forgotten multiply is
|
||||
an off-screen tap.
|
||||
- **Screenshots are expensive.** A full-page PNG per step burns far more context
|
||||
than the equivalent element list, and can't be grepped or asserted on.
|
||||
|
||||
`uiautomator dump` already solves this and is on every device — no new
|
||||
dependency:
|
||||
|
||||
```bash
|
||||
adb shell uiautomator dump /sdcard/ui.xml
|
||||
adb pull /sdcard/ui.xml
|
||||
# -> <node text="Connect Firebase" class="android.widget.Button"
|
||||
# bounds="[32,1808][1048,1878]" .../>
|
||||
```
|
||||
|
||||
This is how the same session recovered: dumping the tree found both `EditText`
|
||||
nodes by class and gave exact centers, and the retry worked first time.
|
||||
|
||||
- **Observed 2026-08-10, must be handled:** while a Flutter `TextField` holds
|
||||
focus, the dump returns ONLY the `EditText` nodes — the rest of the tree
|
||||
(including the button you are about to tap) is missing, and it stays missing
|
||||
across retries, so a naive retry loop never converges. Worse, `KEYCODE_BACK`
|
||||
to dismiss the keyboard is treated by Flutter as a route pop: it navigated
|
||||
out of Settings and discarded the typed credentials, twice. The tool must
|
||||
unfocus without popping the route (tap dead space, or `dumpsys input_method`
|
||||
to check `mInputShown` first) and must distinguish "tree is partial" from
|
||||
"element is genuinely absent" rather than reporting a false negative.
|
||||
@ -1,126 +0,0 @@
|
||||
# Task: replace blind coordinate tapping with element-targeted Android UI automation
|
||||
|
||||
> **STATUS 2026-11-02: PARTIAL.** The CLI (`dump`/`find`/`tap`/`type`/`wait`/
|
||||
> `scroll-to`/`focus`) exists at `~/src/testsAndMisc/python_pkg/android_ui/` (see
|
||||
> its README). Remaining: (1) the optional MCP wrapper over the same driver;
|
||||
> (2) rolling it out to `~/src/todo` and `~/src/dufs-cloud/app` (other repos,
|
||||
> needs their own sessions); (3) the `## done` run on the physical Pixel 6a:
|
||||
> needs kuhy, phone not connected. Everything after this line is the original
|
||||
> brief, kept because it records WHY each guarantee exists.
|
||||
|
||||
## what
|
||||
|
||||
Every Flutter/Android app in these repos is currently driven by an agent the
|
||||
same bad way: screenshot -> read pixel positions by eye -> `adb shell input tap
|
||||
<x> <y>`. Replace that with a reusable tool that finds elements by _identity_
|
||||
(text, content-desc, resource-id) and taps their real bounds, and that can
|
||||
report what is on screen as structured text instead of an image.
|
||||
|
||||
## why this is not a nicety
|
||||
|
||||
Observed in one session (2026-08-10, workout_app Firebase verification):
|
||||
|
||||
- **Silent mis-taps.** A tap at `(540, 1705)` intended for the password field
|
||||
landed with the field unfocused. The typed password went nowhere. Nothing
|
||||
errored — the next screenshot just showed an empty box. A no-op and a hit are
|
||||
indistinguishable without dumping the tree and diffing.
|
||||
- **Layout shift invalidates every coordinate.** Opening the soft keyboard moved
|
||||
the email field from y=1572 to y=1319. Coordinates captured one step earlier
|
||||
were already wrong.
|
||||
- **Screenshot scaling is a manual multiply.** The harness renders 1080x2400 at
|
||||
900x2000, so every read coordinate needs `* 1.20`. One forgotten multiply is
|
||||
an off-screen tap.
|
||||
- **Screenshots are expensive.** A full-page PNG per step burns far more context
|
||||
than the equivalent element list, and can't be grepped or asserted on.
|
||||
|
||||
`uiautomator dump` already solves this and is on every device — no new
|
||||
dependency:
|
||||
|
||||
```bash
|
||||
adb shell uiautomator dump /sdcard/ui.xml
|
||||
adb pull /sdcard/ui.xml
|
||||
# -> <node text="Connect Firebase" class="android.widget.Button"
|
||||
# bounds="[32,1808][1048,1878]" .../>
|
||||
```
|
||||
|
||||
This is how the same session recovered: dumping the tree found both `EditText`
|
||||
nodes by class and gave exact centers, and the retry worked first time.
|
||||
|
||||
## where
|
||||
|
||||
New shared tool, not a per-repo copy. Two options, pick one:
|
||||
|
||||
- `~/src/testsAndMisc/python_pkg/android_ui/` — a CLI (`android-ui find "Connect
|
||||
Firebase"`, `android-ui tap "Connect Firebase"`, `android-ui dump`), matching
|
||||
how `app_icons` is already shared across repos.
|
||||
- An MCP server exposing the same as tools, which is what makes it available to
|
||||
the agent without shelling out. Preferred if MCP is acceptable — the user
|
||||
asked for "some tool ... (mcp?) which also translates to UI".
|
||||
|
||||
Consumers (every repo with an Android surface):
|
||||
|
||||
- `~/src/screen-locker/stronglift_replacement/workout_app`
|
||||
- `~/src/todo`
|
||||
- `~/src/dufs-cloud/app`
|
||||
- any future Flutter app (this should be part of the app scaffold)
|
||||
|
||||
## must
|
||||
|
||||
- `find(query)` -> matching elements with class, text/content-desc, bounds,
|
||||
center, and enabled/focused state. Match on text, content-desc, or
|
||||
resource-id; substring and exact.
|
||||
- `tap(query)` -> resolves the query, taps the center of the _current_ bounds
|
||||
(re-dump before every tap; never reuse a stale coordinate), and **fails
|
||||
loudly with a non-zero exit when the query matches zero or >1 elements**.
|
||||
Ambiguity must be an error, not a silent first-match.
|
||||
- `type(query, text)` -> focus the field, type, then **verify the field's text
|
||||
actually changed** and fail if not. This is the specific bug that cost this
|
||||
session a round trip.
|
||||
- `dump()` -> flat, greppable text list of visible elements. This replaces the
|
||||
screenshot for most steps.
|
||||
- Waits: `wait_for(query, timeout)` that polls the tree, so no more blind
|
||||
`sleep 14`.
|
||||
- must not: require root, an emulator, a running Flutter debug connection, or
|
||||
any change to app source. It must work against a plain release APK on a
|
||||
physical device over adb.
|
||||
- optional: `flutter drive` / integration_test as a second backend when a debug
|
||||
build IS available — richer (widget keys, no dump latency), but it cannot
|
||||
drive a release APK, so it can't be the only path.
|
||||
- optional: screenshot fallback for genuinely visual checks (theming, icon
|
||||
rendering) — where a picture is the point, not a workaround.
|
||||
|
||||
## done
|
||||
|
||||
A verification script that drives workout_app's "connect Firebase" flow
|
||||
end-to-end with **zero hardcoded pixel coordinates** in it, and:
|
||||
|
||||
- passes on the current layout;
|
||||
- still passes after the SYNC and OFFLINE BACKUP sections are reordered in
|
||||
`settings_screen.dart` (the test that coordinate-based automation fails);
|
||||
- exits non-zero, naming the query, when an element is missing.
|
||||
|
||||
## verify
|
||||
|
||||
On the physical Pixel 6a over adb, against an installed release APK — not an
|
||||
emulator and not a debug-only Flutter driver session.
|
||||
|
||||
## read first
|
||||
|
||||
- This session's working recovery: `uiautomator dump` + the bounds-parsing
|
||||
python in the screen-locker scratchpad (`ui.xml`, `ui2.xml`).
|
||||
- `~/src/screen-locker/CLAUDE.md` — "You are NOT done until you install the new
|
||||
version on the phone itself", which is why agent-driven UI is on the critical
|
||||
path for every task in this repo.
|
||||
- Note `uiautomator dump` returns an empty/partial tree while an animation is
|
||||
in flight; retry-with-backoff belongs in the tool, not in each caller.
|
||||
- **Observed 2026-08-10, must be handled:** while a Flutter `TextField` holds
|
||||
focus, the dump returns ONLY the `EditText` nodes — the rest of the tree
|
||||
(including the button you are about to tap) is missing, and it stays missing
|
||||
across retries, so a naive retry loop never converges. Worse, `KEYCODE_BACK`
|
||||
to dismiss the keyboard is treated by Flutter as a route pop: it navigated
|
||||
out of Settings and discarded the typed credentials, twice. The tool must
|
||||
unfocus without popping the route (tap dead space, or `dumpsys input_method`
|
||||
to check `mInputShown` first) and must distinguish "tree is partial" from
|
||||
"element is genuinely absent" rather than reporting a false negative.
|
||||
|
||||
REMOVE ME AFTER FINISH
|
||||
Loading…
Reference in New Issue
Block a user