Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class ChatSessionContentBuilder {
private async createResponseTurn(pullRequest: PullRequestSearchItem, logs: string, session: SessionInfo): Promise<ChatResponseTurn2 | undefined> {
if (logs.trim().length > 0) {
return await this.parseSessionLogsIntoResponseTurn(pullRequest, logs, session);
} else if (session.state === 'in_progress') {
} else if (session.state === 'in_progress' || session.state === 'queued') {
// For in-progress sessions without logs, create a placeholder response
const placeholderParts = [new ChatResponseProgressPart('Session is initializing...')];
const responseResult: ChatResult = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,20 @@ export class CopilotChatSessionsProvider extends Disposable implements vscode.Ch
pr: PullRequestSearchItem
): ((stream: vscode.ChatResponseStream, token: vscode.CancellationToken) => Thenable<void>) | undefined {
// Only the latest in-progress session gets activeResponseCallback
const inProgressSession = sessions
const pendingSession = sessions
.slice()
.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())
.find(session => session.state === 'in_progress');
.find(session => session.state === 'in_progress' || session.state === 'queued');

if (inProgressSession) {
return this.createActiveResponseCallback(pr, inProgressSession.id);
if (pendingSession) {
return this.createActiveResponseCallback(pr, pendingSession.id);
}
return undefined;
}

private createActiveResponseCallback(pr: PullRequestSearchItem, sessionId: string): (stream: vscode.ChatResponseStream, token: vscode.CancellationToken) => Thenable<void> {
return async (stream: vscode.ChatResponseStream, token: vscode.CancellationToken) => {
await this.waitForQueuedToInProgress(sessionId, token);
return this.streamSessionLogs(stream, pr, sessionId, token);
};
}
Expand Down Expand Up @@ -845,6 +846,10 @@ export class CopilotChatSessionsProvider extends Disposable implements vscode.Ch
} while (waitForQueuedCount <= waitForQueuedMaxRetries && (!token || !token.isCancellationRequested));

if (!sessionInfo || sessionInfo.state !== 'queued') {
if (sessionInfo?.state === 'in_progress') {
this.logService.trace('Session already in progress');
return sessionInfo;
}
// Failure
this.logService.trace('Failed to find queued session');
return;
Expand All @@ -863,6 +868,7 @@ export class CopilotChatSessionsProvider extends Disposable implements vscode.Ch
}
await new Promise(resolve => setTimeout(resolve, pollInterval));
}
this.logService.error(`Timed out waiting for session ${sessionId} to transition from queued to in_progress.`);
}

private async waitForNewSession(
Expand Down Expand Up @@ -1121,9 +1127,6 @@ export class CopilotChatSessionsProvider extends Disposable implements vscode.Ch

const webviewUri = await toOpenPullRequestWebviewUri({ owner: pullRequest.repository.owner.login, repo: pullRequest.repository.name, pullRequestNumber: number });
const prLlmString = `The remote agent has begun work and has created a pull request. Details about the pull request are being shown to the user. If the user wants to track progress or iterate on the agent's work, they should use the pull request.`;

chatStream?.progress(vscode.l10n.t('Attaching to session'));
await this.waitForQueuedToInProgress(response.session_id, token);
return {
state: 'success',
number,
Expand Down
Loading