dsh-workspaces-scroll 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.en.md +75 -0
- package/README.md +74 -2
- package/client.js +560 -0
- package/cordis.patch.yml +5 -0
- package/docs/DETAIL.md +1 -0
- package/docs/DETAIL.zh.md +1 -0
- package/docs/RELEASE.md +111 -0
- package/docs/preview-00.gif +0 -0
- package/docs/preview-01.gif +0 -0
- package/docs/preview.svg +48 -0
- package/icon.svg +8 -0
- package/index.js +56 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +53 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jimmm-Yuuu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# dsh-workspaces-scroll
|
|
2
|
+
|
|
3
|
+
[简体中文](README.md) · **English**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-workspaces-scroll)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
DeepSeek Harness plugin. **Every expanded workspace in the left sidebar gets its own scrollable session window**: the workspace header stays pinned at the top, that workspace's history scrolls inside the window, each window carries its own scrollbar, and no scrollbar spans two workspaces. The shipped **Show more** control no longer appears. The row count is a setting, five rows by default.
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
Any of the three routes.
|
|
15
|
+
|
|
16
|
+
**① Ask the AI inside DSH** — send this to the model in a conversation:
|
|
17
|
+
|
|
18
|
+
> Install the `dsh-workspaces-scroll` plugin from npm, then restart the host.
|
|
19
|
+
|
|
20
|
+
**② In the app** — open **Plugins → Add plugin**, enter `dsh-workspaces-scroll`, click **Install**, and restart the host when it asks.
|
|
21
|
+
|
|
22
|
+
**③ From the command line** —
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
dsh plugin --profile <profile> add dsh-workspaces-scroll
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Desktop uses the bundled CLI and the `desktop` profile; on the web version use `web`. Verified on DSH Desktop 0.2.2-rc.5; the plugin claims nothing when a release renames the sidebar markers, so the sidebar falls back to its own short list instead of a window it cannot fill.
|
|
29
|
+
|
|
30
|
+
## Quick use
|
|
31
|
+
|
|
32
|
+
1. Expand any workspace in the left sidebar: it is now a fixed-height window with the workspace header left where it was.
|
|
33
|
+
2. Hover the workspace's session rows and scroll: only that window moves, and dragging its own scrollbar does the same. Once the window reaches either end, further scrolling moves the sidebar column as before.
|
|
34
|
+
3. To change the window height: **Settings → Built-in plugins → Workspace windows**, enter a row count.
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
## Settings
|
|
39
|
+
|
|
40
|
+
One setting: **Session rows per workspace window**, five by default.
|
|
41
|
+
|
|
42
|
+
- **In DSH**: **Settings → Built-in plugins → Workspace windows**. The field has the browser's own up/down steps: `3`–`99` sets the window height, and `-1` is the **original setting** — no window at all, the sidebar keeps its short list and its **Show more** button. A change applies to the open windows immediately.
|
|
43
|
+
- **In the profile patch**, as the row's `config`:
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
- insert:
|
|
47
|
+
- id: workspaces-scroll
|
|
48
|
+
name: dsh-workspaces-scroll
|
|
49
|
+
config:
|
|
50
|
+
rows: 8
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The window height is derived, not set directly: it is measured from the shipped list itself — the pinned header, one Session row's real height and the real gap between two rows — and multiplied by the configured count, so a host or theme that changes the row height keeps exactly that many rows in view instead of clipping. On the current host the rows are `32px` tall, `2px` apart, under a `32px` header, so five rows give `32 + 5×32 + 4×2 = 200px`. A field change rewrites the plugin configuration and resizes the windows at once; every later page load reads the stored value from the Host. A non-default value lives in the profile patch, a value equal to the default is stored as absent.
|
|
54
|
+
|
|
55
|
+
## Behavior
|
|
56
|
+
|
|
57
|
+
- Every expanded Workspace shows a window of the configured height plus its header. The window does not grow with the history.
|
|
58
|
+
- The workspace header stays pinned while its Session rows scroll beneath it, and the window has its own scrollbar: wheel over that Workspace's rows in either direction, or drag that window's bar. Once the window reaches an end, further scrolling moves the sidebar column as before.
|
|
59
|
+
- Workspaces stay separate, one below another; no scrollbar spans two of them. Folding, renaming, creating a session in, or reordering a Workspace behaves as before.
|
|
60
|
+
- **Show more** no longer appears; every Session of an expanded Workspace is already in its window.
|
|
61
|
+
- Search keeps its own full-height result panel; the windows apply to the browsing list only.
|
|
62
|
+
|
|
63
|
+
## Known limitations
|
|
64
|
+
|
|
65
|
+
- Every Session of every expanded Workspace is rendered inside its window, so a Workspace with a very long history costs more rows and more fill frames than the shipped short list, even though only the configured rows are visible. The fill runs one batch per animation frame.
|
|
66
|
+
- The window does not scroll the active Session into view on its own; if that Session sits below the visible rows, open the window and scroll to it, the same as the shipped sidebar.
|
|
67
|
+
- Dragging a Workspace to reorder it still works, but the insertion line drawn at the section's top or bottom edge is clipped by the window's own overflow.
|
|
68
|
+
- Workspace Tree grouping nests child Workspaces inside the parent's section, so a child that is itself capped scrolls inside the parent's window. Sibling grouping, the default, has one window per Workspace.
|
|
69
|
+
- The one-list view (`Group by: In one list`) has no Workspace sections, so it keeps its own layout without per-workspace windows.
|
|
70
|
+
- The plugin relies on the shipped browser's markers: the list seat (`data-sidebar-list-area`), the `data-row-key` values of the Workspace, Session and reveal rows, and `aria-expanded` on the reveal control. It claims the list only while that control is recognizable, and it drops the claim again if the control stops revealing rows, so a DSH release that renames or repurposes them leaves the sidebar with its own short list instead of a window it cannot fill.
|
|
71
|
+
- It writes one style rule and one marker attribute; no markup, no storage, no application state.
|
|
72
|
+
|
|
73
|
+
## Turning it off
|
|
74
|
+
|
|
75
|
+
Disabling the bundle removes its style, its wheel listener, its observers, its animation frame and its marker; the sidebar returns to the short list with the **Show more** control.
|
package/README.md
CHANGED
|
@@ -1,3 +1,75 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-workspaces-scroll
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**简体中文** · [English](README.en.md)
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-workspaces-scroll)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
DeepSeek Harness 插件。**左侧栏每个展开的工作区各自拥有一个可滚动的会话窗口**:标题固定在上方,这个工作区的历史在窗口里滚动,每个窗口带自己的滚动条,工作区之间不共享滚动条;原来的「展开其余 N 个会话」不再出现。窗口行数是可配置的,默认 5 行。
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
## 快速安装
|
|
13
|
+
|
|
14
|
+
三种方式,任选一种。
|
|
15
|
+
|
|
16
|
+
**① 让 DSH 里的 AI 帮你装** —— 在会话里把这句话发给模型:
|
|
17
|
+
|
|
18
|
+
> 帮我安装 npm 上的 `dsh-workspaces-scroll` 插件,装好后重启宿主。
|
|
19
|
+
|
|
20
|
+
**② 图形界面** —— 打开 **Plugins → Add plugin**,输入 `dsh-workspaces-scroll`,点 **Install**,按提示重启宿主。
|
|
21
|
+
|
|
22
|
+
**③ 命令行** ——
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
dsh plugin --profile <profile> add dsh-workspaces-scroll
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
桌面版用应用自带的 CLI 和 `desktop` 配置档;Web 版把 `<profile>` 换成 `web`。在 DSH Desktop 0.2.2-rc.5 上验证过;侧栏标记改名后插件会自己退场,不会留下填不满的窗口。
|
|
29
|
+
|
|
30
|
+
## 快速使用
|
|
31
|
+
|
|
32
|
+
1. 在左侧栏展开任意工作区:它现在是一个固定高度的窗口,工作区标题留在原处。
|
|
33
|
+
2. 把鼠标悬停在这个工作区的会话行上滚动滚轮,只有这个窗口在动;拖它自己的滚动条也一样。窗口滚到顶或到底之后,继续滚才会带动整个侧栏。
|
|
34
|
+
3. 想改窗口多高:**设置 → 内置插件 → 工作区窗口**,填一个行数。
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
## 设置
|
|
39
|
+
|
|
40
|
+
只有一个设置项:**每个工作区的会话行数**,默认 5 行。
|
|
41
|
+
|
|
42
|
+
- **在 DSH 里**:**设置 → 内置插件 → 工作区窗口**。输入框带浏览器自带的上下步进:填 `3`–`99` 设定窗口高度,填 `-1` 是**原版设置**——不生成窗口,侧栏保持原来的短列表和「展开其余」按钮。改动对已经打开的窗口立即生效。
|
|
43
|
+
- **在配置档的 patch 里**:写成插件行的 `config`:
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
- insert:
|
|
47
|
+
- id: workspaces-scroll
|
|
48
|
+
name: dsh-workspaces-scroll
|
|
49
|
+
config:
|
|
50
|
+
rows: 8
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
窗口高度是量出来的,不是写死的:从侧栏列表本身量出固定的标题高度、一行会话的真实高度和两行之间的真实间距,再乘以配置的行数,所以换主题或宿主改了行高时,仍然恰好放下这么多行,而不是被裁掉。当前宿主上会话行 `32px`、行距 `2px`、标题 `32px`,5 行即 `32 + 5×32 + 4×2 = 200px`。改一次设置会重写插件配置并立刻调整窗口大小;之后每次打开页面都从宿主读回存下的值。非默认值写在配置档的 patch 里,等于默认值时存成“未设置”。
|
|
54
|
+
|
|
55
|
+
## 行为
|
|
56
|
+
|
|
57
|
+
- 每个展开的工作区显示一个配置高度的窗口,加上它自己的标题;窗口不随历史变长。
|
|
58
|
+
- 标题固定,下面的会话行滚动:滚轮在任意方向都只作用于这个窗口,也可以拖这一条窗口的滑条。窗口到达两端后,继续滚动会像原来一样带动侧栏列。
|
|
59
|
+
- 工作区彼此独立、上下排列,没有一条滚动条横跨两个工作区。折叠、重命名、在其中新建会话、拖动排序都和原来一样。
|
|
60
|
+
- 「展开其余」不再出现:展开的工作区里每个会话都已经在窗口内。
|
|
61
|
+
- 搜索保持自己的整页结果面板;窗口只作用于浏览列表。
|
|
62
|
+
|
|
63
|
+
## 已知限制
|
|
64
|
+
|
|
65
|
+
- 展开的工作区里的每个会话都渲染进窗口,历史很长的工作区比原来的短列表多花一些渲染开销,虽然可见的只有配置的那几行。填充按动画帧一批批进行。
|
|
66
|
+
- 窗口不会自动把当前会话滚进视野;当前会话在可见行以下时,打开窗口自己滚过去,和原来的侧栏一样。
|
|
67
|
+
- 拖动工作区排序仍然可用,但画在分区上下边缘的插入线会被窗口自己的 overflow 裁掉。
|
|
68
|
+
- 按「工作区树」分组时,子工作区嵌在父工作区的分区里,被限制高度的子工作区会在父窗口内部滚动;默认的“同级”分组是一个工作区一个窗口。
|
|
69
|
+
- 单列表视图(`Group by: In one list`)没有工作区分区,不生成分工作区窗口。
|
|
70
|
+
- 插件依赖侧栏内置的标记:列表容器(`data-sidebar-list-area`)、工作区 / 会话 / 揭示行的 `data-row-key`、揭示控件上的 `aria-expanded`。只有认出那个揭示控件才会接管,控件不再能揭示新行时也会放手,所以 DSH 升级后标记改名的话,侧栏会退回自己的短列表,而不是留下一个填不满的窗口。
|
|
71
|
+
- 只写一条样式规则和一个标记属性:不加 DOM、不存数据、没有应用状态。
|
|
72
|
+
|
|
73
|
+
## 关闭
|
|
74
|
+
|
|
75
|
+
禁用这个 bundle 会移除它的样式、滚轮监听、观察器、动画帧和标记,侧栏回到原来的短列表和「展开其余」按钮。
|
package/client.js
ADDED
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspaces scroll — Client half.
|
|
3
|
+
*
|
|
4
|
+
* The shipped sidebar browser keeps each expanded Workspace short by rendering
|
|
5
|
+
* only the first non-blank Sessions and hiding the rest behind one "Show more"
|
|
6
|
+
* control. This module gives every Workspace its own fixed-height window over its
|
|
7
|
+
* whole Session history, so each Workspace is browsed by scrolling inside itself
|
|
8
|
+
* instead of clicking:
|
|
9
|
+
*
|
|
10
|
+
* - it raises every group's visible-row count through the shipped control, one
|
|
11
|
+
* batch per frame, until no rows are hidden (the shipped browser keeps owning
|
|
12
|
+
* the row state, ordering, actions and the reset a fold performs);
|
|
13
|
+
* - it caps each Workspace's group section at the configured number of Session
|
|
14
|
+
* rows plus its pinned header and scrolls the rows inside it. Workspaces stay
|
|
15
|
+
* separate, one below another, and no scrollbar spans several of them.
|
|
16
|
+
*
|
|
17
|
+
* The row count is a Host setting that reaches the page as
|
|
18
|
+
* `globalThis.__DSH_WORKSPACES_SCROLL__.rows`; five rows is the default and the
|
|
19
|
+
* fallback when the Host half is absent. The same setting is editable from the
|
|
20
|
+
* plugin's own tab in Settings → Plugins, which writes it back through the
|
|
21
|
+
* settings Remote and resizes the windows right away.
|
|
22
|
+
*
|
|
23
|
+
* Every override is gated on a marker the module sets only after it has claimed
|
|
24
|
+
* the list, so a DSH release that renames the shipped markers leaves the
|
|
25
|
+
* sidebar's own behavior in place instead of hiding a control it cannot drive.
|
|
26
|
+
*/
|
|
27
|
+
window.__ModuleLoader__.load({
|
|
28
|
+
id: 'dsh-workspaces-scroll',
|
|
29
|
+
factory(require) {
|
|
30
|
+
const React = require('react')
|
|
31
|
+
const h = React.createElement
|
|
32
|
+
|
|
33
|
+
/** The sidebar browser's always-mounted list seat; exists while the sidebar is open. */
|
|
34
|
+
const LIST_AREA = '[data-sidebar-list-area]'
|
|
35
|
+
/** The shipped per-group control that hides rows; `aria-expanded="false"` while it still does. */
|
|
36
|
+
const OVERFLOW = 'button[data-row-key^="overflow:"]'
|
|
37
|
+
/** Marker this module puts on the list seat once it is filled; CSS keys off it. */
|
|
38
|
+
const FULL = 'data-dsh-session-list-full'
|
|
39
|
+
/** One Workspace's section in the session tree: the block that owns its header row. */
|
|
40
|
+
const GROUP = `[data-sidebar-list-area][${FULL}] [role="tree"] > div:has([data-row-key^="workspace:"])`
|
|
41
|
+
/** Rows shown when no setting reaches the page; matches the Host half's default. */
|
|
42
|
+
const DEFAULT_ROWS = 5
|
|
43
|
+
/** Bounds the Host half also enforces. */
|
|
44
|
+
const MIN_ROWS = 3
|
|
45
|
+
const MAX_ROWS = 99
|
|
46
|
+
/** Special value that hands the sidebar back its original short list. */
|
|
47
|
+
const ORIGINAL_ROWS = -1
|
|
48
|
+
/** One Session row, the pinned header, and the gap between two rows, in CSS pixels. */
|
|
49
|
+
const ROW_HEIGHT = 32
|
|
50
|
+
const HEADER_HEIGHT = 32
|
|
51
|
+
const ROW_GAP = 2
|
|
52
|
+
/** Settings namespace this plugin's row is registered under by the Host. */
|
|
53
|
+
const SETTINGS_MATCH = 'workspaces-scroll'
|
|
54
|
+
/** Locale namespace for the tab copy. */
|
|
55
|
+
const LOCALE_NS = 'dsh-workspaces-scroll'
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* One window per Workspace. Every row is rendered (otherwise a scrollbar would
|
|
59
|
+
* have nothing to scroll), but a Workspace stops growing at the configured
|
|
60
|
+
* number of Session rows plus its header, and the header pins to the top while
|
|
61
|
+
* those rows scroll beneath it. Its hover-card anchor wraps the header row as a
|
|
62
|
+
* block, so that anchor takes the sticky position and carries the fill that
|
|
63
|
+
* hides rows under it. Search results render no Workspace headers, so that view
|
|
64
|
+
* keeps its own full-height layout, and the reveal control has no job left once
|
|
65
|
+
* every row is rendered.
|
|
66
|
+
*/
|
|
67
|
+
const STYLE = `
|
|
68
|
+
[data-sidebar-list-area][${FULL}] {
|
|
69
|
+
--dsh-session-window-height: ${windowHeight(configuredRows() === ORIGINAL_ROWS ? DEFAULT_ROWS : configuredRows())}px;
|
|
70
|
+
}
|
|
71
|
+
${GROUP} {
|
|
72
|
+
max-height: var(--dsh-session-window-height);
|
|
73
|
+
overflow-y: auto;
|
|
74
|
+
scrollbar-gutter: stable;
|
|
75
|
+
}
|
|
76
|
+
${GROUP} > :has(> [data-row-key^="workspace:"]) {
|
|
77
|
+
position: sticky;
|
|
78
|
+
top: 0;
|
|
79
|
+
z-index: 1;
|
|
80
|
+
background-color: var(--dsw-specific-sidebar-fill);
|
|
81
|
+
}
|
|
82
|
+
[data-sidebar-list-area][${FULL}] button[data-row-key^="overflow:"] {
|
|
83
|
+
display: none !important;
|
|
84
|
+
}
|
|
85
|
+
`
|
|
86
|
+
|
|
87
|
+
/** Row count the Host injected before the page mounted, clamped to the supported range. */
|
|
88
|
+
function configuredRows() {
|
|
89
|
+
const boot = globalThis.__DSH_WORKSPACES_SCROLL__
|
|
90
|
+
const raw = boot !== null && typeof boot === 'object' ? boot.rows : undefined
|
|
91
|
+
if (typeof raw !== 'number' || !Number.isFinite(raw)) return DEFAULT_ROWS
|
|
92
|
+
return raw === ORIGINAL_ROWS ? ORIGINAL_ROWS : clampRows(raw)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Clamp an untrusted row count into the supported range. */
|
|
96
|
+
function clampRows(rows) {
|
|
97
|
+
const rounded = typeof rows === 'number' && Number.isFinite(rows) ? Math.round(rows) : DEFAULT_ROWS
|
|
98
|
+
return Math.min(MAX_ROWS, Math.max(MIN_ROWS, rounded))
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Window height that keeps `rows` Session rows visible below the pinned header. */
|
|
102
|
+
function windowHeight(rows) {
|
|
103
|
+
return HEADER_HEIGHT + rows * ROW_HEIGHT + (rows - 1) * ROW_GAP
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Copy for the settings tab; registered through the Client locale service. */
|
|
107
|
+
const LOCALE = {
|
|
108
|
+
zh: {
|
|
109
|
+
tab: '工作区窗口',
|
|
110
|
+
label: '每个工作区显示的会话行数',
|
|
111
|
+
hint: '填 3–99 之间的行数(可用上下箭头逐个调整);填 -1 使用原版设置。改动立即生效。',
|
|
112
|
+
original: '当前为原版设置:侧栏恢复自带的前几条会话和「展开其余」按钮。',
|
|
113
|
+
originalBadge: '原版设置',
|
|
114
|
+
missing: '没有读到插件配置,重启 DSH 后这里会出现设置项。',
|
|
115
|
+
},
|
|
116
|
+
en: {
|
|
117
|
+
tab: 'Workspace windows',
|
|
118
|
+
label: 'Session rows per workspace window',
|
|
119
|
+
hint: 'Enter 3–99 (the arrows step by one); enter -1 for the original setting. Changes apply immediately.',
|
|
120
|
+
original: 'Original setting: the sidebar keeps its short list and its Show more button.',
|
|
121
|
+
originalBadge: 'Original setting',
|
|
122
|
+
missing: 'Plugin configuration was not found. Restart DSH and this setting will appear.',
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Tab copy until the locale service binds; the component reads through this. */
|
|
127
|
+
let translate = (key) => LOCALE.en[key] ?? key
|
|
128
|
+
|
|
129
|
+
/** The "Show more" controls inside `root` that still hide rows. */
|
|
130
|
+
function collapsedOverflow(root) {
|
|
131
|
+
const found = []
|
|
132
|
+
for (const button of root.querySelectorAll(OVERFLOW)) {
|
|
133
|
+
if (button.getAttribute('aria-expanded') === 'false') found.push(button)
|
|
134
|
+
}
|
|
135
|
+
return found
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** The Workspace section that contains `target`, or null outside the session tree. */
|
|
139
|
+
function groupAt(target) {
|
|
140
|
+
if (!(target instanceof Element)) return null
|
|
141
|
+
const tree = target.closest('[role="tree"]')
|
|
142
|
+
if (tree === null) return null
|
|
143
|
+
let node = target
|
|
144
|
+
while (node !== null && node !== tree && node.parentElement !== tree) node = node.parentElement
|
|
145
|
+
if (node === null || node === tree) return null
|
|
146
|
+
return node.querySelector('[data-row-key^="workspace:"]') === null ? null : node
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
/**
|
|
151
|
+
* Fill the session list into a scrolling window and contribute the settings tab.
|
|
152
|
+
* @param ctx - Client root context; `effect` and `inject` own the resources.
|
|
153
|
+
*/
|
|
154
|
+
apply(ctx) {
|
|
155
|
+
let frame = 0
|
|
156
|
+
let area = null
|
|
157
|
+
let observer = null
|
|
158
|
+
let guard = null
|
|
159
|
+
let style = null
|
|
160
|
+
let claimed = false
|
|
161
|
+
let lastHidden = -1
|
|
162
|
+
let lastRows = -1
|
|
163
|
+
let stalled = 0
|
|
164
|
+
/** Set when the shipped reveal control stops working; no re-claim until it is reset. */
|
|
165
|
+
let revealBroken = false
|
|
166
|
+
// Settings transport arrives with the injected context; the tab reads through it.
|
|
167
|
+
let settingsRemote = null
|
|
168
|
+
// alse while the setting asks for the original sidebar.
|
|
169
|
+
let windowsEnabled = configuredRows() !== ORIGINAL_ROWS
|
|
170
|
+
/** Configured rows for the open windows; -1 means the original sidebar. */
|
|
171
|
+
let currentRows = configuredRows()
|
|
172
|
+
|
|
173
|
+
// One batch per frame: a click reads the row count of the render its button
|
|
174
|
+
// was mounted with, so the next batch needs that render to land first. The
|
|
175
|
+
// pass ends when no group hides rows any more.
|
|
176
|
+
//
|
|
177
|
+
// Progress is measured by the rendered Session rows, because one click raises a
|
|
178
|
+
// group's watermark by only five rows and keeps the same control mounted; only
|
|
179
|
+
// when neither that count nor the control count moves does the reveal stop
|
|
180
|
+
// working, and then the list is given back instead of being capped with its
|
|
181
|
+
// rows still hidden.
|
|
182
|
+
const pump = () => {
|
|
183
|
+
frame = 0
|
|
184
|
+
if (!windowsEnabled || revealBroken) return
|
|
185
|
+
if (area === null || !area.isConnected) {
|
|
186
|
+
if (!discover()) return
|
|
187
|
+
}
|
|
188
|
+
if (!claimed) {
|
|
189
|
+
claimed = true
|
|
190
|
+
area.setAttribute(FULL, '')
|
|
191
|
+
}
|
|
192
|
+
// Keep the window height on the current geometry: re-measure every batch, and
|
|
193
|
+
// re-attach the observer when React has replaced the nodes it followed.
|
|
194
|
+
applyMeasuredHeight()
|
|
195
|
+
if (!geometryTargetsLive()) {
|
|
196
|
+
untrackGeometry()
|
|
197
|
+
trackGeometry()
|
|
198
|
+
}
|
|
199
|
+
const hidden = collapsedOverflow(area)
|
|
200
|
+
if (hidden.length === 0) {
|
|
201
|
+
lastHidden = 0
|
|
202
|
+
lastRows = -1
|
|
203
|
+
stalled = 0
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
const rows = area.querySelectorAll('[data-row-key^="session:"]').length
|
|
207
|
+
if (hidden.length === lastHidden && rows === lastRows) {
|
|
208
|
+
if (++stalled > 4) {
|
|
209
|
+
revealBroken = true
|
|
210
|
+
untrackGeometry()
|
|
211
|
+
release()
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
lastHidden = hidden.length
|
|
216
|
+
lastRows = rows
|
|
217
|
+
stalled = 0
|
|
218
|
+
}
|
|
219
|
+
for (const button of hidden) button.click()
|
|
220
|
+
frame = requestAnimationFrame(pump)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Give the list back to the shipped browser, dropping the marker and the claim. */
|
|
224
|
+
const release = () => {
|
|
225
|
+
area?.removeAttribute(FULL)
|
|
226
|
+
claimed = false
|
|
227
|
+
lastHidden = -1
|
|
228
|
+
lastRows = -1
|
|
229
|
+
stalled = 0
|
|
230
|
+
}
|
|
231
|
+
/** Observe the header and one Session row so a size change re-measures the window. */
|
|
232
|
+
let geometryObserver = null
|
|
233
|
+
/** The two nodes the observer follows; they are replaced when React re-renders rows. */
|
|
234
|
+
let geometryTargets = []
|
|
235
|
+
|
|
236
|
+
/** The shipped geometry as it is laid out right now, with the constants as fallback. */
|
|
237
|
+
const measureGeometry = () => {
|
|
238
|
+
const fallback = { header: HEADER_HEIGHT, row: ROW_HEIGHT, gap: ROW_GAP }
|
|
239
|
+
if (area === null || !area.isConnected) return fallback
|
|
240
|
+
const sections = [...area.querySelectorAll('[role="tree"] > div')]
|
|
241
|
+
.filter((node) => node.querySelector('[data-row-key^="workspace:"]') !== null)
|
|
242
|
+
if (sections.length === 0) return fallback
|
|
243
|
+
// Prefer a section that actually shows Session rows; a folded one only has its header.
|
|
244
|
+
const section = sections.find((node) => node.querySelector('[data-row-key^="session:"]') !== null) ?? sections[0]
|
|
245
|
+
const header = section.querySelector('[data-row-key^="workspace:"]')
|
|
246
|
+
const rows = section.querySelectorAll('[data-row-key^="session:"]')
|
|
247
|
+
const headerHeight = header === null ? fallback.header : (header.getBoundingClientRect().height || fallback.header)
|
|
248
|
+
if (rows.length === 0) return { header: headerHeight, row: fallback.row, gap: fallback.gap }
|
|
249
|
+
const first = rows[0].getBoundingClientRect()
|
|
250
|
+
const rowHeight = first.height || fallback.row
|
|
251
|
+
let gap = fallback.gap
|
|
252
|
+
if (rows.length > 1) {
|
|
253
|
+
const second = rows[1].getBoundingClientRect()
|
|
254
|
+
const measured = second.top - first.top - rowHeight
|
|
255
|
+
if (Number.isFinite(measured) && measured >= 0) gap = measured
|
|
256
|
+
} else {
|
|
257
|
+
const parsed = Number.parseFloat(getComputedStyle(section).rowGap)
|
|
258
|
+
if (Number.isFinite(parsed)) gap = parsed
|
|
259
|
+
}
|
|
260
|
+
return { header: headerHeight, row: rowHeight, gap }
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Size the live windows from the measured rows instead of the constants, so a
|
|
265
|
+
* taller or shorter Session row still keeps exactly `currentRows` rows in view.
|
|
266
|
+
*/
|
|
267
|
+
const applyMeasuredHeight = () => {
|
|
268
|
+
if (!windowsEnabled) return
|
|
269
|
+
const geometry = measureGeometry()
|
|
270
|
+
const height = `${geometry.header + currentRows * geometry.row + (currentRows - 1) * geometry.gap}px`
|
|
271
|
+
for (const seat of document.querySelectorAll(LIST_AREA)) {
|
|
272
|
+
if (seat.style.getPropertyValue('--dsh-session-window-height') !== height) {
|
|
273
|
+
seat.style.setProperty('--dsh-session-window-height', height)
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** Re-measure whenever the header or a Session row changes size (font, zoom, theme). */
|
|
279
|
+
const trackGeometry = () => {
|
|
280
|
+
if (geometryObserver !== null || area === null || !area.isConnected) return
|
|
281
|
+
const section = area.querySelector('[role="tree"] > div:has([data-row-key^="workspace:"])')
|
|
282
|
+
if (section === null) return
|
|
283
|
+
const targets = [section.querySelector('[data-row-key^="workspace:"]'), section.querySelector('[data-row-key^="session:"]')]
|
|
284
|
+
.filter((node) => node !== null)
|
|
285
|
+
if (targets.length === 0) return
|
|
286
|
+
geometryObserver = new ResizeObserver(() => { requestAnimationFrame(applyMeasuredHeight) })
|
|
287
|
+
geometryTargets = targets
|
|
288
|
+
for (const target of targets) geometryObserver.observe(target)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** Stop following the shipped geometry. */
|
|
292
|
+
const untrackGeometry = () => {
|
|
293
|
+
geometryObserver?.disconnect()
|
|
294
|
+
geometryObserver = null
|
|
295
|
+
geometryTargets = []
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** Whether the observed nodes are still in the document. */
|
|
299
|
+
const geometryTargetsLive = () => geometryTargets.length > 0 && geometryTargets.every((node) => node.isConnected)
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Hand the list back the way the shipped sidebar shows it: the collapse
|
|
303
|
+
* affordance of every group drops its raised watermark, which brings back the
|
|
304
|
+
* short list and its "Show more" button, then the claim comes off.
|
|
305
|
+
*/
|
|
306
|
+
const restoreOriginal = () => {
|
|
307
|
+
windowsEnabled = false
|
|
308
|
+
untrackGeometry()
|
|
309
|
+
if (area !== null && area.isConnected) {
|
|
310
|
+
for (const button of area.querySelectorAll(OVERFLOW)) {
|
|
311
|
+
if (button.getAttribute('aria-expanded') === 'true') button.click()
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
release()
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Apply one configured row count to the open windows: a number resizes them,
|
|
319
|
+
* -1 gives the original sidebar back.
|
|
320
|
+
* @param rows - Configured rows or -1.
|
|
321
|
+
*/
|
|
322
|
+
const applyRows = (rows) => {
|
|
323
|
+
if (rows === ORIGINAL_ROWS) {
|
|
324
|
+
restoreOriginal()
|
|
325
|
+
return
|
|
326
|
+
}
|
|
327
|
+
windowsEnabled = true
|
|
328
|
+
revealBroken = false
|
|
329
|
+
currentRows = clampRows(rows)
|
|
330
|
+
applyMeasuredHeight()
|
|
331
|
+
trackGeometry()
|
|
332
|
+
schedule()
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const schedule = () => {
|
|
336
|
+
if (frame === 0) frame = requestAnimationFrame(pump)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const watch = (next) => {
|
|
340
|
+
if (next === area) return
|
|
341
|
+
observer?.disconnect()
|
|
342
|
+
untrackGeometry()
|
|
343
|
+
area = next
|
|
344
|
+
revealBroken = false
|
|
345
|
+
claimed = false
|
|
346
|
+
lastHidden = -1
|
|
347
|
+
lastRows = -1
|
|
348
|
+
stalled = 0
|
|
349
|
+
observer = new MutationObserver(schedule)
|
|
350
|
+
observer.observe(next, { childList: true, subtree: true })
|
|
351
|
+
schedule()
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** Follow the list seat, which outlives the wide, rail and search states. */
|
|
355
|
+
const discover = () => {
|
|
356
|
+
const found = document.querySelector(LIST_AREA)
|
|
357
|
+
if (found === null) return false
|
|
358
|
+
watch(found)
|
|
359
|
+
return true
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Scroll the Workspace window under the pointer. The sidebar's own wheel
|
|
364
|
+
* hand-off only knows the list seat as its section scroller, so it swallows
|
|
365
|
+
* the upward share of a gesture that belongs to a window; taking the gesture
|
|
366
|
+
* here keeps both directions symmetric. Once the window has no room left the
|
|
367
|
+
* event is left alone, so the hand-off or native scroll chaining moves the
|
|
368
|
+
* sidebar column exactly as before.
|
|
369
|
+
*/
|
|
370
|
+
const scrollWindow = (event) => {
|
|
371
|
+
if (!windowsEnabled) return
|
|
372
|
+
if (event.ctrlKey || event.defaultPrevented) return
|
|
373
|
+
if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) return
|
|
374
|
+
// A remounted seat would have left the old observer behind; the gesture is
|
|
375
|
+
// a free chance to follow the live one again.
|
|
376
|
+
if (area === null || !area.isConnected) discover()
|
|
377
|
+
const group = groupAt(event.target)
|
|
378
|
+
if (group === null) return
|
|
379
|
+
const delta = event.deltaMode === WheelEvent.DOM_DELTA_LINE
|
|
380
|
+
? event.deltaY * 16
|
|
381
|
+
: event.deltaMode === WheelEvent.DOM_DELTA_PAGE ? event.deltaY * group.clientHeight : event.deltaY
|
|
382
|
+
if (delta === 0) return
|
|
383
|
+
const room = delta > 0
|
|
384
|
+
? group.scrollHeight - group.clientHeight - group.scrollTop
|
|
385
|
+
: group.scrollTop
|
|
386
|
+
if (room <= 0) return
|
|
387
|
+
event.preventDefault()
|
|
388
|
+
group.scrollTop += delta > 0 ? Math.min(room, delta) : Math.max(-room, delta)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
ctx.effect(() => {
|
|
392
|
+
// The style lands only after the observer is in place: if a future
|
|
393
|
+
// release's markers move, nothing is hidden that this module cannot fill.
|
|
394
|
+
discover()
|
|
395
|
+
// The browser replaces the list seat when the sidebar switches between its
|
|
396
|
+
// rail, wide and search states, and its own observer dies with the old node.
|
|
397
|
+
// This document-level watch takes the module back to the live seat; it stays
|
|
398
|
+
// idle whenever the seat it already watches is connected.
|
|
399
|
+
guard = new MutationObserver(() => {
|
|
400
|
+
if (area !== null && area.isConnected) return
|
|
401
|
+
discover()
|
|
402
|
+
})
|
|
403
|
+
guard.observe(document.body, { childList: true, subtree: true })
|
|
404
|
+
style = document.createElement('style')
|
|
405
|
+
style.textContent = STYLE
|
|
406
|
+
document.head.append(style)
|
|
407
|
+
// Capture phase with a cancelable listener: it runs before the sidebar's
|
|
408
|
+
// own hand-off, which bails out on a prevented event.
|
|
409
|
+
document.addEventListener('wheel', scrollWindow, { capture: true, passive: false })
|
|
410
|
+
return () => {
|
|
411
|
+
document.removeEventListener('wheel', scrollWindow, { capture: true })
|
|
412
|
+
style.remove()
|
|
413
|
+
observer?.disconnect()
|
|
414
|
+
guard?.disconnect()
|
|
415
|
+
untrackGeometry()
|
|
416
|
+
release()
|
|
417
|
+
area = null
|
|
418
|
+
observer = null
|
|
419
|
+
guard = null
|
|
420
|
+
if (frame !== 0) cancelAnimationFrame(frame)
|
|
421
|
+
frame = 0
|
|
422
|
+
}
|
|
423
|
+
}, 'dsh-workspaces-scroll: session windows')
|
|
424
|
+
|
|
425
|
+
/** Row-count tab rendered inside Settings → Plugins. */
|
|
426
|
+
const RowCountTab = () => {
|
|
427
|
+
const [state, setState] = React.useState({ status: 'loading', rows: DEFAULT_ROWS, revision: undefined, ns: undefined, error: null })
|
|
428
|
+
const [draft, setDraft] = React.useState(String(DEFAULT_ROWS))
|
|
429
|
+
const [saving, setSaving] = React.useState(false)
|
|
430
|
+
|
|
431
|
+
React.useEffect(() => {
|
|
432
|
+
let alive = true
|
|
433
|
+
const load = async () => {
|
|
434
|
+
try {
|
|
435
|
+
const remote = settingsRemote
|
|
436
|
+
if (remote === null) {
|
|
437
|
+
setState({ status: 'missing', rows: DEFAULT_ROWS, revision: undefined, ns: undefined, error: null })
|
|
438
|
+
return
|
|
439
|
+
}
|
|
440
|
+
const response = await remote.describe()
|
|
441
|
+
if (!alive) return
|
|
442
|
+
if (!response.ok) {
|
|
443
|
+
setState({ status: 'error', rows: DEFAULT_ROWS, revision: undefined, ns: undefined, error: response.error.message })
|
|
444
|
+
return
|
|
445
|
+
}
|
|
446
|
+
const row = response.value.namespaces.find((entry) => String(entry.ns).includes(SETTINGS_MATCH))
|
|
447
|
+
if (row === undefined) {
|
|
448
|
+
setState({ status: 'missing', rows: DEFAULT_ROWS, revision: undefined, ns: undefined, error: null })
|
|
449
|
+
return
|
|
450
|
+
}
|
|
451
|
+
const storedRaw = Number(row.value?.rows ?? row.base?.rows ?? configuredRows())
|
|
452
|
+
const stored = storedRaw === ORIGINAL_ROWS ? ORIGINAL_ROWS : clampRows(storedRaw)
|
|
453
|
+
setState({ status: 'ready', rows: stored, revision: row.revision, ns: row.ns, error: null })
|
|
454
|
+
setDraft(String(stored))
|
|
455
|
+
} catch (error) {
|
|
456
|
+
if (alive) setState({ status: 'error', rows: DEFAULT_ROWS, revision: undefined, ns: undefined, error: String(error?.message ?? error) })
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
void load()
|
|
460
|
+
return () => { alive = false }
|
|
461
|
+
}, [])
|
|
462
|
+
|
|
463
|
+
const save = async (next) => {
|
|
464
|
+
if (saving || state.status !== 'ready' || next === state.rows) return
|
|
465
|
+
setSaving(true)
|
|
466
|
+
try {
|
|
467
|
+
const remote = settingsRemote
|
|
468
|
+
if (remote === null) return
|
|
469
|
+
const response = await remote.mutate(state.ns, [{ op: 'set', path: ['rows'], value: next }], state.revision)
|
|
470
|
+
if (!response.ok) {
|
|
471
|
+
setState((current) => ({ ...current, error: response.error.message }))
|
|
472
|
+
return
|
|
473
|
+
}
|
|
474
|
+
setState((current) => ({ ...current, rows: next, revision: response.value.revision, error: null }))
|
|
475
|
+
setDraft(String(next))
|
|
476
|
+
applyRows(next)
|
|
477
|
+
} catch (error) {
|
|
478
|
+
setState((current) => ({ ...current, error: String(error?.message ?? error) }))
|
|
479
|
+
} finally {
|
|
480
|
+
setSaving(false)
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/** Snap the typed or stepped value into the allowed set (-1, or 3–99), then save. */
|
|
485
|
+
const commit = () => {
|
|
486
|
+
const raw = Math.round(Number(draft))
|
|
487
|
+
if (!Number.isFinite(raw)) {
|
|
488
|
+
setDraft(String(state.rows))
|
|
489
|
+
return
|
|
490
|
+
}
|
|
491
|
+
const next = raw <= ORIGINAL_ROWS ? ORIGINAL_ROWS
|
|
492
|
+
: raw < MIN_ROWS ? MIN_ROWS
|
|
493
|
+
: raw > MAX_ROWS ? MAX_ROWS
|
|
494
|
+
: raw
|
|
495
|
+
setDraft(String(next))
|
|
496
|
+
void save(next)
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const draftDisabled = state.status !== 'ready' || saving
|
|
500
|
+
const original = state.rows === ORIGINAL_ROWS
|
|
501
|
+
const note = state.status === 'error' ? String(state.error)
|
|
502
|
+
: state.status === 'missing' ? translate('missing')
|
|
503
|
+
: original ? translate('original')
|
|
504
|
+
: translate('hint')
|
|
505
|
+
return h('div', { style: { display: 'flex', flexDirection: 'column', gap: '10px', padding: '18px 0', maxWidth: '560px' } },
|
|
506
|
+
h('label', { htmlFor: 'dsh-workspaces-scroll-rows', style: { display: 'flex', alignItems: 'center', gap: '12px', font: 'inherit' } },
|
|
507
|
+
h('span', null, translate('label')),
|
|
508
|
+
h('input', {
|
|
509
|
+
id: 'dsh-workspaces-scroll-rows',
|
|
510
|
+
type: 'number',
|
|
511
|
+
min: ORIGINAL_ROWS,
|
|
512
|
+
max: MAX_ROWS,
|
|
513
|
+
step: 1,
|
|
514
|
+
value: draft,
|
|
515
|
+
disabled: draftDisabled,
|
|
516
|
+
onChange: (event) => { setDraft(event.target.value) },
|
|
517
|
+
onBlur: commit,
|
|
518
|
+
onKeyDown: (event) => {
|
|
519
|
+
if (event.key !== 'Enter') return
|
|
520
|
+
event.preventDefault()
|
|
521
|
+
commit()
|
|
522
|
+
},
|
|
523
|
+
style: {
|
|
524
|
+
width: '84px',
|
|
525
|
+
font: 'inherit',
|
|
526
|
+
padding: '4px 8px',
|
|
527
|
+
borderRadius: '8px',
|
|
528
|
+
color: 'inherit',
|
|
529
|
+
background: 'var(--dsw-specific-sidebar-fill, rgba(127,127,127,.12))',
|
|
530
|
+
border: '1px solid rgba(127,127,127,.35)',
|
|
531
|
+
},
|
|
532
|
+
}),
|
|
533
|
+
original ? h('span', { style: { fontSize: '12px', opacity: 0.75 } }, translate('originalBadge')) : null),
|
|
534
|
+
h('p', { style: { margin: 0, opacity: 0.72, fontSize: '12px', lineHeight: 1.5 } }, note),
|
|
535
|
+
)
|
|
536
|
+
}
|
|
537
|
+
// Optional services: the windows work without them, so a missing settings
|
|
538
|
+
// transport only costs the tab instead of the whole module.
|
|
539
|
+
ctx.inject(['slots', 'locale', 'remote', 'remote.settings'], (settingsCtx) => {
|
|
540
|
+
settingsCtx.effect(() => {
|
|
541
|
+
const disposers = []
|
|
542
|
+
for (const [locale, dict] of Object.entries(LOCALE)) {
|
|
543
|
+
disposers.push(settingsCtx.locale.register(LOCALE_NS, locale, dict))
|
|
544
|
+
}
|
|
545
|
+
return () => { for (const dispose of disposers) dispose() }
|
|
546
|
+
}, 'dsh-workspaces-scroll: settings copy')
|
|
547
|
+
const t = settingsCtx.locale.bind(LOCALE_NS)
|
|
548
|
+
translate = t
|
|
549
|
+
settingsRemote = settingsCtx.remote.settings
|
|
550
|
+
settingsCtx.slots.inject('settings.plugins.tab', () => settingsCtx.slots.register({
|
|
551
|
+
name: 'settings.plugins.tab',
|
|
552
|
+
id: 'workspaces-scroll',
|
|
553
|
+
order: 40,
|
|
554
|
+
label: () => t('tab'),
|
|
555
|
+
}, RowCountTab))
|
|
556
|
+
})
|
|
557
|
+
},
|
|
558
|
+
}
|
|
559
|
+
},
|
|
560
|
+
})
|
package/cordis.patch.yml
ADDED
package/docs/DETAIL.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+

|
|
@@ -0,0 +1 @@
|
|
|
1
|
+

|
package/docs/RELEASE.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Release checklist
|
|
2
|
+
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
- README 改成中文,开篇就是「让 DSH 里的 AI 装 / 图形界面 / 命令行」三条快速安装和一段快速使用;npm 上的描述同步成中文。
|
|
6
|
+
- 新增 `README.en.md` 英文版,两个文件顶部互相切换;`files` 已把它一起打包。
|
|
7
|
+
- 去掉 README 顶部的 front matter:npm 会把它当正文显示在包页顶部。
|
|
8
|
+
- 只改文档和描述,插件代码、配置项与行为与 0.1.0 相同。
|
|
9
|
+
|
|
10
|
+
## Package
|
|
11
|
+
|
|
12
|
+
- `dsh-workspaces-scroll@0.1.1`, MIT, bundle patch + web client half, one Host
|
|
13
|
+
setting (`rows`: 5 by default, 3–99, or -1 for the original sidebar) and its own
|
|
14
|
+
settings tab.
|
|
15
|
+
- Contents verified with `npm pack --dry-run`: 15 files, about 1.6 MB packed; the
|
|
16
|
+
two demo GIFs (1.4 MB and 0.44 MB) are most of it.
|
|
17
|
+
- Host half imports `@deepseek-ai/schemastery` (`^3.19.0`) for the Config schema;
|
|
18
|
+
validating `{}` fills the default 5, `-1` and every integer in 3–99 pass, and
|
|
19
|
+
out-of-range values are rejected at activation.
|
|
20
|
+
|
|
21
|
+
## Verified on the running installation
|
|
22
|
+
|
|
23
|
+
DSH Desktop 0.2.2-rc.5, page at 150% scaling, two Workspaces (one with 48 Sessions):
|
|
24
|
+
|
|
25
|
+
- One window per expanded Workspace: the configured rows (five by default) exactly
|
|
26
|
+
visible, the window's own scrollbar, `scrollbar-gutter: stable`. The height is
|
|
27
|
+
measured from the shipped header, one Session row and the real row gap, then
|
|
28
|
+
tracked with a `ResizeObserver`, so a changed row height keeps the count exact
|
|
29
|
+
instead of clipping.
|
|
30
|
+
- Header stays pinned while rows scroll (`position: sticky` on the hover-card
|
|
31
|
+
anchor, `top: 0`).
|
|
32
|
+
- Wheel over a window scrolls only that window, both directions; the other
|
|
33
|
+
windows keep their position. At either end the event is left alone and the
|
|
34
|
+
sidebar column takes over as before.
|
|
35
|
+
- Every Session of the expanded Workspace is rendered and the shipped reveal
|
|
36
|
+
control is gone.
|
|
37
|
+
- Disabling the bundle removes the style, the wheel listener, the observers, the
|
|
38
|
+
animation frame and the marker; the sidebar returns to the shipped short list.
|
|
39
|
+
|
|
40
|
+
Settings, verified in the same session (number field with the browser steps):
|
|
41
|
+
|
|
42
|
+
- The plugin contributes a **Workspace windows** tab under Settings → Built-in
|
|
43
|
+
plugins (the `settings.plugins.tab` list), and the tab renders the row-count
|
|
44
|
+
number field with the stored value.
|
|
45
|
+
- Entering a number rewrites the plugin configuration and resizes the open windows
|
|
46
|
+
at once: `6` was stored as `rows: 6` and produced six-row windows, and returning
|
|
47
|
+
to the default `5` removed the override again, because the default is stored as
|
|
48
|
+
absent.
|
|
49
|
+
- Entering `-1` annotated the control as **original setting** (原版设置) and gave the
|
|
50
|
+
sidebar back its shipped list: the raised watermarks were dropped through each
|
|
51
|
+
group's collapse control, so the five short rows and the **Show more** button
|
|
52
|
+
returned; a later number switched the windows back on.
|
|
53
|
+
- With the Host half not yet reloaded (its Config still not volatile), the tab
|
|
54
|
+
appears but reports that no configuration was found instead of showing a broken
|
|
55
|
+
field.
|
|
56
|
+
|
|
57
|
+
Values above the six rows used in that run were not exercised end to end; the
|
|
58
|
+
3–99 range is enforced by the schema and the field's `min`/`max`. On this host the
|
|
59
|
+
measured geometry equals the constants (header 32, row 32, gap 2), so the measured
|
|
60
|
+
height matched the previous constant formula exactly.
|
|
61
|
+
|
|
62
|
+
Not covered: the search results panel, Workspace Tree grouping, the flat "In one
|
|
63
|
+
list" view, light theme, and narrow (390 px) sidebar states.
|
|
64
|
+
|
|
65
|
+
## Notes for the next release
|
|
66
|
+
|
|
67
|
+
The Client half hot-reloads on file changes. A changed Host half — including its
|
|
68
|
+
Config schema — only takes effect after the entry is reloaded: toggling
|
|
69
|
+
`include:workspaces-scroll` off and on through the plugin manager reloads it live,
|
|
70
|
+
and a restart does the same.
|
|
71
|
+
|
|
72
|
+
## Upload
|
|
73
|
+
|
|
74
|
+
- The manifest carries `repository`, `homepage` and `bugs` for
|
|
75
|
+
`https://github.com/Jimmm-Yuuu/dsh-workspaces-scroll`, and the repository is
|
|
76
|
+
pushed to that remote.
|
|
77
|
+
- `npm publish` from this directory (unscoped name, so `--access public` is not
|
|
78
|
+
needed).
|
|
79
|
+
- Open one entry in the `awesome-dsh-plugin` registry (PR against that repo; it
|
|
80
|
+
is the catalog the market reads, usually picked up within a day):
|
|
81
|
+
|
|
82
|
+
> workspaces-scroll — every sidebar workspace gets its own scrolling session
|
|
83
|
+
> window with a pinned header, replacing the Show more control; the row count is
|
|
84
|
+
> a setting. npm: `dsh-workspaces-scroll`, repo: `https://github.com/<you>/dsh-workspaces-scroll`
|
|
85
|
+
|
|
86
|
+
## Installing locally from this directory
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
dsh plugin --profile <profile> add "link:<path-to-checkout>/dsh-workspaces-scroll"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The profile lists the package in `dependencies` and `dsh.profile.bundles`; the
|
|
93
|
+
client half hot-reloads on file changes while the page is open, the Host half
|
|
94
|
+
needs a reload. Renaming the package again means repeating that step, because pnpm
|
|
95
|
+
keys the link by name; a stale `pnpm-lock.yaml` is harmless at runtime and is
|
|
96
|
+
repaired by the next `dsh plugin --profile <profile> install`.
|
|
97
|
+
|
|
98
|
+
## Identity notes
|
|
99
|
+
|
|
100
|
+
- `client.js` registers the client module under the package name; it must match
|
|
101
|
+
`package.json` and the `name` in `cordis.patch.yml`.
|
|
102
|
+
- The Host half hands `rows` to the page as
|
|
103
|
+
`globalThis.__DSH_WORKSPACES_SCROLL__.rows` through the
|
|
104
|
+
`webserver/index-inject` table; the Client half falls back to five rows when
|
|
105
|
+
that global is absent, so a Host-half failure degrades instead of breaking.
|
|
106
|
+
- The settings tab writes through `ctx.remote.settings` (`describe`/`mutate`) and
|
|
107
|
+
needs the injected `remote` and `remote.settings` services; the DOM behavior does
|
|
108
|
+
not, so a missing settings transport only costs the tab.
|
|
109
|
+
- No `engines.dsh` range is declared on purpose: the plugin degrades to doing
|
|
110
|
+
nothing when the markers it drives change, and a wrong range would block
|
|
111
|
+
installation on builds it works on.
|
|
Binary file
|
|
Binary file
|
package/docs/preview.svg
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="640" height="300" viewBox="0 0 640 300">
|
|
2
|
+
<rect width="640" height="300" rx="20" fill="#f3f5f9"/>
|
|
3
|
+
|
|
4
|
+
<rect x="32" y="32" width="248" height="236" rx="14" fill="#ffffff" stroke="#d3dbe5" stroke-width="2"/>
|
|
5
|
+
<rect x="48" y="44" width="40" height="6" rx="3" fill="#c9d4e1"/>
|
|
6
|
+
|
|
7
|
+
<rect x="48" y="60" width="216" height="92" rx="8" fill="#f8fafd" stroke="#dfe6ef" stroke-width="1.5"/>
|
|
8
|
+
<rect x="48" y="60" width="216" height="24" rx="8" fill="#eaf1f8"/>
|
|
9
|
+
<rect x="48" y="76" width="216" height="8" fill="#eaf1f8"/>
|
|
10
|
+
<rect x="60" y="67" width="10" height="8" rx="2" fill="#247bbf" opacity="0.5"/>
|
|
11
|
+
<rect x="76" y="68" width="50" height="6" rx="3" fill="#b7c6d8"/>
|
|
12
|
+
<rect x="60" y="92" width="118" height="7" rx="3.5" fill="#c3cfdd"/>
|
|
13
|
+
<rect x="60" y="104" width="102" height="7" rx="3.5" fill="#c3cfdd"/>
|
|
14
|
+
<rect x="60" y="116" width="110" height="7" rx="3.5" fill="#c3cfdd"/>
|
|
15
|
+
<rect x="60" y="128" width="94" height="7" rx="3.5" fill="#dbe4ee"/>
|
|
16
|
+
<rect x="60" y="140" width="82" height="7" rx="3.5" fill="#dbe4ee"/>
|
|
17
|
+
<rect x="250" y="86" width="4" height="58" rx="2" fill="#e8eef5"/>
|
|
18
|
+
<rect x="250" y="88" width="4" height="20" rx="2" fill="#a8c8e8"/>
|
|
19
|
+
|
|
20
|
+
<rect x="48" y="162" width="216" height="92" rx="8" fill="#f8fafd" stroke="#dfe6ef" stroke-width="1.5"/>
|
|
21
|
+
<rect x="48" y="162" width="216" height="24" rx="8" fill="#eaf1f8"/>
|
|
22
|
+
<rect x="48" y="178" width="216" height="8" fill="#eaf1f8"/>
|
|
23
|
+
<rect x="60" y="169" width="10" height="8" rx="2" fill="#247bbf" opacity="0.5"/>
|
|
24
|
+
<rect x="76" y="170" width="58" height="6" rx="3" fill="#b7c6d8"/>
|
|
25
|
+
<rect x="60" y="194" width="104" height="7" rx="3.5" fill="#c3cfdd"/>
|
|
26
|
+
<rect x="60" y="206" width="116" height="7" rx="3.5" fill="#c3cfdd"/>
|
|
27
|
+
<rect x="60" y="218" width="90" height="7" rx="3.5" fill="#dbe4ee"/>
|
|
28
|
+
<rect x="60" y="230" width="108" height="7" rx="3.5" fill="#dbe4ee"/>
|
|
29
|
+
<rect x="60" y="242" width="76" height="7" rx="3.5" fill="#e4ebf3"/>
|
|
30
|
+
<rect x="250" y="188" width="4" height="58" rx="2" fill="#e8eef5"/>
|
|
31
|
+
<rect x="250" y="218" width="4" height="20" rx="2" fill="#a8c8e8"/>
|
|
32
|
+
|
|
33
|
+
<rect x="312" y="32" width="296" height="236" rx="14" fill="#ffffff" stroke="#d3dbe5" stroke-width="2"/>
|
|
34
|
+
<rect x="328" y="48" width="264" height="204" rx="10" fill="#f8fafd" stroke="#dfe6ef" stroke-width="1.5"/>
|
|
35
|
+
<rect x="328" y="48" width="264" height="42" rx="10" fill="#eaf1f8"/>
|
|
36
|
+
<rect x="328" y="80" width="264" height="10" fill="#eaf1f8"/>
|
|
37
|
+
<rect x="346" y="62" width="16" height="11" rx="3" fill="#247bbf" opacity="0.5"/>
|
|
38
|
+
<rect x="372" y="64" width="92" height="7" rx="3.5" fill="#b7c6d8"/>
|
|
39
|
+
<rect x="328" y="90" width="264" height="2" fill="#e3eaf2"/>
|
|
40
|
+
<rect x="346" y="104" width="182" height="9" rx="4.5" fill="#c3cfdd"/>
|
|
41
|
+
<rect x="346" y="126" width="152" height="9" rx="4.5" fill="#c3cfdd"/>
|
|
42
|
+
<rect x="346" y="148" width="202" height="9" rx="4.5" fill="#c3cfdd"/>
|
|
43
|
+
<rect x="346" y="170" width="140" height="9" rx="4.5" fill="#dbe4ee"/>
|
|
44
|
+
<rect x="346" y="192" width="172" height="9" rx="4.5" fill="#dbe4ee"/>
|
|
45
|
+
<rect x="346" y="214" width="120" height="9" rx="4.5" fill="#e4ebf3"/>
|
|
46
|
+
<rect x="574" y="98" width="6" height="142" rx="3" fill="#e8eef5"/>
|
|
47
|
+
<rect x="574" y="106" width="6" height="44" rx="3" fill="#a8c8e8"/>
|
|
48
|
+
</svg>
|
package/icon.svg
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36">
|
|
2
|
+
<rect x="8" y="9" width="17" height="3.2" rx="1.6" fill="#4c8fd0"/>
|
|
3
|
+
<rect x="8" y="14.6" width="13.5" height="2.6" rx="1.3" fill="#4c8fd0" opacity="0.45"/>
|
|
4
|
+
<rect x="8" y="19.2" width="15.5" height="2.6" rx="1.3" fill="#4c8fd0" opacity="0.45"/>
|
|
5
|
+
<rect x="8" y="23.8" width="11.5" height="2.6" rx="1.3" fill="#4c8fd0" opacity="0.45"/>
|
|
6
|
+
<rect x="26.4" y="9" width="2.2" height="17.4" rx="1.1" fill="#4c8fd0" opacity="0.22"/>
|
|
7
|
+
<rect x="26.4" y="12.4" width="2.2" height="5.6" rx="1.1" fill="#4c8fd0" opacity="0.85"/>
|
|
8
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host half of the dsh-workspaces-scroll bundle.
|
|
3
|
+
*
|
|
4
|
+
* The window height is the only setting: the count of Session rows a Workspace
|
|
5
|
+
* window shows, or `-1` to hand the sidebar back its original short list. It is a
|
|
6
|
+
* volatile Config field, so the Host settings document lists it and a changed value
|
|
7
|
+
* never restarts the plugin, and it reaches the browser through the index injection
|
|
8
|
+
* table, so the Client half reads it before the page mounts.
|
|
9
|
+
*/
|
|
10
|
+
import z from '@deepseek-ai/schemastery'
|
|
11
|
+
|
|
12
|
+
/** Rows shown when the setting is absent; the Client half falls back to the same value. */
|
|
13
|
+
export const DEFAULT_ROWS = 5
|
|
14
|
+
/** Lower bound of a window; below three rows the pinned header leaves almost no history. */
|
|
15
|
+
export const MIN_ROWS = 3
|
|
16
|
+
/** Upper bound of one window; larger values only add scrolling above the list. */
|
|
17
|
+
export const MAX_ROWS = 99
|
|
18
|
+
/** Special value that restores the shipped short list instead of a window. */
|
|
19
|
+
export const ORIGINAL_ROWS = -1
|
|
20
|
+
/** Name of the `globalThis` property the page picks the value up from. */
|
|
21
|
+
export const BOOT_KEY = '__DSH_WORKSPACES_SCROLL__'
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Session rows a window shows, or `-1` for the original sidebar. Volatile: the
|
|
25
|
+
* settings tab edits it in place, and every later page load picks the new count up
|
|
26
|
+
* from the Host.
|
|
27
|
+
*/
|
|
28
|
+
export const Config = z.object({
|
|
29
|
+
rows: z.number().min(ORIGINAL_ROWS).max(MAX_ROWS).step(1).default(DEFAULT_ROWS)
|
|
30
|
+
.description('Session rows a workspace window shows, or -1 for the original sidebar.')
|
|
31
|
+
.volatile(),
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
/** Clamp a configured row count into the supported range, keeping `-1` as is. */
|
|
35
|
+
function rowCount(value) {
|
|
36
|
+
if (value === ORIGINAL_ROWS) return ORIGINAL_ROWS
|
|
37
|
+
const rows = typeof value === 'number' && Number.isFinite(value) ? Math.round(value) : DEFAULT_ROWS
|
|
38
|
+
return Math.min(MAX_ROWS, Math.max(MIN_ROWS, rows))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Read the row count from a volatile Config field, tolerating a plain value. */
|
|
42
|
+
function readRows(config) {
|
|
43
|
+
const field = config?.rows
|
|
44
|
+
return rowCount(typeof field?.get === 'function' ? field.get() : field)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Hand the configured row count to the page.
|
|
49
|
+
* @param ctx - Host plugin context.
|
|
50
|
+
* @param config - Validated row.
|
|
51
|
+
*/
|
|
52
|
+
export function apply(ctx, config) {
|
|
53
|
+
ctx.on('webserver/index-inject', (table) => {
|
|
54
|
+
table.push({ kind: 'global', name: BOOT_KEY, value: { rows: readRows(config) } })
|
|
55
|
+
})
|
|
56
|
+
}
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Workspace session windows",
|
|
4
|
+
"description": "Each expanded workspace in the left sidebar gets its own fixed-height scrolling window: the workspace header stays pinned at the top, the workspace's whole conversation history scrolls inside it with that window's own scrollbar, and workspaces never share a scrollbar. The Show more control no longer appears. The row count is a plugin setting (Settings → Built-in plugins → Workspace windows), five rows by default, adjustable between 3 and 99, and -1 restores the original sidebar; a very long workspace renders all its rows inside the window, the plugin relies on the sidebar's shipped list markers and does nothing once they are renamed, and the flat \"In one list\" view gets no per-workspace windows. Search and its full-height result panel stay as they were.",
|
|
5
|
+
"detail": "docs/DETAIL.md"
|
|
6
|
+
}
|
|
7
|
+
}
|
package/locale/zh.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "侧栏工作区会话窗口",
|
|
4
|
+
"description": "左侧每个展开的工作区各自拥有一个固定高度的滚动窗口:工作区标题固定在上方,该工作区的全部历史会话在窗口里滚动,各自带自己的滚动条,工作区之间不共享滚动条。「展开其余 N 个会话」不再出现。窗口行数是插件设置项(设置 → 内置插件 → 工作区窗口),默认 5 行,可在 3–99 之间调整,填 -1 恢复侧栏原版行为;历史很长的工作区会把全部会话行渲染进窗口;插件依赖侧栏列表的内置标记,标记改名后自动不生效;「In one list」单列表视图不生成分工作区窗口。搜索和搜索结果面板保持原样。",
|
|
5
|
+
"detail": "docs/DETAIL.zh.md"
|
|
6
|
+
}
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-workspaces-scroll",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-workspaces-scroll",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "让左侧栏每个展开的工作区拥有各自可滚动的会话窗口,替代「展开其余」;窗口行数是设置项,默认 5 行。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Jimmm-Yuuu",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"dsh",
|
|
10
|
+
"dsh-plugin",
|
|
11
|
+
"deepseek-harness",
|
|
12
|
+
"sidebar",
|
|
13
|
+
"scroll",
|
|
14
|
+
"session-list"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/Jimmm-Yuuu/dsh-workspaces-scroll.git"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/Jimmm-Yuuu/dsh-workspaces-scroll#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/Jimmm-Yuuu/dsh-workspaces-scroll/issues"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./index.js",
|
|
26
|
+
"./client": "./client.js",
|
|
27
|
+
"./locale/*.json": "./locale/*.json",
|
|
28
|
+
"./icon": "./icon.svg"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"index.js",
|
|
32
|
+
"client.js",
|
|
33
|
+
"cordis.patch.yml",
|
|
34
|
+
"locale/*.json",
|
|
35
|
+
"docs",
|
|
36
|
+
"icon.svg",
|
|
37
|
+
"README.md",
|
|
38
|
+
"README.en.md",
|
|
39
|
+
"LICENSE"
|
|
40
|
+
],
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@deepseek-ai/schemastery": "^3.19.0"
|
|
43
|
+
},
|
|
44
|
+
"dsh": {
|
|
45
|
+
"bundle": {
|
|
46
|
+
"patch": "./cordis.patch.yml"
|
|
47
|
+
},
|
|
48
|
+
"client": {
|
|
49
|
+
"platform": "web",
|
|
50
|
+
"immediately": true
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|