Skip to content

fix(mobile): let a pull's spinner own the wait it restarts - #843

Merged
huichen merged 2 commits into
mainfrom
fix/chat-pull-sync-notice
Sep 25, 2026
Merged

huichen merged 2 commits into
mainfrom
fix/chat-pull-sync-notice

Conversation

@huichen

@huichen huichen commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

问题:一次下拉,两处报同一个等待

截图里(真机 Android,倒置列表):从底部往上拉之后,视觉底部的原生转圈和列表上方的「正在同步…」胶囊同时亮起。

原因不在 #840——那里只是把转圈从"任何自动同步都转"改成"只有真下拉才转"。而下拉本身就会重启同一条 lane(reloadTimeline → refreshTimeline → timelineSyncStatus = "syncing"),于是 #840 之后:

  • 自动同步:只有胶囊(正确,转圈不亮);
  • 真下拉:转圈 + 胶囊(同一个等待被报了两遍,位置还在屏幕两端)。

改法:重叠时让"手指那一处"说话

  • 胶囊新增一个判断:pullRefreshActive && syncNoticeState === "syncing" 时不显示——这次等待已经由下拉的原生转圈在原地报了,而且手指刚离开那里。
  • 只让**平淡的"正在同步…"**让位。retrying("最新内容尚未同步完成,正在重试…")和 waitingNetwork("…正在等待连接恢复…")照旧显示:这两个状态转圈说不出来(转圈只会一直转),信息不重复;真机弱网里"下拉之后开始重试/断连"正是最需要这句话的时候。
  • 抑制加在 useMinimumVisible 的输入而不是渲染上:否则胶囊的 750ms 最短可见窗口会在下拉结束之后补一段"正在同步…",成了事后闪现。
  • 顺带把"哪个状态说什么话"收成一个 syncNoticeState,让闸门和文案读同一份判断(原来是三目里一套、闸门再猜一套);JSX 里那串嵌套三目变成 SYNC_NOTICE_KEYS[state]。

验证

  • 新增断言 the pull's spinner is the only report of the wait it restarts 证伪过:把 pullOwnsTheWait 改成 false(即旧行为),该用例失败在 expect(notice("chat.syncingLatest")).toBe(false) → 收到 true。
  • 既有的 cached messages…750ms 用例在改法中途失败过一次,暴露出"胶囊最短可见窗口的尾巴(状态已回 idle、胶囊还挂着 ≤750ms)"不能被闸门吃掉;因此渲染仍由 showSyncNotice 决定,尾巴沿用平淡文案(与旧三目的兜底一致)。
  • mobile:npx tsc --noEmit、npx eslint src、npx jest 全绿 —— 除 useSkillRecommendation.test.ts 里 skips a skill already shown today… 一条,在打补丁前的干净工作树上以同样方式失败(该用例用 new Date().toISOString().slice(0,10) 造数据、hook 按本地日期存,本地时间刚过午夜(本地 09-26 / UTC 09-25)就对不上;CI 跑 UTC 不受影响),与本次改动无关。
  • 截图 harness 验不了这一步:RNW 下的 RefreshControl 不渲染原生指示器,那圈转圈只在真机上存在;所以这一处只能靠单测 + 真机复看。

A pull restarts the very lane the sync notice above the transcript reports,
so the native indicator at the visual bottom and the pill came up together and
said the same sentence twice. While the pull spins, the pill now stands down for
the plain "syncing" state; "retrying" and "waiting for the connection" stay
because the spinner cannot say them.
@huichen
huichen enabled auto-merge (squash) September 25, 2026 16:03
@huichen
huichen merged commit 4ac3fad into main Sep 25, 2026
12 checks passed
@huichen
huichen deleted the fix/chat-pull-sync-notice branch September 25, 2026 16:10
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