AGENTS.md — todo/ (':todo')
Scoped supplement. Global rules in root AGENTS.md apply. Stay inside todo/ + allowed shared modules. Do not root-scan.
Install: ./install todo (dev by default).
- Gradle: :todo / dir: todo/
- Package roots present: ui, data, domain, platform, sync, notifications, widget, service, intents
- Entry files: MainActivity.kt (sole launcher; routes watches to WearMainActivity), Route.kt, Navigation.kt, TodoApplication.kt, ui/WearMainActivity.kt
- Dialog routes:
Routedialog destinations (list edit/delete, todo delete/move, bulk move/date, import confirm, digest time) areDialogPage()entries in Navigation.kt rendering stateless content fromui/dialogs/; sheet-nested pickers and the quick-add paste confirm remain local (see DIALOG LOCAL EXCEPTION markers in those files) - Deps: :library:room, :library:widgets, :library:wearlink, :library:log, Wear Compose (material + foundation)
- Metadata: metadata_data/todo.md (present)
- Rust: no / screenshotTest: yes
Overview
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. 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. Entry points + reading order: Route → Navigation.kt → ui/TodoShell → ui/TodoListPage → platform/TodoViewModel → domain/TodoQuery → data/TodoRepository → sync/RelayTodoProvider.
One APK, two form factors (phone + watch)
This module is the single Todo APK for phones and watches: same applicationId = "com.vayunmathur.todo" and signing on both, as the WearLink handshake requires. The manifest deliberately declares no android.hardware.type.watch feature (required=true would block phones; required=false is disallowed for this feature), plus touchscreen not-required and com.google.android.wearable.standalone=false; distribution is sideload/F-Droid, not Play's watch channel, so the APK installs on phones and watches alike. platform/FormFactor.kt reads PackageManager.FEATURE_WATCH at runtime: MainActivity (the sole launcher entry) forwards watches to ui/WearMainActivity before any phone state loads; phones get the list UI. Phone-only work gates on the same signal: TodoApplication skips TodoBackground on a watch, and notifications/BootReceiver early-returns there.
Wear sync (Watch conduit client)
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.
- Catalog + page snapshots: conduit data items (
/todo/catalog,/todo/page, phone -> watch; paginated, PAGE_SIZE tasks per page) - Page/sync requests: conduit messages (
/todo/request-page,/todo/request-sync, watch -> phone) - Watch-originated ops: conduit message (
/todo/op: SETDONE incl. repeating-task roll-forward on the phone, SNOOZEHOUR/SNOOZETOMORROW, QUICKADD parsed by the phone's QuickAddParser, EDIT title/due/priority, DELETE with watch-side confirmation) - Transport: Watch conduit client — phone side
sync/WearTodoSync.ktand watch sidesync/WearLinkBridge.ktboth useWearLinkClientNode(Messenger to the Watch app'swatch_conduitservice, appIdtodo); 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 reportsNotInstalled/Unavailableand the sync stays idle; the catalog and tracked pages republish on conduitConnectedand on todo/list changes, and pending watch ops flush onConnected. App-lifecycle-bound (no Play services, no listener service).
Watch experience (in this module)
ui/WearMainActivity(aWearShellActivity) routesui/WearRouteover home (the phone drawer's view index) / task pages / task detail / quick-add / edit / delete-confirm, mirroring the phoneRoute(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.- 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. - Watch listing screenshots are the
group = "wear"previews insrc/screenshotTest/.../ui/WearMetadataPreviews.kt, collected by:todo:metadataintometadata_data/photos/todo/wear/; phone shots use thephonebucket.
Gotchas:
- Relay envelopes (
sync/RelayEnvelopes.kt) mirror everysync'sRemoteTodo/RemoteTodoListfield-for-field. Never rename a key; new fields need defaults (encodeDefaults is off, so hashes of existing envelopes stay identical). Update both sides together. - Lists sync on their own
todolists:<vault>channel so pre-list builds never see them as tasks. - All-day
dueAtis local midnight. The Material date picker speaks UTC midnight — go throughDueDates.fromPickerMillis/toPickerMillis(orui/TodoDatePickerDialog). - Editor writes run on
TodoRepository.appScopeand flush on close; a new task is only inserted once it has a title (platform/TodoEditor). - Completing a repeating task rolls the same row forward (
domain/Completion), it does not create a copy. exportSchema = true: bump the DB version and commitschemas/…/<n>.jsonwith every schema change; extendTodoMigrationTest.settings.gradle.ktslists:todotwice — harmless Gradle quirk.
Key files
Root
- MainActivity.kt (intent capture →
platform/IntentRouter), Navigation.kt, Route.kt, TodoApplication.kt
data/
- Todo.kt, TodoList.kt, TodoDatabase.kt (DAOs), TodoMigrations.kt, TodoRepository.kt, TodoSettings.kt (DataStore)
domain/
- TodoQuery.kt, TodoView.kt, QuickAddParser.kt + QuickAddWords.kt, Recurrence.kt, Completion.kt, DueDates.kt, DueBuckets.kt, Positions.kt, Reminders.kt, format/
platform/
- TodoViewModel.kt, TodoEditor.kt, TodoListUiContract.kt, TodoEditorUiContract.kt, TodoBackground.kt, IntentRouter.kt, TodoDataTransfer.kt, AppBackupAgent.kt
ui/dialogs/
- ListPickerDialog.kt, ListSectionPickerDialog.kt, ListEditDialog.kt, TodoDatePickerDialog.kt, TodoTimePickerDialog.kt, DeleteTodoDialog.kt, DeleteListDialog.kt, ImportConfirmDialog.kt (stateless dialog content for the dialog routes)
sync/
- 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.WearTodoProtocolin:library:wearlink), WearLinkBridge.kt (watch conduit client node; catalog/page receive into the store, watch-state publish, pending-op flush, page/sync requests)
Watch experience (ui/ + data/)
- ui/WearMainActivity.kt — watch entry (WearShellActivity)
- ui/WearRoute.kt, WearTodoHomeScreen.kt, WearTodoPageScreen.kt, WearTodoTaskScreen.kt, WearTodoQuickAddScreen.kt, WearTodoEditScreen.kt, WearTodoConfirmDeleteScreen.kt
- data/WearTodoStore.kt — watch cache (catalog, pages, pending ops)
- platform/FormFactor.kt — watch detection (
FEATURE_WATCH)
notifications/ widget/ service/ intents/
- ReminderScheduler, ReminderReceiver, ReminderActionReceiver, BootReceiver, DigestScheduler; TodayWidget, QuickAddWidget; QuickAddTileService; Get/Insert/CompleteTodoIntent (openassistant tools)
Verify (this module only)
./gradlew :todo:compileDevKotlin :todo:testDevUnitTest :todo:lint
./gradlew checkMetadata
./gradlew :todo:metadata # regenerate listing screenshots after UI changesRelay changes: also ./gradlew :everysync:testDevUnitTest.