Skip to content

Conversation

@shubham-padia
Copy link
Member

@shubham-padia shubham-padia commented Oct 29, 2025

Fixes #1371.
We do not accept a filePath from the web app when recieving the event to show the file in a folder, since that could introduce securithy vulnerabilies. We store the latest downloaded file path instead in a variable. Only one in-app notification is active at a time, so storing the latest file path is enough for out use case.

To test this PR, run a zulip server that runs the branch on zulip/zulip#36408 and add it to the zulip desktop app running on this PR. Upload a file and download it to test.

Screenshots and screen captures:
Screenshot 2025-11-06 at 3 14 14 PM
Screenshot 2025-11-06 at 3 04 50 PM

Platforms this PR was tested on:

  • Windows
  • macOS
  • Linux (specify distro)
Self-review checklist
  • Self-reviewed the changes for clarity and maintainability
    (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns.

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (see commit discipline).

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

"show-download-success",
notificationTitle,
notificationBody,
);
Copy link
Member

Choose a reason for hiding this comment

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

This seems to do both the old notification mechanism and the new one -- is that intendedd?

It is important for backwards-compatibility to make sure we do the old thing on existing web app versions. But I don't know if doing both would be problematic, and in any case, I would expect some sort of detection logic and comments explaining the reasoning behind what we're doing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that is intended. My understanding of the requirements is that we want to show both in-app and native notifications. @alya let me know if that is not the case.

Added comments.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good question, I was imagining we'd have both, but I'm not sure if it's silly to do it that way. If you'd be up for it, it might be good to check how a few other apps handle it. Trying Discord, Slack, and WhatsApp, it seems like they pick one or the other, unless my desktop notifications aren't working properly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So possibly we'd suppress the native notification when showing the in-app one.

Copy link
Member

Choose a reason for hiding this comment

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

I think we don't want to send both. There are some potential advantages to the native notification; It appears even if your desktop app is not focused -- say if you started downloading a long video and then tabbed away.

Is there a way to check if the native notification actually sent?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there a way to check if the native notification actually sent?

I checked this and there's not for all OS. Only windows emits a failed event: https://www.electronjs.org/docs/latest/api/notification#event-failed-windows.

Might be ok having both notifications in that case?

title: notificationTitle,
body: notificationBody,
silent: true, // We'll play our own sound - ding.ogg
});
Copy link
Member

Choose a reason for hiding this comment

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

So the original issue is a complaint about the native notifications not working on Windows. Do we understand how that's happening? I feel like papering over a bug like that without understanding it is risky -- have you tried arranging an interactive debugging session with someone experiencing the bug?

Copy link
Member Author

Choose a reason for hiding this comment

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

The user didn't confirm whether they had desktop notifications enabled or not.
Screenshot 2025-11-06 at 2 31 18 PM

The original intention was to solve #desktop > several clicks to download a file, I can unlink the issue from the PR if we think it's a windows bug (which I highly doubt). Reply from the issue poster felt incoherent.

Fixes zulip#1371.
We do not accept a filePath from the web app when recieving the event to
show the file in a folder, since that could introduce securithy
vulnerabilies.

We instead keep the list of latest 50 downloaded files in memory and
give each filePath a unique downloadId that can be passed around between
the webapp and the desktop app.
@shubham-padia
Copy link
Member Author

shubham-padia commented Nov 6, 2025

Updated the PR to store the last 50 downloaded files in memory. I tested the oldest file removal logic by printing the downloadedFiles map in console. The PR shows both native and in-app notification right now since it is not possible to know when the user has disabled notifications from system-side.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

strange downloading a file

4 participants