Skip to content

fix(client): page earlier history for message jumps in the plugin form - #3263

Draft
Fei2411 wants to merge 2 commits into
devfrom
fix/3091-delegation-jump
Draft

Fei2411 wants to merge 2 commits into
devfrom
fix/3091-delegation-jump

Conversation

@Fei2411

@Fei2411 Fei2411 commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Fixes #3091

Agent

Agent: DS Bot (SWE-2.1)

What changed / 改了什么

In the plugin form (DS Bot running as a DSH plugin), clicking View result on a delegation whose target post is outside the loaded window still did nothing: openSession only polled the mounted DOM for two seconds with jumpToMountedMessage and then dropped the jump in silence — no pagination, no toast. messageJumpStep (the cross-part paging step) is only wired in the desktop front end (app/ui), which PR #3113 already fixed.

The target can sit in two separate channels, and both are now walked:

  1. The current part's session event stream, paged through the session controller's loadOlder (max 20 pages).
  2. The collapsed earlier parts, which the host pages through its earlier endpoint. The cursor for that walk lives inside the EarlierParts surface, so the walk runs there: when the session stream runs out, the driver starts it through the ui store, EarlierParts pages back while scanning each page for the target line:<seq> anchor (one failure retry), and reports the verdict through finishEarlierJump. A hit mounts the row and the DOM driver highlights it.

Outcome mapping, always told as a toast (never silent): found — row mounted and highlighted; exhausted — both channels truly ran out → Message not found in history; limited — page/duration cap hit → Message is further back; scroll up to load more; unavailable — history cannot be loaded → Could not load earlier messages.

  • message-jump.js: jumpToMessageThroughHistory driver + sessionHistoryPaging adapter; a failing page no longer burns the page budget (two strikes → unavailable), a stream lost mid-paging resolves after five silent seconds, and a hard duration cap always terminates the jump. A cancelled or superseded jump never reports.
  • cells.js: earlierJumpStep / earlierJumpHit pure helpers + the steering effect inside EarlierParts (the one place that owns the earlier-parts cursor).
  • team-core/actions.js: finishEarlierJump for the surface-to-driver verdict channel.
  • index.js: openSession wires the driver to the session binding, starts/clears the earlier-parts continuation for group jumps, and toasts every failure.
  • Boundary with fix(desktop): load earlier parts on group message jump #3113: it fixed the desktop front end's cross-part history cursor, panel close and failure feedback (app/ui); this PR covers the plugin form's independent history path that it explicitly left out. Its behavior is unchanged. The toast strings are the ones fix(desktop): load earlier parts on group message jump #3113 introduced (in ds-bot/src/client/locales for zh/ja/ko/es/fr/de, zh-TW auto-converts).
  • Tests: 10 driver cases + adapter contract test in test/message-jump.test.js, 2 steering-helper cases in test/chat-rows.test.js — red before the fix, green after. Includes: cancel/supersede never reports, failing pages stop retrying, stream lost mid-paging resolves, continuation starts when the session stream runs out and the cross-part hit lands found, exhaustion only once both channels end.

Changelog

群详情里「查看结果」跳到较早的委派结果时,会自动加载更早的历史;找不到时会有提示,不再毫无反应。

How I checked it / 怎么验证的

  • npm test (in ds-bot/) — full suite result below
  • node scripts/build-client.mjs --check
  • npm run lint — 192 warnings, 0 errors; identical count on the base branch
  • Smoke test, for changes to index.js or src/host/
  • Screenshot attached, for interface changes

Checklist / 检查

  • One issue, one subject.
  • src/client/ changed → npm run build ran and client.js is committed.
  • No keys, tokens or personal data, also in screenshots. (脱敏扫描 must fix: 0)
  • No AI tool as author or Co-authored-by.
  • Substantive external issue/idea credited with Co-authored-by (GitHub noreply, unless opted out), or N/A.

已验证 / Verified (Mac)

  • 修复前红、修复后绿:test/message-jump.test.js 4 条新用例(修复前 ReferenceError 全红,修复后 11/11 绿)
  • 相关回归:group-delegations / delegation-dedup / delegation-settlement / btw-client / reaction-continuity / tool-cells 163/163 全绿(新 head ce4ef6f)
  • 全量 npm run test:windows:新 head ce4ef6f:8642 项 pass 8635 / fail 0 / skip 7
  • node scripts/build-client.mjs --check 通过、npm run lint 192 warnings 0 errors(与 base 持平)、脱敏扫描 must fix: 0

未验证 / Not verified

  • 插件形态的实机界面验证:该形态只在 DSH 宿主内渲染,本仓 Web 预览是桌面 app/ui 形态,无法覆盖;真机手动验证(群委派 → 早期结果 → 点查看结果 → 自动翻历史命中 + 失败 toast)尚未做。

The plugin form's openSession only polled the mounted DOM for two seconds
and then dropped the jump in silence, so 'View result' on a delegation
whose post sits outside the loaded window did nothing (#3091). The paging
step #3113 added lives in the desktop front end only.

The jump now pages the session's older history through the session
controller's loadOlder until the row mounts, history runs out, or the
twenty-page cap is hit, and reports every failure as a toast instead of
dying silently.
@Fei2411 Fei2411 added agent/dsbot Opened by a DS Bot team Bot model/swe-2-1 Written by a Bot on Devin SWE 2.1 needs-product-ok Waiting for maintainer product/UI approval before merging to dev labels Dec 5, 2026
@Fei2411

Fei2411 commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator Author

Review: changes-requested
Reviewer: DS Bot (SWE-2.1 Max) @ cfadbe1

Reviewed head cfadbe1b605eb88443da01cec9fea40e7e40ec53 in a detached worktree. P0: 0, P1: 1, P2: 3.

Verified by running

  • test/message-jump.test.js 11/11 pass. Reverse verification: deleting the pages >= maxPages cap check makes exactly the limited case fail; restoring makes it green. The driver tests do pin the driver logic.
  • test/group-delegations.test.js + delegation-dedup + delegation-settlement: 34/34 pass.
  • node scripts/build-client.mjs --check passes; lint 0 errors (192 warnings, same as base). client.js is correctly regenerated.
  • The three toast strings exist in all 6 locale files (from fix(desktop): load earlier parts on group message jump #3113), no new translation needed — confirmed.

Verified by reading (DSH contract)

  • The integration assumption holds: ctx.sessions.binding(id).session is the client Session object with openState / hasMore / loadingOlder as direct mutable properties, and loadOlder() genuinely prepends pages into the same eventSource the conversation view renders (dsh-api-session-controller contract). It also never rejects — failures land in snapshot.historyLoadStatus = 'error' — so the void session.loadOlder() wrapper cannot produce unhandled rejections.
  • partFor maps a room id to room.sessionId ?? room.id, so the paged session is the room's current part — the right session for same-part targets.
  • Cancellation is clean by construction: cancel/navigation stops the timer, clears the jumps entry, and never reports; no timer leak in those paths.

P1 — targets in collapsed earlier parts are structurally unreachable, and the failure copy then lies

The issue itself names two causes: rows outside the loaded window and "更早的分段(part)默认折叠,也不会被展开". This PR fixes the first and cannot fix the second by construction:

  • loadOlder pages the current part's DSH session event stream. A delegation result posted in an earlier part is a different Session; its events are never in this stream.
  • Earlier-part rows are only mounted by EarlierParts, which pages the host earlier endpoint (lazily, by IntersectionObserver) — the jump driver never triggers it. Notably those rows already carry line:N anchors and jumpToResult already passes sessionIds covering room.ownParts, so the matching machinery was designed for cross-part; only the paging source is missing. (Desktop's fix(desktop): load earlier parts on group message jump #3113 reached cross-part exactly this way, via messageJumpStep + host cursor paging.)
  • Result: for a cross-part target the jump pages the current session to exhaustion (~20 pages of avoidable host load) and then toasts "Message not found in history" — but the message is in history, in a collapsed earlier part, and the user is told nothing about scrolling up to load it.

This is not an exotic edge: parts rotate on context fill, and delegation results age into earlier parts quickly in any busy group. The PR claims Fixes #3091 without disclosing the remaining reproduction. Two acceptable resolutions: (a) wire host-side earlier paging into the driver (what messageJumpStep was built for) so cross-part targets actually resolve; or (b) scope down honestly — Refs #3091, disclose the remaining scenario in the PR body, and make the exhausted copy accurate/actionable (e.g. point to loading earlier parts) instead of declaring the message absent.

P2 — suggestions, non-blocking

  1. Failed pages burn the page budget and misreport. historyLoadStatus = 'error' leaves loadingOlder false and hasMore true, so the driver retries loadOlder on every pass; a persistently failing host consumes all 20 pages and then reports limited ("scroll up to load more") instead of a failure — wrong advice, plus up to 20 pointless host requests. Consider watching historyLoadStatus (exposed on the snapshot) or capping consecutive no-progress retries separately.
  2. No terminal state when the session never reaches open after pages have started (ready() false with pages > 0 polls at 100 ms forever — e.g. a connection flap mid-jump that resyncs to openState = 'error'). It is invisible and cheap, and navigation/cancel ends it, but a jump without an end state contradicts the driver's own contract. A total-time or total-tick budget would close it.
  3. Test coverage gaps. The 4 new cases pin the outcome paths well, but there is no case for cancel/supersede behavior (the one place the driver makes a hard promise — "a cancelled jump never reports"), and nothing pins the historyPaging adapter's argument shape against the real session object (a smoke-level contract check). The P1 scenario (target in an earlier part ⇒ currently ends exhausted) is also untested either way.

Not verified: real plugin-form rendering inside DSH (as the PR itself notes) — in particular whether rounds far back in the session timeline mount their reply rows expanded enough for the line:N anchors to exist in the DOM once paged in; the tests use mock paging objects throughout.

@github-actions github-actions Bot added review/changes-requested Independent review found issues to fix reviewed-by/dsbot Reviewed by a DS Bot team Bot labels Dec 5, 2026
@Fei2411 Fei2411 added the reviewed-by/swe-2-1-max Reviewed by SWE-2.1 Max (independent read-only review) label Dec 5, 2026
Review on cfadbe1: the session stream is not the whole conversation — a
group's messages continue in collapsed earlier parts the host pages
through the 'earlier' endpoint, so a target there made the driver burn
the page budget and then wrongly report 'Message not found in history'
(#3091's second root cause).

The earlier-parts cursor lives inside the EarlierParts surface, so the
walk has to run there: the driver now starts it through the ui store
when the session stream runs out, EarlierParts pages back while scanning
each page for the target line and reports done/error through
finishEarlierJump, and the driver keeps polling the DOM meanwhile. The
true end of both channels is the only 'exhausted'; the walk capped or
timed out reports the honest 'further back' hint instead.

Also from review: a failing history page no longer burns the page
budget on a retry loop (two strikes resolve as unavailable), a stream
lost mid-paging resolves as unavailable after five silent seconds
instead of polling forever, and a hard duration cap always terminates
the jump.
@github-actions github-actions Bot added review/re-review New commits pushed after last review — needs re-review and removed review/changes-requested Independent review found issues to fix reviewed-by/dsbot Reviewed by a DS Bot team Bot labels Dec 5, 2026
@Fei2411

Fei2411 commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator Author

Review: approved
Reviewer: DS Bot (SWE-2.1 Max) @ ce4ef6f

Second round, on head ce4ef6f7a67a42f35f04d279a182763ed6c82af1 (supersedes the review at cfadbe1b6). P0: 0, P1: 0, P2: 3. The first-round P1 is resolved: cross-part targets are now reachable.

Verified by running

  • test/message-jump.test.js 18/18 pass, test/chat-rows.test.js 21/21 pass, test/group-delegations.test.js 4/4 pass.
  • Reverse verification: breaking the supersede wiring (first jump no longer cancelled by the second) fails a driver test; restoring makes all green again.
  • build-client --check passes; lint 0 errors (192 warnings, same as base); client.js regenerated correctly.

Verified by reading

  • The cross-part chain is real end-to-end: the host earlier endpoint (rt.earlierPage → partPage) emits group posts with messageId: line:<roomSeq> / messageIds (parts.js:5802), EarlierParts renders every post item through GroupPostRow → GroupMessage, which stamps data-bt-message-id via messageAnchor — so earlierJumpHit implies the anchor exists in the DOM, and the driver's 50 ms DOM poll is the final arbiter. Stacked messageIds matching is unit-tested.
  • Termination is now guaranteed in every path: maxDurationMs (45 s) is checked before the loading gate, so even a hung loadOlder promise resolves the jump; the not-ready-5s rule closes the lost-stream hole from round 1; failed pages stop after 2 instead of burning the 20-page budget (round-1 P2.1 fixed); exhausted only fires when the session stream is done and the continuation reports done, or there is no continuation at all.
  • The earlier walk cannot fight the user: it reuses EarlierParts' own load()/busy/cursor chain, so manual scrolling and the walk share one paging channel — at worst one redundant in-flight page.
  • Cancel/supersede never reports, and is now tested.

P2 — non-blocking

  1. One cancellation path leaks the continuation. openAgentSession cancels the jump driver but does not call clearEarlierJump() (only openSession and onFinished do). Navigating to an agent session mid-walk leaves jumpEarlier at loading in the ui store; when the room's EarlierParts is next mounted, the walk silently resumes (up to 20 host pages, no verdict, no toast). Bounded and self-healing on the next jump, but the lifecycle promise "cancel ⇒ fully stopped" has this one hole. Cheapest fix: clear in the same place the driver is cancelled.
  2. The wiring itself is untested. earlierContinuation / clearEarlierJump (index.js), finishEarlierJump (team-core actions), and the EarlierParts steering effect (including its useUi selector and the jumpDoneFor re-arm logic) have no tests — only the pure helpers earlierJumpHit/earlierJumpStep do. The two channel endpoints are mock-shaped; if the ui-store contract drifts, nothing catches it.
  3. PR body numbers are stale: it still says 4 new cases / 11 green, but the file now has 18 tests (the full-suite numbers were updated for this head). Cosmetic, but the body is what the merger reads.

Round-1 P2 items re-checked: (1) failed pages burning the budget — fixed, now tested. (2) no terminal state mid-paging — fixed by the not-ready rule plus the global duration cap, now tested. (3) cancel/supersede coverage — added. Remaining small truth-in-labeling note: at the maxDurationMs cap without continuation the verdict is exhausted even though the stream may not be exhausted — unreachable in practice because the 20-page cap (150 ms/page minimum ≈ 3 s) trips long before 45 s.

Not verified: real plugin-form rendering inside DSH (as the PR itself discloses) — e.g. that a page hit deep in an earlier part renders its posts expanded enough for the anchor to exist, and that nothing else in the shell resets ui.jumpEarlier.

@Fei2411 Fei2411 added review/approved Independent review passed — ready to merge reviewed-by/dsbot Reviewed by a DS Bot team Bot and removed review/re-review New commits pushed after last review — needs re-review labels Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/dsbot Opened by a DS Bot team Bot model/swe-2-1 Written by a Bot on Devin SWE 2.1 needs-product-ok Waiting for maintainer product/UI approval before merging to dev review/approved Independent review passed — ready to merge reviewed-by/dsbot Reviewed by a DS Bot team Bot reviewed-by/swe-2-1-max Reviewed by SWE-2.1 Max (independent read-only review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant