makecindy / makecindy/cindy

mobile: remoteSessionStore 分片订阅(按 topic/selector),消除全局 emit 惊动全体订阅者

Open
#59 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.7k
Forks
395
Avg merge
21h 48m
Merged PRs (30d)
776

Description

## 背景

2026-07 手机版会话白屏/卡死排查(风暴修复链 e576b07ef / fc98be23b)确认的结构性病理之一:`remoteSessionStore` 是单一全局 store,任何一条消息追加、运行态变化都会 `emit()` 通知**全部**订阅者;消费端靠全局 `storeVersion` 粗粒度失效。桌面端流式输出期间 emit 频率可达每秒多条,曾把首页 105 个挂载会话行打成每秒 50-100 次重渲染、JS 线程停摆 10-90 秒(进而饿死心跳、被 relay 1001 踢线形成恶性循环)。

当前修复(引用调和 + useStableValue + 行级 memo)是在**消费端逐点做手艺活**,有效但每个新消费点都要重复这套模式,且靠 review 与契约测试守护,容易漏。

## 提案

把 `subscribe` 改为按分片订阅:`sessions` / `messages(sessionId)` / `runStatus(sessionId)` / `liveActivity(sessionId)` / `interactions(sessionId)` 等,emit 只通知相关分片的订阅者——把「无关更新不惊动消费者」从消费端手艺升级为结构保证。桌面端 renderer 的 store 经验可参考。

## 验收

- `pnpm test:unit` 中「引用调和」组与风暴不变量用例(消息/运行态高频 churn + 内容等价重算下 `getSessions()` 引用零漂移)全绿;
- `apps/mobile/docs/simulator-debugging.md`「Render Storm Forensics」节的 trace 测量流程,重构前后同场景(桌面端流式 + 首页/会话往返 2 分钟)对比:组件渲染次数/耗时不劣化;
- dev 下 `[js-stall]` 无 ≥10s 停摆。

Contributor guide

Open the contributing guide

Research direction

Start with the remoteSessionStore subscribe/emit path and the desktop renderer store experience referenced in the issue. Run pnpm test:unit, then use the Render Storm Forensics procedure in apps/mobile/docs/simulator-debugging.md; done means the reference-stability and storm-invariant tests pass, render metrics do not worsen, and dev shows no ≥10s [js-stall].

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, mobile
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.