fix(tui): mark disposed when the agent leaves the registry under the TUI

agent/disposed only cleared the status line, so an agent-loop-only reload that
disposed the agent while the TUI stayed mounted left the local disposed flag
false. Since retained agents accept deliveries after detachment, later input
drove a zombie agent/session. Set disposed on agent/disposed so dispatchMessage
reports it. Adds a regression that sends after disposal and asserts no delivery.
This commit is contained in:
_Kerman
2026-07-27 01:59:59 +08:00
parent 1008d221e2
commit 71152bc4c0
2 changed files with 24 additions and 0 deletions
+5
View File
@@ -3217,6 +3217,11 @@ export function createTuiChat(
})
const disposeAgent = ctx.on('agent/disposed', (subject) => {
if (subject !== agent) return
// The agent left the registry (e.g. an agent-loop-only reload) while the
// TUI stays mounted. Retained agents accept deliveries after detachment, so
// without this a later send would drive a zombie agent/session; mark
// disposed so dispatchMessage reports it instead.
disposed = true
clearStatus()
appendNotice(`Agent "${agent.id}" was disposed.`, 'warning')
})