dsh-remote-panel 0.3.8 → 0.3.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/lib/client.js +69 -45
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -1174,52 +1174,26 @@ window.__ModuleLoader__.load({
|
|
|
1174
1174
|
问候语留在屏幕中间(原生居中),输入条钉到底部 */
|
|
1175
1175
|
/* 输入条下方那排统计(轮次/步数、token、缓存):手机上会撑高输入区,
|
|
1176
1176
|
按「托盘状态」的思路挪到右上角,做成一行半透明小字,不再占输入条的垂直空间 */
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
max-width:
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
box-sizing: border-box !important;
|
|
1197
|
-
font-size: 10.5px !important;
|
|
1198
|
-
line-height: 15px !important;
|
|
1199
|
-
z-index: 56 !important;
|
|
1200
|
-
overflow: hidden !important;
|
|
1201
|
-
transform: none !important;
|
|
1202
|
-
}
|
|
1203
|
-
/* 前两颗外面那层是 display:contents,Chrome 里不参与 flex 计算,实体化才能并排 */
|
|
1204
|
-
.uV2eYG_dock > div {
|
|
1205
|
-
display: flex !important;
|
|
1206
|
-
align-items: center !important;
|
|
1207
|
-
gap: 8px !important;
|
|
1208
|
-
min-width: 0 !important;
|
|
1209
|
-
}
|
|
1210
|
-
.uV2eYG_dock [data-composer-stat] { min-width: 0 !important; }
|
|
1211
|
-
/* 胶囊里的 label 自带 max-width,会被截成「2 轮 8 步 · 211 …」;托盘里放开 */
|
|
1212
|
-
.uV2eYG_dock [class*="_label"] {
|
|
1213
|
-
max-width: none !important;
|
|
1214
|
-
overflow: visible !important;
|
|
1215
|
-
text-overflow: clip !important;
|
|
1216
|
-
white-space: nowrap !important;
|
|
1177
|
+
/* 原生的统计条藏在输入条下方、文案又长,手机上只能挤;这里整体隐藏,
|
|
1178
|
+
由 installStatsTray() 读它的文本、精简后放到顶部右上角 */
|
|
1179
|
+
.uV2eYG_dock { display: none !important; }
|
|
1180
|
+
|
|
1181
|
+
.dsh-stats-tray {
|
|
1182
|
+
position: fixed;
|
|
1183
|
+
top: max(2px, calc(var(--dsh-safe-top, 0px) - 24px));
|
|
1184
|
+
right: 14px;
|
|
1185
|
+
z-index: 57;
|
|
1186
|
+
max-width: 62vw;
|
|
1187
|
+
overflow: hidden;
|
|
1188
|
+
text-overflow: ellipsis;
|
|
1189
|
+
white-space: nowrap;
|
|
1190
|
+
font-size: 10px;
|
|
1191
|
+
line-height: 16px;
|
|
1192
|
+
font-variant-numeric: tabular-nums;
|
|
1193
|
+
color: rgba(255, 255, 255, .5);
|
|
1194
|
+
pointer-events: none;
|
|
1195
|
+
letter-spacing: .01em;
|
|
1217
1196
|
}
|
|
1218
|
-
/* 托盘只留两项:轮次/步数 + token/缓存;分支与占比收掉(面板里可见) */
|
|
1219
|
-
[data-composer-stat="git-branch"] { display: none !important; }
|
|
1220
|
-
.uV2eYG_dock > span[class*="_root"] { display: none !important; }
|
|
1221
|
-
/* 没有统计时不渲染空壳(hero 页就是这样) */
|
|
1222
|
-
.uV2eYG_dock:empty { display: none !important; }
|
|
1223
1197
|
|
|
1224
1198
|
/* 输入条座位顶部有一段渐隐(DSH 原本渐到 #151517),在纯黑底上会显出一条灰带,
|
|
1225
1199
|
这里把终点色换成纯黑,观感才对得上;底部那行状态(轮次/token/缓存)同理 */
|
|
@@ -1708,6 +1682,54 @@ window.__ModuleLoader__.load({
|
|
|
1708
1682
|
}
|
|
1709
1683
|
|
|
1710
1684
|
|
|
1685
|
+
/**
|
|
1686
|
+
* 顶部统计托盘:DSH 的统计条文案太长(「2 轮 8 步 · 211 tok/s」「1.7M tok · 缓存命中 99%」),
|
|
1687
|
+
* 手机上一行放不下。这里读它的文本、精简成 `2 轮 · 211 tok/s · 缓存 99%` 放到右上角,
|
|
1688
|
+
* 原条隐藏,既省高度又不挤。
|
|
1689
|
+
*/
|
|
1690
|
+
function installStatsTray() {
|
|
1691
|
+
if (typeof document === 'undefined' || typeof MutationObserver === 'undefined') return () => {}
|
|
1692
|
+
const tray = document.createElement('div')
|
|
1693
|
+
tray.className = 'dsh-stats-tray'
|
|
1694
|
+
tray.setAttribute('aria-hidden', 'true')
|
|
1695
|
+
document.body.appendChild(tray)
|
|
1696
|
+
|
|
1697
|
+
let frame = 0
|
|
1698
|
+
let shown = ''
|
|
1699
|
+
const format = (text) => {
|
|
1700
|
+
const rounds = text.match(/(\d+)\s*轮/)
|
|
1701
|
+
const speed = text.match(/([\d.]+)\s*tok\/s/i)
|
|
1702
|
+
const cache = text.match(/(\d+(?:\.\d+)?)\s*%/)
|
|
1703
|
+
const parts = []
|
|
1704
|
+
if (rounds !== null) parts.push(`${rounds[1]} 轮`)
|
|
1705
|
+
if (speed !== null) parts.push(`${speed[1]} tok/s`)
|
|
1706
|
+
if (cache !== null) parts.push(`缓存 ${cache[1]}%`)
|
|
1707
|
+
return parts.join(' · ')
|
|
1708
|
+
}
|
|
1709
|
+
const sync = () => {
|
|
1710
|
+
frame = 0
|
|
1711
|
+
const dock = document.querySelector('.uV2eYG_dock')
|
|
1712
|
+
const raw = dock?.textContent ?? ''
|
|
1713
|
+
const next = raw.trim() === '' ? '' : format(raw)
|
|
1714
|
+
if (next === shown) return
|
|
1715
|
+
shown = next
|
|
1716
|
+
tray.textContent = next
|
|
1717
|
+
tray.style.display = next === '' ? 'none' : 'block'
|
|
1718
|
+
}
|
|
1719
|
+
const schedule = () => {
|
|
1720
|
+
if (frame !== 0) return
|
|
1721
|
+
frame = requestAnimationFrame(sync)
|
|
1722
|
+
}
|
|
1723
|
+
const observer = new MutationObserver(schedule)
|
|
1724
|
+
observer.observe(document.body, { subtree: true, childList: true, characterData: true })
|
|
1725
|
+
sync()
|
|
1726
|
+
return () => {
|
|
1727
|
+
observer.disconnect()
|
|
1728
|
+
if (frame !== 0) cancelAnimationFrame(frame)
|
|
1729
|
+
tray.remove()
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1711
1733
|
/**
|
|
1712
1734
|
* 外壳挂点自检:DSH 升级后这些 hash 类名可能全变,样式就整体失配。
|
|
1713
1735
|
* 启动后检查一遍 DOM,把结果报给宿主,面板里能直接看到「外壳适配」这盏灯。
|
|
@@ -2349,6 +2371,7 @@ window.__ModuleLoader__.load({
|
|
|
2349
2371
|
const cleanupFocus = installComposerFocusGuard()
|
|
2350
2372
|
const cleanupFps = installFpsMeter()
|
|
2351
2373
|
const cleanupContract = installShellContractReport()
|
|
2374
|
+
const cleanupTray = installStatsTray()
|
|
2352
2375
|
if (typeof ctx.effect === 'function') ctx.effect(() => cleanupClear, 'remote-panel: workspace clear')
|
|
2353
2376
|
if (typeof ctx.effect === 'function') ctx.effect(() => cleanupBack, 'remote-panel: back gesture')
|
|
2354
2377
|
if (typeof ctx.effect === 'function') ctx.effect(() => cleanupAttention, 'remote-panel: attention')
|
|
@@ -2357,6 +2380,7 @@ window.__ModuleLoader__.load({
|
|
|
2357
2380
|
if (typeof ctx.effect === 'function') ctx.effect(() => cleanupFocus, 'remote-panel: composer focus guard')
|
|
2358
2381
|
if (typeof ctx.effect === 'function') ctx.effect(() => cleanupFps, 'remote-panel: fps meter')
|
|
2359
2382
|
if (typeof ctx.effect === 'function') ctx.effect(() => cleanupContract, 'remote-panel: shell contract report')
|
|
2383
|
+
if (typeof ctx.effect === 'function') ctx.effect(() => cleanupTray, 'remote-panel: stats tray')
|
|
2360
2384
|
if (typeof ctx.effect === 'function') ctx.effect(() => cleanup, 'remote-panel: mobile shell css')
|
|
2361
2385
|
|
|
2362
2386
|
ctx.slots.inject('shell.overlay', () =>
|