dsh-branch-aside 0.0.0-stage → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/LICENSE +21 -0
- package/README.md +137 -2
- package/client.js +60 -0
- package/cordis.patch.yml +3 -0
- package/icon.png +0 -0
- package/index.js +2 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +66 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
修复 fork 后侧栏「父会话瞬移」。
|
|
6
|
+
|
|
7
|
+
- fork 成功后立即预隐藏子会话原始行,主会话位置不再被挤动。
|
|
8
|
+
- 新增 session 行时立即同步,其它侧栏变化仍走 120ms 节流,避免无效重算。
|
|
9
|
+
- fork 进行中宿主先插入的子会话行也会被预隐藏(覆盖首次渲染时序竞态),失败时自动释放。
|
|
10
|
+
- MutationObserver 提前挂载,不再依赖侧栏列表区域已渲染。
|
|
11
|
+
- 补充 5 个客户端测试覆盖预隐藏时序。
|
|
12
|
+
|
|
13
|
+
## 0.3.0
|
|
14
|
+
|
|
15
|
+
**多子会话**首个稳定版。
|
|
16
|
+
|
|
17
|
+
- 从任意一条回答分叉出子会话,在右侧边栏继续追问,主对话不受影响。
|
|
18
|
+
- 子会话使用 DSH 原生命名规则。
|
|
19
|
+
- 左侧父会话行内折叠:默认收起、箭头展开、新增条目淡入。
|
|
20
|
+
- 右键父会话「子会话归档」:多选、全选、批量归档/恢复。
|
|
21
|
+
- 子会话行使用宿主原生 `归档会话` / `取消归档` 图标,归档后按官方样式变灰。
|
|
22
|
+
- fork 失败有可见提示;busy 状态等待 Promise 结束,避免重复创建。
|
|
23
|
+
- 父子映射带环保护;折叠/右键/错误边界文案支持中英文。
|
|
24
|
+
- Node 构建 + 可复现产物;CI 覆盖 Gitleaks、lint、8 项测试、SBOM;Release 附 tar.gz、zip、SHA256SUMS 与构建来源证明。
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kelight
|
|
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,138 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img src="./icon.png" width="96" alt="dsh-branch-aside 图标" />
|
|
4
|
+
|
|
5
|
+
# dsh-branch-aside
|
|
6
|
+
|
|
7
|
+
**多子会话:从任意一条回答分叉,在右侧边栏继续追问,主对话不受影响。**
|
|
8
|
+
|
|
9
|
+
[](https://github.com/YE-LIGHT/dsh-branch-aside/actions/workflows/ci.yml)
|
|
10
|
+
[](https://github.com/YE-LIGHT/dsh-branch-aside/releases)
|
|
11
|
+
[](LICENSE)
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
这是我给 DeepSeek Harness 写的一个小插件:在回答操作栏加一个动作,从该轮回答分叉出一个子会话,在右侧边栏打开。主对话留在中间继续推进;子会话是分叉点的快照,不会自动写回主线。
|
|
17
|
+
|
|
18
|
+
适合这些场景:
|
|
19
|
+
|
|
20
|
+
- 主对话正在推进,想就某条回答深入追问,又不想打断主线;
|
|
21
|
+
- 同一个问题想试几种不同问法,把结果并排放在右栏比较;
|
|
22
|
+
- 需要把某轮回答单独拎出来做长任务,主对话继续保持干净。
|
|
23
|
+
|
|
24
|
+
## 功能一览
|
|
25
|
+
|
|
26
|
+
| 功能 | 说明 |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| 🌿 **右侧开启子会话** | 回答操作栏一键分叉,右栏打开,主对话不切走 |
|
|
29
|
+
| 📂 **侧栏折叠** | 父会话行前的箭头展开/收起子会话列表,默认收起,新建条目淡入 |
|
|
30
|
+
| 🗃️ **归档与恢复** | 行内原生图标单项归档;右键父会话可多选、全选、批量归档/恢复 |
|
|
31
|
+
| 🏷️ **原生命名** | 子会话标题走 DSH 原生规则,不自动加前缀 |
|
|
32
|
+
| 🌐 **中英文界面** | 界面文案随语言切换,fork 失败有可见提示 |
|
|
33
|
+
|
|
34
|
+
## 安装
|
|
35
|
+
|
|
36
|
+
要求 DSH **0.2.2 及以上**,桌面端。npm / 插件市场发布尚未开放,目前以 GitHub Release 与本地目录安装为主。
|
|
37
|
+
|
|
38
|
+
### 从 Release 安装(推荐)
|
|
39
|
+
|
|
40
|
+
1. 打开 [Releases](https://github.com/YE-LIGHT/dsh-branch-aside/releases),下载 `dsh-branch-aside-vX.Y.Z.tar.gz`(Windows 也可选 `.zip`);
|
|
41
|
+
2. 让DSH帮你装就行。
|
|
42
|
+
|
|
43
|
+
### 从源码安装
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
git clone https://github.com/YE-LIGHT/dsh-branch-aside.git
|
|
47
|
+
cd dsh-branch-aside
|
|
48
|
+
node scripts/build-client.mjs
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
把仓库目录加入 profile 或通过插件管理器安装。`client.js` 是 DSH 直接加载的产物,改完源码必须重新构建。
|
|
52
|
+
|
|
53
|
+
## 使用
|
|
54
|
+
|
|
55
|
+
### 分叉一个子会话
|
|
56
|
+
|
|
57
|
+
1. 在主对话里完成一轮回答;
|
|
58
|
+
2. 悬停回答,点操作栏里的「右侧开启子会话」;
|
|
59
|
+
3. 右栏出现子会话标签,在里面继续提问;
|
|
60
|
+
4. 主对话照常输入,两边互不影响。
|
|
61
|
+
|
|
62
|
+
### 折叠与展开
|
|
63
|
+
|
|
64
|
+
- 父会话行标题前的箭头:点一下展开,再点收起,状态会记住;
|
|
65
|
+
- 展开后每行可直接打开对应子会话,新建条目会淡入出现;
|
|
66
|
+
- 父子关系在创建时记录,之后改标题也不会掉组。
|
|
67
|
+
|
|
68
|
+
### 归档与恢复
|
|
69
|
+
|
|
70
|
+
- 子会话行 hover → 原生「归档会话」图标,归档后该行变灰、图标变为「取消归档」;
|
|
71
|
+
- 右键父会话 →「子会话归档」:进入多选模式,可全选、批量归档/恢复;
|
|
72
|
+
- 归档只是从列表隐藏,可随时恢复,**不删除会话数据**;运行中的子会话需先停止才能归档。
|
|
73
|
+
|
|
74
|
+
## 数据与状态
|
|
75
|
+
|
|
76
|
+
| 数据 | 存放位置 |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| 子会话内容 | 就是普通 DSH 会话,仍在 `$DSH_HOME/sessions` |
|
|
79
|
+
| 归档状态 | 宿主的 `workspace.json` |
|
|
80
|
+
| 折叠状态 | 浏览器 localStorage(`dsba-fold.v2:*`) |
|
|
81
|
+
| 父子关系 | 插件记录的映射优先,旧数据兼容 `旁支 · 父标题` / `父标题 (N)` 标题规则 |
|
|
82
|
+
|
|
83
|
+
## 限制
|
|
84
|
+
|
|
85
|
+
- 子会话是**分叉点快照**:主线之后的内容不同步,子会话的新回答也不自动回主线;
|
|
86
|
+
- 侧栏折叠依赖 DSH 客户端 DOM 结构,DSH 大改侧栏布局时需要适配;
|
|
87
|
+
- 目前我只在 DSH 0.2.2 系桌面端实测过,其他版本未做运行时验证。
|
|
88
|
+
|
|
89
|
+
## 常见问题
|
|
90
|
+
|
|
91
|
+
**子会话会自动跟上主对话的新内容吗?**
|
|
92
|
+
不会。它是分叉点的快照,两边之后各自独立——这正是为了互不干扰。
|
|
93
|
+
|
|
94
|
+
**归档会删掉我的会话吗?**
|
|
95
|
+
不会,只是从列表隐藏,随时可以恢复。
|
|
96
|
+
|
|
97
|
+
**旧版本创建的「旁支」会话还能识别吗?**
|
|
98
|
+
能。插件优先读自己记录的父子映射,旧数据会按 `旁支 · 父标题` / `父标题 (N)` 的标题规则兜底识别。
|
|
99
|
+
|
|
100
|
+
**其他 DSH 版本能用吗?**
|
|
101
|
+
我只在 0.2.2 系桌面端实测过。其他版本欢迎试用,遇到问题请告诉我(见下方反馈)。
|
|
102
|
+
|
|
103
|
+
## 反馈与贡献
|
|
104
|
+
|
|
105
|
+
- 🐛 **报 Bug**:[提一个 Issue](https://github.com/YE-LIGHT/dsh-branch-aside/issues/new),最好附上 DSH 版本、复现步骤和截图;
|
|
106
|
+
- 💡 **提建议**:同样走 [Issues](https://github.com/YE-LIGHT/dsh-branch-aside/issues),标题写清想要的效果就行;
|
|
107
|
+
- 🔧 **直接改**:欢迎 PR。改完 `src/client.js` 记得重新构建,提交前跑 `pnpm lint && pnpm test`。
|
|
108
|
+
|
|
109
|
+
## 开发
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
pnpm install --frozen-lockfile --ignore-scripts
|
|
113
|
+
node scripts/build-client.mjs # 产出 client.js
|
|
114
|
+
pnpm lint # ESLint(警告即失败)
|
|
115
|
+
pnpm test # Node 原生测试
|
|
116
|
+
pnpm sbom # 生成 sbom.cdx.json
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## 发布与验证
|
|
120
|
+
|
|
121
|
+
CI 在 push/PR 时执行秘密扫描、lint、测试与 SBOM 校验;推送 `v*` tag 会自动构建、校验产物一致性并生成构建来源证明,发布说明取自 CHANGELOG。
|
|
122
|
+
|
|
123
|
+
Release 附件(tar.gz / zip / SHA256SUMS)可验证:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
sha256sum -c SHA256SUMS
|
|
127
|
+
gh attestation verify dsh-branch-aside-v0.3.1.tar.gz -R YE-LIGHT/dsh-branch-aside
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
SBOM 位于仓库根目录 `sbom.cdx.json`(CycloneDX 1.5)。
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
<div align="center">
|
|
135
|
+
|
|
136
|
+
MIT © Kelight · 如果这个插件帮到了你,欢迎点个 ⭐️
|
|
137
|
+
|
|
138
|
+
</div>
|
package/client.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({id:"dsh-branch-aside",factory(we){const L=we("react"),w=L.createElement,U="branch-aside",ee="dsh-branch-aside",te="branchaside",ne="branchaside",ae="dsh-resource://branchaside/session/",$="branchaside.conversation",Se="branchAside",oe="\u5B50\u4F1A\u8BDD",X="\u65C1\u652F \xB7 ";function se(a){try{if(typeof a.get=="function")return a.get("sidebarRight")}catch{}try{return a.sidebarRight}catch{return}}const xe={"action.label":"\u53F3\u4FA7\u5F00\u542F\u5B50\u4F1A\u8BDD","action.latest":"\u4ECE\u6700\u540E\u4E00\u8F6E\u5206\u53C9\uFF08\u672A\u80FD\u7CBE\u786E\u5B9A\u4F4D\u8BE5\u8F6E\uFF09","action.failed":"\u521B\u5EFA\u5B50\u4F1A\u8BDD\u5931\u8D25","action.unavailable":"\u65E0\u6CD5\u5B9A\u4F4D\u8FD9\u6761\u56DE\u7B54\u5BF9\u5E94\u7684\u8F6E\u6B21","tab.title":"\u5B50\u4F1A\u8BDD","banner.based":"\u57FA\u4E8E\u7B2C {seq} \u4E2A\u4E8B\u4EF6\u5206\u53C9","banner.note":"\u4E3B\u7EBF\u7EE7\u7EED\u63A8\u8FDB\u4E0D\u53D7\u5F71\u54CD\uFF1B\u5206\u652F\u662F\u5206\u53C9\u70B9\u7684\u5FEB\u7167\uFF0C\u770B\u4E0D\u5230\u4E4B\u540E\u7684\u5BF9\u8BDD\u3002","banner.archive":"\u5F52\u6863","banner.archiving":"\u5F52\u6863\u4E2D\u2026","banner.archiveTitle":"\u5F52\u6863\u8FD9\u4E2A\u5B50\u4F1A\u8BDD\uFF08\u4ECE\u5DE6\u4FA7\u5217\u8868\u9690\u85CF\uFF0C\u53EF\u6062\u590D\uFF09","banner.archiveFailed":"\u5F52\u6863\u5931\u8D25\uFF1A\u5206\u652F\u53EF\u80FD\u4ECD\u5728\u8FD0\u884C\uFF0C\u5148\u505C\u6B62\u518D\u5F52\u6863\u3002"},P={"action.label":"Open child in right sidebar","action.latest":"Fork from the latest turn (this turn could not be located)","action.failed":"Could not create the branch","action.unavailable":"The turn for this reply is not available","tab.title":"Child session","banner.based":"Forked at event {seq}","banner.note":"The main chat keeps going; this branch is a snapshot at the fork point.","banner.archive":"Archive","banner.archiving":"Archiving\u2026","banner.archiveTitle":"Archive this aside (hidden from the list, restorable)","banner.archiveFailed":"Archive failed: the branch may still be running; stop it first."},re=`
|
|
2
|
+
.dsba-action{display:inline-flex;align-items:center;justify-content:center;width:calc(28px + var(--dsh-content-font-delta, 0px));height:calc(28px + var(--dsh-content-font-delta, 0px));padding:6px;border:none;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer}
|
|
3
|
+
.dsba-action svg{width:calc(17px + var(--dsh-content-font-delta, 0px));height:calc(17px + var(--dsh-content-font-delta, 0px))}
|
|
4
|
+
@media (hover: hover){.dsba-action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}}
|
|
5
|
+
.dsba-action[data-unavailable]{cursor:default;opacity:.4}
|
|
6
|
+
.dsba-action[data-failed]{color:#d9534f}
|
|
7
|
+
.dsba-action-failed{font-size:11px;line-height:16px;color:#d9534f;margin-left:4px;align-self:center}
|
|
8
|
+
@media (hover: hover){.dsba-action[data-unavailable]:hover{background:transparent;color:var(--dsw-alias-label-tertiary)}}
|
|
9
|
+
.dsba-footer{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 10px;border:none;border-radius:999px;background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary);font-size:12px;cursor:pointer}
|
|
10
|
+
.dsba-footer svg{width:14px;height:14px}
|
|
11
|
+
.dsba-footer[data-unavailable]{cursor:default;opacity:.4}
|
|
12
|
+
`,ke=`
|
|
13
|
+
.dsba-root{display:flex;flex-direction:column;width:100%;height:100%;min-width:0;min-height:0}
|
|
14
|
+
.dsba-banner{display:flex;align-items:center;gap:8px;flex:none;padding:6px 10px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);border-bottom:1px solid var(--dsw-alias-border-secondary)}
|
|
15
|
+
.dsba-badge{flex:none;padding:0 6px;border-radius:999px;background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary);font-size:11px}
|
|
16
|
+
.dsba-note{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
17
|
+
.dsba-archive{display:inline-flex;align-items:center;gap:4px;flex:none;height:22px;padding:0 8px;border:1px solid var(--dsw-alias-border-secondary);border-radius:999px;background:transparent;color:var(--dsw-alias-label-secondary);font-size:11px;cursor:pointer}
|
|
18
|
+
.dsba-archive:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
19
|
+
.dsba-archive[data-busy]{cursor:default;opacity:.5}
|
|
20
|
+
.dsba-body{flex:1;min-height:0;display:flex;width:100%}
|
|
21
|
+
`;function Z(a){let o;try{o=new URL(a)}catch{return}if(o.protocol!=="dsh-resource:"||o.hostname.toLowerCase()!==ne)return;const b=o.pathname.split("/").filter(Boolean);if(b.length!==2||b[0]!=="session")return;let c;try{c=decodeURIComponent(b[1])}catch{return}const u=o.searchParams.get("parent")||void 0,p=o.searchParams.get("at"),m=p===null?void 0:Number(p);return{childSessionId:c,parentSessionId:u,atSeq:Number.isFinite(m)?m:void 0}}function ie(a){const o=new URLSearchParams;a.parentSessionId!==void 0&&o.set("parent",a.parentSessionId),a.atSeq!==void 0&&o.set("at",String(a.atSeq));const b=o.toString();return ae+encodeURIComponent(a.childSessionId)+(b===""?"":"?"+b)}function K(a,o,b=0,c=new Set([a])){const u=[];for(const p of o.get(a)??[])c.has(p)||(c.add(p),u.push({id:p,depth:b}),u.push(...K(p,o,b+1,c)));return u}function Ce(a){return a.aborted?Promise.resolve():new Promise(o=>{a.addEventListener("abort",()=>{o()},{once:!0})})}function de(){return w("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},w("rect",{x:3,y:4,width:18,height:16,rx:3}),w("path",{d:"M15 4v16"}),w("path",{d:"M6.5 8.5h5M6.5 12h5"}))}class Ae extends L.Component{constructor(o){super(o),this.state={error:null}}static getDerivedStateFromError(o){return{error:o}}componentDidCatch(o){console.error("[dsh-branch-aside] branch panel failed",o)}render(){return this.state.error!==null?w("div",{style:{padding:"12px",fontSize:"12px",color:"var(--dsw-alias-label-tertiary)"}},I("renderFailed")+String(this.state.error&&this.state.error.message?this.state.error.message:this.state.error)):this.props.children}}function F(a,o,b){return typeof a!="function"?o:b===void 0?a(o):a(o,b)}const V=new Set,G=new Set,J=new Set;function Ee(a){return String(a).replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function le(){if(typeof document>"u")return;let a=document.getElementById("dsba-prehide");a===null&&(a=document.createElement("style"),a.id="dsba-prehide",document.head.appendChild(a)),a.textContent=Array.from(V).map(o=>`[data-row-key="session:${Ee(o)}"]{display:none!important}`).join(`
|
|
22
|
+
`)}function ce(a){typeof a!="string"||a===""||(V.add(a),le())}function fe(){const a=new Set;if(typeof document<"u")for(const b of document.querySelectorAll('[data-row-key^="session:"]'))a.add(b.getAttribute("data-row-key").slice(8));const o={knownIds:a};return J.add(o),o}function ue(a){if(!(typeof a!="string"||a==="")){for(const o of J)if(!o.knownIds.has(a)){G.add(a),ce(a);return}}}function Q(a,o){if(!J.delete(a))return;typeof o=="string"&&o!==""&&(G.delete(o),ce(o));let b=!1;for(const c of G){let u=!1;for(const p of J)if(!p.knownIds.has(c)){u=!0;break}u||(G.delete(c),V.delete(c),b=!0)}b&&le()}async function he(a,o,b){const c=fe();let u;try{u=await a.sessions.fork({sessionId:o,...b===void 0?{}:{atSeq:b}});try{localStorage.setItem("dsba.parent."+u,o)}catch{}return Q(c,u),se(a).openResource(ie({childSessionId:u,parentSessionId:o,atSeq:b}),{kind:te}),u}catch(p){throw Q(c,u),console.error("[dsh-branch-aside] fork failed",p),p}}function Te(a){function o(p,m){if(typeof p=="function")return p(v=>{try{const C=v===void 0?void 0:v.timeline,q=C===void 0?void 0:C.turns;if(q==null)return;const x=typeof q.values=="function"||typeof q[Symbol.iterator]=="function"?q:null;if(x===null)return;for(const E of x){if(E==null)continue;const _=typeof E.data?.get=="function"?E.data.get("turn-tail"):void 0,T=_===void 0?void 0:_.closing,N=T===void 0?void 0:T.finalNode;if(N!==void 0&&N.messageId===m)return E.end===void 0?void 0:E.end.seq}const B=v.nodes!==void 0&&typeof v.nodes.values=="function"?v.nodes.values():[];for(let E=B.length-1;E>=0;E--){const _=B[E],T=_===void 0?void 0:_.data;if(T==null||(T.finalNode?.messageId??T.messageId??T.closing?.finalNode?.messageId)!==m)continue;const O=T.seq??T.anchorSeq??_.anchorSeq;if(typeof O=="number")return O}return}catch(C){console.warn("[dsh-branch-aside] seq lookup failed",C);return}})}function b(p){const{messageId:m,sessionId:v,useChat:C,useAccess:q,t:x}=p,B=o(C,m),E=typeof q=="function"?q("session/fork"):!0,[_,T]=L.useState(!1),[N,O]=L.useState(!1),M=E&&!_,z=B!==void 0?F(x,"action.label"):F(x,"action.latest"),W=L.useCallback(async()=>{if(M){T(!0),O(!1);try{await he(a,v,B)}catch{O(!0),setTimeout(()=>O(!1),3e3)}finally{T(!1)}}},[M,v,B]);return w(L.Fragment,null,w("style",{key:"style"},re),w("button",{key:"button",type:"button",className:"dsba-action",title:N?F(x,"action.failed"):M?z:F(x,"action.unavailable"),"data-failed":N?"":void 0,"aria-label":z,"aria-disabled":M?void 0:!0,"data-unavailable":M?void 0:"",onClick:W},w(de)),N?w("span",{key:"failed",className:"dsba-action-failed",role:"status"},F(x,"action.failed")):null)}function c(p){const{sessionId:m,t:v}=p;return w(L.Fragment,null,w("style",{key:"style"},re),w("button",{key:"button",type:"button",className:"dsba-action",title:F(v,"action.label"),"aria-label":F(v,"action.label"),onClick:()=>{he(a,m,void 0).catch(()=>{})}},w(de)))}class u extends L.Component{constructor(m){super(m),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(m){console.error("[dsh-branch-aside] action entry failed",m)}render(){return this.state.failed?this.props.fallback:this.props.children}}return function(m){return w(u,{fallback:w(c,m)},w(b,m))}}const be={zh:{archive:"\u5F52\u6863",restore:"\u6062\u590D",selectAll:"\u5168\u9009",exit:"\u9000\u51FA",selected:"\u5DF2\u9009 {count} / {total}",archiveFailed:"\u5F52\u6863\u5931\u8D25\uFF1A",restoreFailed:"\u6062\u590D\u5931\u8D25\uFF1A",archiveTitle:"\u5F52\u6863\u4F1A\u8BDD",unarchiveTitle:"\u53D6\u6D88\u5F52\u6863",expand:"\u5C55\u5F00\u5B50\u4F1A\u8BDD\uFF08{count}\uFF09",collapse:"\u6536\u8D77\u5B50\u4F1A\u8BDD\uFF08{count}\uFF09",menuArchive:"\u5B50\u4F1A\u8BDD\u5F52\u6863",renderFailed:"\u5B50\u4F1A\u8BDD\u9762\u677F\u6E32\u67D3\u5931\u8D25\uFF1A"},en:{archive:"Archive",restore:"Restore",selectAll:"Select all",exit:"Exit",selected:"{count} of {total} selected",archiveFailed:"Archive failed: ",restoreFailed:"Restore failed: ",archiveTitle:"Archive session",unarchiveTitle:"Unarchive session",expand:"Expand child sessions ({count})",collapse:"Collapse child sessions ({count})",menuArchive:"Archive child sessions",renderFailed:"Child session panel failed: "}};function I(a,o){const b=typeof document<"u"&&document.documentElement&&document.documentElement.lang||typeof navigator<"u"&&navigator.language||"zh";let u=(String(b).toLowerCase().startsWith("zh")?be.zh:be.en)[a]??a;if(o!==void 0)for(const p of Object.keys(o))u=u.split("{"+p+"}").join(String(o[p]));return u}const Y=`
|
|
23
|
+
.dsba-fold-toggle{display:inline-flex;align-items:center;justify-content:center;align-self:center;vertical-align:middle;width:24px;height:24px;padding:0;margin:0 1px 0 0;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-tertiary,#8a94a6);font-size:16px;line-height:1;cursor:pointer;flex:none;transition:background .15s ease}
|
|
24
|
+
.dsba-fold-toggle:hover{background:var(--dsw-alias-bg-hover,#f3f6fa);color:var(--dsw-alias-label-secondary,#5b6573)}
|
|
25
|
+
.dsba-fold-toggle .dsba-fold-chev{display:block;width:16px;height:16px;transform-origin:50% 50%;transition:transform .18s ease}
|
|
26
|
+
.dsba-fold-toggle[data-open="1"] .dsba-fold-chev{transform:rotate(90deg)}
|
|
27
|
+
.dsba-fold-wrap{display:grid;grid-template-rows:0fr;transition:grid-template-rows .18s ease}
|
|
28
|
+
.dsba-fold-wrap[data-open="1"]{grid-template-rows:1fr}
|
|
29
|
+
.dsba-fold-inner{overflow:hidden;min-height:0}
|
|
30
|
+
.dsba-fold-list{display:flex;flex-direction:column;margin:0 6px 4px 30px;padding:2px 0}
|
|
31
|
+
.dsba-fold-actions{display:flex;align-items:center;flex-wrap:wrap;gap:2px;margin:0 6px 2px 30px;padding:0}
|
|
32
|
+
.dsba-fold-wrap[data-select="0"] .dsba-fold-actions{display:none}
|
|
33
|
+
.dsba-fold-check{flex:none;width:14px;height:14px;margin:0;accent-color:#7fc4ff;cursor:pointer}
|
|
34
|
+
.dsba-fold-tool{padding:1px 5px;border:0;border-radius:5px;background:transparent;color:var(--dsw-alias-label-tertiary,#8a94a6);font:inherit;font-size:11px;line-height:16px;cursor:pointer;transition:background .15s ease,color .15s ease}
|
|
35
|
+
.dsba-fold-tool:hover:not(:disabled){background:var(--dsw-alias-bg-hover,#f3f6fa);color:var(--dsw-alias-label-secondary,#5b6573)}
|
|
36
|
+
.dsba-fold-tool:disabled{opacity:.4;cursor:default}
|
|
37
|
+
.dsba-fold-count{margin-left:auto;padding-left:6px;font-size:10px;color:var(--dsw-alias-label-tertiary,#8a94a6);white-space:nowrap}
|
|
38
|
+
.dsba-fold-status{color:#c0392b;font-size:10px;margin-left:4px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:140px}
|
|
39
|
+
.dsba-fold-item{display:flex;align-items:center;gap:6px;width:100%;padding:3px 8px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary,#5b6573);font:inherit;font-size:12px;text-align:left;cursor:pointer}
|
|
40
|
+
.dsba-fold-item:hover{background:var(--dsw-alias-bg-hover,#f3f6fa)}
|
|
41
|
+
.dsba-fold-item[data-active="1"]{background:var(--dsw-alias-bg-active,#eaf1f8)}
|
|
42
|
+
.dsba-fold-item[data-indent="1"]{padding-left:20px}
|
|
43
|
+
.dsba-fold-item[data-indent="2"]{padding-left:32px}
|
|
44
|
+
.dsba-fold-dot{width:6px;height:6px;border-radius:50%;background:#7fc4ff;flex:none}
|
|
45
|
+
.dsba-fold-dot[data-archived="1"]{background:#c3ccd8}
|
|
46
|
+
.dsba-fold-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
47
|
+
.dsba-fold-tag{margin-left:auto;font-size:10px;color:var(--dsw-alias-label-tertiary,#8a94a6);flex:none}
|
|
48
|
+
.dsba-fold-item[data-new="1"]{animation:dsba-item-in .18s ease both}
|
|
49
|
+
@keyframes dsba-item-in{from{opacity:0}to{opacity:1}}
|
|
50
|
+
.dsba-fold-archive{flex:none;margin-left:auto;border:0;background:transparent;color:var(--dsw-alias-label-tertiary,#8a94a6);padding:2px;border-radius:4px;cursor:pointer;opacity:0;display:inline-flex;align-items:center;justify-content:center;transition:opacity .15s ease,background .15s ease}
|
|
51
|
+
.dsba-fold-item:hover .dsba-fold-archive{opacity:1}
|
|
52
|
+
.dsba-fold-archive:hover{background:var(--dsw-alias-bg-hover,#f3f6fa);color:var(--dsw-alias-label-secondary,#5b6573)}
|
|
53
|
+
.dsba-fold-item .dsba-fold-tag{margin-left:6px}
|
|
54
|
+
.dsba-fold-archive svg{display:block;width:18px;height:18px}
|
|
55
|
+
.dsba-fold-item[data-archived="1"] .dsba-fold-title{color:var(--dsw-alias-label-tertiary,#8a94a6)}
|
|
56
|
+
.dsba-fold-item[data-archived="1"] .dsba-fold-dot{background:#c3ccd8}
|
|
57
|
+
.dsba-fold-item:not([data-archived="1"]) .dsba-fold-unarchive{display:none}
|
|
58
|
+
.dsba-fold-item[data-archived="1"] .dsba-fold-archive-act{display:none}
|
|
59
|
+
`;function pe(a){const o={ids:[],byId:{},archived:new Set},b=new Map,c=new Set,u=new Map;let p=!1,m=!1,v=0,C=null;function q(){if(p||typeof document>"u")return;p=!0;const t=Math.max(0,120-(performance.now()-v));setTimeout(()=>{p=!1,m||H()},t)}function x(t){if(!u.has(t)){let s=!1;try{s=localStorage.getItem("dsba-fold.v2:"+t)==="1"}catch{s=!1}u.set(t,s)}return u.get(t)===!0}function B(t){const s=!x(t);u.set(t,s),s||(c.delete(t),j(t).clear());try{localStorage.setItem("dsba-fold.v2:"+t,s?"1":"0")}catch{}E(t,s),q()}function E(t,s){if(typeof document>"u")return;const i=document.querySelector("[data-sidebar-list-area]");if(i===null)return;const l=i.querySelector(`[data-dsba-fold-wrap="${t}"]`);l!==null&&(l.dataset.open=s?"1":"0");const f=i.querySelector(`[data-row-key="session:${t}"]`),n=f===null?null:f.querySelector(".dsba-fold-toggle");n!==null&&(n.dataset.open=s?"1":"0"),H()}function _(){const t=document.getElementById("dsba-fold-style");if(t!==null){t.textContent!==Y&&(t.textContent=Y);return}const s=document.createElement("style");s.id="dsba-fold-style",s.textContent=Y,document.head.appendChild(s)}function T(t){let s=document.getElementById("dsba-fold-hide");s===null&&(s=document.createElement("style"),s.id="dsba-fold-hide",document.head.appendChild(s)),s.textContent=t.length===0?"":t.map(i=>`[data-row-key="session:${i}"]{display:none!important}`).join(`
|
|
60
|
+
`)}function N(t){const s=o.byId[t];if(s?.origin==="subagent")return;if(s?.parentId!==void 0&&o.byId[s.parentId]!==void 0)return s.parentId;try{const n=localStorage.getItem("dsba.parent."+t);if(n!==null&&o.byId[n]!==void 0)return n}catch{}const i=typeof s?.displayTitle=="string"?s.displayTitle:"";if(i==="")return;if(!i.startsWith(X)){const n=i.match(/^(.*) \(\d+\)$/);if(n===null)return;const e=n[1];for(const r of o.ids)if(r!==t&&o.byId[r]?.displayTitle===e){try{localStorage.setItem("dsba.parent."+t,r)}catch{}return r}return}const l=i.slice(X.length);let f;for(const n of o.ids){if(n===t)continue;const e=o.byId[n]?.displayTitle;typeof e!="string"||e===""||e.startsWith(X)||(l===e||l.startsWith(e+" \xB7 "))&&(f===void 0||e.length>(o.byId[f]?.displayTitle?.length??0))&&(f=n)}if(f!==void 0)try{localStorage.setItem("dsba.parent."+t,f)}catch{}return f}function O(){const t=new Map;for(const s of o.ids){const i=N(s);typeof i!="string"||i===s||(t.has(i)||t.set(i,[]),t.get(i).push(s))}return t}function M(t,s){return(c.has(s)?"s":"n")+"|"+t.map(l=>{const n=(o.byId[l.id]?.retainedBy?.mainView??0)>0?"1":"0";return l.id+":"+l.depth+":"+(o.archived.has(l.id)?"1":"0")+":"+n}).join("|")}function j(t){return b.has(t)||b.set(t,new Set),b.get(t)}function z(t){return Array.from(t.querySelectorAll(".dsba-fold-item")).map(s=>s.dataset.id)}function W(t,s){const i=t.querySelector(".dsba-fold-actions");if(i===null)return;const l=z(t),f=j(s),n=i.querySelector('[data-act="archive"]'),e=i.querySelector('[data-act="restore"]'),r=i.querySelector(".dsba-fold-count"),h=l.filter(d=>f.has(d)&&!o.archived.has(d)),g=l.filter(d=>f.has(d)&&o.archived.has(d));n!==null&&(n.disabled=h.length===0,n.textContent=h.length===0?I("archive"):I("archive")+" ("+h.length+")"),e!==null&&(e.disabled=g.length===0,e.textContent=g.length===0?I("restore"):I("restore")+" ("+g.length+")"),r!==null&&(r.textContent=I("selected",{count:f.size,total:l.length}))}function ve(t){c.delete(t),j(t).clear(),q()}function Fe(t,s){const i=document.createElement("div");i.className="dsba-fold-actions";const l=document.createElement("button");l.type="button",l.className="dsba-fold-tool",l.dataset.act="all",l.textContent=I("selectAll");const f=document.createElement("button");f.type="button",f.className="dsba-fold-tool",f.dataset.act="archive",f.textContent=I("archive");const n=document.createElement("button");n.type="button",n.className="dsba-fold-tool",n.dataset.act="restore",n.textContent=I("restore");const e=document.createElement("button");e.type="button",e.className="dsba-fold-tool",e.dataset.act="done",e.textContent=I("exit");const r=document.createElement("span");r.className="dsba-fold-count";const h=document.createElement("span");h.className="dsba-fold-status",l.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation();const d=z(t),k=j(s),y=d.length>0&&d.every(S=>k.has(S));if(k.clear(),!y)for(const S of d)k.add(S);for(const S of t.querySelectorAll(".dsba-fold-check")){const A=S.closest(".dsba-fold-item");A!==null&&(S.checked=k.has(A.dataset.id))}W(t,s)});for(const g of[f,n,e])g.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),me(g)});return i.append(l,f,n,e,r,h),i}async function me(t){const s=t.closest(".dsba-fold-wrap");if(s===null)return;const i=s.dataset.dsbaFoldWrap;if(i===void 0)return;const l=t.dataset.act,f=j(i),n=s.querySelector(".dsba-fold-status");if(l==="done"){ve(i);return}if(l!=="archive"&&l!=="restore")return;n!==null&&(n.textContent="");const e=z(s).filter(d=>l==="archive"?f.has(d)&&!o.archived.has(d):f.has(d)&&o.archived.has(d)),r=s.querySelector('[data-act="archive"]'),h=s.querySelector('[data-act="restore"]');r!==null&&(r.disabled=!0),h!==null&&(h.disabled=!0);let g="";for(const d of e)try{l==="archive"?await a.uiWorkspace.archiveSession(d,{stopActivity:!0}):await a.uiWorkspace.unarchiveSession(d)}catch(k){g=k&&k.message?String(k.message):String(k),console.warn("[dsh-branch-aside] "+l+" branch failed",k)}if(g!==""){n!==null&&(n.textContent=I(l==="archive"?"archiveFailed":"restoreFailed")+g),W(s,i);return}ve(i)}function ye(t,s,i){const l=new Set((t.dataset.ids||"").split(",").filter(Boolean));t.textContent="";const f=j(i);for(const n of s){const e=o.byId[n.id],r=document.createElement("div");r.className="dsba-fold-item",r.dataset.id=n.id,l.size>0&&!l.has(n.id)&&(r.dataset.new="1"),(e?.retainedBy?.mainView??0)>0&&(r.dataset.active="1"),n.depth>0&&(r.dataset.indent=String(Math.min(n.depth,2)));let h=null;c.has(i)&&(h=document.createElement("input"),h.type="checkbox",h.className="dsba-fold-check",h.checked=f.has(n.id),h.addEventListener("click",R=>R.stopPropagation()),h.addEventListener("change",()=>{h.checked?f.add(n.id):f.delete(n.id);const R=r.closest(".dsba-fold-wrap");R!==null&&W(R,i)}),r.append(h));const g=document.createElement("span");g.className="dsba-fold-dot",o.archived.has(n.id)&&(g.dataset.archived="1");const d=document.createElement("span");d.className="dsba-fold-title";const k=typeof e?.displayTitle=="string"&&e.displayTitle!==""?e.displayTitle:n.id;d.textContent=k,d.title=k,r.append(g,d),o.archived.has(n.id)&&(r.dataset.archived="1");const y='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke-width="1.5"><path d="M13.5 2.5H2.5C1.94772 2.5 1.5 2.94772 1.5 3.5V4.5C1.5 5.05228 1.94772 5.5 2.5 5.5H13.5C14.0523 5.5 14.5 5.05228 14.5 4.5V3.5C14.5 2.94772 14.0523 2.5 13.5 2.5Z" stroke="currentColor"></path><path d="M2.5 5.5V13.5C2.5 13.7652 2.60536 14.0196 2.79289 14.2071C2.98043 14.3946 3.23478 14.5 3.5 14.5H12.5C12.7652 14.5 13.0196 14.3946 13.2071 14.2071C13.3946 14.0196 13.5 13.7652 13.5 13.5V5.5" stroke="currentColor"></path><path d="M6.5 9.5H9.5" stroke="currentColor"></path></svg>',S='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" stroke-width="1.5"><path fill-rule="evenodd" clip-rule="evenodd" d="M15.8659 2.05975C17.2603 2.05995 18.3913 3.19096 18.3914 4.58527V5.4874C18.3914 6.02747 18.2192 6.52672 17.9303 6.93735C17.9336 6.96524 17.9388 6.99318 17.9388 7.02195V12.8884C17.9388 13.6345 17.9395 14.2379 17.8996 14.7254C17.8642 15.1593 17.7936 15.5499 17.6373 15.9141L17.5654 16.0685C17.278 16.6328 16.8405 17.1046 16.3038 17.434L16.0679 17.5661C15.66 17.7739 15.2196 17.8598 14.7237 17.9003C14.2362 17.9401 13.6327 17.9405 12.8867 17.9405H7.11122C6.36511 17.9405 5.76171 17.9401 5.27418 17.9003C4.84051 17.8649 4.44949 17.7952 4.08545 17.6391L3.93104 17.5661C3.36673 17.2785 2.89392 16.8414 2.56465 16.3044L2.43245 16.0685C2.22473 15.6608 2.13878 15.2211 2.09825 14.7254C2.05841 14.2379 2.05912 13.6345 2.05912 12.8884V7.02195C2.05912 6.99284 2.06422 6.96449 2.06758 6.93629C1.77931 6.52592 1.60858 6.02687 1.60858 5.4874V4.58527C1.60876 3.19084 2.73962 2.05975 4.1341 2.05975H15.8659ZM16.4984 7.92936C16.296 7.98169 16.0847 8.01288 15.8659 8.01291H4.1341C3.91478 8.01291 3.70246 7.98194 3.49955 7.92936V12.8884C3.49955 13.6582 3.50053 14.1927 3.53445 14.608C3.56769 15.0146 3.62923 15.244 3.71635 15.415L3.7925 15.5514C3.98339 15.8627 4.25749 16.1165 4.58464 16.2833L4.72529 16.3435C4.88095 16.3993 5.08638 16.4402 5.39158 16.4651C5.80685 16.4991 6.34138 16.5001 7.11122 16.5001H12.8867C13.6564 16.5001 14.1911 16.499 14.6063 16.4651C15.0128 16.432 15.2423 16.3703 15.4133 16.2833L15.5508 16.2061C15.8618 16.0152 16.116 15.7419 16.2827 15.415L16.3429 15.2732C16.3985 15.1177 16.4396 14.9128 16.4645 14.608C16.4985 14.1927 16.4984 13.6583 16.4984 12.8884V7.92936ZM4.1341 3.50019C3.53511 3.50019 3.0492 3.98631 3.04902 4.58527V5.4874C3.04902 6.08649 3.535 6.57248 4.1341 6.57248H15.8659C16.4648 6.57228 16.951 6.08638 16.951 5.4874V4.58527C16.9509 3.98644 16.4647 3.50038 15.8659 3.50019H4.1341Z" fill="currentColor"></path><path d="M10 14.1V10.1M7.85 12.05L10 9.9L12.15 12.05" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path></svg>',A=document.createElement("button");A.type="button",A.className="dsba-fold-archive dsba-fold-archive-act",A.title=I("archiveTitle"),A.setAttribute("aria-label",I("archiveTitle")),A.innerHTML=y;const D=document.createElement("button");D.type="button",D.className="dsba-fold-archive dsba-fold-unarchive",D.title=I("unarchiveTitle"),D.setAttribute("aria-label",I("unarchiveTitle")),D.innerHTML=S,r.append(A,D),r.addEventListener("click",R=>{if(!(h!==null&&R.target===h)&&!(R.target instanceof Element&&R.target.closest(".dsba-fold-archive")!==null)){R.preventDefault(),R.stopPropagation();try{a.uiWorkspace.openSession(n.id)}catch(Re){console.warn("[dsh-branch-aside] open branch from fold failed",Re)}}}),t.append(r)}t.dataset.ids=s.map(n=>n.id).join(",")}function _e(t,s,i,l){let f=t.querySelector(".dsba-fold-inner");f===null&&(f=document.createElement("div"),f.className="dsba-fold-inner",t.append(f));let n=f.querySelector(".dsba-fold-list");if(n===null){n=document.createElement("div"),n.className="dsba-fold-list",n.dataset.sig=l,ye(n,i,s),f.replaceChildren(Fe(t,s),n),W(t,s);return}n.dataset.sig!==l&&(ye(n,i,s),n.dataset.sig=l,W(t,s))}function H(){if(v=performance.now(),typeof document>"u")return;_();const t=document.querySelector("[data-sidebar-list-area]");if(t===null)return;const s=new Map;for(const n of t.querySelectorAll('[data-row-key^="session:"]')){const e=n.getAttribute("data-row-key")??"";e.startsWith("session:")&&s.set(e.slice(8),n)}const i=O(),l=new Set;for(const n of i.keys())s.has(n)&&l.add(n);const f=new Map;for(const n of Array.from(t.querySelectorAll(".dsba-fold-wrap"))){const e=n.dataset.dsbaFoldWrap;if(e===void 0||!l.has(e)){n.remove();continue}const r=f.get(e);if(r===void 0){f.set(e,n);continue}const h=s.get(e);r.previousElementSibling!==h&&n.previousElementSibling===h?(r.remove(),f.set(e,n)):n.remove()}for(const n of t.querySelectorAll(".dsba-fold-toggle")){const e=n.closest('[data-row-key^="session:"]'),r=e===null?"":e.getAttribute("data-row-key")??"",h=r.startsWith("session:")?r.slice(8):"";l.has(h)||n.remove()}for(const n of l){const e=s.get(n);if(e===void 0)continue;const r=K(n,i);if(r.length===0)continue;const h=e.querySelectorAll(".dsba-fold-toggle");for(let S=1;S<h.length;S+=1)h[S].remove();let g=h.length===0?null:h[0];g===null&&(g=document.createElement("button"),g.type="button",g.className="dsba-fold-toggle"),g.dataset.parent=n;const d=e.querySelector(':scope > span[class*="title"]');d!==null?(g.nextSibling!==d||g.parentElement!==e)&&e.insertBefore(g,d):g.parentElement!==e&&e.insertBefore(g,e.firstChild);const k=x(n);let y=g.querySelector(".dsba-fold-chev");if(y===null||y.tagName.toLowerCase()!=="svg"){const S=document.createElementNS("http://www.w3.org/2000/svg","svg");S.setAttribute("class","dsba-fold-chev"),S.setAttribute("viewBox","0 0 16 16"),S.setAttribute("width","16"),S.setAttribute("height","16"),S.setAttribute("aria-hidden","true");const A=document.createElementNS("http://www.w3.org/2000/svg","path");A.setAttribute("d","M6 3.5 10.5 8 6 12.5"),A.setAttribute("fill","none"),A.setAttribute("stroke","currentColor"),A.setAttribute("stroke-width","2"),A.setAttribute("stroke-linecap","round"),A.setAttribute("stroke-linejoin","round"),S.append(A),y=S}else{y.setAttribute("width","16"),y.setAttribute("height","16");const S=y.querySelector("path");S!==null&&S.setAttribute("stroke-width","2")}(g.childNodes.length!==1||g.firstChild!==y)&&g.replaceChildren(y),g.dataset.open=k?"1":"0",g.title=I(k?"collapse":"expand",{count:r.length})}m=!0;try{for(const e of t.querySelectorAll("[data-dsba-fold-list]"))e.closest(".dsba-fold-wrap")===null&&e.remove();for(const e of t.querySelectorAll("[data-dsba-fold]"))e.remove();for(const e of t.querySelectorAll("[data-dsba-fold-list]"))e.closest(".dsba-fold-wrap")===null&&e.remove();for(const e of t.querySelectorAll("[data-dsba-fold-wrap]")){const r=e.dataset.dsbaFoldWrap;(r===void 0||!l.has(r))&&e.remove()}const n=Array.from(V);for(const e of l){const r=K(e,i),h=s.get(e);if(r.length===0||h===void 0)continue;for(const y of r)n.push(y.id);const g=M(r,e);let d=f.get(e)??null;if(d!==null&&d.dataset.version!=="8"&&(d.remove(),d=null),d===null){d=document.createElement("div"),d.className="dsba-fold-wrap",d.dataset.dsbaFoldWrap=e,d.dataset.version="8",d.dataset.open="0";const y=document.createElement("div");y.className="dsba-fold-inner",d.append(y),h.insertAdjacentElement("afterend",d)}else d.previousElementSibling!==h&&h.insertAdjacentElement("afterend",d);f.set(e,d);const k=x(e);d.dataset.open=k?"1":"0",d.dataset.select=c.has(e)?"1":"0",k?(d.__dsbaCleanup!==void 0&&(clearTimeout(d.__dsbaCleanup),d.__dsbaCleanup=void 0),_e(d,e,r,g)):d.querySelector(".dsba-fold-list")!==null&&d.__dsbaCleanup===void 0&&(d.__dsbaCleanup=setTimeout(()=>{if(d.__dsbaCleanup=void 0,!x(e)){const y=d.querySelector(".dsba-fold-inner");y!==null&&y.replaceChildren()}},240))}for(const e of Array.from(t.querySelectorAll(".dsba-fold-wrap"))){const r=e.dataset.dsbaFoldWrap;if(r===void 0||!l.has(r)){e.remove();continue}const h=f.get(r);if(h===void 0||e!==h){e.remove();continue}x(r)||(e.dataset.open="0")}T(n)}finally{m=!1}}function Le(){if(C!==null||typeof document>"u"||typeof MutationObserver>"u")return;const t=i=>i instanceof Element?i.matches('[data-row-key^="session:"], .dsba-fold-wrap, .dsba-fold-toggle, .dsba-fold-list')?!0:i.querySelector('[data-row-key^="session:"], .dsba-fold-wrap, .dsba-fold-toggle, .dsba-fold-list')!==null:!1,s=i=>i instanceof Element?i.matches('[data-row-key^="session:"]')?[i]:Array.from(i.querySelectorAll('[data-row-key^="session:"]')):[];C=new MutationObserver(i=>{let l=!1,f=!1;for(const n of i){for(const e of n.addedNodes){const r=s(e);if(r.length>0){for(const h of r)ue(h.getAttribute("data-row-key").slice(8));l=!0}else t(e)&&(f=!0)}for(const e of n.removedNodes)t(e)&&(f=!0)}l?m||H():f&&q()}),C.observe(document,{childList:!0,subtree:!0})}function Me(t){const{useSessions:s,useWorkspaces:i}=t,l=s(e=>e.ids),f=s(e=>e.byId),n=typeof i=="function"?i(e=>e.archivedSessionIds):[];return L.useEffect(()=>{const e=r=>{const h=r.target;if(!(h instanceof Element))return;const g=h.closest(".dsba-fold-archive");if(g!==null&&r.type==="click"){r.preventDefault(),r.stopImmediatePropagation();const y=g.closest(".dsba-fold-item"),S=y===null?void 0:y.dataset.id;S!==void 0&&(y!==null&&y.dataset.archived==="1"||g.classList.contains("dsba-fold-unarchive")?a.uiWorkspace.unarchiveSession(S).catch(A=>{console.warn("[dsh-branch-aside] item unarchive failed",A)}):a.uiWorkspace.archiveSession(S,{stopActivity:!0}).catch(A=>{console.warn("[dsh-branch-aside] item archive failed",A)}));return}const d=h.closest(".dsba-fold-tool");if(d!==null&&r.type==="click"&&d.dataset.act!=="all"){r.preventDefault(),r.stopImmediatePropagation(),me(d);return}const k=h.closest(".dsba-fold-toggle");if(k!==null){if(r.stopImmediatePropagation(),r.type!=="click")return;r.preventDefault();const y=k.dataset.parent;typeof y=="string"&&y!==""&&B(y);return}};for(const r of["pointerdown","mousedown","pointerup","mouseup","click"])document.addEventListener(r,e,!0);return()=>{for(const r of["pointerdown","mousedown","pointerup","mouseup","click"])document.removeEventListener(r,e,!0)}},[]),L.useEffect(()=>{o.ids=l,o.byId=f,o.archived=new Set(Array.isArray(n)?n:[]),H()},[l,f,n]),null}function Oe(t){c.add(t),u.set(t,!0),E(t,!0),H(),requestAnimationFrame(()=>{const s=document.querySelector("[data-sidebar-list-area]");if(s===null)return;const i=s.querySelector('[data-dsba-fold-wrap="'+t+'"]');i!==null&&(i.dataset.open="1")})}return Le(),{Controller:Me,open:Oe}}function ge(a,o,b){const c=o[b];if(c===void 0)return[];const u=typeof c.displayTitle=="string"?c.displayTitle:"";if(u==="")return[];const p=X+u;return a.filter(m=>{const v=o[m];if(v===void 0||v.origin==="subagent")return!1;try{if(localStorage.getItem("dsba.parent."+m)===b)return!0}catch{}const C=v.displayTitle;if(C===p||C.startsWith(p+" \xB7 ")){try{localStorage.setItem("dsba.parent."+m,b)}catch{}return!0}return!1})}function Ie(a){return a.renderSlot("conversation.session",{view:"chat"})}function qe(){return function(o){const{sessionId:b,useSession:c,useConversation:u,useSessions:p,renderFactorySlot:m}=o,v=c(N=>N),x=u(N=>N).activeTargets.size>0||!v.blank&&!v.awaitingFirstTurn||v.running?"active":v.promptAttempted?"engaging":"blank",B=p(N=>N.byId[b]?.blank),E=x==="blank"&&v.openState==="loading"&&B!==!0,_=x==="blank"&&(v.openState==="open"||B===!0),T=E?"settling":_?"hero":"active";return w(L.Fragment,null,m("conversation.content",{variant:"embedded",phase:T,hero:_},{slots:{views:Ie}}))}}function Ne(a){return function(b){const{useResource:c,useTabInfo:u,SessionProvider:p,renderSlot:m,t:v}=b,{tab:C}=u(),q=c(C.contentId),x=q===void 0?void 0:q.value,[B,E]=L.useState(!1),[_,T]=L.useState(!1);if(x===void 0||p===void 0||typeof m!="function")return null;const N=x.atSeq===void 0?F(v,"banner.note"):F(v,"banner.based",{seq:x.atSeq})+" \xB7 "+F(v,"banner.note"),O=()=>{B||(E(!0),T(!1),Promise.resolve(a.uiWorkspace.archiveSession(x.childSessionId)).then(()=>{try{se(a)?.close(C.id)}catch(M){console.warn("[dsh-branch-aside] close branch tab failed",M)}}).catch(M=>{console.warn("[dsh-branch-aside] archive branch failed",M),T(!0),E(!1)}))};return w("div",{className:"dsba-root"},w("style",{key:"style"},ke),w("div",{key:"banner",className:"dsba-banner"},w("span",{className:"dsba-badge"},F(v,"tab.title")),w("span",{className:"dsba-note"},_?F(v,"banner.archiveFailed"):N),w("button",{key:"archive",type:"button",className:"dsba-archive",title:F(v,"banner.archiveTitle"),"aria-label":F(v,"banner.archiveTitle"),"data-busy":B?"":void 0,disabled:B,onClick:O},F(v,B?"banner.archiving":"banner.archive"))),w("div",{key:"body",className:"dsba-body"},w(Ae,null,w(p,{session:x.reference},m($,{})))))}}function Be(a){return{protocol:ne,async*open(o,{signal:b}){const c=Z(o);if(c===void 0)throw new Error('dsh-branch-aside: invalid branch address "'+o+'"');if(b.aborted)return;const u=a.retain(c.childSessionId,{source:Se,signal:b});try{yield{ok:!0,value:{...c,reference:u}},await Ce(b)}finally{u.release()}}}}return globalThis.__DSBA_TEST_HOOKS__===!0&&(globalThis.__DSBA_TEST__={parseAddress:Z,addressOf:ie,descendants:K,branchChildrenOf:ge,createBranchFold:pe,prehide:{begin:fe,observe:ue,finish:Q,has:a=>V.has(a),css:()=>document.getElementById("dsba-prehide")?.textContent??""}}),{inject:["slots","sessions","locale","sidebarRight","uiWorkspace"],apply(a){console.info("[dsh-branch-aside] client apply"),a.effect(()=>a.locale.register(U,{zh:xe,en:P,ja:P,es:P,fr:P,de:P,ru:P,pt:P}),"dsh-branch-aside: locales"),a.inject(["resources","sidebarRightTabs"],c=>{try{c.effect(()=>c.resources.register(Be(c.sessions)),"dsh-branch-aside: branch chat resources"),c.effect(()=>c.sidebarRightTabs.register({id:ee,kind:te,patterns:[ae+"**"],priority:"extension",canOpen:m=>Z(m)!==void 0,title:m=>{const v=Z(m);if(v===void 0)return oe;const C=c.sessions.list.getSnapshot().byId[v.childSessionId];return C===void 0||!C.displayTitle?oe:C.displayTitle}}),"dsh-branch-aside: branch tab type");const u=Ne(a);c.slots.inject("sidebar.right.pane.tab",()=>c.slots.register({name:"sidebar.right.pane.tab",key:ee,locale:U,children:{[$]:{kind:"single",scope:"session"}}},u));const p=qe();c.slots.inject($,()=>c.slots.register({name:$,locale:U},p)),console.info("[dsh-branch-aside] sidebar chat registered")}catch(u){console.error("[dsh-branch-aside] sidebar chat registration failed",u)}});const o=Te(a);a.slots.inject("conversation.chat.assistant-actions",()=>a.slots.register({name:"conversation.chat.assistant-actions",id:"branch-aside",order:1,locale:U},o));const b=pe(a);a.slots.inject("shell.overlay",()=>a.slots.register({name:"shell.overlay",id:"branch-aside-fold"},b.Controller)),a.inject(["contextMenus"],c=>{try{c.effect(()=>c.contextMenus.register({id:"branch-aside.archive-branches",target:"session",order:550,observe:()=>[a.sessions.list],resolve:({sessionId:u})=>{const p=a.sessions.list.getSnapshot();return ge(p.ids,p.byId,u).length===0?[]:[{id:"branch-aside.archive-branches",label:I("menuArchive"),icon:{key:"workspace.archive"},run:()=>b.open(u)}]}}),"dsh-branch-aside: session branch archive menu")}catch(u){console.warn("[dsh-branch-aside] session menu registration failed",u)}}),console.info("[dsh-branch-aside] actions registered")}}}});
|
package/cordis.patch.yml
ADDED
package/icon.png
ADDED
|
Binary file
|
package/index.js
ADDED
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-branch-aside",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Open a forked child session in the right sidebar while the main chat keeps advancing.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/YE-LIGHT/dsh-branch-aside.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/YE-LIGHT/dsh-branch-aside#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/YE-LIGHT/dsh-branch-aside/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"deepseek-harness",
|
|
17
|
+
"dsh",
|
|
18
|
+
"dsh-plugin",
|
|
19
|
+
"dsh-client",
|
|
20
|
+
"fork",
|
|
21
|
+
"branch",
|
|
22
|
+
"sidebar"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./index.js",
|
|
26
|
+
"./client": "./client.js",
|
|
27
|
+
"./locale/*.json": "./locale/*.json",
|
|
28
|
+
"./icon": "./icon.png"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"index.js",
|
|
32
|
+
"client.js",
|
|
33
|
+
"cordis.patch.yml",
|
|
34
|
+
"locale/*.json",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE",
|
|
37
|
+
"icon.png",
|
|
38
|
+
"CHANGELOG.md"
|
|
39
|
+
],
|
|
40
|
+
"dsh": {
|
|
41
|
+
"bundle": {
|
|
42
|
+
"patch": "./cordis.patch.yml"
|
|
43
|
+
},
|
|
44
|
+
"client": {
|
|
45
|
+
"platform": "web",
|
|
46
|
+
"immediately": true,
|
|
47
|
+
"inject": [
|
|
48
|
+
"@deepseek-ai/dsh-client-ui-chat",
|
|
49
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
50
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "node scripts/build-client.mjs",
|
|
56
|
+
"build:minify": "node scripts/build-client.mjs --minify",
|
|
57
|
+
"prepack": "node scripts/build-client.mjs --minify",
|
|
58
|
+
"lint": "eslint src scripts tests --max-warnings=0",
|
|
59
|
+
"test": "node --test tests/*.test.mjs",
|
|
60
|
+
"sbom": "node scripts/gen-sbom.mjs",
|
|
61
|
+
"verify": "node --check client.js && npm run lint && npm test && npm run sbom"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@eslint/js": "^10.0.1",
|
|
65
|
+
"esbuild": "^0.28.2",
|
|
66
|
+
"eslint": "^9.39.5"
|
|
67
|
+
}
|
|
68
|
+
}
|