Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): reset wheel state across sessions
[._.]/ Adam Eivy99199aa47bfa
diff --git a/client/src/hooks/useShellSession.js b/client/src/hooks/useShellSession.jsindex 8c3692f426..8ba71d9879 100644--- a/client/src/hooks/useShellSession.js+++ b/client/src/hooks/useShellSession.js@@ -9,7 +9,12 @@ import { useSocket } from './useSocket';import { useThemeContext } from '../components/ThemeContext';import { buildTerminalTheme, parseCssColorToHex } from '../lib/terminalTheme';import { attachDictationBridge } from '../lib/terminalDictation';-import { attachTerminalTouchScroll, attachTerminalWheelScroll, scrollTerminalPage } from '../lib/terminalScroll';+import {+ attachTerminalTouchScroll,+ attachTerminalWheelScroll,+ resetTerminalWheelScroll,+ scrollTerminalPage,+} from '../lib/terminalScroll';import { readFileAsBase64 } from '../utils/fileUpload';import * as api from '../services/api';import toast from '../components/ui/Toast';@@ -452,6 +457,7 @@ export function useShellSession({ isFullscreen } = {}) {// persist into this fresh shell and make xterm inject escape-sequence// reports (mouse/focus events) as INPUT, echoing as accumulating garbage// at the prompt. reset() restores the terminal to a clean initial state.+ resetTerminalWheelScroll(termInstanceRef.current);termInstanceRef.current.reset();termInstanceRef.current.writeln('\x1b[36mStarting shell session...\x1b[0m');}@@ -473,6 +479,7 @@ export function useShellSession({ isFullscreen } = {}) {// reset() not clear() — drop any DEC private modes (mouse/focus tracking,// alt-screen) the previously-viewed session left active so they can't// bleed into this one as injected escape-sequence input. See startSession.+ resetTerminalWheelScroll(termInstanceRef.current);termInstanceRef.current.reset();termInstanceRef.current.writeln('\x1b[36mAttaching to session...\x1b[0m');}@@ -703,6 +710,7 @@ export function useShellSession({ isFullscreen } = {}) {// TUI's lingering mouse/focus tracking can't inject garbage here. The// freshly-painted bufferedOutput re-establishes whatever modes THIS// session legitimately uses. See startSession for the full rationale.+ resetTerminalWheelScroll(termInstanceRef.current);termInstanceRef.current.reset();if (bufferedOutput) {termInstanceRef.current.write(bufferedOutput);diff --git a/client/src/lib/terminalScroll.js b/client/src/lib/terminalScroll.jsindex 0c982086b5..554ea6dbe1 100644--- a/client/src/lib/terminalScroll.js+++ b/client/src/lib/terminalScroll.js@@ -87,6 +87,13 @@ const wheelDeltaLines = (event, rowHeightPx) => {return event.deltaY / rowHeightPx;};+const wheelScrollResetters = new WeakMap();++/** Clear fractional wheel state before a reused terminal starts a new session. */+export const resetTerminalWheelScroll = (terminal) => {+ if (terminal && typeof terminal === 'object') wheelScrollResetters.get(terminal)?.();+};+/*** Scroll the normal terminal buffer by `lines` (negative = toward older output).* Alternate-screen apps have no terminal scrollback, so each requested logical@@ -153,8 +160,14 @@ export const attachTerminalWheelScroll = (terminal) => {if (pages) scrollTerminalLines(terminal, pages);};+ const reset = () => { remainderLines = 0; };+ wheelScrollResetters.set(terminal, reset);el.addEventListener('wheel', onWheel, { capture: true, passive: false });- return () => el.removeEventListener('wheel', onWheel, { capture: true });+ return () => {+ reset();+ if (wheelScrollResetters.get(terminal) === reset) wheelScrollResetters.delete(terminal);+ el.removeEventListener('wheel', onWheel, { capture: true });+ };};/**diff --git a/client/src/lib/terminalScroll.test.js b/client/src/lib/terminalScroll.test.jsindex 742d899b45..5def6df4fc 100644--- a/client/src/lib/terminalScroll.test.js+++ b/client/src/lib/terminalScroll.test.js@@ -4,6 +4,7 @@ import {attachTerminalWheelScroll,measureTerminalGeometry,planTouchScrollSteps,+ resetTerminalWheelScroll,scrollTerminalLines,scrollTerminalPage,sendTerminalPageKey,@@ -177,6 +178,18 @@ describe('attachTerminalWheelScroll', () => {detach();});+ it('resets fractional wheel state when the terminal session changes', () => {+ const term = makeTerminal({ rows: 24, height: 480 });+ const detach = attachTerminalWheelScroll(term);+ term.element.dispatchEvent(new WheelEvent('wheel', { deltaY: -20, bubbles: true, cancelable: true }));++ resetTerminalWheelScroll(term);+ term.element.dispatchEvent(new WheelEvent('wheel', { deltaY: -60, bubbles: true, cancelable: true }));++ expect(term.input).not.toHaveBeenCalled();+ detach();+ });+it('leaves normal-buffer wheel input to xterm', () => {const term = makeTerminal({ alt: false });const xtermListener = vi.fn();