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/dist/_version.d.ts +1 -1
- package/dist/_version.js +1 -1
- package/dist/index.js +11 -13
- package/dist/tui.js +1859 -0
- package/package.json +6 -3
- package/src/_version.ts +1 -1
- package/src/index.tsx +11 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-subagent-magazine",
|
|
3
|
-
"version": "1.1.
|
|
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": "./
|
|
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
|
+
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
|
-
//
|
|
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
|
-
//
|
|
351
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
727
|
-
//
|
|
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
|
-
//
|
|
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
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
879
|
+
// 优先从模块级缓存加载,KV 仅作缓存未命中时的回退
|
|
882
880
|
const next = switched
|
|
883
881
|
? new Map(globalEntryCache.get(sid) ?? loadEntries(sid))
|
|
884
882
|
: new Map(prev)
|