Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (C) Microsoft Corporation. All rights reserved.

Comment thread
AlexDenfordSkyboxLabs marked this conversation as resolved.
// TypeScript mirror of ScriptDiagnosticsDescriptor (C++) and its Cereal based wire format.

export type DiagnosticsDataSource = 'server' | 'client' | 'server_script';
Expand Down Expand Up @@ -26,4 +27,5 @@ export interface DiagnosticsTabDescriptor {
value_labels?: string[];
statistic_id?: string;
statistic_ids?: string[];
is_empty_tab?: boolean;
}
3 changes: 2 additions & 1 deletion src/panels/minecraft-diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import { getUri } from '../utilities/getUri';
import { getNonce } from '../utilities/getNonce';
import { DebuggerRequestHandler } from '../requests/debugger-request-handler';
import { DiagnosticsTabDescriptor, StatData, StatsListener, StatsProvider } from '../stats/stats-provider';
import { StatData, StatsListener, StatsProvider } from '../stats/stats-provider';
import { DiagnosticsTabDescriptor } from '../diagnostics-schema';

export class MinecraftDiagnosticsPanel {
private static activeDiagnosticsPanels: MinecraftDiagnosticsPanel[] = [];
Expand Down Expand Up @@ -148,7 +149,7 @@
saveLabel: 'Export',
defaultUri: workspaceFolderUri ? Uri.joinPath(workspaceFolderUri, suggestedFileName) : undefined,
filters: {
'CSV Files': ['csv'],

Check warning on line 152 in src/panels/minecraft-diagnostics.ts

View workflow job for this annotation

GitHub Actions / Build and Test

Object Literal Property name `CSV Files` must match one of the following formats: camelCase, snake_case
},
});

Expand Down
7 changes: 5 additions & 2 deletions src/protocol-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { LogLevel } from '@vscode/debugadapter/lib/logger';
import { DebugProtocol } from '@vscode/debugprotocol';
import { DiagnosticsTabDescriptor, StatMessageModel } from './stats/stats-provider';
import { StatMessageModel } from './stats/stats-provider';
import { DiagnosticsTabDescriptor } from './diagnostics-schema';

// protocol version history
// 1 - initial version
Expand All @@ -14,6 +15,7 @@ import { DiagnosticsTabDescriptor, StatMessageModel } from './stats/stats-provid
// 7 - support for debugger requests, MC can reject or respond with args
// 8 - New serialization tech (use Cereal)
// 9 - Added support for MC C++/native driven stat descriptors/schemas for UI display
// 10 - Added is_empty_tab to DiagnosticsTabDescriptor

export enum ProtocolVersion {
_Unknown = 0,
Expand All @@ -26,9 +28,10 @@ export enum ProtocolVersion {
SupportDebuggerRequests = 7,
SupportCerealSerialization = 8,
SupportNativeDescriptors = 9,
SupportEmptyTabs = 10,
}

export const DEBUGGER_PROTOCOL_VERSION = ProtocolVersion.SupportNativeDescriptors;
export const DEBUGGER_PROTOCOL_VERSION = ProtocolVersion.SupportEmptyTabs;

// -------------------------------------------------------------------------
// Interfaces for event message payloads (received from the debugee)
Expand Down
3 changes: 2 additions & 1 deletion src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export class Session extends DebugSession implements IDebuggeeMessageSender {
args: IAttachRequestArguments,
): Promise<void> {
this.closeSession();

this._statsProvider.clearSchema();
this.resolveEnvironmentVariables(args);

const host = args.host || 'localhost';
Expand Down Expand Up @@ -878,6 +878,7 @@ export class Session extends DebugSession implements IDebuggeeMessageSender {
private terminateSession(reason: string, logLevel: LogLevel = LogLevel.Log) {
this.closeServer();
this.closeSession();
this._statsProvider.clearSchema();

this._connected = false;
this._clientProtocolVersion = ProtocolVersion._Unknown;
Expand Down
35 changes: 7 additions & 28 deletions src/stats/stats-provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (C) Microsoft Corporation. All rights reserved.

import { DiagnosticsTabDescriptor } from "../diagnostics-schema";

export interface StatData {
name: string;
parent_name: string;
Expand All @@ -26,33 +28,6 @@ export interface StatMessageModel {
stats: StatDataModel[];
}

export type DiagnosticsDataSource = 'server' | 'client' | 'server_script';

export type DiagnosticsDisplayType =
| 'line_chart'
| 'stacked_line_chart'
| 'stacked_bar_chart'
| 'table'
| 'multi_column_table'
| 'dynamic_properties_table';

// Mirrors ScriptDiagnosticsDescriptor from C++. Sent once on connect via SchemaEvent.
export interface DiagnosticsTabDescriptor {
name: string;
stat_group_id: string;
data_source: DiagnosticsDataSource;
display_type: DiagnosticsDisplayType;
title?: string;
y_label?: string;
tick_range?: number;
value_scalar?: number;
target_value?: number;
key_label?: string;
value_labels?: string[];
statistic_id?: string;
statistic_ids?: string[];
}

export interface StatsListener {
onStatUpdated?: (stat: StatData) => void;
onSpeedUpdated?: (speed: number) => void;
Expand Down Expand Up @@ -83,6 +58,10 @@ export class StatsProvider {
});
}

public clearSchema(): void {
this.setSchema([]);
}

public start(): void {
throw new Error('Method not implemented.');
}
Expand Down Expand Up @@ -164,7 +143,7 @@ export class StatsProvider {
}

private _fireStatUpdated(stat: StatDataModel, tick: number, parent?: StatData) {
const statId = stat.name.toLowerCase();
const statId = stat.name;

const statData: StatData = {
...stat,
Expand Down
6 changes: 3 additions & 3 deletions webview-ui/src/diagnostics_panel/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import tabPrefabs from './prefabs';
import { TabPrefab, TabPrefabDataSource, TabPrefabParams } from './prefabs/TabPrefab';
import { handleDebuggerRequestResult } from './utilities/useDebuggerRequests';
import { vscode } from './utilities/vscode';
import { DiagnosticsTabDescriptor } from './DiagnosticsSchema';
import DynamicTab from './DynamicTab';
import { DiagnosticsTabDescriptor } from '../../../src/diagnostics-schema';

// Wraps each tab's content() as a proper React component so that any hooks
// inside the content function are correctly isolated and not called conditionally
Expand Down Expand Up @@ -175,7 +175,7 @@ function App() {
)}
<TabView tabPrefab={tab.tab} params={{ selectedClient, selectedPlugin, onRunCommand }} />
</>
) : (
) : (!tab.descriptor.is_empty_tab && (
<>
{tab.descriptor.data_source === 'client' && (
<StatGroupSelectionBox
Expand All @@ -198,7 +198,7 @@ function App() {
selectedPlugin={selectedPlugin}
/>
</>
)}
))}
</div>
))}
</div>
Expand Down
2 changes: 1 addition & 1 deletion webview-ui/src/diagnostics_panel/DynamicTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// and renders the matching control — no new tab files needed for new diagnostics.

import { useMemo } from 'react';
import { DiagnosticsTabDescriptor } from './DiagnosticsSchema';
import {
SimpleStatisticProvider,
MultipleStatisticProvider,
Expand All @@ -18,6 +17,7 @@ import MinecraftStatisticStackedBarChart from './controls/MinecraftStatisticStac
import MinecraftStatisticTable from './controls/MinecraftStatisticTable';
import MinecraftMultiColumnStatisticTable from './controls/MinecraftMultiColumnStatisticTable';
import { MinecraftDynamicPropertiesTable } from './controls/MinecraftDynamicPropertiesTable';
import { DiagnosticsTabDescriptor } from '../../../src/diagnostics-schema';

type DynamicTabProps = {
descriptor: DiagnosticsTabDescriptor;
Expand Down