-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[WIP] Display initial loading message in terminal #6957
Conversation
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
@vitaliy-guliy is there a way to reproduce with the vanilla Theia on master with system connection throttling? It would help to see the issue more clear and compare with the behavior proposed in the PR. Reproduction steps would help, thank you. |
export class TaskTerminal { | ||
|
||
@inject(WidgetManager) | ||
protected readonly widgetManager: WidgetManager; |
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.
Please use termialservice, it is responsible to create terminals and hides the logic of working with widhermanager
|
||
@injectable() | ||
export class TaskTerminal { | ||
|
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.
TaskTerminal will mean that it provides an access to a terminal for a task. This class seems to be responsible to manage many tasks terminals. TakTerminalManager or TaskTerminalService would be the better name. Also it will be aligned with other wrappers around WidgetManager, e.g. EditorManager, TerminalService and so on
@inject(ApplicationShell) | ||
protected readonly shell: ApplicationShell; | ||
|
||
protected terminalWidgets: TerminalWidget[] = []; |
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.
There is a single place which keeps references to all widget. It’s WidgetManager, please use its methods to look up terminal widgets, don’t cache it. Caching is common cause of race conditions, memory leaks and so on
/** | ||
* Initial message to be displayed while terminal is not started. | ||
*/ | ||
readonly loadingMessage?: string; |
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.
We should test reload page reload. What would you expect should happen? We try to preserve terminals. I assume terminal should appear immediately with loading message till connection to the task process is not recovered. We need ways to test it with the vanilla Theia.
@@ -193,6 +194,24 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget | |||
for (const contribution of this.terminalContributionProvider.getContributions()) { | |||
contribution.onCreate(this); | |||
} | |||
|
|||
if (this.options.loadingMessage) { | |||
this.loadingMessage = document.createElement('div'); |
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.
please use css, you can find css guidance in our coding guidelines
|
||
protected terminalWidgets: TerminalWidget[] = []; | ||
|
||
async openEmptyTerminal(taskLabel: string): Promise<void> { |
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.
How about returning a widget id here and passing it to attach later to avoid guessing?
@@ -454,6 +459,9 @@ export class TaskService implements TaskConfigurationClient { | |||
* It looks for configured and detected tasks. | |||
*/ | |||
async run(source: string, taskLabel: string, scope?: string): Promise<TaskInfo | undefined> { | |||
// Open an empty terminal, display a message informing the user that terminal is starting | |||
await this.taskTerminal.openEmptyTerminal(taskLabel); |
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 see that code below can exit without reaching attach ever what should happen with the terminal then?
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.
@elaihau can a task be executed without the terminal? background tasks?
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.
@vitaliy-guliy
Maybe it's not good place for creating a new terminal widget, for example here a task can be terminated or restarted, so how is a new terminal widget handled for this case?
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.
@elaihau can a task be executed without the terminal? background tasks?
@akosyakov sorry for replying so late.
as far as I can tell, we create terminalProcess for all tasks.
@marechal-p please correct me if i am wrong
@vitaliy-guliy let us know if you need help to prepare a test case for the vanilla Theia |
Signed-off-by: Vitaliy Guliy <vgulyy@redhat.com>
@@ -454,6 +459,9 @@ export class TaskService implements TaskConfigurationClient { | |||
* It looks for configured and detected tasks. | |||
*/ | |||
async run(source: string, taskLabel: string, scope?: string): Promise<TaskInfo | undefined> { | |||
// Open an empty terminal, display a message informing the user that terminal is starting | |||
await this.taskTerminal.openEmptyTerminal(taskLabel); |
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.
@vitaliy-guliy
Maybe it's not good place for creating a new terminal widget, for example here a task can be terminated or restarted, so how is a new terminal widget handled for this case?
@@ -54,6 +54,7 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget | |||
protected waitForConnection: Deferred<MessageConnection> | undefined; | |||
protected hoverMessage: HTMLDivElement; | |||
protected lastTouchEnd: TouchEvent | undefined; | |||
protected loadingMessage: HTMLDivElement; |
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.
if (taskInfo && taskInfo.config.label) { | ||
for (let i = 0; i < this.terminalWidgets.length; i++) { | ||
const w = this.terminalWidgets[i]; | ||
if (taskInfo.config.label === w.title.label) { |
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 think label usage to find the corresponding widget is not enough: user can have tasks with the same label, but different source or type, for example.
@vitaliy-guliy |
Signed-off-by: Vitaliy Guliy <vgulyy@redhat.com>
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
@akosyakov sorry for the delay. I cannot reproduce the problem with the vanilla Theia running on che.openshift.io and on the local machine. Network throttling does not affect on the delay. It looks like |
Signed-off-by: Vitaliy Gulyy vgulyy@redhat.com
What it does
It's a solution proposal.
On slow infrastructures after running a task user has to wait for several seconds until task terminal is appeared. On che.openshift.io where an extension of Theia is running, this delay is around 5 seconds.
The main idea is to open a terminal immediately when the user asked for running a task.
Terminal should have an initial message e.g.
Task '${taskLabel}' - Connecting...
Solves issue eclipse-che/che#15277
The corresponding issue into Theia repository and demo videos demonstrating the problem will be created and recorded.
How to test
Review checklist
Reminder for reviewers