Skip to content

Conversation

eneufeld
Copy link
Contributor

What it does

fixes #15503

How to test

Follow-ups

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Review checklist

Reminder for reviewers

@github-project-automation github-project-automation bot moved this to Waiting on reviewers in PR Backlog Apr 23, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces new tool providers to enhance the IDE's functionality by allowing users to list, run, and search tasks within the workspace. Key changes include:

  • Adding TaskListProvider for filtering and listing available tasks.
  • Implementing TaskRunnerProvider for executing specified tasks.
  • Creating WorkspaceSearchProvider for searching file content, with updated module bindings.

Reviewed Changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.

File Description
packages/ai-ide/src/browser/workspace-task-provider.ts Adds TaskListProvider and TaskRunnerProvider for task management.
packages/ai-ide/src/browser/workspace-search-provider.ts Adds WorkspaceSearchProvider for content search in the workspace.
packages/ai-ide/src/browser/frontend-module.ts Updates bindings to include the new providers.
Files not reviewed (2)
  • packages/ai-ide/package.json: Language not supported
  • packages/ai-ide/tsconfig.json: Language not supported

Comment on lines 105 to 108
cancellationToken.onCancellationRequested(() => {
this.taskService.terminateTask(taskInfo);
});
const terminal = this.terminalService.getByTerminalId(taskInfo.terminalId!);
Copy link
Preview

Copilot AI Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure cancellationToken is defined before invoking onCancellationRequested; consider making the cancellationToken parameter optional or adding a null check to prevent potential runtime errors.

Suggested change
cancellationToken.onCancellationRequested(() => {
this.taskService.terminateTask(taskInfo);
});
const terminal = this.terminalService.getByTerminalId(taskInfo.terminalId!);
if (cancellationToken) {
cancellationToken.onCancellationRequested(() => {
this.taskService.terminateTask(taskInfo);
});
}

Copilot uses AI. Check for mistakes.

cancellationToken.onCancellationRequested(() => {
this.taskService.terminateTask(taskInfo);
});
const terminal = this.terminalService.getByTerminalId(taskInfo.terminalId!);
Copy link
Preview

Copilot AI Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using a non-null assertion on taskInfo.terminalId; verify its existence before retrieving the terminal to prevent potential runtime errors.

Suggested change
const terminal = this.terminalService.getByTerminalId(taskInfo.terminalId!);
if (!taskInfo.terminalId) {
return `Task '${args.taskName}' does not have an associated terminal.`;
}
const terminal = this.terminalService.getByTerminalId(taskInfo.terminalId);

Copilot uses AI. Check for mistakes.

@eneufeld eneufeld requested a review from Copilot April 23, 2025 09:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds new tools for managing tasks and searching the workspace.

  • Introduces TaskListProvider and TaskRunnerProvider to list and run tasks.
  • Implements WorkspaceSearchProvider for file content search.
  • Registers the new providers in the frontend module.

Reviewed Changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.

File Description
packages/ai-ide/src/browser/workspace-task-provider.ts Implements task listing and execution tools.
packages/ai-ide/src/browser/workspace-search-provider.ts Adds workspace search functionality.
packages/ai-ide/src/browser/frontend-module.ts Registers new tool providers with the frontend module.
Files not reviewed (2)
  • packages/ai-ide/package.json: Language not supported
  • packages/ai-ide/tsconfig.json: Language not supported

Comment on lines +117 to +119
const allLines = terminal?.buffer.getLines(0, length).reverse() ?? [];

// collect the first 50 lines:
const firstLines = allLines.slice(0, numberOfLines);
result.push(...firstLines);
// collect the last 50 lines:
if (length > numberOfLines) {
const lastLines = allLines.slice(length - numberOfLines);
Copy link
Preview

Copilot AI Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for retrieving terminal output lines may lead to overlapping or unexpected results when slicing for the first and last 50 lines due to the use of reverse before slicing. Consider revising the approach to capture these segments from the original order separately.

Suggested change
const allLines = terminal?.buffer.getLines(0, length).reverse() ?? [];
// collect the first 50 lines:
const firstLines = allLines.slice(0, numberOfLines);
result.push(...firstLines);
// collect the last 50 lines:
if (length > numberOfLines) {
const lastLines = allLines.slice(length - numberOfLines);
const allLines = terminal?.buffer.getLines(0, length) ?? [];
// collect the first 50 lines:
const firstLines = allLines.slice(0, numberOfLines);
result.push(...firstLines);
// collect the last 50 lines:
if (length > numberOfLines) {
const lastLines = allLines.slice(-numberOfLines);

Copilot uses AI. Check for mistakes.

return `No terminal output available. The terminate signal was :${signal}.`;

} catch (error) {
return JSON.stringify({ success: false, message: error.message || 'Failed to run task' });
Copy link
Preview

Copilot AI Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error handling assumes that the thrown 'error' object has a 'message' property, which might not always be true. Consider adding a type check or providing a default error value that safely handles non-Error objects.

Suggested change
return JSON.stringify({ success: false, message: error.message || 'Failed to run task' });
const errorMessage = error instanceof Error && error.message
? error.message
: typeof error === 'string'
? error
: JSON.stringify(error) || 'Failed to run task';
return JSON.stringify({ success: false, message: errorMessage });

Copilot uses AI. Check for mistakes.

@JonasHelming JonasHelming mentioned this pull request Apr 23, 2025
13 tasks
description: 'Lists available tasks filtered by name.',
parameters: {
type: 'object',
properties: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether the filtering by name really adds value. Usually projects have less than 30 tasks, which should be fine to always return.

@planger planger self-requested a review April 24, 2025 13:01
Copy link
Contributor

@planger planger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the liberty to directly make some changes.
I had issues as the list of tasks we provide to the LLM wasn't the same as we used for retrieving the command to execute. Also the search should be case-insensitive.

This change is now fine with me and works great!

image

@github-project-automation github-project-automation bot moved this from Waiting on reviewers to Needs merge in PR Backlog Apr 24, 2025
@eneufeld eneufeld force-pushed the gh-15503 branch 2 times, most recently from 98e2f5b to 7186042 Compare April 25, 2025 10:51
Comment on lines 58 to 62
To locate a file within the workspace, use the ~{searchInWorkspace} feature.

## Tasks

The user might want you to execute some task. You can find tasks using ~{listTasks} and execute them using ~{runTask}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use the constants to refer to the tool functions?

Copy link
Contributor

@JonasHelming JonasHelming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one wording suggestion

@eneufeld eneufeld merged commit 620d284 into master Apr 25, 2025
9 of 11 checks passed
@github-project-automation github-project-automation bot moved this from Needs merge to Done in PR Backlog Apr 25, 2025
@github-actions github-actions bot added this to the 1.61.0 milestone Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add support for running tasks
3 participants