diff --git a/frontend/app/view/term/term.tsx b/frontend/app/view/term/term.tsx index 92e385a39..b74d37611 100644 --- a/frontend/app/view/term/term.tsx +++ b/frontend/app/view/term/term.tsx @@ -304,6 +304,19 @@ const TerminalView = ({ blockId, model }: TerminalViewProps) => { const termTheme = computeTheme(fullConfig, blockData?.meta?.["term:theme"]); const themeCopy = { ...termTheme }; themeCopy.background = "#00000000"; + let termScrollback = 1000; + if (termSettings?.["term:scrollback"]) { + termScrollback = Math.floor(termSettings["term:scrollback"]); + } + if (blockData?.meta?.["term:scrollback"]) { + termScrollback = Math.floor(blockData.meta["term:scrollback"]); + } + if (termScrollback < 0) { + termScrollback = 0; + } + if (termScrollback > 10000) { + termScrollback = 10000; + } const termWrap = new TermWrap( blockId, connectElemRef.current, @@ -315,6 +328,7 @@ const TerminalView = ({ blockId, model }: TerminalViewProps) => { fontWeight: "normal", fontWeightBold: "bold", allowTransparency: true, + scrollback: termScrollback, }, { keydownHandler: handleTerminalKeydown, diff --git a/frontend/app/view/term/termwrap.ts b/frontend/app/view/term/termwrap.ts index 2ef539188..7e441d9d4 100644 --- a/frontend/app/view/term/termwrap.ts +++ b/frontend/app/view/term/termwrap.ts @@ -21,6 +21,7 @@ const dlog = debug("wave:termwrap"); const TermFileName = "term"; const TermCacheFileName = "cache:term:full"; +const MinDataProcessedForCache = 100 * 1024; // detect webgl support function detectWebGLSupport(): boolean { @@ -250,7 +251,7 @@ export class TermWrap { } processAndCacheData() { - if (this.dataBytesProcessed < 10 * 1024) { + if (this.dataBytesProcessed < MinDataProcessedForCache) { return; } const serializedOutput = this.serializeAddon.serialize(); diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 026862856..1c9d272e1 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -305,6 +305,7 @@ declare global { "term:theme"?: string; "term:localshellpath"?: string; "term:localshellopts"?: string[]; + "term:scrollback"?: number; count?: number; }; @@ -423,6 +424,7 @@ declare global { "term:disablewebgl"?: boolean; "term:localshellpath"?: string; "term:localshellopts"?: string[]; + "term:scrollback"?: number; "editor:minimapenabled"?: boolean; "editor:stickyscrollenabled"?: boolean; "web:*"?: boolean; diff --git a/pkg/waveobj/metaconsts.go b/pkg/waveobj/metaconsts.go index 4f719368e..df21805e5 100644 --- a/pkg/waveobj/metaconsts.go +++ b/pkg/waveobj/metaconsts.go @@ -62,6 +62,7 @@ const ( MetaKey_TermTheme = "term:theme" MetaKey_TermLocalShellPath = "term:localshellpath" MetaKey_TermLocalShellOpts = "term:localshellopts" + MetaKey_TermScrollback = "term:scrollback" MetaKey_Count = "count" ) diff --git a/pkg/waveobj/wtypemeta.go b/pkg/waveobj/wtypemeta.go index e1431b560..de6a444ec 100644 --- a/pkg/waveobj/wtypemeta.go +++ b/pkg/waveobj/wtypemeta.go @@ -63,6 +63,7 @@ type MetaTSType struct { TermTheme string `json:"term:theme,omitempty"` TermLocalShellPath string `json:"term:localshellpath,omitempty"` // matches settings TermLocalShellOpts []string `json:"term:localshellopts,omitempty"` // matches settings + TermScrollback *int `json:"term:scrollback,omitempty"` Count int `json:"count,omitempty"` // temp for cpu plot. will remove later } diff --git a/pkg/wconfig/metaconsts.go b/pkg/wconfig/metaconsts.go index 2950bbdd1..15a06d852 100644 --- a/pkg/wconfig/metaconsts.go +++ b/pkg/wconfig/metaconsts.go @@ -20,6 +20,7 @@ const ( ConfigKey_TermDisableWebGl = "term:disablewebgl" ConfigKey_TermLocalShellPath = "term:localshellpath" ConfigKey_TermLocalShellOpts = "term:localshellopts" + ConfigKey_TermScrollback = "term:scrollback" ConfigKey_EditorMinimapEnabled = "editor:minimapenabled" ConfigKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled" diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go index d93a33f18..38811de36 100644 --- a/pkg/wconfig/settingsconfig.go +++ b/pkg/wconfig/settingsconfig.go @@ -54,6 +54,7 @@ type SettingsType struct { TermDisableWebGl bool `json:"term:disablewebgl,omitempty"` TermLocalShellPath string `json:"term:localshellpath,omitempty"` TermLocalShellOpts []string `json:"term:localshellopts,omitempty"` + TermScrollback *int64 `json:"term:scrollback,omitempty"` EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"` EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"`