Jump to Previous/Next @Mention Messages in Forkgram

Preface

We previously implemented pinning groups with @mention messages to help us "quickly get to the battlefield"
We went further and implemented jumping to the last @mention message

But what if there are more than one new @mention messages in the group?

Agent-Oriented Development

Hermes connecting to oc/deepseek-v4-flash-free

The text inside the quotation boxes below are all natural language I sent to the Agent
Based on the code at https://github.com/crazypeace/forkgram-tdesktop/tree/goto-last-mention , perform enhanced development
After clicking "Go to the last msg mentioned me", the effect of jumping to the message is achieved.
Then, at this point, clicking "Go to the last msg mentioned me" again should continue to jump to the previous @message.
Tell me how you understand my requirements, and discuss with me.
The Agent analyzed for a while and asked me, when jumping backwards, what should be used as the anchor?
Should we save the message id from the previous jump as the anchor?
Or should we use the messages visible in the current group chat viewport as the anchor?
Anchor = current viewport
Change the original "Go to the last message mentioned me" menu item to "Go to the Pre msg @me"
The effect is: using the current viewport as the anchor, jump to the previous @me message
Add a new item "Go to the Next msg @me"
The effect is: using the current viewport as the anchor, jump to the next @me message

Result

Group menu
Group chat menu highlighting the Go to the Pre msg @me and Go to the Next msg @me options

Jump effect

Github

Code

Release

========

Postscript

The "jump to next @me message" feature has a flaw
In the Telegram API, searching for group messages is messages.search . This API can only search from a specified message id towards older times, not towards newer times. So strictly speaking, this feature cannot be implemented.
The essence of the algorithm currently implemented is:
First, use the group's latest message as the anchor, search towards older times for 10 @me messages, and get the ids of these messages; (1)
Get the message ids visible in the current group chat viewport; (2)
From the 10 message ids obtained in (1), find the one that is just greater than the id in (2), and jump to it.
In other words, the "jump to next @me message" feature is only effective within the last 10 @me messages of the group.

Comments