Skip to content

Commit

Permalink
fix: should not clear log for non-user running (#1244)
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Wu <[email protected]>
  • Loading branch information
scnwwu authored Oct 29, 2024
1 parent 00ff483 commit b0e2d19
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion client/src/components/logViewer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion client/src/connection/itc/CodeRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
5 changes: 3 additions & 2 deletions client/src/store/run/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Store, [], [], RunActions> = (
set,
) => ({
setIsExecutingCode: (isExecutingCode) => {
setIsExecutingCode: (isExecutingCode, isUserExecuting = true) => {
set({
isExecutingCode,
isUserExecuting,
});
},
});
2 changes: 2 additions & 0 deletions client/src/store/run/initialState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
1 change: 1 addition & 0 deletions client/test/store/run/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe("run actions", () => {
const { setIsExecutingCode } = useRunStore.getState();
const expectedState: RunState = {
isExecutingCode: true,
isUserExecuting: true,
};

setIsExecutingCode(true);
Expand Down

0 comments on commit b0e2d19

Please sign in to comment.