dsh-workspaces-scroll 0.0.0-stage → 0.1.0
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.md +113 -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 +104 -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 +52 -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.md
CHANGED
|
@@ -1,3 +1,114 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
description: "Client plugin that gives every workspace its own scrolling session window with its own scrollbar, replacing the Show more control; the row count is a setting."
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# dsh-workspaces-scroll
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
dsh plugin --profile <profile> add dsh-workspaces-scroll
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Or open **Plugins → Add plugin** in DSH and pick the package directory of a
|
|
15
|
+
cloned checkout: DSH links a local directory instead of copying it. The registry
|
|
16
|
+
copy also appears in the plugin market inside DSH. Restart the host when it asks.
|
|
17
|
+
|
|
18
|
+
Installed on DSH Desktop 0.2.2-rc.5; the plugin claims nothing when a release
|
|
19
|
+
renames the markers it drives.
|
|
20
|
+
|
|
21
|
+
## Summary
|
|
22
|
+
|
|
23
|
+
The shipped sidebar browser keeps each expanded Workspace short by rendering the
|
|
24
|
+
first non-blank Sessions and putting the rest behind one **Show more** control at
|
|
25
|
+
the end of the group. This plugin replaces that control with a window per
|
|
26
|
+
Workspace: each expanded Workspace stays the configured number of Session rows
|
|
27
|
+
tall, keeps its header pinned at the top, and scrolls its whole history inside
|
|
28
|
+
itself with its own scrollbar.
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
Nothing else about the sidebar changes. The plugin adds no row markup and keeps no
|
|
33
|
+
state of its own: it reads one Host setting, drives the shipped control to render
|
|
34
|
+
the remaining rows, hides that control, and caps each Workspace's group section
|
|
35
|
+
while keeping its rows scrollable. Its only other surface is one tab in Settings.
|
|
36
|
+
|
|
37
|
+
## Settings
|
|
38
|
+
|
|
39
|
+
One setting, **Session rows per workspace window**, five by default:
|
|
40
|
+
|
|
41
|
+
- In DSH: **Settings → Built-in plugins → Workspace windows**. The value is a
|
|
42
|
+
number field with the browser's own up/down steps: `3`–`99` sets the window
|
|
43
|
+
height, and `-1` is the **original setting** — no window at all, the sidebar
|
|
44
|
+
keeps its short list and its **Show more** button. A change applies to the open
|
|
45
|
+
windows immediately.
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
- In the profile patch, as the row's `config`:
|
|
50
|
+
|
|
51
|
+
```yaml
|
|
52
|
+
- insert:
|
|
53
|
+
- id: workspaces-scroll
|
|
54
|
+
name: dsh-workspaces-scroll
|
|
55
|
+
config:
|
|
56
|
+
rows: 8
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The window height is derived, not set directly: it is measured from the shipped
|
|
60
|
+
list itself — the pinned header, one Session row's real height and the real gap
|
|
61
|
+
between two rows — and multiplied by the configured count, so a host or theme that
|
|
62
|
+
changes the row height keeps exactly that many rows in view instead of clipping.
|
|
63
|
+
On the current host the rows are `32px` tall, `2px` apart, under a `32px` header,
|
|
64
|
+
so five rows give `32 + 5×32 + 4×2 = 200px`. A field change rewrites the plugin
|
|
65
|
+
configuration and resizes the windows at once; every later page load reads the
|
|
66
|
+
stored value from the Host. A non-default value lives in the profile patch, a value
|
|
67
|
+
equal to the default is stored as absent.
|
|
68
|
+
|
|
69
|
+
## Behavior
|
|
70
|
+
|
|
71
|
+
- Every expanded Workspace shows a window of the configured height plus its
|
|
72
|
+
header. The window does not grow with the history.
|
|
73
|
+
- The workspace header stays pinned while its Session rows scroll beneath it, and
|
|
74
|
+
the window has its own scrollbar: wheel over that Workspace's rows in either
|
|
75
|
+
direction, or drag that window's bar. Once the window reaches an end, further
|
|
76
|
+
scrolling moves the sidebar column as before.
|
|
77
|
+
- Workspaces stay separate, one below another; no scrollbar spans two of them.
|
|
78
|
+
Folding, renaming, creating a session in, or reordering a Workspace behaves as
|
|
79
|
+
before.
|
|
80
|
+
- **Show more** no longer appears; every Session of an expanded Workspace is
|
|
81
|
+
already in its window.
|
|
82
|
+
- Search keeps its own full-height result panel; the windows apply to the
|
|
83
|
+
browsing list only.
|
|
84
|
+
|
|
85
|
+
## Known limitations
|
|
86
|
+
|
|
87
|
+
- Every Session of every expanded Workspace is rendered inside its window, so a
|
|
88
|
+
Workspace with a very long history costs more rows and more fill frames than the
|
|
89
|
+
shipped short list, even though only the configured rows are visible. The fill
|
|
90
|
+
runs one batch per animation frame.
|
|
91
|
+
- The window does not scroll the active Session into view on its own; if that
|
|
92
|
+
Session sits below the visible rows, open the window and scroll to it, the same
|
|
93
|
+
as the shipped sidebar.
|
|
94
|
+
- Dragging a Workspace to reorder it still works, but the insertion line drawn at
|
|
95
|
+
the section's top or bottom edge is clipped by the window's own overflow.
|
|
96
|
+
- Workspace Tree grouping nests child Workspaces inside the parent's section, so a
|
|
97
|
+
child that is itself capped scrolls inside the parent's window. Sibling
|
|
98
|
+
grouping, the default, has one window per Workspace.
|
|
99
|
+
- The one-list view (`Group by: In one list`) has no Workspace sections, so it
|
|
100
|
+
keeps its own layout without per-workspace windows.
|
|
101
|
+
- The plugin relies on the shipped browser's markers: the list seat
|
|
102
|
+
(`data-sidebar-list-area`), the `data-row-key` values of the Workspace, Session
|
|
103
|
+
and reveal rows, and `aria-expanded` on the reveal control. It claims the list
|
|
104
|
+
only while that control is recognizable, and it drops the claim again if the
|
|
105
|
+
control stops revealing rows, so a DSH release that renames or repurposes them
|
|
106
|
+
leaves the sidebar with its own short list instead of a window it cannot fill.
|
|
107
|
+
- It writes one style rule and one marker attribute; no markup, no storage, no
|
|
108
|
+
application state.
|
|
109
|
+
|
|
110
|
+
## Turning it off
|
|
111
|
+
|
|
112
|
+
Disabling the bundle removes its style, its wheel listener, its observers, its
|
|
113
|
+
animation frame and its marker; the sidebar returns to the short list with the
|
|
114
|
+
**Show more** control.
|
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,104 @@
|
|
|
1
|
+
# Release checklist
|
|
2
|
+
|
|
3
|
+
## Package
|
|
4
|
+
|
|
5
|
+
- `dsh-workspaces-scroll@0.1.0`, MIT, bundle patch + web client half, one Host
|
|
6
|
+
setting (`rows`: 5 by default, 3–99, or -1 for the original sidebar) and its own
|
|
7
|
+
settings tab.
|
|
8
|
+
- Contents verified with `npm pack --dry-run`: 15 files, about 1.6 MB packed; the
|
|
9
|
+
two demo GIFs (1.4 MB and 0.44 MB) are most of it.
|
|
10
|
+
- Host half imports `@deepseek-ai/schemastery` (`^3.19.0`) for the Config schema;
|
|
11
|
+
validating `{}` fills the default 5, `-1` and every integer in 3–99 pass, and
|
|
12
|
+
out-of-range values are rejected at activation.
|
|
13
|
+
|
|
14
|
+
## Verified on the running installation
|
|
15
|
+
|
|
16
|
+
DSH Desktop 0.2.2-rc.5, page at 150% scaling, two Workspaces (one with 48 Sessions):
|
|
17
|
+
|
|
18
|
+
- One window per expanded Workspace: the configured rows (five by default) exactly
|
|
19
|
+
visible, the window's own scrollbar, `scrollbar-gutter: stable`. The height is
|
|
20
|
+
measured from the shipped header, one Session row and the real row gap, then
|
|
21
|
+
tracked with a `ResizeObserver`, so a changed row height keeps the count exact
|
|
22
|
+
instead of clipping.
|
|
23
|
+
- Header stays pinned while rows scroll (`position: sticky` on the hover-card
|
|
24
|
+
anchor, `top: 0`).
|
|
25
|
+
- Wheel over a window scrolls only that window, both directions; the other
|
|
26
|
+
windows keep their position. At either end the event is left alone and the
|
|
27
|
+
sidebar column takes over as before.
|
|
28
|
+
- Every Session of the expanded Workspace is rendered and the shipped reveal
|
|
29
|
+
control is gone.
|
|
30
|
+
- Disabling the bundle removes the style, the wheel listener, the observers, the
|
|
31
|
+
animation frame and the marker; the sidebar returns to the shipped short list.
|
|
32
|
+
|
|
33
|
+
Settings, verified in the same session (number field with the browser steps):
|
|
34
|
+
|
|
35
|
+
- The plugin contributes a **Workspace windows** tab under Settings → Built-in
|
|
36
|
+
plugins (the `settings.plugins.tab` list), and the tab renders the row-count
|
|
37
|
+
number field with the stored value.
|
|
38
|
+
- Entering a number rewrites the plugin configuration and resizes the open windows
|
|
39
|
+
at once: `6` was stored as `rows: 6` and produced six-row windows, and returning
|
|
40
|
+
to the default `5` removed the override again, because the default is stored as
|
|
41
|
+
absent.
|
|
42
|
+
- Entering `-1` annotated the control as **original setting** (原版设置) and gave the
|
|
43
|
+
sidebar back its shipped list: the raised watermarks were dropped through each
|
|
44
|
+
group's collapse control, so the five short rows and the **Show more** button
|
|
45
|
+
returned; a later number switched the windows back on.
|
|
46
|
+
- With the Host half not yet reloaded (its Config still not volatile), the tab
|
|
47
|
+
appears but reports that no configuration was found instead of showing a broken
|
|
48
|
+
field.
|
|
49
|
+
|
|
50
|
+
Values above the six rows used in that run were not exercised end to end; the
|
|
51
|
+
3–99 range is enforced by the schema and the field's `min`/`max`. On this host the
|
|
52
|
+
measured geometry equals the constants (header 32, row 32, gap 2), so the measured
|
|
53
|
+
height matched the previous constant formula exactly.
|
|
54
|
+
|
|
55
|
+
Not covered: the search results panel, Workspace Tree grouping, the flat "In one
|
|
56
|
+
list" view, light theme, and narrow (390 px) sidebar states.
|
|
57
|
+
|
|
58
|
+
## Notes for the next release
|
|
59
|
+
|
|
60
|
+
The Client half hot-reloads on file changes. A changed Host half — including its
|
|
61
|
+
Config schema — only takes effect after the entry is reloaded: toggling
|
|
62
|
+
`include:workspaces-scroll` off and on through the plugin manager reloads it live,
|
|
63
|
+
and a restart does the same.
|
|
64
|
+
|
|
65
|
+
## Upload
|
|
66
|
+
|
|
67
|
+
- The manifest carries `repository`, `homepage` and `bugs` for
|
|
68
|
+
`https://github.com/Jimmm-Yuuu/dsh-workspaces-scroll`, and the repository is
|
|
69
|
+
pushed with the `v0.1.0` tag.
|
|
70
|
+
- `npm publish` from this directory (unscoped name, so `--access public` is not
|
|
71
|
+
needed).
|
|
72
|
+
- Open one entry in the `awesome-dsh-plugin` registry (PR against that repo; it
|
|
73
|
+
is the catalog the market reads, usually picked up within a day):
|
|
74
|
+
|
|
75
|
+
> workspaces-scroll — every sidebar workspace gets its own scrolling session
|
|
76
|
+
> window with a pinned header, replacing the Show more control; the row count is
|
|
77
|
+
> a setting. npm: `dsh-workspaces-scroll`, repo: `https://github.com/<you>/dsh-workspaces-scroll`
|
|
78
|
+
|
|
79
|
+
## Installing locally from this directory
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
dsh plugin --profile <profile> add "link:<path-to-checkout>/dsh-workspaces-scroll"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The profile lists the package in `dependencies` and `dsh.profile.bundles`; the
|
|
86
|
+
client half hot-reloads on file changes while the page is open, the Host half
|
|
87
|
+
needs a reload. Renaming the package again means repeating that step, because pnpm
|
|
88
|
+
keys the link by name; a stale `pnpm-lock.yaml` is harmless at runtime and is
|
|
89
|
+
repaired by the next `dsh plugin --profile <profile> install`.
|
|
90
|
+
|
|
91
|
+
## Identity notes
|
|
92
|
+
|
|
93
|
+
- `client.js` registers the client module under the package name; it must match
|
|
94
|
+
`package.json` and the `name` in `cordis.patch.yml`.
|
|
95
|
+
- The Host half hands `rows` to the page as
|
|
96
|
+
`globalThis.__DSH_WORKSPACES_SCROLL__.rows` through the
|
|
97
|
+
`webserver/index-inject` table; the Client half falls back to five rows when
|
|
98
|
+
that global is absent, so a Host-half failure degrades instead of breaking.
|
|
99
|
+
- The settings tab writes through `ctx.remote.settings` (`describe`/`mutate`) and
|
|
100
|
+
needs the injected `remote` and `remote.settings` services; the DOM behavior does
|
|
101
|
+
not, so a missing settings transport only costs the tab.
|
|
102
|
+
- No `engines.dsh` range is declared on purpose: the plugin degrades to doing
|
|
103
|
+
nothing when the markers it drives change, and a wrong range would block
|
|
104
|
+
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,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-workspaces-scroll",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-workspaces-scroll",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Give every sidebar workspace its own scrolling session window; the row count is a setting, five by default.",
|
|
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
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@deepseek-ai/schemastery": "^3.19.0"
|
|
42
|
+
},
|
|
43
|
+
"dsh": {
|
|
44
|
+
"bundle": {
|
|
45
|
+
"patch": "./cordis.patch.yml"
|
|
46
|
+
},
|
|
47
|
+
"client": {
|
|
48
|
+
"platform": "web",
|
|
49
|
+
"immediately": true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|