Skip to content

refactor(frontend): extract touchScrollDebug helpers from TerminalView.vue - #325

Merged
attson merged 1 commit into
mainfrom
refactor/extract-touch-scroll-debug
Aug 4, 2026
Merged

refactor(frontend): extract touchScrollDebug helpers from TerminalView.vue#325
attson merged 1 commit into
mainfrom
refactor/extract-touch-scroll-debug

Conversation

@attson

@attson attson commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

First slice of milestone 5-b. TerminalView.vue is a 2700-line SFC and the touch-scroll debug plumbing was ~50 lines of module-scoped state (ring buffer + enabled flag) and helpers (`readTouchDebugFlag`, `logTouch`, `installTouchDebugDump`) that had nothing to do with the terminal setup around them — they existed only to instrument the touch/scroll code paths across the file.

Move to `lib/touchScrollDebug.ts`. `touchState()` stays inline because it closes over reactive refs (`selectionMode` / `imeFocused` / `softKeyboardOpen` / `keyboardWanted` / `userScrolledDuringKeyboardCycle`) that only exist inside setup.

Exports: `readTouchDebugFlag`, `setTouchDebugEnabled`, `isTouchDebugEnabled`, `logTouch`, `installTouchDebugDump`. The enable flag flip becomes explicit at the call site (`setTouchDebugEnabled(readTouchDebugFlag())`) instead of the direct `touchDebugEnabled = readTouchDebugFlag()` module-var mutation. `logTouch` keeps its "no-op when disabled" behavior; three call sites that guarded on the raw variable now use `isTouchDebugEnabled()`.

Behavior is byte-identical: same localStorage key, same ring size (300), same `[tsc]` console prefix, same `window.__attermTouchDebug()` dump.

Test plan

  • `npm test` 1631/1631
  • `npm run build` (vue-tsc + vite) green
  • Manual (browser): set `localStorage.setItem('atterm.debugTouch', '1')`, reload, tap the terminal — `[tsc]` lines appear in console; `window.__attermTouchDebug()` returns the ring

…w.vue

First slice of milestone 5-b. TerminalView.vue is a 2700-line SFC and
the touch-scroll debug plumbing was ~50 lines of module-scoped state
(ring buffer + enabled flag) and helpers (readTouchDebugFlag, logTouch,
installTouchDebugDump) that had nothing to do with the terminal setup
around them — they existed only to instrument the touch/scroll code
paths across the file.

Move to lib/touchScrollDebug.ts. touchState() stays inline because it
closes over reactive refs (selectionMode / imeFocused / softKeyboardOpen
/ keyboardWanted / userScrolledDuringKeyboardCycle) that only exist
inside setup.

Exports: readTouchDebugFlag, setTouchDebugEnabled, isTouchDebugEnabled,
logTouch, installTouchDebugDump. The enable flag flip becomes explicit
at the call site (setTouchDebugEnabled(readTouchDebugFlag())) instead
of the direct `touchDebugEnabled = readTouchDebugFlag()` module-var
mutation. logTouch keeps its "no-op when disabled" behavior; three
call sites that guarded on the raw variable now use isTouchDebugEnabled().

Behavior is byte-identical: same localStorage key, same ring size (300),
same `[tsc]` console prefix, same window.__attermTouchDebug() dump.
`npm test` 1631/1631; `npm run build` green.
@attson
attson merged commit 1565c2d into main Aug 4, 2026
7 checks passed
@attson
attson deleted the refactor/extract-touch-scroll-debug branch August 4, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant