Skip to content

fix(client): keep the conversation clear of the Bot column after a mode switch - #3288

Draft
Fei2411 wants to merge 3 commits into
devfrom
fix/936-leftcol-overlap
Draft

Fei2411 wants to merge 3 commits into
devfrom
fix/936-leftcol-overlap

Conversation

@Fei2411

@Fei2411 Fei2411 commented Dec 6, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Fixes #936

Agent

Agent: DS Bot (DeepSeek V4.1 Flash)

What happened / 根因

The Bot column is fixed over the shell, and its compensation is margin = pushed - frameSnap.collapsedWidth. After switching from Agent mode to Bot mode, the shell folds its own sidebar track to zero (the plugin's shell CSS), but collapsedWidth still holds the host's fallback rail (56px here). The conversation column then starts 56px underneath .bt-leftcol until a drag remeasures it. The report's own diagnostics and analysis point at the same snapshot-vs-rendered geometry; the shell's full-width bottom row had no compensation either.

Before / after / 前后对比

Before — 56px overlap (panel right 280, conversation left 224):
Before: 56px overlap

After — 0 overlap (panel right 280, conversation left 280):
After: 0 overlap

The screenshots live on the temporary fix/936-shots branch and can be deleted after merge.

What changed / 改了什么

  • frame-layout.js: add measuredLeftInset(panelRight, columnLeft, currentInset), which adds only the overlap still visible.
  • sidebar.js: after the layout settles, measure .bt-leftcol's right edge against the center column's left edge (with its current inset) and add the remaining overlap. Recheck on the next frame, on ResizeObserver changes of the panel, the center column and the host sidebar, on the frame's and the host sidebar's transitionend, on window resize, and after the slide spring settles. Skip while a drag owns the column or the host is mid-transition, so the drag path stays authoritative.
  • chat-room.js + styles-dsh.js: expose --bt-left-inset (the docked column width) and pad [data-shell-bottom] by it, so a full-width host bottom row is not covered. It resets to 0 when the Bot surface unmounts.
  • The correction reads the center column through the adapter's data-bt-center stamp (chatRoom.columns()), not DSH class fragments, so the desktop selector guard stays clean; the host track is rechecked after it settles instead of observing its private frame nodes.

Changelog

Switching from Agent mode to Bot mode no longer leaves chat content underneath the Bot sidebar.

How I checked it / 怎么验证的

  • Real DSH web shell with the plugin (mock model), 1600×900, starting in Agent mode and switching to Bot:
    • before (the parent of this PR's first commit): panel right 280, center left 224, overlap 56px, margin 224
    • after: panel right 280, center left 280, overlap 0, margin 280; repeated the switch twice and a fresh Bot load, all 0
    • bottom row: computed padding-left and --bt-left-inset are 280 while the open column is docked (0 when hidden)
  • test/frame-layout.test.js + test/sidebar-switch.test.js: 107/107 pass (adds the settled-inset regression and models the measured host track in the existing spring test)
  • npm test: 8647 tests, 8639 pass, 0 failures from this change; 1 pre-existing memory-test flake (a private Bot drops a legacy frozen snapshot…) that passes alone and is unrelated to the client layout
  • node scripts/build-client.mjs --check and node scripts/build-link.mjs --check
  • npm run lint: 0 errors
  • Desensitization scan: must fix: 0
  • Preview: local DSH web bench at http://127.0.0.1:4195/ (loopback, session-token protected; not publicly reachable). Before/after screenshots are in the first comment.

Assumptions / 假设

  • The plugin's shell CSS folds the host sidebar track to zero, so the rendered overlap is the honest signal; the correction only adds positive overlap and never shrinks an inset.
  • The host's bottom row is full-width and can take a left padding equal to the docked column width; the padding is plugin-only CSS.
  • Dragging remains authoritative: the correction skips while activeDrag is set, and the drag's own per-frame writes are unchanged.

Risks / 风险

  • The correction runs a few bounded times after a mode switch (next frame, two timers, observer events); it skips while the slide spring runs or the host is animating.
  • If another plugin also writes margin-left on the center column, the measured inset adds to it; only positive overlap is added.
  • The [data-shell-bottom] padding applies only while this plugin's shell CSS is loaded; it is 0 when the Bot surface is not mounted.

Rollback / 回滚

Revert the commit; no storage or protocol change.

未验证 / Not verified

  • Windows DSH Desktop itself; verified in DSH web with the same shell DOM (macOS, 1600×900).
  • A real plugin-provided bottom bar in [data-shell-bottom]; the row is empty in this shell, so the bottom-row padding is verified by computed style, not by a filled bar.

…de switch

The mode-switch compensation read the saved collapsed-width snapshot. After Agent mode the host folds its own sidebar track to zero, so the snapshot's fallback rail was subtracted from the rendered column and left the conversation that far underneath .bt-leftcol until a drag remeasured. Follow the visible overlap after layout settles, and expose the docked width for full-width host rows.
@Fei2411 Fei2411 added agent/dsbot Opened by a DS Bot team Bot model/deepseek-flash Written by a Bot on DeepSeek Flash needs-product-ok Waiting for maintainer product/UI approval before merging to dev labels Dec 6, 2026
@Fei2411

Fei2411 commented Dec 6, 2026

Copy link
Copy Markdown
Collaborator Author

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

Scope reviewed: measuredLeftInset, the correctRoom closure and every call site (settle path, RO/transitionend/resize/timers effect), the drag interplay, --bt-left-inset lifecycle in chat-room.js/styles-dsh.js, the spring margin derivation (slide - collapsedWidth during motion vs finalMargin at rest), and both test files. Verified on this head:

  • test/frame-layout.test.js + test/sidebar-switch.test.js: 107/107 pass.
  • Red-green: with all four client sources reset to origin/dev, frame-layout.test.js fails wholesale (the new tests import the missing measuredLeftInset export); sidebar-switch passes — consistent with the coverage analysis below.
  • node scripts/build-client.mjs --check clean (client.js genuinely regenerated), npm run lint 0 errors.

Answers to the review questions

1. Idempotency — mathematically convergent, and the convergence is self-arresting. correctRoom is additive: next = current + max(0, panelRight - columnLeft). Since columnLeft already includes current as its margin, the first application moves the column's left edge exactly to the panel's right edge, so overlap → 0 and every subsequent invocation is a no-op (the 0.5 px epsilon absorbs sub-pixel/rounding noise). Re-firing from RAF + ResizeObserver + transitionend simultaneously cannot ratchet: the second run measures the already-corrected geometry. Negative overlap is deliberately clamped — the inset never shrinks — so a host track that expands (or any geometry change that reduces overlap) leaves the margin too large: content sits too far right but stays visible, the safe direction. That is documented as an assumption and is the right call versus shrinking a user's layout. One real consequence: the correction can never undo an overshoot it created — see P2-1.

2. ResizeObserver feedback — bounded. RO fires on size changes, not position changes; margin-left moves the column's position, so the RO chain does not self-excite. The one theoretical path to oscillation (margin affecting the column's width in a shrink-to-fit layout) does not apply to the grid/fixed center column here. Skip conditions cover the moving states: active drag (activeDrag.current !== null), host mid-transition ([data-animating]), and the slide spring itself (springs.isRunning()); the settle path corrects only after the spring completes. Window resize legitimately re-measures since host layout may change.

3. Drag authority — preserved. The correction is inert throughout a drag (activeDrag check) and the drag's own per-frame writes are untouched. On release, the drag seeds width/margin from its own measured geometry; correctRoom then finds zero visible overlap in the normal case and fires nothing. The correction and the drag agree by construction because both derive from the same rendered truth — the panel's right edge — so no snap-back of the user's chosen position is possible; worst case the correction adds a small residual if the host track folded after the drag's snapshot, which is exactly the fix working as intended.

4. Bottom row — lifecycle correct, side effects minimal. --bt-left-inset resets to 0 both when the mode is hidden and on surface unmount; the padding is plugin-only CSS scoped to [data-shell-bottom], so with no host bottom bar it is a no-op on an absent element, and it cannot affect other plugins' rows unless they place content inside the same shell node — in which case the padding is precisely what keeps their content clear of the column too. One asymmetry worth noting: the bottom row uses uncorrected pushed while the center column uses the measured/corrected margin. If the correction ever adds overlap beyond pushed (panel rendered wider than its state width — transforms, zoom), the bottom row stays short of the correction. Rare and cosmetic; P2-2.

5. Tests and scope — the honest weakness. measuredLeftInset's arithmetic is pinned as a pure function, but correctRoom itself has no automated coverage of the actual fix: in jsdom every getBoundingClientRect returns zeros, and the one mocked rect ({left: 56}) produces zero overlap, so the integration path — measurement, additive application, skip conditions, settle ordering — is exercised by no test. The PR body overstates this slightly ("adds the settled-inset regression" refers to the pure-function math, not the wiring). I verified the wiring by reading, and the author verified it in a real DSH web shell with before/after geometry measurements (panel right 280 / center left 224 → 280), which for a geometry bug of this kind is the strongest available evidence short of a real-browser e2e. Scope is clean: only the overlap is served, no storage/protocol, rollback is a revert. client.js is genuinely rebuilt.

P2 (suggestions, not blocking)

  • P2-1: one-way ratchet can never correct downward. If any mechanism (another plugin's margin write, a host layout change that expands the sidebar track, a fractional-zoom rounding step) ever makes the inset too large, the correction cannot remove the excess — the margin sticks until a mode change recomputes targetMargin. Acceptable per the documented assumption, but if the host ever un-folds its track in Bot mode this becomes a visible rightward gap that only a drag or mode switch heals.
  • P2-2: bottom-row inset is uncorrected. --bt-left-inset is pushed exactly, while the center column can receive measured corrections beyond it. If divergent geometry is ever observed, mirroring the final corrected margin into setLeftInset at settle time would keep them consistent.
  • P2-3: effect re-registration per drag frame. The observer/listener effect depends on pushed/ourWidth, which change on every drag frame, so RO, listeners and timers are torn down and rebuilt continuously during a drag (all no-ops functionally, since correctRoom is inert then). Subscribing once with refs would cost less; purely a cleanliness point.
  • P2-4: [class*="_centerCol"]/_sidebarCol/_frame substring selectors remain host-DOM-coupled. Pre-existing pattern in this file, not introduced here, but the new code leans on it harder — a host class rename degrades the correction silently to the old snapshot behavior (which is what it replaced, so no worse than before).

Not verified

Windows DSH Desktop itself (verified by the author in macOS DSH web at 1600×900 with the same shell DOM); a filled plugin bottom bar; real-browser automated e2e of the correction loop (none exists in this codebase for shell geometry).

@github-actions github-actions Bot added review/approved Independent review passed — ready to merge reviewed-by/dsbot Reviewed by a DS Bot team Bot labels Dec 6, 2026
@Fei2411 Fei2411 added the reviewed-by/swe-2-1-max Reviewed by SWE-2.1 Max (independent read-only review) label Dec 6, 2026
The layout correction reuses the center column that the plugin adapter stamps instead of querying DSH class fragments, and rechecks after the host settles instead of observing its private frame nodes. The desktop selector guard requires app-loaded code to use only DS Bot data-bt-* contracts.
@github-actions github-actions Bot added review/re-review New commits pushed after last review — needs re-review and removed review/approved Independent review passed — ready to merge reviewed-by/dsbot Reviewed by a DS Bot team Bot labels Dec 6, 2026
The correction must not build the shared margin stylesheet: app-ready's fake document has no createElement. The adapter already stamps data-bt-center on the conversation column, so read that attribute directly.
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/deepseek-flash Written by a Bot on DeepSeek Flash needs-product-ok Waiting for maintainer product/UI approval before merging to dev review/re-review New commits pushed after last review — needs re-review 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