Skip to content

Delay showing new-message notifications on the primary device when scli is running #209

@max-baz

Description

@max-baz

I'd like to implement sending read receipts, and I want to run it by you first, to discuss some architectural decisions 😄

The primary goal: I don't want to receive signal notifications on phone/smartwatch, if I'm actively chatting in scli.

The main challenges, as I currently see them, are:

  1. Implementing the code that will use signal-cli to actually send read receipt.
  2. Detecting that scli is currently focused.

The first item seems possible, although I haven't worked with signal-cli before, I can see sendReadReceipt in the docs. Do you see any challenges here, missing APIs or some other problems? I haven't used Signal Desktop for a while, but I seem to remember that when Signal Desktop is open (but not focused, or focused but on a different contact), notifications on the phone arrive with a delay, seemingly giving the user a few seconds to check them out on desktop, before "spamming" their phone. I don't know if that's just "magically" works via their backend, or there's a special API to use, to activate such "delayed" mode. Do you know, perhaps?

Detecting whether a user is currently looking at scli is both difficult to implement for everyone, but at the same time is easy to do when you know the particulars of user's setup. Just to give you a concrete example, I am running Hyprland, which comes with both a CLI tool that can detect the currently focused window, and a Unix socket where you can subscribe for events of changing the active window. Identifying scli process specifically within a terminal window is also possible, e.g. by running a dedicated terminal instance with a custom app_id / class (e.g. kitty --class=scli scli).

So it sounds like it should be left to the user, to tell scli if it's currently focused, and scli should send read receipts if it has such information.

Here are the two different ways I thought such integration could potentially be implemented:

  1. We give scli a command, which it periodically runs, say every second or two, to detect if scli is currently focused or not (say it outputs a boolean). Maybe also runs it additionally after every received message.
  2. We teach scli a couple of Unix signals (say SIGUSR1 and SIGUSR2), which would tell sci that it got focused and unfocused respectively. We leave it up to users to send those signals (either precisely when these events occur, if they can e.g. subscribe to a socket like me, or just sending these signals in an infinite loop).

The latter seems a lot more robust and battery-friendly, but also requires users to implement more glue.

What are your thoughts on it?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions