opencode-subagent-magazine 1.1.2 → 1.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-subagent-magazine",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "OpenCode TUI plugin monitoring sub-agent invocation status in real time",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -11,7 +11,7 @@
11
11
  "types": "./dist/index.d.ts"
12
12
  },
13
13
  "./tui": {
14
- "import": "./src/index.tsx",
14
+ "import": "./dist/tui.js",
15
15
  "config": {
16
16
  "enabled": true
17
17
  }
@@ -27,7 +27,8 @@
27
27
  "opencode-subagent-magazine": "install.mjs"
28
28
  },
29
29
  "scripts": {
30
- "build": "tsc",
30
+ "build": "tsc && node build.tui.mjs",
31
+ "build:tui": "node build.tui.mjs",
31
32
  "typecheck": "tsc --noEmit",
32
33
  "version": "node -e \"require('fs').writeFileSync('src/_version.ts','// auto-generated\\nexport const PLUGIN_VERSION='+JSON.stringify(require('./package.json').version)+';\\n')\"",
33
34
  "prepublishOnly": "tsc"
@@ -54,6 +55,8 @@
54
55
  "devDependencies": {
55
56
  "@opencode-ai/plugin": "^1.14.50",
56
57
  "@opencode-ai/sdk": "^1.14.50",
58
+ "esbuild": "^0.25.0",
59
+ "esbuild-plugin-solid": "^0.5.0",
57
60
  "tsx": "^4.22.3",
58
61
  "typescript": "^5.8.0"
59
62
  }
package/src/_version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // auto-generated
2
- export const PLUGIN_VERSION="1.1.2";
2
+ export const PLUGIN_VERSION="1.1.3";
package/src/index.tsx CHANGED
@@ -247,8 +247,7 @@ function safeErrorMsg(err: unknown): string {
247
247
  // Sidebar component
248
248
  // ===================================================================
249
249
 
250
- // 模块级缓存:保留各 session 的最新 entryMap,不随组件内 session 切换而丢失。
251
- // 当用户在子 session 内部时,handleSessionEnd 可通过此缓存找到父 session 的 entries。
250
+ // 模块级缓存:各 session entry 状态独立存储,不随当前视图切换而清除。
252
251
  const globalEntryCache = new Map<string, Map<string, SubEntry>>()
253
252
 
254
253
  function SubAgentPanel(props: {
@@ -347,8 +346,8 @@ function SubAgentPanel(props: {
347
346
  setEntryMapRaw((prev) => {
348
347
  const next = typeof arg === "function" ? (arg as Function)(prev) : arg
349
348
 
350
- // 检测是否有 entry 从 running 变为 done/error 立即写 KV
351
- // 避免 session 切换时 KV 仍是旧状态,导致 scan 用 Date.now() 覆盖正确的 endedAt
349
+ // entry 状态落定(done/error)时立即持久化到 KV,跳过常规 debounce,
350
+ // 确保跨视图的状态一致性。
352
351
  let needsImmediateFlush = false
353
352
  for (const [id, entry] of next) {
354
353
  const prevEntry = prev.get(id)
@@ -369,7 +368,7 @@ function SubAgentPanel(props: {
369
368
  persistEntries(props.sessionId, next)
370
369
  }
371
370
 
372
- // 同步到全局缓存,确保跨 session 查找时数据可用
371
+ // 同步到模块级缓存,供其他视图读取当前 session 的最新状态
373
372
  globalEntryCache.set(props.sessionId, new Map(next))
374
373
 
375
374
  return next
@@ -723,14 +722,13 @@ function SubAgentPanel(props: {
723
722
  return changed ? next : prev
724
723
  })
725
724
 
726
- // session 完成事件:用户正在查看子 session 内部时,其他子代理 done。
727
- // 上面的 setEntryMap 在子 session 的 entries 中找不到父 session 的 entry
728
- // 通过全局缓存(切换前保留的父 session entries)查找并更新,再同步回 KV。
725
+ // 当子代理所属的父 session 与当前视图不同时,通过模块级缓存定位
726
+ // 并更新父 session 的 entry 状态,随后写回 KV
729
727
  try {
730
728
  const sessionObj = props.api.state.session.get(sid)
731
729
  const parentSid = sessionObj?.parentID
732
730
  if (parentSid && parentSid !== props.sessionId) {
733
- // 优先全局缓存——切换 session 时不会被替换,始终保留父 session 的最新 entries
731
+ // 优先从模块级缓存获取父 session entries,不受当前视图切换影响
734
732
  const parentCache = globalEntryCache.get(parentSid)
735
733
  const nowTs = Date.now()
736
734
  let found = false
@@ -739,7 +737,7 @@ function SubAgentPanel(props: {
739
737
  found = tryMatchAndUpdate(parentCache, sid, status, nowTs)
740
738
  }
741
739
 
742
- // 缓存未命中时回退到 KV(极端情况:session 切换前缓存未建立)
740
+ // 缓存未命中时回退到 KV 读取
743
741
  if (!found) {
744
742
  const data = loadSessionData()
745
743
  const rec = data[parentSid]
@@ -747,7 +745,7 @@ function SubAgentPanel(props: {
747
745
  const fallbackMap = new Map(rec.entries.map((e: SubEntry) => [e.id, e]))
748
746
  found = tryMatchAndUpdate(fallbackMap, sid, status, nowTs)
749
747
  if (found) {
750
- // 回退命中了也要写回 KV,并回填缓存
748
+ // 回退命中后写入 KV 并回填缓存
751
749
  data[parentSid] = { ...rec, ts: nowTs, entries: [...fallbackMap.values()] }
752
750
  saveSessionData(data)
753
751
  globalEntryCache.set(parentSid, fallbackMap)
@@ -755,7 +753,7 @@ function SubAgentPanel(props: {
755
753
  }
756
754
  }
757
755
 
758
- // KV 同步:以全局缓存(最新的内存状态)为准写回 KV
756
+ // 将模块级缓存中的最新状态同步到 KV
759
757
  if (found && parentCache) {
760
758
  const data = loadSessionData()
761
759
  data[parentSid] = { ...data[parentSid], ts: nowTs, entries: [...parentCache.values()] }
@@ -878,7 +876,7 @@ function SubAgentPanel(props: {
878
876
  // scan uses setEntryMapRaw — ephemeral data, not persisted to kv.
879
877
  // Only event-driven changes (handlePartUpdated, handleSessionEnd) persist.
880
878
  setEntryMapRaw((prev) => {
881
- // 优先全局缓存——handleSessionEnd 修复2 已同步更新,无 KV 读写延迟
879
+ // 优先从模块级缓存加载,KV 仅作缓存未命中时的回退
882
880
  const next = switched
883
881
  ? new Map(globalEntryCache.get(sid) ?? loadEntries(sid))
884
882
  : new Map(prev)