-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add a new tools which allow to list and run tasks #15504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
cancellationToken.onCancellationRequested(() => { | ||
this.taskService.terminateTask(taskInfo); | ||
}); | ||
const terminal = this.terminalService.getByTerminalId(taskInfo.terminalId!); |
There was a problem hiding this comment.
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.
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!); |
There was a problem hiding this comment.
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.
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.
There was a problem hiding this 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
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); |
There was a problem hiding this comment.
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.
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' }); |
There was a problem hiding this comment.
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.
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.
description: 'Lists available tasks filtered by name.', | ||
parameters: { | ||
type: 'object', | ||
properties: { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
98e2f5b
to
7186042
Compare
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}. |
There was a problem hiding this comment.
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?
There was a problem hiding this 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
Co-authored-by: Jonas Helming <jhelming@eclipsesource.com>
What it does
fixes #15503
How to test
Follow-ups
Breaking changes
Attribution
Review checklist
Reminder for reviewers