Commit graph

16 commits

Author SHA1 Message Date
Jason Monk
4bbe3930c7 Fix #107: Wire SettingsScreen toggle + AuditHistoryViewModel for showAllMcpMessages
Follow-up to #105, which landed the backend (RoomAuditListener.onRequest,
mcp_request_entries table, NotificationSettings.showAllMcpMessages). This
wires the flag through the UI so users can actually see the extra entries.

SettingsScreen gains a SwitchRow in the Audit Notifications section. The
toggle binds to SettingsViewModel.showAllMcpMessages, which observes a new
NotificationSettingsProvider.observeSettings() Flow so toggle state reacts
to writes from either the Settings screen or the Audit tab.

AuditHistoryViewModel now takes an optional McpRequestDao and
NotificationSettingsProvider. When the toggle is off, only tool-call
entries surface (unchanged). When on, generic MCP request entries are
queried and merged with tool calls, sorted timestamp-desc within each
day group. The display type is a sealed AuditHistoryItem hierarchy with
ToolCall and Request variants so the view renders each shape correctly
(tool calls stay clickable; requests show a muted Api icon + method).

Sealed class chosen over a polymorphic AuditEntry because the two row
shapes differ meaningfully in interactivity (detail navigation vs none)
and visual treatment, and the compiler-enforced exhaustiveness prevents
missing a variant when future row types are added.

Screenshot goldens regenerated: existing Settings screens pick up the new
SwitchRow; a new 36a_audit_history_show_all_mcp_messages pair captures
the interleaved mixed view.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 06:35:37 -04:00
Jason Monk
87146cbab7 Fix #102: Outreach SYSTEM_ALERT_WINDOW opt-in + notification fallback for background launches
Android 14+ tightened background-activity-start rules: the sender of a
PendingIntent must hold BAL privilege at send() time. Rouse's
FOREGROUND_SERVICE_TYPE_DATA_SYNC does NOT grant BAL, so open_link and
launch_app silently no-op when the app is backgrounded on Pixel 10 Pro
and similar API 34+ devices.

This change adds a two-part fix:

1. SYSTEM_ALERT_WINDOW opt-in in the Outreach setup screen. When the user
   enables it and grants the OS permission, the PendingIntent path keeps
   working as before. The new SwitchRow only appears on API 34+
   (`directLaunchApplicable`); older devices don't need the workaround.

2. Tap-to-launch notification fallback when the opt-in is off or denied.
   A new LaunchRequestNotifier in :notifications posts a notification
   whose tap fires the PendingIntent — notification-tap launches bypass
   BAL restrictions. The channel `rouse_outreach_launch` defaults to
   IMPORTANCE_DEFAULT so it shows in the shade without heads-up.

OutreachMcpProvider now takes a `canLaunchDirectly` predicate and an
optional `LaunchRequestNotifierApi`. OutreachIntegration wires both from
the IntegrationSettingsStore toggle and the overlay permission check,
so the decision is re-evaluated on every tool call.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 22:59:03 -04:00
Jason Monk
e9a7ff582f Fix #105: Audit all MCP JSON-RPC methods, not just tool calls
Previously, only `tools/call` invocations were surfaced to the audit
listener, so a connected client could enumerate the full tool menu
(`tools/list`, `resources/read`, etc.) without leaving any user-visible
trace.

Changes:
- Extend `AuditListener` with a generic `onRequest(event: McpRequestEvent)`
  that fires for every JSON-RPC method. `onToolCall` remains the
  specialized path for `tools/call` so the existing tool-call UI stays
  intact.
- `McpRouting.emitAuditEvent` now fires `onRequest` for every dispatched
  method, and additionally fires `onToolCall` for `tools/call` (helpers
  split for detekt complexity).
- Add Room `McpRequestEntry` entity + `McpRequestDao` parallel to the
  existing `AuditEntry`. DB version 2 -> 3 with a migration that creates
  the new `mcp_request_entries` table without touching existing data.
- `RoomAuditListener` accepts an optional `McpRequestDao` and persists
  every request when supplied, encrypting `paramsJson` at rest via the
  existing `FieldEncryptor` (covers `prompts/get` / `resources/read`
  which may carry user data).
- `NotificationSettingsProvider` + DataStore gain
  `showAllMcpMessages` (default false) so the UI can later gate
  visibility behind a user opt-in.

Tests:
- `McpProtocolTest`: `onRequest` fires for every method; `tools/call`
  fires both callbacks; params/duration/resultBytes captured;
  onToolCall does not fire for non-tool methods.
- `RoomAuditListenerTest`: `onRequest` persists to the request DAO;
  is a no-op when the DAO is absent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 22:51:13 -04:00
Jason Monk
2e9eee6908 Fix #103: Replace status bar icon PNGs with vector + alpha gradient
Regenerate ic_stat_rouse as a vector drawable (24dp viewport) with a
solid circle path and vertical alpha gradient (40% -> 100% opacity).
The alpha gradient survives Android's status-bar tinting (which
flattens color gradients) and evokes the halftone-density feel of the
brand icon at notification-shade size.

Deletes five PNG density variants in favor of the single vector — the
previous PNG conversion from #55 quantized the halftone dot pattern
into an unrecognizable silhouette at 24dp.

No code changes: AuthRequestNotifier, SessionSummaryPoster,
NotificationAdapter, and ForegroundNotification continue to reference
ApiR.drawable.ic_stat_rouse, which now resolves to the vector.

Launcher monochrome variant (for Android 13+ themed icons) deferred
as a follow-up — requires a matching foreground silhouette asset.
2026-04-13 22:08:50 -04:00
Jason Monk
b86fea6e45 Fix #69: Move notification mode to global onboarding
Adds a one-time NotificationPreferences step between the Welcome screen
and Home so users pick their audit notification mode (Summary / Each
usage / Suppress) once during onboarding rather than being re-prompted
in every per-integration setup. The setting remains editable from the
global Settings screen, and both surfaces now read/write through a
shared NotificationSettingsProvider backed by DataStore.

Per-integration setup screens (Notification, Outreach, Usage, Health
Connect) never surfaced the mode in the first place, so no UI removal
is required there — they keep their integration-specific options only.

- Adds NotificationSettingsProvider.setPostSessionMode() and implements
  persistence in DataStoreNotificationSettingsProvider.
- Wires SettingsViewModel.setPostSessionMode to actually persist (was a
  no-op TODO).
- Adds NotificationPreferencesViewModel seeded from the provider so the
  previously-chosen option is pre-selected if the screen is revisited.
- Adds Routes.NOTIFICATION_PREFERENCES as an onboarding route; Welcome
  "Get Started" now navigates there, and Continue on the preferences
  screen kicks off relay registration before popping to HOME.
- Covers new flow with ViewModel tests, SettingsViewModel persistence
  tests, and BackStack/NavigationBarVisibility tests for the new route.

Closes #69.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 12:53:30 -04:00
Jason Monk
304e40a8d7 Fix #18: Update Gradle wrapper and dependencies to latest stable
- Gradle: 8.12 -> 8.14
- AGP: 8.10.0 -> 8.13.2
- Compose BOM: 2025.02.00 -> 2026.03.00
- Firebase BOM: 33.10.0 -> 34.12.0 (migrate -ktx to main modules)
- Ktor: 3.1.3 -> 3.4.1
- Activity/Activity-Compose: 1.10.1 -> 1.12.4
- Lifecycle: 2.9.0 -> 2.10.0
- Navigation Compose: 2.8.9 -> 2.9.6
- Room: 2.7.1 -> 2.8.4
- WorkManager: 2.10.0 -> 2.11.2
- Koin: 4.0.0 -> 4.1.1
- DataStore: 1.1.1 -> 1.2.1
- OkHttp: 4.12.0 -> 5.3.0
- kotlinx-serialization-json: 1.9.0 -> 1.11.0
- kotlinx-io: 0.7.0 -> 0.9.0
- Health Connect: 1.1.0-alpha12 -> 1.1.0 (stable)
- Roborazzi: 1.36.0 -> 1.58.0
- Robolectric: 4.14.1 -> 4.16.1
- MockK: 1.13.16 -> 1.14.9
- JUnit Jupiter: 5.11.4 -> 5.13.4
- ktlint plugin: 12.2.0 -> 14.2.0
- detekt: 1.23.7 -> 1.23.8
- Splashscreen: 1.0.1 -> 1.2.0
- AppCompat: 1.7.0 -> 1.7.1
- Acme4j: 3.5.0 -> 3.5.1
- Google Services: 4.4.2 -> 4.4.4
- compileSdk: 35 -> 36

Also runs ktlintFormat to fix new class-signature rule violations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 17:36:46 -04:00
Jason Monk
bfba41c4a4 Fix #55: Convert notification icon to PNG for proper rendering
Vector drawable notification icons can render incorrectly in the
notification tray. Replace with density-specific PNGs (mdpi through
xxxhdpi) generated from the same sun-rising pattern, white on
transparent for proper Android tinting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 15:11:22 -04:00
Jason Monk
1c47ace4c2 Fix #47: Move shared icon to :api module
Move ic_stat_rouse drawable from :notifications to :api so that
:outreach can reference it without depending on :notifications.
Replace :notifications dependency with :api in outreach/build.gradle.kts.
Add :api dependency to :work for the same icon reference.
Update all R.drawable.ic_stat_rouse references to use ApiR import alias
in notifications module sources (required by nonTransitiveRClass=true).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 18:44:55 -04:00
Jason Monk
3ce208e232 Lower minSdk from 29 to 24 to support ~98% of active Android devices
- Enable core library desugaring for java.time and java.util.Base64 usage
  in app, core:mcp, health, and notifications modules
- Guard NotificationChannel creation (API 26+) in NotificationChannels
  and OutreachMcpProvider
- Guard FOREGROUND_SERVICE_TYPE_DATA_SYNC (API 29+) in
  TunnelForegroundService, fall back to type-less startForeground
- Use ContextCompat.startForegroundService() in FcmReceiver and
  TestWakeReceiver for pre-API-26 compatibility
- Guard Health Connect availability check for API 28+ in
  HealthConnectIntegration
- Add tools:overrideLibrary for Health Connect in health manifest
- Pin Robolectric to SDK 33 in outreach, work, and notifications test
  resources to match app module

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 12:15:09 -04:00
Jason Monk
6fe84536a8 Make dashboard reactive so integration and audit state updates without navigation
The dashboard was stale because it used a manual refreshTrigger instead of
reactive data sources. Now IntegrationStateStore exposes observeChanges()
and AuditDao exposes observeRecent() — both Flows that the ViewModel combines
so the UI updates immediately when integrations are toggled or new audit
entries arrive.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 19:47:58 -04:00
Jason Monk
44670a6696 Remove stale mcp-core/ and mcp-health/ directories, fix conflict markers in health build files 2026-04-05 12:42:38 -04:00
Jason Monk
1b357a3dc5 Add real Health Connect MCP tools: get_steps, get_heart_rate, get_sleep 2026-04-05 11:32:55 -04:00
Jason Monk
45c39f36ac Fix conflict marker in api/build.gradle.kts from T-16 merge 2026-04-05 10:01:32 -04:00
Jason Monk
535fb2e430 Merge T-16: Tunnel + relay integration tests with mock relay server 2026-04-05 10:00:46 -04:00
Jason Monk
78f0fc65d3 Define McpIntegration, IntegrationStateStore, and IntegrationState contracts
Implement the :api module provider contract (T-6):
- McpIntegration interface for integration modules to implement
- IntegrationStateStore interface for user enable/disable persistence
- IntegrationState enum with deriveIntegrationState() derivation function
- NotificationSettingsProvider and NotificationSettings for notification model
- Tests for state derivation logic and state store contract

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 07:31:56 -04:00
Jason Monk
65d71fba10 Restructure Gradle modules: flat layout to nested architecture
Rename modules to match target architecture:
- mcp-core/ -> core/mcp/ (MCP session, providers, audit)
- tunnel/ -> core/tunnel/ (mux protocol, TLS, CertificateStore)
- mcp-health/ -> health/ (Health Connect integration)

Create new empty modules:
- api/ (integration contract layer, depends on core:mcp)
- notifications/ (notification state machine + audit persistence)
- work/ (foreground service, FCM, WorkManager)

Update all module references in settings.gradle.kts, app/build.gradle.kts,
health/build.gradle.kts. Update .claude/CLAUDE.md with Java 21 and new
module paths. Fix .gitignore to cover all build/ directories.

Verified: ./gradlew assemble, :core:mcp:testDebugUnitTest, ktlintCheck
all pass with JAVA_HOME=/usr/lib/jvm/java-21-openjdk.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 07:18:03 -04:00