Persist agent session metadata for workspace resume (#4706)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo Hong
2026-06-07 19:41:25 -07:00
committed by GitHub
co-authored by Orca
parent f0945c7aa2
commit 3ef63c972a
35 changed files with 1412 additions and 39 deletions
+10
View File
@@ -110,6 +110,16 @@ describe('OpenCode hook plugin source', () => {
expect(source).toContain('await post("AskUserQuestion", event.properties || {});')
})
it('forwards sessionID on status and message posts for resume metadata', () => {
const source = _internals.getOpenCodePluginSource()
expect(source).toContain(
'await post("MessagePart", { role, text: part.text, messageID: part.messageID, sessionID });'
)
expect(source).toContain('await setStatus("busy", { sessionID });')
expect(source.match(/await setStatus\("idle", \{ sessionID \}\);/g) ?? []).toHaveLength(2)
})
it('guards endpoint-file parse warnings with a process-lifetime latch', () => {
// Why: ENOENT is the normal pre-install case and must stay silent, but a
// malformed/unreadable file (EACCES, EIO, parse error) would otherwise
+4 -4
View File
@@ -312,23 +312,23 @@ function getOpenCodePluginSource(): string {
' if (!part || part.type !== "text" || !part.text) return;',
' const role = messageRoleById.get(part.messageID);',
' if (!role) return;',
' await post("MessagePart", { role, text: part.text, messageID: part.messageID });',
' await post("MessagePart", { role, text: part.text, messageID: part.messageID, sessionID });',
' return;',
' }',
'',
' if (event.type === "session.idle" || event.type === "session.error") {',
' await setStatus("idle");',
' await setStatus("idle", { sessionID });',
' return;',
' }',
'',
' if (event.type === "session.status") {',
' const statusType = getStatusType(event);',
' if (statusType === "busy" || statusType === "retry") {',
' await setStatus("busy");',
' await setStatus("busy", { sessionID });',
' return;',
' }',
' if (statusType === "idle") {',
' await setStatus("idle");',
' await setStatus("idle", { sessionID });',
' }',
' }',
' },',