@hydranium/client-theia 1.0.0-next.18 → 1.0.0-next.180
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -6
- package/lib/browser/browser-capture.js.map +1 -1
- package/lib/browser/channel-logger.d.ts +4 -3
- package/lib/browser/channel-logger.d.ts.map +1 -1
- package/lib/browser/channel-logger.js +9 -4
- package/lib/browser/channel-logger.js.map +1 -1
- package/lib/browser/connection-diagnostics-contribution.d.ts +69 -0
- package/lib/browser/connection-diagnostics-contribution.d.ts.map +1 -0
- package/lib/browser/connection-diagnostics-contribution.js +153 -0
- package/lib/browser/connection-diagnostics-contribution.js.map +1 -0
- package/lib/browser/connection-reporter.d.ts +57 -0
- package/lib/browser/connection-reporter.d.ts.map +1 -0
- package/lib/browser/connection-reporter.js +104 -0
- package/lib/browser/connection-reporter.js.map +1 -0
- package/lib/browser/editor-disk-sync.d.ts +133 -0
- package/lib/browser/editor-disk-sync.d.ts.map +1 -0
- package/lib/browser/editor-disk-sync.js +232 -0
- package/lib/browser/editor-disk-sync.js.map +1 -0
- package/lib/browser/hydranium-file-service.d.ts +44 -0
- package/lib/browser/hydranium-file-service.d.ts.map +1 -0
- package/lib/browser/hydranium-file-service.js +61 -0
- package/lib/browser/hydranium-file-service.js.map +1 -0
- package/lib/browser/index.d.ts +5 -0
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +5 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/log-level-preference.d.ts.map +1 -1
- package/lib/browser/log-level-preference.js +11 -0
- package/lib/browser/log-level-preference.js.map +1 -1
- package/lib/browser/memory-diagnostics-contribution.d.ts +40 -4
- package/lib/browser/memory-diagnostics-contribution.d.ts.map +1 -1
- package/lib/browser/memory-diagnostics-contribution.js +161 -31
- package/lib/browser/memory-diagnostics-contribution.js.map +1 -1
- package/lib/browser/session-aware-connection-source.d.ts +98 -0
- package/lib/browser/session-aware-connection-source.d.ts.map +1 -0
- package/lib/browser/session-aware-connection-source.js +167 -0
- package/lib/browser/session-aware-connection-source.js.map +1 -0
- package/lib/common/clock.d.ts +19 -0
- package/lib/common/clock.d.ts.map +1 -0
- package/lib/common/clock.js +13 -0
- package/lib/common/clock.js.map +1 -0
- package/lib/common/connection-resilience-options.d.ts +24 -0
- package/lib/common/connection-resilience-options.d.ts.map +1 -0
- package/lib/common/connection-resilience-options.js +11 -0
- package/lib/common/connection-resilience-options.js.map +1 -0
- package/lib/common/framed-socket-write-buffer.d.ts +121 -0
- package/lib/common/framed-socket-write-buffer.d.ts.map +1 -0
- package/lib/common/framed-socket-write-buffer.js +190 -0
- package/lib/common/framed-socket-write-buffer.js.map +1 -0
- package/lib/common/index.d.ts +12 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +31 -0
- package/lib/common/index.js.map +1 -0
- package/lib/node/abstract-socket-forwarding-connection-handler.d.ts +12 -8
- package/lib/node/abstract-socket-forwarding-connection-handler.d.ts.map +1 -1
- package/lib/node/abstract-socket-forwarding-connection-handler.js +70 -13
- package/lib/node/abstract-socket-forwarding-connection-handler.js.map +1 -1
- package/lib/node/index.d.ts +2 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +2 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/session-bound-frontend-connection-service.d.ts +77 -0
- package/lib/node/session-bound-frontend-connection-service.d.ts.map +1 -0
- package/lib/node/session-bound-frontend-connection-service.js +128 -0
- package/lib/node/session-bound-frontend-connection-service.js.map +1 -0
- package/lib/node/socket-channel-forwarder.d.ts +54 -0
- package/lib/node/socket-channel-forwarder.d.ts.map +1 -0
- package/lib/node/socket-channel-forwarder.js +93 -0
- package/lib/node/socket-channel-forwarder.js.map +1 -0
- package/lib/testing/stub-inversify-context.js.map +1 -1
- package/lib/testing/stub-output-channel.js.map +1 -1
- package/package.json +35 -20
- package/src/browser/channel-logger.ts +9 -4
- package/src/browser/connection-diagnostics-contribution.ts +142 -0
- package/src/browser/connection-reporter.ts +121 -0
- package/src/browser/editor-disk-sync.ts +236 -0
- package/src/browser/hydranium-file-service.ts +56 -0
- package/src/browser/index.ts +5 -0
- package/src/browser/log-level-preference.ts +11 -0
- package/src/browser/memory-diagnostics-contribution.ts +268 -45
- package/src/browser/session-aware-connection-source.ts +179 -0
- package/src/common/clock.ts +20 -0
- package/src/common/connection-resilience-options.ts +24 -0
- package/src/common/framed-socket-write-buffer.ts +227 -0
- package/src/common/index.ts +15 -0
- package/src/node/abstract-socket-forwarding-connection-handler.ts +61 -15
- package/src/node/index.ts +2 -0
- package/src/node/session-bound-frontend-connection-service.ts +155 -0
- package/src/node/socket-channel-forwarder.ts +99 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
|
|
10
|
+
import type URI from '@theia/core/lib/common/uri';
|
|
11
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
12
|
+
import { FileService, type UpdateTextFileOptions } from '@theia/filesystem/lib/browser/file-service';
|
|
13
|
+
import { ETAG_DISABLED } from '@theia/filesystem/lib/common/files';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Theia's `FileService`, refusing an incremental save once the file has
|
|
17
|
+
* changed since the editor read it.
|
|
18
|
+
*
|
|
19
|
+
* Theia's own check, which `write` and `update` share, passes a file whose
|
|
20
|
+
* mtime moved on when its size still matches the etag the editor read. That
|
|
21
|
+
* is safe for `write`, which replaces the file with the whole text, but
|
|
22
|
+
* `update` applies the editor's pending edits to the file as it is, so after a
|
|
23
|
+
* same-size change, the server saving those very edits included, it applies
|
|
24
|
+
* them a second time. Here `update` hands that check the etag with a `!`
|
|
25
|
+
* appended, which no file's etag can match: Theia writes an etag as the mtime
|
|
26
|
+
* in base 29 followed by the size in base 31, digits and lower-case letters
|
|
27
|
+
* only. An advanced mtime is then enough for Theia to refuse with its
|
|
28
|
+
* `FILE_MODIFIED_SINCE`. The editor's save then falls back to `write` with the
|
|
29
|
+
* whole text, which Theia checks as before: it writes when the size is
|
|
30
|
+
* unchanged, and asks the user otherwise. A same-size change by another
|
|
31
|
+
* process is therefore overwritten by that write rather than merged with the
|
|
32
|
+
* editor's edits. `write` is left as it is.
|
|
33
|
+
*
|
|
34
|
+
* It is the safety net behind `EditorDiskSync`, which acts only when the
|
|
35
|
+
* file holds the editor's buffer: a file holding some of the edits, as when a
|
|
36
|
+
* save participant ordered ahead of Theia's first one edits before its first
|
|
37
|
+
* await, is left to this check.
|
|
38
|
+
*
|
|
39
|
+
* A write within the file system's mtime resolution of the read goes unseen,
|
|
40
|
+
* as it does for Theia's own check. A file whose mtime moves while its text
|
|
41
|
+
* stays the same costs a whole-text write rather than the edits.
|
|
42
|
+
*
|
|
43
|
+
* The adopter binds it with `rebind(FileService).to(HydraniumFileService).inSingletonScope()`.
|
|
44
|
+
*/
|
|
45
|
+
@injectable()
|
|
46
|
+
export class HydraniumFileService extends FileService {
|
|
47
|
+
override update(
|
|
48
|
+
resource: URI,
|
|
49
|
+
changes: Parameters<FileService['update']>[1],
|
|
50
|
+
options: UpdateTextFileOptions
|
|
51
|
+
): ReturnType<FileService['update']> {
|
|
52
|
+
const strict =
|
|
53
|
+
typeof options.etag === 'string' && options.etag !== ETAG_DISABLED ? { ...options, etag: `${options.etag}!` } : options;
|
|
54
|
+
return super.update(resource, changes, strict);
|
|
55
|
+
}
|
|
56
|
+
}
|
package/src/browser/index.ts
CHANGED
|
@@ -12,3 +12,8 @@ export * from './channel-logger';
|
|
|
12
12
|
export * from './log-level-preference';
|
|
13
13
|
export * from './browser-capture';
|
|
14
14
|
export * from './memory-diagnostics-contribution';
|
|
15
|
+
export * from './session-aware-connection-source';
|
|
16
|
+
export * from './connection-diagnostics-contribution';
|
|
17
|
+
export * from './connection-reporter';
|
|
18
|
+
export * from './editor-disk-sync';
|
|
19
|
+
export * from './hydranium-file-service';
|
|
@@ -108,7 +108,18 @@ export class LogLevelPreferenceContribution implements FrontendApplicationContri
|
|
|
108
108
|
protected applyLevel(): void {
|
|
109
109
|
const level = parseLogLevel(this.preferences.get<string>(this.preferenceName));
|
|
110
110
|
if (level) {
|
|
111
|
+
const previous = Logger.getLevel();
|
|
111
112
|
Logger.setLevel(level);
|
|
113
|
+
if (previous !== level) {
|
|
114
|
+
// Through Theia's `ILogger`, which has a threshold of its own and so
|
|
115
|
+
// is not silenced by the value just applied — the framework logger
|
|
116
|
+
// this preference governs would drop the line on a switch to `error`.
|
|
117
|
+
//
|
|
118
|
+
// Frontend and server announce separately: this preference reaches
|
|
119
|
+
// the server only if a client delivers it as configuration, so one
|
|
120
|
+
// line without the other says it did not.
|
|
121
|
+
this.logger.info(`Log level ${previous} → ${level} (preference '${this.preferenceName}')`);
|
|
122
|
+
}
|
|
112
123
|
}
|
|
113
124
|
}
|
|
114
125
|
}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
type StartProfilingArgs
|
|
15
15
|
} from '@hydranium/protocol';
|
|
16
16
|
import { captureBrowserRuntime, formatBrowserRuntime } from './browser-capture';
|
|
17
|
-
import { CommandContribution, MessageService, type Command, type CommandRegistry } from '@theia/core';
|
|
17
|
+
import { CommandContribution, MessageService, nls, type Command, type CommandRegistry } from '@theia/core';
|
|
18
18
|
import { inject, injectable, optional, type interfaces } from '@theia/core/shared/inversify';
|
|
19
19
|
import { OutputChannelManager, type OutputChannel } from '@theia/output/lib/browser/output-channel';
|
|
20
20
|
|
|
@@ -54,6 +54,17 @@ export const MemoryDiagnosticsService = Symbol('MemoryDiagnosticsService');
|
|
|
54
54
|
export type HostMemoryDiagnosticsService = HostDiagnosticsProtocol;
|
|
55
55
|
export const HostMemoryDiagnosticsService = Symbol('HostMemoryDiagnosticsService');
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* What a `report` call captured, as a code rather than a prose fragment. The
|
|
59
|
+
* sentences it appears in are authored once per code, because a fragment
|
|
60
|
+
* substituted into a sentence is itself translatable text and a translator
|
|
61
|
+
* given the sentence alone cannot inflect around a hole.
|
|
62
|
+
*/
|
|
63
|
+
export type DiagnosticsSubject = 'server-state' | 'pod-memory' | 'latency' | 'backend-state' | 'profile';
|
|
64
|
+
|
|
65
|
+
/** Which process a heap snapshot is taken of; a code, for the reason {@link DiagnosticsSubject} is one. */
|
|
66
|
+
export type HeapSnapshotTarget = 'server' | 'backend';
|
|
67
|
+
|
|
57
68
|
/**
|
|
58
69
|
* Memory-diagnostics commands, one per layer reachable from the frontend. Full
|
|
59
70
|
* multi-line snapshots are appended to the configured output channel; a one-line
|
|
@@ -88,76 +99,162 @@ export class MemoryDiagnosticsContribution implements CommandContribution {
|
|
|
88
99
|
* localized apart, leaving a button or an instruction that names a command
|
|
89
100
|
* the user cannot find.
|
|
90
101
|
*/
|
|
91
|
-
protected readonly stopProfilingLabel: string =
|
|
102
|
+
protected readonly stopProfilingLabel: string = nls.localize(
|
|
103
|
+
'hydranium/client-theia/command-stop-profiling-server',
|
|
104
|
+
'Stop Profiling (Server)'
|
|
105
|
+
);
|
|
92
106
|
|
|
93
107
|
registerCommands(registry: CommandRegistry): void {
|
|
94
108
|
const { category } = this.options;
|
|
95
|
-
registry.registerCommand(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
registry.registerCommand(
|
|
110
|
+
this.command({
|
|
111
|
+
id: 'dumpServerState',
|
|
112
|
+
label: nls.localize('hydranium/client-theia/command-dump-server-state', 'Dump Server State'),
|
|
113
|
+
category
|
|
114
|
+
}),
|
|
115
|
+
{
|
|
116
|
+
execute: () =>
|
|
117
|
+
this.report('server-state', () => this.diagnostics.dumpServerState({ label: new Date().toISOString() }), ['heap'])
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
registry.registerCommand(
|
|
121
|
+
this.command({
|
|
122
|
+
id: 'dumpPodMemory',
|
|
123
|
+
label: nls.localize('hydranium/client-theia/command-dump-pod-memory', 'Dump Pod Memory'),
|
|
124
|
+
category
|
|
125
|
+
}),
|
|
126
|
+
{
|
|
127
|
+
execute: () => this.report('pod-memory', () => this.diagnostics.dumpPodMemory(), ['current', 'rss sum'])
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
registry.registerCommand(
|
|
131
|
+
this.command({
|
|
132
|
+
id: 'dumpFrontendState',
|
|
133
|
+
label: nls.localize('hydranium/client-theia/command-dump-frontend-state', 'Dump Frontend State'),
|
|
134
|
+
category
|
|
135
|
+
}),
|
|
136
|
+
{
|
|
137
|
+
execute: () => this.dumpFrontendState()
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
registry.registerCommand(
|
|
141
|
+
this.command({
|
|
142
|
+
id: 'writeHeapSnapshot',
|
|
143
|
+
label: nls.localize('hydranium/client-theia/command-write-heap-snapshot-server', 'Write Heap Snapshot (Server)'),
|
|
144
|
+
category
|
|
145
|
+
}),
|
|
146
|
+
{
|
|
147
|
+
execute: () => this.writeSnapshot('server', label => this.diagnostics.writeHeapSnapshot({ label }))
|
|
148
|
+
}
|
|
149
|
+
);
|
|
107
150
|
// Sampled profiling of the server process — sampling does NOT pause it (unlike
|
|
108
151
|
// the heap snapshot). Start/Stop are the manual pair; Record wraps a fixed window.
|
|
109
|
-
registry.registerCommand(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
152
|
+
registry.registerCommand(
|
|
153
|
+
this.command({
|
|
154
|
+
id: 'startProfiling',
|
|
155
|
+
label: nls.localize('hydranium/client-theia/command-start-profiling-server', 'Start Profiling (Server)'),
|
|
156
|
+
category
|
|
157
|
+
}),
|
|
158
|
+
{
|
|
159
|
+
execute: () => this.startProfiling()
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
registry.registerCommand(this.command({ id: 'stopProfiling', label: this.stopProfilingLabel, category }), {
|
|
113
163
|
execute: () => this.stopProfiling()
|
|
114
164
|
});
|
|
115
165
|
registry.registerCommand(
|
|
116
|
-
this.command(
|
|
166
|
+
this.command({
|
|
167
|
+
id: 'recordProfile',
|
|
168
|
+
// The window length rides the substitution path rather than a
|
|
169
|
+
// template literal: an extractor reads the source text, so an
|
|
170
|
+
// interpolated default is never in the catalogue at all.
|
|
171
|
+
label: nls.localize(
|
|
172
|
+
'hydranium/client-theia/command-record-profile',
|
|
173
|
+
'Record Performance Profile (Server, {0}s)',
|
|
174
|
+
this.recordDurationSeconds()
|
|
175
|
+
),
|
|
176
|
+
category
|
|
177
|
+
}),
|
|
117
178
|
{
|
|
118
179
|
execute: () => this.recordProfile()
|
|
119
180
|
}
|
|
120
181
|
);
|
|
121
|
-
registry.registerCommand(
|
|
122
|
-
|
|
123
|
-
|
|
182
|
+
registry.registerCommand(
|
|
183
|
+
this.command({
|
|
184
|
+
id: 'dumpLatency',
|
|
185
|
+
label: nls.localize('hydranium/client-theia/command-dump-latency', 'Dump RPC/LSP Latency (Server)'),
|
|
186
|
+
category
|
|
187
|
+
}),
|
|
188
|
+
{
|
|
189
|
+
execute: () => this.report('latency', async () => formatLatencyReport(await this.diagnostics.getLatency()), ['window'])
|
|
190
|
+
}
|
|
191
|
+
);
|
|
124
192
|
// Host (Theia backend) process commands — registered only when the
|
|
125
193
|
// optional host-diagnostics service is bound (see HostMemoryDiagnosticsService).
|
|
126
194
|
const hostDiagnostics = this.hostDiagnostics;
|
|
127
195
|
if (hostDiagnostics) {
|
|
128
|
-
registry.registerCommand(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
196
|
+
registry.registerCommand(
|
|
197
|
+
this.command({
|
|
198
|
+
id: 'dumpBackendState',
|
|
199
|
+
label: nls.localize('hydranium/client-theia/command-dump-backend-state', 'Dump Backend State'),
|
|
200
|
+
category
|
|
201
|
+
}),
|
|
202
|
+
{
|
|
203
|
+
execute: () =>
|
|
204
|
+
this.report('backend-state', () => hostDiagnostics.dumpHostState({ label: new Date().toISOString() }), ['heap'])
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
registry.registerCommand(
|
|
208
|
+
this.command({
|
|
209
|
+
id: 'writeBackendHeapSnapshot',
|
|
210
|
+
label: nls.localize('hydranium/client-theia/command-write-heap-snapshot-backend', 'Write Heap Snapshot (Backend)'),
|
|
211
|
+
category
|
|
212
|
+
}),
|
|
213
|
+
{
|
|
214
|
+
execute: () => this.writeSnapshot('backend', label => hostDiagnostics.writeHostHeapSnapshot({ label }))
|
|
215
|
+
}
|
|
216
|
+
);
|
|
134
217
|
}
|
|
135
218
|
}
|
|
136
219
|
|
|
137
|
-
|
|
138
|
-
|
|
220
|
+
/**
|
|
221
|
+
* Takes an object rather than positional arguments so that `label` — the one
|
|
222
|
+
* user-facing member — is addressable by name. A lint rule guarding the
|
|
223
|
+
* localization of labels has only syntax to work with, and a selector for an
|
|
224
|
+
* argument position would equally catch `id`, which must stay a bare literal.
|
|
225
|
+
*/
|
|
226
|
+
protected command(spec: { id: string; label: string; category: string }): Command {
|
|
227
|
+
return { id: `${this.options.commandIdPrefix}.${spec.id}`, label: spec.label, category: spec.category };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** The record window as whole seconds, for the label and the toast that must agree on it. */
|
|
231
|
+
protected recordDurationSeconds(): number {
|
|
232
|
+
return Math.round(this.recordDurationMs / 1000);
|
|
139
233
|
}
|
|
140
234
|
|
|
141
235
|
/** Run a snapshot call, append the full result to the channel, toast the first matching summary line. */
|
|
142
|
-
protected async report(
|
|
236
|
+
protected async report(subject: DiagnosticsSubject, produce: () => Promise<string>, summaryKeys: string[]): Promise<void> {
|
|
143
237
|
try {
|
|
144
238
|
const snapshot = await produce();
|
|
145
239
|
this.channel().appendLine(snapshot);
|
|
146
240
|
this.channel().appendLine('');
|
|
147
|
-
this.messageService.info(this.summarize(snapshot,
|
|
241
|
+
this.messageService.info(this.summarize(snapshot, subject, summaryKeys), { timeout: 5000 });
|
|
148
242
|
} catch (error) {
|
|
149
|
-
this.messageService.error(
|
|
243
|
+
this.messageService.error(this.dumpFailedMessage(subject, this.errorMessage(error)));
|
|
150
244
|
}
|
|
151
245
|
}
|
|
152
246
|
|
|
153
|
-
protected async writeSnapshot(target:
|
|
247
|
+
protected async writeSnapshot(target: HeapSnapshotTarget, produce: (label: string) => Promise<string>): Promise<void> {
|
|
154
248
|
try {
|
|
155
|
-
this.messageService.info(
|
|
249
|
+
this.messageService.info(this.writingSnapshotMessage(target), { timeout: 3000 });
|
|
156
250
|
const filePath = await produce(new Date().toISOString());
|
|
157
|
-
|
|
158
|
-
|
|
251
|
+
// One sentence, shown in both places: two literals of equal value can be
|
|
252
|
+
// localized apart, leaving the channel and the toast naming different files.
|
|
253
|
+
const written = this.wroteSnapshotMessage(target, filePath);
|
|
254
|
+
this.channel().appendLine(written);
|
|
255
|
+
this.messageService.info(written, { timeout: 8000 });
|
|
159
256
|
} catch (error) {
|
|
160
|
-
this.messageService.error(
|
|
257
|
+
this.messageService.error(this.writeSnapshotFailedMessage(target, this.errorMessage(error)));
|
|
161
258
|
}
|
|
162
259
|
}
|
|
163
260
|
|
|
@@ -166,7 +263,7 @@ export class MemoryDiagnosticsContribution implements CommandContribution {
|
|
|
166
263
|
try {
|
|
167
264
|
await this.diagnostics.startProfiling(this.profileDimensions);
|
|
168
265
|
} catch (error) {
|
|
169
|
-
this.messageService.error(
|
|
266
|
+
this.messageService.error(this.startProfilingFailedMessage(this.errorMessage(error)));
|
|
170
267
|
return;
|
|
171
268
|
}
|
|
172
269
|
// No timeout: the capture runs as long as the user wants it to, and an
|
|
@@ -174,7 +271,7 @@ export class MemoryDiagnosticsContribution implements CommandContribution {
|
|
|
174
271
|
// toast is what keeps the action live, so this resolves only once the
|
|
175
272
|
// user acts on it or dismisses it.
|
|
176
273
|
const chosen = await this.messageService.info(
|
|
177
|
-
'Server profiling started — sampling does not stop the process.',
|
|
274
|
+
nls.localize('hydranium/client-theia/profiling-started', 'Server profiling started — sampling does not stop the process.'),
|
|
178
275
|
{ timeout: 0 },
|
|
179
276
|
this.stopProfilingLabel
|
|
180
277
|
);
|
|
@@ -188,15 +285,27 @@ export class MemoryDiagnosticsContribution implements CommandContribution {
|
|
|
188
285
|
return this.report('profile', () => this.diagnostics.stopProfiling({ label: new Date().toISOString() }), ['duration']);
|
|
189
286
|
}
|
|
190
287
|
|
|
288
|
+
/** One authored sentence for both start paths; identical literals in two places drift apart under translation. */
|
|
289
|
+
protected startProfilingFailedMessage(detail: string): string {
|
|
290
|
+
return nls.localize('hydranium/client-theia/error-start-profiling', 'Failed to start profiling: {0}', detail);
|
|
291
|
+
}
|
|
292
|
+
|
|
191
293
|
/** Capture a fixed-length window: start, wait, stop, and report the result. */
|
|
192
294
|
protected async recordProfile(): Promise<void> {
|
|
193
295
|
try {
|
|
194
296
|
await this.diagnostics.startProfiling(this.profileDimensions);
|
|
195
297
|
} catch (error) {
|
|
196
|
-
this.messageService.error(
|
|
298
|
+
this.messageService.error(this.startProfilingFailedMessage(this.errorMessage(error)));
|
|
197
299
|
return;
|
|
198
300
|
}
|
|
199
|
-
this.messageService.info(
|
|
301
|
+
this.messageService.info(
|
|
302
|
+
nls.localize(
|
|
303
|
+
'hydranium/client-theia/recording-profile',
|
|
304
|
+
'Recording a {0}s server performance profile...',
|
|
305
|
+
this.recordDurationSeconds()
|
|
306
|
+
),
|
|
307
|
+
{ timeout: 4000 }
|
|
308
|
+
);
|
|
200
309
|
await this.delay(this.recordDurationMs);
|
|
201
310
|
await this.stopProfiling();
|
|
202
311
|
}
|
|
@@ -219,15 +328,129 @@ export class MemoryDiagnosticsContribution implements CommandContribution {
|
|
|
219
328
|
}
|
|
220
329
|
|
|
221
330
|
/** Pull the first line starting with one of `keys` for a one-line toast; full text is in the channel. */
|
|
222
|
-
protected summarize(snapshot: string,
|
|
331
|
+
protected summarize(snapshot: string, subject: DiagnosticsSubject, keys: string[]): string {
|
|
223
332
|
const lines = snapshot.split('\n');
|
|
224
333
|
for (const key of keys) {
|
|
225
334
|
const line = lines.find(entry => entry.trim().startsWith(key));
|
|
226
335
|
if (line) {
|
|
227
|
-
return
|
|
336
|
+
return this.capturedDetailMessage(subject, line.replace(new RegExp(`^\\s*${key}\\s*`), ` ${key} `));
|
|
228
337
|
}
|
|
229
338
|
}
|
|
230
|
-
return
|
|
339
|
+
return this.capturedChannelMessage(subject);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* The captured-with-detail toast. The detail is a machine-formatted figure,
|
|
344
|
+
* so it is safe as a substitution parameter; the subject is not, hence one
|
|
345
|
+
* authored sentence per subject.
|
|
346
|
+
*/
|
|
347
|
+
protected capturedDetailMessage(subject: DiagnosticsSubject, detail: string): string {
|
|
348
|
+
switch (subject) {
|
|
349
|
+
case 'server-state':
|
|
350
|
+
return nls.localize('hydranium/client-theia/captured-server-state-detail', 'Captured server state —{0}', detail);
|
|
351
|
+
case 'pod-memory':
|
|
352
|
+
return nls.localize('hydranium/client-theia/captured-pod-memory-detail', 'Captured pod memory —{0}', detail);
|
|
353
|
+
case 'latency':
|
|
354
|
+
return nls.localize('hydranium/client-theia/captured-latency-detail', 'Captured RPC/LSP latency —{0}', detail);
|
|
355
|
+
case 'backend-state':
|
|
356
|
+
return nls.localize('hydranium/client-theia/captured-backend-state-detail', 'Captured backend state —{0}', detail);
|
|
357
|
+
case 'profile':
|
|
358
|
+
return nls.localize('hydranium/client-theia/captured-profile-detail', 'Captured profile —{0}', detail);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** The captured-without-detail toast; the channel name is adopter branding, not translatable text. */
|
|
363
|
+
protected capturedChannelMessage(subject: DiagnosticsSubject): string {
|
|
364
|
+
const channelName = this.options.channelName;
|
|
365
|
+
switch (subject) {
|
|
366
|
+
case 'server-state':
|
|
367
|
+
return nls.localize(
|
|
368
|
+
'hydranium/client-theia/captured-server-state-channel',
|
|
369
|
+
'Captured server state (see the {0} output channel)',
|
|
370
|
+
channelName
|
|
371
|
+
);
|
|
372
|
+
case 'pod-memory':
|
|
373
|
+
return nls.localize(
|
|
374
|
+
'hydranium/client-theia/captured-pod-memory-channel',
|
|
375
|
+
'Captured pod memory (see the {0} output channel)',
|
|
376
|
+
channelName
|
|
377
|
+
);
|
|
378
|
+
case 'latency':
|
|
379
|
+
return nls.localize(
|
|
380
|
+
'hydranium/client-theia/captured-latency-channel',
|
|
381
|
+
'Captured RPC/LSP latency (see the {0} output channel)',
|
|
382
|
+
channelName
|
|
383
|
+
);
|
|
384
|
+
case 'backend-state':
|
|
385
|
+
return nls.localize(
|
|
386
|
+
'hydranium/client-theia/captured-backend-state-channel',
|
|
387
|
+
'Captured backend state (see the {0} output channel)',
|
|
388
|
+
channelName
|
|
389
|
+
);
|
|
390
|
+
case 'profile':
|
|
391
|
+
return nls.localize(
|
|
392
|
+
'hydranium/client-theia/captured-profile-channel',
|
|
393
|
+
'Captured profile (see the {0} output channel)',
|
|
394
|
+
channelName
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** The failed-to-dump toast; the detail is a technical error string, safe as a parameter. */
|
|
400
|
+
protected dumpFailedMessage(subject: DiagnosticsSubject, detail: string): string {
|
|
401
|
+
switch (subject) {
|
|
402
|
+
case 'server-state':
|
|
403
|
+
return nls.localize('hydranium/client-theia/error-dump-server-state', 'Failed to dump server state: {0}', detail);
|
|
404
|
+
case 'pod-memory':
|
|
405
|
+
return nls.localize('hydranium/client-theia/error-dump-pod-memory', 'Failed to dump pod memory: {0}', detail);
|
|
406
|
+
case 'latency':
|
|
407
|
+
return nls.localize('hydranium/client-theia/error-dump-latency', 'Failed to dump RPC/LSP latency: {0}', detail);
|
|
408
|
+
case 'backend-state':
|
|
409
|
+
return nls.localize('hydranium/client-theia/error-dump-backend-state', 'Failed to dump backend state: {0}', detail);
|
|
410
|
+
case 'profile':
|
|
411
|
+
return nls.localize('hydranium/client-theia/error-dump-profile', 'Failed to dump profile: {0}', detail);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
protected writingSnapshotMessage(target: HeapSnapshotTarget): string {
|
|
416
|
+
switch (target) {
|
|
417
|
+
case 'server':
|
|
418
|
+
return nls.localize(
|
|
419
|
+
'hydranium/client-theia/writing-heap-snapshot-server',
|
|
420
|
+
'Writing server heap snapshot — this briefly pauses that process...'
|
|
421
|
+
);
|
|
422
|
+
case 'backend':
|
|
423
|
+
return nls.localize(
|
|
424
|
+
'hydranium/client-theia/writing-heap-snapshot-backend',
|
|
425
|
+
'Writing backend heap snapshot — this briefly pauses that process...'
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
protected wroteSnapshotMessage(target: HeapSnapshotTarget, filePath: string): string {
|
|
431
|
+
switch (target) {
|
|
432
|
+
case 'server':
|
|
433
|
+
return nls.localize('hydranium/client-theia/wrote-heap-snapshot-server', 'Heap snapshot (server) written to {0}', filePath);
|
|
434
|
+
case 'backend':
|
|
435
|
+
return nls.localize('hydranium/client-theia/wrote-heap-snapshot-backend', 'Heap snapshot (backend) written to {0}', filePath);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
protected writeSnapshotFailedMessage(target: HeapSnapshotTarget, detail: string): string {
|
|
440
|
+
switch (target) {
|
|
441
|
+
case 'server':
|
|
442
|
+
return nls.localize(
|
|
443
|
+
'hydranium/client-theia/error-write-heap-snapshot-server',
|
|
444
|
+
'Failed to write server heap snapshot: {0}',
|
|
445
|
+
detail
|
|
446
|
+
);
|
|
447
|
+
case 'backend':
|
|
448
|
+
return nls.localize(
|
|
449
|
+
'hydranium/client-theia/error-write-heap-snapshot-backend',
|
|
450
|
+
'Failed to write backend heap snapshot: {0}',
|
|
451
|
+
detail
|
|
452
|
+
);
|
|
453
|
+
}
|
|
231
454
|
}
|
|
232
455
|
|
|
233
456
|
protected errorMessage(error: unknown): string {
|