dsh-nested-workspaces 1.3.0 → 2.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/README.md +29 -16
- package/client.js +296 -107
- package/index.js +13 -134
- package/locale/en.json +1 -1
- package/locale/ja.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
Nested child workspaces for the DeepSeek Harness sidebar.
|
|
4
4
|
|
|
5
5
|
DeepSeek Harness lists every workspace as a peer. This plugin turns that list
|
|
6
|
-
into a tree: a workspace can own child
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
into a tree: a workspace can own child workspace *groups*, sessions can be filed
|
|
7
|
+
under any group, and the section title becomes yours to name.
|
|
8
|
+
|
|
9
|
+
A child is a grouping record kept by this plugin, not a new folder on disk — the
|
|
10
|
+
project directory is left exactly as it was.
|
|
9
11
|
|
|
10
12
|
## What it does
|
|
11
13
|
|
|
@@ -14,10 +16,14 @@ name.
|
|
|
14
16
|
the same from the keyboard. The name is stored in this browser and falls back to
|
|
15
17
|
the built-in label when emptied.
|
|
16
18
|
- **Add child workspace.** Right-click a workspace (or use its `…` menu) and pick
|
|
17
|
-
**添加子工作区 / Add child workspace**. The dialog asks for a
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
**添加子工作区 / Add child workspace**. The dialog asks for a name and records a
|
|
20
|
+
child group under that workspace. **Nothing is created on disk** — the child is a
|
|
21
|
+
grouping kept in this plugin's own browser storage, so you can split a project
|
|
22
|
+
into sections without littering the repository with empty folders.
|
|
23
|
+
- **New sessions run where the code is.** The `+` on a child group starts the
|
|
24
|
+
session in the nearest real workspace above it (the root, or the parent group's
|
|
25
|
+
real workspace), then files the new row under the child. The child never becomes
|
|
26
|
+
a workspace, so DSH's path binding stays consistent.
|
|
21
27
|
- **File sessions under any workspace.** Drag a session row onto a workspace
|
|
22
28
|
header, or drop it above/below another session to place it exactly. The `…` menu
|
|
23
29
|
on every session also offers **移动到工作区 / Move to workspace** with one entry
|
|
@@ -61,8 +67,13 @@ directory with the workspace path. A session therefore cannot be re-homed to a
|
|
|
61
67
|
workspace with a different path. Filing a session under another workspace is a
|
|
62
68
|
*view* assignment kept by this plugin: the row is shown under the workspace you
|
|
63
69
|
dropped it on, and open/fork/archive keep working, but the session's own working
|
|
64
|
-
directory is unchanged.
|
|
65
|
-
|
|
70
|
+
directory is unchanged.
|
|
71
|
+
|
|
72
|
+
A child workspace is a group, so it has no directory of its own either — the `+`
|
|
73
|
+
on a child starts its session in the nearest real workspace above it, and the
|
|
74
|
+
session then appears under that child. Deleting a child group deletes the record
|
|
75
|
+
and its nested groups; the sessions it showed return to the workspace that really
|
|
76
|
+
owns them.
|
|
66
77
|
|
|
67
78
|
This plugin replaces the shipped workspace browser (it registers the same sidebar
|
|
68
79
|
seat at a lower priority, which is the only way to own the section title and the
|
|
@@ -80,13 +91,15 @@ row list). A few things come with that trade:
|
|
|
80
91
|
`sidebar.session.row.hover`) are not rendered on these rows, so additions other
|
|
81
92
|
plugins place in them will not appear inside this section. The session `…` menu
|
|
82
93
|
is unaffected and remains the supported extension point.
|
|
83
|
-
- **Add child workspace
|
|
84
|
-
directory
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
- **Add child workspace needs no Host support at all.** Earlier versions created
|
|
95
|
+
a real directory, which failed on a Host whose composed directory picker only
|
|
96
|
+
serves the OS chooser (the `native` capability cannot
|
|
97
|
+
`createDirectory`). Children are now records in the browser store, so the
|
|
98
|
+
add-child dialog works everywhere and never touches the filesystem.
|
|
99
|
+
- **Upgrading from 1.x.** Children made by 1.x are real folders that were also
|
|
100
|
+
registered with the Host, so they still show up as ordinary workspaces. Delete
|
|
101
|
+
them here (the folder stays on disk) and add them again as groups if you want
|
|
102
|
+
them to become records.
|
|
90
103
|
|
|
91
104
|
## Using it
|
|
92
105
|
|
package/client.js
CHANGED
|
@@ -42,11 +42,12 @@ window.__ModuleLoader__.load({
|
|
|
42
42
|
'dialog.rename.title': '重命名工作区',
|
|
43
43
|
'dialog.delete.title': '删除工作区',
|
|
44
44
|
'dialog.delete.description': '将把「{name}」从侧边栏移除,磁盘上的文件不会被删除。',
|
|
45
|
+
'dialog.deleteGroup.description': '将把子工作区分组「{name}」及其下级分组从侧边栏删除;其中的会话会回到它们真正所属的工作区。',
|
|
45
46
|
'renamed': '已重命名',
|
|
46
47
|
'deleted': '已删除工作区',
|
|
47
48
|
'dialog.addChild.title': '添加子工作区',
|
|
48
49
|
'dialog.addWorkspace.title': '添加工作区',
|
|
49
|
-
'dialog.addChild.description': '
|
|
50
|
+
'dialog.addChild.description': '会在 {parent} 下新建一个子工作区分组;只在侧栏里记录,不会在磁盘上创建文件夹。',
|
|
50
51
|
'dialog.addWorkspace.description': '填写工作区目录的绝对路径;留空则打开目录选择器。',
|
|
51
52
|
'field.name': '子工作区名称',
|
|
52
53
|
'field.path': '工作区路径(留空可选择)',
|
|
@@ -61,6 +62,7 @@ window.__ModuleLoader__.load({
|
|
|
61
62
|
'actions.hideArchived': '隐藏已归档会话',
|
|
62
63
|
'created': '已创建工作区',
|
|
63
64
|
'createdChild': '已创建子工作区',
|
|
65
|
+
'virtual.hint': '分组,会话在',
|
|
64
66
|
'moved': '已移动会话',
|
|
65
67
|
'rail.search': '搜索',
|
|
66
68
|
'expandGroup': '展开分组',
|
|
@@ -88,7 +90,6 @@ window.__ModuleLoader__.load({
|
|
|
88
90
|
'status.planReview': '等待确认计划',
|
|
89
91
|
'status.waitingAnswer': '等待回答',
|
|
90
92
|
'errors.reorderFailed': '工作区排序更新失败',
|
|
91
|
-
'errors.invalidParent': 'The parent workspace directory is not usable.',
|
|
92
93
|
'errors.unreadable': 'The new directory could not be read.',
|
|
93
94
|
},
|
|
94
95
|
en: {
|
|
@@ -108,11 +109,12 @@ window.__ModuleLoader__.load({
|
|
|
108
109
|
'dialog.rename.title': 'Rename workspace',
|
|
109
110
|
'dialog.delete.title': 'Delete workspace',
|
|
110
111
|
'dialog.delete.description': 'This removes "{name}" from the sidebar. Files on disk are kept.',
|
|
112
|
+
'dialog.deleteGroup.description': 'This removes the child workspace group "{name}" and its nested groups from the sidebar. Sessions it showed return to the workspace that owns them.',
|
|
111
113
|
'renamed': 'Renamed',
|
|
112
114
|
'deleted': 'Workspace deleted',
|
|
113
115
|
'dialog.addChild.title': 'Add child workspace',
|
|
114
116
|
'dialog.addWorkspace.title': 'Add workspace',
|
|
115
|
-
'dialog.addChild.description': '
|
|
117
|
+
'dialog.addChild.description': 'Adds a child workspace group under {parent}. It is only recorded in the sidebar — no folder is created on disk.',
|
|
116
118
|
'dialog.addWorkspace.description': 'Enter the absolute path of the workspace directory, or leave it empty to pick a folder.',
|
|
117
119
|
'field.name': 'Child workspace name',
|
|
118
120
|
'field.path': 'Workspace path (empty to pick)',
|
|
@@ -127,6 +129,7 @@ window.__ModuleLoader__.load({
|
|
|
127
129
|
'actions.hideArchived': 'Hide archived sessions',
|
|
128
130
|
'created': 'Workspace created',
|
|
129
131
|
'createdChild': 'Child workspace created',
|
|
132
|
+
'virtual.hint': 'group, sessions run in',
|
|
130
133
|
'moved': 'Session moved',
|
|
131
134
|
'rail.search': 'Search',
|
|
132
135
|
'expandGroup': 'Expand group',
|
|
@@ -154,7 +157,6 @@ window.__ModuleLoader__.load({
|
|
|
154
157
|
'status.planReview': 'Waiting for plan review',
|
|
155
158
|
'status.waitingAnswer': 'Waiting for an answer',
|
|
156
159
|
'errors.reorderFailed': 'Could not reorder the workspace',
|
|
157
|
-
'errors.invalidParent': 'The parent workspace directory is not usable.',
|
|
158
160
|
'errors.unreadable': 'The new directory could not be read.',
|
|
159
161
|
},
|
|
160
162
|
ja: {
|
|
@@ -174,11 +176,12 @@ window.__ModuleLoader__.load({
|
|
|
174
176
|
'dialog.rename.title': 'ワークスペース名を変更',
|
|
175
177
|
'dialog.delete.title': 'ワークスペースを削除',
|
|
176
178
|
'dialog.delete.description': '「{name}」をサイドバーから削除します。ディスク上のファイルは残ります。',
|
|
179
|
+
'dialog.deleteGroup.description': '子ワークスペースのグループ「{name}」とその下位グループをサイドバーから削除します。そこに表示されていたセッションは本来のワークスペースに戻ります。',
|
|
177
180
|
'renamed': '名前を変更しました',
|
|
178
181
|
'deleted': 'ワークスペースを削除しました',
|
|
179
182
|
'dialog.addChild.title': '子ワークスペースを追加',
|
|
180
183
|
'dialog.addWorkspace.title': 'ワークスペースを追加',
|
|
181
|
-
'dialog.addChild.description': '{parent}
|
|
184
|
+
'dialog.addChild.description': '{parent} の下に子ワークスペースのグループを追加します。サイドバーに記録するだけで、ディスク上にフォルダーは作成しません。',
|
|
182
185
|
'dialog.addWorkspace.description': 'ワークスペースの絶対パスを入力するか、空欄のままフォルダを選択してください。',
|
|
183
186
|
'field.name': '子ワークスペース名',
|
|
184
187
|
'field.path': 'ワークスペースのパス(空欄で選択)',
|
|
@@ -193,6 +196,7 @@ window.__ModuleLoader__.load({
|
|
|
193
196
|
'actions.hideArchived': 'アーカイブ済みを隠す',
|
|
194
197
|
'created': 'ワークスペースを作成しました',
|
|
195
198
|
'createdChild': '子ワークスペースを作成しました',
|
|
199
|
+
'virtual.hint': 'グループ、セッションの実行先は',
|
|
196
200
|
'moved': 'セッションを移動しました',
|
|
197
201
|
'rail.search': '検索',
|
|
198
202
|
'expandGroup': 'グループを開く',
|
|
@@ -220,7 +224,6 @@ window.__ModuleLoader__.load({
|
|
|
220
224
|
'status.planReview': 'プラン確認待ち',
|
|
221
225
|
'status.waitingAnswer': '回答待ち',
|
|
222
226
|
'errors.reorderFailed': 'ワークスペースの並び順を更新できませんでした',
|
|
223
|
-
'errors.invalidParent': '親ワークスペースのディレクトリを使用できません。',
|
|
224
227
|
'errors.unreadable': '作成したディレクトリを読み取れませんでした。',
|
|
225
228
|
},
|
|
226
229
|
}
|
|
@@ -514,9 +517,42 @@ window.__ModuleLoader__.load({
|
|
|
514
517
|
}
|
|
515
518
|
}
|
|
516
519
|
|
|
520
|
+
/** A child workspace is a record in this store, never a directory. */
|
|
521
|
+
function normalizeChildren(value) {
|
|
522
|
+
if (!Array.isArray(value)) return []
|
|
523
|
+
const seen = new Set()
|
|
524
|
+
const children = []
|
|
525
|
+
for (const entry of value) {
|
|
526
|
+
if (!isRecord(entry)) continue
|
|
527
|
+
const id = typeof entry.id === 'string' ? entry.id.trim() : ''
|
|
528
|
+
const parentId = typeof entry.parentId === 'string' ? entry.parentId.trim() : ''
|
|
529
|
+
const title = typeof entry.title === 'string' ? entry.title.trim() : ''
|
|
530
|
+
if (id === '' || parentId === '' || title === '') continue
|
|
531
|
+
if (seen.has(id)) continue
|
|
532
|
+
seen.add(id)
|
|
533
|
+
children.push({ id, parentId, title })
|
|
534
|
+
}
|
|
535
|
+
return children
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function newChildId() {
|
|
539
|
+
return 'vk-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 8)
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/** Move one child record before another (or to the end of its parent run). */
|
|
543
|
+
function moveChildRecord(children, id, anchorId) {
|
|
544
|
+
const record = children.find(entry => entry.id === id)
|
|
545
|
+
if (record === undefined) return children
|
|
546
|
+
const rest = children.filter(entry => entry.id !== id)
|
|
547
|
+
if (anchorId === undefined || anchorId === null) return [...rest, record]
|
|
548
|
+
const at = rest.findIndex(entry => entry.id === anchorId)
|
|
549
|
+
if (at === -1) return [...rest, record]
|
|
550
|
+
return [...rest.slice(0, at), record, ...rest.slice(at)]
|
|
551
|
+
}
|
|
552
|
+
|
|
517
553
|
function createStore() {
|
|
518
554
|
const read = () => {
|
|
519
|
-
const empty = { title: null, assign: {}, order: {}, collapsed: {} }
|
|
555
|
+
const empty = { title: null, assign: {}, order: {}, collapsed: {}, children: [] }
|
|
520
556
|
if (typeof localStorage === 'undefined') return empty
|
|
521
557
|
try {
|
|
522
558
|
const raw = localStorage.getItem(STORAGE_KEY)
|
|
@@ -528,6 +564,7 @@ window.__ModuleLoader__.load({
|
|
|
528
564
|
assign: isRecord(parsed.assign) ? parsed.assign : {},
|
|
529
565
|
order: isRecord(parsed.order) ? parsed.order : {},
|
|
530
566
|
collapsed: isRecord(parsed.collapsed) ? parsed.collapsed : {},
|
|
567
|
+
children: normalizeChildren(parsed.children),
|
|
531
568
|
}
|
|
532
569
|
} catch {
|
|
533
570
|
return empty
|
|
@@ -574,6 +611,7 @@ window.__ModuleLoader__.load({
|
|
|
574
611
|
known.add(item.workspaceId)
|
|
575
612
|
if (realOwner === null && item.sessionIds.includes(sessionId)) realOwner = item.workspaceId
|
|
576
613
|
}
|
|
614
|
+
for (const id of current.children) known.add(id.id)
|
|
577
615
|
const assigned = current.assign[sessionId]
|
|
578
616
|
const previousKey =
|
|
579
617
|
typeof assigned === 'string' && known.has(assigned)
|
|
@@ -600,7 +638,7 @@ window.__ModuleLoader__.load({
|
|
|
600
638
|
}
|
|
601
639
|
|
|
602
640
|
return {
|
|
603
|
-
inject: ['slots', 'locale', 'contextMenus', 'workspaces', 'uiWorkspace', 'sessions'
|
|
641
|
+
inject: ['slots', 'locale', 'contextMenus', 'workspaces', 'uiWorkspace', 'sessions'],
|
|
604
642
|
apply(ctx) {
|
|
605
643
|
const store = createStore()
|
|
606
644
|
const addChildRequest = createSignal(null)
|
|
@@ -627,47 +665,6 @@ window.__ModuleLoader__.load({
|
|
|
627
665
|
}
|
|
628
666
|
}
|
|
629
667
|
|
|
630
|
-
/* --------------------------------------------------- child directories */
|
|
631
|
-
|
|
632
|
-
/* The composed directory picker is a capability union: a Host whose
|
|
633
|
-
* backend is the OS chooser serves only `native`, and `createDirectory`
|
|
634
|
-
* belongs to `browse`, so it answers "needs the browse capability".
|
|
635
|
-
* Making a folder is not really browsing, so this bundle's Host half
|
|
636
|
-
* does the mkdir and answers over Connection; `createDirectory` stays
|
|
637
|
-
* as the fallback for compositions that do serve the browse backend. */
|
|
638
|
-
const CREATE_CHILD_ENDPOINT = 'nested-workspaces'
|
|
639
|
-
|
|
640
|
-
const createChildDirectory = async (parent, name) => {
|
|
641
|
-
const connection = ctx.get('connection')
|
|
642
|
-
const rpc = connection !== null && typeof connection === 'object' ? connection.rpc : null
|
|
643
|
-
if (rpc !== null && typeof rpc === 'object' && typeof rpc.call === 'function') {
|
|
644
|
-
let result = null
|
|
645
|
-
try {
|
|
646
|
-
const controller = typeof AbortController === 'function' ? new AbortController() : null
|
|
647
|
-
result = await rpc.call(
|
|
648
|
-
'/api',
|
|
649
|
-
CREATE_CHILD_ENDPOINT,
|
|
650
|
-
{ action: 'createChild', parent, name },
|
|
651
|
-
controller === null ? undefined : controller.signal,
|
|
652
|
-
)
|
|
653
|
-
} catch {
|
|
654
|
-
/* Transport missing or route unregistered: fall through to the
|
|
655
|
-
* shipped picker endpoint below. */
|
|
656
|
-
result = null
|
|
657
|
-
}
|
|
658
|
-
if (result !== null && typeof result === 'object') {
|
|
659
|
-
if (result.ok === true) {
|
|
660
|
-
const value = result.value !== null && typeof result.value === 'object' ? result.value.path : undefined
|
|
661
|
-
if (typeof value === 'string' && value !== '') return value
|
|
662
|
-
throw new Error('createChild answered without a directory path')
|
|
663
|
-
} else if (result.error !== null && typeof result.error === 'object' && typeof result.error.code === 'string') {
|
|
664
|
-
throw Object.assign(new Error(String(result.error.message || result.error.code)), { code: result.error.code })
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
return uiWorkspace.createDirectory(parent, name)
|
|
669
|
-
}
|
|
670
|
-
|
|
671
668
|
/* ------------------------------------------------------- context menus */
|
|
672
669
|
|
|
673
670
|
ctx.effect(
|
|
@@ -685,7 +682,7 @@ window.__ModuleLoader__.load({
|
|
|
685
682
|
run: () => {
|
|
686
683
|
addChildRequest.set({
|
|
687
684
|
parentId: target.workspaceId,
|
|
688
|
-
parentPath:
|
|
685
|
+
parentPath: null,
|
|
689
686
|
parentTitle: target.displayTitle,
|
|
690
687
|
})
|
|
691
688
|
},
|
|
@@ -727,6 +724,18 @@ window.__ModuleLoader__.load({
|
|
|
727
724
|
notify(ctx.locale.bind(NS)('moved'), true)
|
|
728
725
|
},
|
|
729
726
|
}))
|
|
727
|
+
/* Virtual child groups are this plugin's own records, so they are
|
|
728
|
+
* listed from the store rather than from the workspace list. */
|
|
729
|
+
for (const record of store.get().children) {
|
|
730
|
+
children.push({
|
|
731
|
+
id: 'move:' + record.id,
|
|
732
|
+
label: record.title,
|
|
733
|
+
run: () => {
|
|
734
|
+
assignSessionIn(store, items, sessionId, record.id, undefined)
|
|
735
|
+
notify(ctx.locale.bind(NS)('moved'), true)
|
|
736
|
+
},
|
|
737
|
+
})
|
|
738
|
+
}
|
|
730
739
|
children.push({
|
|
731
740
|
id: 'move:ungrouped',
|
|
732
741
|
label: ctx.locale.bind(NS)('ungrouped'),
|
|
@@ -757,7 +766,9 @@ window.__ModuleLoader__.load({
|
|
|
757
766
|
|
|
758
767
|
function NewWorkspaceDialog(props) {
|
|
759
768
|
const request = props.request
|
|
760
|
-
|
|
769
|
+
/* A request carries `parentId` for a child group; a top-level "add
|
|
770
|
+
* workspace" leaves it null and asks for a real directory instead. */
|
|
771
|
+
const isChild = typeof request.parentId === 'string' && request.parentId !== ''
|
|
761
772
|
const [value, setValue] = useState('')
|
|
762
773
|
const [busy, setBusy] = useState(false)
|
|
763
774
|
const [error, setError] = useState(null)
|
|
@@ -782,7 +793,6 @@ window.__ModuleLoader__.load({
|
|
|
782
793
|
}
|
|
783
794
|
/* The Host answers these two with a stable code and an English OS
|
|
784
795
|
* string; show the localized wording instead of the raw message. */
|
|
785
|
-
if (code === 'nested-workspaces/invalid-parent') return t('errors.invalidParent')
|
|
786
796
|
if (code === 'directory-picker/unreadable') return t('errors.unreadable')
|
|
787
797
|
return t('errors.createFailed', { message })
|
|
788
798
|
}
|
|
@@ -801,10 +811,24 @@ window.__ModuleLoader__.load({
|
|
|
801
811
|
setBusy(true)
|
|
802
812
|
setError(null)
|
|
803
813
|
try {
|
|
804
|
-
|
|
814
|
+
/* A child workspace is a record in this plugin's store — no folder,
|
|
815
|
+
* no Host registration. Its sessions run in the nearest real
|
|
816
|
+
* ancestor, which is why nothing needs to be created on disk. */
|
|
805
817
|
if (isChild) {
|
|
806
|
-
|
|
807
|
-
|
|
818
|
+
const id = newChildId()
|
|
819
|
+
store.update(state => ({
|
|
820
|
+
...state,
|
|
821
|
+
/* Prepend: a freshly added child sits at the top of its
|
|
822
|
+
* siblings, the same place the shipped browser puts one. */
|
|
823
|
+
children: [{ id, parentId: request.parentId, title: trimmed }, ...state.children],
|
|
824
|
+
collapsed: { ...state.collapsed, [request.parentId]: false },
|
|
825
|
+
}))
|
|
826
|
+
notify(t('createdChild'), true)
|
|
827
|
+
props.onClose()
|
|
828
|
+
return
|
|
829
|
+
}
|
|
830
|
+
let path = trimmed
|
|
831
|
+
if (path === '') {
|
|
808
832
|
/* No typed path: ask the host's directory picker, which is the
|
|
809
833
|
* same flow the shipped picker uses. */
|
|
810
834
|
const picked = await uiWorkspace.pickDirectory()
|
|
@@ -814,28 +838,8 @@ window.__ModuleLoader__.load({
|
|
|
814
838
|
setValue(picked)
|
|
815
839
|
setBusy(true)
|
|
816
840
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
store.update(state => ({
|
|
820
|
-
...state,
|
|
821
|
-
collapsed: { ...state.collapsed, [request.parentId]: false },
|
|
822
|
-
}))
|
|
823
|
-
/* Land the new child at the TOP of its siblings instead of below
|
|
824
|
-
* them. The Host appends new registrations after the existing
|
|
825
|
-
* ones, so anchor the new workspace to the first sibling that is
|
|
826
|
-
* already registered under the same parent. */
|
|
827
|
-
const createdId = created && created.workspaceId ? created.workspaceId : null
|
|
828
|
-
if (createdId !== null) {
|
|
829
|
-
const snapshot = workspaces.list.getSnapshot()
|
|
830
|
-
const siblings = snapshot.items
|
|
831
|
-
.filter(item => item.workspaceId !== createdId)
|
|
832
|
-
.filter(item => owningParentPath(item.path, snapshot.items.map(entry => entry.path)) === request.parentPath)
|
|
833
|
-
if (siblings.length > 0) await workspaces.insertBefore(createdId, siblings[0].workspaceId).catch(() => {})
|
|
834
|
-
}
|
|
835
|
-
notify(t('createdChild'), true)
|
|
836
|
-
} else {
|
|
837
|
-
notify(t('created'), true)
|
|
838
|
-
}
|
|
841
|
+
await workspaces.create({ path })
|
|
842
|
+
notify(t('created'), true)
|
|
839
843
|
props.onClose()
|
|
840
844
|
} catch (failure) {
|
|
841
845
|
setError(describe(failure))
|
|
@@ -849,7 +853,7 @@ window.__ModuleLoader__.load({
|
|
|
849
853
|
{
|
|
850
854
|
title: isChild ? t('dialog.addChild.title') : t('dialog.addWorkspace.title'),
|
|
851
855
|
description: isChild
|
|
852
|
-
? t('dialog.addChild.description', { parent: request.
|
|
856
|
+
? t('dialog.addChild.description', { parent: request.parentTitle })
|
|
853
857
|
: t('dialog.addWorkspace.description'),
|
|
854
858
|
error,
|
|
855
859
|
busy,
|
|
@@ -1153,6 +1157,18 @@ window.__ModuleLoader__.load({
|
|
|
1153
1157
|
setBusy(true)
|
|
1154
1158
|
setError(null)
|
|
1155
1159
|
try {
|
|
1160
|
+
/* A virtual group has no Host record; its title lives here. */
|
|
1161
|
+
if (workspace.virtual) {
|
|
1162
|
+
store.update(current => ({
|
|
1163
|
+
...current,
|
|
1164
|
+
children: current.children.map(entry =>
|
|
1165
|
+
entry.id === workspace.workspaceId ? { ...entry, title: trimmed } : entry,
|
|
1166
|
+
),
|
|
1167
|
+
}))
|
|
1168
|
+
notify(t('renamed'), true)
|
|
1169
|
+
onClose()
|
|
1170
|
+
return
|
|
1171
|
+
}
|
|
1156
1172
|
await workspaces.rename(workspace.workspaceId, trimmed)
|
|
1157
1173
|
notify(t('renamed'), true)
|
|
1158
1174
|
onClose()
|
|
@@ -1206,7 +1222,62 @@ window.__ModuleLoader__.load({
|
|
|
1206
1222
|
setBusy(true)
|
|
1207
1223
|
setError(null)
|
|
1208
1224
|
try {
|
|
1225
|
+
if (workspace.virtual) {
|
|
1226
|
+
/* Drop the record and its subtree; sessions filed under it fall
|
|
1227
|
+
* back to their real workspace because their assignment is gone. */
|
|
1228
|
+
const doomed = new Set([workspace.workspaceId])
|
|
1229
|
+
let grew = true
|
|
1230
|
+
while (grew) {
|
|
1231
|
+
grew = false
|
|
1232
|
+
for (const entry of store.get().children) {
|
|
1233
|
+
if (doomed.has(entry.parentId) && !doomed.has(entry.id)) {
|
|
1234
|
+
doomed.add(entry.id)
|
|
1235
|
+
grew = true
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
store.update(current => {
|
|
1240
|
+
const assign = { ...current.assign }
|
|
1241
|
+
for (const [sessionId, groupKey] of Object.entries(assign)) {
|
|
1242
|
+
if (doomed.has(groupKey)) delete assign[sessionId]
|
|
1243
|
+
}
|
|
1244
|
+
return {
|
|
1245
|
+
...current,
|
|
1246
|
+
children: current.children.filter(entry => !doomed.has(entry.id)),
|
|
1247
|
+
assign,
|
|
1248
|
+
}
|
|
1249
|
+
})
|
|
1250
|
+
notify(t('deleted'), true)
|
|
1251
|
+
onClose()
|
|
1252
|
+
return
|
|
1253
|
+
}
|
|
1209
1254
|
await workspaces.delete(workspace.workspaceId)
|
|
1255
|
+
/* Its child groups can no longer be reached through the tree, so
|
|
1256
|
+
* drop the records instead of leaving them orphaned in storage. */
|
|
1257
|
+
const orphans = new Set([workspace.workspaceId])
|
|
1258
|
+
let spread = true
|
|
1259
|
+
while (spread) {
|
|
1260
|
+
spread = false
|
|
1261
|
+
for (const entry of store.get().children) {
|
|
1262
|
+
if (orphans.has(entry.parentId) && !orphans.has(entry.id)) {
|
|
1263
|
+
orphans.add(entry.id)
|
|
1264
|
+
spread = true
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
if (orphans.size > 1) {
|
|
1269
|
+
store.update(current => {
|
|
1270
|
+
const assign = { ...current.assign }
|
|
1271
|
+
for (const [sessionId, groupKey] of Object.entries(assign)) {
|
|
1272
|
+
if (orphans.has(groupKey)) delete assign[sessionId]
|
|
1273
|
+
}
|
|
1274
|
+
return {
|
|
1275
|
+
...current,
|
|
1276
|
+
children: current.children.filter(entry => !orphans.has(entry.id)),
|
|
1277
|
+
assign,
|
|
1278
|
+
}
|
|
1279
|
+
})
|
|
1280
|
+
}
|
|
1210
1281
|
notify(t('deleted'), true)
|
|
1211
1282
|
onClose()
|
|
1212
1283
|
} catch (failure) {
|
|
@@ -1218,7 +1289,9 @@ window.__ModuleLoader__.load({
|
|
|
1218
1289
|
|
|
1219
1290
|
return h(DialogShell, {
|
|
1220
1291
|
title: t('dialog.delete.title'),
|
|
1221
|
-
description:
|
|
1292
|
+
description: workspace.virtual === true
|
|
1293
|
+
? t('dialog.deleteGroup.description', { name: workspace.title })
|
|
1294
|
+
: t('dialog.delete.description', { name: workspace.title }),
|
|
1222
1295
|
error,
|
|
1223
1296
|
busy,
|
|
1224
1297
|
danger: true,
|
|
@@ -1463,7 +1536,7 @@ window.__ModuleLoader__.load({
|
|
|
1463
1536
|
|
|
1464
1537
|
function WorkspaceGroup(props) {
|
|
1465
1538
|
const { workspace, depth, env } = props
|
|
1466
|
-
const { view, state, t, uiWorkspace, useWorkspaceAccess, openMenu, openWorkspaceMenu, assignSession, setExpanded, setRenaming, menu, dragIdRef, draggingId, dropTarget, setDropTarget, setDraggingId, workspaceDrag, draggingWorkspaceId, beginWorkspaceDrag, endWorkspaceDrag, hoverWorkspaceDrag, workspaceClickBlockRef } = env
|
|
1539
|
+
const { view, state, t, uiWorkspace, useWorkspaceAccess, openMenu, openWorkspaceMenu, assignSession, startSessionInGroup, setExpanded, setRenaming, menu, dragIdRef, draggingId, dropTarget, setDropTarget, setDraggingId, workspaceDrag, draggingWorkspaceId, beginWorkspaceDrag, endWorkspaceDrag, hoverWorkspaceDrag, workspaceClickBlockRef } = env
|
|
1467
1540
|
const workspaceId = workspace.workspaceId
|
|
1468
1541
|
const collapsed = state.collapsed[workspaceId] === true
|
|
1469
1542
|
const members = view.members.get(workspaceId) || []
|
|
@@ -1475,7 +1548,11 @@ window.__ModuleLoader__.load({
|
|
|
1475
1548
|
const isDropTarget =
|
|
1476
1549
|
dropTarget !== null && dropTarget.workspaceId === workspaceId && dropTarget.sessionId === undefined
|
|
1477
1550
|
const indent = { '--dnw-indent': depth * INDENT_PX + 'px' }
|
|
1478
|
-
|
|
1551
|
+
/* A virtual group has no directory of its own: access and new sessions
|
|
1552
|
+
* belong to the nearest real ancestor, which is where it runs. */
|
|
1553
|
+
const realId = view.realOf.get(workspaceId)
|
|
1554
|
+
const accessId = realId === undefined ? workspaceId : realId
|
|
1555
|
+
const canCreateSession = useWorkspaceAccess(accessId, 'session/create')
|
|
1479
1556
|
const collapsible = children.length > 0 || hasSessions
|
|
1480
1557
|
/* A workspace drag is legal only between rows that share a parent, so a
|
|
1481
1558
|
* child can be reordered among its siblings but never leave its root. */
|
|
@@ -1504,7 +1581,9 @@ window.__ModuleLoader__.load({
|
|
|
1504
1581
|
tabIndex: 0,
|
|
1505
1582
|
draggable: true,
|
|
1506
1583
|
'aria-expanded': !collapsed,
|
|
1507
|
-
'aria-label': workspace.
|
|
1584
|
+
'aria-label': workspace.virtual
|
|
1585
|
+
? workspace.title + ' — ' + t('virtual.hint') + ' ' + workspace.path
|
|
1586
|
+
: workspace.title + ' — ' + workspace.path,
|
|
1508
1587
|
style: indent,
|
|
1509
1588
|
onClick: () => {
|
|
1510
1589
|
/* A drag ends with a click; expanding on it would undo the drop. */
|
|
@@ -1652,7 +1731,7 @@ window.__ModuleLoader__.load({
|
|
|
1652
1731
|
'aria-label': t('actions.newSession') + ' ' + workspace.title,
|
|
1653
1732
|
onClick: event => {
|
|
1654
1733
|
event.stopPropagation()
|
|
1655
|
-
|
|
1734
|
+
startSessionInGroup(workspaceId, accessId)
|
|
1656
1735
|
},
|
|
1657
1736
|
},
|
|
1658
1737
|
h(IconPlus, null),
|
|
@@ -1732,24 +1811,89 @@ window.__ModuleLoader__.load({
|
|
|
1732
1811
|
const byId = new Map(items.map(item => [item.workspaceId, item]))
|
|
1733
1812
|
const byPath = new Map(items.map(item => [item.path, item.workspaceId]))
|
|
1734
1813
|
const paths = items.map(item => item.path)
|
|
1735
|
-
|
|
1814
|
+
|
|
1815
|
+
/* Real workspaces nest by path ancestry. */
|
|
1816
|
+
const realParentOf = new Map()
|
|
1736
1817
|
for (const item of items) {
|
|
1737
1818
|
const parentPath = owningParentPath(item.path, paths)
|
|
1738
1819
|
if (parentPath === null) continue
|
|
1739
1820
|
const parentId = byPath.get(parentPath)
|
|
1740
|
-
if (parentId !== undefined)
|
|
1821
|
+
if (parentId !== undefined) realParentOf.set(item.workspaceId, parentId)
|
|
1741
1822
|
}
|
|
1823
|
+
|
|
1824
|
+
const realOf = new Map()
|
|
1825
|
+
const realIdOf = parentId => {
|
|
1826
|
+
let cursor = parentId
|
|
1827
|
+
for (let guard = 0; cursor !== undefined && guard < 64; guard += 1) {
|
|
1828
|
+
const real = realOf.get(cursor)
|
|
1829
|
+
if (real !== undefined) return real
|
|
1830
|
+
cursor = parentOf.get(cursor)
|
|
1831
|
+
}
|
|
1832
|
+
return undefined
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
const parentOf = new Map(realParentOf)
|
|
1836
|
+
const nodesById = new Map()
|
|
1837
|
+
for (const item of items) {
|
|
1838
|
+
nodesById.set(item.workspaceId, {
|
|
1839
|
+
workspaceId: item.workspaceId,
|
|
1840
|
+
title: item.title,
|
|
1841
|
+
path: item.path,
|
|
1842
|
+
virtual: false,
|
|
1843
|
+
parentId: realParentOf.get(item.workspaceId),
|
|
1844
|
+
})
|
|
1845
|
+
realOf.set(item.workspaceId, item.workspaceId)
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
/* Virtual children: records only. Their `path` is the nearest real
|
|
1849
|
+
* ancestor's directory, because that is where a session started
|
|
1850
|
+
* from them actually runs. Records are stored flat, so resolve them
|
|
1851
|
+
* to a fixpoint: a record whose parent is another record only lands
|
|
1852
|
+
* once that parent is known. */
|
|
1853
|
+
let pending = state.children.slice()
|
|
1854
|
+
for (let pass = 0; pass < 64 && pending.length > 0; pass += 1) {
|
|
1855
|
+
const deferred = []
|
|
1856
|
+
let placed = 0
|
|
1857
|
+
for (const record of pending) {
|
|
1858
|
+
const parent = nodesById.get(record.parentId)
|
|
1859
|
+
if (parent === undefined) {
|
|
1860
|
+
deferred.push(record)
|
|
1861
|
+
continue
|
|
1862
|
+
}
|
|
1863
|
+
placed += 1
|
|
1864
|
+
parentOf.set(record.id, record.parentId)
|
|
1865
|
+
const realId = parent.virtual ? realIdOf(record.parentId) : parent.workspaceId
|
|
1866
|
+
nodesById.set(record.id, {
|
|
1867
|
+
workspaceId: record.id,
|
|
1868
|
+
title: record.title,
|
|
1869
|
+
path: realId === undefined ? parent.path : (byId.get(realId) || parent).path,
|
|
1870
|
+
virtual: true,
|
|
1871
|
+
parentId: record.parentId,
|
|
1872
|
+
})
|
|
1873
|
+
if (realId !== undefined) realOf.set(record.id, realId)
|
|
1874
|
+
}
|
|
1875
|
+
pending = deferred
|
|
1876
|
+
if (placed === 0) break
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1742
1879
|
const childrenOf = new Map()
|
|
1743
1880
|
const roots = []
|
|
1744
1881
|
for (const item of items) {
|
|
1745
|
-
const parentId =
|
|
1882
|
+
const parentId = realParentOf.get(item.workspaceId)
|
|
1746
1883
|
if (parentId === undefined) {
|
|
1747
|
-
roots.push(item)
|
|
1884
|
+
roots.push(nodesById.get(item.workspaceId))
|
|
1748
1885
|
continue
|
|
1749
1886
|
}
|
|
1750
1887
|
const bucket = childrenOf.get(parentId)
|
|
1751
|
-
if (bucket === undefined) childrenOf.set(parentId, [item])
|
|
1752
|
-
else bucket.push(item)
|
|
1888
|
+
if (bucket === undefined) childrenOf.set(parentId, [nodesById.get(item.workspaceId)])
|
|
1889
|
+
else bucket.push(nodesById.get(item.workspaceId))
|
|
1890
|
+
}
|
|
1891
|
+
for (const record of state.children) {
|
|
1892
|
+
const node = nodesById.get(record.id)
|
|
1893
|
+
if (node === undefined) continue
|
|
1894
|
+
const bucket = childrenOf.get(record.parentId)
|
|
1895
|
+
if (bucket === undefined) childrenOf.set(record.parentId, [node])
|
|
1896
|
+
else bucket.push(node)
|
|
1753
1897
|
}
|
|
1754
1898
|
|
|
1755
1899
|
const archived = new Set(workspaceSnapshot.archivedSessionIds)
|
|
@@ -1760,14 +1904,16 @@ window.__ModuleLoader__.load({
|
|
|
1760
1904
|
|
|
1761
1905
|
const ownerOf = id => {
|
|
1762
1906
|
const assigned = state.assign[id]
|
|
1763
|
-
if (typeof assigned === 'string' &&
|
|
1907
|
+
if (typeof assigned === 'string' && nodesById.has(assigned)) return assigned
|
|
1764
1908
|
const real = realOwner.get(id)
|
|
1765
|
-
|
|
1909
|
+
if (real === undefined) return UNGROUPED
|
|
1910
|
+
/* A session whose real workspace is not visible belongs to no group */
|
|
1911
|
+
return nodesById.has(real) ? real : UNGROUPED
|
|
1766
1912
|
}
|
|
1767
1913
|
|
|
1768
1914
|
const members = new Map()
|
|
1769
1915
|
members.set(UNGROUPED, [])
|
|
1770
|
-
for (const
|
|
1916
|
+
for (const nodeId of nodesById.keys()) members.set(nodeId, [])
|
|
1771
1917
|
|
|
1772
1918
|
const needle = query.trim().toLowerCase()
|
|
1773
1919
|
const matches = text => needle === '' || String(text || '').toLowerCase().includes(needle)
|
|
@@ -1823,8 +1969,8 @@ window.__ModuleLoader__.load({
|
|
|
1823
1969
|
let visibleCount = 0
|
|
1824
1970
|
for (const bucket of members.values()) visibleCount += bucket.length
|
|
1825
1971
|
|
|
1826
|
-
return { byId, parentOf, childrenOf, roots, members, currentId, ownerOf, realOwner, archived, pinned, filtering, visibleCount }
|
|
1827
|
-
}, [items, list, state.order, state.assign, workspaceSnapshot.archivedSessionIds, workspaceSnapshot.pinnedSessionIds, query, showArchived])
|
|
1972
|
+
return { byId, nodesById, parentOf, childrenOf, roots, members, currentId, ownerOf, realOwner, realOf, archived, pinned, filtering, visibleCount }
|
|
1973
|
+
}, [items, list, state.order, state.assign, state.children, workspaceSnapshot.archivedSessionIds, workspaceSnapshot.pinnedSessionIds, query, showArchived])
|
|
1828
1974
|
|
|
1829
1975
|
const setExpanded = useCallback((workspaceId, expanded) => {
|
|
1830
1976
|
store.update(current => ({
|
|
@@ -1835,21 +1981,34 @@ window.__ModuleLoader__.load({
|
|
|
1835
1981
|
|
|
1836
1982
|
/* Workspace reorder. Mirrors the shipped `commitWorkspaceDrag`: the drop
|
|
1837
1983
|
* anchor is the next row after the target, and a move that would leave
|
|
1838
|
-
* the order unchanged is dropped instead of being
|
|
1984
|
+
* the order unchanged is dropped instead of being written.
|
|
1985
|
+
* A virtual group is ordered in this plugin's own store, a real
|
|
1986
|
+
* workspace in the Host registry, so the two are never mixed. */
|
|
1839
1987
|
const commitWorkspaceDrag = useCallback(
|
|
1840
1988
|
(drag, over) => {
|
|
1841
1989
|
if (drag === null || over === null) return
|
|
1990
|
+
const dragged = view.nodesById.get(drag.workspaceId)
|
|
1991
|
+
const target = view.nodesById.get(over.id)
|
|
1992
|
+
if (dragged === undefined || target === undefined) return
|
|
1842
1993
|
const owner = view.parentOf.get(drag.workspaceId)
|
|
1843
|
-
if (
|
|
1844
|
-
|
|
1845
|
-
|
|
1994
|
+
if (view.parentOf.get(over.id) !== owner) return
|
|
1995
|
+
/* Mixing the plugin order with the Host order would need a position
|
|
1996
|
+
* neither store can express, so a cross-kind drop is refused. */
|
|
1997
|
+
if (dragged.virtual !== target.virtual) return
|
|
1998
|
+
const siblings =
|
|
1999
|
+
owner === undefined ? view.roots.slice() : (view.childrenOf.get(owner) || []).slice()
|
|
2000
|
+
const rowIndex = siblings.findIndex(node => node.workspaceId === over.id)
|
|
1846
2001
|
if (rowIndex === -1) return
|
|
1847
2002
|
const anchor = over.half === 'before' ? over.id : (siblings[rowIndex + 1] || {}).workspaceId
|
|
1848
2003
|
if (anchor === drag.workspaceId) return
|
|
1849
|
-
const sourceIndex = siblings.findIndex(
|
|
2004
|
+
const sourceIndex = siblings.findIndex(node => node.workspaceId === drag.workspaceId)
|
|
1850
2005
|
const anchorIndex =
|
|
1851
|
-
anchor === undefined ? siblings.length : siblings.findIndex(
|
|
2006
|
+
anchor === undefined ? siblings.length : siblings.findIndex(node => node.workspaceId === anchor)
|
|
1852
2007
|
if (sourceIndex !== -1 && (anchorIndex === sourceIndex || anchorIndex === sourceIndex + 1)) return
|
|
2008
|
+
if (dragged.virtual) {
|
|
2009
|
+
store.update(current => ({ ...current, children: moveChildRecord(current.children, drag.workspaceId, anchor) }))
|
|
2010
|
+
return
|
|
2011
|
+
}
|
|
1853
2012
|
workspaces.insertBefore(drag.workspaceId, anchor).catch(() => {
|
|
1854
2013
|
notify(t('errors.reorderFailed'), false)
|
|
1855
2014
|
})
|
|
@@ -1920,6 +2079,35 @@ window.__ModuleLoader__.load({
|
|
|
1920
2079
|
[view],
|
|
1921
2080
|
)
|
|
1922
2081
|
|
|
2082
|
+
/**
|
|
2083
|
+
* New session for a row. A real workspace opens its own blank. A
|
|
2084
|
+
* virtual group has no directory, so the session is created in the
|
|
2085
|
+
* nearest real ancestor and then filed into the group — the same
|
|
2086
|
+
* display assignment a drag writes, only done right after creation.
|
|
2087
|
+
*/
|
|
2088
|
+
const startSessionInGroup = useCallback(
|
|
2089
|
+
(groupId, realId) => {
|
|
2090
|
+
const node = view.nodesById.get(groupId)
|
|
2091
|
+
if (node === undefined || node.virtual !== true) {
|
|
2092
|
+
uiWorkspace.startSession(realId === undefined ? groupId : realId)
|
|
2093
|
+
return
|
|
2094
|
+
}
|
|
2095
|
+
if (realId === undefined) {
|
|
2096
|
+
uiWorkspace.startSession()
|
|
2097
|
+
return
|
|
2098
|
+
}
|
|
2099
|
+
void uiWorkspace
|
|
2100
|
+
.openWorkspace(realId, sessionId => {
|
|
2101
|
+
assignSession(sessionId, groupId, undefined)
|
|
2102
|
+
})
|
|
2103
|
+
.catch(failure => {
|
|
2104
|
+
const message = failure && failure.message ? String(failure.message) : String(failure)
|
|
2105
|
+
notify(t('errors.createFailed', { message }), false)
|
|
2106
|
+
})
|
|
2107
|
+
},
|
|
2108
|
+
[view, uiWorkspace, assignSession, notify, t],
|
|
2109
|
+
)
|
|
2110
|
+
|
|
1923
2111
|
const openMenu = (target, label) => {
|
|
1924
2112
|
if (typeof renderFactorySlot !== 'function') return null
|
|
1925
2113
|
const node = renderFactorySlot('contextMenu.button', { target, label, className: 'dnw-iconButton' })
|
|
@@ -1940,11 +2128,12 @@ window.__ModuleLoader__.load({
|
|
|
1940
2128
|
})
|
|
1941
2129
|
}
|
|
1942
2130
|
|
|
1943
|
-
const menuWorkspace =
|
|
1944
|
-
menu === null ? null : items.find(item => item.workspaceId === menu.workspaceId) || null
|
|
2131
|
+
const menuWorkspace = menu === null ? null : view.nodesById.get(menu.workspaceId) || null
|
|
1945
2132
|
|
|
1946
2133
|
const menuItems = useMemo(() => {
|
|
1947
2134
|
if (menuWorkspace === null) return []
|
|
2135
|
+
const groupId = menuWorkspace.workspaceId
|
|
2136
|
+
const realId = view.realOf.get(groupId)
|
|
1948
2137
|
return [
|
|
1949
2138
|
{
|
|
1950
2139
|
id: 'addChild',
|
|
@@ -1952,8 +2141,8 @@ window.__ModuleLoader__.load({
|
|
|
1952
2141
|
icon: IconFolderPlus,
|
|
1953
2142
|
onSelect: () =>
|
|
1954
2143
|
addChildRequest.set({
|
|
1955
|
-
parentId:
|
|
1956
|
-
parentPath:
|
|
2144
|
+
parentId: groupId,
|
|
2145
|
+
parentPath: null,
|
|
1957
2146
|
parentTitle: menuWorkspace.title,
|
|
1958
2147
|
}),
|
|
1959
2148
|
},
|
|
@@ -1961,7 +2150,7 @@ window.__ModuleLoader__.load({
|
|
|
1961
2150
|
id: 'newSession',
|
|
1962
2151
|
label: t('actions.newSession'),
|
|
1963
2152
|
icon: IconPlus,
|
|
1964
|
-
onSelect: () =>
|
|
2153
|
+
onSelect: () => startSessionInGroup(groupId, realId),
|
|
1965
2154
|
},
|
|
1966
2155
|
{
|
|
1967
2156
|
id: 'rename',
|
|
@@ -1978,7 +2167,7 @@ window.__ModuleLoader__.load({
|
|
|
1978
2167
|
onSelect: () => setDeleting(menuWorkspace),
|
|
1979
2168
|
},
|
|
1980
2169
|
]
|
|
1981
|
-
}, [menuWorkspace, t,
|
|
2170
|
+
}, [menuWorkspace, t, view, startSessionInGroup])
|
|
1982
2171
|
|
|
1983
2172
|
const commitTitle = () => {
|
|
1984
2173
|
/* Escape sets the cancel flag first; the input then unmounts and its
|
|
@@ -2031,7 +2220,7 @@ window.__ModuleLoader__.load({
|
|
|
2031
2220
|
const env = {
|
|
2032
2221
|
view, state, statuses, t, uiWorkspace, list,
|
|
2033
2222
|
useSessionAccess, useWorkspaceAccess,
|
|
2034
|
-
openMenu, openWorkspaceMenu, assignSession, setExpanded, setRenaming,
|
|
2223
|
+
openMenu, openWorkspaceMenu, assignSession, startSessionInGroup, setExpanded, setRenaming,
|
|
2035
2224
|
menu, menuOpenSessionId, draggingId, dropTarget, dragIdRef, setDraggingId, setDropTarget,
|
|
2036
2225
|
workspaceDrag, draggingWorkspaceId: workspaceDrag === null ? null : workspaceDrag.workspaceId,
|
|
2037
2226
|
beginWorkspaceDrag, hoverWorkspaceDrag, endWorkspaceDrag, workspaceClickBlockRef,
|
package/index.js
CHANGED
|
@@ -1,140 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* dsh-nested-workspaces — Host half.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* A child workspace is a grouping record in this plugin's own storage, not a
|
|
5
|
+
* directory and not a Workspace registration: DSH binds a Session to a
|
|
6
|
+
* Workspace by exact path equality, so a folder could only ever hold sessions
|
|
7
|
+
* whose cwd already matched it. Keeping the grouping purely in the Client
|
|
8
|
+
* half means nothing is written into the user's project directories, and a
|
|
9
|
+
* session started from a child simply runs in the nearest real ancestor.
|
|
7
10
|
*
|
|
8
|
-
* The
|
|
9
|
-
*
|
|
10
|
-
* and a Host whose picker backend is the OS chooser serves only the `native`
|
|
11
|
-
* capability: `directoryPicker.createDirectory` then answers
|
|
12
|
-
* `directory-picker/unavailable: ... needs the browse capability`. Creating a
|
|
13
|
-
* folder is not really a "browse" feature, so this bundle answers it over the
|
|
14
|
-
* public Connection transport instead (the same `/api` carrier other bundles
|
|
15
|
-
* use), and the Client falls back to `createDirectory` when this route is
|
|
16
|
-
* missing.
|
|
11
|
+
* The Host half therefore has no work to do. It exists so the bundle is a
|
|
12
|
+
* well-formed DSH package.
|
|
17
13
|
*/
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
/** No Host services are needed: the grouping lives in the browser. */
|
|
16
|
+
export const inject = []
|
|
21
17
|
|
|
22
|
-
/**
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
/** Exact route below `/api`; Connection rejects anything that is not an exact `/api/...` path. */
|
|
26
|
-
const ROUTE_PATH = '/api/nested-workspaces'
|
|
27
|
-
/** Envelope method name, mirrored by the Client call. */
|
|
28
|
-
const ENDPOINT = 'nested-workspaces'
|
|
29
|
-
|
|
30
|
-
/** A child name becomes one directory segment, so it may not carry a separator. */
|
|
31
|
-
const INVALID_NAME = /[\\/]/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Validate the requested child name.
|
|
35
|
-
* @param value - raw name from the Client.
|
|
36
|
-
* @returns the trimmed name, or null when it cannot be a directory segment.
|
|
37
|
-
*/
|
|
38
|
-
function normalizeName(value) {
|
|
39
|
-
if (typeof value !== 'string') return null
|
|
40
|
-
const name = value.trim()
|
|
41
|
-
if (name === '' || name === '.' || name === '..') return null
|
|
42
|
-
if (INVALID_NAME.test(name)) return null
|
|
43
|
-
return name
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** One failure result in the Connection envelope. */
|
|
47
|
-
function failure(code, message) {
|
|
48
|
-
return { ok: false, error: { code, message, details: {} } }
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Create `<parent>/<name>` without creating any other segment.
|
|
53
|
-
* @param payload - decoded request payload.
|
|
54
|
-
* @returns a Connection handler result.
|
|
55
|
-
*/
|
|
56
|
-
async function createChild(payload) {
|
|
57
|
-
const parent = payload !== null && typeof payload === 'object' ? payload.parent : undefined
|
|
58
|
-
const name = normalizeName(payload !== null && typeof payload === 'object' ? payload.name : undefined)
|
|
59
|
-
if (typeof parent !== 'string' || parent.trim() === '') {
|
|
60
|
-
return failure('nested-workspaces/invalid-parent', 'A parent directory is required.')
|
|
61
|
-
}
|
|
62
|
-
if (name === null) {
|
|
63
|
-
return failure('nested-workspaces/invalid-name', 'A child name may not be empty, "." , ".." or contain a separator.')
|
|
64
|
-
}
|
|
65
|
-
const target = path.join(parent, name)
|
|
66
|
-
try {
|
|
67
|
-
await mkdir(target)
|
|
68
|
-
} catch (error) {
|
|
69
|
-
if (error !== null && typeof error === 'object' && error.code === 'EEXIST') {
|
|
70
|
-
return failure('directory-picker/exists', `"${target}" already exists.`)
|
|
71
|
-
}
|
|
72
|
-
const message = error instanceof Error ? error.message : String(error)
|
|
73
|
-
return failure('directory-picker/create-failed', message)
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
const info = await stat(target)
|
|
77
|
-
if (!info.isDirectory()) {
|
|
78
|
-
return failure('directory-picker/create-failed', `"${target}" is not a directory.`)
|
|
79
|
-
}
|
|
80
|
-
} catch (error) {
|
|
81
|
-
const message = error instanceof Error ? error.message : String(error)
|
|
82
|
-
return failure('directory-picker/unreadable', message)
|
|
83
|
-
}
|
|
84
|
-
return { ok: true, value: { path: target } }
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** Reply in the envelope `createWebConnectionRpc` parses. */
|
|
88
|
-
function reply(rpcId, result) {
|
|
89
|
-
return Response.json({ type: 'server-response', rpcId, result })
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Register the child-directory route.
|
|
94
|
-
* @param ctx - the Host plugin context.
|
|
95
|
-
*/
|
|
96
|
-
export function apply(ctx) {
|
|
97
|
-
let dispose
|
|
98
|
-
try {
|
|
99
|
-
dispose = ctx.connection.fetch.register({
|
|
100
|
-
path: ROUTE_PATH,
|
|
101
|
-
methods: ['POST'],
|
|
102
|
-
requestBody: 'buffered',
|
|
103
|
-
async fetch(request) {
|
|
104
|
-
if (request.method !== 'POST') return new Response('method not allowed', { status: 405 })
|
|
105
|
-
let message
|
|
106
|
-
try {
|
|
107
|
-
message = await request.json()
|
|
108
|
-
} catch {
|
|
109
|
-
return new Response('body is not JSON', { status: 400 })
|
|
110
|
-
}
|
|
111
|
-
const rpcId = message !== null && typeof message === 'object' && typeof message.rpcId === 'string'
|
|
112
|
-
? message.rpcId
|
|
113
|
-
: 'invalid-request'
|
|
114
|
-
if (
|
|
115
|
-
message === null
|
|
116
|
-
|| typeof message !== 'object'
|
|
117
|
-
|| message.type !== 'client-request'
|
|
118
|
-
|| typeof message.method !== 'string'
|
|
119
|
-
|| message.method !== ENDPOINT
|
|
120
|
-
) {
|
|
121
|
-
return reply(rpcId, failure('gateway/bad-request', 'Invalid nested-workspaces request.'))
|
|
122
|
-
}
|
|
123
|
-
const payload = message.payload
|
|
124
|
-
if (payload === null || typeof payload !== 'object' || payload.action !== 'createChild') {
|
|
125
|
-
return reply(rpcId, failure('gateway/bad-request', 'Unknown nested-workspaces action.'))
|
|
126
|
-
}
|
|
127
|
-
return reply(rpcId, await createChild(payload))
|
|
128
|
-
},
|
|
129
|
-
})
|
|
130
|
-
} catch (error) {
|
|
131
|
-
/* The route registry is a Host-wide singleton: a live reload can reach this
|
|
132
|
-
* line with the previous instance still holding the path. Yielding keeps the
|
|
133
|
-
* serving instance authoritative instead of failing the whole composition. */
|
|
134
|
-
if (/already registered/.test(String(error && error.message ? error.message : error))) return
|
|
135
|
-
throw error
|
|
136
|
-
}
|
|
137
|
-
/* `fetch.register` already returns the disposer that drops the route; hand it
|
|
138
|
-
* straight to the effect instead of wrapping it a second time. */
|
|
139
|
-
ctx.effect(() => dispose, 'dsh-nested-workspaces: child directory route')
|
|
140
|
-
}
|
|
18
|
+
/** Nothing to install on the Host. */
|
|
19
|
+
export function apply() {}
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Nested workspaces",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "Child workspace groups in the DeepSeek Harness sidebar. A child is recorded in the sidebar only, so no folder is created in the project; new sessions run in the nearest real workspace above the group. Drag workspaces to reorder siblings, drag sessions between groups, rename the section title by double-clicking, and see each session last-used time and pin marker."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/ja.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "子ワークスペース",
|
|
4
|
-
"description": "DeepSeek Harness
|
|
4
|
+
"description": "DeepSeek Harness のサイドバーで子ワークスペースをグループ化します。子はサイドバー内の記録だけで、プロジェクトにフォルダーは作成しません。グループ上で開始したセッションは、その上にある最も近い実ワークスペースで実行されます。ほかに、同階層の並べ替え、セッションの移動、見出しのダブルクリック変更、最終使用時刻とピン留めの表示に対応します。"
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "子工作区",
|
|
4
|
-
"description": "在 DeepSeek Harness
|
|
4
|
+
"description": "在 DeepSeek Harness 侧边栏中组织子工作区:子工作区只是侧栏里的分组记录,不会在项目目录里创建文件夹;在分组上新建的会话跑在它上方最近的真实工作区里。另外支持拖动工作区调整同级顺序、把会话拖到其它分组、双击改写分区标题,并显示每个会话的最近使用时间与置顶标记。"
|
|
5
5
|
}
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-nested-workspaces",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Nested child workspaces in the DeepSeek Harness sidebar: editable section title, an Add child workspace menu, and sessions you can drag between workspaces.",
|