@ququ-jiaxk/dsh-groupchat 0.1.7 → 0.1.9
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/client.js +692 -251
- package/docs/DESIGN.md +1 -1
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dsh-groupchat · Client half (MVP)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 入口:左侧栏顶部「会话 / 群聊」两个 tab(全局,任何会话都可见);
|
|
5
|
+
* 会话模式下插件列表(插件/WorkBuddy…)上方还有一条「+ 新会话」。
|
|
6
|
+
* 群聊模式下左栏的「工作区 / 会话」列表让位给群聊列表(注入原生侧栏渲染),
|
|
7
|
+
* 切回会话时原生工作区列表自动恢复,并点回进群聊前的那个会话。
|
|
5
8
|
* 数据通过 fetch('/groupchat/api/...') 从 Host 拉取(对齐 ops-board 的已验证通道)。
|
|
6
9
|
*
|
|
7
|
-
*
|
|
8
|
-
* -
|
|
10
|
+
* 主面板三层:
|
|
11
|
+
* - 欢迎页:没选中群时的入口(新建群聊 / 花名册)
|
|
9
12
|
* - 群详情:消息流 + 发消息 + 让项目经理汇报 + 解散群
|
|
10
13
|
* - 新建群对话框:群名/描述/初始任务/项目经理会话(留空=自动创建)/成员会话列表
|
|
11
14
|
*/
|
|
@@ -15,6 +18,13 @@ window.__ModuleLoader__.load({
|
|
|
15
18
|
const React = require('react')
|
|
16
19
|
const { useState, useEffect, useCallback, useRef } = React
|
|
17
20
|
const h = React.createElement
|
|
21
|
+
// 左栏群聊列表要挂进 DSH 原生侧栏的 DOM,需要一个独立的 React 根。
|
|
22
|
+
// react-dom/client 由宿主平台模块表提供;取不到就放弃注入(主面板不受影响)。
|
|
23
|
+
const ReactDOMClient = (() => {
|
|
24
|
+
try { return require('react-dom/client') } catch (_e) {
|
|
25
|
+
try { return require('react-dom') } catch (_e2) { return null }
|
|
26
|
+
}
|
|
27
|
+
})()
|
|
18
28
|
|
|
19
29
|
const PANEL_ID = 'groupchat'
|
|
20
30
|
const API = '/groupchat/api'
|
|
@@ -281,6 +291,8 @@ window.__ModuleLoader__.load({
|
|
|
281
291
|
|
|
282
292
|
// ---- 当前会话 id(建群时记录创建者) ----
|
|
283
293
|
const sessionsRef = { current: null }
|
|
294
|
+
// 进群聊前正在看的会话:群聊模式下工作区列表被替换,返回会话时用它点回原会话
|
|
295
|
+
const lastMainSessionRef = { current: null }
|
|
284
296
|
// ---- layout 服务(全局 toast 跳转到群聊面板用) ----
|
|
285
297
|
const layoutRef = { current: null }
|
|
286
298
|
function getCurrentSessionId() {
|
|
@@ -426,6 +438,26 @@ window.__ModuleLoader__.load({
|
|
|
426
438
|
}
|
|
427
439
|
})()
|
|
428
440
|
|
|
441
|
+
// ---- 插件是否仍然启用(宿主接口还活着) ----
|
|
442
|
+
// 生产包里停用插件时客户端 bundle 不一定立刻被 dispose;
|
|
443
|
+
// 靠轮询 /state 的 404 判定「宿主半边已停用」,主动拆掉注入的 UI 和样式。
|
|
444
|
+
const pluginAliveStore = (() => {
|
|
445
|
+
let value = true
|
|
446
|
+
const listeners = new Set()
|
|
447
|
+
return {
|
|
448
|
+
get: () => value,
|
|
449
|
+
set: (next) => {
|
|
450
|
+
if (next === value) return
|
|
451
|
+
value = next
|
|
452
|
+
for (const l of listeners) l()
|
|
453
|
+
},
|
|
454
|
+
subscribe: (listener) => {
|
|
455
|
+
listeners.add(listener)
|
|
456
|
+
return () => listeners.delete(listener)
|
|
457
|
+
},
|
|
458
|
+
}
|
|
459
|
+
})()
|
|
460
|
+
|
|
429
461
|
// ---- 面板记忆(跨卸载保留 UI 状态) ----
|
|
430
462
|
// 用户切到别的界面/会话时 GroupchatPanel 会卸载,React state 全部丢失,
|
|
431
463
|
// 再回来就"重新加载"(回到列表、草稿没了、滚动回顶部)。
|
|
@@ -438,6 +470,25 @@ window.__ModuleLoader__.load({
|
|
|
438
470
|
statusMenuFor: null,
|
|
439
471
|
}
|
|
440
472
|
|
|
473
|
+
// ---- 当前群聊面板视图(左栏列表用来高亮「正在看的群 / 花名册」) ----
|
|
474
|
+
// 面板内部 state 卸载即丢失,这里单独存一份给侧栏订阅。
|
|
475
|
+
const panelViewStore = (() => {
|
|
476
|
+
let value = panelMemo.view || 'list'
|
|
477
|
+
const listeners = new Set()
|
|
478
|
+
return {
|
|
479
|
+
get: () => value,
|
|
480
|
+
set: (next) => {
|
|
481
|
+
if (next === value) return
|
|
482
|
+
value = next
|
|
483
|
+
for (const l of listeners) l()
|
|
484
|
+
},
|
|
485
|
+
subscribe: (listener) => {
|
|
486
|
+
listeners.add(listener)
|
|
487
|
+
return () => listeners.delete(listener)
|
|
488
|
+
},
|
|
489
|
+
}
|
|
490
|
+
})()
|
|
491
|
+
|
|
441
492
|
// ---- 当前正在查看的群(用于抑制该群的 toast 通知) ----
|
|
442
493
|
// 用户在群里看消息时,新消息已经在眼前了,再弹「XX 说…」纯属噪音。
|
|
443
494
|
const viewingGroupStore = (() => {
|
|
@@ -457,20 +508,21 @@ window.__ModuleLoader__.load({
|
|
|
457
508
|
}
|
|
458
509
|
})()
|
|
459
510
|
|
|
460
|
-
// ---- 面板导航 store(全局 toast
|
|
511
|
+
// ---- 面板导航 store(全局 toast / 左栏列表 跳转用) ----
|
|
512
|
+
// target 可以是群 id,也可以是 'roster' / 'create' / 'list' 这类视图名。
|
|
461
513
|
const panelNavStore = (() => {
|
|
462
|
-
let
|
|
463
|
-
let
|
|
514
|
+
let openViewHandler = null
|
|
515
|
+
let pendingView = null
|
|
464
516
|
return {
|
|
465
|
-
// 由 GroupchatPanel 注册:负责把 view
|
|
466
|
-
registerOpener: (fn) => {
|
|
467
|
-
//
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
// 面板还没挂载时,选中群聊主面板会让它挂载,挂载后消费
|
|
471
|
-
if (typeof
|
|
472
|
-
|
|
473
|
-
|
|
517
|
+
// 由 GroupchatPanel 注册:负责把 view 切到目标视图
|
|
518
|
+
registerOpener: (fn) => { openViewHandler = fn },
|
|
519
|
+
// 跳转到某个视图:先切到群聊主面板,再让面板打开对应视图
|
|
520
|
+
requestView: (target) => {
|
|
521
|
+
pendingView = target
|
|
522
|
+
// 面板还没挂载时,选中群聊主面板会让它挂载,挂载后消费 pendingView
|
|
523
|
+
if (typeof openViewHandler === 'function') {
|
|
524
|
+
openViewHandler(target)
|
|
525
|
+
pendingView = null
|
|
474
526
|
return
|
|
475
527
|
}
|
|
476
528
|
try {
|
|
@@ -479,11 +531,15 @@ window.__ModuleLoader__.load({
|
|
|
479
531
|
}
|
|
480
532
|
} catch (_e) { /* 主面板未注册时忽略 */ }
|
|
481
533
|
},
|
|
482
|
-
//
|
|
534
|
+
// 兼容旧调用:跳转到某个群
|
|
535
|
+
request: (groupId) => {
|
|
536
|
+
panelNavStore.requestView(groupId)
|
|
537
|
+
},
|
|
538
|
+
// GroupchatPanel 挂载时调用:消费挂起的视图
|
|
483
539
|
consume: () => {
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
return
|
|
540
|
+
const target = pendingView
|
|
541
|
+
pendingView = null
|
|
542
|
+
return target
|
|
487
543
|
},
|
|
488
544
|
}
|
|
489
545
|
})()
|
|
@@ -521,12 +577,18 @@ window.__ModuleLoader__.load({
|
|
|
521
577
|
async function api(path, options) {
|
|
522
578
|
const res = await fetch(API + path, options)
|
|
523
579
|
const json = await res.json().catch(() => ({}))
|
|
524
|
-
if (!res.ok)
|
|
580
|
+
if (!res.ok) {
|
|
581
|
+
const error = new Error(json.error || ('HTTP ' + res.status))
|
|
582
|
+
error.status = res.status
|
|
583
|
+
throw error
|
|
584
|
+
}
|
|
525
585
|
return json
|
|
526
586
|
}
|
|
527
587
|
|
|
528
588
|
// ---- 全局轮询:无论是否打开群聊面板,都拉增量并弹 toast / 更新角标 ----
|
|
529
589
|
const globalLastTsRef = { current: 0 }
|
|
590
|
+
let groupchatStyleEl = null
|
|
591
|
+
let hostGoneCount = 0
|
|
530
592
|
|
|
531
593
|
// 按群聚合新消息并弹全局 toast(供全局轮询复用)
|
|
532
594
|
function fireToastForNewMessages(newMsgs, groups) {
|
|
@@ -588,7 +650,15 @@ window.__ModuleLoader__.load({
|
|
|
588
650
|
unreadStore.set(totalUnread)
|
|
589
651
|
// 把整个 state 推给面板,让 agent 状态实时更新(不依赖面板自己的轮询)
|
|
590
652
|
if (st.groups) stateStore.set(st, r.delta === true)
|
|
591
|
-
|
|
653
|
+
hostGoneCount = 0
|
|
654
|
+
if (!pluginAliveStore.get()) recoverPluginUi()
|
|
655
|
+
} catch (e) {
|
|
656
|
+
// 宿主接口 404 = 插件在宿主侧已被停用/卸载;连续 3 次才动手,避开重启抖动
|
|
657
|
+
if (e && e.status === 404) {
|
|
658
|
+
hostGoneCount += 1
|
|
659
|
+
if (hostGoneCount >= 3) handleHostDisabled()
|
|
660
|
+
}
|
|
661
|
+
}
|
|
592
662
|
}
|
|
593
663
|
|
|
594
664
|
// ---- 小工具 ----
|
|
@@ -882,7 +952,7 @@ window.__ModuleLoader__.load({
|
|
|
882
952
|
color: T.text, font: "14px/1.6 -apple-system, PingFang SC, 'Segoe UI', sans-serif",
|
|
883
953
|
background: T.bg, ...style,
|
|
884
954
|
},
|
|
885
|
-
}, children)
|
|
955
|
+
}, ...children)
|
|
886
956
|
|
|
887
957
|
const btn = (text, onClick, kind, size) => h('button', {
|
|
888
958
|
onClick,
|
|
@@ -1128,10 +1198,50 @@ window.__ModuleLoader__.load({
|
|
|
1128
1198
|
}, avatar(m.name, m.role, size, m.agentState, m.avatar || null)))
|
|
1129
1199
|
)
|
|
1130
1200
|
|
|
1201
|
+
// ---- 群聊欢迎页(没选中群时的主区域) ----
|
|
1202
|
+
// 群列表在左栏常驻,这里只负责「进来先看到什么」,并给出新建群 / 花名册入口。
|
|
1203
|
+
function GroupchatWelcome({ lang, btn, setView, groups, loading }) {
|
|
1204
|
+
const hasGroups = (groups || []).length > 0
|
|
1205
|
+
return h('div', {
|
|
1206
|
+
'data-gc-welcome': '',
|
|
1207
|
+
style: {
|
|
1208
|
+
flex: 1, minHeight: 0, display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
1209
|
+
padding: 40, background: T.bg,
|
|
1210
|
+
},
|
|
1211
|
+
},
|
|
1212
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', textAlign: 'center', maxWidth: 460 } },
|
|
1213
|
+
h('div', {
|
|
1214
|
+
style: {
|
|
1215
|
+
width: 64, height: 64, borderRadius: 20, background: T.accentSoft, color: T.accent,
|
|
1216
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center', marginBottom: 16,
|
|
1217
|
+
},
|
|
1218
|
+
},
|
|
1219
|
+
h('svg', { width: 30, height: 30, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round', strokeLinejoin: 'round' },
|
|
1220
|
+
h('path', { d: 'M4 6.5A2.5 2.5 0 0 1 6.5 4h7A2.5 2.5 0 0 1 16 6.5v4A2.5 2.5 0 0 1 13.5 13H9l-3.2 2.6A.8.8 0 0 1 4.5 15v-2.2A2.5 2.5 0 0 1 4 11.2z' }),
|
|
1221
|
+
h('path', { d: 'M17 9h.5A2.5 2.5 0 0 1 20 11.5v3.3a2.5 2.5 0 0 1-.5 1.5V18l-3-2h-3' }),
|
|
1222
|
+
),
|
|
1223
|
+
),
|
|
1224
|
+
h('div', { style: { fontSize: 18, fontWeight: 600, letterSpacing: '-0.2px', marginBottom: 8 } }, lang.panel),
|
|
1225
|
+
h('div', { style: { fontSize: 13, color: T.textMuted, lineHeight: 1.7, marginBottom: 18 } },
|
|
1226
|
+
loading
|
|
1227
|
+
? lang.loading
|
|
1228
|
+
: hasGroups
|
|
1229
|
+
? '从左侧选择一个群聊,查看消息和任务看板。'
|
|
1230
|
+
: '还没有群聊。新建一个群,把智能体拉进来一起干活。'),
|
|
1231
|
+
h('div', { style: { display: 'flex', gap: 10, alignItems: 'center' } },
|
|
1232
|
+
btn(lang.newGroup, () => setView('create')),
|
|
1233
|
+
btn(lang.roster, () => setView('roster'), 'ghost'),
|
|
1234
|
+
),
|
|
1235
|
+
),
|
|
1236
|
+
)
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1131
1239
|
// ---- 主面板 ----
|
|
1132
1240
|
function GroupchatPanel() {
|
|
1133
1241
|
// 挂载 = 群聊面板被选中(DSH 的 main 插槽只挂载当前面板),用于侧栏入口高亮
|
|
1134
1242
|
useEffect(() => {
|
|
1243
|
+
// 切面板本身不会释放 mainView 引用,所以这里拿到的仍是刚离开的那个会话
|
|
1244
|
+
lastMainSessionRef.current = getCurrentSessionId()
|
|
1135
1245
|
panelActiveStore.set(true)
|
|
1136
1246
|
return () => panelActiveStore.set(false)
|
|
1137
1247
|
}, [])
|
|
@@ -1142,6 +1252,7 @@ window.__ModuleLoader__.load({
|
|
|
1142
1252
|
const [view, setViewRaw] = useState(() => panelMemo.view || 'list') // 'list' | 'create' | 'roster' | 'createProfile' | groupId
|
|
1143
1253
|
const setView = useCallback((next) => {
|
|
1144
1254
|
panelMemo.view = next
|
|
1255
|
+
panelViewStore.set(next)
|
|
1145
1256
|
setViewRaw(next)
|
|
1146
1257
|
}, [])
|
|
1147
1258
|
const [error, setError] = useState(null)
|
|
@@ -1165,9 +1276,10 @@ window.__ModuleLoader__.load({
|
|
|
1165
1276
|
}
|
|
1166
1277
|
}, [])
|
|
1167
1278
|
|
|
1168
|
-
//
|
|
1279
|
+
// 注册视图切换入口(全局 toast / 左栏群聊列表都用它),并消费挂起的视图
|
|
1169
1280
|
useEffect(() => {
|
|
1170
|
-
panelNavStore.registerOpener((
|
|
1281
|
+
panelNavStore.registerOpener((target) => setView(target))
|
|
1282
|
+
panelViewStore.set(panelMemo.view || 'list')
|
|
1171
1283
|
const pending = panelNavStore.consume()
|
|
1172
1284
|
if (pending) setView(pending)
|
|
1173
1285
|
return () => panelNavStore.registerOpener(null)
|
|
@@ -1179,6 +1291,10 @@ window.__ModuleLoader__.load({
|
|
|
1179
1291
|
try { await fn() } catch (e) { setError(e.message || '操作失败') } finally { setBusy(false) }
|
|
1180
1292
|
}, [busy])
|
|
1181
1293
|
|
|
1294
|
+
// 宿主侧停用后不渲染(handleHostDisabled 通常已经切回会话,这里是兜底)
|
|
1295
|
+
const alive = useStoreValue(pluginAliveStore)
|
|
1296
|
+
if (!alive) return null
|
|
1297
|
+
|
|
1182
1298
|
// ---- 空态 ----
|
|
1183
1299
|
if (error && !state) {
|
|
1184
1300
|
return wrap({ alignItems: 'center', justifyContent: 'center', padding: 40 },
|
|
@@ -1198,153 +1314,12 @@ window.__ModuleLoader__.load({
|
|
|
1198
1314
|
if (g) return h(GroupDetail, { lang, input, btn, act, api, wrap, drawer, state, group: g, setView, onChanged: () => reload() })
|
|
1199
1315
|
}
|
|
1200
1316
|
|
|
1201
|
-
// ----
|
|
1317
|
+
// ---- 欢迎页 ----
|
|
1318
|
+
// 群列表已经移到左侧栏(SidebarGroupList),主区域只显示「选中的群」详情;
|
|
1319
|
+
// 没选群时给一个入口页,避免同一份列表在左右两边重复出现。
|
|
1202
1320
|
const groups = (state && state.groups) || []
|
|
1203
1321
|
return wrap({ overflow: 'hidden' },
|
|
1204
|
-
|
|
1205
|
-
h('div', {
|
|
1206
|
-
style: {
|
|
1207
|
-
padding: '16px 20px', borderBottom: `1px solid ${T.border}`, background: T.card,
|
|
1208
|
-
display: 'flex', alignItems: 'center', justifyContent: 'space-between', flexShrink: 0,
|
|
1209
|
-
},
|
|
1210
|
-
},
|
|
1211
|
-
h('div', { style: { display: 'flex', gap: 20, alignItems: 'center' } },
|
|
1212
|
-
tabLink(lang.panel, view === 'list', () => setView('list')),
|
|
1213
|
-
tabLink(lang.roster, view === 'roster', () => setView('roster')),
|
|
1214
|
-
),
|
|
1215
|
-
h('div', { style: { display: 'flex', alignItems: 'center', gap: 10 } },
|
|
1216
|
-
h(VersionBadge, null),
|
|
1217
|
-
btn(lang.newGroup, () => setView('create')),
|
|
1218
|
-
),
|
|
1219
|
-
),
|
|
1220
|
-
// 群卡片列表
|
|
1221
|
-
h('div', { className: 'gc-fade', style: { flex: 1, overflow: 'auto', padding: '16px 20px' } },
|
|
1222
|
-
groups.length === 0
|
|
1223
|
-
? h('div', { style: { color: T.textMuted, padding: '40px 0', textAlign: 'center' } }, lang.empty)
|
|
1224
|
-
: groups.map((g, gi) => {
|
|
1225
|
-
// sAgent 的状态挂在 sAgentState,成员的挂在各自 agentState 上
|
|
1226
|
-
const members = [
|
|
1227
|
-
{ name: g.sAgentName, role: 'manager', agentState: g.sAgentState },
|
|
1228
|
-
...(g.members || []),
|
|
1229
|
-
]
|
|
1230
|
-
const status = g.task ? g.task.status : 'idle'
|
|
1231
|
-
const unread = g.unreadToUser || 0
|
|
1232
|
-
// 有 agent 正在干活(思考/写回复/跑工具/等响应)就亮出状态
|
|
1233
|
-
const busyMembers = members.filter(m => {
|
|
1234
|
-
const st = m.agentState && (m.agentState.state || m.agentState)
|
|
1235
|
-
return st && st !== 'idle' && st !== 'offline'
|
|
1236
|
-
})
|
|
1237
|
-
return h('div', {
|
|
1238
|
-
key: keyOf(g.id),
|
|
1239
|
-
onClick: () => setView(g.id),
|
|
1240
|
-
className: 'gc-card gc-in',
|
|
1241
|
-
style: {
|
|
1242
|
-
background: T.card, borderRadius: T.radius, boxShadow: T.shadow,
|
|
1243
|
-
padding: '16px 18px', marginBottom: 12, cursor: 'pointer',
|
|
1244
|
-
border: '1px solid transparent',
|
|
1245
|
-
position: 'relative',
|
|
1246
|
-
// 错峰入场:每张卡延后 45ms
|
|
1247
|
-
animationDelay: (Math.min(gi, 8) * 45) + 'ms',
|
|
1248
|
-
},
|
|
1249
|
-
onMouseEnter: (e) => { e.currentTarget.style.boxShadow = T.shadowHover },
|
|
1250
|
-
onMouseLeave: (e) => { e.currentTarget.style.boxShadow = T.shadow },
|
|
1251
|
-
},
|
|
1252
|
-
h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8 } },
|
|
1253
|
-
h('div', { style: { fontSize: 15, fontWeight: 600, letterSpacing: '-0.2px' } }, g.name),
|
|
1254
|
-
h('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } },
|
|
1255
|
-
unread > 0 ? h('span', {
|
|
1256
|
-
// key 跟着数字走:未读数一变就重挂载,触发 pop 动画
|
|
1257
|
-
key: 'unread-' + unread,
|
|
1258
|
-
className: 'gc-pop',
|
|
1259
|
-
style: {
|
|
1260
|
-
minWidth: 20, height: 20, borderRadius: '50%', background: T.danger, color: '#fff',
|
|
1261
|
-
fontSize: 11, fontWeight: 700, display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
1262
|
-
padding: '0 5px',
|
|
1263
|
-
},
|
|
1264
|
-
}, unread > 99 ? '99+' : unread) : null,
|
|
1265
|
-
badge(({
|
|
1266
|
-
idle: lang.taskIdle, doing: lang.taskDoing, blocked: lang.taskBlocked, done: lang.taskDone,
|
|
1267
|
-
})[status] || status, status),
|
|
1268
|
-
),
|
|
1269
|
-
),
|
|
1270
|
-
g.description ? h('div', { style: { fontSize: 12.5, color: T.textMuted, marginBottom: 8 } }, g.description) : null,
|
|
1271
|
-
// 最近一条消息预览(随 2 秒轮询实时更新)
|
|
1272
|
-
(() => {
|
|
1273
|
-
const all = (state && state.messages) || []
|
|
1274
|
-
let last = null
|
|
1275
|
-
for (const mm of all) {
|
|
1276
|
-
if (mm.groupId !== g.id) continue
|
|
1277
|
-
if (!last || mm.ts > last.ts) last = mm
|
|
1278
|
-
}
|
|
1279
|
-
if (!last) return null
|
|
1280
|
-
const body = String(last.content || '').replace(/\s+/g, ' ').trim()
|
|
1281
|
-
const isMine = last.authorRole === 'user'
|
|
1282
|
-
return h('div', {
|
|
1283
|
-
// key 跟消息 id 走:来了新消息就重挂载,闪一次背景提示更新
|
|
1284
|
-
key: 'preview-' + last.id,
|
|
1285
|
-
className: 'gc-flash',
|
|
1286
|
-
style: {
|
|
1287
|
-
fontSize: 12, marginBottom: 8, display: 'flex', gap: 4,
|
|
1288
|
-
overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis',
|
|
1289
|
-
color: T.textMuted, alignItems: 'baseline',
|
|
1290
|
-
borderRadius: 4, padding: '1px 3px', marginLeft: -3,
|
|
1291
|
-
},
|
|
1292
|
-
title: `${last.authorName}:${body}`,
|
|
1293
|
-
},
|
|
1294
|
-
h('span', { style: { color: isMine ? T.accent : T.text, fontWeight: 500, flexShrink: 0 } },
|
|
1295
|
-
`${last.authorName}:`),
|
|
1296
|
-
h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis' } }, body.slice(0, 80)),
|
|
1297
|
-
)
|
|
1298
|
-
})(),
|
|
1299
|
-
h('div', { style: { display: 'flex', alignItems: 'center', gap: 6, flexWrap: 'wrap' } },
|
|
1300
|
-
avatarStack(members, 22),
|
|
1301
|
-
h('span', { style: { fontSize: 12, color: T.textMuted } }, members.map(m => m.name).join('、')),
|
|
1302
|
-
// 正在干活的成员状态(思考中 / 写回复 / 执行工具 / 等待响应)
|
|
1303
|
-
busyMembers.length > 0
|
|
1304
|
-
? h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 6, marginLeft: 'auto' } },
|
|
1305
|
-
busyMembers.slice(0, 2).map((m, i) =>
|
|
1306
|
-
h('span', { key: i, style: { display: 'inline-flex', alignItems: 'center', gap: 4 } },
|
|
1307
|
-
h('span', { style: { fontSize: 11, color: T.textMuted } }, m.name),
|
|
1308
|
-
statePill(m.agentState),
|
|
1309
|
-
),
|
|
1310
|
-
),
|
|
1311
|
-
)
|
|
1312
|
-
: null,
|
|
1313
|
-
),
|
|
1314
|
-
// 当前进行中任务的轮播条(随任务状态实时更新,数据来自 2s 全局轮询)
|
|
1315
|
-
(() => {
|
|
1316
|
-
const subs = (g.task && g.task.subtasks) || []
|
|
1317
|
-
const doing = subs.find(x => x.status === 'doing')
|
|
1318
|
-
const blocked = subs.find(x => x.status === 'blocked')
|
|
1319
|
-
const current = blocked || doing
|
|
1320
|
-
if (!current) return null
|
|
1321
|
-
const isBlocked = current.status === 'blocked'
|
|
1322
|
-
const label = (isBlocked ? lang.taskBlocked : lang.taskDoing) + ' · ' + current.title
|
|
1323
|
-
return h('div', {
|
|
1324
|
-
style: {
|
|
1325
|
-
marginTop: 8, paddingTop: 8, borderTop: `1px dashed ${T.border}`,
|
|
1326
|
-
display: 'flex', alignItems: 'center', gap: 6, overflow: 'hidden',
|
|
1327
|
-
},
|
|
1328
|
-
title: label,
|
|
1329
|
-
},
|
|
1330
|
-
h('span', {
|
|
1331
|
-
style: {
|
|
1332
|
-
width: 7, height: 7, borderRadius: '50%', flexShrink: 0,
|
|
1333
|
-
background: isBlocked ? T.warn : T.primary,
|
|
1334
|
-
animation: 'groupchatPulse 1.2s ease-in-out infinite',
|
|
1335
|
-
},
|
|
1336
|
-
}),
|
|
1337
|
-
// 超长标题上下轮播(不再左右摆)
|
|
1338
|
-
h(VerticalTicker, { text: label, lineHeight: 18, visibleLines: 1, color: isBlocked ? T.warn : T.textMuted }),
|
|
1339
|
-
current.ownerName
|
|
1340
|
-
? h('span', { style: { fontSize: 11, color: T.accent, flexShrink: 0 } }, current.ownerName)
|
|
1341
|
-
: null,
|
|
1342
|
-
)
|
|
1343
|
-
})(),
|
|
1344
|
-
)
|
|
1345
|
-
}),
|
|
1346
|
-
),
|
|
1347
|
-
// 新建群抽屉
|
|
1322
|
+
h(GroupchatWelcome, { lang, btn, setView, groups, loading: !state }),
|
|
1348
1323
|
view === 'create' ? h(CreateGroup, { lang, input, btn, act, api, wrap, drawer, setView, state, onDone: (id) => { reload(); setView(id) } }) : null,
|
|
1349
1324
|
)
|
|
1350
1325
|
}
|
|
@@ -3471,19 +3446,444 @@ window.__ModuleLoader__.load({
|
|
|
3471
3446
|
)
|
|
3472
3447
|
}
|
|
3473
3448
|
|
|
3449
|
+
// ===== 左栏群聊列表 =====
|
|
3450
|
+
// 群聊模式下把原生「工作区 / 会话」列表让出来,在原位置渲染群聊列表;
|
|
3451
|
+
// 切回会话时 GroupchatPanel 卸载 → panelActiveStore=false → 原生列表恢复。
|
|
3452
|
+
// 实现方式:往 [data-sidebar-scrollport] 这个 grid 里追加一个与原生区域同格的容器,
|
|
3453
|
+
// 挂一个独立 React 根(这样面板卸载也不会带走列表)。
|
|
3454
|
+
const GC_SIDEBAR_ATTR = 'data-groupchat-sidebar'
|
|
3455
|
+
const GC_NATIVE_REGION_ATTR = 'data-groupchat-native-region'
|
|
3456
|
+
|
|
3457
|
+
function useStoreValue(store) {
|
|
3458
|
+
const [value, setValue] = useState(() => store.get())
|
|
3459
|
+
useEffect(() => {
|
|
3460
|
+
const unsubscribe = store.subscribe(() => setValue(store.get()))
|
|
3461
|
+
setValue(store.get())
|
|
3462
|
+
return unsubscribe
|
|
3463
|
+
}, [store])
|
|
3464
|
+
return value
|
|
3465
|
+
}
|
|
3466
|
+
|
|
3467
|
+
// 左栏时间显示:刚刚 / N 分钟 / N 小时 / N 天 / M-D
|
|
3468
|
+
function fmtSidebarTime(ts) {
|
|
3469
|
+
if (!ts) return ''
|
|
3470
|
+
const diff = Date.now() - ts
|
|
3471
|
+
if (diff < 60e3) return '刚刚'
|
|
3472
|
+
if (diff < 3600e3) return Math.floor(diff / 60e3) + ' 分钟'
|
|
3473
|
+
if (diff < 86400e3) return Math.floor(diff / 3600e3) + ' 小时'
|
|
3474
|
+
if (diff < 7 * 86400e3) return Math.floor(diff / 86400e3) + ' 天'
|
|
3475
|
+
const d = new Date(ts)
|
|
3476
|
+
return (d.getMonth() + 1) + '-' + d.getDate()
|
|
3477
|
+
}
|
|
3478
|
+
|
|
3479
|
+
// 左栏列表排序:最近有消息的排前面,其次按建群时间
|
|
3480
|
+
function groupIndex(state) {
|
|
3481
|
+
const groups = (state && state.groups) || []
|
|
3482
|
+
const messages = (state && state.messages) || []
|
|
3483
|
+
const lastBy = new Map()
|
|
3484
|
+
for (const m of messages) {
|
|
3485
|
+
const cur = lastBy.get(m.groupId)
|
|
3486
|
+
if (!cur || m.ts > cur.ts) lastBy.set(m.groupId, m)
|
|
3487
|
+
}
|
|
3488
|
+
return groups.map(g => ({ group: g, last: lastBy.get(g.id) || null }))
|
|
3489
|
+
.sort((a, b) => {
|
|
3490
|
+
const ta = a.last ? a.last.ts : (a.group.createdAt || 0)
|
|
3491
|
+
const tb = b.last ? b.last.ts : (b.group.createdAt || 0)
|
|
3492
|
+
if (tb !== ta) return tb - ta
|
|
3493
|
+
return String(a.group.name || '').localeCompare(String(b.group.name || ''), 'zh-Hans-CN')
|
|
3494
|
+
})
|
|
3495
|
+
}
|
|
3496
|
+
|
|
3497
|
+
function sidebarBtn(title, onClick, children) {
|
|
3498
|
+
return h('button', {
|
|
3499
|
+
type: 'button', title, 'aria-label': title, onClick,
|
|
3500
|
+
className: 'gc-side-icon',
|
|
3501
|
+
style: {
|
|
3502
|
+
width: 24, height: 24, flexShrink: 0, border: 'none', borderRadius: 6, padding: 0,
|
|
3503
|
+
background: 'transparent', color: 'var(--dsw-alias-label-secondary, #5B6470)',
|
|
3504
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer',
|
|
3505
|
+
},
|
|
3506
|
+
onMouseEnter: (e) => { e.currentTarget.style.background = 'var(--dsw-alias-interactive-bg-hover, rgba(16,41,66,0.08))' },
|
|
3507
|
+
onMouseLeave: (e) => { e.currentTarget.style.background = 'transparent' },
|
|
3508
|
+
}, children)
|
|
3509
|
+
}
|
|
3510
|
+
|
|
3511
|
+
// 群头像:用群名首字 + 按名字散列的颜色,避免所有群都是同一只 sAgent 头像
|
|
3512
|
+
const GC_GROUP_COLORS = ['#2E6BE6', '#764ba2', '#1E7D46', '#B7791F', '#C0392B', '#0F766E', '#7C3AED']
|
|
3513
|
+
function groupAvatar(group, size) {
|
|
3514
|
+
const name = String((group && group.name) || '?')
|
|
3515
|
+
let hash = 0
|
|
3516
|
+
for (let i = 0; i < name.length; i++) hash = (hash * 31 + name.charCodeAt(i)) >>> 0
|
|
3517
|
+
const bg = GC_GROUP_COLORS[hash % GC_GROUP_COLORS.length]
|
|
3518
|
+
const st = normalizeAgentState(group && group.sAgentState)
|
|
3519
|
+
const meta = st ? agentStateMeta(st.state) : null
|
|
3520
|
+
return h('div', {
|
|
3521
|
+
title: meta ? group.sAgentName + ':' + meta.label : group.sAgentName,
|
|
3522
|
+
style: {
|
|
3523
|
+
width: size, height: size, borderRadius: Math.round(size * 0.3), flexShrink: 0,
|
|
3524
|
+
background: bg, color: '#fff', fontSize: Math.round(size * 0.44), fontWeight: 600,
|
|
3525
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center', position: 'relative',
|
|
3526
|
+
boxShadow: '0 1px 3px rgba(16,41,66,0.12)', overflow: 'hidden',
|
|
3527
|
+
},
|
|
3528
|
+
},
|
|
3529
|
+
Array.from(name)[0] || '?',
|
|
3530
|
+
meta && meta.busy
|
|
3531
|
+
? h('span', {
|
|
3532
|
+
style: {
|
|
3533
|
+
position: 'absolute', right: 0, bottom: 0, width: Math.max(9, Math.round(size * 0.3)),
|
|
3534
|
+
height: Math.max(9, Math.round(size * 0.3)), borderRadius: '50%', background: meta.dot,
|
|
3535
|
+
border: '2px solid var(--dsw-specific-sidebar-fill, #F7F8FA)',
|
|
3536
|
+
animation: 'groupchatPulse 1.2s ease-in-out infinite',
|
|
3537
|
+
},
|
|
3538
|
+
})
|
|
3539
|
+
: null,
|
|
3540
|
+
)
|
|
3541
|
+
}
|
|
3542
|
+
|
|
3543
|
+
function SidebarGroupRow({ group, last, active, onClick }) {
|
|
3544
|
+
const unread = group.unreadToUser || 0
|
|
3545
|
+
const members = [
|
|
3546
|
+
{ name: group.sAgentName, role: 'manager', agentState: group.sAgentState },
|
|
3547
|
+
...(group.members || []),
|
|
3548
|
+
]
|
|
3549
|
+
const busy = members.find(m => {
|
|
3550
|
+
const st = m.agentState && (m.agentState.state || m.agentState)
|
|
3551
|
+
return st && st !== 'idle' && st !== 'offline'
|
|
3552
|
+
})
|
|
3553
|
+
const busyState = busy ? normalizeAgentState(busy.agentState) : null
|
|
3554
|
+
const busyMeta = busyState ? agentStateMeta(busyState.state) : null
|
|
3555
|
+
const preview = last
|
|
3556
|
+
? (last.authorName + ':' + String(last.content || '').replace(/\s+/g, ' ').trim())
|
|
3557
|
+
: (group.description || '还没有消息')
|
|
3558
|
+
return h('div', {
|
|
3559
|
+
role: 'button', tabIndex: 0,
|
|
3560
|
+
'aria-current': active ? 'page' : undefined,
|
|
3561
|
+
title: group.name,
|
|
3562
|
+
onClick,
|
|
3563
|
+
onKeyDown: (e) => {
|
|
3564
|
+
if (e.target !== e.currentTarget) return
|
|
3565
|
+
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onClick() }
|
|
3566
|
+
},
|
|
3567
|
+
className: 'gc-side-row',
|
|
3568
|
+
style: {
|
|
3569
|
+
display: 'flex', alignItems: 'center', gap: 9,
|
|
3570
|
+
margin: '0 6px 2px', padding: '7px 8px', borderRadius: 9,
|
|
3571
|
+
cursor: 'pointer', position: 'relative',
|
|
3572
|
+
background: active ? 'var(--dsw-alias-interactive-bg-hover, rgba(16,41,66,0.08))' : undefined,
|
|
3573
|
+
},
|
|
3574
|
+
},
|
|
3575
|
+
groupAvatar(group, 30),
|
|
3576
|
+
h('div', { style: { flex: 1, minWidth: 0 } },
|
|
3577
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 6 } },
|
|
3578
|
+
h('div', {
|
|
3579
|
+
style: {
|
|
3580
|
+
flex: 1, minWidth: 0, fontSize: 13, fontWeight: active ? 600 : 500, color: T.text,
|
|
3581
|
+
overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis', lineHeight: '18px',
|
|
3582
|
+
},
|
|
3583
|
+
}, group.name),
|
|
3584
|
+
unread > 0
|
|
3585
|
+
? h('span', {
|
|
3586
|
+
style: {
|
|
3587
|
+
minWidth: 16, height: 16, borderRadius: 999, background: T.danger, color: '#fff',
|
|
3588
|
+
fontSize: 9.5, fontWeight: 700, display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
3589
|
+
padding: '0 4px', flexShrink: 0,
|
|
3590
|
+
},
|
|
3591
|
+
}, unread > 99 ? '99+' : String(unread))
|
|
3592
|
+
: null,
|
|
3593
|
+
),
|
|
3594
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 5, marginTop: 1 } },
|
|
3595
|
+
h('span', {
|
|
3596
|
+
style: {
|
|
3597
|
+
flex: 1, minWidth: 0, fontSize: 11.5, color: T.textMuted, lineHeight: '16px',
|
|
3598
|
+
overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis',
|
|
3599
|
+
},
|
|
3600
|
+
}, preview),
|
|
3601
|
+
busyMeta
|
|
3602
|
+
? h('span', {
|
|
3603
|
+
title: (busy.name || '') + ':' + busyMeta.label,
|
|
3604
|
+
style: {
|
|
3605
|
+
width: 6, height: 6, borderRadius: '50%', background: busyMeta.dot, flexShrink: 0,
|
|
3606
|
+
animation: busyMeta.pulse ? 'groupchatPulse 1.2s ease-in-out infinite' : 'none',
|
|
3607
|
+
},
|
|
3608
|
+
})
|
|
3609
|
+
: null,
|
|
3610
|
+
h('span', { style: { fontSize: 10.5, color: 'var(--dsw-alias-label-caption, #8A94A6)', flexShrink: 0 } },
|
|
3611
|
+
fmtSidebarTime(last && last.ts)),
|
|
3612
|
+
),
|
|
3613
|
+
),
|
|
3614
|
+
)
|
|
3615
|
+
}
|
|
3616
|
+
|
|
3617
|
+
function SidebarGroupList() {
|
|
3618
|
+
const state = useStoreValue(stateStore)
|
|
3619
|
+
const view = useStoreValue(panelViewStore)
|
|
3620
|
+
const entries = groupIndex(state)
|
|
3621
|
+
const rosterActive = view === 'roster' || view === 'createProfile'
|
|
3622
|
+
const totalUnread = entries.reduce((sum, e) => sum + (e.group.unreadToUser || 0), 0)
|
|
3623
|
+
|
|
3624
|
+
return h('div', {
|
|
3625
|
+
style: {
|
|
3626
|
+
flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column',
|
|
3627
|
+
boxSizing: 'border-box',
|
|
3628
|
+
},
|
|
3629
|
+
},
|
|
3630
|
+
// 头部:标题 + 未读总数 + 新建群
|
|
3631
|
+
h('div', {
|
|
3632
|
+
style: {
|
|
3633
|
+
display: 'flex', alignItems: 'center', gap: 6, padding: '2px 8px 6px 12px',
|
|
3634
|
+
flexShrink: 0,
|
|
3635
|
+
},
|
|
3636
|
+
},
|
|
3637
|
+
h('span', { style: { fontSize: 12, fontWeight: 600, color: T.textMuted, letterSpacing: '0.3px' } }, '群聊'),
|
|
3638
|
+
h('span', { style: { fontSize: 10.5, color: 'var(--dsw-alias-label-caption, #8A94A6)' } },
|
|
3639
|
+
totalUnread > 0 ? totalUnread + ' 条未读' : entries.length + ' 个'),
|
|
3640
|
+
h('div', { style: { flex: 1 } }),
|
|
3641
|
+
sidebarBtn('新建群聊', () => panelNavStore.requestView('create'),
|
|
3642
|
+
h('svg', { width: 15, height: 15, viewBox: '0 0 16 16', fill: 'none', stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round' },
|
|
3643
|
+
h('path', { d: 'M8 3.2v9.6M3.2 8h9.6' }))),
|
|
3644
|
+
),
|
|
3645
|
+
// 群列表
|
|
3646
|
+
h('div', {
|
|
3647
|
+
style: {
|
|
3648
|
+
flex: 1, minHeight: 0, overflowY: 'auto', overflowX: 'hidden',
|
|
3649
|
+
overscrollBehavior: 'contain', paddingBottom: 4,
|
|
3650
|
+
},
|
|
3651
|
+
},
|
|
3652
|
+
entries.length === 0
|
|
3653
|
+
? h('div', { style: { padding: '18px 16px', fontSize: 12, color: T.textMuted, lineHeight: 1.6 } },
|
|
3654
|
+
'还没有群聊。点右上角 + 新建一个群。')
|
|
3655
|
+
: entries.map(entry => h(SidebarGroupRow, {
|
|
3656
|
+
key: entry.group.id,
|
|
3657
|
+
group: entry.group,
|
|
3658
|
+
last: entry.last,
|
|
3659
|
+
active: view === entry.group.id,
|
|
3660
|
+
onClick: () => panelNavStore.requestView(entry.group.id),
|
|
3661
|
+
})),
|
|
3662
|
+
),
|
|
3663
|
+
// 底部:花名册(与列表分开,始终可见)
|
|
3664
|
+
h('div', {
|
|
3665
|
+
style: {
|
|
3666
|
+
flexShrink: 0, borderTop: `1px solid ${T.border}`, padding: '4px 6px 6px',
|
|
3667
|
+
},
|
|
3668
|
+
},
|
|
3669
|
+
h('div', {
|
|
3670
|
+
role: 'button', tabIndex: 0,
|
|
3671
|
+
'aria-current': rosterActive ? 'page' : undefined,
|
|
3672
|
+
title: '花名册',
|
|
3673
|
+
onClick: () => panelNavStore.requestView('roster'),
|
|
3674
|
+
onKeyDown: (e) => {
|
|
3675
|
+
if (e.target !== e.currentTarget) return
|
|
3676
|
+
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); panelNavStore.requestView('roster') }
|
|
3677
|
+
},
|
|
3678
|
+
className: 'gc-side-row',
|
|
3679
|
+
style: {
|
|
3680
|
+
display: 'flex', alignItems: 'center', gap: 8, padding: '6px 8px', borderRadius: 9,
|
|
3681
|
+
cursor: 'pointer', fontSize: 12.5,
|
|
3682
|
+
color: rosterActive ? T.accent : T.textMuted,
|
|
3683
|
+
fontWeight: rosterActive ? 600 : 500,
|
|
3684
|
+
background: rosterActive ? T.accentSoft : undefined,
|
|
3685
|
+
},
|
|
3686
|
+
},
|
|
3687
|
+
h('svg', { width: 15, height: 15, viewBox: '0 0 16 16', fill: 'none', stroke: 'currentColor', strokeWidth: 1.5, strokeLinecap: 'round', strokeLinejoin: 'round' },
|
|
3688
|
+
h('circle', { cx: 6, cy: 5.5, r: 2.2 }),
|
|
3689
|
+
h('path', { d: 'M2.2 13c0-2 1.5-3.3 3.8-3.3S9.8 11 9.8 13' }),
|
|
3690
|
+
h('path', { d: 'M10.6 6.6a1.8 1.8 0 1 0 0-3.6M12 9.9c1.3.4 2 1.4 2 2.8' }),
|
|
3691
|
+
),
|
|
3692
|
+
h('span', null, '花名册'),
|
|
3693
|
+
h('div', { style: { flex: 1 } }),
|
|
3694
|
+
// 版本徽标有自己的点击行为,别让它冒泡成「打开花名册」
|
|
3695
|
+
h('div', { style: { display: 'flex' }, onClick: (e) => e.stopPropagation() }, h(VersionBadge, null)),
|
|
3696
|
+
),
|
|
3697
|
+
),
|
|
3698
|
+
)
|
|
3699
|
+
}
|
|
3700
|
+
|
|
3701
|
+
// 插件列表顶部的那一项「+ 新会话」。
|
|
3702
|
+
// 挂在 nav.panelList 的第一个子节点,只在会话模式显示(CSS 用 html[data-groupchat-active] 隐藏)。
|
|
3703
|
+
// 点它 = 点原生新会话按钮(保持挂载在入口槽位里,标记 data-groupchat-native-new)。
|
|
3704
|
+
function NewSessionNavRow() {
|
|
3705
|
+
const start = () => {
|
|
3706
|
+
const host = document.querySelector('[data-groupchat-native-new]')
|
|
3707
|
+
const btn = host && host.querySelector('button')
|
|
3708
|
+
if (btn) btn.click()
|
|
3709
|
+
}
|
|
3710
|
+
return h('button', {
|
|
3711
|
+
type: 'button', title: '新建会话', 'aria-label': '新建会话',
|
|
3712
|
+
onClick: start,
|
|
3713
|
+
style: {
|
|
3714
|
+
display: 'flex', alignItems: 'center', gap: 8, width: 'calc(100% - 8px)', boxSizing: 'border-box',
|
|
3715
|
+
minHeight: 32, margin: '2px 4px -8px', padding: '5px 10px', border: 'none', borderRadius: 10,
|
|
3716
|
+
background: 'transparent', color: T.text, fontFamily: 'inherit',
|
|
3717
|
+
fontSize: 12.5, fontWeight: 500, cursor: 'pointer', textAlign: 'left', flex: 'none',
|
|
3718
|
+
},
|
|
3719
|
+
onMouseEnter: (e) => { e.currentTarget.style.background = 'var(--dsw-alias-interactive-bg-hover, rgba(16,41,66,0.08))' },
|
|
3720
|
+
onMouseLeave: (e) => { e.currentTarget.style.background = 'transparent' },
|
|
3721
|
+
},
|
|
3722
|
+
h('svg', {
|
|
3723
|
+
width: 16, height: 16, viewBox: '0 0 18 18', fill: 'none', stroke: 'currentColor',
|
|
3724
|
+
strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round',
|
|
3725
|
+
}, h('path', { d: 'M9 3.6v10.8M3.6 9h10.8' })),
|
|
3726
|
+
h('span', null, '新会话'),
|
|
3727
|
+
)
|
|
3728
|
+
}
|
|
3729
|
+
|
|
3730
|
+
// 侧栏内容宿主:非群聊模式什么都不渲染,原生工作区列表照常显示。
|
|
3731
|
+
function SidebarHost() {
|
|
3732
|
+
const active = useStoreValue(panelActiveStore)
|
|
3733
|
+
useEffect(() => {
|
|
3734
|
+
const html = document.documentElement
|
|
3735
|
+
if (active) html.setAttribute('data-groupchat-active', '')
|
|
3736
|
+
else html.removeAttribute('data-groupchat-active')
|
|
3737
|
+
return () => { html.removeAttribute('data-groupchat-active') }
|
|
3738
|
+
}, [active])
|
|
3739
|
+
|
|
3740
|
+
// 群聊模式下把注入容器撑满导航以下的剩余高度:
|
|
3741
|
+
// 这样群列表自己滚、花名册固定在底部,而不是短列表时footer悬在半空。
|
|
3742
|
+
useEffect(() => {
|
|
3743
|
+
if (!active) return
|
|
3744
|
+
const container = document.querySelector('[' + GC_SIDEBAR_ATTR + ']')
|
|
3745
|
+
const scroll = document.querySelector('[data-sidebar-scrollport]')
|
|
3746
|
+
if (!container || !scroll) return
|
|
3747
|
+
const resize = () => {
|
|
3748
|
+
try {
|
|
3749
|
+
if (scroll.scrollTop !== 0) scroll.scrollTop = 0
|
|
3750
|
+
const bottom = scroll.getBoundingClientRect().bottom
|
|
3751
|
+
const top = container.getBoundingClientRect().top
|
|
3752
|
+
const avail = Math.max(160, Math.round(bottom - top - 4))
|
|
3753
|
+
container.style.height = avail + 'px'
|
|
3754
|
+
} catch (_e) { /* ignore */ }
|
|
3755
|
+
}
|
|
3756
|
+
resize()
|
|
3757
|
+
const timer = setTimeout(resize, 300)
|
|
3758
|
+
let ro = null
|
|
3759
|
+
try {
|
|
3760
|
+
ro = new ResizeObserver(resize)
|
|
3761
|
+
ro.observe(scroll)
|
|
3762
|
+
} catch (_e) { ro = null }
|
|
3763
|
+
window.addEventListener('resize', resize)
|
|
3764
|
+
return () => {
|
|
3765
|
+
clearTimeout(timer)
|
|
3766
|
+
if (ro) { try { ro.disconnect() } catch (_e) { /* ignore */ } }
|
|
3767
|
+
window.removeEventListener('resize', resize)
|
|
3768
|
+
try { container.style.height = '' } catch (_e) { /* ignore */ }
|
|
3769
|
+
}
|
|
3770
|
+
}, [active])
|
|
3771
|
+
|
|
3772
|
+
return h('div', {
|
|
3773
|
+
style: {
|
|
3774
|
+
display: active ? 'flex' : 'none',
|
|
3775
|
+
flexDirection: 'column', minHeight: 0, flex: 1,
|
|
3776
|
+
},
|
|
3777
|
+
}, active ? h(SidebarGroupList) : null)
|
|
3778
|
+
}
|
|
3779
|
+
|
|
3780
|
+
// 把 SidebarHost 挂到原生侧栏(侧栏可能尚未渲染,用轻量轮询等它出现/重挂)
|
|
3781
|
+
let sidebarMount = null
|
|
3782
|
+
function mountGroupchatSidebar() {
|
|
3783
|
+
if (sidebarMount || !ReactDOMClient || typeof ReactDOMClient.createRoot !== 'function') return
|
|
3784
|
+
const state = { container: null, root: null, rowContainer: null, rowRoot: null, timer: null }
|
|
3785
|
+
const ensure = () => {
|
|
3786
|
+
try {
|
|
3787
|
+
const scroll = document.querySelector('[data-sidebar-scrollport]')
|
|
3788
|
+
if (!scroll) return
|
|
3789
|
+
if (!state.container) {
|
|
3790
|
+
const container = document.createElement('div')
|
|
3791
|
+
container.setAttribute(GC_SIDEBAR_ATTR, '')
|
|
3792
|
+
container.style.cssText = 'grid-column:2;grid-row:4;align-self:start;min-height:0;display:flex;flex-direction:column;'
|
|
3793
|
+
state.root = ReactDOMClient.createRoot(container)
|
|
3794
|
+
state.root.render(h(SidebarHost))
|
|
3795
|
+
state.container = container
|
|
3796
|
+
}
|
|
3797
|
+
// 原生工作区区域 = scrollArea 里除我们容器之外的那个 div,打个标记供 CSS 隐藏
|
|
3798
|
+
const region = Array.from(scroll.children).find(
|
|
3799
|
+
el => el.tagName === 'DIV' && !el.hasAttribute(GC_SIDEBAR_ATTR),
|
|
3800
|
+
)
|
|
3801
|
+
if (region && !region.hasAttribute(GC_NATIVE_REGION_ATTR)) region.setAttribute(GC_NATIVE_REGION_ATTR, '')
|
|
3802
|
+
if (state.container.parentNode !== scroll) scroll.appendChild(state.container)
|
|
3803
|
+
|
|
3804
|
+
// 「+ 新会话」= 滚动区上方、插件列表上面的一条,固定可见(不随列表滚走)。
|
|
3805
|
+
// 插到 .scrollRegion 前面(= sidebar root 的直接子节点),不占入口槽位的高度。
|
|
3806
|
+
const scrollRegion = scroll.parentElement
|
|
3807
|
+
const root = scrollRegion && scrollRegion.parentElement
|
|
3808
|
+
if (root && scrollRegion) {
|
|
3809
|
+
if (!state.rowContainer) {
|
|
3810
|
+
const row = document.createElement('div')
|
|
3811
|
+
row.setAttribute('data-groupchat-new-session', '')
|
|
3812
|
+
row.style.cssText = 'flex:none;min-height:0;display:flex;flex-direction:column;'
|
|
3813
|
+
state.rowRoot = ReactDOMClient.createRoot(row)
|
|
3814
|
+
state.rowRoot.render(h(NewSessionNavRow))
|
|
3815
|
+
state.rowContainer = row
|
|
3816
|
+
}
|
|
3817
|
+
if (state.rowContainer.parentNode !== root || state.rowContainer.nextElementSibling !== scrollRegion) {
|
|
3818
|
+
root.insertBefore(state.rowContainer, scrollRegion)
|
|
3819
|
+
}
|
|
3820
|
+
}
|
|
3821
|
+
} catch (e) {
|
|
3822
|
+
console.warn('groupchat sidebar mount failed:', e)
|
|
3823
|
+
}
|
|
3824
|
+
}
|
|
3825
|
+
ensure()
|
|
3826
|
+
state.timer = setInterval(ensure, 1500)
|
|
3827
|
+
sidebarMount = state
|
|
3828
|
+
}
|
|
3829
|
+
|
|
3830
|
+
function unmountGroupchatSidebar() {
|
|
3831
|
+
const state = sidebarMount
|
|
3832
|
+
sidebarMount = null
|
|
3833
|
+
if (!state) return
|
|
3834
|
+
clearInterval(state.timer)
|
|
3835
|
+
try { if (state.rowRoot) state.rowRoot.unmount() } catch (_e) { /* ignore */ }
|
|
3836
|
+
try { if (state.rowContainer) state.rowContainer.remove() } catch (_e) { /* ignore */ }
|
|
3837
|
+
try { if (state.root) state.root.unmount() } catch (_e) { /* ignore */ }
|
|
3838
|
+
try { if (state.container) state.container.remove() } catch (_e) { /* ignore */ }
|
|
3839
|
+
document.querySelectorAll('[' + GC_NATIVE_REGION_ATTR + ']').forEach(el => el.removeAttribute(GC_NATIVE_REGION_ATTR))
|
|
3840
|
+
document.documentElement.removeAttribute('data-groupchat-active')
|
|
3841
|
+
}
|
|
3842
|
+
|
|
3843
|
+
// 宿主侧插件被停用/卸载:客户端这半边可能没被 dispose(生产包里常见),
|
|
3844
|
+
// 由轮询到 /state 连续 404 触发,把注入的 DOM、样式、属性全部撤掉,恢复原生侧栏。
|
|
3845
|
+
function handleHostDisabled() {
|
|
3846
|
+
if (!pluginAliveStore.get()) return
|
|
3847
|
+
pluginAliveStore.set(false)
|
|
3848
|
+
try {
|
|
3849
|
+
if (panelActiveStore.get() && layoutRef.current && typeof layoutRef.current.selectPanel === 'function') {
|
|
3850
|
+
layoutRef.current.selectPanel(null)
|
|
3851
|
+
}
|
|
3852
|
+
} catch (_e) { /* ignore */ }
|
|
3853
|
+
try { unmountGroupchatSidebar() } catch (_e) { /* ignore */ }
|
|
3854
|
+
if (groupchatStyleEl) {
|
|
3855
|
+
try { groupchatStyleEl.remove() } catch (_e) { /* ignore */ }
|
|
3856
|
+
}
|
|
3857
|
+
document.documentElement.removeAttribute('data-groupchat-active')
|
|
3858
|
+
}
|
|
3859
|
+
|
|
3860
|
+
// 宿主侧重新启用:接口恢复 200 时把 UI 挂回去(客户端没重新 import 也能恢复)
|
|
3861
|
+
function recoverPluginUi() {
|
|
3862
|
+
if (pluginAliveStore.get()) return
|
|
3863
|
+
pluginAliveStore.set(true)
|
|
3864
|
+
try {
|
|
3865
|
+
if (groupchatStyleEl && !groupchatStyleEl.isConnected) document.head.appendChild(groupchatStyleEl)
|
|
3866
|
+
} catch (_e) { /* ignore */ }
|
|
3867
|
+
try { mountGroupchatSidebar() } catch (_e) { /* ignore */ }
|
|
3868
|
+
}
|
|
3869
|
+
|
|
3474
3870
|
/**
|
|
3475
|
-
*
|
|
3871
|
+
* 侧栏顶部(`sidebar.session.action` 槽位):「会话 / 群聊」两个 tab,
|
|
3872
|
+
* 以及会话模式下的「+ 新会话」入口(就在插件列表上方)。
|
|
3476
3873
|
*
|
|
3477
|
-
*
|
|
3478
|
-
* 1.
|
|
3479
|
-
*
|
|
3480
|
-
*
|
|
3874
|
+
* 约束(都踩过):
|
|
3875
|
+
* 1. 槽位会把原生「新会话」按钮作为 children 传进来,必须保持挂载,否则新会话动作丢失;
|
|
3876
|
+
* 宽栏下把它视觉隐藏,由「+ 新会话」代触发它的 click。
|
|
3877
|
+
* 2. 槽位外层是 display:contents,根节点直接参与 flex。
|
|
3878
|
+
* 3. 折叠窄栏(wide=false)放不下 tab,保留原生新会话图标 + 群聊图标。
|
|
3481
3879
|
*/
|
|
3482
3880
|
function GroupchatEntryButton(props) {
|
|
3483
3881
|
const wide = !!(props && props.wide)
|
|
3484
3882
|
const children = props ? props.children : null
|
|
3485
3883
|
const [unread, setUnread] = useState(0)
|
|
3486
3884
|
const [active, setActive] = useState(() => panelActiveStore.get())
|
|
3885
|
+
const alive = useStoreValue(pluginAliveStore)
|
|
3886
|
+
const nativeRef = useRef(null)
|
|
3487
3887
|
useEffect(() => {
|
|
3488
3888
|
const unsubscribe = unreadStore.subscribe(() => setUnread(unreadStore.get()))
|
|
3489
3889
|
setUnread(unreadStore.get())
|
|
@@ -3494,91 +3894,115 @@ window.__ModuleLoader__.load({
|
|
|
3494
3894
|
setActive(panelActiveStore.get())
|
|
3495
3895
|
return unsubscribe
|
|
3496
3896
|
}, [])
|
|
3497
|
-
|
|
3897
|
+
|
|
3898
|
+
// 返回会话:切回会话 tab,并把进群聊前正在看的那个会话点回来
|
|
3899
|
+
const returnToConversation = () => {
|
|
3498
3900
|
const layout = layoutRef.current
|
|
3499
|
-
if (layout
|
|
3901
|
+
if (!layout || typeof layout.selectPanel !== 'function') return
|
|
3902
|
+
const sessionId = lastMainSessionRef.current
|
|
3903
|
+
try { layout.selectPanel(null) } catch (_e) { return }
|
|
3904
|
+
if (!sessionId) return
|
|
3905
|
+
// 工作区列表要等面板挂载后才渲染出来,找到原来那行就点它(= 用户手动切回)
|
|
3906
|
+
const openRow = (attempt) => {
|
|
3907
|
+
if (panelActiveStore.get()) return
|
|
3908
|
+
const row = document.querySelector('[data-row-key="session:' + sessionId + '"]')
|
|
3909
|
+
if (row) { try { row.click() } catch (_e) { /* ignore */ } return }
|
|
3910
|
+
if (attempt < 3) setTimeout(() => openRow(attempt + 1), 250)
|
|
3911
|
+
}
|
|
3912
|
+
setTimeout(() => openRow(0), 120)
|
|
3500
3913
|
}
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3914
|
+
const openGroupchat = () => {
|
|
3915
|
+
if (active) return
|
|
3916
|
+
lastMainSessionRef.current = getCurrentSessionId()
|
|
3917
|
+
const layout = layoutRef.current
|
|
3918
|
+
if (!layout || typeof layout.selectPanel !== 'function') return
|
|
3919
|
+
try { layout.selectPanel(PANEL_ID) } catch (_e) { /* 主面板未注册时忽略 */ }
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
// 插件已在宿主侧停用:把槽位还给原生「新会话」按钮
|
|
3923
|
+
if (!alive) return children
|
|
3924
|
+
|
|
3925
|
+
const groupchatIcon = h('svg', {
|
|
3926
|
+
width: 16, height: 16, viewBox: '0 0 18 18', fill: 'none', stroke: 'currentColor',
|
|
3927
|
+
strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round',
|
|
3928
|
+
},
|
|
3929
|
+
h('circle', { cx: 6, cy: 7.5, r: 2.2 }),
|
|
3930
|
+
h('circle', { cx: 12, cy: 7.5, r: 2.2 }),
|
|
3931
|
+
h('path', { d: 'M2.5 14.5c0-1.9 1.3-3.2 3.3-3.2h1.4M15.5 14.5c0-1.9-1.3-3.2-3.3-3.2h-1.4' }),
|
|
3932
|
+
)
|
|
3933
|
+
|
|
3934
|
+
// 折叠窄栏:原生新会话图标 + 群聊图标(tab 放不下)
|
|
3935
|
+
if (!wide) {
|
|
3936
|
+
return h(React.Fragment, null,
|
|
3937
|
+
children,
|
|
3938
|
+
h('button', {
|
|
3939
|
+
type: 'button', title: '群聊', 'aria-label': '群聊',
|
|
3940
|
+
'aria-current': active ? 'page' : undefined,
|
|
3941
|
+
onClick: openGroupchat,
|
|
3942
|
+
style: {
|
|
3943
|
+
position: 'relative', width: 30, height: 30, flexShrink: 0, padding: 0,
|
|
3944
|
+
border: 'none', borderRadius: 8, cursor: 'pointer',
|
|
3945
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
3946
|
+
background: active ? 'var(--dsw-alias-accent, #2E6BE6)' : 'transparent',
|
|
3947
|
+
color: active ? '#fff' : 'var(--dsw-alias-label-primary, #102942)',
|
|
3948
|
+
},
|
|
3529
3949
|
},
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
onMouseDown: (e) => { if (active) e.currentTarget.style.filter = 'brightness(0.94)' },
|
|
3533
|
-
onMouseUp: (e) => { e.currentTarget.style.filter = 'none' },
|
|
3534
|
-
},
|
|
3535
|
-
h('span', { style: { position: 'relative', display: 'flex', flexShrink: 0 } },
|
|
3536
|
-
h('svg', { width: 16, height: 16, viewBox: '0 0 18 18', fill: 'none', stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round' },
|
|
3537
|
-
h('circle', { cx: 6, cy: 7.5, r: 2.2 }),
|
|
3538
|
-
h('circle', { cx: 12, cy: 7.5, r: 2.2 }),
|
|
3539
|
-
h('path', { d: 'M2.5 14.5c0-1.9 1.3-3.2 3.3-3.2h1.4M15.5 14.5c0-1.9-1.3-3.2-3.3-3.2h-1.4' }),
|
|
3540
|
-
),
|
|
3541
|
-
unread > 0 && !wide ? h('span', {
|
|
3950
|
+
groupchatIcon,
|
|
3951
|
+
unread > 0 ? h('span', {
|
|
3542
3952
|
style: {
|
|
3543
|
-
position: 'absolute', top: -3, right: -
|
|
3544
|
-
background:
|
|
3953
|
+
position: 'absolute', top: -3, right: -4, minWidth: 14, height: 14, borderRadius: 999,
|
|
3954
|
+
background: T.danger, color: '#fff', fontSize: 8, fontWeight: 700,
|
|
3545
3955
|
display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '0 3px',
|
|
3956
|
+
border: '1.5px solid var(--dsw-specific-sidebar-fill, #fff)', boxSizing: 'content-box',
|
|
3546
3957
|
},
|
|
3547
3958
|
}, unread > 99 ? '99+' : String(unread)) : null,
|
|
3548
3959
|
),
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
style: {
|
|
3552
|
-
minWidth: 16, height: 16, borderRadius: 999, background: '#C0392B', color: '#fff',
|
|
3553
|
-
fontSize: 9, fontWeight: 700, display: 'flex', alignItems: 'center',
|
|
3554
|
-
justifyContent: 'center', padding: '0 4px', flexShrink: 0,
|
|
3555
|
-
},
|
|
3556
|
-
}, unread > 99 ? '99+' : String(unread)) : null,
|
|
3557
|
-
),
|
|
3558
|
-
)
|
|
3559
|
-
}
|
|
3960
|
+
)
|
|
3961
|
+
}
|
|
3560
3962
|
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3963
|
+
const tab = (label, selected, onClick) => h('button', {
|
|
3964
|
+
type: 'button', role: 'tab',
|
|
3965
|
+
'aria-selected': selected ? 'true' : 'false',
|
|
3966
|
+
onClick,
|
|
3967
|
+
style: {
|
|
3968
|
+
flex: 1, minWidth: 0, height: 28, padding: '0 8px', border: 'none', borderRadius: 7,
|
|
3969
|
+
cursor: 'pointer', fontFamily: 'inherit', fontSize: 12.5,
|
|
3970
|
+
fontWeight: selected ? 600 : 500,
|
|
3971
|
+
color: selected ? T.text : T.textMuted,
|
|
3972
|
+
background: selected ? 'var(--dsw-alias-surface, #fff)' : 'transparent',
|
|
3973
|
+
boxShadow: selected ? '0 1px 2px rgba(16,41,66,0.10), 0 0 0 1px rgba(16,41,66,0.04)' : 'none',
|
|
3974
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 5,
|
|
3975
|
+
transition: 'background .15s ease, color .15s ease, box-shadow .15s ease',
|
|
3976
|
+
},
|
|
3977
|
+
onMouseEnter: (e) => { if (!selected) e.currentTarget.style.color = T.text },
|
|
3978
|
+
onMouseLeave: (e) => { if (!selected) e.currentTarget.style.color = T.textMuted },
|
|
3979
|
+
}, label)
|
|
3980
|
+
|
|
3981
|
+
return h('div', {
|
|
3982
|
+
style: { display: 'flex', alignItems: 'center', flex: 1, minWidth: 0 },
|
|
3983
|
+
},
|
|
3984
|
+
// 两个 tab:会话 / 群聊(高度固定 32px,不随模式变化,避免把旁边的导入按钮挤动)
|
|
3985
|
+
h('div', {
|
|
3986
|
+
role: 'tablist', 'aria-label': '侧栏视图',
|
|
3575
3987
|
style: {
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
fontSize: 8, fontWeight: 700, display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
3579
|
-
padding: '0 3px', border: '2px solid #fff',
|
|
3988
|
+
display: 'flex', gap: 2, padding: 2, borderRadius: 9, flex: 1, minWidth: 0,
|
|
3989
|
+
background: 'var(--dsw-alias-fill-secondary, rgba(16,41,66,0.05))',
|
|
3580
3990
|
},
|
|
3581
|
-
},
|
|
3991
|
+
},
|
|
3992
|
+
tab('会话', !active, () => { if (active) returnToConversation() }),
|
|
3993
|
+
tab(h(React.Fragment, null,
|
|
3994
|
+
'群聊',
|
|
3995
|
+
unread > 0 ? h('span', {
|
|
3996
|
+
style: {
|
|
3997
|
+
minWidth: 14, height: 14, borderRadius: 999, background: T.danger, color: '#fff',
|
|
3998
|
+
fontSize: 8.5, fontWeight: 700, display: 'inline-flex', alignItems: 'center',
|
|
3999
|
+
justifyContent: 'center', padding: '0 3px', boxSizing: 'border-box',
|
|
4000
|
+
},
|
|
4001
|
+
}, unread > 99 ? '99+' : String(unread)) : null,
|
|
4002
|
+
), active, openGroupchat),
|
|
4003
|
+
),
|
|
4004
|
+
// 原生新会话按钮保持挂载(display:none),由插件列表里的「+ 新会话」代触发
|
|
4005
|
+
h('div', { ref: nativeRef, 'data-groupchat-native-new': '', style: { display: 'none' } }, children),
|
|
3582
4006
|
)
|
|
3583
4007
|
}
|
|
3584
4008
|
|
|
@@ -3650,12 +4074,23 @@ window.__ModuleLoader__.load({
|
|
|
3650
4074
|
}
|
|
3651
4075
|
.gc-toast { animation: gcToastIn .28s cubic-bezier(0.22,1,0.36,1) both; }
|
|
3652
4076
|
.gc-toast-bar { animation: gcToastBar 5s linear forwards; }
|
|
4077
|
+
/* 左栏群聊列表:行 hover / 键盘焦点;群聊模式隐藏原生工作区列表 */
|
|
4078
|
+
html[data-groupchat-active] [data-groupchat-native-region] { display: none !important; }
|
|
4079
|
+
html[data-groupchat-active] [data-groupchat-new-session] { display: none !important; }
|
|
4080
|
+
[data-sidebar-collapsed] [data-groupchat-sidebar],
|
|
4081
|
+
[data-sidebar-collapsed] [data-groupchat-new-session] { display: none !important; }
|
|
4082
|
+
.gc-side-row:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(16,41,66,0.08)); }
|
|
4083
|
+
.gc-side-row:focus-visible {
|
|
4084
|
+
outline: var(--dsw-focus-ring-width, 2px) solid var(--dsw-focus-ring-color, var(--dsw-alias-accent, #2E6BE6));
|
|
4085
|
+
outline-offset: -2px;
|
|
4086
|
+
}
|
|
3653
4087
|
@media (prefers-reduced-motion: reduce) {
|
|
3654
4088
|
.gc-card, .gc-in, .gc-fade, .gc-pop, .gc-flash, .gc-toast, .gc-toast-bar { animation: none !important; transition: none !important; }
|
|
3655
4089
|
}
|
|
3656
4090
|
`
|
|
3657
4091
|
document.head.appendChild(style)
|
|
3658
|
-
|
|
4092
|
+
groupchatStyleEl = style
|
|
4093
|
+
return () => { try { style.remove() } catch (_e) { /* ignore */ }; if (groupchatStyleEl === style) groupchatStyleEl = null }
|
|
3659
4094
|
}, 'groupchat: animations')
|
|
3660
4095
|
|
|
3661
4096
|
// 全局轮询:页面加载即开始,不依赖群聊面板是否打开
|
|
@@ -3665,8 +4100,14 @@ window.__ModuleLoader__.load({
|
|
|
3665
4100
|
return () => { clearInterval(globalPollTimer); globalPollTimer = null }
|
|
3666
4101
|
}, 'groupchat: global poll')
|
|
3667
4102
|
|
|
3668
|
-
//
|
|
3669
|
-
|
|
4103
|
+
// 左栏群聊列表:注入原生侧栏,群聊模式下顶替「工作区 / 会话」列表
|
|
4104
|
+
ctx.effect(() => {
|
|
4105
|
+
mountGroupchatSidebar()
|
|
4106
|
+
return () => { unmountGroupchatSidebar() }
|
|
4107
|
+
}, 'groupchat: sidebar list')
|
|
4108
|
+
|
|
4109
|
+
// 侧栏入口:把「新会话 + 群聊」收成一条紧凑图标栏(sidebar.session.action 槽位)。
|
|
4110
|
+
// 行内布局由 GroupchatEntryButton 负责,新会话按钮保持挂载但视觉隐藏。
|
|
3670
4111
|
ctx.slots.inject('sidebar.session.action', () =>
|
|
3671
4112
|
ctx.slots.register({ name: 'sidebar.session.action', id: PANEL_ID, locale: NS }, GroupchatEntryButton),
|
|
3672
4113
|
)
|
package/docs/DESIGN.md
CHANGED
|
@@ -293,7 +293,7 @@ sAgent = 一个普通会话(专属 persona + 群管理工具集),靠「被
|
|
|
293
293
|
|
|
294
294
|
| 能力 | 说明 |
|
|
295
295
|
|---|---|
|
|
296
|
-
| 群聊面板 |
|
|
296
|
+
| 群聊面板 | 左栏群聊列表(未读/最近消息/忙闲)+ 主区域群详情;群聊模式下左栏顶替工作区列表,切回会话自动恢复 |
|
|
297
297
|
| 新建群 | 群名/描述/初始任务;项目经理可自动创建或从花名册选;成员从花名册勾选 |
|
|
298
298
|
| 群详情 | 消息流 + 发消息 + 让项目经理汇报 + 解散群 |
|
|
299
299
|
| 角色模板 | 预置 项目经理/产品/研发/测试,各带 persona + 职责 |
|