Skip to content

完善消息去重并增加说明文档#576

Open
chenjei2011 wants to merge 1 commit into
InkCanvasForClass:net6from
chenjei2011:feature/notification-dedup-alter
Open

完善消息去重并增加说明文档#576
chenjei2011 wants to merge 1 commit into
InkCanvasForClass:net6from
chenjei2011:feature/notification-dedup-alter

Conversation

@chenjei2011

Copy link
Copy Markdown
Contributor

1 修改相关变量名等
2 使去重条件更加严格
3 增加说明文档

以下为具体更改

  • 将可变结构体 JudgeRepeatMessageStruct 改为类 LastMessageInfo
  • 规范命名若干变量
  • 新增对 Summary 字段的比较,使得标题相同但内容不同的通知不会被误判为重复。
  • 只有 Title 非空的消息才会更新去重相关变量,避免无标题消息干扰
  • 新增说明文档 消息去重说明.md

@augmentcode

augmentcode Bot commented Jul 5, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR tightens NotificationCenterService message de-duplication to reduce repeated popups in high-frequency plugin scenarios.

Changes:

  • Refactors the last-message state from a mutable struct to a dedicated class and renames related variables
  • Extracts duplicate detection into IsDuplicate with a 2-second sliding window constant
  • Adds Summary comparison so same-title notifications with different content aren’t suppressed incorrectly
  • Only updates the de-duplication state when Title is non-empty to avoid untitled messages interfering
  • Adds a dedicated markdown document explaining the de-duplication rules

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

if (_lastMessage.Title == message.Title && totalSeconds <= DeduplicationWindowSeconds && message.Source == _lastMessage.Source && message.Summary == _lastMessage.Summary)
{
_lastMessage.Time = message.CreatedAt;
Console.WriteLine("[info]标题" + message.Title + "已被自动去重" + "发送方" + message.Source);

@augmentcode augmentcode Bot Jul 5, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

IsDuplicate 里直接 Console.WriteLine 可能会在正常运行中产生大量标准输出噪声;当前项目其他位置更倾向用 LogHelper.WriteLogToFile 做可控日志。可以考虑统一到现有日志通道,避免课堂环境下刷屏。

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

对于插件或程序运行错误导致的大批量的通知,如果直接记录日志会导致日志体积快速膨胀,有计划在以后对于拦截采用日志记录(但要加重复的只记录一次的逻辑)

## 描述
为避免插件在短时间内高频推送相同通知(例如网络重连、循环异常等)干扰课堂体验,"NotificationCenterService" 内置了 滑动窗口去重 策略。符合去重条件的消息将被静默抑制,不会重复弹出。
## 触发条件
### 要同时满足以下条件才会被去重

@augmentcode augmentcode Bot Jul 5, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

这里的去重触发条件列表似乎少了一项:代码里还要求 message.Source 相同才会去重(NotificationCenterService.IsDuplicate)。建议文档补充“来源(Source)相同”,避免读者误以为跨来源也会去重。

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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.

1 participant