Jump to Previous/Next @Mention Messages in Forkgram

Preface

We previously implemented Pin groups with @mention messages to make it easier to "quickly jump to the battlefield".
We then further implemented Jump to the last @mention message.

But what if there are multiple new @mention messages in the group? 

Agent-Oriented Development

Hermes integrates with oc/deepseek-v4-flash-free

The natural language in the quote block below is what I sent to the Agent.
基于 https://github.com/crazypeace/forkgram-tdesktop/tree/goto-last-mention 的代码, 进行增强开发
当 点击 "Go to the last msg mentioned me" 之后, 实现了跳转消息的效果,
然后, 在这个时候, 再次点击 "Go to the last msg mentioned me", 希望能继续跳转到再上一条 @消息
你说一下你是怎么理解 我的需求的, 与我讨论.
After analyzing it, the Agent asked me, what should be the anchor point when jumping backward?
Should it save the message ID from the previous jump as the anchor point?
Or should it use the messages currently visible in the group message viewport as the anchor point?
锚点=当前视口
把原来的 "Go to the last message mentioned me" 菜单项 改为 "Go to the Pre msg @me"
效果为, 以当前视口为锚点, 跳转上一条 @我 的消息
增加一项 "Go to the Next msg @me"
效果为, 以当前视口为锚点, 跳转下一条 @我 的消息

Results

Group menu

Jump effect

Github

Source code

Release

========

Postscript

The "Jump to the next @mention message" feature has a flaw.
In the Telegram API, searching for group messages is done via messages.search, which can only search from a specified message ID toward older messages, not toward newer ones. So strictly speaking, this feature cannot be fully implemented.
The actual algorithm currently implemented is:
First, using the group's latest message as the anchor point, search backward in time for 10 @mention messages and get their IDs; (1)
Then, get the IDs of messages currently visible in the group message viewport; (2)
From the 10 message IDs obtained in (1), find the one that is just greater than the ID from (2), and jump to it.
In other words, the "Jump to the next @mention message" feature only works within the scope of the last 10 @mention messages in the group.

========

Related Recommendations


Comments