fix(background-agent): add polling mechanism for child session tracking

- Replace unreliable event-based tracking with 2-second polling
- Use SDK session.get() to detect completion (status === idle)
- Use SDK session.messages() to count tool_use parts for progress
- Auto-start polling on launch, auto-stop when no running tasks
- Resume polling on restore if running tasks exist

Fixes: Child session events not reaching plugin event handler

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2025-12-11 17:12:45 +09:00
parent 245acdabad
commit b5d56246f6
2 changed files with 113 additions and 2 deletions

View File

@@ -7,7 +7,21 @@
"description": "Explore opencode in codebase",
"agent": "explore",
"status": "completed",
"startedAt": 1765434417395,
"completedAt": 1765434456778
"startedAt": "2025-12-11T06:26:57.395Z",
"completedAt": "2025-12-11T06:27:36.778Z"
},
{
"id": "bg_392b9c9b",
"sessionID": "ses_4f38ebf4fffeJZBocIn3UVv7vE",
"parentSessionID": "ses_4f38eefa0ffeKV0pVNnwT37P5L",
"parentMessageID": "msg_b0c7110d2001TMBlPeEYIrByvs",
"description": "Test explore agent",
"agent": "explore",
"status": "running",
"startedAt": "2025-12-11T08:05:07.378Z",
"progress": {
"toolCalls": 0,
"lastUpdate": "2025-12-11T08:05:07.378Z"
}
}
]