@@ -822,31 +822,27 @@ func TestExpMcpReporter(t *testing.T) {
822822URI :"https://dev.coder.com" ,
823823},
824824},
825- // A completed update at this point from the watcher should be discarded.
825+ // A stable update now from the watcher should be discarded, as it is a
826+ // duplicate.
826827{
827828event :makeStatusEvent (agentapi .StatusStable ),
828829},
829830// Terminal becomes active again according to the screen watcher, but no
830831// new user message. This could be the AI agent being active again, but
831832// it could also be the user messing around. We will prefer not updating
832833// the status so the "working" update here should be skipped.
834+ //
835+ // TODO: How do we test the no-op updates? This update is skipped
836+ // because of the logic mentioned above, but how do we prove this update
837+ // was skipped because of that and not that the next update was skipped
838+ // because it is a duplicate state? We could mock the queue?
833839{
834840event :makeStatusEvent (agentapi .StatusRunning ),
835841},
836842// Agent messages are ignored.
837843{
838844event :makeMessageEvent (0 ,agentapi .RoleAgent ),
839845},
840- // AI agent reports that it failed and URI is blank.
841- {
842- state :codersdk .WorkspaceAppStatusStateFailure ,
843- summary :"oops" ,
844- expected :& codersdk.WorkspaceAppStatus {
845- State :codersdk .WorkspaceAppStatusStateFailure ,
846- Message :"oops" ,
847- URI :"" ,
848- },
849- },
850846// The watcher reports the screen is active again...
851847{
852848event :makeStatusEvent (agentapi .StatusRunning ),
@@ -857,17 +853,17 @@ func TestExpMcpReporter(t *testing.T) {
857853event :makeMessageEvent (1 ,agentapi .RoleUser ),
858854expected :& codersdk.WorkspaceAppStatus {
859855State :codersdk .WorkspaceAppStatusStateWorking ,
860- Message :"oops " ,
861- URI :"" ,
856+ Message :"doing work " ,
857+ URI :"https://dev.coder.com " ,
862858},
863859},
864860// Watcher reports stable again.
865861{
866862event :makeStatusEvent (agentapi .StatusStable ),
867863expected :& codersdk.WorkspaceAppStatus {
868864State :codersdk .WorkspaceAppStatusStateIdle ,
869- Message :"oops " ,
870- URI :"" ,
865+ Message :"doing work " ,
866+ URI :"https://dev.coder.com " ,
871867},
872868},
873869},
@@ -924,6 +920,40 @@ func TestExpMcpReporter(t *testing.T) {
924920},
925921},
926922},
923+ // We ignore the state from the agent and assume "working".
924+ {
925+ name :"IgnoreAgentState" ,
926+ // AI agent reports that it is finished but the summary says it is doing
927+ // work.
928+ tests : []test {
929+ {
930+ state :codersdk .WorkspaceAppStatusStateIdle ,
931+ summary :"doing work" ,
932+ expected :& codersdk.WorkspaceAppStatus {
933+ State :codersdk .WorkspaceAppStatusStateWorking ,
934+ Message :"doing work" ,
935+ },
936+ },
937+ // AI agent reports finished again, with a matching summary. We still
938+ // assume it is working.
939+ {
940+ state :codersdk .WorkspaceAppStatusStateIdle ,
941+ summary :"finished" ,
942+ expected :& codersdk.WorkspaceAppStatus {
943+ State :codersdk .WorkspaceAppStatusStateWorking ,
944+ Message :"finished" ,
945+ },
946+ },
947+ // Once the watcher reports stable, then we record idle.
948+ {
949+ event :makeStatusEvent (agentapi .StatusStable ),
950+ expected :& codersdk.WorkspaceAppStatus {
951+ State :codersdk .WorkspaceAppStatusStateIdle ,
952+ Message :"finished" ,
953+ },
954+ },
955+ },
956+ },
927957}
928958
929959for _ ,run := range runs {