@zfdx123/dsh-session-cleaner 1.0.6 → 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.
Files changed (2) hide show
  1. package/client.js +18 -5
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -1107,6 +1107,21 @@ window.__ModuleLoader__.load({
1107
1107
  report('trigger', { name: name.slice(0, 60) })
1108
1108
  }
1109
1109
 
1110
+ // 目录请求的序号:只有最新一次的结果允许写进 `catalog`。
1111
+ //
1112
+ // 回归:启动时一次拉取(下面 1142 行)与「行内 id 没解出来时」的重试
1113
+ // (1124 行)会同时在飞,先发的旧响应可能后到并覆盖 `catalog`。已经插进去的
1114
+ // 菜单项不会被重建(标签看起来是对的),但 `catalog` 会一直陈旧到刷新页面,
1115
+ // 于是**下一个**打开的菜单会把运行中的会话显示成可删除。
1116
+ let catalogSeq = 0
1117
+ const loadCatalog = () => {
1118
+ const seq = (catalogSeq += 1)
1119
+ return fetchCatalog().then((resolved) => {
1120
+ if (catalogSeq === seq) catalog = resolved
1121
+ return resolved
1122
+ })
1123
+ }
1124
+
1110
1125
  const attempt = (added) => {
1111
1126
  const found = findSessionMenu(added)
1112
1127
  if (found === undefined) return
@@ -1121,10 +1136,9 @@ window.__ModuleLoader__.load({
1121
1136
  pendingRow = null
1122
1137
  return
1123
1138
  }
1124
- fetchCatalog()
1139
+ loadCatalog()
1125
1140
  .then((resolved) => {
1126
- catalog = resolved
1127
- if (found.menu.isConnected) augmentMenu(found, row, catalog, ctx, dict)
1141
+ if (found.menu.isConnected) augmentMenu(found, row, resolved, ctx, dict)
1128
1142
  })
1129
1143
  .catch(() => {})
1130
1144
  }
@@ -1139,9 +1153,8 @@ window.__ModuleLoader__.load({
1139
1153
  })
1140
1154
  document.addEventListener('pointerdown', onPointerDown, true)
1141
1155
  observer.observe(document.body, { childList: true, subtree: true })
1142
- fetchCatalog()
1156
+ loadCatalog()
1143
1157
  .then((resolved) => {
1144
- catalog = resolved
1145
1158
  report('catalog', { ok: resolved !== null, known: resolved === null ? 0 : resolved.byId.size })
1146
1159
  })
1147
1160
  .catch(() => {})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zfdx123/dsh-session-cleaner",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "会话清理:在运行中的 web 运行时里彻底删除 DSH 会话——实时 store 条目、工作区记录、磁盘产物与投影缓存行一并清掉,并在会话行菜单里加一个删除入口。",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/zfdx123/dsh-atelier/tree/main/packages/dsh-session-cleaner#readme",