fix: emit state after refreshing runtime info so clients get model updates
The Claude agent model was not showing in the UI ("Model: Unknown") because
refreshRuntimeInfo() updated agent.runtimeInfo but never called emitState()
to notify connected clients of the change.
Fixed by:
1. Adding change detection in refreshRuntimeInfo() to check if model, sessionId,
or modeId changed
2. Calling emitState(agent) when changes are detected
3. Added debug logging in handleSystemMessage() to confirm model capture
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
071f83db86
commit
1bf4a1d478
@@ -782,7 +782,16 @@ export class AgentManager {
|
||||
|
||||
private async refreshRuntimeInfo(agent: ActiveManagedAgent): Promise<void> {
|
||||
try {
|
||||
agent.runtimeInfo = await agent.session.getRuntimeInfo();
|
||||
const newInfo = await agent.session.getRuntimeInfo();
|
||||
const changed =
|
||||
newInfo.model !== agent.runtimeInfo?.model ||
|
||||
newInfo.sessionId !== agent.runtimeInfo?.sessionId ||
|
||||
newInfo.modeId !== agent.runtimeInfo?.modeId;
|
||||
agent.runtimeInfo = newInfo;
|
||||
// Emit state if runtimeInfo changed so clients get the updated model
|
||||
if (changed) {
|
||||
this.emitState(agent);
|
||||
}
|
||||
} catch {
|
||||
// Keep existing runtimeInfo if refresh fails.
|
||||
}
|
||||
|
||||
@@ -875,6 +875,7 @@ class ClaudeAgentSession implements AgentSession {
|
||||
this.persistence = null;
|
||||
// Capture actual model from SDK init message (not just the configured model)
|
||||
if (message.model) {
|
||||
console.log(`[ClaudeAgentSession] Captured model from SDK init: ${message.model}`);
|
||||
this.lastOptionsModel = message.model;
|
||||
// Invalidate cached runtime info so it picks up the new model
|
||||
this.cachedRuntimeInfo = null;
|
||||
|
||||
Reference in New Issue
Block a user