From 5e59ea42a2d0ac6f948a7d969e5b4414bef4305b Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 4 Dec 2026 14:14:30 +0200 Subject: [PATCH] feat(tape): add floating back-to-top button when scrolling tape --- VERSION | 2 +- docs/RELEASES.md | 1 + docs/SPEC.md | 6 ++-- docs/releases/v2.16.0.md | 38 ++++++++++++++++++++++ docs/wiki/Running-Momentum-Tape.md | 4 ++- docs/wiki/_Footer.md | 2 +- tests/test_tape_scroll_top.py | 51 ++++++++++++++++++++++++++++++ web/css/app.css | 24 ++++++++++++-- web/index.html | 14 ++++---- web/js/tape.js | 42 +++++++++++++++++++++--- web/tape.html | 6 ++-- 11 files changed, 167 insertions(+), 23 deletions(-) create mode 100644 docs/releases/v2.16.0.md create mode 100644 tests/test_tape_scroll_top.py diff --git a/VERSION b/VERSION index 68e69e4..7524906 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.15.0 +2.16.0 diff --git a/docs/RELEASES.md b/docs/RELEASES.md index 1458c4a..bf2eecf 100644 --- a/docs/RELEASES.md +++ b/docs/RELEASES.md @@ -37,6 +37,7 @@ All official releases are produced deterministically through GitHub Actions: ## Release History +- [v2.16.0 Release Notes](releases/v2.16.0.md) — Added floating `↑ Back to Top` (`#tape-scroll-top`) pill when scrolling the Running Tape, paired side-by-side with `New Events ↑` in `.tape-float-bar` across both main and pop-out `web/tape.html` windows (Resolves #94). - [v2.15.0 Release Notes](releases/v2.15.0.md) — Added dedicated screener tab Add (`+`), inline Duplicate (`⧉`), and right-side inline Close (`×`) buttons without right-clicking, plus stale screen state pruning in `ScreenerWorker` (Resolves #85). - [v2.14.0 Release Notes](releases/v2.14.0.md) — Added responsive horizontal topbar scrolling with auto-shown left/right arrow buttons on both sides of the screen for narrow windows and multi-tab layouts (Resolves #84). - [v2.13.0 Release Notes](releases/v2.13.0.md) — Added cross-platform Power & Keep-Awake controls (prevent screen lock, prevent system sleep, prevent monitors turning off) in General Settings with a 1-click topbar Prevent Screen Lock toggle button (Resolves #83). diff --git a/docs/SPEC.md b/docs/SPEC.md index 783af28..f386b25 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -344,7 +344,8 @@ Non-session fields: `float_shares_outstanding`, `market_cap_basic`, `sector`, - Watchlist Selector Bar (`#watchlist-bar`) positioned directly above the News pane. - News pane features custom US equity symbol inspection (`#news-sym-input`) and quick watchlist chips. - Tape header features instant quick-filter popout (`Strategies 11/13`) with color bullets and select/unselect all. -- Tape can pop out into its own window (second `pywebview` window serving `web/tape.html` with full watchlist `+` parity). +- Tape floating pill bar (`.tape-float-bar`) houses both `New Events ↑` (`#tape-new-events`) and an auto-shown `↑ Back to Top` (`#tape-scroll-top`) scroll utility button side-by-side without overlap across both embedded and pop-out `web/tape.html` views. +- Tape can pop out into its own window (second `pywebview` window serving `web/tape.html` with full watchlist `+` and floating `↑ Back to Top` parity). - Dark theme matching TradingView look. ## 6. Screener @@ -481,7 +482,8 @@ The right-hand pane combines real-time catalyst PR headlines with deep SEC EDGAR - triggers a squeeze condition (§8.2), with per-symbol/per-strategy cooldown (default 30 s). **Monotonic Window Progression**: During an active time window (e.g. 5 min / 10 min), subsequent triggers for the same symbol & strategy require strictly higher prices (`price > last_alert_price`). Server-side `change|5` velocity checks are isolated to regular trading hours. If the price falls or is flat vs the previous trigger, alerts are suppressed; once the time window resets (`now - last_alert_time >= window_min * 60`), a new squeeze cycle can begin. - **Persistent Storage & Off-Hours Review**: Tape alerts are automatically saved to `/tape_history.json` via debounced atomic writes and respect user-configured `retention_days` (default 4 days, minimum 1 day) and `max_events` (default 5,000, minimum 100). On startup or session transition, the first poll silently seeds initial universe state before emitting live alerts. When the app restarts, reloads, or opens during off-hours / weekends, all historical alerts are immediately loaded into the tape for retrospective review. - **Timestamp Formatting**: Displays `H:MM:SS am/pm` for alerts triggered today, and `MMM DD H:MM am/pm` for older alerts, with full ET date/time and relative age tooltips. -- Newest events on top; bounded by `max_events` (default 5,000); ⏸ pause freezes scrolling and shows "New events ↑"; 🗑️ clear button removes history (`POST /api/clear_tape`). +- Newest events on top; bounded by `max_events` (default 5,000); ⏸ pause freezes scrolling and shows `New Events ↑` (`#tape-new-events`); 🗑️ clear button removes history (`POST /api/clear_tape`). +- **Floating Back-to-Top Pill (`#tape-scroll-top`)**: Whenever the user scrolls down past `24px` in the Running Tape (in either the embedded pane or detached `web/tape.html`), a dark-glass `↑ Back to Top` pill appears automatically inside `.tape-float-bar` (bottom-centered at `bottom: 18px`) alongside `#tape-new-events` without overlap. Clicking `#tape-scroll-top` immediately jumps back to `scrollTop = 0` (avoiding mid-flight cancellation during live tape cascades) while preserving manual pause state (`Tape.paused`); returning to top automatically hides `#tape-scroll-top` and clears unpaused `scrolledNew` state. ### 8.2 Predefined strategies (toggle list like the Warrior screenshot) | Strategy | Rule (defaults, all editable in Settings) | diff --git a/docs/releases/v2.16.0.md b/docs/releases/v2.16.0.md new file mode 100644 index 0000000..8eafd32 --- /dev/null +++ b/docs/releases/v2.16.0.md @@ -0,0 +1,38 @@ +# NewsAlerts v2.16.0 — Release Notes + +**Release Date:** December 2026 +**Type:** Minor Feature Release (`MINOR` — Running Tape Floating Back-to-Top Button) +**Single Source of Truth:** `VERSION` (`2.16.0`) + +--- + +## 🚀 Overview + +NewsAlerts **v2.16.0** adds an automatic floating **`↑ Back to Top`** (`#tape-scroll-top`) pill to the Running Momentum Tape so traders reviewing deep historical prints (up to 3,000 DOM rows / 4-day history) can jump straight back to the top in a single click—even during quiet periods or off-hours when no new live events are arriving. + +--- + +## ✨ What's New + +- **Floating `↑ Back to Top` Pill (`#tape-scroll-top`)**: + - Automatically appears as soon as the tape scrolls down past `24px` (`SCROLL_TOP_THRESHOLD`) and hides automatically once back at the top. + - Jumps immediately back to `scrollTop = 0` (immune to mid-flight cancellation during rapid live cascades) while **preserving manual pause state** (`Tape.paused`) so paused tape reviews are never accidentally resumed. +- **Non-Overlapping Centered Float Bar (`.tape-float-bar`)**: + - Groups `New Events ↑` (`#tape-new-events`) and `↑ Back to Top` (`#tape-scroll-top`) inside a bottom-centered flex pill bar (`.tape-float-bar`, `bottom: 18px`) with an `8px` gap so both controls can appear simultaneously with zero collision against each other, `.pane-head`, sticky column headers, scrollbars, or the corner version badge. + - Fixed `@keyframes bob` to translate vertically only (`translateY(3px)`), eliminating horizontal shift inside the centered flex bar. +- **Embedded & Pop-Out Tape Parity**: + - Works identically in both `web/index.html` and detached `web/tape.html`, with synchronized `?v=12` cache-buster versions across both HTML entry points. + +--- + +## 🎯 Closed Issues + +- Resolves [#94](https://github.com/mlgitdev/NewsAlerts/issues/94): `feat(tape): add floating back-to-top button when scrolling tape` + +--- + +## 🧪 Verification & Test Suite + +- Added test-first regression suite in `tests/test_tape_scroll_top.py` verifying `#tape-scroll-top`, `.tape-float-bar`, vertical-only `@keyframes bob`, `index.html`/`tape.html` `?v=` asset parity, and `docs/SPEC.md` documentation. +- Verified live in the integrated browser against an isolated `NEWSALERTS_DIR` server across desktop (`1920x1080`, `1600x900`) and narrow (`820x900`, `640x520`) viewports plus detached `web/tape.html`, confirming zero overlap, pause preservation, smooth return to top, and `0` console errors. +- Passed full syntax compilation, unit test suite, PyInstaller portable build, and deterministic package verification gate. diff --git a/docs/wiki/Running-Momentum-Tape.md b/docs/wiki/Running-Momentum-Tape.md index 2fda4d0..c2d395e 100644 --- a/docs/wiki/Running-Momentum-Tape.md +++ b/docs/wiki/Running-Momentum-Tape.md @@ -25,7 +25,9 @@ The **Running Momentum Tape** provides a high-velocity stream of High of Day (HO - **Pop-Out Detached Window**: Press `T` on your keyboard or click the Pop-Out icon (`⧉`) in the Tape header to launch a dedicated, borderless floating tape window for multi-monitor setups. - **Pause & Scroll Lock**: - Press `Space` or click `⏸` to freeze tape scrolling during rapid cascades while inbound events continue queuing (`New events ↑`). + Press `Space` or click `⏸` to freeze tape scrolling during rapid cascades while inbound events continue queuing (`New Events ↑`). +- **Floating Back-to-Top Pill (`↑ Back to Top`)**: + As soon as you scroll down through historical tape rows (in either the embedded tape or detached pop-out window), a floating **`↑ Back to Top`** pill appears beside `New Events ↑` so you can jump back to the top in one click—even when paused or during off-hours with no new events arriving. --- diff --git a/docs/wiki/_Footer.md b/docs/wiki/_Footer.md index 7eaedab..18f9895 100644 --- a/docs/wiki/_Footer.md +++ b/docs/wiki/_Footer.md @@ -1,7 +1,7 @@ ---

- NewsAlerts v2.15.0 · Institutional Trading Terminal · Maintained by @mlgitdev · GitHub Repository · Wiki Home + NewsAlerts v2.16.0 · Institutional Trading Terminal · Maintained by @mlgitdev · GitHub Repository · Wiki Home

diff --git a/tests/test_tape_scroll_top.py b/tests/test_tape_scroll_top.py new file mode 100644 index 0000000..9b1f66b --- /dev/null +++ b/tests/test_tape_scroll_top.py @@ -0,0 +1,51 @@ +"""Unit tests for Running Tape floating Back-to-Top button and sibling entry-point parity.""" +from __future__ import annotations + +import re +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent + + +class TestTapeBackToTop(unittest.TestCase): + def test_tape_js_mounts_float_bar_and_scroll_top_button(self): + js = (ROOT / "web" / "js" / "tape.js").read_text(encoding="utf-8") + self.assertIn('id: "tape-scroll-top"', js) + self.assertIn("tape-float-bar", js) + self.assertIn("SCROLL_TOP_THRESHOLD", js) + self.assertIn("updateScrollTopBtn()", js) + self.assertIn("scrollToTop()", js) + + def test_tape_css_uses_non_overlapping_float_bar_and_vertical_bob(self): + css = (ROOT / "web" / "css" / "app.css").read_text(encoding="utf-8") + self.assertIn(".tape-float-bar", css) + self.assertIn(".tape-scroll-top", css) + self.assertIn(".tape-scroll-top.show", css) + # Anchor float bar near the bottom of .tape-pane so it never occludes .pane-head or sticky + self.assertRegex(css, r"\.tape-float-bar\s*\{[^}]*bottom:\s*\d+px;") + # @keyframes bob must translate vertically only once centered by .tape-float-bar + self.assertRegex(css, r"@keyframes\s+bob\s*\{\s*50%\s*\{\s*transform:\s*translateY\(") + + def test_index_and_popout_tape_html_share_asset_cache_buster_version(self): + idx_html = (ROOT / "web" / "index.html").read_text(encoding="utf-8") + tape_html = (ROOT / "web" / "tape.html").read_text(encoding="utf-8") + for asset in ("css/app.css", "js/util.js", "js/tape.js"): + m_idx = re.search(rf'{re.escape(asset)}\?v=(\d+)', idx_html) + m_tape = re.search(rf'{re.escape(asset)}\?v=(\d+)', tape_html) + self.assertIsNotNone(m_idx, f"{asset} version missing in index.html") + self.assertIsNotNone(m_tape, f"{asset} version missing in tape.html") + self.assertEqual( + m_idx.group(1), + m_tape.group(1), + f"Cache-buster mismatch for {asset}: index.html v={m_idx.group(1)} vs tape.html v={m_tape.group(1)}", + ) + + def test_spec_md_documents_tape_back_to_top_control(self): + spec = (ROOT / "docs" / "SPEC.md").read_text(encoding="utf-8") + self.assertIn("#tape-scroll-top", spec) + self.assertIn("Back to Top", spec) + + +if __name__ == "__main__": + unittest.main() diff --git a/web/css/app.css b/web/css/app.css index 583c358..a43c2fe 100644 --- a/web/css/app.css +++ b/web/css/app.css @@ -670,13 +670,31 @@ body.bright .tape-pane .grid td.vol-cell { color: #fff; } .tape-pane td.float-low { color: var(--mint); font-weight: 600; } body.bright .tape-pane td.float-low { background: #8ff0a4 !important; color: #06140f; } .vol-cell { font-weight: 600; } +.tape-float-bar { + position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 5; + display: flex; align-items: center; gap: 8px; pointer-events: none; max-width: calc(100% - 24px); +} .new-events { - position: absolute; top: 44px; left: 50%; transform: translateX(-50%); z-index: 5; + pointer-events: auto; padding: 6px 14px; border-radius: 999px; background: #fff5c2; color: #2b2200; font-weight: 700; + font-size: 12px; white-space: nowrap; box-shadow: var(--shadow); cursor: pointer; display: none; border: none; } -.new-events.show { display: block; animation: bob 1.4s ease-in-out infinite; } -@keyframes bob { 50% { transform: translate(-50%, 3px); } } +.new-events.show { display: inline-flex; align-items: center; animation: bob 1.4s ease-in-out infinite; } +@keyframes bob { 50% { transform: translateY(3px); } } +.tape-scroll-top { + pointer-events: auto; + padding: 6px 13px; border-radius: 999px; + background: rgba(18, 24, 38, 0.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); + color: var(--text); border: 1px solid var(--border-2); + font-size: 12px; font-weight: 650; white-space: nowrap; + box-shadow: var(--shadow); cursor: pointer; display: none; + transition: border-color .15s ease, color .15s ease, background .15s ease; +} +.tape-scroll-top.show { display: inline-flex; align-items: center; gap: 5px; } +.tape-scroll-top:hover { + border-color: var(--mint); color: var(--mint); background: rgba(24, 33, 52, 0.96); +} /* ---------------------------------------------------------------- dropdowns / popovers */ .pop { diff --git a/web/index.html b/web/index.html index 1b9ad4c..34176d0 100644 --- a/web/index.html +++ b/web/index.html @@ -6,7 +6,7 @@ - +
@@ -235,11 +235,11 @@

Settings & Data Sources

- - - - - - + + + + + + diff --git a/web/js/tape.js b/web/js/tape.js index 11591c8..514f238 100644 --- a/web/js/tape.js +++ b/web/js/tape.js @@ -15,6 +15,7 @@ ["Strategy Name", "l", (e) => e.strategy], ]; const MAX_DOM = 3000; + const SCROLL_TOP_THRESHOLD = 24; const Tape = { events: [], @@ -34,7 +35,15 @@ }); const popBtn = opts.popout ? null : U.el("button", { class: "icon-btn", id: "tape-popout-btn", title: "Pop out tape", html: U.icons.popout }); const count = U.el("span", { class: "sub" }); - const newBtn = U.el("button", { class: "new-events", id: "tape-new-events" }, "New Events ↑"); + const newBtn = U.el("button", { class: "new-events", id: "tape-new-events", type: "button" }, "New Events ↑"); + const scrollTopBtn = U.el("button", { + class: "tape-scroll-top", + id: "tape-scroll-top", + type: "button", + "aria-label": "Back to top", + title: "Scroll back to top of tape", + }, "↑ Back to Top"); + const floatBar = U.el("div", { class: "tape-float-bar", id: "tape-float-bar" }, newBtn, scrollTopBtn); const thead = U.el("tr", {}, COLS.map(([h, c]) => U.el("th", { class: c, html: h }))); const tbody = U.el("tbody"); const body = U.el("div", { class: "pane-body" }, @@ -43,9 +52,9 @@ U.el("div", { class: "pane-head" }, U.el("div", { class: "pane-title" }, "⚡ Small Cap — High of Day Momentum", count), U.el("div", { class: "spacer" }), strBtn, pauseBtn, clearBtn, popBtn), - newBtn, body); + floatBar, body); host.append(pane); - Object.assign(Tape, { root: pane, tbody, body, newBtn, pauseBtn, clearBtn, strBtn, count }); + Object.assign(Tape, { root: pane, tbody, body, floatBar, newBtn, scrollTopBtn, pauseBtn, clearBtn, strBtn, count }); strBtn.onclick = () => Tape.strategyMenu(strBtn); pauseBtn.onclick = () => Tape.setPaused(!Tape.paused); @@ -57,8 +66,17 @@ } }; if (popBtn) popBtn.onclick = () => App.api().pop_tape(); - newBtn.onclick = () => { Tape.setPaused(false); body.scrollTop = 0; Tape.updateNewBtn(); }; - body.addEventListener("scroll", () => { if (body.scrollTop < 5 && !Tape.paused) Tape.updateNewBtn(); }); + newBtn.onclick = () => { + Tape.setPaused(false); + body.scrollTop = 0; + Tape.updateNewBtn(); + Tape.updateScrollTopBtn(); + }; + scrollTopBtn.onclick = () => Tape.scrollToTop(); + body.addEventListener("scroll", () => { + if (body.scrollTop < 5 && !Tape.paused) Tape.updateNewBtn(); + Tape.updateScrollTopBtn(); + }); tbody.addEventListener("click", (e) => { const tr = e.target.closest("tr"); if (tr && tr.dataset.t) App.api().select_symbol(tr.dataset.t); @@ -169,6 +187,7 @@ Tape.pending = []; Tape.updateStrBtn(); Tape.updateNewBtn(); + Tape.updateScrollTopBtn(); }, add(evs) { @@ -201,6 +220,7 @@ while (Tape.tbody.children.length > MAX_DOM) Tape.tbody.lastChild.remove(); if (body.scrollTop > 5) { body.scrollTop += body.scrollHeight - before; Tape.scrolledNew = true; } Tape.updateNewBtn(); + Tape.updateScrollTopBtn(); }, setPaused(p) { @@ -235,6 +255,18 @@ Tape.count.textContent = Tape.paused ? "· paused" : (vis ? `· ${vis} alerts (${days}d history)` : ""); }, + scrollToTop() { + if (!Tape.body) return; + Tape.body.scrollTop = 0; + if (!Tape.paused) Tape.updateNewBtn(); + Tape.updateScrollTopBtn(); + }, + + updateScrollTopBtn() { + if (!Tape.scrollTopBtn || !Tape.body) return; + Tape.scrollTopBtn.classList.toggle("show", Tape.body.scrollTop > SCROLL_TOP_THRESHOLD); + }, + updateStrBtn() { const all = App.config.tape.strategies.length; diff --git a/web/tape.html b/web/tape.html index fafb1cc..da6b0d4 100644 --- a/web/tape.html +++ b/web/tape.html @@ -6,7 +6,7 @@ - +
@@ -17,8 +17,8 @@
- - + +