fix(coding-agent): sync agent state after newSession setup callback

Move setup callback handling from interactive/rpc modes into AgentSession.newSession().
After setup() runs, sync agent state via replaceMessages() so the LLM has context
and the UI renders the messages properly.

fixes #968
This commit is contained in:
Mario Zechner 2026-01-26 22:25:09 +01:00
parent 0134a2a73d
commit f86e3c3103
4 changed files with 25 additions and 15 deletions

View file

@ -261,10 +261,8 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
commandContextActions: {
waitForIdle: () => session.agent.waitForIdle(),
newSession: async (options) => {
const success = await session.newSession({ parentSession: options?.parentSession });
if (success && options?.setup) {
await options.setup(session.sessionManager);
}
// Delegate to AgentSession (handles setup + agent state sync)
const success = await session.newSession(options);
return { cancelled: !success };
},
fork: async (entryId) => {