Keep PR status current after agent merges (#1455)
* feat(server): refresh PR state promptly after agent merges via gh CLI When an agent merges a PR with gh pr merge, the app could take up to 2 minutes to show the merged state because: - gh pr merge is a remote GitHub operation that does not touch local git refs, so file watchers never fire - the GitHub self-heal poll runs on a 2-minute slow interval for settled PRs - no refresh is triggered when agent tool calls complete Add a detection path that intercepts completed shell tool calls in the agent manager and signals the workspace git service when a command may have changed external state (gh *, git push, npm publish). The git service then invalidates the GitHub cache and schedules a forced GitHub-inclusive refresh, so the updated PR state arrives within ~500ms. The agent manager does not leak cache semantics; it calls a semantic onWorkspaceStateMayHaveChanged callback and lets the git service decide what that means internally. * refactor(server): share workspace refresh merge logic
This commit is contained in:
@@ -521,6 +521,7 @@ function createSessionForWorkspaceTests(
|
||||
unsubscribe: () => {},
|
||||
}),
|
||||
scheduleRefreshForCwd: () => {},
|
||||
onWorkspaceStateMayHaveChanged: () => {},
|
||||
getMetrics: () => ({
|
||||
checkoutDiffTargetCount: 0,
|
||||
checkoutDiffSubscriptionCount: 0,
|
||||
@@ -631,6 +632,7 @@ test("create_agent_request keeps requested child cwd when grouped under an exist
|
||||
unsubscribe: () => {},
|
||||
}),
|
||||
scheduleRefreshForCwd: () => {},
|
||||
onWorkspaceStateMayHaveChanged: () => {},
|
||||
getMetrics: () => ({
|
||||
checkoutDiffTargetCount: 0,
|
||||
checkoutDiffSubscriptionCount: 0,
|
||||
@@ -1013,6 +1015,7 @@ test("archive emits an authoritative agent_update upsert for subscribed clients"
|
||||
unsubscribe: () => {},
|
||||
}),
|
||||
scheduleRefreshForCwd: () => {},
|
||||
onWorkspaceStateMayHaveChanged: () => {},
|
||||
getMetrics: () => ({
|
||||
checkoutDiffTargetCount: 0,
|
||||
checkoutDiffSubscriptionCount: 0,
|
||||
@@ -1373,6 +1376,7 @@ test("close_items_request archives agents and kills terminals in one batch", asy
|
||||
unsubscribe: () => {},
|
||||
}),
|
||||
scheduleRefreshForCwd: () => {},
|
||||
onWorkspaceStateMayHaveChanged: () => {},
|
||||
getMetrics: () => ({
|
||||
checkoutDiffTargetCount: 0,
|
||||
checkoutDiffSubscriptionCount: 0,
|
||||
@@ -1562,6 +1566,7 @@ test("close_items_request archives stored agents that are not currently loaded",
|
||||
unsubscribe: () => {},
|
||||
}),
|
||||
scheduleRefreshForCwd: () => {},
|
||||
onWorkspaceStateMayHaveChanged: () => {},
|
||||
getMetrics: () => ({
|
||||
checkoutDiffTargetCount: 0,
|
||||
checkoutDiffSubscriptionCount: 0,
|
||||
@@ -1712,6 +1717,7 @@ test("close_items_request continues after an archive failure", async () => {
|
||||
unsubscribe: () => {},
|
||||
}),
|
||||
scheduleRefreshForCwd: () => {},
|
||||
onWorkspaceStateMayHaveChanged: () => {},
|
||||
getMetrics: () => ({
|
||||
checkoutDiffTargetCount: 0,
|
||||
checkoutDiffSubscriptionCount: 0,
|
||||
@@ -2578,6 +2584,7 @@ test("workspace update stream keeps persisted workspace visible after agents sto
|
||||
unsubscribe: () => {},
|
||||
}),
|
||||
scheduleRefreshForCwd: () => {},
|
||||
onWorkspaceStateMayHaveChanged: () => {},
|
||||
getMetrics: () => ({
|
||||
checkoutDiffTargetCount: 0,
|
||||
checkoutDiffSubscriptionCount: 0,
|
||||
|
||||
Reference in New Issue
Block a user