@murchey/dsh-session-manager 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -41,7 +41,7 @@ dsh plugin --profile <profile> add link:<此目录绝对路径>
41
41
 
42
42
  - 顶部显示总会话数与磁盘占用;
43
43
  - 每个会话显示标题、ID、项目目录、创建日期、占用空间和比例条;
44
- - 运行中的会话标记为 `运行中`,不能选择(先结束会话再删除);已归档会话显示 `已归档` 徽标;
44
+ - 运行中的会话标记为 `运行中`,不能选择(先结束会话再删除);已归档会话显示 `已归档` 徽标;页面打开期间每 5 秒自动同步一次状态,切回后台页面时会立即同步,因此结束会话后无需重启 DSH;
45
45
  - 支持按标题 / ID / 项目目录搜索,按大小或时间排序;
46
46
  - 行尾“删除”按钮删除单个会话,“删除所选”批量删除;
47
47
  - 删除前弹出确认对话框,明确显示数量、总字节数和“不可撤销”警告,并默认勾选“同时删除不再被其他会话引用的附件”;
package/client.js CHANGED
@@ -314,9 +314,12 @@ window.__ModuleLoader__.load({
314
314
  const deleteRef = React.useRef(null);
315
315
  const selectAllRef = React.useRef(null);
316
316
  const wasOpen = React.useRef(false);
317
+ const loadingRef = React.useRef(false);
317
318
 
318
- const load = React.useCallback(async () => {
319
- setLoading(true);
319
+ const load = React.useCallback(async (showLoading = true) => {
320
+ if (loadingRef.current) return;
321
+ loadingRef.current = true;
322
+ if (showLoading) setLoading(true);
320
323
  try {
321
324
  const value = await requestJson('/api/session-shredder/sessions');
322
325
  setSessions(Array.isArray(value.sessions) ? value.sessions : []);
@@ -327,7 +330,8 @@ window.__ModuleLoader__.load({
327
330
  } catch (loadError) {
328
331
  setError(loadError instanceof Error ? loadError.message : String(loadError));
329
332
  } finally {
330
- setLoading(false);
333
+ loadingRef.current = false;
334
+ if (showLoading) setLoading(false);
331
335
  }
332
336
  }, []);
333
337
 
@@ -335,6 +339,22 @@ window.__ModuleLoader__.load({
335
339
  void load();
336
340
  }, [load]);
337
341
 
342
+ // The Host derives `live` from its current agent registry. Keep the page
343
+ // synchronized while it stays mounted, and refresh immediately when a
344
+ // backgrounded tab becomes visible again. This avoids requiring an app
345
+ // restart after an agent finishes or is stopped.
346
+ React.useEffect(() => {
347
+ const refreshIfVisible = () => {
348
+ if (typeof document === 'undefined' || document.visibilityState === 'visible') void load(false);
349
+ };
350
+ const timer = setInterval(refreshIfVisible, 5000);
351
+ if (typeof document !== 'undefined') document.addEventListener('visibilitychange', refreshIfVisible);
352
+ return () => {
353
+ clearInterval(timer);
354
+ if (typeof document !== 'undefined') document.removeEventListener('visibilitychange', refreshIfVisible);
355
+ };
356
+ }, [load]);
357
+
338
358
  React.useEffect(() => {
339
359
  setSelected((previous) => {
340
360
  if (previous.size === 0) return previous;
package/index.js CHANGED
@@ -18,8 +18,8 @@ import {
18
18
  resolveOptions,
19
19
  } from './lib/core.js';
20
20
 
21
- /** Cordis activation requires the tool registry and the persistence seam. */
22
- export const inject = ['tools', 'sessionPersistence'];
21
+ /** Cordis activation requires the tool, persistence, and live-agent services. */
22
+ export const inject = ['tools', 'sessionPersistence', 'agents'];
23
23
 
24
24
  /** Stable plugin row name. */
25
25
  export const name = 'session-shredder';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@murchey/dsh-session-manager",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "基于 DeepSeek Harness 的会话存储管理插件:查看会话磁盘占用、永久删除会话,并清理侧边栏失效条目。",
5
5
  "type": "module",
6
6
  "exports": {
@@ -64,4 +64,4 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  }
67
- }
67
+ }