Repository navigation
Conversation
Without a setContentIntent, tapping an activity-time alert notification did nothing. Add a PendingIntent that brings MainActivity to the front (or starts it), opening the AW dashboard/activity view. BackgroundService already had this pattern for the foreground-service notification; NotifyWorker's category-alert notifications were missing it. Fixes: ActivityWatch#224
Greptile SummaryThe PR makes activity-time alert notifications open
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the distinct request code fixes the previously reported PendingIntent collision. Important Files Changed
Reviews (2): Last reviewed commit: "fix(notify): use a distinct PendingInten..." | Re-trigger Greptile |
|
CI-green and mergeable — waiting only on a maintainer click. This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted. |
BackgroundService's foreground notification already registers request code 0 for a MainActivity PendingIntent with no launch flags. PendingIntent identity is (requestCode, Intent.filterEquals) — extras and launch flags are not part of it, and FLAG_UPDATE_CURRENT replaces only extras. Reusing code 0 therefore resolved to that existing PendingIntent and silently dropped FLAG_ACTIVITY_CLEAR_TOP, so tapping an alert could stack a second MainActivity instead of bringing the existing one forward. Use request code 1 (0 and 2 are taken by BackgroundService and the widget) and name the collision in a comment so it does not regress.
|
Correction to my 02:48 comment: this was not "waiting only on a maintainer click" — an unaddressed Greptile P1 had been sitting on it for 4 days. My earlier comment read the green CI and mergeable state and skipped the open review thread. Apologies for the noise. The finding was real. Fixed in 64c933d: request code Re-running CI now — will confirm green before this is actually ready. |
|
CI green on 64c933d — confirming as promised:
Greptile thread resolved. No open review threads remain. Now genuinely ready for a maintainer merge — the bot is pull-only here. |
|
@greptileai review |
* fix(notify): open the activity view when an alert is tapped #225 already attached a MainActivity PendingIntent, so the notification no longer did nothing — but the extra was missing, so a tap still landed on dashboard home instead of the Activity drawer destination (/#/activity/unknown/). Pass EXTRA_OPEN_ACTIVITY_VIEW, honor it on cold start and onNewIntent (SINGLE_TOP), and share the URL with the drawer item so the two cannot drift. * fix(notify): honor activity-view extra after process death If the process was killed, onCreate restores the previous fragment and used to return before reading EXTRA_OPEN_ACTIVITY_VIEW, so a notification tap could land on dashboard home. Replace the restored fragment when the extra is set, and consume it so a later rotation does not reload the WebView. * fix(notify): defer activity-view replace until onResume onNewIntent runs while MainActivity is still stopped, after onSaveInstanceState. commit() there throws IllegalStateException when the user taps a notification on a backgrounded app. Stash the intent and replace the fragment in onResume, which is also the process-death restore path. * fix(notify): handle taps while activity is resumed
Problem
Tapping an activity-time alert notification ("Time spent: Work 1h 30m") did nothing. The
NotifyWorker.sendNotification()method built notifications without asetContentIntent, which is the Android API for wiring up a tap action.Fix
Add a
PendingIntentthat opensMainActivity— the AW dashboard/activity view — when the notification is tapped. UsesFLAG_ACTIVITY_CLEAR_TOPso an already-running instance is brought to the front rather than starting a new one.BackgroundServicealready had this pattern for the foreground-service notification (line 207);NotifyWorkerwas missing it.Change
private fun sendNotification(alert: CategoryAlert, ...) { + val openIntent = Intent(applicationContext, MainActivity::class.java).apply { + flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP + } + val pendingIntent = PendingIntent.getActivity( + applicationContext, 0, openIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE, + ) val notification = NotificationCompat.Builder(applicationContext, CHANNEL_ID) ... .setAutoCancel(true) + .setContentIntent(pendingIntent) .build() }Fixes #224