dsh-coding-sidebar 1.0.5 → 1.0.7
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/lib/client-editor.js +174 -174
- package/lib/client-registry.js +330 -302
- package/lib/client-terminal.js +175 -175
- package/lib/client.js +333 -305
- package/package.json +1 -1
- package/src/client/BrowserView.tsx +36 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-coding-sidebar",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "DSH web plugin: a VSCode-like right sidebar (explorer / editor / terminal / git / browser), isolated per conversation session. Exposes the betterSidebar service for other plugins to register sidebar tabs and file viewers. KCoder-maintained fork of DSH-better-sidebar 0.17.2 (bottom panel removed, upstream-decoupled release line).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* address-bar navigations (in-frame link clicks are cross-origin and
|
|
17
17
|
* invisible — a documented limitation).
|
|
18
18
|
*/
|
|
19
|
-
import { useEffect, useState } from 'react'
|
|
19
|
+
import { useEffect, useRef, useState } from 'react'
|
|
20
20
|
import {
|
|
21
21
|
IconChevronLeftOutline14,
|
|
22
22
|
IconChevronRightOutline14,
|
|
@@ -81,7 +81,7 @@ export function iframeSandboxFor(url: string | undefined, allowedLoopback: strin
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export function BrowserView(props: TabComponentProps) {
|
|
84
|
-
const { store, tab } = props
|
|
84
|
+
const { store, tab, ctx } = props
|
|
85
85
|
// The current address (initialized from the persisted tab.path so a
|
|
86
86
|
// reload restores the visited page).
|
|
87
87
|
const [url, setUrl] = useState<string | undefined>(tab.path)
|
|
@@ -121,6 +121,40 @@ export function BrowserView(props: TabComponentProps) {
|
|
|
121
121
|
return () => { cancelled = true }
|
|
122
122
|
}, [url])
|
|
123
123
|
|
|
124
|
+
// Agent 实况自动切换(2026-09-12 边沿触发重构):非实况态轮询浏览器宿主
|
|
125
|
+
// 的 page target——agent 页面(非 about: 空页)从「无」到「有」的那一拍
|
|
126
|
+
// 才自动开实况并把本 tab 顶到前台。两条风暴防线(1.0.7):
|
|
127
|
+
// - 边沿判定:上一拍必须明确观测过「无 agent 页」(null=尚无历史,首拍
|
|
128
|
+
// 永不触发)——重挂载/页面重载后 agent 页面虽在,也不构成「新出现」;
|
|
129
|
+
// 配合一次性闩,用户手动关掉实况后不会被再次强制打开。
|
|
130
|
+
// - 顶前台走 activateTab(本 tab)而非 openTab:browser 类型每次 openTab
|
|
131
|
+
// 都经 createTab 铸唯一 id 新开 tab(无 dedupe),旧写法在新挂载的组件
|
|
132
|
+
// 里每拍都 mint 新 tab,几何级繁殖直至渲染进程被打爆(引擎表现为
|
|
133
|
+
// 反复重连、tab 关不掉,只能重启应用)。
|
|
134
|
+
const autoRaised = useRef(false)
|
|
135
|
+
const hadAgentPage = useRef<boolean | null>(null)
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if (live || autoRaised.current) return
|
|
138
|
+
const timer = setInterval(async () => {
|
|
139
|
+
if (autoRaised.current) return
|
|
140
|
+
try {
|
|
141
|
+
const { targets: list } = await api.cdpTargets()
|
|
142
|
+
const agentPages = list.filter((t) => t.url !== '' && !t.url.startsWith('about:'))
|
|
143
|
+
const had = hadAgentPage.current
|
|
144
|
+
hadAgentPage.current = agentPages.length > 0
|
|
145
|
+
if (agentPages.length > 0 && had === false) {
|
|
146
|
+
autoRaised.current = true
|
|
147
|
+
setLive(true)
|
|
148
|
+
try {
|
|
149
|
+
const better = (ctx as unknown as { betterSidebar?: { activateTab?: (id: string) => unknown } }).betterSidebar
|
|
150
|
+
better?.activateTab?.(tab.id)
|
|
151
|
+
} catch { /* 顶起失败:实况仍已在 tab 内容里生效 */ }
|
|
152
|
+
}
|
|
153
|
+
} catch { /* 宿主未起:静默等下次轮询 */ }
|
|
154
|
+
}, 3000)
|
|
155
|
+
return () => { clearInterval(timer) }
|
|
156
|
+
}, [live, ctx, tab.id])
|
|
157
|
+
|
|
124
158
|
const persist = (nextUrl: string): void => {
|
|
125
159
|
let host = nextUrl
|
|
126
160
|
try { host = new URL(nextUrl).hostname } catch { /* keep the URL as title */ }
|