diff --git a/package.json b/package.json index 04b801e..bc107c8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gerbil", "productName": "Gerbil", - "version": "1.0.3", + "version": "1.0.4", "description": "Run Large Language Models locally", "main": "out/main/index.js", "homepage": "./", diff --git a/src/components/TitleBar.tsx b/src/components/TitleBar.tsx index fce8785..861ece7 100644 --- a/src/components/TitleBar.tsx +++ b/src/components/TitleBar.tsx @@ -117,8 +117,8 @@ export const TitleBar = ({ {PRODUCT_NAME} 50; + const elementId = element.id; + const currentHeight = element.scrollHeight; + const lastHeight = lastScrollHeights[elementId] || currentHeight; + + const heightGrowth = Math.max(0, currentHeight - lastHeight); + const dynamicThreshold = Math.min(Math.max(heightGrowth * 1.2, 30), 200); + + lastScrollHeights[elementId] = currentHeight; + + return (element.scrollHeight - element.scrollTop - element.clientHeight) > dynamicThreshold; } if((alwaysscroll && !shouldRespectUserScroll(box1)) || isScrolledToBottom(box1)) { @@ -121,8 +136,19 @@ export const KLITE_AUTOSCROLL_PATCHES = ` let shouldSkipAutoscroll = false; ["gametext", "chat_msg_body", "corpostylemain"].forEach(id => { let el = document.getElementById(id); - if (el && (el.scrollHeight - el.scrollTop - el.clientHeight) > 50) { - shouldSkipAutoscroll = true; + if (el) { + const currentHeight = el.scrollHeight; + const lastHeight = lastScrollHeights[id] || currentHeight; + + // Calculate dynamic threshold based on recent growth + const heightGrowth = Math.max(0, currentHeight - lastHeight); + const dynamicThreshold = Math.min(Math.max(heightGrowth * 1.2, 30), 200); + + lastScrollHeights[id] = currentHeight; + + if ((el.scrollHeight - el.scrollTop - el.clientHeight) > dynamicThreshold) { + shouldSkipAutoscroll = true; + } } }); diff --git a/src/main/managers/KoboldCppManager.ts b/src/main/managers/KoboldCppManager.ts index de616d3..1548705 100644 --- a/src/main/managers/KoboldCppManager.ts +++ b/src/main/managers/KoboldCppManager.ts @@ -289,14 +289,28 @@ export class KoboldCppManager { const content = await readFile(kliteEmbdPath, 'utf8'); - if ( - content.includes('') && - !content.includes('gerbil-autoscroll-patches') - ) { - const patchedContent = content.replace( + if (content.includes('')) { + let patchedContent = content; + + if (content.includes('gerbil-css-override')) { + patchedContent = patchedContent.replace( + /