Persist agent session metadata for workspace resume (#4706)
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 });',
|
||||
' }',
|
||||
' }',
|
||||
' },',
|
||||
|
||||
Reference in New Issue
Block a user