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

Server offline landing clean #5

Closed
wants to merge 1 commit into from
Closed
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
1 change: 0 additions & 1 deletion vscode-trace-common/src/client/tsp-client-provider-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export class TspClientProvider implements ITspClientProvider {
this._signalHandler?.notifyConnection(status);
};
RestClient.addConnectionStatusListener(this._statusListener);
this._tspClient.checkHealth();

this._urlProvider = _urlProvider;
this._listeners = [];
Expand Down
7 changes: 6 additions & 1 deletion vscode-trace-common/src/messages/vscode-message-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export const VSCODE_MESSAGES = {
REQUEST_SELECTION_RANGE_CHANGE: 'requestSelectionRangeChange',
RESTORE_VIEW: 'restoreView',
RESTORE_COMPLETE: 'restoreComplete',
OUTPUT_DATA_CHANGED: 'outputDataChanged'
OUTPUT_DATA_CHANGED: 'outputDataChanged',
START_SERVER: 'startServer',
};

export class VsCodeMessageManager extends Messages.MessageManager {
Expand Down Expand Up @@ -193,4 +194,8 @@ export class VsCodeMessageManager extends Messages.MessageManager {
const status: string = JSON.stringify(context);
vscode.postMessage({ command: VSCODE_MESSAGES.MARKER_CATEGORIES_CONTEXT, data: { status } });
}

startServer(): void {
vscode.postMessage({ command: VSCODE_MESSAGES.START_SERVER });
}
}
15 changes: 11 additions & 4 deletions vscode-trace-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,28 +124,35 @@
},
"views": {
"trace-explorer": [
{
"type": "webview",
"id": "traceExplorer.welcomeView",
"name": "Welcome",
"when": "trace-explorer.noExperiments || !traceViewer.serverOn"
},
{
"type": "webview",
"id": "traceExplorer.openedTracesView",
"name": "Opened Traces"
"name": "Opened Traces",
"when": "!trace-explorer.noExperiments && traceViewer.serverOn"
},
{
"type": "webview",
"id": "traceExplorer.availableViews",
"name": "Views",
"when": "!trace-explorer.noExperiments"
"when": "!trace-explorer.noExperiments && traceViewer.serverOn"
},
{
"type": "webview",
"id": "traceExplorer.timeRangeDataView",
"name": "Time Range Data",
"when": "!trace-explorer.noExperiments"
"when": "!trace-explorer.noExperiments && traceViewer.serverOn"
},
{
"type": "webview",
"id": "traceExplorer.itemPropertiesView",
"name": "Item Properties",
"when": "!trace-explorer.noExperiments"
"when": "!trace-explorer.noExperiments && traceViewer.serverOn"
}
]
},
Expand Down
57 changes: 41 additions & 16 deletions vscode-trace-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { TraceExplorerItemPropertiesProvider } from './trace-explorer/properties
import { TraceExplorerTimeRangeDataProvider } from './trace-explorer/time-range/trace-explorer-time-range-data-webview-provider';
import { TraceExplorerAvailableViewsProvider } from './trace-explorer/available-views/trace-explorer-available-views-webview-provider';
import { TraceExplorerOpenedTracesViewProvider } from './trace-explorer/opened-traces/trace-explorer-opened-traces-webview-provider';
import { TraceExplorerWelcomeViewProvider } from './trace-explorer/welcome-view/trace-explorer-welcome-webview-provider';

import {
fileHandler,
openOverviewHandler,
Expand All @@ -31,7 +33,7 @@ const tspClientProvider = new TspClientProvider(getTspClientUrl(), undefined, ne

export function activate(context: vscode.ExtensionContext): ExternalAPI {
traceLogger = new TraceExtensionLogger('Trace Extension');

vscode.commands.executeCommand('setContext', 'traceViewer.serverOn', false);
const serverStatusBarItemPriority = 1;
const serverStatusBarItem = vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Right,
Expand Down Expand Up @@ -60,6 +62,11 @@ export function activate(context: vscode.ExtensionContext): ExternalAPI {
vscode.window.registerWebviewViewProvider(TraceExplorerTimeRangeDataProvider.viewType, timeRangeDataProvider)
);

const welcomeViewProvider = new TraceExplorerWelcomeViewProvider(context.extensionUri, serverStatusService)
context.subscriptions.push(
vscode.window.registerWebviewViewProvider(TraceExplorerWelcomeViewProvider.viewType, welcomeViewProvider)
);

context.subscriptions.push(
vscode.commands.registerCommand('messages.post.propertiespanel', (command: string, data) => {
if (propertiesProvider) {
Expand All @@ -68,12 +75,24 @@ export function activate(context: vscode.ExtensionContext): ExternalAPI {
})
);

const updateUris = async (): Promise<void> => {
const baseUri = vscode.Uri.parse(getTraceServerUrl());
const extUri = await vscode.env.asExternalUri(baseUri);
const extUriString = extUri.toString();

tracesProvider.updateTraceServerUrl(extUriString);
myAnalysisProvider.updateTraceServerUrl(extUriString);
TraceViewerPanel.updateTraceServerUrl(extUriString);
};

const analysisProvider = new AnalysisProvider();
// TODO: For now, a different command opens traces from file explorer. Remove when we have a proper trace finder
const fileOpenHandler = fileHandler(analysisProvider);

context.subscriptions.push(
vscode.commands.registerCommand('traces.openTraceFile', async (file: vscode.Uri) => {
await startTraceServerIfAvailable(file.fsPath);
await updateUris();
if (await isUp()) {
fileOpenHandler(context, file);
}
Expand All @@ -91,14 +110,7 @@ export function activate(context: vscode.ExtensionContext): ExternalAPI {
}

if (e.affectsConfiguration('trace-compass.traceserver.url')) {
const newUrl = getTraceServerUrl();

// Signal the change to the `Opened traces` and `Available views` webview
tracesProvider.updateTraceServerUrl(newUrl);
myAnalysisProvider.updateTraceServerUrl(newUrl);

// Signal the change to all trace panels
TraceViewerPanel.updateTraceServerUrl(newUrl);
updateUris();
}
})
);
Expand Down Expand Up @@ -157,6 +169,7 @@ export function activate(context: vscode.ExtensionContext): ExternalAPI {
context.subscriptions.push(
vscode.commands.registerCommand('openedTraces.openTraceFolder', async () => {
await startTraceServerIfAvailable();
await updateUris();
if (await isUp()) {
fileOpenHandler(context, undefined);
}
Expand All @@ -169,21 +182,32 @@ export function activate(context: vscode.ExtensionContext): ExternalAPI {
})
);

context.subscriptions.push(vscode.commands.registerCommand('serverStatus.started', () => {
serverStatusService.render(true);
vscode.commands.executeCommand('setContext', 'traceViewer.serverOn', true);
updateUris();
if (tracesProvider) {
tracesProvider.postMessagetoWebview(VSCODE_MESSAGES.TRACE_SERVER_STARTED, undefined);
}
}));

context.subscriptions.push(
vscode.commands.registerCommand('serverStatus.started', () => {
serverStatusService.render(true);
if (tracesProvider) {
tracesProvider.postMessagetoWebview(VSCODE_MESSAGES.TRACE_SERVER_STARTED, undefined);
}
vscode.commands.registerCommand('serverStatus.stopped', () => {
vscode.commands.executeCommand('setContext', 'traceViewer.serverOn', false);
serverStatusService.render(false);
})
);

context.subscriptions.push(
vscode.commands.registerCommand('serverStatus.stopped', () => {
serverStatusService.render(false);
vscode.commands.registerCommand('traceViewer.startServer', () => {
startTraceServerIfAvailable();
})
);

isUp()
.then(status => vscode.commands.executeCommand('setContext', 'traceViewer.serverOn', status))
.catch(()=> vscode.commands.executeCommand('setContext', 'traceViewer.serverOn', false));

vscode.commands.executeCommand('setContext', 'traceViewer.markerSetsPresent', false);
vscode.commands.executeCommand('setContext', 'traceViewer.markerCategoriesPresent', false);
return traceExtensionAPI;
Expand Down Expand Up @@ -215,6 +239,7 @@ async function startTraceServerIfAvailable(pathToTrace?: string): Promise<void>
await vscode.commands.executeCommand(extensionId + '.start-if-stopped');
}

// Does it make sense for this to be here?
async function isUp() {
const health = await tspClientProvider.getTspClient().checkHealth();
const status = health.getModel()?.status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,18 @@ export class TraceExplorerOpenedTracesViewProvider implements vscode.WebviewView
case VSCODE_MESSAGES.OPEN_TRACE:
vscode.commands.executeCommand('openedTraces.openTraceFolder');
return;
case VSCODE_MESSAGES.EXPERIMENT_SELECTED: {
let experiment: Experiment | undefined;
if (message.data && message.data.wrapper) {
experiment = convertSignalExperiment(JSONBig.parse(message.data.wrapper));
} else {
experiment = undefined;
case VSCODE_MESSAGES.EXPERIMENT_SELECTED:
// Need to block scope the variable 'experiment'...
if (true) {
let experiment: Experiment | undefined;
if (message.data && message.data.wrapper) {
experiment = convertSignalExperiment(JSONBig.parse(message.data.wrapper));
} else {
experiment = undefined;
}
signalManager().fireExperimentSelectedSignal(experiment);
}
signalManager().fireExperimentSelectedSignal(experiment);
}
return;
}
},
undefined,
Expand Down
Loading
Loading