Skip to content

Add line grouping view to lyrics editor - #13

Closed
cchacs wants to merge 12 commits into
got-feedBack:mainfrom
get-flashbacks:agent/line-group-view
Closed

cchacs wants to merge 12 commits into
got-feedBack:mainfrom
get-flashbacks:agent/line-group-view

Conversation

@cchacs

@cchacs cchacs commented Sep 23, 2026

Copy link
Copy Markdown

Summary

  • add a Words/Lines view toggle to the manual lyrics editor
  • group existing word entries by line-break markers for display
  • preserve the original ordering, timing, and saved arrangement

Testing

  • node --check screen.js
  • py -m pytest (28 passed)
  • git diff --check

cchacs and others added 12 commits August 2, 2026 14:27
ls_status() treated any HTTP 200 from /health as "alignment server ready",
but the demucs-server responds 200 with status:"ok" as soon as the process
is up -- well before whisperx (needed for /align's VAD-anchored windows)
finishes downloading/loading. During that window /health's own `warmup`
block already reports e.g. `whisperx: "downloading"`.

This showed a green "Alignment server ready" notice while a request would
still hit the server mid-warmup, then fail with a confusing "Cannot
connect to alignment server" the moment the user actually clicked Align --
despite the ready notice being visible seconds earlier.

ls_status() now inspects /health's `warmup.whisperx` field and only
reports available:true once it's "ready", surfacing an accurate
"still loading" reason otherwise. Per-language aligners load lazily on
demand and are not gated on here.

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
* Fix: saved lyrics never carried line-break markers

ls_save() wrote each segment's plain text straight into lyrics.json's `w`
field, but the sloppak-spec line-wrap convention (docs/sloppak-hand-editing.md
§Lyrics) requires a trailing "+" on the last syllable/word of every line —
that's the only signal renderers (e.g. the Lyrics Karaoke plugin's
syllableText()) use to know where to wrap. With it never written, saved
lyrics always rendered as one unbroken line regardless of granularity.

- screen.js: lsSave() now sends the selected granularity alongside segments.
- routes.py: ls_save() appends "+" to the line-ending entry of each line —
  every entry for 'line' granularity (each segment already IS a whole line,
  per the align server's own docs), or the entry immediately before a
  `new_line: true` segment (word/syllable granularity, where the align
  server marks the FIRST entry of each line instead of the last).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* Group preview rows by input line for word/syllable granularity

_lsRenderPreview() rendered one row per individual word/syllable segment,
with only a thin divider between line groups -- so the preview didn't read
like the lyrics the user actually typed. Groups consecutive segments back
into one row per original input line, using the same new_line boundary
the save-time fix (previous commit) already relies on.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
* Add FeedBack issue templates

* Add FeedBack issue templates

* Add FeedBack issue templates

* Add FeedBack issue templates
… in search results (#5)

- routes.py: /align and /save built filesystem paths as `dlc / filename`
  with no containment check. A `filename` containing `..` traversal or an
  absolute path (which silently discards `dlc` under Path's `/` operator)
  let a request read/write files outside the configured DLC folder, as
  long as the target existed and was named *.sloppak/*.feedpak. Added
  `_safe_dlc_path()`, mirroring core's lib/dlc_paths._resolve_dlc_path
  containment check, and route both filename-bound handlers through it.

- screen.js: lsSearchSongs() spliced song title/artist into an inline
  onclick="" attribute using esc(), which only escapes <, >, & for
  text-node use and does not escape quotes. A title/artist containing a
  `"` broke out of the onclick attribute (esc() output is also nested
  inside a single-quoted JS string literal, a second unescaped context),
  allowing arbitrary attribute/markup injection. Song metadata is
  untrusted (GP/MusicXML import tags, manifest.json, MusicBrainz
  enrichment). Rebuilt the row via createElement/textContent with an
  addEventListener closure instead of a serialized attribute string.

Co-authored-by: Claude <noreply@anthropic.com>
Ecosystem versioning convention (feedBack-plugin-spec best practices,
rule 4): PATCH bump for a fix. Covers the two security fixes already
pushed to this branch. No CHANGELOG.md exists in this repo to update.
…esponses (#10)

* fix: escape Content-Disposition filenames and guard malformed align responses

- ls_export now quote-escapes title/artist before embedding them in the
  Content-Disposition filename param, and adds an RFC 5987 filename*=
  fallback, so an embedded quote can't corrupt/break out of the header.
- ls_align now wraps resp.json() in a try/except so a non-JSON response
  from the configured align server returns a clean 502 instead of an
  unhandled 500.

Fixes #7, #8

* fix: clarify no-op backslash escape in ls_export filename header

pullfrog review on PR #10 flagged that the \\ -> \\\\ replacement in
ascii_name is a no-op today (safe_name already stripped \\ above) —
harmless but confusing without context. Added a one-line comment
explaining it's a belt-and-suspenders guard for if that stripping
ever changes, rather than dead code.

---------

Co-authored-by: Claude <noreply@anthropic.com>
* Add manual lyrics editor: tap-to-time and waveform drag-editing

Both existing lyrics plugins were generate-only (Whisper align, save) with
no way to fix the ~10% alignment gets wrong or author lyrics for a song
with no vocals stem. Adds a hand-editing surface: tap-to-time, drag/resize
syllable blocks over a client-decoded waveform, text seeding with manual
syllable splits, and loading/correcting a song's existing lyrics via a new
GET /lyrics endpoint. Saves go through a new POST /save-lyrics, validated
server-side the same way the sloppak loader filters lyrics.json on read.

Also fixes a real bug in the existing align-based /save: it wrote
lyrics.json into the extraction cache for zip-form sloppaks instead of the
distributable .sloppak file, so edits were silently lost whenever the
cache was invalidated. Both save paths now funnel through one
_persist_lyrics helper (ported from lyrics_karaoke's mature zip-repack
pattern) that rewrites directory-form packs in place and re-zips zip-form
packs with a one-time .bak.

Hardens _find_vocals_stem against a manifest-controlled path escaping the
pack directory, matching the containment check already applied to
request-supplied filenames.

* Fix three data-loss bugs Pullfrog's review caught in the manual editor

- _lsAlignmentResult wasn't bound to the song it was computed for:
  align song A, select song B, then "Edit Manually"/"Save to Song" would
  persist A's alignment into B. Clear it (and hide the preview) whenever
  the selected song changes.

- Re-opening the editor, or navigating away from the screen, silently
  discarded unsaved tap-to-time/drag edits with no warning. Added dirty
  tracking (generation + history-index pair, so undoing back to exactly
  the loaded/saved snapshot correctly reports clean again) and a
  confirm() guard in lsOpenEditor's reopen path, lsCloseEditor, and the
  showScreen navigation hook. Callers that switch songs now check
  lsCloseEditor()'s return value and abort the switch if the user kept
  the editor open, rather than moving on to a new song while the editor
  still points at the old one.

- Saving a session with only untimed syllables (text seeded via "Add",
  nothing tapped/dragged yet) silently posted an empty list, which the
  server correctly treats as "clear the track" — wiping any lyrics
  already saved on the song, with the seeded text already gone from the
  textarea and no way to recover it. Now confirms first.

* Fix inaccurate docstring and add the tests the PR body claimed

- ls_save_lyrics's docstring said validation matched the sloppak
  loader's own read-side filter. It doesn't — the loader only checks
  type (str / int-or-float), with no finiteness check, no d<=0 drop, no
  rounding. This handler is stricter, not equivalent; reworded to say so.

- The original PR body described round-trip, traversal, and endpoint
  tests that were run ad-hoc but never committed — this repo had no
  tests/ directory at all. Adds tests/test_helpers.py (mirrors
  lyrics_karaoke's existing isolated-test convention: pure/file-IO
  helpers only, no dependency on core's sloppak module since that isn't
  available outside the feedBack host). Covers path-traversal rejection,
  manifest IO, and — the load-bearing case — _persist_lyrics for both
  directory-form and zip-form sloppaks, asserting the write lands inside
  the actual .zip archive rather than only the extraction cache. That's
  a direct regression test for the persistence bug this PR fixed.

* Fix two real regressions in the dirty-tracking guard just added

- lsEditInEditor's .then() ran unconditionally, so declining the
  "discard unsaved edits?" prompt in lsOpenEditor (or having no song
  selected) didn't stop it — the alignment seed still overwrote
  _lsEditorSyllables and reset the undo history, destroying the exact
  edits the user just chose to keep. lsOpenEditor now returns whether it
  actually (re)loaded; lsEditInEditor checks that before seeding.

- The (generation, history-index) dirty scheme broke once a session
  crossed the 50-entry undo cap: _lsEditorPushHistory shifts the oldest
  snapshot out on overflow, so "index 0" after enough edits no longer
  means the snapshot that was actually saved — undoing back to it could
  report clean (skipping the discard prompt) while showing genuinely
  different content. Replaced with a content-based comparison
  (JSON-serialized snapshot vs. the live array), which doesn't depend on
  history-array bookkeeping surviving intact across the whole session.

Both caught by Pullfrog's review of the previous fix commit.

---------

Co-authored-by: Claude <noreply@anthropic.com>
- /export raised UnicodeEncodeError (500) for any title/artist with a
  character outside Latin-1 (CJK, Cyrillic, emoji, ...), because
  Starlette encodes Content-Disposition header values as Latin-1 and
  the legacy filename= fallback was never folded to ASCII. Extracted
  the fold already used by the karaoke plugin into
  _ascii_safe_filename_component() and applied it here too.
- _format_lrc / _format_lrc_word_level computed minutes/seconds
  independently (int(t // 60), f"{t % 60:05.2f}"), so a seconds
  remainder that rounds up to 60.00 under :05.2f (e.g. 59.996) printed
  an invalid timestamp like [01:60.00] instead of rolling into the next
  minute. New _lrc_timestamp() rounds to whole centiseconds first, then
  splits into minutes/seconds, so the carry happens before formatting.
- Both formatters, and /save's segment-to-lyrics conversion, indexed
  seg["start"]/seg["text"]/seg["end"] directly, so a malformed
  segment (missing key, non-numeric start/end, a non-dict entry) raised
  KeyError/TypeError and 500'd the whole request instead of being
  skipped (/export) or reported as a clear 400 (/save).
- Bumped plugin.json to 1.1.2 (bug fixes affecting real behavior).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVxQShyx8Mrqe1GKNstjHy
…orrupting

Infinity/NaN (via literal "Infinity"/"nan" or an overflowing literal like
1e999) parsed fine as floats and slipped past every existing malformed-
segment guard:

- /export: _lrc_timestamp's round(inf * 100) raised OverflowError,
  500ing the whole export.
- /save: the same values passed validation and were persisted as literal
  Infinity/NaN in lyrics.json (json.dumps' default allow_nan=True) --
  unreadable by both the frontend's JSON.parse and ls_get_lyrics' own
  allow_nan=False serializer, corrupting the song.

Added math.isfinite checks alongside the existing float() conversions in
_format_lrc, _format_lrc_word_level, and ls_save's /save validation.

Also hardened _format_lrc_word_level against "words": null -- iterating
it directly raised TypeError outside any try/except. Checking
isinstance(seg.get("words"), list) rejects None the same way it already
rejected any other non-list shape.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVxQShyx8Mrqe1GKNstjHy
…Error

Same latent bug just found and fixed in the lyrics_karaoke plugin's copy
of this code (feedBack-plugin-lyrics-karaoke#9 review): callers gate
_lrc_timestamp() calls on math.isfinite(t), but that alone doesn't catch
a value like 1e307 -- a real, finite double whose *scaled* form
(1e307 * 100 = 1e309) exceeds the max representable double and becomes
inf, so round() on the scaled value raised OverflowError instead of the
clean skip the finiteness check was meant to guarantee.

_lrc_timestamp() now checks the scaled (centisecond) value for
finiteness too, raising ValueError instead of letting round() overflow.
_format_lrc() and _format_lrc_word_level() now catch that ValueError
and skip the segment/word, consistent with their existing malformed-
input handling, rather than letting it propagate as a 500.

This PR (#11) already merged before this bug was found, so this branch
was restarted from main per the merged-PR branch-recovery convention.

Bumped plugin.json to 1.1.4.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVxQShyx8Mrqe1GKNstjHy
@coderabbitai

coderabbitai Bot commented Sep 23, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 5c41f42d-36e7-4012-965f-a52d49596dd3

📥 Commits

Reviewing files that changed from the base of the PR and between f172eef and e09eb27.

📒 Files selected for processing (11)
  • .github/ISSUE_TEMPLATE/bug_report.yml
  • .github/ISSUE_TEMPLATE/config.yml
  • .github/ISSUE_TEMPLATE/feature_request.yml
  • .github/ISSUE_TEMPLATE/task.yml
  • .github/workflows/pullfrog.yml
  • README.md
  • plugin.json
  • routes.py
  • screen.html
  • screen.js
  • tests/test_helpers.py
 __________________________________________
< Your favorite GPT-wrapped code reviewer. >
 ------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@cchacs

cchacs commented Sep 23, 2026

Copy link
Copy Markdown
Author

Opened against the wrong base repository. Superseded by get-flashbacks#14, which contains only the intended commit.

@cchacs cchacs closed this Sep 23, 2026
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