@fabianactor/dsh-lil-whale-group-ui 1.12.3 → 1.13.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.
@@ -0,0 +1,293 @@
1
+ /**
2
+ * 绑定(pins)的规则与写入形状。
3
+ *
4
+ * 为什么单独一层:这件事有三条入口——会话行的「⋯」菜单、面板的 HTTP 路由、命令行的
5
+ * `bind-member.mjs --unbind`。三个地方各写一遍"这段会话是不是这条鱼的",早晚会分叉;
6
+ * 分叉之后最糟的不是报错,是三个入口各认一个答案。
7
+ *
8
+ * 规则(fi-0017):
9
+ * - 只有 `kind === "fish"` 的成员能被绑;人类不行(他没有会话)。
10
+ * - 会话必须真的在那个成员的 `dshHome` 里:`<dshHome>\sessions\<项目>\<session-id>`。
11
+ * 绑一段别人的会话 = 把别人的名字顶到她头上,比绑不上难查得多。
12
+ * - 菜单里"绑"= 替换(pins[成员] = [这段会话]);一个成员多段会话这门语言还不支持。
13
+ * - 解绑 = pins[成员] = [],members.json 的 sessionId 一起清空;两处必须一起改。
14
+ */
15
+ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
16
+ import { join } from 'node:path'
17
+
18
+ /** 会话 id 的形状:`session-` + uuid。和 scripts/bind-member.mjs 用同一条。 */
19
+ export const SESSION_RE = /^session-[0-9a-f-]{20,}$/
20
+
21
+ /** 读进来的值可能带空白、可能不是字符串:合法就返回去空白后的 id,否则 null。 */
22
+ export function sessionIdOf(value) {
23
+ const text = typeof value === 'string' ? value.trim() : ''
24
+ return SESSION_RE.test(text) ? text : null
25
+ }
26
+
27
+ /** 这条鱼的家(dshHome 优先;老名册只有 home 时按 `<home>\dsh-home` 推)。 */
28
+ export function homeOfMember(member) {
29
+ if (!member) return null
30
+ if (typeof member.dshHome === 'string' && member.dshHome.trim()) return member.dshHome.trim()
31
+ if (typeof member.home === 'string' && member.home.trim()) return join(member.home.trim(), 'dsh-home')
32
+ return null
33
+ }
34
+
35
+ /**
36
+ * 这段会话在不在这个家里。
37
+ *
38
+ * 只认目录:`<dshHome>\sessions\**\session-<id>`。不读会话内容 —— 判"归属"不该顺带
39
+ * 把别人的话翻开(A.24 私聊那条同一条边界)。
40
+ */
41
+ export function sessionExistsInHome(home, sessionId) {
42
+ const id = sessionIdOf(sessionId)
43
+ if (!home || !id) return false
44
+ const root = join(home, 'sessions')
45
+ if (!existsSync(root)) return false
46
+ let projects
47
+ try {
48
+ projects = readdirSync(root, { withFileTypes: true })
49
+ } catch {
50
+ return false
51
+ }
52
+ for (const project of projects) {
53
+ if (!project.isDirectory()) continue
54
+ const dir = join(root, project.name, id)
55
+ if (existsSync(join(dir, 'session.v4.jsonl.zstd'))) return true
56
+ // 会话目录存在但文件还没落(刚建的空会话):也算"在这里",否则第一次绑会莫名其妙被拒。
57
+ if (existsSync(dir)) return true
58
+ }
59
+ return false
60
+ }
61
+
62
+ /** 名册里的鱼(按 kind 挑,不按名字猜)。保持名册顺序,菜单的次序就是出场的次序。 */
63
+ export function fishOf(roster) {
64
+ const members = roster?.members ?? roster ?? {}
65
+ return Object.entries(members)
66
+ .filter(([, m]) => m && m.kind === 'fish')
67
+ .map(([key, m]) => ({
68
+ key,
69
+ name: typeof m.name === 'string' && m.name.trim() ? m.name.trim().slice(0, 16) : key,
70
+ role: m.role === 'watcher' ? 'watcher' : 'member',
71
+ dshHome: homeOfMember(m),
72
+ }))
73
+ }
74
+
75
+ /** 这段会话现在绑给谁(pins 里允许一个成员多段,返回第一个命中的)。 */
76
+ export function findBinding(pins, sessionId) {
77
+ for (const [member, raw] of Object.entries(pins ?? {})) {
78
+ const list = Array.isArray(raw) ? raw : raw ? [raw] : []
79
+ if (list.includes(sessionId)) return { member, sessionId }
80
+ }
81
+ return null
82
+ }
83
+
84
+ /**
85
+ * 这段会话登记在哪个工作区(读 `<dshHome>\storages\workspace.json` 的 tables.workspaces)。
86
+ *
87
+ * 为什么要这一格:会话自带创建时的工作区,醒来时的 cwd 就是它。绑一段"在 default-workspace
88
+ * 或别人家里建的"会话,她醒来会站在错的地方——文件工具与沙箱按错的根走,写不进或写错处。
89
+ * 返回 null = 没有登记(未分组),由调用方决定放不放行。
90
+ */
91
+ export function workspacePathOf(home, sessionId) {
92
+ const id = sessionIdOf(sessionId)
93
+ if (!home || !id) return null
94
+ const file = join(home, 'storages', 'workspace.json')
95
+ if (!existsSync(file)) return null
96
+ let data
97
+ try {
98
+ data = JSON.parse(readFileSync(file, 'utf8'))
99
+ } catch {
100
+ return null
101
+ }
102
+ const tables = data?.tables?.workspaces
103
+ if (!tables || typeof tables !== 'object') return null
104
+ for (const ws of Object.values(tables)) {
105
+ const ids = Array.isArray(ws?.sessionIds) ? ws.sessionIds : []
106
+ if (ids.includes(id)) return typeof ws.path === 'string' ? ws.path : null
107
+ }
108
+ return null
109
+ }
110
+
111
+ /** 路径比较用:斜杠归一、去尾斜杠、大小写不敏感(Windows 上这两条路是同一个地方)。 */
112
+ export function normalizePath(value) {
113
+ return String(value ?? '')
114
+ .trim()
115
+ .replace(/[\\/]+/g, '\\')
116
+ .replace(/\\$/, '')
117
+ .toLowerCase()
118
+ }
119
+
120
+ function underRoot(value, root) {
121
+ const a = normalizePath(value)
122
+ const b = normalizePath(root)
123
+ if (!a || !b) return false
124
+ return a === b || a.startsWith(b + '\\')
125
+ }
126
+
127
+ /**
128
+ * 能不能绑。返回 null 表示可以;否则给出给人看的理由(HTTP 状态 + 机器码 + 人话)。
129
+ * 人话里带上"这段会话不在谁家里",别只说 400。
130
+ *
131
+ * 工作区那一格(Fi-0017 的补充):
132
+ * - 普通鱼:会话登记的工作区必须就是她的家(`member.home`);不在自己家的拒绝。
133
+ * - 巡守(宿主自己):他的工作区是鱼塘根(`D:\…\lil-whale`),不是 `~\.dsh`,所以只要求
134
+ * 在鱼塘里面(`pondRoot`);会话文件仍在 `dshHome\sessions` 下这条不变。
135
+ * - 没登记工作区的会话:放行(r261 那种"未分组"),否则第一段会话反而绑不上。
136
+ */
137
+ export function bindingProblem({ roster, memberKey, sessionId, pondRoot }) {
138
+ const id = sessionIdOf(sessionId)
139
+ if (!id) return { status: 400, error: 'bad-session-id', message: '会话 id 形如 session-xxxxxxxx-…' }
140
+ const member = (roster?.members ?? roster ?? {})[memberKey]
141
+ if (!member) return { status: 400, error: 'no-member', message: `名册里没有成员:${memberKey}` }
142
+ if (member.kind !== 'fish') return { status: 400, error: 'not-fish', message: `${memberKey} 不是鱼(kind=${member.kind}),不能绑会话` }
143
+ const home = homeOfMember(member)
144
+ const name = typeof member.name === 'string' && member.name.trim() ? member.name.trim() : memberKey
145
+ if (!home) return { status: 400, error: 'no-home', message: `名册里没有 ${memberKey} 的 dshHome` }
146
+ if (!sessionExistsInHome(home, id)) {
147
+ return { status: 400, error: 'session-not-in-home', message: `这段会话不在 ${name} 的家里(${home}),不绑` }
148
+ }
149
+ const wsPath = workspacePathOf(home, id)
150
+ if (wsPath) {
151
+ if (member.role === 'watcher') {
152
+ // 巡守的会话常建在鱼塘根的父目录里(例:default-workspace\lil-whale 的会话建在 default-workspace)。
153
+ // 2026-11-23 r439:允许"鱼塘根的祖先",但至少要有两级目录,免得把 C:\ 这种当成合法工作区。
154
+ const ancestorOk = underRoot(pondRoot, wsPath) && normalizePath(wsPath).split('\\').filter(Boolean).length >= 2
155
+ if (pondRoot && !underRoot(wsPath, pondRoot) && !ancestorOk) {
156
+ return { status: 409, error: 'session-workspace-outside-pond', message: `这段会话的工作区在鱼塘外面(${wsPath}),不绑给 ${name}` }
157
+ }
158
+ } else {
159
+ const own = typeof member.home === 'string' && member.home.trim() ? member.home.trim() : home
160
+ if (normalizePath(wsPath) !== normalizePath(own)) {
161
+ return { status: 409, error: 'session-workspace-mismatch', message: `这段会话登记在别的工作区(${wsPath}),醒来 cwd 不是 ${name} 的家(${own});换一段在她家里建的会话` }
162
+ }
163
+ }
164
+ }
165
+ return null
166
+ }
167
+
168
+ /** 能不能解绑:只查"现在是不是真绑着",不查会话还在不在(会话删了也要能解)。 */
169
+ export function unbindProblem({ pins, memberKey, sessionId }) {
170
+ const id = sessionIdOf(sessionId)
171
+ if (!id) return { status: 400, error: 'bad-session-id', message: '会话 id 形如 session-xxxxxxxx-…' }
172
+ const list = Array.isArray(pins?.[memberKey]) ? pins[memberKey] : pins?.[memberKey] ? [pins[memberKey]] : []
173
+ if (!list.includes(id)) {
174
+ return { status: 409, error: 'not-bound', message: `${memberKey} 现在没有绑这段会话(${id})` }
175
+ }
176
+ return null
177
+ }
178
+
179
+ /** 绑:pins[成员] = [这段会话](替换)。同一段会话同时只归一个人 —— 别人手里的同一段要摘掉。 */
180
+ export function applyBind(pins, memberKey, sessionId) {
181
+ const id = sessionIdOf(sessionId)
182
+ const next = {}
183
+ for (const [member, raw] of Object.entries(pins ?? {})) {
184
+ const list = Array.isArray(raw) ? raw : raw ? [raw] : []
185
+ next[member] = member === memberKey ? [id] : list.filter((x) => x !== id)
186
+ }
187
+ if (!Object.prototype.hasOwnProperty.call(next, memberKey)) next[memberKey] = [id]
188
+ return next
189
+ }
190
+
191
+ /** 解绑:pins[成员] = []。返回新对象。 */
192
+ export function applyUnbind(pins, memberKey) {
193
+ const next = { ...(pins ?? {}) }
194
+ next[memberKey] = []
195
+ return next
196
+ }
197
+
198
+ /**
199
+ * 面板要的一份视图:鱼列表 + 当前 pins + 每段被绑会话到底还在不在盘上。
200
+ * `stale` 的会话照样列出来并标出来("已绑给 X(会话已不存在)"),不假装没这回事。
201
+ */
202
+ export function bindingsView({ roster, pins, liveKeys = [], exists = () => true }) {
203
+ const fish = fishOf(roster).map((m) => ({ ...m, live: liveKeys.includes(m.key) }))
204
+ const bound = []
205
+ for (const [member, raw] of Object.entries(pins ?? {})) {
206
+ const list = Array.isArray(raw) ? raw : raw ? [raw] : []
207
+ for (const id of list) {
208
+ if (typeof id !== 'string') continue
209
+ bound.push({ member, sessionId: id, exists: Boolean(exists(id)) })
210
+ }
211
+ }
212
+ return { members: fish, pins: { ...(pins ?? {}) }, bound }
213
+ }
214
+
215
+ /** 面板上写短一点:`session-ab12cd34`。完整 id 太长,卡片一行放不下。 */
216
+ export function shortSessionId(id) {
217
+ const text = sessionIdOf(id)
218
+ if (!text) return ''
219
+ return text.length <= 17 ? text : `${text.slice(0, 17)}…`
220
+ }
221
+
222
+ /**
223
+ * 这条鱼家里有哪些会话(只认目录名,不读内容)。
224
+ * 返回 [{ id, project, mtimeMs }],按 mtime 倒序;同一 id 出现在多个项目目录时只留一条。
225
+ */
226
+ export function sessionsInHome(home) {
227
+ if (!home || !existsSync(home)) return []
228
+ const root = join(home, 'sessions')
229
+ if (!existsSync(root)) return []
230
+ const seen = new Map()
231
+ let projects = []
232
+ try {
233
+ projects = readdirSync(root, { withFileTypes: true })
234
+ } catch {
235
+ return []
236
+ }
237
+ for (const project of projects) {
238
+ if (!project.isDirectory()) continue
239
+ let entries = []
240
+ try {
241
+ entries = readdirSync(join(root, project.name), { withFileTypes: true })
242
+ } catch {
243
+ continue
244
+ }
245
+ for (const entry of entries) {
246
+ if (!entry.isDirectory()) continue
247
+ const id = sessionIdOf(entry.name)
248
+ if (!id || seen.has(id)) continue
249
+ let mtimeMs = 0
250
+ try {
251
+ mtimeMs = statSync(join(root, project.name, entry.name)).mtimeMs
252
+ } catch {
253
+ mtimeMs = 0
254
+ }
255
+ seen.set(id, { id, project: project.name, mtimeMs })
256
+ }
257
+ }
258
+ return [...seen.values()].sort((a, b) => b.mtimeMs - a.mtimeMs)
259
+ }
260
+
261
+ /**
262
+ * 换绑弹窗要的一份候选表:这条鱼家里的会话 + 每一条"能不能绑、现在归谁、是不是正被挂着"。
263
+ * 判定全落在 bindingProblem 上,别在界面里另写一套。
264
+ */
265
+ export function sessionCandidatesOf({ roster, memberKey, pondRoot, pins = {}, liveSessionIds = [] }) {
266
+ const member = (roster?.members ?? roster ?? {})[memberKey]
267
+ const home = homeOfMember(member)
268
+ if (!member || !home) return { member: memberKey, home, sessions: [] }
269
+ const live = new Set(liveSessionIds)
270
+ const sessions = sessionsInHome(home).map((entry) => {
271
+ const problem = bindingProblem({ roster, memberKey, sessionId: entry.id, pondRoot })
272
+ const boundTo = findBinding(pins, entry.id)?.member ?? null
273
+ return {
274
+ id: entry.id,
275
+ short: shortSessionId(entry.id),
276
+ project: entry.project,
277
+ mtimeMs: entry.mtimeMs,
278
+ workspace: workspacePathOf(home, entry.id),
279
+ registered: workspacePathOf(home, entry.id) !== null,
280
+ eligible: problem === null,
281
+ reason: problem ? problem.message : null,
282
+ inUse: live.has(entry.id),
283
+ boundTo,
284
+ }
285
+ })
286
+ return { member: memberKey, home, sessions }
287
+ }
288
+
289
+ /** 账单里的一行。和 scripts/bind-member.mjs 的 bind/unbind 行同形,`by=` 说清是谁干的。 */
290
+ export function stateLogLine({ ts, action, memberKey, sessionId, by = 'panel' }) {
291
+ const id = sessionIdOf(sessionId) ?? String(sessionId ?? '')
292
+ return `${ts} | ${action} | fmt=1 member=${memberKey} session=${id} by=${by}`
293
+ }
package/lib/client.js CHANGED
@@ -25,6 +25,49 @@ window.__ModuleLoader__.load({
25
25
  const PANEL_ID = 'group'
26
26
  const SETTINGS_ID = 'lil-whale'
27
27
 
28
+ // 会话绑定(fi-0017):菜单要回答"这段会话现在绑给谁",数据是异步取的。
29
+ // contextMenus 的 observe 只要求 getSnapshot/subscribe,给一个可订阅的小格子就够,
30
+ // 不必把整份名册塞进组件状态里。
31
+ const bindingStore = (() => {
32
+ let value = { members: [], pins: {}, bound: [], loaded: false }
33
+ const listeners = new Set()
34
+ return {
35
+ getSnapshot: () => value,
36
+ subscribe(listener) { listeners.add(listener); return () => listeners.delete(listener) },
37
+ set(next) { value = next; for (const listener of [...listeners]) listener() },
38
+ }
39
+ })()
40
+ let bindingsFetchedAt = 0
41
+ async function loadBindings(force = false) {
42
+ if (!force && Date.now() - bindingsFetchedAt < 3000) return
43
+ try {
44
+ const res = await fetch('/group/api/bindings', { cache: 'no-store' })
45
+ if (!res.ok) return
46
+ const data = await res.json()
47
+ bindingsFetchedAt = Date.now()
48
+ bindingStore.set({
49
+ members: Array.isArray(data?.members) ? data.members : [],
50
+ pins: data?.pins && typeof data.pins === 'object' ? data.pins : {},
51
+ bound: Array.isArray(data?.bound) ? data.bound : [],
52
+ loaded: true,
53
+ })
54
+ } catch {
55
+ // 网抽风就维持上一份;loaded 还是 false 时菜单会显示"读不到名册"
56
+ }
57
+ }
58
+ async function postBinding(kind, body) {
59
+ const res = await fetch(`/group/api/${kind}`, {
60
+ method: 'POST',
61
+ headers: { 'content-type': 'application/json', 'x-llw-panel': '1' },
62
+ body: JSON.stringify(body),
63
+ })
64
+ let data = null
65
+ try { data = await res.json() } catch { /* 非 JSON 也要报状态码 */ }
66
+ if (!res.ok) throw new Error(data?.message || data?.error || `HTTP ${res.status}`)
67
+ await loadBindings(true)
68
+ return data
69
+ }
70
+
28
71
  // 宽度:两侧各留 4% 页边距,再宽就压到边框上了
29
72
  const WIDTH_MIN = 30
30
73
  const WIDTH_MAX = 92
@@ -40,8 +83,9 @@ window.__ModuleLoader__.load({
40
83
  lee: { text: '大', tint: '#4a7dbd' },
41
84
  whale: { text: '小', tint: '#c2705a' },
42
85
  fabian: { text: 'F', tint: '#5c8a6a' },
86
+ system: { text: '系', tint: '#5b6472' },
43
87
  },
44
- names: { lee: '第一条鱼', whale: '第二条鱼', fabian: '宿主' },
88
+ names: { lee: '第一条鱼', whale: '第二条鱼', fabian: '宿主', system: '系统' },
45
89
  /** 座位名:会话 id 前 6 位 → 这段会话在群里显示的名字(同一个人的第二段会话用得上)。 */
46
90
  seats: {},
47
91
  }
@@ -55,13 +99,15 @@ window.__ModuleLoader__.load({
55
99
  toAll: '所有人',
56
100
  toLee: '第一条鱼',
57
101
  toWhale: '第二条鱼',
58
- groupOnly: '在群里说(谁会醒由阀门决定)',
59
- toOne: (name) => `只有 ${name} 会被叫醒`,
102
+ groupOnly: '不叫醒任何人(消息照样在群里)',
103
+ toOne: (names) => `会叫醒:${names}`,
60
104
  typing: (names) => `${names} 正在回复…`,
61
105
  // 两档"忙",群聊私聊同一套:在回这一段(typing)/ 在别处忙(busy,可能就在另一个窗口)。
62
106
  // 宿主只给得出 reason,给不出"这句话回谁"——所以文案也只承诺到这一层。
63
107
  busy: (names) => `${names} 正在忙…`,
64
- mention: '右键 @',
108
+ mention: '右键点名叫醒',
109
+ mentionPrefix: '提到了:',
110
+ mentionAll: '所有人',
65
111
  settingsTitle: '小小肥鱼',
66
112
  settingsHint: '这些只改显示,不碰她的文件。',
67
113
  }
@@ -161,6 +207,7 @@ window.__ModuleLoader__.load({
161
207
  * 就先在 `seats` 里找座位名 —— 群里因此能分出「大肥鱼·工」和「大肥鱼·家」。
162
208
  */
163
209
  function nameOf(config, id, s) {
210
+ if (id === 'system') return '系统'
164
211
  const seat = s ? config?.seats?.[s] : ''
165
212
  if (typeof seat === 'string' && seat.trim() !== '') return seat
166
213
  return config?.names?.[id] || NAMES[id] || id
@@ -268,6 +315,27 @@ window.__ModuleLoader__.load({
268
315
  return `${nameOf(config, base)} · ${seat}`
269
316
  }
270
317
 
318
+ /**
319
+ * 「提到了谁」(2026-11-22 r413)。群消息不再有 to;叫醒名单只看 mention。
320
+ * 老记录没有 mention:只有当年指了名(to=成员)才回退显示,to=all 的广播保持原样。
321
+ * 与宿主投影(scripts/rebuild-group-md.mjs)和 messages-core.js 用同一句话。
322
+ */
323
+ function mentionNameOf(config, message) {
324
+ const mention = message?.mention
325
+ if (mention === 'all') return t.mentionAll
326
+ if (Array.isArray(mention)) {
327
+ return mention.length === 0 ? '' : mention.map((key) => targetName(config, key)).join('、')
328
+ }
329
+ const to = message?.to
330
+ // 私聊没有"提到了谁":dm 里的 to 是收件人(这间屋开给谁),不是叫醒名单。
331
+ // r419:老群消息里的 channel='dm' 是"当年 @ 定向",仍在群账本里,照旧推。
332
+ // r423:系统提示行(kind='system'、channel='dm')也在私聊那一侧;只有 kind 缺失或 say 才算群记录。
333
+ const isGroup = !message?.kind || message.kind === 'say'
334
+ // r414:老记录按当年 to 推出来的,自标"(按当年 to 推)"——推出来的得说明是推的。
335
+ if (isGroup && typeof to === 'string' && to !== '' && to !== 'all') return `${targetName(config, to)}(按当年 to 推)`
336
+ return ''
337
+ }
338
+
271
339
  const baseStyle = {
272
340
  color: 'var(--dsw-alias-label-primary)',
273
341
  fontFamily: 'inherit',
@@ -716,9 +784,10 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
716
784
  const humanId = config?.humanId ?? 'fabian'
717
785
  const mine = message.from === humanId
718
786
  const who = nameOf(config, message.from, message.s)
719
- // 指名到座位的消息,显示"→ 大肥鱼 · 日常",只写给这个人的显示"→ 大肥鱼"。
720
- const targetTo = message.toSeat ? `${message.to}@${message.toSeat}` : message.to
721
- const target = message.to && message.to !== 'all' ? ` → ${targetName(config, targetTo)}` : ''
787
+ // 提到了谁(2026-11-22 r413):新记录看 mention;老记录按 to 回退,只有当年指了名才写。
788
+ // to=all 的广播不补"所有人"——那一条当年没有点名,补上去等于改历史。
789
+ const mentionName = mentionNameOf(config, message)
790
+ const target = mentionName === '' ? '' : ` · ${t.mentionPrefix}${mentionName}`
722
791
  const time = formatStamp(message.ts)
723
792
  // 行号:引用地址。群是 messages.jsonl 的行,私聊是 pool\dm\<pair>.jsonl 的行。
724
793
  // 文件是 append-only,行号不会变;点一下复制成别人能直接引用的形状。
@@ -882,8 +951,8 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
882
951
  )
883
952
  }
884
953
 
885
- /** "@ 谁" 的小面板:一行一个成员,头像 + 名字。点「所有人」= 不指定对象。 */
886
- function AtPicker({ config, current, seats, onPick, onClose }) {
954
+ /** "@ 谁" 的小面板(2026-11-22 r413):多选,选的是"叫醒谁",不是"说给谁"。 */
955
+ function AtPicker({ config, mention, onToggle, onPickAll, onClear, onClose }) {
887
956
  const [hovered, setHovered] = useState(null)
888
957
  const boxRef = useRef(null)
889
958
  // 移出去不关;点别处才关。她自己点 @ 钮那种情况由 data-at-anchor 放行,
@@ -903,23 +972,11 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
903
972
  document.removeEventListener('keydown', onKey)
904
973
  }
905
974
  }, [onClose])
906
- // 名字下面列出座位:同一个人**真的有几段会话**时才列。
907
- // (2026-11-12 他报的"@ 按钮后面有椅子后缀":以前名册里每人一段也会列一行
908
- // `小肥鱼 · c145f6`,看着像两条鱼。一段就是常态,不列。)
909
- const rows = [{ id: 'all', label: t.toAll, plain: true }]
975
+ // 座位已废弃(2026-11-22,Fabian:`seat 字段已经废弃了`):@ 只列人和"所有人",
976
+ // 不再列椅子后缀——选了也没有新消息会带 toSeat。
977
+ const rows = [{ id: 'all', label: t.mentionAll, plain: true }]
910
978
  const memberIds = Object.keys(config?.names ?? NAMES).filter((id) => id !== (config?.humanId ?? 'fabian'))
911
- for (const member of memberIds) {
912
- rows.push({ id: member, label: nameOf(config, member) })
913
- const mine = (seats ?? []).filter((item) => item.member === member)
914
- if (mine.length < 2) continue
915
- for (const seat of mine) {
916
- rows.push({
917
- id: `${member}@${seat.prefix}`,
918
- label: config?.seats?.[seat.prefix] || `${nameOf(config, member)} · ${seat.prefix}`,
919
- indented: true,
920
- })
921
- }
922
- }
979
+ for (const member of memberIds) rows.push({ id: member, label: nameOf(config, member) })
923
980
  return h('div', {
924
981
  ref: boxRef,
925
982
  style: {
@@ -930,11 +987,13 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
930
987
  boxShadow: '0 8px 28px rgba(0,0,0,0.18)',
931
988
  },
932
989
  }, rows.map((row) => {
933
- const active = (current || 'all') === row.id
990
+ const active = row.id === 'all'
991
+ ? mention === 'all'
992
+ : (Array.isArray(mention) && mention.includes(row.id))
934
993
  const lit = active || hovered === row.id
935
994
  return h('button', {
936
995
  key: row.id,
937
- onClick: () => onPick(row.id),
996
+ onClick: () => (row.id === 'all' ? onPickAll() : onToggle(row.id)),
938
997
  onMouseDown: (event) => event.preventDefault(),
939
998
  onMouseEnter: () => setHovered(row.id),
940
999
  onMouseLeave: () => setHovered(null),
@@ -1855,9 +1914,17 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
1855
1914
  const [hasText, setHasText] = useState(() => initialTextRef.current.trim() !== '')
1856
1915
  const draftTimerRef = useRef(null)
1857
1916
  const draftValueRef = useRef(initialTextRef.current)
1858
- const [to, setTo] = useState('all')
1859
- // @ 面板选中人的回调要稳定:Bubble 是 memo 的,每次渲染新函数会让 120 个气泡全部重渲染。
1860
- const mentionTo = useCallback((id) => setTo(id), [])
1917
+ // 叫醒名单(2026-11-22 r413):'all' 或成员 id 数组;[] = 谁都不叫醒(消息仍全群可见)。
1918
+ const [mention, setMention] = useState([])
1919
+ // @ 面板 / 右键头像的回调要稳定:Bubble 是 memo 的,每次渲染新函数会让 120 个气泡全部重渲染。
1920
+ const mentionTo = useCallback((id) => {
1921
+ setMention((current) => {
1922
+ if (current === 'all') return [id]
1923
+ return current.includes(id) ? current.filter((key) => key !== id) : [...current, id]
1924
+ })
1925
+ }, [])
1926
+ const pickAll = useCallback(() => setMention('all'), [])
1927
+ const clearMention = useCallback(() => setMention([]), [])
1861
1928
  const [error, setError] = useState(null)
1862
1929
  const [sending, setSending] = useState(false)
1863
1930
  // 待发送的图(data URL)。上传在 submit 里做,这里只存"用户选了哪张"。
@@ -1974,6 +2041,10 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
1974
2041
  const pendingScrollRef = useRef(null)
1975
2042
  const pendingHistoryRef = useRef(null)
1976
2043
  const messagesSigRef = useRef('')
2044
+ // 2026-11-23 r444:线不在渲染窗口里时量不到它,但「上面还有没看过的」仍然为真。
2045
+ const messagesRef = useRef(messages)
2046
+ const visibleStartRef = useRef(0)
2047
+ messagesRef.current = messages
1977
2048
  const presenceSigRef = useRef('')
1978
2049
  const seatsSigRef = useRef('')
1979
2050
  // 发送后按内容重算高度(同 DmPage)。
@@ -1999,7 +2070,22 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
1999
2070
  const el = scrollRef.current
2000
2071
  const line = dividerRef.current
2001
2072
  // 线在视口上方 = 上面还有没看过的。
2002
- const lineAbove = Boolean(el && line && line.getBoundingClientRect().top < el.getBoundingClientRect().top + 4)
2073
+ let lineAbove = Boolean(el && line && line.getBoundingClientRect().top < el.getBoundingClientRect().top + 4)
2074
+ // 2026-11-23 r444(测试机):积压很多消息时,线根本不在渲染窗口里(只挂最近 120 条),
2075
+ // ref 是空的 ⇒ 只靠几何量永远 false,于是「要向上滚一次才出现」。
2076
+ // 线在窗口之前(未读段从更早的位置开始)本身就说明它在视口上方。
2077
+ if (!lineAbove && !line && el) {
2078
+ const seen = String(seenGroupRef.current ?? '')
2079
+ const list = messagesRef.current ?? []
2080
+ const start = visibleStartRef.current ?? 0
2081
+ if (seen && start > 0) {
2082
+ let boundary = -1
2083
+ for (let i = 0; i < list.length; i += 1) {
2084
+ if (String(list[i]?.ts ?? '') > seen) { boundary = i; break }
2085
+ }
2086
+ if (boundary >= 0 && boundary < start) lineAbove = true
2087
+ }
2088
+ }
2003
2089
  // 点过一次就不再催:往下读时线会滑出视口上沿,以前会反复把提示亮出来(第 4 条)。
2004
2090
  // 贴底时也不催:人已经看见最新的了;2026-11-17 第 2 条就是新消息比视口高、
2005
2091
  // 分割线被顶出上沿,于是"回到历史未读"又亮起来。
@@ -2253,13 +2339,14 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
2253
2339
  if (!uploaded.ok) throw new Error(result?.detail ?? `图片上传失败 HTTP ${uploaded.status}`)
2254
2340
  if (result?.image) images.push(result.image)
2255
2341
  }
2256
- const { base, seat } = splitTarget(to)
2257
2342
  const endpoint = tab === 'dm' ? '/group/api/dm' : '/group/api/send'
2258
2343
  const body = tab === 'dm'
2259
2344
  ? { text: value, ...(images.length === 0 ? {} : { images }) }
2260
2345
  : {
2261
- to: base, text: value,
2262
- ...(seat === '' ? {} : { toSeat: seat }),
2346
+ text: value,
2347
+ // mention(2026-11-22 r413):面板的 @ 只决定叫醒谁——消息仍然全群可见。
2348
+ // 不 @ 就是 [](谁都不叫醒,人和鱼同一套);「所有人」写 'all'。
2349
+ mention,
2263
2350
  ...(images.length === 0 ? {} : { images }),
2264
2351
  }
2265
2352
  const response = await fetch(endpoint, {
@@ -2283,6 +2370,12 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
2283
2370
  setHasText((inputRef.current?.value ?? '').trim() !== '')
2284
2371
  }
2285
2372
  setPendingImages([])
2373
+ // 2026-11-22(宿主报):发出去之后 @ 还留在输入框上,下一条会带着上次的叫醒名单。
2374
+ // 只在群里清;私聊没有 mention 状态(tab 复用同一个 submit)。
2375
+ if (tab === 'group') {
2376
+ setMention([])
2377
+ setPickerOpen(false)
2378
+ }
2286
2379
  await refresh()
2287
2380
  } catch (e) {
2288
2381
  // 发失败别把人刚打的字吞掉:输入框空着时把原文放回去(草稿已经按输入存过了)。
@@ -2297,7 +2390,7 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
2297
2390
  } finally {
2298
2391
  setSending(false)
2299
2392
  }
2300
- }, [to, sending, refresh, tab, pendingImages.length])
2393
+ }, [mention, sending, refresh, tab, pendingImages.length])
2301
2394
 
2302
2395
  // 两档忙:正在回这一段 / 在别处忙。群聊与私聊同一套文案。
2303
2396
  // 名单从配置(名册)来 —— 写死 lee/whale 时,新鱼的"正在忙"永远不会显示(A.32 同一个病)。
@@ -2320,6 +2413,7 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
2320
2413
  // 列表只跟消息、分割线、宽度、配置有关;输入框里的文字不是它的输入。
2321
2414
  // 只渲染最近 N 条:500+ 条时,600 个气泡每 3 秒重排一次就是卡顿的来源。
2322
2415
  const visibleStart = Math.max(0, messages.length - renderLimit)
2416
+ visibleStartRef.current = visibleStart
2323
2417
  // 打字时不能重新切片:slice 每次都是新数组,会让下面的 useMemo 依赖每帧都变,
2324
2418
  // 等于每敲一个字就重建一遍气泡元素树(2026-11-15 第二轮:他报快速输入仍卡)。
2325
2419
  const visibleMessages = useMemo(
@@ -2584,29 +2678,49 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
2584
2678
  gap: 10, padding: '10px 12px 8px',
2585
2679
  },
2586
2680
  },
2587
- to === 'all'
2588
- ? null
2589
- : h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap' } },
2681
+ mention === 'all'
2682
+ ? h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap' } },
2590
2683
  h('span', {
2591
2684
  style: {
2592
2685
  display: 'inline-flex', alignItems: 'center', gap: 6,
2593
- padding: '2px 4px 2px 2px', borderRadius: 999,
2686
+ padding: '2px 6px', borderRadius: 999,
2594
2687
  background: 'var(--dsw-alias-bg-layer-3, rgba(0,0,0,0.06))',
2595
2688
  border: '1px solid var(--dsw-alias-border-l2, rgba(0,0,0,0.1))',
2596
2689
  fontSize: 12, color: 'var(--dsw-alias-label-secondary)',
2597
2690
  },
2598
2691
  },
2599
- h(Avatar, { config, member: splitTarget(to).base, size: 18 }),
2600
- h('span', null, targetName(config, to)),
2692
+ h('span', null, `${t.mentionPrefix}${t.mentionAll}`),
2601
2693
  h('button', {
2602
- onClick: () => setTo('all'),
2603
- title: '取消指定',
2694
+ onClick: clearMention, title: '清空叫醒名单',
2604
2695
  style: {
2605
2696
  width: 16, height: 16, borderRadius: '50%', border: 'none', background: 'transparent',
2606
2697
  color: 'var(--dsw-alias-label-tertiary)', fontSize: 13, lineHeight: 1, padding: 0,
2607
2698
  display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer',
2608
2699
  },
2609
- }, '×'))),
2700
+ }, '×')))
2701
+ : mention.length === 0
2702
+ ? null
2703
+ : h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap' } },
2704
+ ...mention.map((key) => h('span', {
2705
+ key: `mention-${key}`,
2706
+ style: {
2707
+ display: 'inline-flex', alignItems: 'center', gap: 6,
2708
+ padding: '2px 4px 2px 2px', borderRadius: 999,
2709
+ background: 'var(--dsw-alias-bg-layer-3, rgba(0,0,0,0.06))',
2710
+ border: '1px solid var(--dsw-alias-border-l2, rgba(0,0,0,0.1))',
2711
+ fontSize: 12, color: 'var(--dsw-alias-label-secondary)',
2712
+ },
2713
+ },
2714
+ h(Avatar, { config, member: key, size: 18 }),
2715
+ h('span', null, nameOf(config, key)),
2716
+ h('button', {
2717
+ onClick: () => mentionTo(key), title: '不叫醒他',
2718
+ style: {
2719
+ width: 16, height: 16, borderRadius: '50%', border: 'none', background: 'transparent',
2720
+ color: 'var(--dsw-alias-label-tertiary)', fontSize: 13, lineHeight: 1, padding: 0,
2721
+ display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer',
2722
+ },
2723
+ }, '×')))),
2610
2724
  pendingImages.length > 0
2611
2725
  ? h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
2612
2726
  ...pendingImages.map((src, index) => h('div', { key: `pending-${index}`, style: { position: 'relative' } },
@@ -2680,7 +2794,7 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
2680
2794
  void submit()
2681
2795
  }
2682
2796
  },
2683
- placeholder: to === 'all' ? t.placeholder : `对 ${targetName(config, to)} 说…`,
2797
+ placeholder: t.placeholder,
2684
2798
  rows: 1,
2685
2799
  style: {
2686
2800
  border: 'none', outline: 'none', resize: 'none', background: 'transparent',
@@ -2692,7 +2806,7 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
2692
2806
  h('div', { style: { position: 'relative', display: 'flex', alignItems: 'center', gap: 10 } },
2693
2807
  h('button', {
2694
2808
  onClick: () => setPickerOpen((open) => !open),
2695
- title: '指定说话对象',
2809
+ title: '点名叫醒谁(可以多选,选所有人也行)',
2696
2810
  'data-at-anchor': '1',
2697
2811
  style: {
2698
2812
  flex: '0 0 32px', width: 32, height: 32, padding: 0, border: 'none',
@@ -2744,7 +2858,7 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
2744
2858
  },
2745
2859
  }),
2746
2860
  h('div', { style: { flex: 1, fontSize: 11, color: 'var(--dsw-alias-label-caption)' } },
2747
- to === 'all' ? t.groupOnly : t.toOne(targetName(config, to))),
2861
+ mention === 'all' ? t.toOne(t.mentionAll) : (mention.length === 0 ? t.groupOnly : t.toOne(mention.map((key) => nameOf(config, key)).join('、')))),
2748
2862
  h('button', {
2749
2863
  onClick: () => { void submit() },
2750
2864
  disabled: sending || (!hasText && pendingImages.length === 0),
@@ -2768,9 +2882,10 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
2768
2882
  pickerOpen
2769
2883
  ? h(AtPicker, {
2770
2884
  config,
2771
- seats,
2772
- current: to,
2773
- onPick: (id) => { setTo(id); setPickerOpen(false) },
2885
+ mention,
2886
+ onToggle: mentionTo,
2887
+ onPickAll: pickAll,
2888
+ onClear: clearMention,
2774
2889
  onClose: () => setPickerOpen(false),
2775
2890
  })
2776
2891
  : null,
@@ -3242,6 +3357,25 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
3242
3357
  autoStartLabel: '起主 dsh 时把鱼也带起来',
3243
3358
  autoStartHint: '下次启动主 dsh 生效:巡守起来 8 秒后按名册逐条唤醒,不开浏览器窗。关掉=只起巡守(空鱼塘,调试用)——鱼活不过主进程,没有「鱼自己单独活着」这个选项。',
3244
3359
  autoStartFailed: '开关没保存:',
3360
+ sessionLabel: '会话',
3361
+ sessionUnbound: '未绑定',
3362
+ bind: '换绑',
3363
+ bindTitle: (name) => ('换绑 ' + name + ' 的会话'),
3364
+ bindHint: '换绑后下次醒来是这段会话,原来的上下文不再续。只改 pins,重启对应进程后生效。',
3365
+ bindInputPlaceholder: '粘贴 session-…(从她的 WebUI 复制)',
3366
+ bindCandidates: '她家里的会话:',
3367
+ bindEmpty: '她家里还没有会话;先去她的 WebUI 说一句话,再回来换绑。',
3368
+ bindLoadFailed: '候选没读出来:',
3369
+ bindFailed: '换绑失败:',
3370
+ bindDone: '换绑成功',
3371
+ bindSuccessHint: '重启对应进程后才生效。',
3372
+ bindCancel: '取消',
3373
+ bindConfirm: '确认换绑',
3374
+ bindCurrent: '当前',
3375
+ bindInUseTag: '正在使用',
3376
+ bindInUseConfirm: '这段会话正在被使用;换绑后旧窗口不会自动停,可能出现两个 writer。确认要换吗?',
3377
+ bindUnregistered: '未登记工作区',
3378
+ bindBlocked: '不能绑',
3245
3379
  generation: (n) => (n <= 0 ? '根' : `第 ${n} 代`),
3246
3380
  modeText: (mode) => {
3247
3381
  const value = mode?.mode ?? null
@@ -3353,6 +3487,7 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
3353
3487
  const [result, setResult] = useState(null)
3354
3488
  const [demo, setDemo] = useState(false)
3355
3489
  const [autoStart, setAutoStart] = useState(false)
3490
+ const [bindFor, setBindFor] = useState(null)
3356
3491
 
3357
3492
  const load = useCallback(async () => {
3358
3493
  try {
@@ -3642,6 +3777,14 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
3642
3777
  `${POND.lastRun}:${item.lastRun.ts} ${item.lastRun.event}`,
3643
3778
  )
3644
3779
  : null,
3780
+ demo
3781
+ ? null
3782
+ : h(
3783
+ 'div',
3784
+ { style: { fontSize: 11, lineHeight: '16px', color: 'var(--dsw-alias-label-tertiary, #8a8f98)', display: 'flex', alignItems: 'center', gap: 6 } },
3785
+ h('span', null, POND.sessionLabel + ' ' + (item.sessionShort || POND.sessionUnbound)),
3786
+ h('button', { onClick: () => setBindFor(item), style: pondButtonStyle(false), title: POND.bindHint }, POND.bind),
3787
+ ),
3645
3788
  self
3646
3789
  ? h('div', { style: { fontSize: 11, lineHeight: '16px', color: 'var(--dsw-alias-label-tertiary, #8a8f98)' } }, POND.selfHint)
3647
3790
  : (() => {
@@ -3826,6 +3969,126 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
3826
3969
  ),
3827
3970
  )
3828
3971
  : null,
3972
+ bindFor
3973
+ ? h(BindDialog, {
3974
+ fish: bindFor,
3975
+ onClose: () => setBindFor(null),
3976
+ onDone: (message) => {
3977
+ setBindFor(null)
3978
+ setResult({ action: 'bind', key: bindFor.key, ok: true, output: message, at: Date.now() })
3979
+ void load()
3980
+ },
3981
+ })
3982
+ : null,
3983
+ )
3984
+ }
3985
+
3986
+ // 鱼塘卡片上的「换绑」:输入框 + 候选菜单;能不能绑仍由服务端 bindingProblem 判。
3987
+ // 2026-11-23(Fabian 定):只留「换绑」一个按钮;解绑没有应用场景,不进面板。
3988
+ function BindDialog(props) {
3989
+ const fish = props.fish
3990
+ const [candidates, setCandidates] = useState(null)
3991
+ const [error, setError] = useState(null)
3992
+ const [value, setValue] = useState(typeof fish?.sessionId === 'string' ? fish.sessionId : '')
3993
+ const [busy, setBusy] = useState(false)
3994
+
3995
+ useEffect(() => {
3996
+ let alive = true
3997
+ fetch('/group/api/bind-candidates?member=' + encodeURIComponent(fish.key), { headers: { accept: 'application/json' } })
3998
+ .then((response) => response.json().then((data) => ({ ok: response.ok, data })))
3999
+ .then(({ ok, data }) => {
4000
+ if (!alive) return
4001
+ if (!ok || data?.ok === false) throw new Error(data?.message || data?.error || '读候选失败')
4002
+ setCandidates(data)
4003
+ })
4004
+ .catch((e) => { if (alive) setError(POND.bindLoadFailed + String(e?.message ?? e)) })
4005
+ return () => { alive = false }
4006
+ }, [fish.key])
4007
+
4008
+ const list = candidates?.sessions ?? []
4009
+ const typed = value.trim()
4010
+ const picked = list.find((s) => s.id === typed) ?? null
4011
+ const inUse = picked?.inUse === true
4012
+
4013
+ const submit = async () => {
4014
+ setBusy(true)
4015
+ setError(null)
4016
+ try {
4017
+ const response = await fetch('/group/api/bind', {
4018
+ method: 'POST',
4019
+ headers: { 'content-type': 'application/json', 'x-llw-panel': '1' },
4020
+ body: JSON.stringify({ member: fish.key, sessionId: typed }),
4021
+ })
4022
+ const data = await response.json()
4023
+ if (!response.ok || data?.ok === false) throw new Error(data?.message || data?.error || ('HTTP ' + response.status))
4024
+ props.onDone(POND.bindDone + ':' + fish.name + ' → ' + typed.slice(0, 17) + '…。' + POND.bindSuccessHint)
4025
+ } catch (e) {
4026
+ setError(POND.bindFailed + String(e?.message ?? e))
4027
+ } finally {
4028
+ setBusy(false)
4029
+ }
4030
+ }
4031
+
4032
+ const tagsOf = (s) => {
4033
+ const tags = []
4034
+ if (s.boundTo === fish.key) tags.push(POND.bindCurrent)
4035
+ else if (s.boundTo) tags.push(s.boundTo)
4036
+ if (s.inUse) tags.push(POND.bindInUseTag)
4037
+ if (!s.registered) tags.push(POND.bindUnregistered)
4038
+ if (!s.eligible) tags.push(POND.bindBlocked)
4039
+ return tags
4040
+ }
4041
+
4042
+ return h(
4043
+ 'div',
4044
+ { style: { position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.32)', zIndex: 1000, display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 16 } },
4045
+ h(
4046
+ 'div',
4047
+ { style: { width: 'min(560px, 92vw)', maxHeight: '82vh', overflow: 'auto', background: 'var(--dsw-alias-bg-layer-1, #fff)', borderRadius: 'var(--dsw-radius-lg, 12px)', border: '0.5px solid var(--dsw-alias-border-l2, rgba(0,0,0,0.1))', padding: 16, display: 'flex', flexDirection: 'column', gap: 10 } },
4048
+ h('div', { style: { fontSize: 14, fontWeight: 600 } }, POND.bindTitle(fish.name)),
4049
+ h('div', { style: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-secondary, #6b7076)' } }, POND.bindHint),
4050
+ h('input', {
4051
+ value,
4052
+ placeholder: POND.bindInputPlaceholder,
4053
+ onChange: (event) => setValue(event.target.value),
4054
+ style: { padding: '8px 10px', fontSize: 13, borderRadius: 'var(--dsw-radius-md, 8px)', border: '0.5px solid var(--dsw-alias-border-l2, rgba(0,0,0,0.15))', background: 'transparent', color: 'inherit' },
4055
+ }),
4056
+ error ? h('div', { style: { fontSize: 12, color: 'var(--dsw-alias-label-error, #c93c40)' } }, error) : null,
4057
+ inUse ? h('div', { style: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-error, #c93c40)' } }, POND.bindInUseConfirm) : null,
4058
+ h('div', { style: { fontSize: 12, fontWeight: 600 } }, POND.bindCandidates),
4059
+ candidates === null
4060
+ ? h('div', { style: { fontSize: 12, color: 'var(--dsw-alias-label-tertiary, #8a8f98)' } }, '…')
4061
+ : list.length === 0
4062
+ ? h('div', { style: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary, #8a8f98)' } }, POND.bindEmpty)
4063
+ : h(
4064
+ 'div',
4065
+ { style: { display: 'flex', flexDirection: 'column', gap: 6 } },
4066
+ list.map((s) => h(
4067
+ 'button',
4068
+ {
4069
+ key: s.id,
4070
+ onClick: () => setValue(s.id),
4071
+ disabled: !s.eligible,
4072
+ style: {
4073
+ textAlign: 'left', padding: '6px 8px', borderRadius: 'var(--dsw-radius-md, 8px)',
4074
+ border: '0.5px solid ' + (s.id === typed ? 'var(--dsw-alias-brand-primary, #4c8dff)' : 'var(--dsw-alias-border-l2, rgba(0,0,0,0.12))'),
4075
+ background: 'transparent', color: 'inherit', fontSize: 12, lineHeight: '18px',
4076
+ cursor: s.eligible ? 'pointer' : 'not-allowed', opacity: s.eligible ? 1 : 0.6,
4077
+ },
4078
+ },
4079
+ h('span', { style: { fontWeight: 600 } }, s.short),
4080
+ s.workspace ? h('span', { style: { marginLeft: 6, color: 'var(--dsw-alias-label-tertiary, #8a8f98)' } }, s.workspace) : null,
4081
+ tagsOf(s).length ? h('span', { style: { marginLeft: 6, color: 'var(--dsw-alias-label-tertiary, #8a8f98)' } }, '(' + tagsOf(s).join('、') + ')') : null,
4082
+ s.eligible ? null : h('div', { style: { marginTop: 2, color: 'var(--dsw-alias-label-tertiary, #8a8f98)' } }, s.reason || POND.bindBlocked),
4083
+ )),
4084
+ ),
4085
+ h(
4086
+ 'div',
4087
+ { style: { display: 'flex', gap: 8, justifyContent: 'flex-end' } },
4088
+ h('button', { onClick: props.onClose, style: pondButtonStyle(false) }, POND.bindCancel),
4089
+ h('button', { onClick: () => { void submit() }, disabled: busy || !typed, style: pondButtonStyle(true) }, busy ? POND.pending : POND.bindConfirm),
4090
+ ),
4091
+ ),
3829
4092
  )
3830
4093
  }
3831
4094
 
@@ -3833,7 +4096,7 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
3833
4096
  inject: ['slots'],
3834
4097
  apply(ctx) {
3835
4098
  // 一行"我跑的是哪一版"的自报,方便判断浏览器是不是还在用旧 bundle
3836
- console.info('[dsh-lil-whale-group-ui] client build v57 · image-picker-files:', Object.keys(MARKDOWN_LABELS).join(','))
4099
+ console.info('[dsh-lil-whale-group-ui] client build v66 · history-hint-backlog:', Object.keys(MARKDOWN_LABELS).join(','))
3837
4100
  // 「正在回复…」那三个点的呼吸动画 + 过场转圈。只在浏览器里注入一次。
3838
4101
  if (typeof document !== 'undefined' && !document.getElementById('dsh-lil-whale-group-keyframes')) {
3839
4102
  const style = document.createElement('style')
@@ -3843,6 +4106,7 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
3843
4106
  }
3844
4107
 
3845
4108
  void loadConfig()
4109
+ void loadBindings(true)
3846
4110
 
3847
4111
  ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
3848
4112
  name: 'sidebar.panellist',
package/lib/index.js CHANGED
@@ -13,9 +13,10 @@ import { Socket } from 'node:net'
13
13
  import { fileURLToPath } from 'node:url'
14
14
  import { createRequire } from 'node:module'
15
15
  import { config } from './config.js'
16
- import { parseMessageLines } from './messages-core.js'
16
+ import { parseMessageLines, mentionLabelOf } from './messages-core.js'
17
17
  import { presenceReasonOf } from './presence-core.js'
18
18
  import { newerThan, latestReleaseOf, LATEST_RELEASE_API } from './version-core.js'
19
+ import { bindingProblem, unbindProblem, applyBind, applyUnbind, bindingsView, sessionExistsInHome, fishOf, stateLogLine, sessionCandidatesOf, shortSessionId } from './bindings-core.js'
19
20
 
20
21
  export const name = '@fabianactor/dsh-lil-whale-group-ui'
21
22
  export const inject = ['webServer', 'agents']
@@ -42,6 +43,44 @@ const UI_CONFIG = join(GROUP_DIR, 'ui-config.json')
42
43
  // 「看到哪儿了」的游标:只在面板里看,不影响她那边读群的游标
43
44
  const UI_READ = join(GROUP_DIR, 'ui-read.json')
44
45
  const PINS = join(GROUP_DIR, 'pins.json')
46
+ // 名册原文:绑定要判 home / dshHome,面板那份 MEMBERS 只留了名字与角色(够显示、不够判定)。
47
+ const MEMBERS_FILE = config().membersFile || join(config().poolDir || join(GROUP_DIR, '..'), 'members.json')
48
+
49
+ function readPinsFile() {
50
+ try { return JSON.parse(readFileSync(PINS, 'utf8')) } catch { return {} }
51
+ }
52
+ function readRosterFile() {
53
+ try { return JSON.parse(readFileSync(MEMBERS_FILE, 'utf8')) } catch { return { members: {} } }
54
+ }
55
+ function writeJsonAtomic(file, value) {
56
+ const tmp = `${file}.tmp-${process.pid}-${Date.now()}`
57
+ writeFileSync(tmp, JSON.stringify(value, null, 2) + '\n', 'utf8')
58
+ renameSync(tmp, file)
59
+ }
60
+ function nowStamp() {
61
+ const d = new Date()
62
+ const pad = (n) => String(n).padStart(2, '0')
63
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
64
+ }
65
+ function liveFishKeys() {
66
+ const out = []
67
+ for (const key of Object.keys(MEMBERS)) {
68
+ try {
69
+ const beat = JSON.parse(readFileSync(join(PRESENCE_DIR, `${key}.json`), 'utf8'))
70
+ if (Date.now() - (Number(beat?.at) || 0) <= PRESENCE_FRESH_MS) out.push(key)
71
+ } catch { /* 没心跳 = 没启动 */ }
72
+ }
73
+ return out
74
+ }
75
+ /** 面板要的一份绑定视图(鱼 + pins + 每段会话还在不在盘上)。 */
76
+ function bindingsPayload() {
77
+ const roster = readRosterFile()
78
+ const pins = readPinsFile()
79
+ const homes = new Map(fishOf(roster).map((f) => [f.key, f.dshHome]))
80
+ const view = bindingsView({ roster, pins, liveKeys: liveFishKeys() })
81
+ view.bound = view.bound.map((b) => ({ ...b, exists: sessionExistsInHome(homes.get(b.member), b.sessionId) }))
82
+ return view
83
+ }
45
84
  // 跨进程心跳:dsh-lil-whale-group 插件在各自那个进程里每 5 秒写一份 `state\presence\<成员>.json`。
46
85
  // 面板要显示"小肥鱼 正在回复",只能读这个 —— 这个进程里的 ctx.agents 只有大肥鱼自己的会话。
47
86
  const POOL_STATE = config().poolStateDir || join(GROUP_DIR, '..', 'state')
@@ -448,11 +487,21 @@ function writeUiRead(next) {
448
487
  }
449
488
  }
450
489
 
490
+ function wakesHuman(message) {
491
+ // 2026-11-22 r413:群消息不再写 to,叫醒名单只看 mention。
492
+ // 老记录没有 mention:按老规则读——to=all 是广播、to=fabian 是点名叫他。
493
+ const mention = message.mention
494
+ if (mention === 'all') return true
495
+ if (Array.isArray(mention)) return mention.includes(HUMAN_ID)
496
+ if (mention !== undefined) return false
497
+ return message.to === 'all' || message.to === HUMAN_ID
498
+ }
499
+
451
500
  function countUnread(file, since, scope = 'all') {
452
501
  return readMessages(file).filter((message) => {
453
502
  if (message.from === HUMAN_ID) return false
454
503
  if (String(message.ts ?? '') <= since) return false
455
- if (scope === 'mentions' && message.to !== 'all' && message.to !== HUMAN_ID) return false
504
+ if (scope === 'mentions' && !wakesHuman(message)) return false
456
505
  return true
457
506
  }).length
458
507
  }
@@ -724,6 +773,8 @@ function writePondSettings(payload) {
724
773
 
725
774
  async function pondStatus() {
726
775
  const members = pondMembers()
776
+ // 卡片上要显示"这段会话绑给谁了":pins 只读一次,六条鱼共用它。
777
+ const pins = readPinsFile()
727
778
  const fish = []
728
779
  for (const [key, member] of Object.entries(members)) {
729
780
  if (member?.kind !== 'fish') continue
@@ -731,6 +782,7 @@ async function pondStatus() {
731
782
  const [portOpen] = await Promise.all([tcpOpen(port)])
732
783
  const run = lastRunOf(key)
733
784
  const presence = presenceOf(key)
785
+ const boundList = Array.isArray(pins?.[key]) ? pins[key] : pins?.[key] ? [pins[key]] : []
734
786
  fish.push({
735
787
  key,
736
788
  name: typeof member?.name === 'string' ? member.name : key,
@@ -749,6 +801,8 @@ async function pondStatus() {
749
801
  mode: modeOf(key),
750
802
  sleep: sleepOf(key),
751
803
  canManage: member?.role !== 'watcher',
804
+ sessionId: boundList[0] ?? null,
805
+ sessionShort: boundList[0] ? shortSessionId(boundList[0]) : null,
752
806
  url: portOpen ? pondUrlOf(member) : null,
753
807
  })
754
808
  }
@@ -1142,6 +1196,108 @@ export function apply(ctx) {
1142
1196
  sendJson(res, 200, { seats })
1143
1197
  },
1144
1198
  }))
1199
+ // ---------- 绑定(fi-0017,2026-11-23) ----------
1200
+ // GET /group/api/bindings → 鱼列表 + pins + 每段被绑会话还在不在盘上
1201
+ // POST /group/api/bind {member,sessionId} → 换绑(同一段会话只归一个人)
1202
+ // POST /group/api/unbind {member,sessionId} → 解绑(pins=[],members.sessionId='')
1203
+ // 菜单只是最后一个入口;判断与写入形状在 bindings-core.js,命令行/路由共用同一套规则。
1204
+ disposers.push(ctx.webServer.register({
1205
+ kind: 'exact',
1206
+ path: '/group/api/bindings',
1207
+ handler(req, res) {
1208
+ if (req.method !== 'GET') return sendJson(res, 405, { error: 'method-not-allowed' })
1209
+ sendJson(res, 200, bindingsPayload())
1210
+ },
1211
+ }))
1212
+
1213
+ // 换绑弹窗的候选:某条鱼家里的会话,逐条说清能不能绑、现在归谁、是不是正被挂着。
1214
+ // 判定仍走 bindingProblem(和菜单/命令行同一套),界面不再自己写规则。
1215
+ disposers.push(ctx.webServer.register({
1216
+ kind: 'exact',
1217
+ path: '/group/api/bind-candidates',
1218
+ handler(req, res) {
1219
+ if (req.method !== 'GET') return sendJson(res, 405, { error: 'method-not-allowed' })
1220
+ const url = new URL(req.url ?? '/', 'http://127.0.0.1')
1221
+ const member = (url.searchParams.get('member') ?? '').trim()
1222
+ const roster = readRosterFile()
1223
+ const pins = readPinsFile()
1224
+ const pondRoot = join(config().poolDir || join(GROUP_DIR, '..'), '..')
1225
+ const live = []
1226
+ try {
1227
+ for (const agent of ctx.agents.list()) {
1228
+ const id = agent?.session?.header?.id
1229
+ if (typeof id === 'string' && id) live.push(id)
1230
+ }
1231
+ } catch { /* 拿不到就只报"在不在盘上",不猜 */ }
1232
+ const out = sessionCandidatesOf({ roster, memberKey: member, pondRoot, pins, liveSessionIds: live })
1233
+ sendJson(res, 200, { ok: true, ...out })
1234
+ },
1235
+ }))
1236
+
1237
+ const bindingAction = async (req, res, kind, path) => {
1238
+ if (!guardWrite(req, res, path)) return
1239
+ if (req.method !== 'POST') return sendJson(res, 405, { error: 'method-not-allowed' })
1240
+ let payload
1241
+ try {
1242
+ payload = JSON.parse(await readBody(req))
1243
+ } catch {
1244
+ return sendJson(res, 400, { error: 'bad-json' })
1245
+ }
1246
+ const member = typeof payload?.member === 'string' ? payload.member.trim() : ''
1247
+ const sessionId = typeof payload?.sessionId === 'string' ? payload.sessionId.trim() : ''
1248
+ const roster = readRosterFile()
1249
+ const pins = readPinsFile()
1250
+ const problem = kind === 'bind'
1251
+ ? bindingProblem({ roster, memberKey: member, sessionId, pondRoot: join(config().poolDir || join(GROUP_DIR, '..'), '..') })
1252
+ : unbindProblem({ pins, memberKey: member, sessionId })
1253
+ if (problem) {
1254
+ return sendJson(res, problem.status, {
1255
+ error: problem.error,
1256
+ message: problem.message,
1257
+ hint: kind === 'bind' ? '要绑别的会话:先在 fish.ps1 sessions <鱼> 里看候选' : '这段会话现在没绑着,不用解',
1258
+ })
1259
+ }
1260
+ const nextPins = kind === 'bind' ? applyBind(pins, member, sessionId) : applyUnbind(pins, member)
1261
+ try {
1262
+ writeJsonAtomic(PINS, nextPins)
1263
+ let touched = false
1264
+ const members = roster?.members ?? {}
1265
+ if (kind === 'bind') {
1266
+ for (const [key, m] of Object.entries(members)) {
1267
+ if (!m) continue
1268
+ if (key === member) {
1269
+ if (m.sessionId !== sessionId) { m.sessionId = sessionId; touched = true }
1270
+ } else if (m.sessionId === sessionId) {
1271
+ m.sessionId = ''
1272
+ touched = true
1273
+ }
1274
+ }
1275
+ } else if (members[member] && members[member].sessionId === sessionId) {
1276
+ members[member].sessionId = ''
1277
+ touched = true
1278
+ }
1279
+ if (touched) writeJsonAtomic(MEMBERS_FILE, roster)
1280
+ } catch (error) {
1281
+ return sendJson(res, 500, { error: 'write-failed', detail: String(error?.message ?? error) })
1282
+ }
1283
+ try {
1284
+ appendFileSync(join(POOL_STATE, 'fish.log'), stateLogLine({ ts: nowStamp(), action: kind, memberKey: member, sessionId, by: 'panel' }) + '\n', 'utf8')
1285
+ } catch { /* 记账失败不拦正确动作 */ }
1286
+ sendJson(res, 200, { ok: true, action: kind, ...bindingsPayload() })
1287
+ }
1288
+
1289
+ disposers.push(ctx.webServer.register({
1290
+ kind: 'exact',
1291
+ path: '/group/api/bind',
1292
+ handler(req, res) { return bindingAction(req, res, 'bind', '/group/api/bind') },
1293
+ }))
1294
+
1295
+ disposers.push(ctx.webServer.register({
1296
+ kind: 'exact',
1297
+ path: '/group/api/unbind',
1298
+ handler(req, res) { return bindingAction(req, res, 'unbind', '/group/api/unbind') },
1299
+ }))
1300
+
1145
1301
  // ---------- 群图片 ----------
1146
1302
  // GET ?id=<16hex>&ext=png → 图片字节(内容哈希当 id,所以可以永久缓存)
1147
1303
  // POST { dataUrl } → { id, ext, bytes, month },前端拿到后再调 /group/api/send 带 image
@@ -1228,7 +1384,6 @@ export function apply(ctx) {
1228
1384
  return
1229
1385
  }
1230
1386
  const text = typeof payload?.text === 'string' ? payload.text.trim() : ''
1231
- const to = payload?.to
1232
1387
  // 图片(可选,最多 4 张):[{ id, ext, bytes, month, path }],由 /group/api/image 先上传拿到。
1233
1388
  // 2026-11-15:面板支持多图;记录里 1 张仍写 image、多张写 images(老读者不受影响)。
1234
1389
  let images = []
@@ -1242,33 +1397,53 @@ export function apply(ctx) {
1242
1397
  sendJson(res, 400, { error: 'empty-message', detail: '至少要有文字或一张图片' })
1243
1398
  return
1244
1399
  }
1245
- // 收信人从名册校验,不再写死三条 —— 2026-11-12 19:59 现场:fishball 被这里挡住,
1400
+ // 2026-11-22 r413:群消息不再写 to,叫醒谁只看 mention。
1401
+ // 面板发话的人就是 Fabian;不 @ 就是 [](谁都不叫醒,消息仍全群可见)。
1402
+ // mention 从名册校验,不再写死三条 —— 2026-11-12 19:59 现场:fishball 被这里挡住,
1246
1403
  // 面板回 bad-target,看着像"她不在群里",其实是名单又抄了一份(A.32 同一个病)。
1247
- if (to !== 'all' && !Object.prototype.hasOwnProperty.call(MEMBERS, to)) {
1248
- sendJson(res, 400, { error: 'bad-target' })
1404
+ const rawMention = payload?.mention
1405
+ let mention
1406
+ if (rawMention === undefined) {
1407
+ // 兼容旧面板缓存:它还按 to 发。映射一次,下一版删掉这条分支。
1408
+ const legacyTo = payload?.to
1409
+ mention = legacyTo === 'all'
1410
+ ? 'all'
1411
+ : (typeof legacyTo === 'string' && legacyTo !== '' ? [legacyTo] : [])
1412
+ } else if (rawMention === 'all') {
1413
+ mention = 'all'
1414
+ } else if (Array.isArray(rawMention)) {
1415
+ mention = rawMention.filter((key) => typeof key === 'string' && key !== '')
1416
+ } else {
1417
+ sendJson(res, 400, { error: 'bad-mention' })
1249
1418
  return
1250
1419
  }
1420
+ if (Array.isArray(mention)) {
1421
+ const unknown = mention.filter((key) => !Object.prototype.hasOwnProperty.call(MEMBERS, key))
1422
+ if (unknown.length > 0) {
1423
+ sendJson(res, 400, { error: 'bad-mention', detail: `不认识的成员:${unknown.join('、')}` })
1424
+ return
1425
+ }
1426
+ }
1251
1427
  const now = new Date()
1252
- // toSeat(可选):指名这个人的哪一段会话收(6 位十六进制)。不填 = 叫这个人,谁空谁应。
1253
- const rawSeat = typeof payload?.toSeat === 'string' ? payload.toSeat.trim() : ''
1254
- const toSeat = /^[0-9a-f]{6}$/.test(rawSeat) ? rawSeat : ''
1255
1428
  // s = 谁发的:'ui' 表示从面板发的(他没有会话 id)。跟 group_say 写的 s=<会话前6位> 是同一个字段。
1256
1429
  const record = {
1257
1430
  // 2026-11-16:s 只放会话号前 6 位;面板发的话没有"那段会话",所以不写这个字段
1258
- // (旧记录里的 s=ui/watch 是历史遗留,纸上已写分界)。
1259
- ts: now.toISOString(), from: HUMAN_ID, to, text, kind: 'say',
1260
- ...(toSeat === '' ? {} : { toSeat }),
1431
+ // (旧记录里的 s=ui/watch 是历史遗留,纸上已写分界)。
1432
+ ts: now.toISOString(), from: HUMAN_ID, text, kind: 'say', channel: 'group',
1433
+ // 叫醒谁(2026-11-22 r413):空数组 = 谁都不叫醒。群消息不再写 to / toSeat。
1434
+ // channel=group 与宿主 say() 写出来的记录保持同一形状——少这个字段,读端就得猜"没有 channel 算哪间屋"。
1435
+ mention,
1261
1436
  ...(images.length === 0 ? {} : (images.length === 1 ? { image: images[0] } : { images })),
1262
1437
  }
1263
1438
  try {
1264
1439
  // 宿主 say() 会先 ensureDir;面板这条路以前没建目录,group 被清掉后第一条消息 500。
1265
1440
  mkdirSync(GROUP_DIR, { recursive: true })
1266
1441
  appendFileSync(MESSAGES, JSON.stringify(record) + '\n', 'utf8')
1267
- // 投影格式必须和宿主 say() 逐字一致(2026-11-12 19:46 起:指名时写「时间 · 谁 → 收信人」)。
1268
- // 收信人写在投影里,是为了让"读记录"的人知道这条是在对谁说话——不写,指名和公开在纸上一样。
1442
+ // 投影格式必须和宿主 say() 逐字一致(2026-11-22 r413:`时间 · 谁 · 提到了:X`,空名单不写)。
1269
1443
  const body = readableBodyWithImages(text, images)
1270
- const toLabel = to !== '' && to !== 'all' ? ` → ${LABEL[to] ?? to}` : ''
1271
- appendFileSync(READABLE, `**${stamp(now)} · ${LABEL[HUMAN_ID] ?? HUMAN_ID}${toLabel}**\n\n${body}\n\n`, 'utf8')
1444
+ const mentionName = mentionLabelOf(record, (key) => LABEL[key] ?? key)
1445
+ const mentionPart = mentionName === '' ? '' : ` · 提到了:${mentionName}`
1446
+ appendFileSync(READABLE, `**${stamp(now)} · ${LABEL[HUMAN_ID] ?? HUMAN_ID}${mentionPart}**\n\n${body}\n\n`, 'utf8')
1272
1447
  } catch (error) {
1273
1448
  sendJson(res, 500, { error: 'write-failed', detail: String(error?.message ?? error) })
1274
1449
  return
@@ -8,7 +8,7 @@
8
8
  // 只靠静态断言证明"代码里写了这件事",测不到"空行/坏行时行号对不对"。
9
9
 
10
10
  export function projectMessage(record) {
11
- // 投影要带全:面板靠这些字段画图、画「→ 某人的哪一段」、判断私聊/群。早先只留了
11
+ // 投影要带全:面板靠这些字段画图、画「提到了谁」、判断私聊/群。早先只留了
12
12
  // ts/from/to/text/kind,结果她发的图在面板里根本不显示 —— 记录里有、列表里没有。
13
13
  const out = {
14
14
  ts: record.ts,
@@ -20,11 +20,40 @@ export function projectMessage(record) {
20
20
  if (record.s) out.s = record.s
21
21
  if (record.channel) out.channel = record.channel
22
22
  if (record.toSeat) out.toSeat = record.toSeat
23
+ // 2026-11-22 r413:叫醒名单。新记录一定有;老记录没有(面板按 to 回退显示)。
24
+ if (record.mention !== undefined) out.mention = record.mention
23
25
  if (record.image) out.image = record.image
24
26
  if (Array.isArray(record.images) && record.images.length > 0) out.images = record.images
25
27
  return out
26
28
  }
27
29
 
30
+ /**
31
+ * 「提到了谁」的显示文案(纯函数,面板与投影共用)。
32
+ * mention = 'all' → 所有人;数组 → 名字;空数组 → ''(这一节不写)。
33
+ * 老记录没有 mention:只有当年指了名(to=某人)才推;to=all 的广播不补(不改历史)。
34
+ * 拆出来是为了两处用同一句话:记录投影(群.md)与面板气泡。
35
+ */
36
+ export function mentionLabelOf(record, labelOf) {
37
+ const say = (key) => (typeof labelOf === 'function' ? labelOf(key) : key)
38
+ const mention = record?.mention
39
+ if (mention === 'all') return '所有人'
40
+ if (Array.isArray(mention)) return mention.map(say).join('、')
41
+ const to = record?.to
42
+ // 私聊没有"提到了谁"这回事:dm 记录里的 to 是"这间屋开给谁"(收件人),不是叫醒名单。
43
+ // 2026-11-22 修:私聊气泡全部冒出「(按当年 to 推)」就是这个回退没分屋造成的。
44
+ // 2026-11-23 修(r419):老群消息里 channel='dm' 是"当年 @ 定向",它仍在群账本里、
45
+ // 也该显示;分屋只认 kind='dm'(私聊),不认 channel='dm'。
46
+ // 2026-11-23 修(r423):系统提示行是 kind='system'、channel='dm',也在私聊那一侧。
47
+ // 判"这是群消息吗"比列举"哪些是私聊"更稳:只有 kind 缺失或 kind='say' 才按群记录回退。
48
+ const isGroup = !record?.kind || record.kind === 'say'
49
+ // 老记录:只有当年指了名(to 是某个成员)才显示;to=all 的广播保持原样,
50
+ // 补一句"提到了:所有人"等于替它改历史(2026-11-22 r413 的取舍)。
51
+ // r414:当年 to 的含义是"这话给谁",不是"谁被叫醒"——推出来的必须自标门牌,
52
+ // 否则下一个人会拿它当读数(小肥鱼 2026-11-22 20:14 的提议)。
53
+ if (isGroup && typeof to === 'string' && to !== '' && to !== 'all') return `${say(to)}(按当年 to 推)`
54
+ return ''
55
+ }
56
+
28
57
  export function parseMessageLines(text) {
29
58
  const out = []
30
59
  let lineNo = 0
package/package.json CHANGED
@@ -1,51 +1,51 @@
1
- {
2
- "name": "@fabianactor/dsh-lil-whale-group-ui",
3
- "version": "1.12.3",
4
- "type": "module",
5
- "description": "群聊页面:侧边栏一个图标,点开是三条鱼的群(读写 lil-whale\\group\\messages.jsonl)",
6
- "author": "Fabian",
7
- "license": "MIT",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/FabianActor/dsh-lil-whale.git",
11
- "directory": "plugin/dsh-lil-whale-group-ui"
12
- },
13
- "keywords": [
14
- "dsh",
15
- "dsh-plugin",
16
- "deepseek-harness",
17
- "group-chat",
18
- "web-ui"
19
- ],
20
- "engines": {
21
- "dsh": ">=0.2.2-rc.1"
22
- },
23
- "publishConfig": {
24
- "access": "public"
25
- },
26
- "exports": {
27
- ".": "./lib/index.js",
28
- "./client": "./lib/client.js",
29
- "./package.json": "./package.json",
30
- "./locale/*": "./locale/*"
31
- },
32
- "files": [
33
- "lib/*.js",
34
- "cordis.patch.yml",
35
- "icon.png",
36
- "locale"
37
- ],
38
- "dsh": {
39
- "bundle": {
40
- "patch": "./cordis.patch.yml"
41
- },
42
- "client": {
43
- "platform": "web",
44
- "immediately": true,
45
- "inject": [
46
- "@deepseek-ai/dsh-client-ui-primitives"
47
- ]
48
- }
49
- },
50
- "icon": "icon.png"
51
- }
1
+ {
2
+ "name": "@fabianactor/dsh-lil-whale-group-ui",
3
+ "version": "1.13.0",
4
+ "type": "module",
5
+ "description": "群聊页面:侧边栏一个图标,点开是三条鱼的群(读写 lil-whale\\group\\messages.jsonl)",
6
+ "author": "Fabian",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/FabianActor/dsh-lil-whale.git",
11
+ "directory": "plugin/dsh-lil-whale-group-ui"
12
+ },
13
+ "keywords": [
14
+ "dsh",
15
+ "dsh-plugin",
16
+ "deepseek-harness",
17
+ "group-chat",
18
+ "web-ui"
19
+ ],
20
+ "engines": {
21
+ "dsh": ">=0.2.2-rc.1"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "exports": {
27
+ ".": "./lib/index.js",
28
+ "./client": "./lib/client.js",
29
+ "./package.json": "./package.json",
30
+ "./locale/*": "./locale/*"
31
+ },
32
+ "files": [
33
+ "lib/*.js",
34
+ "cordis.patch.yml",
35
+ "icon.png",
36
+ "locale"
37
+ ],
38
+ "dsh": {
39
+ "bundle": {
40
+ "patch": "./cordis.patch.yml"
41
+ },
42
+ "client": {
43
+ "platform": "web",
44
+ "immediately": true,
45
+ "inject": [
46
+ "@deepseek-ai/dsh-client-ui-primitives"
47
+ ]
48
+ }
49
+ },
50
+ "icon": "icon.png"
51
+ }