mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-04 02:21:47 +00:00
Replaces the static WHEEL_SCROLL_STEP=1 multiplier on wheel events
with an adaptive accel state machine that infers user intent from
inter-event timing.
Algorithm ported straight from claude-code's
src/components/ScrollKeybindingHandler.tsx. All tuning constants,
the native/xterm.js path split, the encoder-bounce detection, the
trackpad-burst signature → all theirs. This file is a mechanical
port into our module structure.
What it does:
precision click (>500ms gap) 1 row/event (deliberate scan)
sustained mouse (40-200ms) 2-6 rows (decay curve)
detected wheel bounce ramps to 15 (sticky wheel-mode)
trackpad flick (5+ <5ms) 1 row/event (burst detect)
direction reversal reset to base
Two implementation paths:
* native terminals (ghostty, iTerm2, Kitty, WezTerm) — linear
window-ramp + optional wheel-mode curve triggered by detected
encoder bounce. SGR proportional reporting handled via the
burst-count guard.
* xterm.js (VS Code / Cursor / browser terminals) — pure
exponential-decay curve with fractional carry. Events arrive
1-per-notch with no pre-amplification, so the curve is more
aggressive.
Selected at construction via isXtermJs() from @hermes/ink (now
exported). Per-user tune via HERMES_TUI_SCROLL_SPEED (alias
CLAUDE_CODE_SCROLL_SPEED for portability).
13 unit tests covering direction flip/bounce/reversal, idle
disengage, trackpad-burst disengage, frac invariants, and the
native vs xterm.js branches.
Profiled under --rate 30 (stress test) and --rate 10 (realistic
sustained scroll): accel ramps to cap=6 at 30Hz burst, decays to
1-3 rows at sparse 10Hz clicks. Perf is comparable to baseline
because accel IS multiplying step — the win is perceptual (fast
flicks cover distance, slow clicks keep precision), not raw fps.
Companion to the earlier WHEEL_SCROLL_STEP=1 change: that set the
base; this modulates around it.
|
||
|---|---|---|
| .. | ||
| asCommandDispatch.test.ts | ||
| clipboard.test.ts | ||
| constants.test.ts | ||
| createGatewayEventHandler.test.ts | ||
| createSlashHandler.test.ts | ||
| details.test.ts | ||
| emoji.test.ts | ||
| markdown.test.ts | ||
| messages.test.ts | ||
| osc52.test.ts | ||
| paths.test.ts | ||
| platform.test.ts | ||
| providers.test.ts | ||
| reasoning.test.ts | ||
| rpc.test.ts | ||
| scroll.test.ts | ||
| stateIsolation.test.ts | ||
| streamingMarkdown.test.ts | ||
| subagentTree.test.ts | ||
| syntax.test.ts | ||
| terminalParity.test.ts | ||
| terminalSetup.test.ts | ||
| text.test.ts | ||
| textInputLineNav.test.ts | ||
| textInputWrap.test.ts | ||
| theme.test.ts | ||
| turnStore.test.ts | ||
| useComposerState.test.ts | ||
| useConfigSync.test.ts | ||
| useSessionLifecycle.test.ts | ||
| viewport.test.ts | ||
| viewportStore.test.ts | ||
| virtualHistoryClamp.test.ts | ||
| wheelAccel.test.ts | ||