Repository navigation
Conversation
…nects A phone drops its link when the app goes to the background or loses the network mid-turn. The phone link forwarded only live feed events, so a phone that reconnected during a long turn received no streamed text at all until the turn committed its message; the whole reply then appeared at once, which reads as if it landed after any message the user sent meanwhile. The feed already replays its accumulated reply text to SSE clients and remote subscribers when they connect. Reuse the same replay for the phone link: when a device joins, forward the feed opening to every connected device so the newcomer catches up and the ones already tracking the stream rebuild identical text. Streaming accumulated its attempts in component state, so leaving the chat screen mid-turn and coming back discarded the text received so far. Keep the accumulation in module-level state keyed by session id; the feed keeps flowing while the screen is away, and the remount reads the current text instead of starting over. Refs #3108
A delta arriving between the snapshot read and the feed subscription would never reach the screen again. Subscribe first, then sync.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Refs #3108 (partial: the ordering/visual-position half is a product decision and is not done here, see "Remaining" below)
Agent
Agent: DS Bot (SWE-2.1)
What changed / 改了什么
Root cause / 根因: during a long turn the reply text exists only as transient
streamfeed events. The phone link forwarded only live events with no replay, so a phone that lost its link mid-turn — the app drops the link in the background — received nothing at all until the turn committed. The whole reply then appeared at once, and to a user who had sent another message meanwhile the conversation read as out of order. The same applied when the user left the chat screen mid-turn:Streamingaccumulated text in component state, so the remount started over from whatever delta arrived next.ds-bot/src/host/feed.js: exposert.replayFeed, the same feed openingsubscribeFeedlisteners already get (hello+ accumulated reply text per in-flight attempt).ds-bot/src/host/phone.js: forward feed events through a shared helper; when a device's ready count increases, invite the replay so a reconnecting phone catches up with the reply streamed so far. Devices already tracking the stream rebuild identical text, so replaying to all connected devices is safe.mobile/src/screens/Chat.tsx: accumulate stream attempts in module-level state keyed by session id instead of component state, so leaving and re-entering a chat mid-turn keeps the text received so far; empty sessions are released when attempts end. Subscription happens before the mount-time snapshot so no delta is lost in between.ds-bot/test/phone.test.js— a phone connected mid-stream disconnects, misses further streamed text, reconnects, and must receive the replayed baseline (红 → 绿verified).Ordering note / 排序说明: the seq-based order of committed messages is unchanged and intentionally so. A queued user message commits only when the next turn consumes it, so the committed order
answer → queued messageis causally correct; reordering by insertion time would break pagination cursors and read watermarks that share the seq domain. Whether the chat should visually pin a user message at its insertion position (itsagent/inbox/splicedevent) is a product decision — left out here because splices can sit on an earlier page than the commit, which the paging architecture cannot reposition across.Remaining / 剩余: the ordering half — showing a queued user message at its insertion position instead of after the committed answer — is not done and is not possible without changing the seq/paging domain; it needs a product decision (and its own issue/PR if wanted). This PR fixes only "in-turn reply is invisible until the turn lands".
Changelog
When the phone app returns from the background or reopens a chat while the Bot is still answering, the reply being typed now reappears and keeps streaming instead of showing nothing until the turn ends.
How I checked it / 怎么验证的
已验证(在 Mac 上验证):
npm test(inds-bot/) —npm run test:windowsfull suite: 8616 tests, 8609 pass, 0 fail, 0 cancelled (7 skipped). Regression test red before the fix ("the link must invite a feed replay when a device connects"), green after; re-confirmed red by stashing the fix.node scripts/build-client.mjs --checknpm run lint— 0 errors (warnings unchanged, pre-existing)npm run typecheckclean;npm test286/286 pass (including the updatedstreaming.test.tsremount case)test/phone.test.js+test/feed.test.js+test/mobile.test.js+test/remote.test.js+test/phone-push.test.js+test/phone-browser.test.js— 118/118 passindex.jsorsrc/host/— not runnable on this machine (no deepseek-harness source); see below未验证:
src/host/changes against a live DSH session (no deepseek-harness source on this machine, per the squad README).Checklist / 检查
src/client/changed →npm run buildran andclient.jsis committed. / 不适用 — nosrc/client/changes.Co-authored-by. / 没有把 AI 工具写成作者或Co-authored-by。Co-authored-by— N/A.