From 28327d322afbddfcde86db3aa230ef30d2e511c1 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Wed, 11 Nov 2026 14:27:52 +0100 Subject: [PATCH] =?UTF-8?q?Make=20wake-alarm=20text-free=20(textgate-rewor?= =?UTF-8?q?k)=20=E2=80=94=20res=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Todo: 364208fc --- keep.md | 38 +++++++++++ .../com/kuhy/wake_alarm_sync/AlarmService.kt | 2 +- .../com/kuhy/wake_alarm_sync/AppName.kt | 9 +++ .../com/kuhy/wake_alarm_sync/SessionNotice.kt | 2 +- phone_app/lib/main.dart | 3 +- phone_app/lib/ui/app_name.dart | 6 ++ scripts/check_textgate_keep.sh | 65 +++++++++++++++++++ 7 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 keep.md create mode 100644 phone_app/android/app/src/main/kotlin/com/kuhy/wake_alarm_sync/AppName.kt create mode 100644 phone_app/lib/ui/app_name.dart create mode 100755 scripts/check_textgate_keep.sh diff --git a/keep.md b/keep.md new file mode 100644 index 0000000..09489fa --- /dev/null +++ b/keep.md @@ -0,0 +1,38 @@ +# Text-free keep list + +Every `textgate scan` hit that stays on purpose. `scripts/check_textgate_keep.sh` +runs the scan and fails on any hit no row below covers. Rework rationale and the +per-screen decisions: `~/data/wake-alarm_notext/keep.md` (2026-11-10 rework). + +## Scan exceptions + +First cell: a file, or a directory ending in `/`. Second cell: the exact text, +or `*` for any text. The checker parses only this table. + +| Path | Text | Reason | +|---|---|---| +| `docs/explanations/` | * | Generated by the `explain-diff` skill (`docs/explanations/index.html`). Explanation pages for the repo, not app UI; a text-free explanation defeats its purpose. | + +## Kept but not flagged by the scan + +Rows copied from the rework's keep list. The scan does not report these today; +they are listed so the next rework does not delete them. + +### OS-level labels: the app name only + +| Where | Text | Reason | +|---|---|---| +| `phone_app/lib/ui/app_name.dart` `kAppName` | `WakeAlarm` | `MaterialApp.title`: the task-switcher name, a proper noun | +| `phone_app/android/app/src/main/AndroidManifest.xml` | `android:label="WakeAlarm"` | launcher label, a proper noun | +| `phone_app/android/app/src/main/kotlin/com/kuhy/wake_alarm_sync/AppName.kt` `APP_NAME` | `WakeAlarm` | name of the ring and session notification channels | + +### Content: data the program only displays + +| Where | Content | Reason | +|---|---|---| +| `room_proof_screen.dart`, `session_tags_screen.dart` | registered NFC tag ids | authored identifiers read off the tag | +| `ring_challenge.dart` `challenge.display` | digits, operators, sequences, the reversed word | the thing you must read to dismiss; always visible | +| `home_location_screen.dart` | captured SSID, BSSIDs, coordinates | read from the radio | +| all screens | clock times, numeral dates, counts, kg, `N/M` | numbers | +| `escape_dialog.dart` | the excuse text kuhy types | typed value | +| `alarm_publisher.dart` two `publish()` failure strings | spoken labels, two distinct cue kinds | CLAUDE.md: keep both messages | diff --git a/phone_app/android/app/src/main/kotlin/com/kuhy/wake_alarm_sync/AlarmService.kt b/phone_app/android/app/src/main/kotlin/com/kuhy/wake_alarm_sync/AlarmService.kt index 78cff58..9e9ccd3 100644 --- a/phone_app/android/app/src/main/kotlin/com/kuhy/wake_alarm_sync/AlarmService.kt +++ b/phone_app/android/app/src/main/kotlin/com/kuhy/wake_alarm_sync/AlarmService.kt @@ -105,7 +105,7 @@ class AlarmService : Service() { // IMPORTANCE_HIGH is required for a full-screen intent to be honoured. val channel = NotificationChannel( CHANNEL_ID, - "WakeAlarm", + APP_NAME, NotificationManager.IMPORTANCE_HIGH, ).apply { // The service owns sound and vibration, so the channel must not add diff --git a/phone_app/android/app/src/main/kotlin/com/kuhy/wake_alarm_sync/AppName.kt b/phone_app/android/app/src/main/kotlin/com/kuhy/wake_alarm_sync/AppName.kt new file mode 100644 index 0000000..2b48400 --- /dev/null +++ b/phone_app/android/app/src/main/kotlin/com/kuhy/wake_alarm_sync/AppName.kt @@ -0,0 +1,9 @@ +package com.kuhy.wake_alarm_sync + +/** + * The app's only visible word, used as every notification channel's name. + * + * Matches `android:label` in AndroidManifest.xml and Dart's `kAppName`, so the + * notification settings name the app the way the launcher does. + */ +const val APP_NAME = "WakeAlarm" diff --git a/phone_app/android/app/src/main/kotlin/com/kuhy/wake_alarm_sync/SessionNotice.kt b/phone_app/android/app/src/main/kotlin/com/kuhy/wake_alarm_sync/SessionNotice.kt index ad38019..46feda9 100644 --- a/phone_app/android/app/src/main/kotlin/com/kuhy/wake_alarm_sync/SessionNotice.kt +++ b/phone_app/android/app/src/main/kotlin/com/kuhy/wake_alarm_sync/SessionNotice.kt @@ -50,7 +50,7 @@ object SessionNotice { .apply() val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager manager.createNotificationChannel( - NotificationChannel(CHANNEL_ID, "WakeAlarm", NotificationManager.IMPORTANCE_LOW), + NotificationChannel(CHANNEL_ID, APP_NAME, NotificationManager.IMPORTANCE_LOW), ) manager.notify(NOTIFICATION_ID, build(context, label, deadlineMillis)) } diff --git a/phone_app/lib/main.dart b/phone_app/lib/main.dart index 80d3d3e..c4b9361 100644 --- a/phone_app/lib/main.dart +++ b/phone_app/lib/main.dart @@ -7,6 +7,7 @@ import 'package:wake_alarm_sync/services/alarm_policy.dart'; import 'package:wake_alarm_sync/services/alarm_scheduler.dart'; import 'package:wake_alarm_sync/services/day_pool_refresh.dart'; import 'package:wake_alarm_sync/services/headless_ring_start.dart'; +import 'package:wake_alarm_sync/ui/app_name.dart'; import 'package:wake_alarm_sync/ui/theme.dart'; /// Route the Kotlin `AlarmActivity` hands to the engine as its initial @@ -63,7 +64,7 @@ class WakeAlarmSyncApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - title: 'Wake Alarm Sync', + title: kAppName, theme: buildAppTheme(), navigatorKey: navigatorKey, // AlarmActivity sets its initial route to kRingRoute, so the ring screen diff --git a/phone_app/lib/ui/app_name.dart b/phone_app/lib/ui/app_name.dart new file mode 100644 index 0000000..ecd0c71 --- /dev/null +++ b/phone_app/lib/ui/app_name.dart @@ -0,0 +1,6 @@ +/// The app's only visible word: the proper noun the OS task switcher shows. +/// +/// Matches `android:label` in AndroidManifest.xml and the Kotlin `APP_NAME` +/// (notification channels), so the launcher, the task switcher and the +/// notification settings all name the app the same way. +const String kAppName = 'WakeAlarm'; diff --git a/scripts/check_textgate_keep.sh b/scripts/check_textgate_keep.sh new file mode 100755 index 0000000..e5d5575 --- /dev/null +++ b/scripts/check_textgate_keep.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# ============================================================================ +# Fail if `textgate scan` reports any text item not covered by keep.md. +# +# textgate has no path exclusion and its config is a gate control, so the +# repo's deliberate exceptions live in keep.md instead. This script reads the +# "## Scan exceptions" table there (first cell: a backticked file, or a +# directory ending in "/"; second cell: the backticked exact text, or * for +# any text) and prints every scan hit no row covers. +# +# Not wired into pre-commit or CI: adding it there is a gate change. +# +# Usage: scripts/check_textgate_keep.sh (from anywhere in the repo) +# Exit: 0 all hits kept, 1 unmatched hits, 2 missing tool or keep file. +# Needs: textgate, jq. +# ============================================================================ + +set -euo pipefail + +REPO_ROOT="$(git rev-parse --show-toplevel)" +readonly REPO_ROOT +readonly KEEP_FILE="$REPO_ROOT/keep.md" +readonly SECTION="## Scan exceptions" + +die() { + echo "Error: $*" >&2 + exit 2 +} + +# Print the exception rows of keep.md as "pathtext" (empty text = any). +keep_rows() { + awk -v section="$SECTION" '/^## /{on = ($0 == section)} on && /^\| `/' "$KEEP_FILE" | + sed -E 's/^\| `([^`]+)` \| (`([^`]*)`|\*) \|.*$/\1\t\3/' +} + +main() { + command -v textgate >/dev/null || die "textgate not found on PATH" + command -v jq >/dev/null || die "jq not found on PATH" + [[ -f "$KEEP_FILE" ]] || die "keep list not found at $KEEP_FILE" + + local rows scan unmatched + rows="$(keep_rows | jq -R -s 'split("\n") | map(select(length > 0) | split("\t") | {path: .[0], text: (.[1] // "")})')" + # textgate exits 1 whenever it lists any item, so the exit code alone + # cannot tell hits from a crash: require 0/1 and a JSON array. + local rc=0 + scan="$(cd "$REPO_ROOT" && textgate scan --json)" || rc=$? + ((rc <= 1)) || die "textgate scan failed (exit $rc)" + jq -e 'type == "array"' <<<"$scan" >/dev/null || die "textgate scan did not print a JSON array" + unmatched="$(jq -r --argjson rows "$rows" ' + def covered($hit): any($rows[] as $r + | (if ($r.path | endswith("/")) then ($hit.file | startswith($r.path)) else $hit.file == $r.path end) + and ($r.text == "" or $r.text == $hit.text); .); + .[] | select(covered(.) | not) | "\(.file):\(.line) \(.text | tojson)" + ' <<<"$scan")" + + if [[ -n "$unmatched" ]]; then + echo "$unmatched" + echo "textgate keep: $(wc -l <<<"$unmatched") hit(s) not in keep.md" >&2 + exit 1 + fi + echo "textgate keep: all $(jq length <<<"$scan") hit(s) covered by keep.md" +} + +main "$@"