Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions lemonade_arcade/static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ let isServerKnownOnline = false;
let setupInProgress = false;
let setupComplete = false;

// Smart scroll control for LLM output
let autoScrollEnabled = true;

// New User Experience - Checklist Setup
class SetupManager {
constructor() {
Expand Down Expand Up @@ -1111,8 +1114,10 @@ function setLLMOutput(text, isMarkdown = true) {
outputElement.textContent = text;
}

// Auto-scroll to bottom
outputElement.scrollTop = outputElement.scrollHeight;
// Smart auto-scroll: only scroll if auto-scroll is enabled
if (autoScrollEnabled) {
outputElement.scrollTop = outputElement.scrollHeight;
}
}

// Check server status periodically
Expand Down Expand Up @@ -1514,6 +1519,32 @@ document.addEventListener('DOMContentLoaded', function() {
}
});

// Initialize smart scroll control for LLM output
const outputElement = document.getElementById('llmOutput');
if (outputElement) {
outputElement.addEventListener('scroll', function() {
// Dynamic threshold calculation for better cross-device compatibility
const dynamicThreshold = Math.max(
5, // Minimum 5px threshold
Math.min(
50, // Maximum 50px threshold
this.clientHeight * 0.05 // 5% of visible height
)
);

// Check if user is at the bottom with dynamic tolerance
const isAtBottom = this.scrollTop + this.clientHeight >= this.scrollHeight - dynamicThreshold;

if (isAtBottom) {
// User scrolled to bottom - re-enable auto-scroll
autoScrollEnabled = true;
} else {
// User scrolled up - disable auto-scroll
autoScrollEnabled = false;
}
});
}

// Start the new user experience setup process
setTimeout(() => {
console.log('Starting new user experience setup...');
Expand Down