Skip to content
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

Update message about task start/stop #5296

Merged
merged 1 commit into from
Jun 18, 2019
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
23 changes: 19 additions & 4 deletions packages/task/src/browser/task-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { TERMINAL_WIDGET_FACTORY_ID, TerminalWidgetFactoryOptions } from '@theia
import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service';
import { TerminalWidget } from '@theia/terminal/lib/browser/base/terminal-widget';
import { MessageService } from '@theia/core/lib/common/message-service';
import { TaskServer, TaskExitedEvent, TaskInfo, TaskConfiguration } from '../common/task-protocol';
import { TaskServer, TaskExitedEvent, TaskInfo, TaskConfiguration, ContributedTaskConfiguration } from '../common/task-protocol';
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
import { VariableResolverService } from '@theia/variable-resolver/lib/browser';
import { TaskWatcher } from '../common/task-watcher';
Expand Down Expand Up @@ -111,7 +111,14 @@ export class TaskService implements TaskConfigurationClient {
// notify user that task has started
this.taskWatcher.onTaskCreated((event: TaskInfo) => {
if (this.isEventForThisClient(event.ctx)) {
this.messageService.info(`Task #${event.taskId} created - ${event.config.label}`);
const task = event.config;
const taskIdentifier =
task
? ContributedTaskConfiguration.is(task)
? `${task._source}: ${task.label}`
: `${task.type}: ${task.label}`
: `${event.taskId}`;
this.messageService.info(`Task ${taskIdentifier} has been started`);
}
});

Expand All @@ -121,15 +128,23 @@ export class TaskService implements TaskConfigurationClient {
return;
}

const taskConfiguration = event.config;
const taskIdentifier =
taskConfiguration
? ContributedTaskConfiguration.is(taskConfiguration)
? `${taskConfiguration._source}: ${taskConfiguration.label}`
: `${taskConfiguration.type}: ${taskConfiguration.label}`
: `${event.taskId}`;

if (event.code !== undefined) {
const message = `Task ${event.taskId} has exited with code ${event.code}.`;
const message = `Task ${taskIdentifier} has exited with code ${event.code}.`;
if (event.code === 0) {
this.messageService.info(message);
} else {
this.messageService.error(message);
}
} else if (event.signal !== undefined) {
this.messageService.info(`Task ${event.taskId} was terminated by signal ${event.signal}.`);
this.messageService.info(`Task ${taskIdentifier} was terminated by signal ${event.signal}.`);
} else {
console.error('Invalid TaskExitedEvent received, neither code nor signal is set.');
}
Expand Down
2 changes: 2 additions & 0 deletions packages/task/src/common/task-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export interface TaskExitedEvent {
// Exactly one of code and signal will be set.
readonly code?: number;
readonly signal?: string;

readonly config?: TaskConfiguration;
Copy link
Contributor

Choose a reason for hiding this comment

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

i know that having an optional property does not break API. but is it good to make config optional? all exited tasks have a TaskConfiguration, so it does not look optional conceptually. what do you think @akosyakov ?

}

export interface TaskClient {
Expand Down
3 changes: 2 additions & 1 deletion packages/task/src/node/process/process-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export class ProcessTask extends Task {
taskId: this.taskId,
ctx: this.options.context,
code: event.code,
signal: event.signal
signal: event.signal,
config: this.options.config
});
});

Expand Down