Skip to content

feat(app): open the file or the task when a notification is clicked - #533

Merged
linroid merged 1 commit into
mainfrom
feat/notification-click
Oct 13, 2026
Merged

linroid merged 1 commit into
mainfrom
feat/notification-click

Conversation

@linroid

@linroid linroid commented Oct 13, 2026

Copy link
Copy Markdown
Owner

What

Clicking a notification now always leads somewhere useful:

  • Finished download saved on this device → opens the file. If the file is gone or won't open, it shows the task in Ketch instead.
  • Everything else → opens Ketch on the task (switching device first). Summaries ("3 downloads finished", "All finished") open that device's Finished tab; message notifications (e.g. Discover asking for an OK) open the message.

Per platform

  • Desktop — clicks previously did nothing.
    • macOS: new MacNotifications posts through NSUserNotificationCenter with its own delegate (via JNA, like MacDock) that reports clicks by notification name. Only works in an app bundle; from a build directory it falls back to AWT's tray notifications, which still ignore clicks.
    • Windows/Linux with a tray: AWT reports a balloon click as the tray icon's action. TrayClicks tells the two apart because only icon clicks come with mouse events; a balloon click is taken to be the last balloon posted.
    • Linux without a tray: notify-send --action=default=… waits and reports the click; versions without --action fall back to posting without it.
    • TrayNotifier emits NotificationClicks; main.kt opens the file or shows the window on the target.
  • Android / iOS — tapping a finished download opens its file; the Open button is replaced by Show (the task) and Share. Share is now only offered for files on this device (it could previously point at a remote device's path).
  • Web — summary notifications open the Finished tab instead of doing nothing.

The task-opening logic that lived in MainActivity is now shared as NotificationLink + AppState.open in app:shared commonMain and used by every platform. NotificationAction.Open became Show.

Reviewer notes

  • No real notification clicks were exercised on any platform. Worth checking by hand: a packaged macOS build (finished + failed notification), and on Windows click a balloon then double-click the tray icon (the latter should only show the window).
  • With several balloons stacked on Windows/Linux, clicking an older one opens the newest one's target — the system doesn't say which was clicked.

Tests

  • New NotificationLinkTest (common) and NotificationClickTest (desktop: tray click classification, last-posted target, notify-send command).
  • :app:shared:jvmTest, :app:desktop:test pass; :app:android:compileDirectDebugKotlin, :app:shared:compileKotlinWasmJs and :app:shared:compileTestKotlinIosSimulatorArm64 compile.

Clicking a finished download saved on this device opens its file, falling
back to its task when the file is gone or will not open; every other
notification opens Ketch on its task, a summary on its device's Finished tab
and a message on the message.

Desktop notifications did nothing when clicked: macOS now posts through
NSUserNotificationCenter with a delegate of its own, Windows and Linux tell
tray balloon clicks from icon clicks by their lack of mouse events, and
notify-send waits for its default action. Android and iOS replace the Open
button with Show, and Share is only offered for files on this device. The
link handling Android had is now shared by every platform.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T10:52:58.227020Z e2cba1d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@linroid
linroid merged commit d135e32 into main Oct 13, 2026
12 checks passed
@linroid
linroid deleted the feat/notification-click branch October 13, 2026 10:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2cba1d68e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +68 to +69
link.filter?.let { statusFilter = it }
if (key == null) return

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Send summary clicks to the Downloads destination

For a CompletedBatch or QueueDrained click, key is null, so this updates statusFilter and immediately returns without requesting AppDestination.Downloads. AppShell only changes destinations when downloadsRequests emits (AppShell.kt:348-350), so if the user last left the app on Discover—especially when a desktop window is recreated after being hidden—the click opens Ketch but remains on Discover instead of showing the Finished tab. Make this navigation durably select Downloads before returning.

AGENTS.md reference: AGENTS.md:L997-L1000

Useful? React with 👍 / 👎.

Comment on lines 194 to +196
val builder = builder(CHANNEL_DONE, copy)
.setGroup(GROUP_DONE)
.setContentIntent(showIntent(tag, task = event.taskKey))
copy.actions.mapNotNull { fileAction(it, event.state.outputPath, tag) }
.forEach(builder::addAction)
.setContentIntent(open ?: show)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Route file taps through Ketch to preserve fallback

If the file exists when the notification is posted but is moved or deleted before the tap—or if no activity handles its MIME type—open remains a direct external ACTION_VIEW pending intent selected here. MainActivity therefore never receives the tap and cannot fall back to showing the task, leaving the click ineffective despite the promised fallback; route the content tap through Ketch so it can attempt the open and handle failure.

AGENTS.md reference: AGENTS.md:L997-L998

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant