Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
translate ▾

Modern-Apps.git / todo / AGENTS.md

AGENTS.md8.3 KiBRenderedCodeRaw
1# AGENTS.md — todo/ (':todo')
2
3> Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `todo/` + allowed shared modules. Do not root-scan.
4
5_Install: ./install todo (dev by default)._
6- Gradle: :todo / dir: todo/
7- Package roots present: ui, data, domain, platform, sync, notifications, widget, service, intents
8- Entry files: MainActivity.kt (sole launcher; routes watches to WearMainActivity), Route.kt, Navigation.kt, TodoApplication.kt, ui/WearMainActivity.kt
9- Dialog routes: `Route` dialog destinations (list edit/delete, todo delete/move, bulk move/date, import confirm, digest time) are `DialogPage()` entries in Navigation.kt rendering stateless content from `ui/dialogs/`; sheet-nested pickers and the quick-add paste confirm remain local (see DIALOG LOCAL EXCEPTION markers in those files)
10- Deps: :library:room, :library:widgets, :library:wearlink, :library:log, Wear Compose (material + foundation)
11- Metadata: metadata_data/todo.md (present)
12- Rust: no / screenshotTest: yes
13
14## Overview
15**Purpose:** Offline task manager: lists, smart views, subtasks, priorities, timed due dates, repeats, reminders, natural-language quick add, widgets, calendar mirror, import/export, and E2EE sync via EverySync.
16**Architecture / data-flow:** `ui/` (stateless `*Screen` + binding `*Page`) → `platform/TodoViewModel` / `platform/TodoEditor` → `data/TodoRepository` over Room (`Todo`, `TodoList`, `SyncSnapshot`). Pure logic lives in `domain/` (no Android): `TodoQuery` (views/sort/groups), `QuickAddParser`, `Recurrence`, `Completion`, `Positions`, `DueDates`, `format/` (todo.txt, CSV, VTODO). `platform/TodoBackground` (started by `TodoApplication`) reacts to any data change: reminder alarms, digest, per-list channels, widgets, calendar mirror.
17**Entry points + reading order:** `Route` → `Navigation.kt` → `ui/TodoShell` → `ui/TodoListPage` → `platform/TodoViewModel` → `domain/TodoQuery` → `data/TodoRepository` → `sync/RelayTodoProvider`.
18
19## One APK, two form factors (phone + watch)
20This module is the single Todo APK for phones and watches: same
21`applicationId = "com.vayunmathur.todo"` and signing on both, as the
22WearLink handshake requires. The manifest deliberately declares no
23`android.hardware.type.watch` feature (required=true would block
24phones; required=false is disallowed for this feature), plus
25touchscreen not-required and
26`com.google.android.wearable.standalone=false`; distribution is
27sideload/F-Droid, not Play's watch channel, so the APK installs on
28phones and watches alike. `platform/FormFactor.kt`
29reads `PackageManager.FEATURE_WATCH` at runtime: `MainActivity` (the
30sole launcher entry) forwards watches to `ui/WearMainActivity` before
31any phone state loads; phones get the list UI. Phone-only work gates
32on the same signal: `TodoApplication` skips `TodoBackground` on a
33watch, and `notifications/BootReceiver` early-returns there.
34
35## Wear sync (Watch conduit client)
36**Protocol:** shared wire types live in `:library:wearlink` at `com.vayunmathur.library.wearlink.todo.WearTodoProtocol`; the golden-JSON tests in this module pin the shared code's wire format.
37- Catalog + page snapshots: conduit data items (`/todo/catalog`, `/todo/page`, phone -> watch; paginated, PAGE_SIZE tasks per page)
38- Page/sync requests: conduit messages (`/todo/request-page`, `/todo/request-sync`, watch -> phone)
39- Watch-originated ops: conduit message (`/todo/op`: SET_DONE incl. repeating-task roll-forward on the phone, SNOOZE_HOUR/SNOOZE_TOMORROW, QUICK_ADD parsed by the phone's QuickAddParser, EDIT title/due/priority, DELETE with watch-side confirmation)
40- **Transport: Watch conduit client** — phone side `sync/WearTodoSync.kt` and watch side `sync/WearLinkBridge.kt` both use `WearLinkClientNode` (Messenger to the Watch app's `watch_conduit` service, appId `todo`); this app owns no RFCOMM link and holds no Bluetooth permission for this channel, so neither entry activity prompts for Bluetooth. With the Watch app absent the node reports `NotInstalled`/`Unavailable` and the sync stays idle; the catalog and tracked pages republish on conduit `Connected` and on todo/list changes, and pending watch ops flush on `Connected`. App-lifecycle-bound (no Play services, no listener service).
41
42## Watch experience (in this module)
43- `ui/WearMainActivity` (a `WearShellActivity`) routes `ui/WearRoute` over home (the phone drawer's view index) / task pages / task detail / quick-add / edit / delete-confirm, mirroring the phone `Route` (detail routes carry the task syncId, the cross-device identity). Settings, search, sort, manual reorder, bulk selection, list/tag/section editing, recurrence and reminder-offset editing, blocked-by/estimates, and subtask creation stay on the phone; existing subtasks show and can be checked off.
44- Watch state persists in `data/WearTodoStore` (catalog, visited pages, and pending watch-originated ops as JSON in app-private files); the watch renders fully offline and an op leaves the pending queue only when a refreshed catalog/page reflects it.
45- Watch listing screenshots are the `group = "wear"` previews in `src/screenshotTest/.../ui/WearMetadataPreviews.kt`, collected by `:todo:metadata` into `metadata_data/photos/todo/wear/`; phone shots use the `phone` bucket.
46**Gotchas:**
47- Relay envelopes (`sync/RelayEnvelopes.kt`) mirror everysync's `RemoteTodo` / `RemoteTodoList` field-for-field. Never rename a key; new fields need defaults (encodeDefaults is off, so hashes of existing envelopes stay identical). Update both sides together.
48- Lists sync on their own `todolists:<vault>` channel so pre-list builds never see them as tasks.
49- All-day `dueAt` is **local** midnight. The Material date picker speaks UTC midnight — go through `DueDates.fromPickerMillis` / `toPickerMillis` (or `ui/TodoDatePickerDialog`).
50- Editor writes run on `TodoRepository.appScope` and flush on close; a new task is only inserted once it has a title (`platform/TodoEditor`).
51- Completing a repeating task rolls the same row forward (`domain/Completion`), it does not create a copy.
52- `exportSchema = true`: bump the DB version and commit `schemas/…/<n>.json` with every schema change; extend `TodoMigrationTest`.
53- `settings.gradle.kts` lists `:todo` twice — harmless Gradle quirk.
54
55## Key files
56### Root
57- MainActivity.kt (intent capture → `platform/IntentRouter`), Navigation.kt, Route.kt, TodoApplication.kt
58### data/
59- Todo.kt, TodoList.kt, TodoDatabase.kt (DAOs), TodoMigrations.kt, TodoRepository.kt, TodoSettings.kt (DataStore)
60### domain/
61- TodoQuery.kt, TodoView.kt, QuickAddParser.kt + QuickAddWords.kt, Recurrence.kt, Completion.kt, DueDates.kt, DueBuckets.kt, Positions.kt, Reminders.kt, format/
62### platform/
63- TodoViewModel.kt, TodoEditor.kt, TodoListUiContract.kt, TodoEditorUiContract.kt, TodoBackground.kt, IntentRouter.kt, TodoDataTransfer.kt, AppBackupAgent.kt
64### ui/dialogs/
65- ListPickerDialog.kt, ListSectionPickerDialog.kt, ListEditDialog.kt, TodoDatePickerDialog.kt, TodoTimePickerDialog.kt, DeleteTodoDialog.kt, DeleteListDialog.kt, ImportConfirmDialog.kt (stateless dialog content for the dialog routes)
66### sync/
67- RelayTodoProvider.kt, RelayEnvelopes.kt, CalendarMirror.kt, WearTodoSync.kt (phone conduit client node; catalog/page publish, watch-state receive, page/sync requests and watch-op application; wire protocol `com.vayunmathur.library.wearlink.todo.WearTodoProtocol` in `:library:wearlink`), WearLinkBridge.kt (watch conduit client node; catalog/page receive into the store, watch-state publish, pending-op flush, page/sync requests)
68### Watch experience (ui/ + data/)
69- ui/WearMainActivity.kt — watch entry (WearShellActivity)
70- ui/WearRoute.kt, WearTodoHomeScreen.kt, WearTodoPageScreen.kt, WearTodoTaskScreen.kt, WearTodoQuickAddScreen.kt, WearTodoEditScreen.kt, WearTodoConfirmDeleteScreen.kt
71- data/WearTodoStore.kt — watch cache (catalog, pages, pending ops)
72- platform/FormFactor.kt — watch detection (`FEATURE_WATCH`)
73### notifications/ widget/ service/ intents/
74- ReminderScheduler, ReminderReceiver, ReminderActionReceiver, BootReceiver, DigestScheduler; TodayWidget, QuickAddWidget; QuickAddTileService; Get/Insert/CompleteTodoIntent (openassistant tools)
75
76## Verify (this module only)
77```
78./gradlew :todo:compileDevKotlin :todo:testDevUnitTest :todo:lint
79./gradlew checkMetadata
80./gradlew :todo:metadata # regenerate listing screenshots after UI changes
81```
82Relay changes: also `./gradlew :everysync:testDevUnitTest`.