diff --git a/src/contentScript/contentScriptPlatform.ts b/src/contentScript/contentScriptPlatform.ts index fb4d26f48a..75f4c57b08 100644 --- a/src/contentScript/contentScriptPlatform.ts +++ b/src/contentScript/contentScriptPlatform.ts @@ -270,11 +270,17 @@ class ContentScriptPlatform extends PlatformBase { override get debugger(): PlatformProtocol["debugger"] { return { - async clear(componentId: UUID): Promise { - await Promise.all([ - traces.clear(componentId), - clearModComponentDebugLogs(componentId), - ]); + async clear( + componentId: UUID, + { logValues }: { logValues: boolean }, + ): Promise { + const clearPromises = [traces.clear(componentId)]; + + if (logValues) { + clearPromises.push(clearModComponentDebugLogs(componentId)); + } + + await Promise.all(clearPromises); }, traces: { enter: traces.addEntry, diff --git a/src/extensionPages/extensionPagePlatform.ts b/src/extensionPages/extensionPagePlatform.ts index e46483c3b6..f7fb96cda3 100644 --- a/src/extensionPages/extensionPagePlatform.ts +++ b/src/extensionPages/extensionPagePlatform.ts @@ -69,11 +69,17 @@ class ExtensionPagePlatform extends PlatformBase { // Support tracing for bricks run in the sidebar and clearing logs in Page Editor/Extension Console. See PanelBody.tsx override get debugger(): PlatformProtocol["debugger"] { return { - async clear(componentId: UUID): Promise { - await Promise.all([ - traces.clear(componentId), - clearModComponentDebugLogs(componentId), - ]); + async clear( + componentId: UUID, + { logValues }: { logValues: boolean }, + ): Promise { + const clearPromises = [traces.clear(componentId)]; + + if (logValues) { + clearPromises.push(clearModComponentDebugLogs(componentId)); + } + + await Promise.all(clearPromises); }, traces: { enter: traces.addEntry, diff --git a/src/platform/platformTypes/debuggerProtocol.ts b/src/platform/platformTypes/debuggerProtocol.ts index e2c2ede835..cda83a2f9b 100644 --- a/src/platform/platformTypes/debuggerProtocol.ts +++ b/src/platform/platformTypes/debuggerProtocol.ts @@ -39,7 +39,10 @@ export interface DebuggerProtocol { * * @param componentId the mod component id */ - clear: (componentId: UUID) => Promise; + clear: ( + componentId: UUID, + { logValues }: { logValues: boolean }, + ) => Promise; traces: TraceProtocol; } diff --git a/src/runtime/reducePipeline.ts b/src/runtime/reducePipeline.ts index 7786ca89eb..950523ef4e 100644 --- a/src/runtime/reducePipeline.ts +++ b/src/runtime/reducePipeline.ts @@ -257,6 +257,14 @@ type RunBrickOptions = CommonOptions & { trace: TraceMetadata; }; +async function getLogValues( + logValues: RunBrickOptions["logValues"] | undefined, +): Promise { + const globalLoggingConfig = await getLoggingConfig(); + + return logValues ?? globalLoggingConfig.logValues ?? false; +} + /** * Get the lexical environment for running a pipeline. Currently, we're just tracking on the pipeline arg itself. * https://en.wikipedia.org/wiki/Closure_(computer_programming) @@ -456,11 +464,9 @@ async function renderBrickArg( ): Promise { const { config, type } = resolvedConfig; - const globalLoggingConfig = await getLoggingConfig(); - const { // If logValues not provided explicitly, default to the global setting - logValues = globalLoggingConfig.logValues ?? false, + logValues = await getLogValues(options.logValues), logger, explicitArg, explicitDataFlow, @@ -637,7 +643,6 @@ async function applyReduceDefaults({ Partial, "modComponentRef" >): Promise { - const globalLoggingConfig = await getLoggingConfig(); const logger = providedLogger ?? new ConsoleLogger(); return { @@ -652,7 +657,7 @@ async function applyReduceDefaults({ explicitDataFlow: false, extendModVariable: false, // If logValues not provided explicitly, default to the global setting - logValues: logValues ?? globalLoggingConfig.logValues ?? false, + logValues: await getLogValues(logValues), // For stylistic consistency, default here instead of destructured parameters branches: [], // NOTE: do not set runId here. It should be set by the starter brick explicitly, or implicitly generated @@ -960,6 +965,7 @@ export async function reduceModComponentPipeline( // `await` promise to avoid race condition where the calls here delete entries from this call to reducePipeline await platform.debugger.clear( partialOptions.modComponentRef.modComponentId, + { logValues: await getLogValues(partialOptions.logValues) }, ); } catch { // NOP