diff --git a/client/src/components/logViewer/index.ts b/client/src/components/logViewer/index.ts index 65fb8ff98..641c4da3b 100644 --- a/client/src/components/logViewer/index.ts +++ b/client/src/components/logViewer/index.ts @@ -110,7 +110,11 @@ useRunStore.subscribe( } else if (isExecuting && !prevIsExecuting) { setProducedExecutionLogOutput(false); - if (clearLogOnExecutionStart() && outputChannel) { + if ( + clearLogOnExecutionStart() && + outputChannel && + useRunStore.getState().isUserExecuting + ) { outputChannel.dispose(); outputChannel = undefined; data = []; diff --git a/client/src/connection/itc/CodeRunner.ts b/client/src/connection/itc/CodeRunner.ts index d6650ea97..77f4ca6b0 100644 --- a/client/src/connection/itc/CodeRunner.ts +++ b/client/src/connection/itc/CodeRunner.ts @@ -37,7 +37,7 @@ async function _runCode( } const { setIsExecutingCode } = useRunStore.getState(); - setIsExecutingCode(true); + setIsExecutingCode(true, false); commands.executeCommand("setContext", "SAS.running", true); const session = getSession(); diff --git a/client/src/store/run/actions.ts b/client/src/store/run/actions.ts index 01819222b..c4a2de37b 100644 --- a/client/src/store/run/actions.ts +++ b/client/src/store/run/actions.ts @@ -5,15 +5,16 @@ import { StateCreator } from "zustand/vanilla"; import { type Store } from "./store"; export interface RunActions { - setIsExecutingCode: (isExecuting: boolean) => void; + setIsExecutingCode: (isExecuting: boolean, isUserExecuting?: boolean) => void; } export const createRunActions: StateCreator = ( set, ) => ({ - setIsExecutingCode: (isExecutingCode) => { + setIsExecutingCode: (isExecutingCode, isUserExecuting = true) => { set({ isExecutingCode, + isUserExecuting, }); }, }); diff --git a/client/src/store/run/initialState.ts b/client/src/store/run/initialState.ts index 15ce68b67..f0eabd5aa 100644 --- a/client/src/store/run/initialState.ts +++ b/client/src/store/run/initialState.ts @@ -2,8 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 export interface RunState { isExecutingCode: boolean; + isUserExecuting: boolean; } export const initialState: RunState = { isExecutingCode: false, + isUserExecuting: false, }; diff --git a/client/test/store/run/actions.test.ts b/client/test/store/run/actions.test.ts index 66490e9fc..6fc459f30 100644 --- a/client/test/store/run/actions.test.ts +++ b/client/test/store/run/actions.test.ts @@ -12,6 +12,7 @@ describe("run actions", () => { const { setIsExecutingCode } = useRunStore.getState(); const expectedState: RunState = { isExecutingCode: true, + isUserExecuting: true, }; setIsExecutingCode(true);