Skip to content

Sidebar Layout: switch the right sidebar between push, drawer and body - #31

Open
klarkxy wants to merge 2 commits into
mainfrom
lacquered-lovelace
Open

klarkxy wants to merge 2 commits into
mainfrom
lacquered-lovelace

Conversation

@klarkxy

@klarkxy klarkxy commented Nov 21, 2026

Copy link
Copy Markdown
Owner

改动 / Change

新增客户端插件 @klarkxy/dsh-sidebar-layout(生命周期 draft),把宿主原生右侧边栏(dsh-client-ui-sidebar-right)在三种呈现方式间切换:

  • 常规 (push):宿主默认,面板挤压对话列。
  • 抽屉 (drawer):面板覆盖在对话之上,对话保持完整宽度;对话列叠加半透明遮罩,点击遮罩收起面板;原拖拽手柄仍调整面板宽度。
  • 正文 (swap):面板进入中间列作为正文,对话移到右侧列;宿主拖拽手柄此时调整对话列宽度。

实现:给宿主 AppFrame 与中间列打插件自有属性标记(替代 :has() 选择器——better-sidebar 记载过流式更新时的 restyle 开销),注入一份按属性分组的样式表驱动三种布局;不修补宿主内部 API,不覆盖 dsh-better-sidebar 的任何属性与规则,可与 dsh-better-sidebar 同时使用。

切换入口(同一份全局状态,浏览器本地持久化):

  • 会话头部 conversation.session.header.utilities 图标按钮弹出菜单(常规/抽屉/正文,当前勾选);选抽屉或正文时若面板收起会自动展开。
  • 「设置 → 通用」sidebar-layout/40 行,原生 select(dsh-ui-select)。
  • 快捷键命令 sidebar.layout.cycle,默认 Ctrl/Cmd+Alt+Shift+B 循环三种方式(web:linux 不支持三修饰键默认,留空由用户自绑)。

约束:面板全屏与 <768px 自动全屏在所有方式下保持宿主原样;宿主在空间不足时的自动收起行为不变。

Standalone client plugin: three presentations for the native right Sidebar — push, drawer overlay with a click-to-dismiss mask, and an IDE-style swap where the panel becomes the body and the conversation moves right. Driven by a tagged-attribute stylesheet; no host internals patched; works alongside dsh-better-sidebar.

测试 / Tests

  • pnpm --filter @klarkxy/dsh-sidebar-layout test:27/27(mode store 持久化/非法值回退/storage 同步、frame 定位与重挂、遮罩点击边界、快捷键循环与会话缺失容错、席位注册形态)
  • pnpm --filter @klarkxy/dsh-sidebar-layout typecheck / build
  • node --test scripts/plugin-settings.test.mjs 4/4、pnpm test:editor-build 62、pnpm release:check 78、pnpm pack:check、git diff --check

界面验收 / UI acceptance

侧栏布局:头部菜单 → 抽屉(遮罩点击收起)→ 正文(拖拽手柄调宽)→ 全屏还原

  • 录制 commit:ba09e7b(GIF 录制于提交前,工作区代码与本分支 head 完全相同,无后续界面改动)。
  • 录制环境:.agents/skills/dsh-web-acceptance/ 隔离 dsh web(临时 HOME/DSH_HOME/DSH_AGENTS_HOME),安装 dsh-better-sidebar@0.32.1;qa-report.json 无页面错误、控制台错误和 HTTP 错误。
  • 覆盖场景:头部「侧栏布局」菜单 → 抽屉打开(对话不缩放+遮罩)→ 点击遮罩收起 → 正文(面板入主列,better-sidebar 文件/Git/任务管理标签页正常)→ 拖拽手柄左右缩放对话列(实测 handle 与列边界贴合,拖动量与列宽变化 1:1)→ 全屏切换保持宿主行为 → 「设置 → 通用」下拉与布局双向同步 → Ctrl+Alt+Shift+B 循环。

Generated with Devin

klarkxy and others added 2 commits November 21, 2026 13:56
New client-only plugin @klarkxy/dsh-sidebar-layout. It tags the host
AppFrame and its centre column with plugin-owned attributes (a tagged
node instead of a :has() selector — better-sidebar documents the restyle
cost during streaming), and one injected stylesheet drives the layouts:

- drawer: centre spans the right track so the panel overlays a
  conversation that keeps full width; an ::after mask dims it and a
  click on the mask collapses the panel via ctx.sidebarRight.
- swap ("正文"): the columns trade grid positions — the panel fills the
  centre as the body, the conversation becomes the right column, and
  the host's drag handle resizes the conversation. Windows/macOS chrome
  radii and macOS leading clearance follow the surfaces.

Mode persists browser-local (localStorage) and is shared by three
entry points: a header utilities menu, a Settings > General row
(id sidebar-layout/40), and the sidebar.layout.cycle command bound to
primary+alt+shift+B on every admissible profile. Fullscreen and the
<768px auto-fullscreen are excluded everywhere. Compatible with
dsh-better-sidebar's native tabs and centre-column rules.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
klarkxy pushed a commit that referenced this pull request Nov 21, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

Devin Review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 13 个新增插件文件使用了 CRLF

仓库要求使用 LF。提交中的源码、配置和双语 README 共 13 个文件使用 CRLF,本地 git diff --check 将其报为行尾空白。

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +131 to +142
it('retags a replaced frame', async () => {
const { dom } = mountClient()
const root = dom.window.document.getElementById('root')!
const old = dom.window.document.getElementById('frame')!
const next = old.cloneNode(true) as Element
next.id = 'frame-2'
old.replaceWith(next)
// The MutationObserver delivery is asynchronous.
await new Promise(resolve => setTimeout(resolve, 0))
expect(next.getAttribute(FRAME_ATTRIBUTE)).toBe('push')
expect(next.querySelector('.centre')!.hasAttribute(CENTER_ATTRIBUTE)).toBe(true)
expect(root.contains(old)).toBe(false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 重挂载测试在没有观察器时也能通过

深拷贝会把两个待验证的布局标记一起复制过去。改用未标记的节点,才能测到观察器是否为新框架恢复布局。

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

This branch has not been deployed

No deployments
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