From c278398d1a6f256c5188e8936c3d7840e47b4382 Mon Sep 17 00:00:00 2001 From: iris Date: Wed, 3 Jun 2026 20:56:35 +0200 Subject: [PATCH] feat(terminal): auto-load older history on scroll-to-top Instead of requiring a click on the load-more pill, trigger loadMore() automatically when the user scrolls within LOAD_MORE_SCROLL_PX (80px) of the top of the log. The pill stays as a visual indicator that more history is available. --- frontend/packages/shared/src/terminal.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/packages/shared/src/terminal.js b/frontend/packages/shared/src/terminal.js index e22a6abc..0f495fa7 100644 --- a/frontend/packages/shared/src/terminal.js +++ b/frontend/packages/shared/src/terminal.js @@ -50,6 +50,10 @@ // count=0); pages use it to set state flags from the replayed history. const NEAR_BOTTOM_PX = 48; +// Scroll distance from the top of the log that triggers an automatic +// "load older" fetch — fires via the scroll event handler so the operator +// never has to click the pill; the pill stays as a visual indicator. +const LOAD_MORE_SCROLL_PX = 80; // Snap-to-bottom animation duration. See docs/web-ui.md::Shared // terminal pane (Sticky-bottom + snap animation) for the 140ms-vs- // 500ms-browser-default + 24px short-circuit rationale. @@ -160,6 +164,11 @@ export function create(opts) { if (Date.now() < smoothScrollingUntil) return; stickToBottom = isNearBottom(); if (stickToBottom) { unseen = 0; updatePill(); } + // Auto-fetch older history when the user scrolls near the top — no + // click required; the load-more pill stays as a visual indicator. + if (rootLog.scrollTop <= LOAD_MORE_SCROLL_PX && histHasMore && !histLoading) { + loadMore(); + } }); // Post-append mutation snap — catches renderer mutations that land // after `api.row` returns (badges, multi-line bodies, tool