fix: commit step context before request dispatch

This commit is contained in:
_Kerman
2026-07-30 18:18:04 +08:00
parent a31331cb0e
commit a4ae0b4126
17 changed files with 132 additions and 228 deletions

View File

@@ -233,9 +233,9 @@ export function apply(ctx: Context, config: Config): void {
if (location === undefined) return
const state = renderState(location)
if (previous !== undefined && previous.state === state) return
agent.inject(createUserMessage({
agent.session.append('user/message', createUserMessage({
content: [{ type: 'text', text: renderReading(location, turn) }],
source: { kind: 'plugin', plugin: name },
}))
}), { surfaceOp: 'append' })
}, { prepend: true })
}

View File

@@ -101,9 +101,7 @@ function sessionAgent(session: Session, id = 'agent'): Agent {
ctx: new Context(),
followup: () => {},
steer: () => {},
inject(input) {
session.append('user/message', input, { surfaceOp: 'append' })
},
inject: () => { throw new Error('tmux-context must append directly to the open step') },
cancel() {},
whenIdle: () => Promise.resolve(),
}