Skip to content

Comments

Add --stop-after-empty-queue flag to presage-cli sync#342

Merged
gferon merged 6 commits intowhisperfish:mainfrom
thandal:patch-1
Feb 20, 2026
Merged

Add --stop-after-empty-queue flag to presage-cli sync#342
gferon merged 6 commits intowhisperfish:mainfrom
thandal:patch-1

Conversation

@thandal
Copy link
Contributor

@thandal thandal commented Nov 16, 2025

Break when receive hits QueueEmpty

Break when receive hits QueueEmpty
@hoehermann
Copy link

This makes it impossible to print new messages as they come in.

@gferon
Copy link
Collaborator

gferon commented Nov 17, 2025

Thanks! The original code is intended behaviour and essentially waits until the next message comes. "Hanging" is here desirable and you can abort the receiving loop with exiting the program.

@thandal
Copy link
Contributor Author

thandal commented Nov 17, 2025 via email

@boxdot
Copy link
Collaborator

boxdot commented Nov 17, 2025

How about adding a CLI argument, which enables this behavior?

@hoehermann
Copy link

Generally CLIs do one thing per command, and then return their results.

Indeed, but depending on the tool, the result is not a single value, but a stream – especially if the input too is a stream (network or local input). Popular examples are cat, netcat, socat, grep, sed, awk, and many more. So presage-cli's default behaviour can be regarded "reasonable".

How about adding a CLI argument, which enables this behavior?

That would be a good approach.

@thandal
Copy link
Contributor Author

thandal commented Nov 17, 2025 via email

@thandal
Copy link
Contributor Author

thandal commented Nov 19, 2025

Ok, please take a look.

@kurotych
Copy link
Contributor

kurotych commented Dec 18, 2025

+1 to having this cli argument (but for all such commands that opens stream, not only receive)

@kurotych
Copy link
Contributor

Thanks! The original code is intended behaviour and essentially waits until the next message comes. "Hanging" is here desirable and you can abort the receiving loop with exiting the program.

Could you please tell why this hanging is implemented in such a strange way? Why does it wait for 60 seconds for a Received::Contacts message? (In case of sending a message)

https://github.com/whisperfish/presage/blob/main/presage-cli/src/main.rs#L308

@gferon

@gferon
Copy link
Collaborator

gferon commented Dec 20, 2025

Yeah, so the CLI wasn't ever made to be a fully fledged client, more of a demo and test platform for the library's API. If you were to make your own client, you poll on the receive stream in parallel with sending a message, in which case it doesn't really matter. Sometimes when linking too many times for example, the main client won't send contacts again, which is why I ended up adding this waiting period.

@gferon gferon enabled auto-merge (squash) February 20, 2026 07:23
@gferon gferon disabled auto-merge February 20, 2026 07:23
@gferon gferon enabled auto-merge (squash) February 20, 2026 07:35
@gferon gferon merged commit 1c51e08 into whisperfish:main Feb 20, 2026
3 checks passed
@gferon
Copy link
Collaborator

gferon commented Feb 20, 2026

@thandal thanks for your patience and contribution! I've been busy with a new addition to my family 😄

@gferon gferon changed the title Fix hanging in receive Add --stop-after-empty-queue flag to presage-cli sync Feb 20, 2026
@thandal
Copy link
Contributor Author

thandal commented Feb 20, 2026

Great! And congratulations!

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.

5 participants