Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1006b98

Browse files
committed
fix: accept initial watcher status
We are discarding all "working" updates from the screen watcher that does not include a new user message, but it makes sense to accept the very first message, because the agent could be working but neglected to report that fact.
1 parent e03d132 commit 1006b98

File tree

2 files changed

+259
-211
lines changed

2 files changed

+259
-211
lines changed

cli/exp_mcp.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -399,18 +399,25 @@ func (r *RootCmd) mcpServer() *serpent.Command {
399399
// new user message, and the status is "working" and not self-reported
400400
// (meaning it came from the screen watcher), then it means one of two
401401
// things:
402-
// 1. The AI agent is still working, so there is nothing to update.
403-
// 2. The AI agent stopped working, then the user has interacted with
404-
// the terminal directly. For now, we are ignoring these updates.
405-
// This risks missing cases where the user manually submits a new
406-
// prompt and the AI agent becomes active and does not update itself,
407-
// but it avoids spamming useless status updates as the user is
408-
// typing, so the tradeoff is worth it. In the future, if we can
409-
// reliably distinguish between user and AI agent activity, we can
410-
// change this.
402+
//
403+
// 1. The AI agent is not working; the user is interacting with the
404+
// terminal directly.
405+
// 2. The AI agent is working.
406+
//
407+
// At the moment, we have no way to tell the difference between these
408+
// two states. In the future, if we can reliably distinguish between
409+
// user and AI agent activity, we can change this.
410+
//
411+
// If this is our first update, we assume it is the AI agent working and
412+
// accept the update.
413+
//
414+
// Otherwise we discard the update. This risks missing cases where the
415+
// user manually submits a new prompt and the AI agent becomes active
416+
// (and does not update itself), but it avoids spamming useless status
417+
// updates as the user is typing, so the tradeoff is worth it.
411418
if report.messageID > lastUserMessageID {
412419
report.state = codersdk.WorkspaceAppStatusStateWorking
413-
} else if report.state == codersdk.WorkspaceAppStatusStateWorking && !report.selfReported {
420+
} else if report.state == codersdk.WorkspaceAppStatusStateWorking && !report.selfReported && lastReport.state != "" {
414421
return report, false
415422
}
416423
// Preserve previous message and URI if there was no message.

0 commit comments

Comments
 (0)