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
1 change: 1 addition & 0 deletions apps/desktop/src/renderer/lib/terminal/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const terminalRendererDebug = createRendererDebugChannel({
namespace: "terminal.renderer",
enabled: true,
mirrorToConsole: isTerminalDebugEnabled(),
captureMessageByDefault: false,
});

export function logTerminalWrite(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,11 @@ class TerminalRuntimeRegistryImpl {
appearance: TerminalAppearance,
) {
const entry = this.getOrCreateEntry(terminalId);
terminalRendererDebug.info(
"runtime-attach",
{
terminalId,
hasExistingRuntime: entry.runtime !== null,
connectionState: entry.transport.connectionState,
},
{
captureMessage: true,
fingerprint: ["terminal.renderer", "runtime-attach"],
},
);
terminalRendererDebug.info("runtime-attach", {
terminalId,
hasExistingRuntime: entry.runtime !== null,
connectionState: entry.transport.connectionState,
});

if (!entry.runtime) {
entry.runtime = createRuntime(terminalId, appearance);
Expand Down
17 changes: 5 additions & 12 deletions apps/desktop/src/renderer/lib/terminal/terminal-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,18 +318,11 @@ export function attachToContainer(

runtime.container = container;
container.appendChild(runtime.wrapper);
terminalRendererDebug.info(
"runtime-attach-to-container",
{
terminalId: runtime.terminalId,
containerWidth: container.clientWidth,
containerHeight: container.clientHeight,
},
{
captureMessage: true,
fingerprint: ["terminal.renderer", "runtime-attach-to-container"],
},
);
terminalRendererDebug.info("runtime-attach-to-container", {
terminalId: runtime.terminalId,
containerWidth: container.clientWidth,
containerHeight: container.clientHeight,
});
measureAndResize(runtime);

// Renderer may have skipped frames while the wrapper was detached.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,9 @@ export function createTerminalInWrapper(options: CreateTerminalOptions = {}): {

try {
webglAddon = new WebglAddon();
terminalRendererDebug.info(
"webgl-addon-loaded",
{ suggestedRendererType: suggestedRendererType ?? "auto" },
{
captureMessage: true,
fingerprint: ["terminal.renderer", "webgl-loaded"],
},
);
terminalRendererDebug.info("webgl-addon-loaded", {
suggestedRendererType: suggestedRendererType ?? "auto",
});
webglAddon.onContextLoss(() => {
webglAddon?.dispose();
webglAddon = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,7 @@ export function useTerminalLifecycle({
if (DEBUG_TERMINAL) {
console.log(`[Terminal] Mount: ${paneId}`);
}
terminalRendererDebug.info(
"mount",
{ paneId, workspaceId },
{ captureMessage: true, fingerprint: ["terminal.renderer", "mount"] },
);
terminalRendererDebug.info("mount", { paneId, workspaceId });

// Cancel pending detach from previous unmount
const pendingDetach = pendingDetaches.get(paneId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,11 @@ export function useTerminalRestore({
0,
pendingEventsRef.current.length,
);
terminalRendererDebug.info(
"flush-pending-events",
{
paneId,
eventCount: events.length,
dataEvents: events.filter((event) => event.type === "data").length,
},
{
captureMessage: true,
fingerprint: ["terminal.renderer", "flush-pending-events"],
},
);
terminalRendererDebug.info("flush-pending-events", {
paneId,
eventCount: events.length,
dataEvents: events.filter((event) => event.type === "data").length,
});
for (const event of events) {
if (event.type === "data") {
terminalRendererDebug.observe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,11 @@ export function attachToContainer(

container.appendChild(entry.wrapper);
entry.openOnce();
terminalRendererDebug.info(
"cache-attach-to-container",
{
paneId,
hasSubscription: entry.subscription !== null,
streamReady: entry.streamReady,
},
{
captureMessage: true,
fingerprint: ["terminal.renderer", "cache-attach-to-container"],
},
);
terminalRendererDebug.info("cache-attach-to-container", {
paneId,
hasSubscription: entry.subscription !== null,
streamReady: entry.streamReady,
});

if (container.clientWidth > 0 && container.clientHeight > 0) {
entry.fitAddon.fit();
Expand Down
9 changes: 7 additions & 2 deletions apps/desktop/src/shared/debug-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export interface DebugChannelOptions {
transport?: DebugChannelTransport;
mirrorToConsole?: boolean;
maxStringLength?: number;
// true (default) の場合、aggregate flush が captureMessage を送る。
// false にすると aggregate は Breadcrumb だけを残す。
captureMessageByDefault?: boolean;
}

export interface DebugLogOptions {
Expand Down Expand Up @@ -123,6 +126,7 @@ export class DebugChannel {
private readonly transport?: DebugChannelTransport;
private readonly mirrorToConsole: boolean;
private readonly maxStringLength: number;
private readonly captureMessageByDefault: boolean;
private readonly aggregates = new Map<string, AggregateState>();

constructor(options: DebugChannelOptions) {
Expand All @@ -131,6 +135,7 @@ export class DebugChannel {
this.transport = options.transport;
this.mirrorToConsole = options.mirrorToConsole ?? true;
this.maxStringLength = options.maxStringLength ?? DEFAULT_MAX_STRING_LENGTH;
this.captureMessageByDefault = options.captureMessageByDefault ?? true;
}

log(
Expand Down Expand Up @@ -250,7 +255,7 @@ export class DebugChannel {
key,
metric,
options?.level ?? "info",
options?.captureMessage ?? true,
options?.captureMessage ?? this.captureMessageByDefault,
);
}, intervalMs);
}
Expand All @@ -259,7 +264,7 @@ export class DebugChannel {
flushAll(): void {
for (const key of this.aggregates.keys()) {
const [metric] = key.split(":");
this.flushAggregate(key, metric, "info", true);
this.flushAggregate(key, metric, "info", this.captureMessageByDefault);
}
}

Expand Down
Loading