From e6244c4cc9bafe305efb1564f32a36cd4aa7eda7 Mon Sep 17 00:00:00 2001 From: LegGasai Date: Tue, 17 Nov 2026 12:56:36 +0800 Subject: [PATCH] docs(session-panel): record why a pinned panel has the transcript make room --- .../2026-11-05-session-panel.i18n.yaml | 8 +-- .../feature/2026-11-05-session-panel.md | 6 +-- .../feature/2026-11-05-session-panel.zh.md | 6 +-- ...-16-session-panel-pin-makes-room.i18n.yaml | 31 +++++++++++ ...2026-11-16-session-panel-pin-makes-room.md | 51 +++++++++++++++++++ ...6-11-16-session-panel-pin-makes-room.zh.md | 51 +++++++++++++++++++ 6 files changed, 143 insertions(+), 10 deletions(-) create mode 100644 .agents/notes/implemented/feature/2026-11-16-session-panel-pin-makes-room.i18n.yaml create mode 100644 .agents/notes/implemented/feature/2026-11-16-session-panel-pin-makes-room.md create mode 100644 .agents/notes/implemented/feature/2026-11-16-session-panel-pin-makes-room.zh.md diff --git a/.agents/notes/implemented/feature/2026-11-05-session-panel.i18n.yaml b/.agents/notes/implemented/feature/2026-11-05-session-panel.i18n.yaml index 2ef5bf0f10..9c64e0e783 100644 --- a/.agents/notes/implemented/feature/2026-11-05-session-panel.i18n.yaml +++ b/.agents/notes/implemented/feature/2026-11-05-session-panel.i18n.yaml @@ -21,8 +21,8 @@ en: 08e720a4ea75d4d6 zh: 5e2e5b8452f67d36 /agent-note-session-panel-in-the-chat-view-s-end-gutter/alternatives-considered: - en: 6adaf7a36da05668 - zh: c0ace7297995d764 + en: 06f473c9dda80cb7 + zh: 974f7b94a46f9a2c /agent-note-session-panel-in-the-chat-view-s-end-gutter/consequences: - en: 0b6e547a08c042bc - zh: 154a69e3f54692cd + en: 0392945cc28a0e6d + zh: 9ea6cf996a380dd1 diff --git a/.agents/notes/implemented/feature/2026-11-05-session-panel.md b/.agents/notes/implemented/feature/2026-11-05-session-panel.md index 7ef1e8f306..60b303a766 100644 --- a/.agents/notes/implemented/feature/2026-11-05-session-panel.md +++ b/.agents/notes/implemented/feature/2026-11-05-session-panel.md @@ -39,14 +39,14 @@ The turn rail sits at the scrollport's start edge with its marks, focus ring, an - **The dock kit's floating window.** `FloatLayer` windows are draggable, resizable, and positioned in viewport coordinates; a summary anchored to the transcript gutter needs none of that and would have to fight the window's own placement rules. - **Viewport-width breakpoints.** The transcript width is adaptive and draggable and the right sidebar takes a variable track, so a viewport breakpoint either covers the transcript or hides the panel with room to spare. - **CSS-only hiding with a click-time read.** A container query on the gutter can hide the docked panel, and the toggle could read the computed result when pressed, as the background-job trigger does. The toggle would still render without knowing whether the panel shows, so `aria-expanded` and its tooltip would be wrong whenever the preference says dock but the gutter is too narrow. -- **Squeezing the transcript to make room.** Docking on laptop widths by moving the transcript column aside changes the centered column, the composer, and both width handles; it remains a separate layout decision. +- **Squeezing the transcript to make room by default.** Docking on laptop widths by moving the transcript column aside changes the centered column, the composer, and both width handles without the reader asking. The transcript makes room only for a panel the reader pins ([decision](2026-11-16-session-panel-pin-makes-room.md)). - **A Session-scoped standard hook for the gutter.** Adding a hook to every Session-scoped Slot would make every component fixture in the client restate it; the docking decision has two readers, the panel and the toggle, and both read it from the plugin's own state. ## Consequences -- With the default transcript width, which stops at 880px, the body must be 1576px wide to dock, so laptop widths use the overlay; the panel never covers the transcript unless the user opens it. +- With the default transcript width, which stops at 880px, the body must be 1576px wide to dock, so laptop widths use the overlay unless the reader [pins the panel](2026-11-16-session-panel-pin-makes-room.md); the panel never covers the transcript unless the user opens it. - Sections from independent plugins share one surface, ordering, and title style without depending on each other, and an occupied section id can be replaced by a higher-priority registration. -- `ui-chat` gained one slot and one custom property on its layer and observes nothing for them. Each mounted panel adds one `ResizeObserver` on its dock probe, which calls back only when the docking decision flips. `ui-conversation` caps the default transcript width at 880px. +- `ui-chat` gained one slot and one custom property on its layer and observes nothing for them. Each mounted panel adds one `ResizeObserver` on each of its two probes, which call back only when a docking decision flips. `ui-conversation` caps the default transcript width at 880px. - The panel shows only in Chat Views; elsewhere the toggle stays in the header, unavailable. Every Chat View occurrence renders the aside, so a Session shown in the main body and in an embedded Conversation at once shows its overlay in both. - The turn rail's position changed for every user; its behavior and hiding rule did not. - Change requests, background jobs, and subagents became sections, replacing the change requests sidebar tab, its start-page entry, and the header controls of jobs and subagents; the header keeps the subagent breadcrumb switcher for child Sessions. A section mounts only while the panel shows, so state that must outlast hiding the panel, such as cleared job rows, lives in a per-Session slot store. diff --git a/.agents/notes/implemented/feature/2026-11-05-session-panel.zh.md b/.agents/notes/implemented/feature/2026-11-05-session-panel.zh.md index 5a2a4bada2..1a3e3b6264 100644 --- a/.agents/notes/implemented/feature/2026-11-05-session-panel.zh.md +++ b/.agents/notes/implemented/feature/2026-11-05-session-panel.zh.md @@ -39,14 +39,14 @@ Status: implemented - **dock kit 的悬浮窗。** `FloatLayer` 窗口可拖拽、可缩放、按视口坐标定位;锚定在正文留白的摘要用不上这些能力,还要对抗窗口自身的定位规则。 - **按视口宽度断点。** 正文宽度自适应、可拖拽,右侧栏占用可变宽度,视口断点要么遮挡正文,要么在空间充足时也隐藏面板。 - **纯 CSS 隐藏加点击时读取。** 对留白做容器查询可以隐藏停靠面板,开关在按下时读取计算结果,与后台任务按钮的做法相同。但开关渲染时仍不知道面板是否显示,偏好为停靠而留白不足时,`aria-expanded` 与提示文字都会出错。 -- **挤压正文腾出空间。** 在笔记本宽度下把正文列移开来停靠,会改变居中的正文列、composer 和两侧宽度拖拽条;这仍是另一项布局决策。 +- **默认挤压正文腾出空间。** 在笔记本宽度下把正文列移开来停靠,会在用户没有要求的情况下改变居中的正文列、composer 和两侧宽度拖拽条。正文只为用户固定的面板让位([决策](2026-11-16-session-panel-pin-makes-room.zh.md))。 - **会话作用域标准 hook。** 给每个会话作用域 Slot 增加一个留白 hook,会让客户端所有组件测试夹具都要补上它;停靠判断只有两个读取方,即面板和开关,两者都从插件自己的状态读取。 ## Consequences -- 默认正文宽度最多 880px,此时对话区要 1576px 宽才能停靠,因此笔记本宽度使用浮层;除非用户主动打开,面板不会遮挡正文。 +- 默认正文宽度最多 880px,此时对话区要 1576px 宽才能停靠,因此笔记本宽度使用浮层,除非用户[固定面板](2026-11-16-session-panel-pin-makes-room.zh.md);除非用户主动打开,面板不会遮挡正文。 - 独立插件的分栏共享同一界面、排序和标题样式,彼此不依赖;已占用的分栏 id 可以被更高优先级的注册替换。 -- `ui-chat` 多了一个 slot,侧边层多了一个自定义属性,但不为它们观察任何尺寸。每个已挂载的面板在停靠探针上多一个 `ResizeObserver`,只在停靠判断翻转时回调。`ui-conversation` 把默认正文宽度上限定为 880px。 +- `ui-chat` 多了一个 slot,侧边层多了一个自定义属性,但不为它们观察任何尺寸。每个已挂载的面板在它的两个探针上各多一个 `ResizeObserver`,只在某项停靠判断翻转时回调。`ui-conversation` 把默认正文宽度上限定为 880px。 - 面板只出现在 Chat 视图中;其他视图下开关仍在标题栏中,但不可用。每个 Chat 视图实例都会渲染侧边层,因此同一会话同时显示在主正文区和嵌入的对话中时,两处都会显示浮层。 - 轮次轨道的位置对所有用户都变了;行为和隐藏规则不变。 - 变更请求、后台任务和子智能体成为分栏,取代变更请求侧边栏标签页、其起始页入口,以及标题栏中的后台任务和子智能体控件;标题栏仍为子会话保留子智能体面包屑切换器。分栏只在面板显示时挂载,因此需要在隐藏面板后保留的状态(例如已清空的任务行)放在按会话划分的 slot store 中。 diff --git a/.agents/notes/implemented/feature/2026-11-16-session-panel-pin-makes-room.i18n.yaml b/.agents/notes/implemented/feature/2026-11-16-session-panel-pin-makes-room.i18n.yaml new file mode 100644 index 0000000000..821f96c1b7 --- /dev/null +++ b/.agents/notes/implemented/feature/2026-11-16-session-panel-pin-makes-room.i18n.yaml @@ -0,0 +1,31 @@ +# Bilingual-pair consistency record for 2026-11-16-session-panel-pin-makes-room.md (docs/i18n/README.md): per heading +# section, a hash of its English and Chinese blocks outside code blocks and generated regions. +# After editing either side, bring the other along and re-record with: +# pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-11-16-session-panel-pin-makes-room.md +/agent-note-a-pinned-session-panel-has-the-transcript-make-room: + en: 0ff27427fe39e917 + zh: 785c97d304a8251c +/agent-note-a-pinned-session-panel-has-the-transcript-make-room/problem: + en: b057ffba84f49cc0 + zh: a94da96e3b88cb22 +/agent-note-a-pinned-session-panel-has-the-transcript-make-room/decision: + en: 28d74b94f88d4f62 + zh: 1bd7b0bc7e84711f +/agent-note-a-pinned-session-panel-has-the-transcript-make-room/decision/the-body-owns-the-room-and-the-panel-asks-for-it: + en: 32162a47eda3346b + zh: ef504938f57d89ad +/agent-note-a-pinned-session-panel-has-the-transcript-make-room/decision/two-probes-that-do-not-depend-on-the-pin: + en: 346ddc000d737c97 + zh: 91b930b9ea79baa6 +/agent-note-a-pinned-session-panel-has-the-transcript-make-room/decision/the-pin-and-the-docking-preference-stay-separate: + en: 97af1842a791d745 + zh: 938605942fd434a1 +/agent-note-a-pinned-session-panel-has-the-transcript-make-room/alternatives-considered: + en: 0867c07f5397ef57 + zh: 04a75d241d8049a6 +/agent-note-a-pinned-session-panel-has-the-transcript-make-room/consequences: + en: 943b71da99af20f2 + zh: b7d8e5c15ab92ce4 +/agent-note-a-pinned-session-panel-has-the-transcript-make-room/testing: + en: 8983497f0b7c2230 + zh: d7c4a7e93643d25d diff --git a/.agents/notes/implemented/feature/2026-11-16-session-panel-pin-makes-room.md b/.agents/notes/implemented/feature/2026-11-16-session-panel-pin-makes-room.md new file mode 100644 index 0000000000..9600515ff9 --- /dev/null +++ b/.agents/notes/implemented/feature/2026-11-16-session-panel-pin-makes-room.md @@ -0,0 +1,51 @@ +# Agent Note: A pinned Session panel has the transcript make room + +Status: implemented + +English | [中文](2026-11-16-session-panel-pin-makes-room.zh.md) + +## Problem + +The [Session panel](2026-11-05-session-panel.md) docks only in a 348px end gutter. With the default transcript width that takes a Chat frame 1576px wide, and the left sidebar takes 280px of the window, so no window under about 1860px docks the panel. On 1440px, 1512px, and 1728px windows it shows only as the overlay, which closes on the next press outside it. A reader who wants running subagents, background jobs, or change requests in view while working cannot keep the panel open at those widths. The docking preference does not help: it says whether the panel shows where it already has room. + +## Decision + +The panel carries a pin: a toggle button in its top end corner, one preference for every Session, persisted in `localStorage` under `dsh.sessionPanel.held` and off by default. While the pin and the docking preference are both on and the gutter is narrower than 348px, the Conversation body keeps that gutter free. The transcript column and the composer move toward the start edge by the missing gutter at their own widths; once the column is 32px from the start edge it narrows instead. The panel then docks, and neither Escape nor an outside press hides it. The body makes no room when that would leave the column under 480px, a Chat frame under 860px; a pinned panel then behaves as an unpinned one until the frame is wide enough again. An unpinned panel behaves as it did. + +### The body owns the room, and the panel asks for it + +[`ui-conversation`](../../../../packages/client/ui-conversation/README.md#end-reserve) owns the transcript's width axis, the scrollport, and the width handles, so it owns the room. A stylesheet asks for it by setting `--dsh-chat-end-reserve` on the Conversation body; the body derives `--dsh-chat-end-inset`, the scrollport's end padding, and `--dsh-chat-end-reserve-max`, the largest reserve that leaves a 480px column. The panel's stylesheet sets the reserve to 348px through a `:has()` rule that matches while its gutter probe carries a mark, so the request needs no Slot prop and no render in the Chat View. + +The body derives those lengths from the scrollport's width, which it measures and publishes as `--dsh-conversation-viewport-width`. Three boxes read the inset: the scrollport for its padding, the width handles in the body, and the [`ui-chat`](../../../../packages/client/ui-chat/README.md#scroll-ownership) aside layer, which reaches back across the inset so the panel sits at the scrollport's end edge. A length written with percentages resolves against a different box in each of them, and the scrollport's own content box changes with the inset. A measured pixel width gives all three the same value and does not change when the inset does. + +### Two probes that do not depend on the pin + +The panel reports two facts through 1px probes: its gutter holds it as the transcript stands, and the transcript can make that room. The gutter that the aside layer publishes counts the inset, and the gutter probe subtracts it, so a gutter the transcript made reads as no gutter. The plugin combines the facts with the pin: a panel can dock when its gutter holds it, or when the pin is on and the transcript can make room. + +Keeping both facts independent of the pin gives the plugin what it needs before a press. It offers the pin on an overlay only where pinning would dock the panel. When the reader unpins a panel that only the pin kept beside the transcript, it knows the panel is about to lose its place and leaves it open as the overlay instead of removing it under the pointer. The room the transcript makes cannot change the decision that asked for it, so the layout cannot oscillate. + +### The pin and the docking preference stay separate + +The header toggle still hides and shows a pinned panel by flipping the docking preference, and hiding it gives the room back. Pinning also turns the docking preference on, because a reader who pins a panel wants it shown. The docking preference keeps its `localStorage` key, `dsh.sessionPanel.pinned`, so stored choices survive; the plugin's state calls it `docks` and the pin `pinned`. + +## Alternatives considered + +- **A pinned panel covers the transcript.** It needs no layout change, but on a 1440px window the panel covers about 83px of the transcript column, and the actions at the end of each message, for as long as it is pinned. A panel kept open for a whole Session must not hide part of every reply. +- **Making room whenever the panel shows.** It changes the transcript's position and width for every reader at laptop widths without a request. The [panel's own decision](2026-11-05-session-panel.md) keeps the transcript untouched by default, and the pin makes the trade the reader's choice. +- **A measured reserve passed through Slot props.** The Conversation body, the Chat View, and the aside would each forward a callback for one consumer, and every change of the reserve would render the Chat View. A custom property needs neither. +- **Percentages without a published width.** The inset would differ between the scrollport, the width handles, and the aside layer, and the test for a 480px column would read a width that the inset itself narrows. +- **One probe whose rule follows the pin.** The plugin would not know whether an unpinned overlay can be pinned, or whether unpinning leaves the panel without room. +- **Width handles while the transcript makes room.** The handles sit at the centered column's edges and a drag widens the column about its center. With the column's end edge held by the reserve, a drag would move only the start edge, at twice the pointer's speed. The handles do not show until the transcript centers again. +- **Making room in embedded Chat Views.** An embedded transcript's width is a percentage of its frame, so the inset would need that frame's own measure, and embedded frames are rarely 860px wide. An embedded Chat View makes no room. + +## Consequences + +- A reader can keep the panel beside the transcript on laptop widths. On a 1440px window with the sidebar open, the 742px column keeps its width and moves 143px toward the start; on a 1280px window it narrows to 613px. +- Below an 860px Chat frame the pin has no effect, and the panel is the overlay it was. +- The width handles do not show while the transcript makes room; the reader unpins or hides the panel to drag the width. +- `ui-conversation` publishes the scrollport's width and two derived lengths and pads its scrollport's end; `ui-chat`'s aside layer has an end margin and a gutter that counts the inset. Neither renders or observes anything more for them. +- Each mounted panel observes two probes instead of one; both call back only when a decision flips. + +## Testing + +Unit specs read the three stylesheets and evaluate the reserve, the inset, the gutter, and both probes around their boundaries. `apps/web/tests/session-panel-layout.e2e.ts` measures the shipped Web composition: the column, the composer, the width handles, the probes, the panel, and the pin while pinning, narrowing to the 480px column, crossing that boundary, reloading, hiding from the toggle, and unpinning. diff --git a/.agents/notes/implemented/feature/2026-11-16-session-panel-pin-makes-room.zh.md b/.agents/notes/implemented/feature/2026-11-16-session-panel-pin-makes-room.zh.md new file mode 100644 index 0000000000..e83bd9e5e7 --- /dev/null +++ b/.agents/notes/implemented/feature/2026-11-16-session-panel-pin-makes-room.zh.md @@ -0,0 +1,51 @@ +# Agent Note: 固定的会话面板让正文让出位置 + +Status: implemented + +[English](2026-11-16-session-panel-pin-makes-room.md) | 中文 + +## Problem + +[会话面板](2026-11-05-session-panel.zh.md)只在 348px 的末端留白里停靠。默认正文宽度下,这要求 Chat 外框宽 1576px,而左侧栏占去窗口 280px,因此约 1860px 以下的窗口都无法停靠面板。在 1440px、1512px 和 1728px 的窗口里,面板只能以浮层显示,在面板外按下指针就会关闭。想在工作时一直看到运行中的子智能体、后台任务或变更请求的用户,在这些宽度下无法让面板保持打开。停靠偏好帮不上忙:它只决定面板在已有空间的地方是否显示。 + +## Decision + +面板带一个图钉:位于面板顶部末端角的切换按钮,所有会话共用一个偏好,存放在 `localStorage` 的 `dsh.sessionPanel.held` 中,默认关闭。图钉和停靠偏好都开启、且留白窄于 348px 时,Conversation 主体空出这段留白。正文列和输入框保持各自宽度,向起始边缘移动所缺的留白;正文列距起始边缘只剩 32px 后,改为变窄。面板随即停靠,按 Esc 或在面板外按下指针都不会隐藏它。如果让位会使正文列窄于 480px,也就是 Chat 外框窄于 860px,主体不让位;此时已固定的面板与未固定时相同,直到外框再次够宽。未固定的面板行为不变。 + +### 位置归主体所有,面板提出申请 + +[`ui-conversation`](../../../../packages/client/ui-conversation/README.zh.md#end-reserve) 拥有正文的宽度轴、滚动容器和宽度手柄,因此这段位置也归它所有。样式表在 Conversation 主体上设置 `--dsh-chat-end-reserve` 来提出申请;主体据此推出滚动容器的末端内边距 `--dsh-chat-end-inset`,以及让正文列保持 480px 时能给出的最大预留 `--dsh-chat-end-reserve-max`。面板的样式表通过一条 `:has()` 规则把预留设为 348px,该规则在留白探针带有标记时匹配,因此申请不需要 Slot 属性,也不会让 Chat 视图重新渲染。 + +主体从滚动容器的宽度推出这些长度;它测量该宽度并发布为 `--dsh-conversation-viewport-width`。有三个盒子读取内边距:滚动容器用它作内边距,主体中的宽度手柄用它定位,[`ui-chat`](../../../../packages/client/ui-chat/README.zh.md#scroll-ownership) 的侧边层用它越过内边距延伸回去,让面板位于滚动容器的末端边缘。用百分比写出的长度在这三处会按不同的盒子解析,而滚动容器自身的内容盒又随内边距变化。测量得到的像素宽度让三处取得同一个值,并且不随内边距改变。 + +### 两个不依赖图钉的探针 + +面板通过 1px 的探针报告两项事实:正文不动时留白放得下面板,以及正文能让出这段位置。侧边层发布的留白包含内边距,留白探针再把它减掉,因此正文让出的留白不算作留白。插件把这两项事实与图钉结合:留白放得下面板,或者图钉已开启且正文能让位时,面板可以停靠。 + +两项事实都不依赖图钉,插件因此在按下之前就掌握所需信息。只有固定后能停靠时,它才在浮层上提供图钉。用户取消固定一个仅靠图钉留在正文旁的面板时,它知道面板即将失去位置,于是让面板保持打开并变为浮层,而不是在指针下把它移走。正文让出的位置不会改变提出让位的那项判断,布局因此不会来回振荡。 + +### 图钉与停靠偏好保持独立 + +标题栏开关仍然通过切换停靠偏好来隐藏和显示已固定的面板,隐藏后让出的位置还给正文。固定面板同时会开启停靠偏好,因为固定面板的用户希望它显示出来。停靠偏好沿用 `localStorage` 键 `dsh.sessionPanel.pinned`,已保存的选择得以保留;插件状态中把它称为 `docks`,把图钉称为 `pinned`。 + +## Alternatives considered + +- **固定的面板盖在正文上。** 不需要改动布局,但在 1440px 的窗口里,只要面板处于固定状态,就会一直遮住正文列约 83px 以及每条消息末尾的操作按钮。整个会话期间都打开的面板不能遮住每条回复的一部分。 +- **面板一显示就让位。** 这会在用户没有要求的情况下,改变笔记本宽度下所有用户的正文位置和宽度。[面板自身的决策](2026-11-05-session-panel.zh.md)默认不动正文,图钉把这项取舍交给用户选择。 +- **通过 Slot 属性传递测量出的预留值。** Conversation 主体、Chat 视图和侧边层都要为这一个使用方转发回调,预留值每次变化还会让 Chat 视图重新渲染。自定义属性两者都不需要。 +- **只用百分比,不发布宽度。** 内边距在滚动容器、宽度手柄和侧边层中会取得不同的值,而判断能否保留 480px 正文列时读到的宽度又会被内边距本身收窄。 +- **一个探针,规则随图钉变化。** 插件将无法知道未固定的浮层能否固定,也无法知道取消固定后面板是否还有位置。 +- **正文让位期间保留宽度手柄。** 手柄位于居中正文列的两侧,拖动时正文列以中心为基准变宽。正文列的末端边缘被预留固定后,拖动只会移动起始边缘,速度是指针的两倍。手柄在正文重新居中之前不显示。 +- **在嵌入的 Chat 视图中让位。** 嵌入的正文宽度是其外框的百分比,内边距需要该外框自己的测量值,而嵌入的外框很少有 860px 宽。嵌入的 Chat 视图不让位。 + +## Consequences + +- 用户可以在笔记本宽度下把面板留在正文旁。在侧栏展开的 1440px 窗口里,742px 的正文列宽度不变,向起始方向移动 143px;在 1280px 的窗口里,正文列收窄到 613px。 +- Chat 外框窄于 860px 时图钉不起作用,面板仍是原来的浮层。 +- 正文让位期间不显示宽度手柄;用户需要取消固定或隐藏面板后再拖动宽度。 +- `ui-conversation` 发布滚动容器的宽度和两个推出的长度,并给滚动容器的末端加内边距;`ui-chat` 的侧边层多了末端外边距,其留白包含内边距。两者都没有为此增加渲染或观察。 +- 每个已挂载的面板观察两个探针而不是一个;两者都只在判断翻转时回调。 + +## Testing + +单元测试读取三份样式表,并在边界附近计算预留、内边距、留白和两个探针的取值。`apps/web/tests/session-panel-layout.e2e.ts` 在随产品发布的 Web 组合中测量:固定、收窄到 480px 正文列、越过该边界、刷新页面、用开关隐藏以及取消固定时的正文列、输入框、宽度手柄、探针、面板和图钉。