Skip to content

fix: strip bare "[N]" unread-count prefix from sender - #1

Merged
whtis merged 2 commits into
mainfrom
fix/sender-count-prefix
Jul 20, 2026
Merged

whtis merged 2 commits into
mainfrom
fix/sender-count-prefix

Conversation

@whtis

@whtis whtis commented Jul 20, 2026

Copy link
Copy Markdown
Owner

问题

微信的未读计数有两种形式:[3条] 和不带「条」的 [82]。COUNT_PREFIX 只剥离了前者,后者会残留下来被 SENDER_PREFIX 连同昵称一起捕获:

text = "[82]一条鱼: 融资买杠杆"
  → sender = "[82]一条鱼"   ← 应为 "一条鱼"

同一个人因此被拆成多个 sender(韭菜根 / [28]韭菜根 / [29]韭菜根),digest 里的 focus-person 追踪会漏掉这些发言。

线上实测:11440 行里有 1655 行受影响——微信断线重连后未读数涨到上百,[100]…[1626] 连续出现。

改动

条 改为可选:

- Regex("^[\\[【]\\s*\\d+\\s*条\\s*[\\]】]\\s*")
+ Regex("^[\\[【]\\s*\\d+\\s*条?\\s*[\\]】]\\s*")

数字仍然是必需的,因此方括号表情昵称不受影响——[鲸鱼](411 行)、[熊](63 行)、[火箭]Steve.(11 行) 等共 542 行。这是刻意的边界:更宽松的规则(比如剥离任意方括号内容)破坏的行数会超过它修复的行数。

测试

新增 4 个用例,覆盖两侧边界:

  • [82]一条鱼: … / [12]在吗 → 前缀被剥离
  • [火箭]Steve.: … / [鲸鱼] → 昵称原样保留

已验证这些用例在改动前会失败、改动后通过(21 passed / 0 failed)。

版本

1.0.0 → 1.0.1(bugfix),versionCode 202607201。

🤖 Generated with Claude Code

whtis and others added 2 commits July 20, 2026 16:55
WeChat emits the unread count both as "[3条]" and as a bare "[82]". Only the
former was stripped, so the latter survived into SENDER_PREFIX and was captured
as part of the name: "[82]一条鱼" instead of "一条鱼". The same person then
appeared under many senders ("韭菜根", "[28]韭菜根", "[29]韭菜根"), which breaks
focus-person tracking in the digest. 1655 of 11440 rows were affected after a
reconnect drove unread counts into the hundreds.

Make 条 optional. The digits stay required, so bracketed emoji display names
("[鲸鱼]", "[火箭]Steve.") are still left alone — there are more rows behind
those names than behind this bug, and a looser rule would corrupt them.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@whtis
whtis merged commit e534e33 into main Jul 20, 2026
1 check passed
@whtis
whtis deleted the fix/sender-count-prefix branch July 20, 2026 09:02
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