@@ -822,31 +822,27 @@ func TestExpMcpReporter(t *testing.T) {
822
822
URI : "https://dev.coder.com" ,
823
823
},
824
824
},
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.
826
827
{
827
828
event : makeStatusEvent (agentapi .StatusStable ),
828
829
},
829
830
// Terminal becomes active again according to the screen watcher, but no
830
831
// new user message. This could be the AI agent being active again, but
831
832
// it could also be the user messing around. We will prefer not updating
832
833
// 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?
833
839
{
834
840
event : makeStatusEvent (agentapi .StatusRunning ),
835
841
},
836
842
// Agent messages are ignored.
837
843
{
838
844
event : makeMessageEvent (0 , agentapi .RoleAgent ),
839
845
},
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
- },
850
846
// The watcher reports the screen is active again...
851
847
{
852
848
event : makeStatusEvent (agentapi .StatusRunning ),
@@ -857,17 +853,17 @@ func TestExpMcpReporter(t *testing.T) {
857
853
event : makeMessageEvent (1 , agentapi .RoleUser ),
858
854
expected : & codersdk.WorkspaceAppStatus {
859
855
State : codersdk .WorkspaceAppStatusStateWorking ,
860
- Message : "oops " ,
861
- URI : "" ,
856
+ Message : "doing work " ,
857
+ URI : "https://dev.coder.com " ,
862
858
},
863
859
},
864
860
// Watcher reports stable again.
865
861
{
866
862
event : makeStatusEvent (agentapi .StatusStable ),
867
863
expected : & codersdk.WorkspaceAppStatus {
868
864
State : codersdk .WorkspaceAppStatusStateIdle ,
869
- Message : "oops " ,
870
- URI : "" ,
865
+ Message : "doing work " ,
866
+ URI : "https://dev.coder.com " ,
871
867
},
872
868
},
873
869
},
@@ -924,6 +920,40 @@ func TestExpMcpReporter(t *testing.T) {
924
920
},
925
921
},
926
922
},
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
+ },
927
957
}
928
958
929
959
for _ , run := range runs {
0 commit comments