-
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2020 Red Hat, Inc. and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { inject, injectable } from 'inversify'; | ||
import { TerminalWidgetFactoryOptions, TERMINAL_WIDGET_FACTORY_ID } from '@theia/terminal/lib/browser/terminal-widget-impl'; | ||
import { TerminalWidget } from '@theia/terminal/lib/browser/base/terminal-widget'; | ||
import { ApplicationShell, WidgetManager } from '@theia/core/lib/browser'; | ||
import { TaskInfo, RevealKind } from '../common'; | ||
|
||
@injectable() | ||
export class TaskTerminalManager { | ||
|
||
@inject(WidgetManager) | ||
protected readonly widgetManager: WidgetManager; | ||
|
||
@inject(ApplicationShell) | ||
protected readonly shell: ApplicationShell; | ||
|
||
async openEmptyTerminal(taskLabel: string): Promise<TerminalWidget> { | ||
const id = TERMINAL_WIDGET_FACTORY_ID + '-connecting'; | ||
|
||
const widget = <TerminalWidget>await this.widgetManager.getOrCreateWidget( | ||
TERMINAL_WIDGET_FACTORY_ID, | ||
<TerminalWidgetFactoryOptions>{ | ||
created: new Date().toString(), | ||
id: id, | ||
title: taskLabel, | ||
destroyTermOnClose: true, | ||
loadingMessage: `Task '${taskLabel}' - Connecting...` | ||
} | ||
); | ||
|
||
this.shell.addWidget(widget, { area: 'bottom' }); | ||
this.shell.revealWidget(widget.id); | ||
return widget; | ||
} | ||
|
||
async attach(processId: number, taskId: number, taskInfo: TaskInfo | undefined, | ||
terminalWidgetId: string, widget?: TerminalWidget): Promise<void> { | ||
if (!widget) { | ||
widget = <TerminalWidget>await this.widgetManager.getOrCreateWidget( | ||
TERMINAL_WIDGET_FACTORY_ID, | ||
<TerminalWidgetFactoryOptions>{ | ||
created: new Date().toString(), | ||
id: terminalWidgetId, | ||
title: taskInfo | ||
? `Task: ${taskInfo.config.label}` | ||
: `Task: #${taskId}`, | ||
destroyTermOnClose: true | ||
} | ||
); | ||
|
||
this.shell.addWidget(widget, { area: 'bottom' }); | ||
} | ||
|
||
if (taskInfo && taskInfo.config.presentation && taskInfo.config.presentation.reveal === RevealKind.Always) { | ||
if (taskInfo.config.presentation.focus) { // assign focus to the terminal if presentation.focus is true | ||
this.shell.activateWidget(widget.id); | ||
} else { // show the terminal but not assign focus | ||
this.shell.revealWidget(widget.id); | ||
} | ||
} | ||
|
||
widget.start(processId); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
@inject(WorkspaceService) protected readonly workspaceService: WorkspaceService; | ||
@inject(WebSocketConnectionProvider) protected readonly webSocketConnectionProvider: WebSocketConnectionProvider; | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. please use css, you can find css guidance in our coding guidelines |
||
this.loadingMessage.style.zIndex = '20'; | ||
this.loadingMessage.style.display = 'block'; | ||
this.loadingMessage.style.position = 'absolute'; | ||
this.loadingMessage.style.left = '0px'; | ||
this.loadingMessage.style.right = '0px'; | ||
this.loadingMessage.style.top = '30%'; | ||
this.loadingMessage.style.textAlign = 'center'; | ||
this.loadingMessage.style.color = 'var(--theia-editorWidget-foreground)'; | ||
|
||
const text = document.createElement('pre'); | ||
text.textContent = this.options.loadingMessage; | ||
this.loadingMessage.appendChild(text); | ||
|
||
this.node.appendChild(this.loadingMessage); | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -280,6 +299,12 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget | |
this.terminalId = typeof id !== 'number' ? await this.createTerminal() : await this.attachTerminal(id); | ||
this.resizeTerminalProcess(); | ||
this.connectTerminalProcess(); | ||
|
||
// Hide loading message after starting the terminal. | ||
if (this.loadingMessage) { | ||
this.loadingMessage.style.display = 'none'; | ||
} | ||
|
||
if (IBaseTerminalServer.validateId(this.terminalId)) { | ||
this.onDidOpenEmitter.fire(undefined); | ||
return this.terminalId; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.