Skip to content

spec: InboxListResult.unreadCount 的 JSDoc 仍写「over the returned window」—— 与 #6363 落地后的实现和同族 .describe() 相反 #6438

Description

@hotlong

发现于 #6363 的实施。故意不在该 PR 修#6363 的派单红线是「不改 packages/spec」(Option A 是让声明成真,不是改声明),而这一行落在 spec 座位的文件里,与 #6361cursor 移除同属一个包。单独立单,好让 spec 座位一次处理。

事实

packages/spec/src/contracts/notification-service.ts

/** Result of {@link INotificationService.listInbox}. */
export interface InboxListResult {
    notifications: InboxNotification[];
    /** Unread count over the returned window. */
    unreadCount: number;
}

/** Unread count over the returned window. */ 记录的是 #6363 修好之前的实现语义。#6363 落地后:

  • 实现(service-messaging/src/messaging-service.ts)数的是整个匹配信箱的总未读,窗口只约束 notifications[]
  • 同族的 wire 声明(packages/spec/src/api/protocol.zod.ts:924)一直写的是 'Total number of unread notifications'

于是同一个字段在同一个包里有两句相反的散文,而实现站在 .describe() 那边。

为什么值得单独修,而不是「只是个注释」

这行不是内部注释:它是 INotificationService 这个对外契约接口的 JSDoc,随 .d.ts 发布,是 TS SDK 使用者在编辑器里读到的那句话。一个把「窗口内计数」讲给消费者听的提示,正好会诱导消费者写出 #6363 要消灭的那种适配(自己再去数一遍、或按窗口大小截断显示)。防 AI 轴上也是同一件事:AI 写的消费端就是照这句 JSDoc 生成的。

修法(一行)

/** Unread count over the returned window. */ 改成与 .describe() 同义的表述,例如:

/** Total unread across the user's whole matching inbox — NOT the returned window (#6363). */

顺带可考虑给 notifications 补一句「the limit-bounded window」,因为这两个界现在是故意不同的,而当前接口里没有任何一句写下这个区别。

关联

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions