(t *testing.T)
| 1297 | } |
| 1298 | |
| 1299 | func TestE2E_SubagentAncestorWatch(t *testing.T) { |
| 1300 | t.Parallel() |
| 1301 | |
| 1302 | ctx := testutil.Context(t, testutil.WaitLong) |
| 1303 | repoDir := initTestRepo(t) |
| 1304 | |
| 1305 | // Write a dirty file that the child agent will "touch". |
| 1306 | require.NoError(t, os.WriteFile(filepath.Join(repoDir, "child.go"), []byte("package child\n"), 0o600)) |
| 1307 | |
| 1308 | ps := agentgit.NewPathStore() |
| 1309 | parentChatID := uuid.New() |
| 1310 | childChatID := uuid.New() |
| 1311 | mClock := quartz.NewMock(t) |
| 1312 | |
| 1313 | // Connect a git watch WebSocket for the PARENT chat. |
| 1314 | stream := dialGitWatchWithPathStore(t, ps, parentChatID, agentgit.WithClock(mClock)) |
| 1315 | ch := stream.Chan() |
| 1316 | |
| 1317 | // Simulate a tool call from the CHILD chat with the parent as |
| 1318 | // ancestor. The PathStore propagates the paths to all ancestor |
| 1319 | // chat IDs. |
| 1320 | ps.AddPaths([]uuid.UUID{childChatID, parentChatID}, []string{filepath.Join(repoDir, "child.go")}) |
| 1321 | |
| 1322 | // The parent's git watch connection should receive a changes |
| 1323 | // message because AddPaths notified parentChatID's subscribers. |
| 1324 | msg := recvMsg(ctx, t, ch) |
| 1325 | require.Equal(t, codersdk.WorkspaceAgentGitServerMessageTypeChanges, msg.Type) |
| 1326 | require.NotEmpty(t, msg.Repositories) |
| 1327 | |
| 1328 | foundRepo := false |
| 1329 | for _, r := range msg.Repositories { |
| 1330 | if r.RepoRoot == repoDir { |
| 1331 | foundRepo = true |
| 1332 | require.Contains(t, r.UnifiedDiff, "child.go") |
| 1333 | } |
| 1334 | } |
| 1335 | require.True(t, foundRepo, "parent watcher should see repo from child's tool call") |
| 1336 | } |
| 1337 | |
| 1338 | func TestE2E_MultipleConcurrentChatWatchers(t *testing.T) { |
| 1339 | t.Parallel() |
nothing calls this directly
no test coverage detected