Skip to content

fix(client): 侧栏记忆入口锚定新会话行,防生态插件挤位 (#130) - #134

Merged
modusensus merged 1 commit into
mainfrom
fix/sidebar-entry-order-130
Sep 11, 2026
Merged

modusensus merged 1 commit into
mainfrom
fix/sidebar-entry-order-130

Conversation

@modusensus

@modusensus modusensus commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

问题

任务看板 / 技能中心等生态插件会把各自的侧栏入口插在「新会话」行之后(后插入者在上);而我们的记忆入口固定插在 regionArea 之前,于是被打成插件入口组的末尾——记忆按钮被顶到任务看板/技能中心下面,视觉上成了孤立位(issue #130 截图)。

根因

  • 生态插件共用 linxin666 系 sidebar-entry-core:占位规则 =「紧跟新会话行(logoRow)之后」,且只在自身节点被移除时才重插。
  • 我们的 portal 宿主 insertBefore(created, regionArea) 一次性放置,位置完全取决于插件安装/挂载时序。

修复

  • 占位锚点改为紧跟新会话行:logoRow 行(现役外壳)或直接子按钮(旧外壳)判定与生态 core 一致;锚点不可靠时回退到 regionArea 之前的旧位置。
  • 幂等重排:MutationObserver 回调里发现错位才搬回。生态插件后插入时我们把位置抢回;对方不会响应(它们只在被移除时重插),不会形成拉锯。
  • 关键边界(本地实测踩中):created 已紧跟锚点时 target === created,必须短路返回——insertBefore(x, x) 在 Chromium 里不是 no-op,会触发 childList mutation 造成观察器自激风暴,冻死整个 SPA。已用最小 DOM 实验证实该行为并修复。

验证

  • 全量测试 746 绿(新增 1 个 安装其他插件时,记忆按钮会被顶到下面,不是很好看。 #130 行为测试 + 更新 1 个受影响断言)。
  • web 8788(junction 直载本分支)+ 已装任务看板/SSH/技能中心实测:
    • 侧栏顺序稳定为 新建会话 → 记忆 → 任务看板 → SSH → 技能中心 → 工作区,多次交互/等待无漂移;
    • 入口点击正常打开记忆面板。

Closes #130

Summary by CodeRabbit

  • Bug Fixes
    • Sidebar entries now appear directly after the New Session row, providing more consistent placement across supported shell layouts.
    • Sidebar placement is maintained when other entries are added, preventing unexpected movement or duplication.

任务看板/技能中心等生态插件(linxin666 sidebar-entry-core 系)把入口
插在新会话行后且后插入者在上;我们固定在 regionArea 之前,被打成入口
组末尾的孤立位(issue #130 截图:记忆按钮被顶到任务看板/技能中心下)。

- 占位锚点改为紧跟新会话行(logoRow/直接子按钮判定与生态 core 一致,
  锚点不可靠时回退 regionArea 之前的旧位置)
- MutationObserver 里幂等重排:已在锚点位不写 DOM;生态插件后插入时
  搬回,对方只在自身节点被移除时才重插,不会来回争抢
- 关键边界:created 已紧跟锚点时 target 即 created 自身,必须短路返回
  ——insertBefore(x, x) 在 Chromium 里不是 no-op,会触发 childList
  mutation 造成观察器自激风暴冻死 SPA(本地实测踩中并已验证修复)

web 8788 junction 直载实测:新建会话 → 记忆 → 任务看板 → SSH →
技能中心 → 工作区,顺序稳定无漂移,入口点击正常打开记忆面板。
@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: e6a466ae-26c0-4770-9039-37b1ada5e3e1

📥 Commits

Reviewing files that changed from the base of the PR and between df61f13 and b85f2c0.

📒 Files selected for processing (2)
  • dsh-mneme/lib/client.js
  • dsh-mneme/test/client.test.js

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The sidebar entry now anchors after the host New-Session row, supports old and current shell structures, avoids redundant DOM mutations, and repositions itself after ecosystem-injected DOM changes. Tests cover anchor resolution, fallback placement, idempotency, and observer-driven repositioning.

Changes

Sidebar entry placement

Layer / File(s) Summary
Anchor resolution and idempotent placement
dsh-mneme/lib/client.js
findAnchor resolves the host New-Session row. place inserts the entry after that row, falls back before regionArea, and skips redundant or self-targeted insertion. Initial and observer-driven placement use place.
Placement behavior tests
dsh-mneme/test/client.test.js
Tests verify New-Session adjacency, fallback placement, idempotent behavior, and repositioning after child-list mutations.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

Sequence Diagram(s)

sequenceDiagram
  participant SidebarTopEntry
  participant HostDOM
  participant MutationObserver
  SidebarTopEntry->>HostDOM: Resolve the newSession anchor
  SidebarTopEntry->>HostDOM: Place the entry after the anchor
  HostDOM-->>MutationObserver: Report childList changes
  MutationObserver->>SidebarTopEntry: Re-run place
Loading

Suggested reviewers: small-tailqwq

Merge Risk: ⚪ Minimal · up to b85f2

The sidebar placement change has no remaining actionable risk identified for merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: anchoring the sidebar memory entry to the new-session row to prevent ecosystem plugins from displacing it.
Linked Issues check ✅ Passed PR #130 的编码目标是修复安装生态插件后记忆入口位置错误的问题。dsh-mneme/lib/client.js 新增新会话行锚点查找、锚点失效回退、幂等重排和 MutationObserver 重排逻辑,并避免 insertBefore(x, x)。dsh-mneme/test/client.test.js 覆盖新会话相邻位置及生态插件插入后的重新定位。摘要还报告全量 746…
Out of Scope Changes check ✅ Passed 变更仅涉及记忆入口的侧栏定位逻辑及其测试。锚点兼容、回退、观察器重排和防自激循环均直接支持 Issue #130 的侧栏布局目标。没有证据表明存在无关功能变更。
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sidebar-entry-order-130

Warning

Some tools did not complete. Review the errors below.

🔧 ast-grep (0.45.3)
dsh-mneme/lib/client.js

ast-grep timed out on this file


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@modusensus modusensus self-assigned this Sep 11, 2026
@modusensus
modusensus merged commit 7c91918 into main Sep 11, 2026
9 checks passed
@modusensus
modusensus deleted the fix/sidebar-entry-order-130 branch September 11, 2026 20:52
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