dsh-workspace-expand-toggle 0.0.0-stage → 1.0.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 +89 -2
- package/client.js +345 -0
- package/cordis.patch.yml +3 -0
- package/icon.svg +5 -0
- package/index.js +10 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +53 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 zhoulei1997
|
|
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,90 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-workspace-expand-toggle
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Adds one control to the sidebar's **Workspaces** header, immediately to the right
|
|
4
|
+
of the search button and before the view-options control: a toggle that collapses
|
|
5
|
+
every workspace group under it, and expands them all again on the next click.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
dsh plugin add dsh-workspace-expand-toggle
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or point **Settings → Plugins → Add plugin** at this directory. It is a bundle
|
|
14
|
+
with a Host row and a browser half; there is no build step and no configuration.
|
|
15
|
+
It requires DeepSeek Harness `0.2.2-rc.3` or newer (`0.3.x` is excluded).
|
|
16
|
+
|
|
17
|
+
## Where it sits
|
|
18
|
+
|
|
19
|
+
The shipped sidebar header reads left to right as title, search, view-options,
|
|
20
|
+
add-workspace. The toggle slides in between search and view-options, using the
|
|
21
|
+
same 28px action geometry as those buttons and only host theme tokens, so it
|
|
22
|
+
takes the palette of whatever light theme, dark theme, or skin is active.
|
|
23
|
+
|
|
24
|
+
The button states:
|
|
25
|
+
|
|
26
|
+
- **Collapse all** (two chevrons pointing up) while any workspace group is
|
|
27
|
+
unfolded.
|
|
28
|
+
- **Expand all** (two chevrons pointing down) while every group is folded.
|
|
29
|
+
|
|
30
|
+
The accessible name and the hover tooltip match the state, in the user's
|
|
31
|
+
language (Chinese and English are supplied; other locales fall back to English).
|
|
32
|
+
While a pass is running the control dims, so a second click is visibly ignored
|
|
33
|
+
instead of silently dropped.
|
|
34
|
+
|
|
35
|
+
## How it works
|
|
36
|
+
|
|
37
|
+
DeepSeek Harness gives the workspace browser one single-slot seat
|
|
38
|
+
(`sidebar.workspaces`), so the plugin cannot register a header action — the
|
|
39
|
+
shipped browser owns the whole region. This plugin therefore hooks the region's
|
|
40
|
+
DOM:
|
|
41
|
+
|
|
42
|
+
- `data-sidebar-workspace-header` marks the section header it inserts into, and
|
|
43
|
+
the header's search button (the only `aria-expanded` button there) marks the
|
|
44
|
+
insertion point.
|
|
45
|
+
- `data-sidebar-list-area` scopes the tree; the rows it drives are the public
|
|
46
|
+
`role="treeitem"` elements that carry `aria-expanded`.
|
|
47
|
+
|
|
48
|
+
Toggling dispatches each row's own click, so the shipped browser keeps owning
|
|
49
|
+
its persisted expansion state, its watermark rules, and its animations — this
|
|
50
|
+
plugin never writes that state directly. Folding runs deepest-first, because a
|
|
51
|
+
parent's collapse unmounts its descendants; unfolding repeats across passes,
|
|
52
|
+
because a parent's children mount only after it expands. Each pass waits for the
|
|
53
|
+
clicked rows to report the new state rather than assuming a fixed delay.
|
|
54
|
+
|
|
55
|
+
The plugin is a native button with one stylesheet, one mutation observer, and no
|
|
56
|
+
React root, so it cannot disturb the shipped header or the module table.
|
|
57
|
+
|
|
58
|
+
## When it hides
|
|
59
|
+
|
|
60
|
+
The control is only meaningful where the workspace tree is on screen, so it
|
|
61
|
+
steps aside instead of sitting there as a dead button:
|
|
62
|
+
|
|
63
|
+
- narrow icon rail (the section header there has no search control),
|
|
64
|
+
- the **In one list** grouping (no groups to fold),
|
|
65
|
+
- while the inline search field is open (the shipped header retracts its action
|
|
66
|
+
cluster then, and a click outside the field dismisses the search),
|
|
67
|
+
- while search results replace the tree.
|
|
68
|
+
|
|
69
|
+
## Known behaviour
|
|
70
|
+
|
|
71
|
+
- Folding also drops each group's shipped "show more" session watermark, exactly
|
|
72
|
+
as folding that group by hand does; unfolding afterwards shows the default
|
|
73
|
+
five sessions per group again.
|
|
74
|
+
- Expand all opens every group, including groups that were closed by hand
|
|
75
|
+
before a collapse-all; it does not restore an earlier arrangement.
|
|
76
|
+
- Unfolding repeats at most twelve times, one nesting level per pass; a workspace
|
|
77
|
+
tree nested deeper than that would stop with the deepest level still folded
|
|
78
|
+
and log one warning in the page console.
|
|
79
|
+
|
|
80
|
+
## Limitations
|
|
81
|
+
|
|
82
|
+
- The plugin depends on the DOM hooks above, which the shipped client package
|
|
83
|
+
does not document as a contract. A future DSH release that renames them — or
|
|
84
|
+
that adds a real header-action seat — should be met by moving this control onto
|
|
85
|
+
that seat. Until then the plugin re-attaches itself whenever the header or the
|
|
86
|
+
tree is rebuilt, and logs one console warning if the header anchor disappears
|
|
87
|
+
while a tree is still showing.
|
|
88
|
+
- "All" means the rows currently rendered by the active filter and grouping:
|
|
89
|
+
archived-only or filtered views fold only what they show.
|
|
90
|
+
- It is not a settings-row preference; it always appears while the tree is wide.
|
package/client.js
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-workspace-expand-toggle — browser half.
|
|
3
|
+
*
|
|
4
|
+
* Adds one control to the sidebar's workspace section header, immediately to
|
|
5
|
+
* the right of the search button: a collapse-all / expand-all toggle for the
|
|
6
|
+
* workspace tree under it.
|
|
7
|
+
*
|
|
8
|
+
* Why this hooks the DOM instead of a seat: the shipped workspace browser
|
|
9
|
+
* (`@deepseek-ai/dsh-client-ui-workspace`) owns the whole `sidebar.workspaces`
|
|
10
|
+
* region as a single-slot occupant, so the header has no slot a plugin could
|
|
11
|
+
* fill — the only in-tree options are replacing the entire browser or adding
|
|
12
|
+
* the control beside it. This file therefore uses the region's own DOM hooks
|
|
13
|
+
* (`data-sidebar-workspace-header`, `data-sidebar-list-area`, the header's
|
|
14
|
+
* search button) plus the tree rows' public `role="treeitem"` / `aria-expanded`
|
|
15
|
+
* state, and drives the rows' own toggle (`element.click()`) so the shipped
|
|
16
|
+
* persisted expansion store stays in charge. No React root, no Harness Client
|
|
17
|
+
* package import, no private class name.
|
|
18
|
+
*
|
|
19
|
+
* The button is a native element styled only with the host theme tokens, so it
|
|
20
|
+
* inherits light/dark, the skin, and the sidebar's 28px action geometry.
|
|
21
|
+
*
|
|
22
|
+
* The whole file is one closure because the Host concatenates client bundles
|
|
23
|
+
* into one combo script: top-level bindings must not collide with another
|
|
24
|
+
* plugin's bundle.
|
|
25
|
+
*/
|
|
26
|
+
;(function () {
|
|
27
|
+
'use strict'
|
|
28
|
+
|
|
29
|
+
/** Plugin id, locale namespace, and the button's DOM marker. */
|
|
30
|
+
const ID = 'dsh-workspace-expand-toggle'
|
|
31
|
+
/** Attribute marking the one button this plugin owns. */
|
|
32
|
+
const BUTTON_ATTRIBUTE = 'data-dsh-workspace-expand-toggle'
|
|
33
|
+
/** Attribute marking the stylesheet this plugin owns. */
|
|
34
|
+
const STYLE_ATTRIBUTE = 'data-dsh-workspace-expand-toggle-style'
|
|
35
|
+
/** The shell's workspace section header. */
|
|
36
|
+
const HEADER_SELECTOR = '[data-sidebar-workspace-header]'
|
|
37
|
+
/** The sidebar's session-tree scroller. */
|
|
38
|
+
const LIST_SELECTOR = '[data-sidebar-list-area]'
|
|
39
|
+
/** The tree's workspace/folder rows: the tree items that carry expansion state. */
|
|
40
|
+
const ROW_SELECTOR = `${LIST_SELECTOR} [role="treeitem"][aria-expanded]`
|
|
41
|
+
/** How long one toggle pass waits for the tree to commit before giving up on it. */
|
|
42
|
+
const SETTLE_MS = 600
|
|
43
|
+
/** Safety bound on toggle passes: one pass per nesting level the tree may have. */
|
|
44
|
+
const PASS_LIMIT = 12
|
|
45
|
+
|
|
46
|
+
/** Accessible names for the toggle, in the user's language. */
|
|
47
|
+
const DICTIONARIES = {
|
|
48
|
+
zh: { collapse: '全部收起', expand: '全部展开' },
|
|
49
|
+
en: { collapse: 'Collapse all', expand: 'Expand all' },
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Two stacked chevrons on the shipped 16px icon grid (the geometry of the
|
|
54
|
+
* `chevrons-up-down-outline` glyph), so the control reads as the row arrows
|
|
55
|
+
* do: up folds the tree, down unfolds it.
|
|
56
|
+
*/
|
|
57
|
+
const GLYPHS = {
|
|
58
|
+
collapse: 'm5.1 6.9 2.9-2.9 2.9 2.9M5.1 12l2.9-2.9 2.9 2.9',
|
|
59
|
+
expand: 'm5.1 4 2.9 2.9 2.9-2.9M5.1 9.1l2.9 2.9 2.9-2.9',
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** One 14px glyph element; the state attribute in CSS picks which one shows. */
|
|
63
|
+
function glyph(name, path) {
|
|
64
|
+
return `<svg class="dsh-wexp-glyph dsh-wexp-glyph-${name}" xmlns="http://www.w3.org/2000/svg"`
|
|
65
|
+
+ ' viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor"'
|
|
66
|
+
+ ' stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"'
|
|
67
|
+
+ ` aria-hidden="true"><path d="${path}"/></svg>`
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Geometry, palette, and state rules for the button. Colors and radii are
|
|
72
|
+
* host tokens only, so a light theme, a dark theme, or a skin recolors it the
|
|
73
|
+
* same way it recolors the shipped 28px header buttons beside it.
|
|
74
|
+
*/
|
|
75
|
+
const STYLESHEET = `
|
|
76
|
+
[${BUTTON_ATTRIBUTE}] {
|
|
77
|
+
flex: none;
|
|
78
|
+
display: inline-flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
width: 28px;
|
|
82
|
+
height: 28px;
|
|
83
|
+
border: none;
|
|
84
|
+
border-radius: var(--dsw-radius-sm);
|
|
85
|
+
padding: 0;
|
|
86
|
+
margin: 0;
|
|
87
|
+
background: transparent;
|
|
88
|
+
color: var(--dsw-alias-label-secondary);
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
}
|
|
91
|
+
[${BUTTON_ATTRIBUTE}][hidden] {
|
|
92
|
+
display: none;
|
|
93
|
+
}
|
|
94
|
+
[${BUTTON_ATTRIBUTE}][data-busy] {
|
|
95
|
+
opacity: 0.55;
|
|
96
|
+
cursor: progress;
|
|
97
|
+
}
|
|
98
|
+
[${BUTTON_ATTRIBUTE}] .dsh-wexp-glyph {
|
|
99
|
+
display: block;
|
|
100
|
+
}
|
|
101
|
+
[${BUTTON_ATTRIBUTE}][data-state="collapse"] .dsh-wexp-glyph-expand,
|
|
102
|
+
[${BUTTON_ATTRIBUTE}][data-state="expand"] .dsh-wexp-glyph-collapse {
|
|
103
|
+
display: none;
|
|
104
|
+
}
|
|
105
|
+
@media (hover: hover) {
|
|
106
|
+
[${BUTTON_ATTRIBUTE}]:hover {
|
|
107
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
[${BUTTON_ATTRIBUTE}]:focus-visible {
|
|
111
|
+
outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary, currentColor));
|
|
112
|
+
outline-offset: -2px;
|
|
113
|
+
}
|
|
114
|
+
`
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Count ancestors, for folding deepest-first: a parent's collapse unmounts
|
|
118
|
+
* the descendants that still have to receive their own toggle.
|
|
119
|
+
* @param row - a tree row.
|
|
120
|
+
* @returns its depth in the document.
|
|
121
|
+
*/
|
|
122
|
+
function depth(row) {
|
|
123
|
+
let count = 0
|
|
124
|
+
let node = row
|
|
125
|
+
while (node.parentElement !== null) {
|
|
126
|
+
node = node.parentElement
|
|
127
|
+
count += 1
|
|
128
|
+
}
|
|
129
|
+
return count
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Whether a node is (or contains) a region this plugin watches: the section
|
|
134
|
+
* header or the session-tree scroller. Streaming text outside them never
|
|
135
|
+
* schedules a state pass.
|
|
136
|
+
* @param node - a mutation target or an added/removed node.
|
|
137
|
+
* @returns true when the sidebar workspace region is involved.
|
|
138
|
+
*/
|
|
139
|
+
function inRegion(node) {
|
|
140
|
+
if (!(node instanceof Element)) return false
|
|
141
|
+
return node.closest(HEADER_SELECTOR) !== null || node.closest(LIST_SELECTOR) !== null
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
window.__ModuleLoader__.load({
|
|
145
|
+
id: ID,
|
|
146
|
+
factory() {
|
|
147
|
+
return {
|
|
148
|
+
/** Client locale dictionary registration and translation binding. */
|
|
149
|
+
inject: ['locale'],
|
|
150
|
+
/**
|
|
151
|
+
* Mount the header toggle for as long as this plugin instance lives.
|
|
152
|
+
* @param ctx - client plugin context.
|
|
153
|
+
*/
|
|
154
|
+
apply(ctx) {
|
|
155
|
+
ctx.effect(() => {
|
|
156
|
+
// A generation overlap (HMR) must not fail the whole effect.
|
|
157
|
+
try {
|
|
158
|
+
return ctx.locale.register(ID, DICTIONARIES)
|
|
159
|
+
} catch (error) {
|
|
160
|
+
console.warn('[dsh-workspace-expand-toggle] locale dictionary not registered:', error)
|
|
161
|
+
return () => {}
|
|
162
|
+
}
|
|
163
|
+
}, 'dsh-workspace-expand-toggle: dictionaries')
|
|
164
|
+
|
|
165
|
+
ctx.effect(() => {
|
|
166
|
+
// A previous generation (HMR or a relaunch) may have left its button behind.
|
|
167
|
+
document.querySelectorAll(`[${BUTTON_ATTRIBUTE}], style[${STYLE_ATTRIBUTE}]`).forEach(node => { node.remove() })
|
|
168
|
+
|
|
169
|
+
const style = document.createElement('style')
|
|
170
|
+
style.setAttribute(STYLE_ATTRIBUTE, '')
|
|
171
|
+
style.textContent = STYLESHEET
|
|
172
|
+
document.head.appendChild(style)
|
|
173
|
+
|
|
174
|
+
const button = document.createElement('button')
|
|
175
|
+
button.type = 'button'
|
|
176
|
+
button.setAttribute(BUTTON_ATTRIBUTE, '')
|
|
177
|
+
button.dataset.state = 'collapse'
|
|
178
|
+
button.innerHTML = glyph('collapse', GLYPHS.collapse) + glyph('expand', GLYPHS.expand)
|
|
179
|
+
|
|
180
|
+
const translate = ctx.locale.bind(ID)
|
|
181
|
+
let disposed = false
|
|
182
|
+
let frame = 0
|
|
183
|
+
let busy = false
|
|
184
|
+
let warned = false
|
|
185
|
+
|
|
186
|
+
/** The workspace/folder rows currently rendered, in document order. */
|
|
187
|
+
const rows = () => Array.from(document.querySelectorAll(ROW_SELECTOR))
|
|
188
|
+
/** Whether one row reports itself unfolded. */
|
|
189
|
+
const unfolded = row => row.getAttribute('aria-expanded') === 'true'
|
|
190
|
+
/** One broken-contract diagnostic per generation, never per frame. */
|
|
191
|
+
const diagnose = () => {
|
|
192
|
+
if (warned || rows().length === 0) return
|
|
193
|
+
warned = true
|
|
194
|
+
console.warn('[dsh-workspace-expand-toggle] workspace header anchor not found;'
|
|
195
|
+
+ ' the sidebar DOM hooks this plugin relies on may have changed')
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Keep the button in the right place and showing the right verb.
|
|
200
|
+
* The header is wide-only and its action cluster retracts while the
|
|
201
|
+
* inline search is open, so the control steps aside in exactly those
|
|
202
|
+
* states instead of staying as a dead (or layout-stealing) button.
|
|
203
|
+
*/
|
|
204
|
+
const sync = () => {
|
|
205
|
+
if (disposed) return
|
|
206
|
+
const header = document.querySelector(HEADER_SELECTOR)
|
|
207
|
+
// The wide header's search control is the anchor; the rail header has none.
|
|
208
|
+
const search = header === null ? null : header.querySelector('button[aria-expanded]')
|
|
209
|
+
if (header === null || search === null) {
|
|
210
|
+
button.remove()
|
|
211
|
+
diagnose()
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
// Expanded search owns the whole header row; the shipped cluster hides too.
|
|
215
|
+
if (search.getAttribute('aria-expanded') === 'true') {
|
|
216
|
+
button.remove()
|
|
217
|
+
return
|
|
218
|
+
}
|
|
219
|
+
// Walk up to the header's own child so a Tooltip wrapper or a
|
|
220
|
+
// future inner element cannot misplace the insertion.
|
|
221
|
+
let anchor = search
|
|
222
|
+
while (anchor.parentElement !== null && anchor.parentElement !== header) {
|
|
223
|
+
anchor = anchor.parentElement
|
|
224
|
+
}
|
|
225
|
+
if (button.parentElement !== header || button.previousElementSibling !== anchor) {
|
|
226
|
+
// Right of search, left of the view-options cluster; a React
|
|
227
|
+
// re-insert across the seam is healed the same way.
|
|
228
|
+
anchor.after(button)
|
|
229
|
+
}
|
|
230
|
+
const list = rows()
|
|
231
|
+
const collapse = list.some(unfolded)
|
|
232
|
+
button.hidden = list.length === 0
|
|
233
|
+
button.dataset.state = collapse ? 'collapse' : 'expand'
|
|
234
|
+
const label = translate(collapse ? 'collapse' : 'expand')
|
|
235
|
+
if (button.getAttribute('aria-label') !== label) {
|
|
236
|
+
button.setAttribute('aria-label', label)
|
|
237
|
+
button.title = label
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Coalesce DOM churn into one state pass per animation frame. */
|
|
242
|
+
const queue = () => {
|
|
243
|
+
if (disposed || frame !== 0) return
|
|
244
|
+
frame = window.requestAnimationFrame(() => {
|
|
245
|
+
frame = 0
|
|
246
|
+
sync()
|
|
247
|
+
})
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Ignore mutations outside the sidebar workspace region (chat streaming). */
|
|
251
|
+
const relevant = records => records.some(record => {
|
|
252
|
+
if (record.type === 'attributes') return inRegion(record.target)
|
|
253
|
+
if (inRegion(record.target)) return true
|
|
254
|
+
return [...record.addedNodes, ...record.removedNodes].some(node => node instanceof Element
|
|
255
|
+
&& (inRegion(node) || node.querySelector(HEADER_SELECTOR) !== null
|
|
256
|
+
|| node.querySelector(LIST_SELECTOR) !== null))
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Resolve once every clicked row reports the state its click asked
|
|
261
|
+
* for, or the deadline passes; unmounted rows count as settled.
|
|
262
|
+
*/
|
|
263
|
+
const settled = (targets, wanted) => new Promise(resolve => {
|
|
264
|
+
const started = Date.now()
|
|
265
|
+
const check = () => {
|
|
266
|
+
const pending = targets.some(row => row.isConnected
|
|
267
|
+
&& row.getAttribute('aria-expanded') !== wanted)
|
|
268
|
+
if (disposed || !pending || Date.now() - started > SETTLE_MS) {
|
|
269
|
+
resolve()
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
window.setTimeout(check, 16)
|
|
273
|
+
}
|
|
274
|
+
check()
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Fold or unfold the whole workspace tree. Folding runs deepest
|
|
279
|
+
* first so nested groups get their own toggle before an ancestor
|
|
280
|
+
* unmounts them; unfolding repeats until no collapsed row remains
|
|
281
|
+
* because a parent's children mount only after it unfolds.
|
|
282
|
+
*/
|
|
283
|
+
const toggleAll = async () => {
|
|
284
|
+
if (busy) return
|
|
285
|
+
const list = rows()
|
|
286
|
+
if (list.length === 0) return
|
|
287
|
+
busy = true
|
|
288
|
+
button.dataset.busy = ''
|
|
289
|
+
const collapse = list.some(unfolded)
|
|
290
|
+
const wanted = collapse ? 'false' : 'true'
|
|
291
|
+
// Row identity, so a row that did not change state is not clicked twice.
|
|
292
|
+
const touched = new Set()
|
|
293
|
+
try {
|
|
294
|
+
for (let pass = 0; pass < PASS_LIMIT; pass += 1) {
|
|
295
|
+
const candidates = rows().filter(row => (collapse ? unfolded(row) : !unfolded(row))
|
|
296
|
+
&& !touched.has(row.dataset.rowKey ?? row))
|
|
297
|
+
if (candidates.length === 0) return
|
|
298
|
+
if (collapse) candidates.sort((a, b) => depth(b) - depth(a))
|
|
299
|
+
for (const row of candidates) {
|
|
300
|
+
touched.add(row.dataset.rowKey ?? row)
|
|
301
|
+
row.click()
|
|
302
|
+
}
|
|
303
|
+
await settled(candidates, wanted)
|
|
304
|
+
if (disposed) return
|
|
305
|
+
}
|
|
306
|
+
} finally {
|
|
307
|
+
busy = false
|
|
308
|
+
delete button.dataset.busy
|
|
309
|
+
sync()
|
|
310
|
+
}
|
|
311
|
+
if (rows().some(row => (collapse ? unfolded(row) : !unfolded(row)))) {
|
|
312
|
+
console.warn('[dsh-workspace-expand-toggle] some workspace groups did not toggle')
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
button.addEventListener('click', () => { void toggleAll() })
|
|
317
|
+
|
|
318
|
+
// Row remounts, aria-expanded flips, header replacements, and the
|
|
319
|
+
// search field opening all land here; mutations elsewhere are ignored.
|
|
320
|
+
const observer = new MutationObserver(records => {
|
|
321
|
+
if (relevant(records)) queue()
|
|
322
|
+
})
|
|
323
|
+
observer.observe(document.documentElement, {
|
|
324
|
+
childList: true,
|
|
325
|
+
subtree: true,
|
|
326
|
+
attributes: true,
|
|
327
|
+
attributeFilter: ['aria-expanded'],
|
|
328
|
+
})
|
|
329
|
+
const offLocale = ctx.locale.subscribe(queue)
|
|
330
|
+
|
|
331
|
+
sync()
|
|
332
|
+
return () => {
|
|
333
|
+
disposed = true
|
|
334
|
+
observer.disconnect()
|
|
335
|
+
offLocale()
|
|
336
|
+
if (frame !== 0) window.cancelAnimationFrame(frame)
|
|
337
|
+
button.remove()
|
|
338
|
+
style.remove()
|
|
339
|
+
}
|
|
340
|
+
}, 'dsh-workspace-expand-toggle: header toggle')
|
|
341
|
+
},
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
})
|
|
345
|
+
})()
|
package/cordis.patch.yml
ADDED
package/icon.svg
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36" role="img" aria-label="Collapse or expand all workspaces">
|
|
2
|
+
<path d="M7 11h12M7 18h12M7 25h12" fill="none" stroke="#8f979f" stroke-width="2.2" stroke-linecap="round" />
|
|
3
|
+
<path d="m24.8 12.4 2.9 2.9 2.9-2.9" fill="none" stroke="#2f7fd1" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" />
|
|
4
|
+
<path d="m24.8 23.6 2.9-2.9 2.9 2.9" fill="none" stroke="#2f7fd1" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" />
|
|
5
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host half of the workspace expand/collapse toggle.
|
|
3
|
+
*
|
|
4
|
+
* The browser half (the `./client` export) owns the header control, the
|
|
5
|
+
* stylesheet, and the row toggling. This row only has to exist and stay
|
|
6
|
+
* enabled: the Web module table scans live Loader entries for packages that
|
|
7
|
+
* declare `dsh.client`, so the row is what makes the browser half load. It
|
|
8
|
+
* registers nothing itself.
|
|
9
|
+
*/
|
|
10
|
+
export function apply() {}
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Collapse or expand all workspaces",
|
|
4
|
+
"description": "Adds one button to the sidebar's Workspaces header, right of Search and before the view-options control: it collapses every workspace group under it, and a second click expands them all again. The icon and name follow the current state, and Expand all also opens groups that were closed by hand. The button steps aside in the collapsed icon rail, in the single-list grouping, while the inline search field is open, and while search results are showing."
|
|
5
|
+
}
|
|
6
|
+
}
|
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workspace-expand-toggle",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A collapse-all / expand-all toggle beside the sidebar search button for the DeepSeek Harness workspace tree.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"dsh",
|
|
8
|
+
"dsh-plugin",
|
|
9
|
+
"deepseek-harness",
|
|
10
|
+
"plugin",
|
|
11
|
+
"workspace",
|
|
12
|
+
"sidebar",
|
|
13
|
+
"expand",
|
|
14
|
+
"collapse",
|
|
15
|
+
"ui"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "zhoulei1997",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": "./index.js",
|
|
21
|
+
"./client": "./client.js",
|
|
22
|
+
"./locale/*.json": "./locale/*.json",
|
|
23
|
+
"./icon": "./icon.svg",
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"index.js",
|
|
28
|
+
"client.js",
|
|
29
|
+
"cordis.patch.yml",
|
|
30
|
+
"locale/*.json",
|
|
31
|
+
"icon.svg",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"dsh": ">=0.2.2-rc.3 <0.3.0"
|
|
37
|
+
},
|
|
38
|
+
"dsh": {
|
|
39
|
+
"bundle": {
|
|
40
|
+
"patch": "./cordis.patch.yml"
|
|
41
|
+
},
|
|
42
|
+
"client": {
|
|
43
|
+
"platform": "web",
|
|
44
|
+
"immediately": true,
|
|
45
|
+
"inject": [
|
|
46
|
+
"@deepseek-ai/dsh-client-locale",
|
|
47
|
+
"@deepseek-ai/dsh-client-ui-workspace"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public",
|
|
53
|
+
"registry": "https://registry.npmjs.org"
|
|
54
|
+
}
|
|
55
|
+
}
|