dsh-remote-panel 0.3.7 → 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.
Files changed (2) hide show
  1. package/lib/client.js +73 -19
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -1159,6 +1159,8 @@ window.__ModuleLoader__.load({
1159
1159
  .dsh-mobile-clear-workspace[data-none="true"] { display: none !important; }
1160
1160
  /* 抽屉/遮罩打开时顶栏按钮让位 */
1161
1161
  html.dsh-drawer-open .dsh-mobile-newchat { display: none !important; }
1162
+ /* 「+」是固定定位 + 内联 top:6px,顶栏被安全区顶下去后它会错位,这里拉回同一基线 */
1163
+ .dsh-mobile-newchat { top: calc(6px + var(--dsh-safe-top, 0px)) !important; }
1162
1164
 
1163
1165
  /* 空态:鱼标按原型放大并竖排到标题上方;标题 22/650,收掉「预览版」角标 */
1164
1166
  .pXSMma_headline { flex-direction: column !important; align-items: center !important; gap: 14px !important; }
@@ -1170,26 +1172,28 @@ window.__ModuleLoader__.load({
1170
1172
  .pXSMma_previewBadge { display: none !important; }
1171
1173
  /* 原生把「问候语 + 输入条」一起居中;手机按原型拆开:
1172
1174
  问候语留在屏幕中间(原生居中),输入条钉到底部 */
1173
- /* 输入条下方那排统计(轮次/步数、token、分支):手机上一行放不下时会互相挤压,
1174
- 允许换行 + 拉开间距,宁可两行也别把「58 轮 956 步」挤成一团 */
1175
- .uV2eYG_dock {
1176
- flex-wrap: wrap !important;
1177
- justify-content: flex-start !important;
1178
- column-gap: 14px !important;
1179
- row-gap: 4px !important;
1180
- padding: 0 2px !important;
1181
- }
1182
- /* 前两个胶囊外面那层是 display:contents,Chrome 里它不会参与 flex 换行计算,
1183
- 于是每颗都被挤到单独一行。这里把它实体化成一行,两颗才能并排 */
1184
- .uV2eYG_dock > div {
1185
- display: flex !important;
1186
- align-items: center !important;
1187
- gap: 14px !important;
1188
- min-width: 0 !important;
1175
+ /* 输入条下方那排统计(轮次/步数、token、缓存):手机上会撑高输入区,
1176
+ 按「托盘状态」的思路挪到右上角,做成一行半透明小字,不再占输入条的垂直空间 */
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;
1189
1196
  }
1190
- /* 手机上那排统计放不下三个:分支名是这里最不关键的一个(抽屉/面板里也能看到),
1191
- 先收掉它,让「轮次/步数」和「token/缓存」并排 */
1192
- [data-composer-stat="git-branch"] { display: none !important; }
1193
1197
 
1194
1198
  /* 输入条座位顶部有一段渐隐(DSH 原本渐到 #151517),在纯黑底上会显出一条灰带,
1195
1199
  这里把终点色换成纯黑,观感才对得上;底部那行状态(轮次/token/缓存)同理 */
@@ -1678,6 +1682,54 @@ window.__ModuleLoader__.load({
1678
1682
  }
1679
1683
 
1680
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
+
1681
1733
  /**
1682
1734
  * 外壳挂点自检:DSH 升级后这些 hash 类名可能全变,样式就整体失配。
1683
1735
  * 启动后检查一遍 DOM,把结果报给宿主,面板里能直接看到「外壳适配」这盏灯。
@@ -2319,6 +2371,7 @@ window.__ModuleLoader__.load({
2319
2371
  const cleanupFocus = installComposerFocusGuard()
2320
2372
  const cleanupFps = installFpsMeter()
2321
2373
  const cleanupContract = installShellContractReport()
2374
+ const cleanupTray = installStatsTray()
2322
2375
  if (typeof ctx.effect === 'function') ctx.effect(() => cleanupClear, 'remote-panel: workspace clear')
2323
2376
  if (typeof ctx.effect === 'function') ctx.effect(() => cleanupBack, 'remote-panel: back gesture')
2324
2377
  if (typeof ctx.effect === 'function') ctx.effect(() => cleanupAttention, 'remote-panel: attention')
@@ -2327,6 +2380,7 @@ window.__ModuleLoader__.load({
2327
2380
  if (typeof ctx.effect === 'function') ctx.effect(() => cleanupFocus, 'remote-panel: composer focus guard')
2328
2381
  if (typeof ctx.effect === 'function') ctx.effect(() => cleanupFps, 'remote-panel: fps meter')
2329
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')
2330
2384
  if (typeof ctx.effect === 'function') ctx.effect(() => cleanup, 'remote-panel: mobile shell css')
2331
2385
 
2332
2386
  ctx.slots.inject('shell.overlay', () =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-remote-panel",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "DSH 远程访问控制面:部署向导、状态面板与一键配对(EasyTier + Caddy),数据面保持进程外。",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",