dsh-gufa-code 1.3.68 → 1.3.69
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 +167 -1
- package/desktop/float/bin/gufa-float-macos-arm64 +0 -0
- package/desktop/float/bin/gufa-float-macos-universal +0 -0
- package/desktop/float/bin/gufa-float-macos-x64 +0 -0
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/Info.plist +2 -2
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/MacOS/gufa-float +0 -0
- package/package.json +1 -1
- package/src/client/60-dock.js +166 -0
package/client.js
CHANGED
|
@@ -16,7 +16,7 @@ const GUFA_NS = 'gufa-code'
|
|
|
16
16
|
const G = {}
|
|
17
17
|
G.NS = GUFA_NS
|
|
18
18
|
/** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
|
|
19
|
-
G.BUILD = '1.3.
|
|
19
|
+
G.BUILD = '1.3.69'
|
|
20
20
|
G.PANEL_ID = 'gufa-code'
|
|
21
21
|
/** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
|
|
22
22
|
G.pendingEntryWorkspace = null
|
|
@@ -9259,6 +9259,162 @@ function gufaPlaceDockedConversation(root, host, options) {
|
|
|
9259
9259
|
return true
|
|
9260
9260
|
}
|
|
9261
9261
|
|
|
9262
|
+
/**
|
|
9263
|
+
* 停靠后的官方会话「贴底跟随」守护。
|
|
9264
|
+
*
|
|
9265
|
+
* 官方会话自己有一套 follow 策略(ChatView root 上的 `data-chat-following-tail` 属性),
|
|
9266
|
+
* 但在 fixed 停靠 + 频繁重排/ResizeObserver 的容器里,偶发出现「发起聊天后滚动条不在最下面」。
|
|
9267
|
+
* 这里只在官方自己认为处于「跟随尾部」时补一次贴底(以及刚发送消息后的 2.5s 内),
|
|
9268
|
+
* 用户主动滚动/官方取消跟随时绝不抢滚动条。
|
|
9269
|
+
*/
|
|
9270
|
+
function gufaCreateChatFollowKeeper() {
|
|
9271
|
+
let scroller = null
|
|
9272
|
+
let observer = null
|
|
9273
|
+
let resizeObserver = null
|
|
9274
|
+
let interval = null
|
|
9275
|
+
let frame = 0
|
|
9276
|
+
let retryTimer = 0
|
|
9277
|
+
let forceUntil = 0
|
|
9278
|
+
let diagnosticsLeft = 24
|
|
9279
|
+
const diag = (message) => {
|
|
9280
|
+
if (diagnosticsLeft <= 0) return
|
|
9281
|
+
diagnosticsLeft -= 1
|
|
9282
|
+
try {
|
|
9283
|
+
void G.api('dev.log', { message: `chat-follow ${message}` }).catch(() => {})
|
|
9284
|
+
} catch {
|
|
9285
|
+
/* ignore */
|
|
9286
|
+
}
|
|
9287
|
+
}
|
|
9288
|
+
|
|
9289
|
+
const hasFollowAttr = () => {
|
|
9290
|
+
try {
|
|
9291
|
+
return scroller !== null && scroller.isConnected && scroller.querySelector('[data-chat-following-tail]') !== null
|
|
9292
|
+
} catch {
|
|
9293
|
+
return false
|
|
9294
|
+
}
|
|
9295
|
+
}
|
|
9296
|
+
const shouldFollow = () => hasFollowAttr() || Date.now() < forceUntil
|
|
9297
|
+
const toBottom = () => {
|
|
9298
|
+
if (scroller === null || !scroller.isConnected) return
|
|
9299
|
+
try {
|
|
9300
|
+
const max = scroller.scrollHeight - scroller.clientHeight
|
|
9301
|
+
if (max <= 0) return
|
|
9302
|
+
if (scroller.scrollTop < max - 2) scroller.scrollTop = max
|
|
9303
|
+
} catch {
|
|
9304
|
+
/* ignore */
|
|
9305
|
+
}
|
|
9306
|
+
}
|
|
9307
|
+
const hasRoom = () => {
|
|
9308
|
+
if (scroller === null || !scroller.isConnected) return false
|
|
9309
|
+
return scroller.scrollHeight - scroller.clientHeight > 1
|
|
9310
|
+
}
|
|
9311
|
+
const pump = () => {
|
|
9312
|
+
frame = 0
|
|
9313
|
+
if (document.visibilityState !== 'visible') return
|
|
9314
|
+
if (!shouldFollow()) return
|
|
9315
|
+
const before = Math.round(scroller.scrollTop)
|
|
9316
|
+
const max = Math.round(scroller.scrollHeight - scroller.clientHeight)
|
|
9317
|
+
if (scroller.scrollTop < max - 2) diag(`pump top=${before} max=${max} follow=${hasFollowAttr()} force=${Date.now() < forceUntil}`)
|
|
9318
|
+
toBottom()
|
|
9319
|
+
/* 流式内容/折叠动画/图片加载会分几帧改变高度:短时间重试几次 */
|
|
9320
|
+
if (retryTimer !== 0) window.clearTimeout(retryTimer)
|
|
9321
|
+
retryTimer = window.setTimeout(() => {
|
|
9322
|
+
retryTimer = 0
|
|
9323
|
+
if (shouldFollow() && hasRoom()) toBottom()
|
|
9324
|
+
}, 120)
|
|
9325
|
+
}
|
|
9326
|
+
const schedule = () => {
|
|
9327
|
+
if (frame !== 0) return
|
|
9328
|
+
frame = window.requestAnimationFrame(pump)
|
|
9329
|
+
}
|
|
9330
|
+
const onWheel = () => { forceUntil = 0 }
|
|
9331
|
+
const onKeyDown = (event) => {
|
|
9332
|
+
if (event.key !== 'Enter' || event.shiftKey === true || event.isComposing === true) return
|
|
9333
|
+
try {
|
|
9334
|
+
if (event.target instanceof Element && event.target.closest('[data-composer-input], [data-composer-seat]') !== null) {
|
|
9335
|
+
forceUntil = Date.now() + 2500
|
|
9336
|
+
schedule()
|
|
9337
|
+
}
|
|
9338
|
+
} catch {
|
|
9339
|
+
/* ignore */
|
|
9340
|
+
}
|
|
9341
|
+
}
|
|
9342
|
+
const onPointerDown = (event) => {
|
|
9343
|
+
try {
|
|
9344
|
+
if (event.target instanceof Element && event.target.closest('[data-composer-seat]') !== null) {
|
|
9345
|
+
forceUntil = Date.now() + 2500
|
|
9346
|
+
schedule()
|
|
9347
|
+
}
|
|
9348
|
+
} catch {
|
|
9349
|
+
/* ignore */
|
|
9350
|
+
}
|
|
9351
|
+
}
|
|
9352
|
+
const attach = (next) => {
|
|
9353
|
+
if (next === null || next === undefined || next === scroller) return
|
|
9354
|
+
detach()
|
|
9355
|
+
scroller = next
|
|
9356
|
+
try {
|
|
9357
|
+
observer = new MutationObserver(() => schedule())
|
|
9358
|
+
observer.observe(next, {
|
|
9359
|
+
childList: true,
|
|
9360
|
+
subtree: true,
|
|
9361
|
+
characterData: true,
|
|
9362
|
+
attributes: true,
|
|
9363
|
+
attributeFilter: ['data-chat-following-tail'],
|
|
9364
|
+
})
|
|
9365
|
+
} catch {
|
|
9366
|
+
observer = null
|
|
9367
|
+
}
|
|
9368
|
+
try {
|
|
9369
|
+
if (typeof ResizeObserver === 'function') {
|
|
9370
|
+
resizeObserver = new ResizeObserver(() => schedule())
|
|
9371
|
+
resizeObserver.observe(next)
|
|
9372
|
+
const content = next.firstElementChild
|
|
9373
|
+
if (content !== null && content !== undefined) resizeObserver.observe(content)
|
|
9374
|
+
}
|
|
9375
|
+
} catch {
|
|
9376
|
+
resizeObserver = null
|
|
9377
|
+
}
|
|
9378
|
+
/* 兜底:即使没有 DOM 变更事件,跟随期间也低频检查一次(异步高度变化) */
|
|
9379
|
+
interval = window.setInterval(() => {
|
|
9380
|
+
if (shouldFollow()) schedule()
|
|
9381
|
+
}, 700)
|
|
9382
|
+
next.addEventListener('wheel', onWheel, { passive: true })
|
|
9383
|
+
next.addEventListener('touchstart', onWheel, { passive: true })
|
|
9384
|
+
next.addEventListener('keydown', onKeyDown, true)
|
|
9385
|
+
next.addEventListener('pointerdown', onPointerDown, true)
|
|
9386
|
+
diag(`attach top=${Math.round(next.scrollTop)} max=${Math.round(next.scrollHeight - next.clientHeight)} follow=${hasFollowAttr()}`)
|
|
9387
|
+
schedule()
|
|
9388
|
+
}
|
|
9389
|
+
const detach = () => {
|
|
9390
|
+
if (frame !== 0) {
|
|
9391
|
+
window.cancelAnimationFrame(frame)
|
|
9392
|
+
frame = 0
|
|
9393
|
+
}
|
|
9394
|
+
if (retryTimer !== 0) {
|
|
9395
|
+
window.clearTimeout(retryTimer)
|
|
9396
|
+
retryTimer = 0
|
|
9397
|
+
}
|
|
9398
|
+
if (interval !== null) {
|
|
9399
|
+
window.clearInterval(interval)
|
|
9400
|
+
interval = null
|
|
9401
|
+
}
|
|
9402
|
+
observer?.disconnect()
|
|
9403
|
+
observer = null
|
|
9404
|
+
resizeObserver?.disconnect()
|
|
9405
|
+
resizeObserver = null
|
|
9406
|
+
if (scroller !== null) {
|
|
9407
|
+
scroller.removeEventListener('wheel', onWheel)
|
|
9408
|
+
scroller.removeEventListener('touchstart', onWheel)
|
|
9409
|
+
scroller.removeEventListener('keydown', onKeyDown, true)
|
|
9410
|
+
scroller.removeEventListener('pointerdown', onPointerDown, true)
|
|
9411
|
+
}
|
|
9412
|
+
scroller = null
|
|
9413
|
+
forceUntil = 0
|
|
9414
|
+
}
|
|
9415
|
+
return { attach, detach }
|
|
9416
|
+
}
|
|
9417
|
+
|
|
9262
9418
|
/** 毫秒时间戳 → 简短相对时间(会话下拉用)。 */
|
|
9263
9419
|
function gufaRelativeTime(timestamp) {
|
|
9264
9420
|
const delta = Date.now() - timestamp
|
|
@@ -9421,6 +9577,8 @@ G.ChatDock = function ChatDock(props) {
|
|
|
9421
9577
|
const theme = props.theme === 'light' ? 'light' : 'dark'
|
|
9422
9578
|
const hostRef = useRef(null)
|
|
9423
9579
|
const dockRef = useRef({ root: null, saved: null })
|
|
9580
|
+
const followRef = useRef(null)
|
|
9581
|
+
if (followRef.current === null) followRef.current = gufaCreateChatFollowKeeper()
|
|
9424
9582
|
const tickRef = useRef(null)
|
|
9425
9583
|
const startedRef = useRef(0)
|
|
9426
9584
|
const [phase, setPhase] = useState('searching')
|
|
@@ -9439,6 +9597,7 @@ G.ChatDock = function ChatDock(props) {
|
|
|
9439
9597
|
if (host === null) return
|
|
9440
9598
|
const root = gufaFindConversationRoot()
|
|
9441
9599
|
if (root === null) {
|
|
9600
|
+
followRef.current?.detach()
|
|
9442
9601
|
if (dockRef.current.root !== null) undock()
|
|
9443
9602
|
setPhase((previous) => {
|
|
9444
9603
|
if (previous === 'docked') return 'searching'
|
|
@@ -9452,6 +9611,12 @@ G.ChatDock = function ChatDock(props) {
|
|
|
9452
9611
|
dockRef.current = { root, saved: gufaSnapshotDockTarget(root) }
|
|
9453
9612
|
}
|
|
9454
9613
|
if (gufaPlaceDockedConversation(root, host, { translucent: props.backdrop === true })) {
|
|
9614
|
+
try {
|
|
9615
|
+
const scroller = root.querySelector(GUFA_CONVERSATION_SCROLL_SELECTOR)
|
|
9616
|
+
if (scroller !== null && scroller !== undefined) followRef.current?.attach(scroller)
|
|
9617
|
+
} catch {
|
|
9618
|
+
/* ignore */
|
|
9619
|
+
}
|
|
9455
9620
|
setPhase((previous) => (previous === 'docked' ? previous : 'docked'))
|
|
9456
9621
|
}
|
|
9457
9622
|
}, [active, undock, props.backdrop])
|
|
@@ -9490,6 +9655,7 @@ G.ChatDock = function ChatDock(props) {
|
|
|
9490
9655
|
observer?.disconnect()
|
|
9491
9656
|
resizeObserver?.disconnect()
|
|
9492
9657
|
window.removeEventListener('resize', onWindowResize)
|
|
9658
|
+
followRef.current?.detach()
|
|
9493
9659
|
undock()
|
|
9494
9660
|
}
|
|
9495
9661
|
}, [active, undock])
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
|
|
8
8
|
<key>CFBundleExecutable</key><string>gufa-float</string>
|
|
9
9
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
10
|
-
<key>CFBundleShortVersionString</key><string>1.3.
|
|
11
|
-
<key>CFBundleVersion</key><string>1.3.
|
|
10
|
+
<key>CFBundleShortVersionString</key><string>1.3.69</string>
|
|
11
|
+
<key>CFBundleVersion</key><string>1.3.69</string>
|
|
12
12
|
<key>LSUIElement</key><true/>
|
|
13
13
|
<key>NSHighResolutionCapable</key><true/>
|
|
14
14
|
<key>NSPrincipalClass</key><string>NSApplication</string>
|
|
Binary file
|
package/package.json
CHANGED
package/src/client/60-dock.js
CHANGED
|
@@ -107,6 +107,162 @@ function gufaPlaceDockedConversation(root, host, options) {
|
|
|
107
107
|
return true
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
/**
|
|
111
|
+
* 停靠后的官方会话「贴底跟随」守护。
|
|
112
|
+
*
|
|
113
|
+
* 官方会话自己有一套 follow 策略(ChatView root 上的 `data-chat-following-tail` 属性),
|
|
114
|
+
* 但在 fixed 停靠 + 频繁重排/ResizeObserver 的容器里,偶发出现「发起聊天后滚动条不在最下面」。
|
|
115
|
+
* 这里只在官方自己认为处于「跟随尾部」时补一次贴底(以及刚发送消息后的 2.5s 内),
|
|
116
|
+
* 用户主动滚动/官方取消跟随时绝不抢滚动条。
|
|
117
|
+
*/
|
|
118
|
+
function gufaCreateChatFollowKeeper() {
|
|
119
|
+
let scroller = null
|
|
120
|
+
let observer = null
|
|
121
|
+
let resizeObserver = null
|
|
122
|
+
let interval = null
|
|
123
|
+
let frame = 0
|
|
124
|
+
let retryTimer = 0
|
|
125
|
+
let forceUntil = 0
|
|
126
|
+
let diagnosticsLeft = 24
|
|
127
|
+
const diag = (message) => {
|
|
128
|
+
if (diagnosticsLeft <= 0) return
|
|
129
|
+
diagnosticsLeft -= 1
|
|
130
|
+
try {
|
|
131
|
+
void G.api('dev.log', { message: `chat-follow ${message}` }).catch(() => {})
|
|
132
|
+
} catch {
|
|
133
|
+
/* ignore */
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const hasFollowAttr = () => {
|
|
138
|
+
try {
|
|
139
|
+
return scroller !== null && scroller.isConnected && scroller.querySelector('[data-chat-following-tail]') !== null
|
|
140
|
+
} catch {
|
|
141
|
+
return false
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const shouldFollow = () => hasFollowAttr() || Date.now() < forceUntil
|
|
145
|
+
const toBottom = () => {
|
|
146
|
+
if (scroller === null || !scroller.isConnected) return
|
|
147
|
+
try {
|
|
148
|
+
const max = scroller.scrollHeight - scroller.clientHeight
|
|
149
|
+
if (max <= 0) return
|
|
150
|
+
if (scroller.scrollTop < max - 2) scroller.scrollTop = max
|
|
151
|
+
} catch {
|
|
152
|
+
/* ignore */
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const hasRoom = () => {
|
|
156
|
+
if (scroller === null || !scroller.isConnected) return false
|
|
157
|
+
return scroller.scrollHeight - scroller.clientHeight > 1
|
|
158
|
+
}
|
|
159
|
+
const pump = () => {
|
|
160
|
+
frame = 0
|
|
161
|
+
if (document.visibilityState !== 'visible') return
|
|
162
|
+
if (!shouldFollow()) return
|
|
163
|
+
const before = Math.round(scroller.scrollTop)
|
|
164
|
+
const max = Math.round(scroller.scrollHeight - scroller.clientHeight)
|
|
165
|
+
if (scroller.scrollTop < max - 2) diag(`pump top=${before} max=${max} follow=${hasFollowAttr()} force=${Date.now() < forceUntil}`)
|
|
166
|
+
toBottom()
|
|
167
|
+
/* 流式内容/折叠动画/图片加载会分几帧改变高度:短时间重试几次 */
|
|
168
|
+
if (retryTimer !== 0) window.clearTimeout(retryTimer)
|
|
169
|
+
retryTimer = window.setTimeout(() => {
|
|
170
|
+
retryTimer = 0
|
|
171
|
+
if (shouldFollow() && hasRoom()) toBottom()
|
|
172
|
+
}, 120)
|
|
173
|
+
}
|
|
174
|
+
const schedule = () => {
|
|
175
|
+
if (frame !== 0) return
|
|
176
|
+
frame = window.requestAnimationFrame(pump)
|
|
177
|
+
}
|
|
178
|
+
const onWheel = () => { forceUntil = 0 }
|
|
179
|
+
const onKeyDown = (event) => {
|
|
180
|
+
if (event.key !== 'Enter' || event.shiftKey === true || event.isComposing === true) return
|
|
181
|
+
try {
|
|
182
|
+
if (event.target instanceof Element && event.target.closest('[data-composer-input], [data-composer-seat]') !== null) {
|
|
183
|
+
forceUntil = Date.now() + 2500
|
|
184
|
+
schedule()
|
|
185
|
+
}
|
|
186
|
+
} catch {
|
|
187
|
+
/* ignore */
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const onPointerDown = (event) => {
|
|
191
|
+
try {
|
|
192
|
+
if (event.target instanceof Element && event.target.closest('[data-composer-seat]') !== null) {
|
|
193
|
+
forceUntil = Date.now() + 2500
|
|
194
|
+
schedule()
|
|
195
|
+
}
|
|
196
|
+
} catch {
|
|
197
|
+
/* ignore */
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const attach = (next) => {
|
|
201
|
+
if (next === null || next === undefined || next === scroller) return
|
|
202
|
+
detach()
|
|
203
|
+
scroller = next
|
|
204
|
+
try {
|
|
205
|
+
observer = new MutationObserver(() => schedule())
|
|
206
|
+
observer.observe(next, {
|
|
207
|
+
childList: true,
|
|
208
|
+
subtree: true,
|
|
209
|
+
characterData: true,
|
|
210
|
+
attributes: true,
|
|
211
|
+
attributeFilter: ['data-chat-following-tail'],
|
|
212
|
+
})
|
|
213
|
+
} catch {
|
|
214
|
+
observer = null
|
|
215
|
+
}
|
|
216
|
+
try {
|
|
217
|
+
if (typeof ResizeObserver === 'function') {
|
|
218
|
+
resizeObserver = new ResizeObserver(() => schedule())
|
|
219
|
+
resizeObserver.observe(next)
|
|
220
|
+
const content = next.firstElementChild
|
|
221
|
+
if (content !== null && content !== undefined) resizeObserver.observe(content)
|
|
222
|
+
}
|
|
223
|
+
} catch {
|
|
224
|
+
resizeObserver = null
|
|
225
|
+
}
|
|
226
|
+
/* 兜底:即使没有 DOM 变更事件,跟随期间也低频检查一次(异步高度变化) */
|
|
227
|
+
interval = window.setInterval(() => {
|
|
228
|
+
if (shouldFollow()) schedule()
|
|
229
|
+
}, 700)
|
|
230
|
+
next.addEventListener('wheel', onWheel, { passive: true })
|
|
231
|
+
next.addEventListener('touchstart', onWheel, { passive: true })
|
|
232
|
+
next.addEventListener('keydown', onKeyDown, true)
|
|
233
|
+
next.addEventListener('pointerdown', onPointerDown, true)
|
|
234
|
+
diag(`attach top=${Math.round(next.scrollTop)} max=${Math.round(next.scrollHeight - next.clientHeight)} follow=${hasFollowAttr()}`)
|
|
235
|
+
schedule()
|
|
236
|
+
}
|
|
237
|
+
const detach = () => {
|
|
238
|
+
if (frame !== 0) {
|
|
239
|
+
window.cancelAnimationFrame(frame)
|
|
240
|
+
frame = 0
|
|
241
|
+
}
|
|
242
|
+
if (retryTimer !== 0) {
|
|
243
|
+
window.clearTimeout(retryTimer)
|
|
244
|
+
retryTimer = 0
|
|
245
|
+
}
|
|
246
|
+
if (interval !== null) {
|
|
247
|
+
window.clearInterval(interval)
|
|
248
|
+
interval = null
|
|
249
|
+
}
|
|
250
|
+
observer?.disconnect()
|
|
251
|
+
observer = null
|
|
252
|
+
resizeObserver?.disconnect()
|
|
253
|
+
resizeObserver = null
|
|
254
|
+
if (scroller !== null) {
|
|
255
|
+
scroller.removeEventListener('wheel', onWheel)
|
|
256
|
+
scroller.removeEventListener('touchstart', onWheel)
|
|
257
|
+
scroller.removeEventListener('keydown', onKeyDown, true)
|
|
258
|
+
scroller.removeEventListener('pointerdown', onPointerDown, true)
|
|
259
|
+
}
|
|
260
|
+
scroller = null
|
|
261
|
+
forceUntil = 0
|
|
262
|
+
}
|
|
263
|
+
return { attach, detach }
|
|
264
|
+
}
|
|
265
|
+
|
|
110
266
|
/** 毫秒时间戳 → 简短相对时间(会话下拉用)。 */
|
|
111
267
|
function gufaRelativeTime(timestamp) {
|
|
112
268
|
const delta = Date.now() - timestamp
|
|
@@ -269,6 +425,8 @@ G.ChatDock = function ChatDock(props) {
|
|
|
269
425
|
const theme = props.theme === 'light' ? 'light' : 'dark'
|
|
270
426
|
const hostRef = useRef(null)
|
|
271
427
|
const dockRef = useRef({ root: null, saved: null })
|
|
428
|
+
const followRef = useRef(null)
|
|
429
|
+
if (followRef.current === null) followRef.current = gufaCreateChatFollowKeeper()
|
|
272
430
|
const tickRef = useRef(null)
|
|
273
431
|
const startedRef = useRef(0)
|
|
274
432
|
const [phase, setPhase] = useState('searching')
|
|
@@ -287,6 +445,7 @@ G.ChatDock = function ChatDock(props) {
|
|
|
287
445
|
if (host === null) return
|
|
288
446
|
const root = gufaFindConversationRoot()
|
|
289
447
|
if (root === null) {
|
|
448
|
+
followRef.current?.detach()
|
|
290
449
|
if (dockRef.current.root !== null) undock()
|
|
291
450
|
setPhase((previous) => {
|
|
292
451
|
if (previous === 'docked') return 'searching'
|
|
@@ -300,6 +459,12 @@ G.ChatDock = function ChatDock(props) {
|
|
|
300
459
|
dockRef.current = { root, saved: gufaSnapshotDockTarget(root) }
|
|
301
460
|
}
|
|
302
461
|
if (gufaPlaceDockedConversation(root, host, { translucent: props.backdrop === true })) {
|
|
462
|
+
try {
|
|
463
|
+
const scroller = root.querySelector(GUFA_CONVERSATION_SCROLL_SELECTOR)
|
|
464
|
+
if (scroller !== null && scroller !== undefined) followRef.current?.attach(scroller)
|
|
465
|
+
} catch {
|
|
466
|
+
/* ignore */
|
|
467
|
+
}
|
|
303
468
|
setPhase((previous) => (previous === 'docked' ? previous : 'docked'))
|
|
304
469
|
}
|
|
305
470
|
}, [active, undock, props.backdrop])
|
|
@@ -338,6 +503,7 @@ G.ChatDock = function ChatDock(props) {
|
|
|
338
503
|
observer?.disconnect()
|
|
339
504
|
resizeObserver?.disconnect()
|
|
340
505
|
window.removeEventListener('resize', onWindowResize)
|
|
506
|
+
followRef.current?.detach()
|
|
341
507
|
undock()
|
|
342
508
|
}
|
|
343
509
|
}, [active, undock])
|