Skip to content

feat(editor): toggleable follow-playhead (Shift+L) - #113

Merged
byrongamatos merged 2 commits into
mainfrom
feat/editor-follow-toggle
Jul 7, 2026
Merged

feat(editor): toggleable follow-playhead (Shift+L)#113
byrongamatos merged 2 commits into
mainfrom
feat/editor-follow-toggle

Conversation

@ChrisBeWithYou

@ChrisBeWithYou ChrisBeWithYou commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Roadmap 2.3 (parity cluster). The other 2.3 items — seek-to-note / next-prev note/beat/grid/anchor — already shipped in the earlier waves; this adds the missing follow toggle.

What

The playback auto-scroll (view jumps once the playhead crosses 80% of the window, landing it at 30%) was unconditional. It''s now gated on a follow pref — default ON, behavior unchanged — so an author can pin the view on one passage and keep editing while the song plays on. New registry command toggleFollow, bound Shift+L in both FeedBack Native and EOF Legacy profiles (collision-checked). Editor pref only, never pack data. The scroll policy math moves into a @pure:follow-scroll block.

Tests

tests/follow_toggle.test.js: the 80%-trigger/30%-landing policy pinned exactly, the at-threshold non-trigger, and the follow-off null (fails on main, where the scroll is unconditional). Full JS suite: 42 files green.

Fresh region vs the open queue — playbackTick''s scroll block + registry rows only.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JEoFeTPSnz4NpwwCG52hnu

Summary by CodeRabbit

  • New Features

    • Added a Follow-playhead editor preference controlled via Shift+L to toggle auto-follow during playback.
  • Bug Fixes

    • Playback auto-scrolling is no longer unconditional; it now follows the configured setting (defaults to on) and only applies after the trigger point.
  • Tests

    • Added tests covering follow-enabled vs follow-disabled scrolling behavior, including threshold and scroll target expectations.
  • Documentation

    • Updated the Unreleased changelog entry for the new preference/shortcut.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a Shift+L follow-playhead toggle. Playback auto-scroll now depends on a persisted editor preference that defaults on, with a test covering the scroll target behavior and a changelog update.

Changes

Follow-playhead toggle

Layer / File(s) Summary
Shortcut registration and dispatch
screen.js
Adds toggleFollow shortcut registration, maps Shift+L in two key handlers, and routes the action to _editorToggleFollow().
Follow-gated playback auto-scroll
screen.js, tests/follow_toggle.test.js, CHANGELOG.md
Adds follow-aware scroll targeting, localStorage-backed preference persistence, status text updates for toggle state, a test for enabled/disabled follow behavior, and a changelog entry for the new preference.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: a toggleable editor follow-playhead feature bound to Shift+L.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/editor-follow-toggle

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.44.1)
screen.js

ast-grep timed out on this file


Comment @coderabbitai help to get the list of available commands.

Roadmap 2.3 parity cluster. The playback auto-scroll was unconditional;
it is now gated on a follow pref (default ON — unchanged behavior) so an
author can pin the view on one passage and keep editing while the song
plays. Registry command `toggleFollow` with Shift+L in both profiles; the
scroll policy math is extracted into @pure:follow-scroll and pinned by
tests (the follow-off case fails on main).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JEoFeTPSnz4NpwwCG52hnu
@ChrisBeWithYou
ChrisBeWithYou force-pushed the feat/editor-follow-toggle branch from 2d8f56a to 2119566 Compare July 7, 2026 21:32

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/follow_toggle.test.js (1)

16-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Fragile regex+eval extraction for the pure block.

Extracting _followScrollTargetPure via regex on comment markers and evaluating with new Function is brittle — reformatting the @pure:follow-scroll markers or block whitespace in screen.js would silently break this test's ability to locate/eval the function. Consider having screen.js export the pure function (e.g., conditional module.exports for Node) and require it directly instead.

♻️ Suggested direction (screen.js side)
+if (typeof module !== 'undefined' && module.exports) {
+  module.exports = { _followScrollTargetPure };
+}
// tests/follow_toggle.test.js
const { _followScrollTargetPure } = require('../screen.js');
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/follow_toggle.test.js` around lines 16 - 24, The current test setup in
follow_toggle.test.js is brittle because it locates _followScrollTargetPure by
regexing the `@pure`:follow-scroll markers in screen.js and then evaluating the
block with new Function. Update screen.js to expose _followScrollTargetPure as a
normal export for Node so the test can load it directly with require, and remove
the marker-based extraction logic from the test while keeping the existing
function name and behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/follow_toggle.test.js`:
- Around line 16-24: The current test setup in follow_toggle.test.js is brittle
because it locates _followScrollTargetPure by regexing the `@pure`:follow-scroll
markers in screen.js and then evaluating the block with new Function. Update
screen.js to expose _followScrollTargetPure as a normal export for Node so the
test can load it directly with require, and remove the marker-based extraction
logic from the test while keeping the existing function name and behavior
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a46318cb-9ccd-41d8-b803-d9c13ee3ed9d

📥 Commits

Reviewing files that changed from the base of the PR and between 2d8f56a and 2119566.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • screen.js
  • tests/follow_toggle.test.js
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • screen.js

@byrongamatos

Copy link
Copy Markdown
Collaborator

@coderabbitai Thanks — skipping the module.exports suggestion on this one. The @pure-block regex + new Function extraction is the established convention across all 47 test files in this repo (scroll_bounds, eof_shortcuts, audio_mixer, …), and screen.js is intentionally a single browser IIFE with zero module.exports by design. Adding a Node export just for this one function would be inconsistent with the codebase and break the single-IIFE contract. The marker-based extraction is deliberately uniform, so keeping it consistent here is the lower-risk choice.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@byrongamatos Understood, that makes sense — thanks for the context. Given screen.js is intentionally a single browser IIFE and the @pure:... marker + new Function extraction pattern is the uniform convention across all test files in this repo, adding a one-off module.exports here would indeed be inconsistent. Withdrawing that suggestion.

(⁀ᗢ⁀) noted for future reviews


✏️ Learnings added
Learnt from: byrongamatos
URL: https://github.com/got-feedBack/feedBack-plugin-editor/pull/113

Timestamp: 2026-07-07T23:04:25.521Z
Learning: In this repository (feedBack-plugin-editor), `screen.js` is intentionally a single browser IIFE with zero `module.exports` by design. Tests extract pure functions from it using an `pure:<name>` marker-comment block convention parsed via regex and evaluated with `new Function`, rather than via `module.exports`. This marker-based extraction convention is used uniformly across all test files in the repo (e.g., `scroll_bounds`, `eof_shortcuts`, `audio_mixer`, `follow_toggle`). Do not suggest adding `module.exports` to `screen.js` for testability; instead expect/require the `pure:<name>` block convention for newly extracted pure functions.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

…ggle

# Conflicts:
#	CHANGELOG.md
#	screen.js
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.

2 participants