mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 18:01:22 +00:00
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:
parent
0134a2a73d
commit
f86e3c3103
4 changed files with 25 additions and 15 deletions
|
|
@ -995,15 +995,13 @@ export class InteractiveMode {
|
|||
}
|
||||
this.statusContainer.clear();
|
||||
|
||||
const success = await this.session.newSession({ parentSession: options?.parentSession });
|
||||
// Delegate to AgentSession (handles setup + agent state sync)
|
||||
const success = await this.session.newSession(options);
|
||||
if (!success) {
|
||||
return { cancelled: true };
|
||||
}
|
||||
|
||||
if (options?.setup) {
|
||||
await options.setup(this.sessionManager);
|
||||
}
|
||||
|
||||
// Clear UI state
|
||||
this.chatContainer.clear();
|
||||
this.pendingMessagesContainer.clear();
|
||||
this.compactionQueuedMessages = [];
|
||||
|
|
@ -1011,8 +1009,8 @@ export class InteractiveMode {
|
|||
this.streamingMessage = undefined;
|
||||
this.pendingTools.clear();
|
||||
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
this.chatContainer.addChild(new Text(`${theme.fg("accent", "✓ New session started")}`, 1, 1));
|
||||
// Render any messages added via setup, or show empty session
|
||||
this.renderInitialMessages();
|
||||
this.ui.requestRender();
|
||||
|
||||
return { cancelled: false };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue