From f5abb859500e11fc50846ef6fa024936bad9aabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A1l=C3=B3czi=20Kevin?= Date: Sun, 9 Nov 2025 20:12:46 +0100 Subject: [PATCH 1/2] ref: limit the console log length --- src/stores/useConsoleStore.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/stores/useConsoleStore.ts b/src/stores/useConsoleStore.ts index 8bab1ac..95908bf 100644 --- a/src/stores/useConsoleStore.ts +++ b/src/stores/useConsoleStore.ts @@ -2,7 +2,7 @@ import { create } from 'zustand'; import { ActionTypes } from '../constants/ActionTypes'; interface State { - text: any; + text: Array<{ text: string; length: number }>; active: boolean; fullExpanded: boolean; suggestions: any; @@ -12,6 +12,8 @@ interface State { actions: { [key: number]: (action: any) => void }; } +const CONSOLE_TEXT_LIMIT = 100; + const useConsoleStore = create((set) => ({ text: [], active: false, @@ -22,7 +24,7 @@ const useConsoleStore = create((set) => ({ // actions: { [ActionTypes.TOGGLE_CONSOLE_ACTIVE]: () => { - set((state: any) => { + set((state) => { if (!state.active) { return { suggestions: [], @@ -53,9 +55,9 @@ const useConsoleStore = create((set) => ({ }); }, [ActionTypes.ADD_CONSOLE_TEXT]: (action: any) => { - set((state: any) => { + set((state) => { let text = action.text.trim(); - const finalStateText = [...state.text]; + const finalStateText = state.text.splice(-CONSOLE_TEXT_LIMIT + 1); if (text.startsWith('Unknown console command "')) { let lastIndex = text.lastIndexOf('"'); @@ -201,7 +203,7 @@ const useConsoleStore = create((set) => ({ }); }, [ActionTypes.SET_CONSOLE_SUGGESTIONS]: (action: any) => { - set((state: any) => { + set((state) => { if (!state.active) { return {}; } @@ -212,7 +214,7 @@ const useConsoleStore = create((set) => ({ }); }, [ActionTypes.EXECUTE_CONSOLE_COMMAND]: (action: any) => { - set((state: any) => { + set((state) => { if (action.command.trim().length === 0) { return {}; } From b5addd6ce4d408be42d765daa8821964eefe8af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A1l=C3=B3czi=20Kevin?= Date: Mon, 10 Nov 2025 08:43:35 +0100 Subject: [PATCH 2/2] ref: increase the console text length --- src/stores/useConsoleStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/useConsoleStore.ts b/src/stores/useConsoleStore.ts index 95908bf..a47f1f2 100644 --- a/src/stores/useConsoleStore.ts +++ b/src/stores/useConsoleStore.ts @@ -12,7 +12,7 @@ interface State { actions: { [key: number]: (action: any) => void }; } -const CONSOLE_TEXT_LIMIT = 100; +const CONSOLE_TEXT_LIMIT = 1_000; const useConsoleStore = create((set) => ({ text: [],