Compare commits

...

2 Commits

Author SHA1 Message Date
7821712571 NEXT_SESSION_PROMPT.md: record status_page_state.dart split + midnight-shutdown split plan
Some checks are pending
Pre-commit checks / pre-commit (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Marks focus_owner/lib/status_page_state.dart done (commit 47e05d1),
confirms focus_owner is live so it's off the dead-code-candidate list,
documents the heredoc-generated-script trap in
setup_midnight_shutdown.sh (breaks extract_shell_functions.py and
verify_shell_split.sh as-is, needs a hash-the-emitted-script
verification plan instead), and logs a dart_format_changed.sh path
bug hit this session (cd's into repo before git status, whose paths
are worktree-root-relative -- silently formats nothing).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-18 23:44:36 +02:00
47e05d1dca focus_owner: split status_page_state.dart under the 250-line cap
Extracts the two AlertDialog builders and the build() body-selection
logic into a new status_page_dialogs.dart part file, following the
same part-of-main.dart split pattern status_body.dart already used.
Pure extraction, no behavior change -- verified with dart analyze and
the full flutter test suite (94/94 passing).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-18 23:38:09 +02:00
5 changed files with 217 additions and 80 deletions

View File

@ -112,9 +112,22 @@ baseline.
## Phase 1: Drive the 250-line cap to zero
**Status as of 2026-08-18: 11 files over cap.** Re-run
`bash meta/scripts/check_file_length.sh --all` at the start of every session
in this phase — the exact list drifts as other work touches these files.
**Status as of 2026-08-18 (session 2): 10 files over cap, one done this
session.** Re-run `bash meta/scripts/check_file_length.sh --all` at the start
of every session in this phase — the exact list drifts as other work touches
these files.
`focus_owner/lib/status_page_state.dart` (307 lines) is DONE — split into
`status_page_state.dart` (248) + a new `status_page_dialogs.dart` (103),
commit `47e05d1`. Pure verbatim extraction of the two `AlertDialog` builders
and the `build()` body-selection logic into a new `part of 'main.dart'` file,
following the exact pattern `status_body.dart` already established.
Verified: `dart analyze lib/` clean, full `flutter test` 94/94 passing (no
new tests needed — existing widget tests already drive both dialogs through
the rendered UI). `focus_owner` was confirmed **live and enforcing** this
session (`focus_owner/README.md`: "Live and enforcing... provisioned as
device owner") — do not treat any `focus_owner` file on this list as a
dead-code candidate without a much stronger signal than "it's long."
```
1734 linux_configuration/scripts/periodic_background/digital_wellbeing/setup_midnight_shutdown.sh
@ -127,9 +140,38 @@ in this phase — the exact list drifts as other work touches these files.
564 focus_owner/android/app/src/main/kotlin/com/kuhy/focus_owner/EnforcementRunner.kt
485 linux_configuration/scripts/periodic_background/digital_wellbeing/install_leechblock.sh
415 focus_owner/android/app/src/main/kotlin/com/kuhy/focus_owner/DevicePolicyBridge.kt
307 focus_owner/lib/status_page_state.dart
```
**`setup_midnight_shutdown.sh` needs a non-standard split plan, read this
before touching it:** its 39 top-level-looking functions are NOT all real —
several (`log`, `now_epoch`/`current_epoch`, `cmd_add`/`cmd_list`/`cmd_remove`,
`require_root`, etc.) are duplicated because the outer script generates
_inner_ standalone scripts via heredocs (`create_shutdown_check_script`,
`create_override_manager_script`, `install_monitor_service`) that get written
to `/usr/local/bin/`. `extract_shell_functions.py` and `verify_shell_split.sh`
both assume real top-level functions and will mishandle a heredoc body.
The plan that will work: extract only the genuine outer orchestration
functions normally, treat each `create_*_script` heredoc as one atomic unit
that moves whole (never split its interior), and verify by hashing the
_emitted_ `/usr/local/bin/*` script content before and after the split
(`sha256sum` on a rendered-heredoc temp file), not just by running
`verify_shell_split.sh` on the outer file. This file also belongs on the
live-deployment-trap list below (writes to `/etc/shutdown-schedule.conf`
with `chattr +i`, integrates with guard-lib) — treat it with the same
handle-last caution as `install_leechblock.sh`/`block_compulsive_opening.sh`.
**Tooling bug found this session, fix opportunistically:**
`~/.claude/scripts/dart_format_changed.sh <repo>` reports "No changed Dart
files to format" even when files ARE changed, when invoked with an absolute
or relative repo path from outside that repo. Root cause: it `cd`s into
`$repo` first, then runs `git status --porcelain`, which returns paths
relative to the git _worktree root_ (`testsAndMisc/`), not relative to
`$repo` — so its `[[ -f $path ]]` check silently fails for every file. Not
fixed this session (out of scope for Phase 1); `dart format <files>` run
directly was used as a workaround. Worth a real fix (make the script `cd` to
the git toplevel, or strip the repo-relative prefix) since this affects every
future Dart split in `focus_owner`, `billsplit`, etc.
**Two of these carry a live-deployment trap, handle last or very carefully:**
`install_leechblock.sh` and `block_compulsive_opening.sh` are copied to
`/usr/local/…`, and `pacman_wrapper.sh:831` prefers the deployed copy on

View File

@ -0,0 +1,49 @@
{
"intent": "Phase 1 of NEXT_SESSION_PROMPT.md's 250-line-cap campaign: bring focus_owner/lib/status_page_state.dart (307 lines) under the cap.",
"scope": [
"focus_owner/lib/status_page_state.dart",
"focus_owner/lib/status_page_dialogs.dart (new)",
"focus_owner/lib/main.dart"
],
"changes": [
"Extracted the two AlertDialog builders (_lockVpnDialog, _releaseDialog) out of _lockVpn/_release into standalone functions in a new status_page_dialogs.dart part file",
"Extracted the build() method's body-selection if/else chain into a standalone _statusPageBody() helper in the same new part file",
"Registered the new part file in main.dart alongside the existing status_page_state.dart and status_body.dart parts, following the exact pattern already established by that prior split",
"No behavioral change: all extracted code moved verbatim (dialog content, button labels, callback wiring, hasAccounts branching) with no logic changes"
],
"verification": [
{
"command": "bash meta/scripts/check_file_length.sh --all",
"result": "pass",
"evidence": "status_page_state.dart now 248 lines, status_page_dialogs.dart 103 lines; file count over cap dropped from 11 to 10"
},
{
"command": "dart analyze lib/",
"result": "pass",
"evidence": "No issues found!"
},
{
"command": "flutter test test/status_page_test.dart test/status_page_actions_test.dart",
"result": "pass",
"evidence": "8/8 tests passed, including the release-confirmation dialog and lock-VPN dialog paths driven through the rendered widget tree"
},
{
"command": "flutter test (full suite)",
"result": "pass",
"evidence": "94/94 tests passed, no regressions elsewhere in focus_owner"
},
{
"command": "dart format focus_owner/lib/main.dart focus_owner/lib/status_page_state.dart focus_owner/lib/status_page_dialogs.dart",
"result": "pass",
"evidence": "Formatted 3 files (0 changed) -- already correctly formatted"
}
],
"risks": [
"focus_owner has no dedicated CI workflow or coverage gate (confirmed: no .github/workflows/*focus_owner* file), so this split relies entirely on the local flutter test run performed this session, not an automated gate",
"No new tests were added since this is a pure verbatim extraction already covered by existing widget tests that drive the dialogs through the rendered UI -- if that coverage assumption is wrong, a future regression in these dialogs would not be caught by unit tests alone"
],
"rollback": [
"git revert this commit",
"After rollback, re-run flutter test to confirm the pre-split test count (94) still passes"
]
}

View File

@ -12,6 +12,8 @@ import 'package:focus_owner/theme.dart';
part 'status_page_state.dart';
part 'status_page_dialogs.dart';
part 'status_body.dart';
void main() => runApp(const FocusOwnerApp());

View File

@ -0,0 +1,103 @@
/// Confirmation dialogs and the body-selection helper for the StatusPage.
///
/// Split out of status_page_state.dart to keep it under the 250-line cap. A
/// `part` because these builders are library-private, same as the rest of
/// the StatusPage split.
part of 'main.dart';
/// Picks the StatusPage's body widget for the current load state.
Widget _statusPageBody({
required DevicePolicyStatus? status,
required String? error,
required FocusPolicy? focusPolicy,
required String? policyError,
required bool busy,
required Future<void> Function() onRelease,
required Future<void> Function() onRunNow,
required Future<void> Function() onSetHome,
required Future<void> Function() onLockVpn,
required bool hasHome,
required List<EnforcementRecord> log,
required VoidCallback onOpenLog,
}) {
if (error != null) {
return const _Message(text: 'Could not read state', color: kDanger);
}
if (status != null) {
return _StatusBody(
status: status,
focusPolicy: focusPolicy,
policyError: policyError,
busy: busy,
onRelease: onRelease,
onRunNow: onRunNow,
onSetHome: onSetHome,
onLockVpn: onLockVpn,
hasHome: hasHome,
log: log,
onOpenLog: onOpenLog,
);
}
return const Center(child: CircularProgressIndicator());
}
Widget _lockVpnDialog(BuildContext context) {
return AlertDialog(
backgroundColor: kSurface,
title: const Text('Lock VPN configuration?'),
content: const Text(
'The always-on VPN can no longer be turned off from Settings. '
'Releasing device owner lifts this.',
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
TextButton(
onPressed: () => Navigator.pop(context, true),
child: const Text('Lock'),
),
],
);
}
Widget _releaseDialog(BuildContext context, {required bool hasAccounts}) {
return AlertDialog(
backgroundColor: kSurface,
title: const Text('Release device owner?'),
// Deliberately concrete, and honest in both directions. "Restored only
// by a factory reset" is true but abstract, and this dialog is read in
// the moment the block is most inconvenient -- the price has to be
// legible right then, not inferred. While no account exists the price
// really is low, and overstating it there would teach the user to
// ignore the warning that matters later.
content: Text(
hasAccounts
? 'Enforcement stops. YouTube comes back.\n\n'
'Accounts exist on this device, so device owner can NEVER '
'be set again without a factory reset. That means '
're-pairing mBank, Revolut and inFakt over SMS, '
're-activating mObywatel, signing in to every account '
'again, and losing Signal history.\n\n'
'This is the way out if something is broken. It is a bad '
'trade for wanting to watch a video.'
: 'Enforcement stops and YouTube comes back.\n\n'
'No account exists yet, so device owner can be set again '
'straight afterwards without a wipe. This is the moment to '
'test the release path, before signing in.',
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
TextButton(
onPressed: () => Navigator.pop(context, true),
style: TextButton.styleFrom(foregroundColor: kDanger),
child: const Text('Release'),
),
],
);
}

View File

@ -158,24 +158,7 @@ class _StatusPageState extends State<StatusPage> {
Future<void> _lockVpn() async {
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
backgroundColor: kSurface,
title: const Text('Lock VPN configuration?'),
content: const Text(
'The always-on VPN can no longer be turned off from Settings. '
'Releasing device owner lifts this.',
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
TextButton(
onPressed: () => Navigator.pop(context, true),
child: const Text('Lock'),
),
],
),
builder: _lockVpnDialog,
);
if (confirmed != true) return;
@ -194,44 +177,10 @@ class _StatusPageState extends State<StatusPage> {
}
Future<void> _release() async {
final hasAccounts = _status?.hasAccounts ?? true;
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
backgroundColor: kSurface,
title: const Text('Release device owner?'),
// Deliberately concrete, and honest in both directions. "Restored only
// by a factory reset" is true but abstract, and this dialog is read in
// the moment the block is most inconvenient -- the price has to be
// legible right then, not inferred. While no account exists the price
// really is low, and overstating it there would teach the user to
// ignore the warning that matters later.
content: Text(
_status?.hasAccounts ?? true
? 'Enforcement stops. YouTube comes back.\n\n'
'Accounts exist on this device, so device owner can NEVER '
'be set again without a factory reset. That means '
're-pairing mBank, Revolut and inFakt over SMS, '
're-activating mObywatel, signing in to every account '
'again, and losing Signal history.\n\n'
'This is the way out if something is broken. It is a bad '
'trade for wanting to watch a video.'
: 'Enforcement stops and YouTube comes back.\n\n'
'No account exists yet, so device owner can be set again '
'straight afterwards without a wipe. This is the moment to '
'test the release path, before signing in.',
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
TextButton(
onPressed: () => Navigator.pop(context, true),
style: TextButton.styleFrom(foregroundColor: kDanger),
child: const Text('Release'),
),
],
),
builder: (context) => _releaseDialog(context, hasAccounts: hasAccounts),
);
if (confirmed != true) return;
@ -259,28 +208,20 @@ class _StatusPageState extends State<StatusPage> {
@override
Widget build(BuildContext context) {
final status = _status;
final error = _error;
final Widget body;
if (error != null) {
body = const _Message(text: 'Could not read state', color: kDanger);
} else if (status != null) {
body = _StatusBody(
status: status,
focusPolicy: _focusPolicy,
policyError: _policyError,
busy: _busy,
onRelease: _release,
onRunNow: _runNow,
onSetHome: _setHome,
onLockVpn: _lockVpn,
hasHome: _hasHome,
log: _log,
onOpenLog: _openLog,
);
} else {
body = const Center(child: CircularProgressIndicator());
}
final body = _statusPageBody(
status: _status,
error: _error,
focusPolicy: _focusPolicy,
policyError: _policyError,
busy: _busy,
onRelease: _release,
onRunNow: _runNow,
onSetHome: _setHome,
onLockVpn: _lockVpn,
hasHome: _hasHome,
log: _log,
onOpenLog: _openLog,
);
return Scaffold(
appBar: AppBar(