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

Modern-Apps.git / todo / AGENTS.md

AGENTS.md9.3 KiBRenderedCodeRaw

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: 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)
  • 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.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.
  • Push triggers: the publish also runs on the phone Watch app's scheduled sync-trigger intent (sync/ConduitSyncTriggerReceiver, exported only under the CONDUIT signature permission, invoking WearTodoSync.triggerPush() — no UI, no prompt). Data arriving while the receiving process is dead lands in the conduit host's persistent store and replays on registration.
  • Open on phone: the watch request (/<appId>/open-on-phone conduit message; camera: OPEN_ON_PHONE op) is handled live by the sync message listener when this app is registered, and otherwise the phone conduit host broadcasts OpenOnPhoneContract.ACTION (package-addressed, CONDUIT signature permission) to sync/OpenOnPhoneReceiver, which launches the main activity as a new task — no phone process needs to be running first.

Watch experience (in this module)

  • 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.
  • 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 in src/screenshotTest/.../ui/WearMetadataPreviews.kt, collected by :todo:metadata into metadata_data/photos/todo/wear/; phone shots use the phone bucket.

Gotchas:

  • 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.
  • Lists sync on their own todolists:<vault> channel so pre-list builds never see them as tasks.
  • All-day dueAt is local midnight. The Material date picker speaks UTC midnight — go through DueDates.fromPickerMillis / toPickerMillis (or ui/TodoDatePickerDialog).
  • Editor writes run on TodoRepository.appScope and 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 commit schemas/…/<n>.json with every schema change; extend TodoMigrationTest.
  • settings.gradle.kts lists :todo twice — 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.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)

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 changes

Relay changes: also ./gradlew :everysync:testDevUnitTest.

  • Wear Tile: service/TodoTileService (a MaTileService in :library:weartiles) renders the default view's open count and top open task from WearTodoStore; the store requests a tile update on catalog/page changes, plus 15-minute freshness. Tap opens WearMainActivity.