dsh-gufa-code 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/client.js +172 -9
- package/package.json +1 -1
- package/src/client/00-core.js +52 -0
- package/src/client/90-app.js +120 -9
package/README.md
CHANGED
|
@@ -42,6 +42,8 @@ dsh plugin add dsh-gufa-code
|
|
|
42
42
|
- 多标签、按扩展名语法高亮、面包屑、状态栏(分支 / 行列 / 保存状态);
|
|
43
43
|
- 保存走磁盘版本冲突检测 + 原子写;未保存标记;
|
|
44
44
|
- 资源管理器右键:新建 / 重命名 / 删除 / 复制 / 粘贴 / 打开所在文件夹 / 两文件对比;
|
|
45
|
+
- **从 Finder 粘贴/拖入文件**:系统剪贴板里复制的文件可直接 ⌘V 粘进资源管理器(写入选中的目录,重名自动加「副本」),也可从 Finder 直接拖进文件树;
|
|
46
|
+
- **粘贴文件到聊天框 = @引用**:在 Finder 复制文件后在右侧对话输入框 ⌘V,会自动匹配项目内同名同内容文件并插入 `@相对路径` 引用(图片仍按 DSH 默认附件处理);
|
|
45
47
|
- 支持 Ctrl/Cmd 多选、软删除与 `⌘Z` 撤销;
|
|
46
48
|
- **Git diff**:Monaco diff 视图,红绿强对比、自动定位第一处改动,工作区一侧可编辑并自动保存;
|
|
47
49
|
- **两文件对比**:任选两个文件,左右都可编辑(本地草稿,保存时写回)。
|
|
@@ -62,6 +64,7 @@ dsh plugin add dsh-gufa-code
|
|
|
62
64
|
|
|
63
65
|
- 右侧停靠的就是 **官方 DSH 会话本体**:工具调用、自动读写文件、审批、斜杠命令、上下文引用、会话历史全部可用;
|
|
64
66
|
- 工具条:新建会话 / 会话列表 / 打开完整对话 / 收起;
|
|
67
|
+
- **会话弹窗里可以直接切换工作区**:点弹窗右上角的工作区名,选任意工作区后下方会话列表随之切换,点会话即打开(IDE 项目同时切到该工作区),不用再先切左侧工作区;
|
|
65
68
|
- 会话里的文件链接、diff 标签页属于 DSH 右侧栏,被覆盖层挡住时点「打开完整对话」即可查看。
|
|
66
69
|
|
|
67
70
|
### 外观
|
package/client.js
CHANGED
|
@@ -1086,6 +1086,19 @@ html[data-gufa-ide] [role="dialog"] {
|
|
|
1086
1086
|
.gufa-session-group-count{font-size:10.5px;opacity:.6;font-variant-numeric:tabular-nums}
|
|
1087
1087
|
.gufa-session-group[data-current] .gufa-session-group-head{color:var(--gufa-text)}
|
|
1088
1088
|
.gufa-session-group .gufa-session-row{margin-left:10px}
|
|
1089
|
+
.gufa-session-workspace-btn{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--gufa-border);background:var(--gufa-layer2);
|
|
1090
|
+
color:var(--gufa-text-dim);border-radius:7px;padding:2px 8px;font:inherit;font-size:11.5px;cursor:pointer;max-width:260px}
|
|
1091
|
+
.gufa-session-workspace-btn:hover{background:var(--gufa-hover);color:var(--gufa-text)}
|
|
1092
|
+
.gufa-session-workspace-btn span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1093
|
+
.gufa-session-workspace-picker{display:flex;flex-direction:column;gap:2px;padding:6px 10px;max-height:220px;overflow:auto;
|
|
1094
|
+
border-top:1px solid var(--gufa-border);border-bottom:1px solid var(--gufa-border);background:var(--gufa-layer)}
|
|
1095
|
+
.gufa-session-workspace-option{display:flex;align-items:center;gap:8px;width:100%;padding:6px 8px;border:0;border-radius:7px;
|
|
1096
|
+
background:transparent;color:var(--gufa-text);font:inherit;font-size:12px;cursor:pointer;text-align:left}
|
|
1097
|
+
.gufa-session-workspace-option:hover{background:var(--gufa-hover)}
|
|
1098
|
+
.gufa-session-workspace-option[data-current]{background:var(--gufa-active)}
|
|
1099
|
+
.gufa-session-workspace-option-title{flex:0 0 auto;font-weight:550}
|
|
1100
|
+
.gufa-session-workspace-option-path{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
|
|
1101
|
+
color:var(--gufa-text-dim);font-size:10.5px;text-align:right}
|
|
1089
1102
|
.gufa-session-workspace{font-size:11px;color:var(--gufa-text-dim);max-width:40%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1090
1103
|
.gufa-session-row-title{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis}
|
|
1091
1104
|
.gufa-session-row-when{flex:0 0 auto;font-size:10.5px;color:var(--gufa-solid-text-dim, var(--dsw-alias-label-secondary));font-variant-numeric:tabular-nums}
|
|
@@ -1129,6 +1142,19 @@ html[data-gufa-ide] [role="dialog"] {
|
|
|
1129
1142
|
.gufa-session-group-count{font-size:10.5px;opacity:.6;font-variant-numeric:tabular-nums}
|
|
1130
1143
|
.gufa-session-group[data-current] .gufa-session-group-head{color:var(--gufa-text)}
|
|
1131
1144
|
.gufa-session-group .gufa-session-row{margin-left:10px}
|
|
1145
|
+
.gufa-session-workspace-btn{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--gufa-border);background:var(--gufa-layer2);
|
|
1146
|
+
color:var(--gufa-text-dim);border-radius:7px;padding:2px 8px;font:inherit;font-size:11.5px;cursor:pointer;max-width:260px}
|
|
1147
|
+
.gufa-session-workspace-btn:hover{background:var(--gufa-hover);color:var(--gufa-text)}
|
|
1148
|
+
.gufa-session-workspace-btn span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1149
|
+
.gufa-session-workspace-picker{display:flex;flex-direction:column;gap:2px;padding:6px 10px;max-height:220px;overflow:auto;
|
|
1150
|
+
border-top:1px solid var(--gufa-border);border-bottom:1px solid var(--gufa-border);background:var(--gufa-layer)}
|
|
1151
|
+
.gufa-session-workspace-option{display:flex;align-items:center;gap:8px;width:100%;padding:6px 8px;border:0;border-radius:7px;
|
|
1152
|
+
background:transparent;color:var(--gufa-text);font:inherit;font-size:12px;cursor:pointer;text-align:left}
|
|
1153
|
+
.gufa-session-workspace-option:hover{background:var(--gufa-hover)}
|
|
1154
|
+
.gufa-session-workspace-option[data-current]{background:var(--gufa-active)}
|
|
1155
|
+
.gufa-session-workspace-option-title{flex:0 0 auto;font-weight:550}
|
|
1156
|
+
.gufa-session-workspace-option-path{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
|
|
1157
|
+
color:var(--gufa-text-dim);font-size:10.5px;text-align:right}
|
|
1132
1158
|
.gufa-session-workspace{font-size:11px;color:var(--gufa-text-dim);max-width:40%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1133
1159
|
.gufa-session-row-title{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis}
|
|
1134
1160
|
.gufa-session-row-when{flex:0 0 auto;font-size:10.5px;color:var(--gufa-solid-text-dim, var(--dsw-alias-label-secondary));font-variant-numeric:tabular-nums}
|
|
@@ -1172,6 +1198,19 @@ html[data-gufa-ide] [role="dialog"] {
|
|
|
1172
1198
|
.gufa-session-group-count{font-size:10.5px;opacity:.6;font-variant-numeric:tabular-nums}
|
|
1173
1199
|
.gufa-session-group[data-current] .gufa-session-group-head{color:var(--gufa-text)}
|
|
1174
1200
|
.gufa-session-group .gufa-session-row{margin-left:10px}
|
|
1201
|
+
.gufa-session-workspace-btn{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--gufa-border);background:var(--gufa-layer2);
|
|
1202
|
+
color:var(--gufa-text-dim);border-radius:7px;padding:2px 8px;font:inherit;font-size:11.5px;cursor:pointer;max-width:260px}
|
|
1203
|
+
.gufa-session-workspace-btn:hover{background:var(--gufa-hover);color:var(--gufa-text)}
|
|
1204
|
+
.gufa-session-workspace-btn span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1205
|
+
.gufa-session-workspace-picker{display:flex;flex-direction:column;gap:2px;padding:6px 10px;max-height:220px;overflow:auto;
|
|
1206
|
+
border-top:1px solid var(--gufa-border);border-bottom:1px solid var(--gufa-border);background:var(--gufa-layer)}
|
|
1207
|
+
.gufa-session-workspace-option{display:flex;align-items:center;gap:8px;width:100%;padding:6px 8px;border:0;border-radius:7px;
|
|
1208
|
+
background:transparent;color:var(--gufa-text);font:inherit;font-size:12px;cursor:pointer;text-align:left}
|
|
1209
|
+
.gufa-session-workspace-option:hover{background:var(--gufa-hover)}
|
|
1210
|
+
.gufa-session-workspace-option[data-current]{background:var(--gufa-active)}
|
|
1211
|
+
.gufa-session-workspace-option-title{flex:0 0 auto;font-weight:550}
|
|
1212
|
+
.gufa-session-workspace-option-path{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
|
|
1213
|
+
color:var(--gufa-text-dim);font-size:10.5px;text-align:right}
|
|
1175
1214
|
.gufa-session-workspace{font-size:11px;color:var(--gufa-text-dim);max-width:40%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1176
1215
|
.gufa-session-row-title{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis}
|
|
1177
1216
|
.gufa-session-row-when{flex:0 0 auto;font-size:10.5px;color:var(--gufa-solid-text-dim, var(--dsw-alias-label-secondary));font-variant-numeric:tabular-nums}
|
|
@@ -1215,6 +1254,19 @@ html[data-gufa-ide] [role="dialog"] {
|
|
|
1215
1254
|
.gufa-session-group-count{font-size:10.5px;opacity:.6;font-variant-numeric:tabular-nums}
|
|
1216
1255
|
.gufa-session-group[data-current] .gufa-session-group-head{color:var(--gufa-text)}
|
|
1217
1256
|
.gufa-session-group .gufa-session-row{margin-left:10px}
|
|
1257
|
+
.gufa-session-workspace-btn{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--gufa-border);background:var(--gufa-layer2);
|
|
1258
|
+
color:var(--gufa-text-dim);border-radius:7px;padding:2px 8px;font:inherit;font-size:11.5px;cursor:pointer;max-width:260px}
|
|
1259
|
+
.gufa-session-workspace-btn:hover{background:var(--gufa-hover);color:var(--gufa-text)}
|
|
1260
|
+
.gufa-session-workspace-btn span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1261
|
+
.gufa-session-workspace-picker{display:flex;flex-direction:column;gap:2px;padding:6px 10px;max-height:220px;overflow:auto;
|
|
1262
|
+
border-top:1px solid var(--gufa-border);border-bottom:1px solid var(--gufa-border);background:var(--gufa-layer)}
|
|
1263
|
+
.gufa-session-workspace-option{display:flex;align-items:center;gap:8px;width:100%;padding:6px 8px;border:0;border-radius:7px;
|
|
1264
|
+
background:transparent;color:var(--gufa-text);font:inherit;font-size:12px;cursor:pointer;text-align:left}
|
|
1265
|
+
.gufa-session-workspace-option:hover{background:var(--gufa-hover)}
|
|
1266
|
+
.gufa-session-workspace-option[data-current]{background:var(--gufa-active)}
|
|
1267
|
+
.gufa-session-workspace-option-title{flex:0 0 auto;font-weight:550}
|
|
1268
|
+
.gufa-session-workspace-option-path{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
|
|
1269
|
+
color:var(--gufa-text-dim);font-size:10.5px;text-align:right}
|
|
1218
1270
|
.gufa-session-workspace{font-size:11px;color:var(--gufa-text-dim);max-width:40%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1219
1271
|
.gufa-session-row-title{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis}
|
|
1220
1272
|
.gufa-session-row-when{flex:0 0 auto;font-size:10.5px;color:var(--gufa-solid-text-dim, var(--dsw-alias-label-secondary));font-variant-numeric:tabular-nums}
|
|
@@ -9281,6 +9333,9 @@ G.GufaApp = function GufaApp(props) {
|
|
|
9281
9333
|
const sessionTitle = useSessions !== undefined ? useSessions(selectSessionTitle) : null
|
|
9282
9334
|
const currentSessionId = useSessions !== undefined ? useSessions(selectMainSessionId) : null
|
|
9283
9335
|
const [sessionsOpen, setSessionsOpen] = useState(false)
|
|
9336
|
+
/* 会话弹窗里选中的工作区(null = 跟随当前 IDE 项目) */
|
|
9337
|
+
const [sessionWorkspacePath, setSessionWorkspacePath] = useState(null)
|
|
9338
|
+
const [sessionWorkspacePicker, setSessionWorkspacePicker] = useState(false)
|
|
9284
9339
|
const recentSessionsJson = useSessions !== undefined ? useSessions(selectRecentSessionsJson) : '[]'
|
|
9285
9340
|
const recentSessionsRaw = useMemo(() => {
|
|
9286
9341
|
let parsed
|
|
@@ -10308,7 +10363,14 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10308
10363
|
setRecentCurrentIds((current) => (current.includes(currentSessionId) ? current : [currentSessionId, ...current].slice(0, 12)))
|
|
10309
10364
|
}, [currentSessionId])
|
|
10310
10365
|
|
|
10311
|
-
|
|
10366
|
+
useEffect(() => {
|
|
10367
|
+
if (sessionsOpen === true) return undefined
|
|
10368
|
+
setSessionWorkspacePath(null)
|
|
10369
|
+
setSessionWorkspacePicker(false)
|
|
10370
|
+
return undefined
|
|
10371
|
+
}, [sessionsOpen])
|
|
10372
|
+
|
|
10373
|
+
/* 切换会话弹窗:打开时向 Host 拉取「弹窗里选中工作区的会话」(经典侧边栏同源数据) */
|
|
10312
10374
|
useEffect(() => {
|
|
10313
10375
|
if (sessionsOpen !== true) return undefined
|
|
10314
10376
|
if (project === null || typeof project.root !== 'string' || project.root === '') {
|
|
@@ -10316,10 +10378,11 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10316
10378
|
return undefined
|
|
10317
10379
|
}
|
|
10318
10380
|
let cancelled = false
|
|
10381
|
+
const dialogPath = sessionWorkspacePath !== null && sessionWorkspacePath !== '' ? sessionWorkspacePath : project.root
|
|
10319
10382
|
setWorkspaceSessions({ status: 'loading', sessions: [], groups: [] })
|
|
10320
10383
|
void Promise.all([
|
|
10321
10384
|
G.api('workspaces.list', {}).catch(() => ({ workspaces: [] })),
|
|
10322
|
-
G.api('workspaces.sessions', { path:
|
|
10385
|
+
G.api('workspaces.sessions', { path: dialogPath, currentSessionId: currentSessionId ?? '' }).catch(() => ({ groups: [] })),
|
|
10323
10386
|
])
|
|
10324
10387
|
.then(([listValue, sessionsValue]) => {
|
|
10325
10388
|
if (cancelled) return
|
|
@@ -10333,7 +10396,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10333
10396
|
} catch {
|
|
10334
10397
|
/* ignore */
|
|
10335
10398
|
}
|
|
10336
|
-
const firstGroup = groups.find((group) => group.path ===
|
|
10399
|
+
const firstGroup = groups.find((group) => group.path === dialogPath) ?? groups[0]
|
|
10337
10400
|
setWorkspaceSessions((previous) => {
|
|
10338
10401
|
const nextSessions = Array.isArray(sessionsValue?.sessions)
|
|
10339
10402
|
? sessionsValue.sessions
|
|
@@ -10360,7 +10423,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10360
10423
|
return () => {
|
|
10361
10424
|
cancelled = true
|
|
10362
10425
|
}
|
|
10363
|
-
}, [sessionsOpen, project?.root, currentSessionId])
|
|
10426
|
+
}, [sessionsOpen, project?.root, currentSessionId, sessionWorkspacePath])
|
|
10364
10427
|
|
|
10365
10428
|
/* ── 退出(关闭覆盖层,回到 DSH 界面) ─────────────────────────────── */
|
|
10366
10429
|
const exitMode = useCallback(() => {
|
|
@@ -10434,6 +10497,60 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10434
10497
|
}
|
|
10435
10498
|
}, [])
|
|
10436
10499
|
|
|
10500
|
+
/* 从会话弹窗打开会话:可同时切换到该会话所属工作区的项目 */
|
|
10501
|
+
const openSessionInWorkspace = useCallback((sessionId, workspacePath) => {
|
|
10502
|
+
projectPinnedRef.current = false
|
|
10503
|
+
const service = workspaceService()
|
|
10504
|
+
const path = typeof workspacePath === 'string' ? workspacePath : ''
|
|
10505
|
+
void (async () => {
|
|
10506
|
+
try {
|
|
10507
|
+
if (service !== undefined && service !== null && typeof service.openSession === 'function') service.openSession(sessionId)
|
|
10508
|
+
else setBanner('当前界面不支持切换会话')
|
|
10509
|
+
} catch (error) {
|
|
10510
|
+
setBanner(G.errorText(error))
|
|
10511
|
+
}
|
|
10512
|
+
if (path !== '' && project !== null && project.root !== path) {
|
|
10513
|
+
try {
|
|
10514
|
+
await openProjectPath(path)
|
|
10515
|
+
setBanner('')
|
|
10516
|
+
} catch (error) {
|
|
10517
|
+
setBanner(G.errorText(error))
|
|
10518
|
+
}
|
|
10519
|
+
}
|
|
10520
|
+
})()
|
|
10521
|
+
}, [project, openProjectPath])
|
|
10522
|
+
|
|
10523
|
+
/* 从会话弹窗新建会话:在弹窗选中的工作区里新建,并切换 IDE 项目 */
|
|
10524
|
+
const startNewSessionInWorkspace = useCallback((workspacePath) => {
|
|
10525
|
+
projectPinnedRef.current = false
|
|
10526
|
+
const service = workspaceService()
|
|
10527
|
+
const path = typeof workspacePath === 'string' ? workspacePath : ''
|
|
10528
|
+
void (async () => {
|
|
10529
|
+
let workspaceId = null
|
|
10530
|
+
try {
|
|
10531
|
+
const value = await G.api('workspaces.list', {})
|
|
10532
|
+
const list = Array.isArray(value?.workspaces) ? value.workspaces : []
|
|
10533
|
+
const matched = list.find((item) => item !== null && item.path === path)
|
|
10534
|
+
if (matched !== undefined && typeof matched.id === 'string') workspaceId = matched.id
|
|
10535
|
+
} catch {
|
|
10536
|
+
workspaceId = null
|
|
10537
|
+
}
|
|
10538
|
+
try {
|
|
10539
|
+
if (service !== undefined && service !== null && typeof service.startSession === 'function') {
|
|
10540
|
+
if (workspaceId !== null) service.startSession(workspaceId)
|
|
10541
|
+
else service.startSession()
|
|
10542
|
+
} else {
|
|
10543
|
+
setBanner('当前界面不支持新建会话')
|
|
10544
|
+
return
|
|
10545
|
+
}
|
|
10546
|
+
if (path !== '' && project !== null && project.root !== path) await openProjectPath(path)
|
|
10547
|
+
setBanner('')
|
|
10548
|
+
} catch (error) {
|
|
10549
|
+
setBanner(G.errorText(error))
|
|
10550
|
+
}
|
|
10551
|
+
})()
|
|
10552
|
+
}, [project, openProjectPath])
|
|
10553
|
+
|
|
10437
10554
|
const activeFileForChat = useMemo(() => {
|
|
10438
10555
|
if (activeTab === null || activeTab.kind === 'diff' || activeTab.kind === 'graph') return null
|
|
10439
10556
|
return { path: activeTab.path, content: activeTab.content ?? '', language: activeTab.language }
|
|
@@ -11177,7 +11294,13 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11177
11294
|
const currentRoot = project !== null && typeof project.root === 'string' ? project.root : ''
|
|
11178
11295
|
const currentWorkspace = workspaceIndex.find((item) => item !== null && item.path === currentRoot)
|
|
11179
11296
|
const currentWorkspaceId = currentWorkspace !== undefined && typeof currentWorkspace.id === 'string' ? currentWorkspace.id : ''
|
|
11180
|
-
const
|
|
11297
|
+
const dialogPath = sessionWorkspacePath !== null && sessionWorkspacePath !== '' ? sessionWorkspacePath : currentRoot
|
|
11298
|
+
const dialogWorkspace = workspaceIndex.find((item) => item !== null && item.path === dialogPath)
|
|
11299
|
+
const dialogWorkspaceId = dialogWorkspace !== undefined && typeof dialogWorkspace.id === 'string' ? dialogWorkspace.id : ''
|
|
11300
|
+
const dialogWorkspaceTitle = dialogWorkspace !== undefined && typeof dialogWorkspace.title === 'string' && dialogWorkspace.title !== ''
|
|
11301
|
+
? dialogWorkspace.title
|
|
11302
|
+
: dialogPath !== '' ? G.basename(dialogPath) : ''
|
|
11303
|
+
const hostGroup = hostGroups.find((group) => (dialogWorkspaceId !== '' ? group.workspaceId === dialogWorkspaceId : group.path === dialogPath))
|
|
11181
11304
|
const localTitleById = new Map(
|
|
11182
11305
|
recentSessionsRaw.filter((row) => row !== null && typeof row === 'object' && typeof row.id === 'string').map((row) => [row.id, row.title]),
|
|
11183
11306
|
)
|
|
@@ -11239,7 +11362,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11239
11362
|
if (fromStore !== undefined && fromStore.blank === true) continue
|
|
11240
11363
|
// 只保留属于当前工作区的会话(切换工作区后不要带出旧工作区的会话)
|
|
11241
11364
|
if (fromStore !== undefined && typeof fromStore.workspaceId === 'string' && fromStore.workspaceId !== '' && workspaceSessions.workspaceId !== undefined && workspaceSessions.workspaceId !== '' && fromStore.workspaceId !== workspaceSessions.workspaceId) continue
|
|
11242
|
-
if (fromStore !== undefined && typeof fromStore.cwd === 'string' && fromStore.cwd !== '' &&
|
|
11365
|
+
if (fromStore !== undefined && typeof fromStore.cwd === 'string' && fromStore.cwd !== '' && dialogPath !== '' && fromStore.cwd !== dialogPath) continue
|
|
11243
11366
|
const title = localTitleById.get(id) ?? (fromStore !== undefined ? fromStore.title : '')
|
|
11244
11367
|
if (typeof title !== 'string' || title === '') continue
|
|
11245
11368
|
retained.push({ id, title, when: localWhenById.get(id) ?? (fromStore !== undefined ? fromStore.when : Date.now()) })
|
|
@@ -11270,7 +11393,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11270
11393
|
title: session.title,
|
|
11271
11394
|
onClick: () => {
|
|
11272
11395
|
close()
|
|
11273
|
-
|
|
11396
|
+
openSessionInWorkspace(session.id, dialogPath)
|
|
11274
11397
|
},
|
|
11275
11398
|
},
|
|
11276
11399
|
h(G.Icon, { name: 'message', size: 14 }),
|
|
@@ -11300,9 +11423,49 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11300
11423
|
{ className: 'gufa-modal-head' },
|
|
11301
11424
|
h(G.Icon, { name: 'history', size: 14 }),
|
|
11302
11425
|
h('span', { style: { flex: '1 1 auto' } }, t('dock.sessionsTitle')),
|
|
11303
|
-
project !== null
|
|
11426
|
+
project !== null
|
|
11427
|
+
? h(
|
|
11428
|
+
'button',
|
|
11429
|
+
{
|
|
11430
|
+
type: 'button',
|
|
11431
|
+
className: 'gufa-session-workspace gufa-session-workspace-btn',
|
|
11432
|
+
title: '选择工作区(下方会话列表随之切换)',
|
|
11433
|
+
onClick: () => setSessionWorkspacePicker((value) => !value),
|
|
11434
|
+
},
|
|
11435
|
+
h(G.Icon, { name: 'folder-open', size: 12 }),
|
|
11436
|
+
h('span', null, dialogWorkspaceTitle !== '' ? dialogWorkspaceTitle : project.name),
|
|
11437
|
+
h(G.Icon, { name: sessionWorkspacePicker ? 'chevron-up' : 'chevron-down', size: 12 }),
|
|
11438
|
+
)
|
|
11439
|
+
: null,
|
|
11304
11440
|
h(G.IconButton, { className: 'gufa-modal-close', title: t('common.close'), onClick: close }, h(G.Icon, { name: 'close', size: 14 })),
|
|
11305
11441
|
),
|
|
11442
|
+
sessionWorkspacePicker
|
|
11443
|
+
? h(
|
|
11444
|
+
'div',
|
|
11445
|
+
{ className: 'gufa-session-workspace-picker gufa-scroll' },
|
|
11446
|
+
workspaceIndex.length === 0
|
|
11447
|
+
? h('div', { className: 'gufa-hint', style: { padding: '8px 12px' } }, t('workspace.empty'))
|
|
11448
|
+
: workspaceIndex.map((workspace) =>
|
|
11449
|
+
h(
|
|
11450
|
+
'button',
|
|
11451
|
+
{
|
|
11452
|
+
key: workspace.id,
|
|
11453
|
+
type: 'button',
|
|
11454
|
+
className: 'gufa-session-workspace-option',
|
|
11455
|
+
'data-current': dialogPath === workspace.path ? '' : undefined,
|
|
11456
|
+
title: workspace.path,
|
|
11457
|
+
onClick: () => {
|
|
11458
|
+
setSessionWorkspacePath(workspace.path)
|
|
11459
|
+
setSessionWorkspacePicker(false)
|
|
11460
|
+
},
|
|
11461
|
+
},
|
|
11462
|
+
h(G.Icon, { name: 'folder-open', size: 13 }),
|
|
11463
|
+
h('span', { className: 'gufa-session-workspace-option-title' }, workspace.title !== '' ? workspace.title : G.basename(workspace.path)),
|
|
11464
|
+
h('span', { className: 'gufa-session-workspace-option-path' }, workspace.path),
|
|
11465
|
+
),
|
|
11466
|
+
),
|
|
11467
|
+
)
|
|
11468
|
+
: null,
|
|
11306
11469
|
h(
|
|
11307
11470
|
'div',
|
|
11308
11471
|
{ className: 'gufa-modal-body' },
|
|
@@ -11315,7 +11478,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11315
11478
|
h(
|
|
11316
11479
|
'div',
|
|
11317
11480
|
{ className: 'gufa-modal-foot' },
|
|
11318
|
-
h(G.Button, { icon: 'plus', onClick: () => { close();
|
|
11481
|
+
h(G.Button, { icon: 'plus', onClick: () => { close(); startNewSessionInWorkspace(dialogPath) } }, t('dock.newSession')),
|
|
11319
11482
|
h(G.Button, { onClick: close }, t('common.close')),
|
|
11320
11483
|
),
|
|
11321
11484
|
),
|
package/package.json
CHANGED
package/src/client/00-core.js
CHANGED
|
@@ -1078,6 +1078,19 @@ html[data-gufa-ide] [role="dialog"] {
|
|
|
1078
1078
|
.gufa-session-group-count{font-size:10.5px;opacity:.6;font-variant-numeric:tabular-nums}
|
|
1079
1079
|
.gufa-session-group[data-current] .gufa-session-group-head{color:var(--gufa-text)}
|
|
1080
1080
|
.gufa-session-group .gufa-session-row{margin-left:10px}
|
|
1081
|
+
.gufa-session-workspace-btn{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--gufa-border);background:var(--gufa-layer2);
|
|
1082
|
+
color:var(--gufa-text-dim);border-radius:7px;padding:2px 8px;font:inherit;font-size:11.5px;cursor:pointer;max-width:260px}
|
|
1083
|
+
.gufa-session-workspace-btn:hover{background:var(--gufa-hover);color:var(--gufa-text)}
|
|
1084
|
+
.gufa-session-workspace-btn span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1085
|
+
.gufa-session-workspace-picker{display:flex;flex-direction:column;gap:2px;padding:6px 10px;max-height:220px;overflow:auto;
|
|
1086
|
+
border-top:1px solid var(--gufa-border);border-bottom:1px solid var(--gufa-border);background:var(--gufa-layer)}
|
|
1087
|
+
.gufa-session-workspace-option{display:flex;align-items:center;gap:8px;width:100%;padding:6px 8px;border:0;border-radius:7px;
|
|
1088
|
+
background:transparent;color:var(--gufa-text);font:inherit;font-size:12px;cursor:pointer;text-align:left}
|
|
1089
|
+
.gufa-session-workspace-option:hover{background:var(--gufa-hover)}
|
|
1090
|
+
.gufa-session-workspace-option[data-current]{background:var(--gufa-active)}
|
|
1091
|
+
.gufa-session-workspace-option-title{flex:0 0 auto;font-weight:550}
|
|
1092
|
+
.gufa-session-workspace-option-path{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
|
|
1093
|
+
color:var(--gufa-text-dim);font-size:10.5px;text-align:right}
|
|
1081
1094
|
.gufa-session-workspace{font-size:11px;color:var(--gufa-text-dim);max-width:40%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1082
1095
|
.gufa-session-row-title{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis}
|
|
1083
1096
|
.gufa-session-row-when{flex:0 0 auto;font-size:10.5px;color:var(--gufa-solid-text-dim, var(--dsw-alias-label-secondary));font-variant-numeric:tabular-nums}
|
|
@@ -1121,6 +1134,19 @@ html[data-gufa-ide] [role="dialog"] {
|
|
|
1121
1134
|
.gufa-session-group-count{font-size:10.5px;opacity:.6;font-variant-numeric:tabular-nums}
|
|
1122
1135
|
.gufa-session-group[data-current] .gufa-session-group-head{color:var(--gufa-text)}
|
|
1123
1136
|
.gufa-session-group .gufa-session-row{margin-left:10px}
|
|
1137
|
+
.gufa-session-workspace-btn{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--gufa-border);background:var(--gufa-layer2);
|
|
1138
|
+
color:var(--gufa-text-dim);border-radius:7px;padding:2px 8px;font:inherit;font-size:11.5px;cursor:pointer;max-width:260px}
|
|
1139
|
+
.gufa-session-workspace-btn:hover{background:var(--gufa-hover);color:var(--gufa-text)}
|
|
1140
|
+
.gufa-session-workspace-btn span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1141
|
+
.gufa-session-workspace-picker{display:flex;flex-direction:column;gap:2px;padding:6px 10px;max-height:220px;overflow:auto;
|
|
1142
|
+
border-top:1px solid var(--gufa-border);border-bottom:1px solid var(--gufa-border);background:var(--gufa-layer)}
|
|
1143
|
+
.gufa-session-workspace-option{display:flex;align-items:center;gap:8px;width:100%;padding:6px 8px;border:0;border-radius:7px;
|
|
1144
|
+
background:transparent;color:var(--gufa-text);font:inherit;font-size:12px;cursor:pointer;text-align:left}
|
|
1145
|
+
.gufa-session-workspace-option:hover{background:var(--gufa-hover)}
|
|
1146
|
+
.gufa-session-workspace-option[data-current]{background:var(--gufa-active)}
|
|
1147
|
+
.gufa-session-workspace-option-title{flex:0 0 auto;font-weight:550}
|
|
1148
|
+
.gufa-session-workspace-option-path{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
|
|
1149
|
+
color:var(--gufa-text-dim);font-size:10.5px;text-align:right}
|
|
1124
1150
|
.gufa-session-workspace{font-size:11px;color:var(--gufa-text-dim);max-width:40%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1125
1151
|
.gufa-session-row-title{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis}
|
|
1126
1152
|
.gufa-session-row-when{flex:0 0 auto;font-size:10.5px;color:var(--gufa-solid-text-dim, var(--dsw-alias-label-secondary));font-variant-numeric:tabular-nums}
|
|
@@ -1164,6 +1190,19 @@ html[data-gufa-ide] [role="dialog"] {
|
|
|
1164
1190
|
.gufa-session-group-count{font-size:10.5px;opacity:.6;font-variant-numeric:tabular-nums}
|
|
1165
1191
|
.gufa-session-group[data-current] .gufa-session-group-head{color:var(--gufa-text)}
|
|
1166
1192
|
.gufa-session-group .gufa-session-row{margin-left:10px}
|
|
1193
|
+
.gufa-session-workspace-btn{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--gufa-border);background:var(--gufa-layer2);
|
|
1194
|
+
color:var(--gufa-text-dim);border-radius:7px;padding:2px 8px;font:inherit;font-size:11.5px;cursor:pointer;max-width:260px}
|
|
1195
|
+
.gufa-session-workspace-btn:hover{background:var(--gufa-hover);color:var(--gufa-text)}
|
|
1196
|
+
.gufa-session-workspace-btn span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1197
|
+
.gufa-session-workspace-picker{display:flex;flex-direction:column;gap:2px;padding:6px 10px;max-height:220px;overflow:auto;
|
|
1198
|
+
border-top:1px solid var(--gufa-border);border-bottom:1px solid var(--gufa-border);background:var(--gufa-layer)}
|
|
1199
|
+
.gufa-session-workspace-option{display:flex;align-items:center;gap:8px;width:100%;padding:6px 8px;border:0;border-radius:7px;
|
|
1200
|
+
background:transparent;color:var(--gufa-text);font:inherit;font-size:12px;cursor:pointer;text-align:left}
|
|
1201
|
+
.gufa-session-workspace-option:hover{background:var(--gufa-hover)}
|
|
1202
|
+
.gufa-session-workspace-option[data-current]{background:var(--gufa-active)}
|
|
1203
|
+
.gufa-session-workspace-option-title{flex:0 0 auto;font-weight:550}
|
|
1204
|
+
.gufa-session-workspace-option-path{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
|
|
1205
|
+
color:var(--gufa-text-dim);font-size:10.5px;text-align:right}
|
|
1167
1206
|
.gufa-session-workspace{font-size:11px;color:var(--gufa-text-dim);max-width:40%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1168
1207
|
.gufa-session-row-title{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis}
|
|
1169
1208
|
.gufa-session-row-when{flex:0 0 auto;font-size:10.5px;color:var(--gufa-solid-text-dim, var(--dsw-alias-label-secondary));font-variant-numeric:tabular-nums}
|
|
@@ -1207,6 +1246,19 @@ html[data-gufa-ide] [role="dialog"] {
|
|
|
1207
1246
|
.gufa-session-group-count{font-size:10.5px;opacity:.6;font-variant-numeric:tabular-nums}
|
|
1208
1247
|
.gufa-session-group[data-current] .gufa-session-group-head{color:var(--gufa-text)}
|
|
1209
1248
|
.gufa-session-group .gufa-session-row{margin-left:10px}
|
|
1249
|
+
.gufa-session-workspace-btn{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--gufa-border);background:var(--gufa-layer2);
|
|
1250
|
+
color:var(--gufa-text-dim);border-radius:7px;padding:2px 8px;font:inherit;font-size:11.5px;cursor:pointer;max-width:260px}
|
|
1251
|
+
.gufa-session-workspace-btn:hover{background:var(--gufa-hover);color:var(--gufa-text)}
|
|
1252
|
+
.gufa-session-workspace-btn span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1253
|
+
.gufa-session-workspace-picker{display:flex;flex-direction:column;gap:2px;padding:6px 10px;max-height:220px;overflow:auto;
|
|
1254
|
+
border-top:1px solid var(--gufa-border);border-bottom:1px solid var(--gufa-border);background:var(--gufa-layer)}
|
|
1255
|
+
.gufa-session-workspace-option{display:flex;align-items:center;gap:8px;width:100%;padding:6px 8px;border:0;border-radius:7px;
|
|
1256
|
+
background:transparent;color:var(--gufa-text);font:inherit;font-size:12px;cursor:pointer;text-align:left}
|
|
1257
|
+
.gufa-session-workspace-option:hover{background:var(--gufa-hover)}
|
|
1258
|
+
.gufa-session-workspace-option[data-current]{background:var(--gufa-active)}
|
|
1259
|
+
.gufa-session-workspace-option-title{flex:0 0 auto;font-weight:550}
|
|
1260
|
+
.gufa-session-workspace-option-path{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
|
|
1261
|
+
color:var(--gufa-text-dim);font-size:10.5px;text-align:right}
|
|
1210
1262
|
.gufa-session-workspace{font-size:11px;color:var(--gufa-text-dim);max-width:40%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1211
1263
|
.gufa-session-row-title{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis}
|
|
1212
1264
|
.gufa-session-row-when{flex:0 0 auto;font-size:10.5px;color:var(--gufa-solid-text-dim, var(--dsw-alias-label-secondary));font-variant-numeric:tabular-nums}
|
package/src/client/90-app.js
CHANGED
|
@@ -155,6 +155,9 @@ G.GufaApp = function GufaApp(props) {
|
|
|
155
155
|
const sessionTitle = useSessions !== undefined ? useSessions(selectSessionTitle) : null
|
|
156
156
|
const currentSessionId = useSessions !== undefined ? useSessions(selectMainSessionId) : null
|
|
157
157
|
const [sessionsOpen, setSessionsOpen] = useState(false)
|
|
158
|
+
/* 会话弹窗里选中的工作区(null = 跟随当前 IDE 项目) */
|
|
159
|
+
const [sessionWorkspacePath, setSessionWorkspacePath] = useState(null)
|
|
160
|
+
const [sessionWorkspacePicker, setSessionWorkspacePicker] = useState(false)
|
|
158
161
|
const recentSessionsJson = useSessions !== undefined ? useSessions(selectRecentSessionsJson) : '[]'
|
|
159
162
|
const recentSessionsRaw = useMemo(() => {
|
|
160
163
|
let parsed
|
|
@@ -1182,7 +1185,14 @@ G.GufaApp = function GufaApp(props) {
|
|
|
1182
1185
|
setRecentCurrentIds((current) => (current.includes(currentSessionId) ? current : [currentSessionId, ...current].slice(0, 12)))
|
|
1183
1186
|
}, [currentSessionId])
|
|
1184
1187
|
|
|
1185
|
-
|
|
1188
|
+
useEffect(() => {
|
|
1189
|
+
if (sessionsOpen === true) return undefined
|
|
1190
|
+
setSessionWorkspacePath(null)
|
|
1191
|
+
setSessionWorkspacePicker(false)
|
|
1192
|
+
return undefined
|
|
1193
|
+
}, [sessionsOpen])
|
|
1194
|
+
|
|
1195
|
+
/* 切换会话弹窗:打开时向 Host 拉取「弹窗里选中工作区的会话」(经典侧边栏同源数据) */
|
|
1186
1196
|
useEffect(() => {
|
|
1187
1197
|
if (sessionsOpen !== true) return undefined
|
|
1188
1198
|
if (project === null || typeof project.root !== 'string' || project.root === '') {
|
|
@@ -1190,10 +1200,11 @@ G.GufaApp = function GufaApp(props) {
|
|
|
1190
1200
|
return undefined
|
|
1191
1201
|
}
|
|
1192
1202
|
let cancelled = false
|
|
1203
|
+
const dialogPath = sessionWorkspacePath !== null && sessionWorkspacePath !== '' ? sessionWorkspacePath : project.root
|
|
1193
1204
|
setWorkspaceSessions({ status: 'loading', sessions: [], groups: [] })
|
|
1194
1205
|
void Promise.all([
|
|
1195
1206
|
G.api('workspaces.list', {}).catch(() => ({ workspaces: [] })),
|
|
1196
|
-
G.api('workspaces.sessions', { path:
|
|
1207
|
+
G.api('workspaces.sessions', { path: dialogPath, currentSessionId: currentSessionId ?? '' }).catch(() => ({ groups: [] })),
|
|
1197
1208
|
])
|
|
1198
1209
|
.then(([listValue, sessionsValue]) => {
|
|
1199
1210
|
if (cancelled) return
|
|
@@ -1207,7 +1218,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
1207
1218
|
} catch {
|
|
1208
1219
|
/* ignore */
|
|
1209
1220
|
}
|
|
1210
|
-
const firstGroup = groups.find((group) => group.path ===
|
|
1221
|
+
const firstGroup = groups.find((group) => group.path === dialogPath) ?? groups[0]
|
|
1211
1222
|
setWorkspaceSessions((previous) => {
|
|
1212
1223
|
const nextSessions = Array.isArray(sessionsValue?.sessions)
|
|
1213
1224
|
? sessionsValue.sessions
|
|
@@ -1234,7 +1245,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
1234
1245
|
return () => {
|
|
1235
1246
|
cancelled = true
|
|
1236
1247
|
}
|
|
1237
|
-
}, [sessionsOpen, project?.root, currentSessionId])
|
|
1248
|
+
}, [sessionsOpen, project?.root, currentSessionId, sessionWorkspacePath])
|
|
1238
1249
|
|
|
1239
1250
|
/* ── 退出(关闭覆盖层,回到 DSH 界面) ─────────────────────────────── */
|
|
1240
1251
|
const exitMode = useCallback(() => {
|
|
@@ -1308,6 +1319,60 @@ G.GufaApp = function GufaApp(props) {
|
|
|
1308
1319
|
}
|
|
1309
1320
|
}, [])
|
|
1310
1321
|
|
|
1322
|
+
/* 从会话弹窗打开会话:可同时切换到该会话所属工作区的项目 */
|
|
1323
|
+
const openSessionInWorkspace = useCallback((sessionId, workspacePath) => {
|
|
1324
|
+
projectPinnedRef.current = false
|
|
1325
|
+
const service = workspaceService()
|
|
1326
|
+
const path = typeof workspacePath === 'string' ? workspacePath : ''
|
|
1327
|
+
void (async () => {
|
|
1328
|
+
try {
|
|
1329
|
+
if (service !== undefined && service !== null && typeof service.openSession === 'function') service.openSession(sessionId)
|
|
1330
|
+
else setBanner('当前界面不支持切换会话')
|
|
1331
|
+
} catch (error) {
|
|
1332
|
+
setBanner(G.errorText(error))
|
|
1333
|
+
}
|
|
1334
|
+
if (path !== '' && project !== null && project.root !== path) {
|
|
1335
|
+
try {
|
|
1336
|
+
await openProjectPath(path)
|
|
1337
|
+
setBanner('')
|
|
1338
|
+
} catch (error) {
|
|
1339
|
+
setBanner(G.errorText(error))
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
})()
|
|
1343
|
+
}, [project, openProjectPath])
|
|
1344
|
+
|
|
1345
|
+
/* 从会话弹窗新建会话:在弹窗选中的工作区里新建,并切换 IDE 项目 */
|
|
1346
|
+
const startNewSessionInWorkspace = useCallback((workspacePath) => {
|
|
1347
|
+
projectPinnedRef.current = false
|
|
1348
|
+
const service = workspaceService()
|
|
1349
|
+
const path = typeof workspacePath === 'string' ? workspacePath : ''
|
|
1350
|
+
void (async () => {
|
|
1351
|
+
let workspaceId = null
|
|
1352
|
+
try {
|
|
1353
|
+
const value = await G.api('workspaces.list', {})
|
|
1354
|
+
const list = Array.isArray(value?.workspaces) ? value.workspaces : []
|
|
1355
|
+
const matched = list.find((item) => item !== null && item.path === path)
|
|
1356
|
+
if (matched !== undefined && typeof matched.id === 'string') workspaceId = matched.id
|
|
1357
|
+
} catch {
|
|
1358
|
+
workspaceId = null
|
|
1359
|
+
}
|
|
1360
|
+
try {
|
|
1361
|
+
if (service !== undefined && service !== null && typeof service.startSession === 'function') {
|
|
1362
|
+
if (workspaceId !== null) service.startSession(workspaceId)
|
|
1363
|
+
else service.startSession()
|
|
1364
|
+
} else {
|
|
1365
|
+
setBanner('当前界面不支持新建会话')
|
|
1366
|
+
return
|
|
1367
|
+
}
|
|
1368
|
+
if (path !== '' && project !== null && project.root !== path) await openProjectPath(path)
|
|
1369
|
+
setBanner('')
|
|
1370
|
+
} catch (error) {
|
|
1371
|
+
setBanner(G.errorText(error))
|
|
1372
|
+
}
|
|
1373
|
+
})()
|
|
1374
|
+
}, [project, openProjectPath])
|
|
1375
|
+
|
|
1311
1376
|
const activeFileForChat = useMemo(() => {
|
|
1312
1377
|
if (activeTab === null || activeTab.kind === 'diff' || activeTab.kind === 'graph') return null
|
|
1313
1378
|
return { path: activeTab.path, content: activeTab.content ?? '', language: activeTab.language }
|
|
@@ -2051,7 +2116,13 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2051
2116
|
const currentRoot = project !== null && typeof project.root === 'string' ? project.root : ''
|
|
2052
2117
|
const currentWorkspace = workspaceIndex.find((item) => item !== null && item.path === currentRoot)
|
|
2053
2118
|
const currentWorkspaceId = currentWorkspace !== undefined && typeof currentWorkspace.id === 'string' ? currentWorkspace.id : ''
|
|
2054
|
-
const
|
|
2119
|
+
const dialogPath = sessionWorkspacePath !== null && sessionWorkspacePath !== '' ? sessionWorkspacePath : currentRoot
|
|
2120
|
+
const dialogWorkspace = workspaceIndex.find((item) => item !== null && item.path === dialogPath)
|
|
2121
|
+
const dialogWorkspaceId = dialogWorkspace !== undefined && typeof dialogWorkspace.id === 'string' ? dialogWorkspace.id : ''
|
|
2122
|
+
const dialogWorkspaceTitle = dialogWorkspace !== undefined && typeof dialogWorkspace.title === 'string' && dialogWorkspace.title !== ''
|
|
2123
|
+
? dialogWorkspace.title
|
|
2124
|
+
: dialogPath !== '' ? G.basename(dialogPath) : ''
|
|
2125
|
+
const hostGroup = hostGroups.find((group) => (dialogWorkspaceId !== '' ? group.workspaceId === dialogWorkspaceId : group.path === dialogPath))
|
|
2055
2126
|
const localTitleById = new Map(
|
|
2056
2127
|
recentSessionsRaw.filter((row) => row !== null && typeof row === 'object' && typeof row.id === 'string').map((row) => [row.id, row.title]),
|
|
2057
2128
|
)
|
|
@@ -2113,7 +2184,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2113
2184
|
if (fromStore !== undefined && fromStore.blank === true) continue
|
|
2114
2185
|
// 只保留属于当前工作区的会话(切换工作区后不要带出旧工作区的会话)
|
|
2115
2186
|
if (fromStore !== undefined && typeof fromStore.workspaceId === 'string' && fromStore.workspaceId !== '' && workspaceSessions.workspaceId !== undefined && workspaceSessions.workspaceId !== '' && fromStore.workspaceId !== workspaceSessions.workspaceId) continue
|
|
2116
|
-
if (fromStore !== undefined && typeof fromStore.cwd === 'string' && fromStore.cwd !== '' &&
|
|
2187
|
+
if (fromStore !== undefined && typeof fromStore.cwd === 'string' && fromStore.cwd !== '' && dialogPath !== '' && fromStore.cwd !== dialogPath) continue
|
|
2117
2188
|
const title = localTitleById.get(id) ?? (fromStore !== undefined ? fromStore.title : '')
|
|
2118
2189
|
if (typeof title !== 'string' || title === '') continue
|
|
2119
2190
|
retained.push({ id, title, when: localWhenById.get(id) ?? (fromStore !== undefined ? fromStore.when : Date.now()) })
|
|
@@ -2144,7 +2215,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2144
2215
|
title: session.title,
|
|
2145
2216
|
onClick: () => {
|
|
2146
2217
|
close()
|
|
2147
|
-
|
|
2218
|
+
openSessionInWorkspace(session.id, dialogPath)
|
|
2148
2219
|
},
|
|
2149
2220
|
},
|
|
2150
2221
|
h(G.Icon, { name: 'message', size: 14 }),
|
|
@@ -2174,9 +2245,49 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2174
2245
|
{ className: 'gufa-modal-head' },
|
|
2175
2246
|
h(G.Icon, { name: 'history', size: 14 }),
|
|
2176
2247
|
h('span', { style: { flex: '1 1 auto' } }, t('dock.sessionsTitle')),
|
|
2177
|
-
project !== null
|
|
2248
|
+
project !== null
|
|
2249
|
+
? h(
|
|
2250
|
+
'button',
|
|
2251
|
+
{
|
|
2252
|
+
type: 'button',
|
|
2253
|
+
className: 'gufa-session-workspace gufa-session-workspace-btn',
|
|
2254
|
+
title: '选择工作区(下方会话列表随之切换)',
|
|
2255
|
+
onClick: () => setSessionWorkspacePicker((value) => !value),
|
|
2256
|
+
},
|
|
2257
|
+
h(G.Icon, { name: 'folder-open', size: 12 }),
|
|
2258
|
+
h('span', null, dialogWorkspaceTitle !== '' ? dialogWorkspaceTitle : project.name),
|
|
2259
|
+
h(G.Icon, { name: sessionWorkspacePicker ? 'chevron-up' : 'chevron-down', size: 12 }),
|
|
2260
|
+
)
|
|
2261
|
+
: null,
|
|
2178
2262
|
h(G.IconButton, { className: 'gufa-modal-close', title: t('common.close'), onClick: close }, h(G.Icon, { name: 'close', size: 14 })),
|
|
2179
2263
|
),
|
|
2264
|
+
sessionWorkspacePicker
|
|
2265
|
+
? h(
|
|
2266
|
+
'div',
|
|
2267
|
+
{ className: 'gufa-session-workspace-picker gufa-scroll' },
|
|
2268
|
+
workspaceIndex.length === 0
|
|
2269
|
+
? h('div', { className: 'gufa-hint', style: { padding: '8px 12px' } }, t('workspace.empty'))
|
|
2270
|
+
: workspaceIndex.map((workspace) =>
|
|
2271
|
+
h(
|
|
2272
|
+
'button',
|
|
2273
|
+
{
|
|
2274
|
+
key: workspace.id,
|
|
2275
|
+
type: 'button',
|
|
2276
|
+
className: 'gufa-session-workspace-option',
|
|
2277
|
+
'data-current': dialogPath === workspace.path ? '' : undefined,
|
|
2278
|
+
title: workspace.path,
|
|
2279
|
+
onClick: () => {
|
|
2280
|
+
setSessionWorkspacePath(workspace.path)
|
|
2281
|
+
setSessionWorkspacePicker(false)
|
|
2282
|
+
},
|
|
2283
|
+
},
|
|
2284
|
+
h(G.Icon, { name: 'folder-open', size: 13 }),
|
|
2285
|
+
h('span', { className: 'gufa-session-workspace-option-title' }, workspace.title !== '' ? workspace.title : G.basename(workspace.path)),
|
|
2286
|
+
h('span', { className: 'gufa-session-workspace-option-path' }, workspace.path),
|
|
2287
|
+
),
|
|
2288
|
+
),
|
|
2289
|
+
)
|
|
2290
|
+
: null,
|
|
2180
2291
|
h(
|
|
2181
2292
|
'div',
|
|
2182
2293
|
{ className: 'gufa-modal-body' },
|
|
@@ -2189,7 +2300,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2189
2300
|
h(
|
|
2190
2301
|
'div',
|
|
2191
2302
|
{ className: 'gufa-modal-foot' },
|
|
2192
|
-
h(G.Button, { icon: 'plus', onClick: () => { close();
|
|
2303
|
+
h(G.Button, { icon: 'plus', onClick: () => { close(); startNewSessionInWorkspace(dialogPath) } }, t('dock.newSession')),
|
|
2193
2304
|
h(G.Button, { onClick: close }, t('common.close')),
|
|
2194
2305
|
),
|
|
2195
2306
|
),
|