Skip to content

fix(DockView): persist active panel when renderer is always - #1284

Merged
ArgoZhang merged 3 commits into
masterfrom
fix-dockview-active-panel-persist
Nov 10, 2026
Merged

ArgoZhang merged 3 commits into
masterfrom
fix-dockview-active-panel-persist

Conversation

@zhaijunlei955

@zhaijunlei955 zhaijunlei955 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

关联 Issue

close #1285

现象

Renderer="DockViewRenderMode.Always" 时切换活动面板(点标签 / 切到别的分组),刷新页面后激活态回退到上一次保存的值。

原因

切标签只改 group.activePanel,不改变 grid 分割结构,gridview.onDidChange 不会触发。唯一的非结构变更落盘路径是 dockview-panel.js 的可见性回调,但它受 renderer === 'onlyWhenVisible' && inited 限制,Always 下完全不执行。因此该模式下切换活动面板从未写过配置。

拖拽移动面板同样会改变激活面板,但 core 在 _moving 期间不 fire onDidActivePanelChange,所以只补切标签覆盖不到这条路径。

修改

wwwroot/js/dockview-utils.js

  • 监听 onDidActivePanelChange,切换即 saveConfig;
  • 监听 onDidMovePanel 兜住拖拽/程序化移动。移动一组多面板时该事件按面板逐个 fire,用 0ms 定时器合并为一次落盘;
  • postLayoutInit 里的 _loadTabs 改取 group.activePanel,不再遍历 params.isActive 快照。

wwwroot/js/dockview-panel.js

  • 去掉可见性回调里的 saveConfig,避免与上面的监听重复写盘;
  • _loadTabs 同步改取 group.activePanel。这一步是必须的:params.isActive 原本靠那行 saveConfig 的副作用刷新,删掉后它就变成上一轮的旧值,_loadTabs 会发出过期 key,对应面板内容不加载(偶发空白)。group.activePanel 是 core 维护的实时值。

影响面

  • onlyWhenVisible 与 Always 两种模式均回归通过;
  • 拖拽、浮动、还原、关闭等既有落盘路径不受影响,多写一次不改变结果;
  • 不改序列化格式,旧配置可正常加载。

验证

  • 切换标签 → F5,激活面板保持;
  • 快速连续切换,无空白、无异常;
  • 拖拽调整顺序后 F5,顺序与激活态保持;
  • 浮动面板后还原 → F5,状态保持。

Summary by Sourcery

Persist DockView active-panel state reliably across refreshes in all rendering modes.

Bug Fixes:

  • Persist the active DockView panel when using the always-rendered mode, including changes caused by tab switches and panel moves.
  • Prevent stale active-panel state from causing panels to load incorrectly after visibility changes.

Enhancements:

  • Use DockView’s current active-panel state when loading visible tabs and consolidate panel-move persistence updates.

@sourcery-ai

sourcery-ai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Persist active-panel changes and coalesce move events into a save, while deriving loaded tabs from each group’s current active panel so stale activity snapshots cannot restore or load the wrong panel.

  • src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-panel.js L18
  • src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js L210-223 (+3 small edits)

Remove obsolete explanatory comments without changing the maximize, collapsed-save, or width-handling logic.

  • src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js L29-296 (4 small edits)

Configuration

Review the DockView project-file version change alongside the persistence fix.

  • src/components/BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj L4

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto

bb-auto Bot commented Nov 9, 2026

Copy link
Copy Markdown

Thanks for your PR, @zhaijunlei955. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@bb-auto
bb-auto Bot requested a review from ArgoZhang November 9, 2026 06:02

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js" line_range="223-224" />
<code_context>
+
+    // 拖拽期 core 会抑制上一条事件,程序化移动也不经 drop 处理器;0ms 合并掉一次操作的连续 fire
+    let movePanelTimer = null
+    dockview.onDidMovePanel(() => {
+        if (movePanelTimer) return
+        movePanelTimer = setTimeout(() => {
+            movePanelTimer = null
</code_context>
<issue_to_address>
**Some group merges are not persisted**

When a caller programmatically merges a group into another group at the center with `skipSetActive: true`, the merge empties the source group before DockView emits `onDidMovePanel`, and `skipSetActive: true` suppresses the active-panel save; the layout change is therefore not saved and is lost on refresh.

Ensure center merges emit a move event after completing, or explicitly save the layout for this programmatic move path.
</issue_to_address>

### Comment 2
<location path="src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js" line_range="218" />
<code_context>
         saveConfig(dockview)
     })

</code_context>
<issue_to_address>
**Older panel state overwrites newer state**

When server-side configuration persistence is enabled, the consumer performs asynchronous saves, and rapid panel changes cause an older save to complete after a newer one, each `saveConfig` call fires an independent asynchronous save callback without waiting for earlier calls. If the earlier save finishes last, it overwrites the newer panel selection, so a refresh restores the wrong active panel.

Serialize saves or attach a monotonically increasing revision so older snapshots cannot overwrite newer state.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@ArgoZhang ArgoZhang changed the title fix(DockView): persist active panel when renderer is always (#IKGH29) fix(DockView): persist active panel when renderer is always Nov 10, 2026
@bb-auto bb-auto Bot added the chore label Nov 10, 2026
@bb-auto bb-auto Bot added this to the v10.0.0 milestone Nov 10, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Linked issues

Checked at commit 1cd469b

#1285 fix(DockView): persist active panel when renderer is always · 1 of 1 met

# Requirement Status Notes
1 Persist the active panel when the renderer is always. ✅ Met Active-panel changes and panel moves trigger saveConfig; it records the current active-panel state for serialization.

@ArgoZhang
ArgoZhang merged commit 601ea24 into master Nov 10, 2026
3 checks passed
@ArgoZhang
ArgoZhang deleted the fix-dockview-active-panel-persist branch November 10, 2026 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(DockView): persist active panel when renderer is always

2 participants