Skip to content

Commit a663a6b

Browse files
feat: add progress notifications during PR polling in assign_copilot_to_issue
Add MCP progress notifications during the PR polling loop to provide real-time status updates while waiting for Copilot to create a PR. Changes: - Use the request parameter to access the ServerSession for notifications - Send an initial progress notification when polling starts - Send progress updates on each polling attempt with attempt count - Only send notifications when progressToken is provided by the client This aligns with the behavior in create_pull_request_with_copilot tool and improves the user experience during the waiting period.
1 parent f1d33d5 commit a663a6b

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

pkg/github/issues.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ func AssignCopilotToIssue(t translations.TranslationHelperFunc) inventory.Server
17571757
},
17581758
},
17591759
[]scopes.Scope{scopes.Repo},
1760-
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
1760+
func(ctx context.Context, deps ToolDependencies, request *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
17611761
var params struct {
17621762
Owner string `mapstructure:"owner"`
17631763
Repo string `mapstructure:"repo"`
@@ -1919,12 +1919,35 @@ func AssignCopilotToIssue(t translations.TranslationHelperFunc) inventory.Server
19191919
// Poll for a linked PR created by Copilot after the assignment
19201920
pollConfig := getPollConfig(ctx)
19211921

1922+
// Get progress token from request for sending progress notifications
1923+
progressToken := request.Params.GetProgressToken()
1924+
1925+
// Send initial progress notification that assignment succeeded and polling is starting
1926+
if progressToken != nil && request.Session != nil && pollConfig.MaxAttempts > 0 {
1927+
_ = request.Session.NotifyProgress(ctx, &mcp.ProgressNotificationParams{
1928+
ProgressToken: progressToken,
1929+
Progress: 0,
1930+
Total: float64(pollConfig.MaxAttempts),
1931+
Message: "Copilot assigned to issue, waiting for PR creation...",
1932+
})
1933+
}
1934+
19221935
var linkedPR *linkedPullRequest
19231936
for attempt := range pollConfig.MaxAttempts {
19241937
if attempt > 0 {
19251938
time.Sleep(pollConfig.Delay)
19261939
}
19271940

1941+
// Send progress notification if progress token is available
1942+
if progressToken != nil && request.Session != nil {
1943+
_ = request.Session.NotifyProgress(ctx, &mcp.ProgressNotificationParams{
1944+
ProgressToken: progressToken,
1945+
Progress: float64(attempt + 1),
1946+
Total: float64(pollConfig.MaxAttempts),
1947+
Message: fmt.Sprintf("Waiting for Copilot to create PR... (attempt %d/%d)", attempt+1, pollConfig.MaxAttempts),
1948+
})
1949+
}
1950+
19281951
pr, err := findLinkedCopilotPR(ctx, client, params.Owner, params.Repo, int(params.IssueNumber), assignmentTime)
19291952
if err != nil {
19301953
// Polling errors are non-fatal, continue to next attempt

0 commit comments

Comments
 (0)