Skip to content

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

docs([issue-1028]): log issue #1028 to changelog

Adam Eivy52837622ca7f
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index e6da4e1006..f8b28c545d 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -1,5 +1,6 @@
## Added
+- **[issue-1028] Songs: a practice mode to learn and memorize a song** — the song editor and reader gain a Training panel that turns the sheet music into a drill. Pick the whole song or a single section, get a one-bar count-in, sing it, and watch each note light up green/yellow/red with an accuracy score for the take — then repeat, or turn on Loop to keep cycling the same part. PortOS tracks your progress over time: each section earns a rolling average and flips to "learned" once you hit it accurately a few takes in a row, a memorization bar shows how much of the song you've got down, and it nudges you toward your weakest sections to practice next. As your accuracy on a part climbs, the lyrics fade and finally hide so you're singing it from memory. It runs entirely on the built-in pitch detection — no extra audio library — and completes the song system's vocal pitch-detection and training toolkit.
- **[issue-1025] Songs: color-match playback that grades you against the score** — sing along while recording and the sheet music grades you note by note in real time. A one-bar metronome counts you in, then the song walks through the written melody in tempo and lights each notehead green when you're in tune, yellow when you're close, and red when you miss or stray off pitch. When you stop, you get a per-take score — the percentage of notes you nailed — so you can track how well you're learning the song. It listens to the same take you're recording (no second microphone), works on mobile, and shuts the mic and analysis down cleanly when you stop.
- **Songs: a live vocal tuner while you record** — the song recorder now shows the note you're singing and how flat or sharp it is, in real time, right next to the metronome. Hit a take and the tuner reads the same microphone you're recording into (it never opens a second mic), displaying the detected note and a green/yellow/red cents needle that swings flat ↔ sharp and centers when you're in tune. When you're not recording, a **Tune** button opens a standalone tuning mode that listens to the mic without recording or saving anything — handy for warming up or finding a starting pitch. Mobile-friendly, and the mic and analysis shut down cleanly the moment you stop or leave the page. Built on the in-house pitch-detection core — no third-party audio library. (#1023)
- **[issue-1026] Songs: sing a melody and turn it into sheet music** — the score editor has a new **Sing to score** panel. Press Sing, get a one-bar count-in so you know where the downbeat is, sing your phrase, then press Stop — PortOS listens to the melody, picks out the notes, snaps their timing to the song's tempo, and writes them out as notation. The detected notes preview on a real staff before you commit, and you can append them to the end of your score or drop them in place of whatever you've selected in the editor. Notes are spelled to match the song's key (flats in a flat key), and it all runs on the built-in pitch detection — no extra audio library.
diff --git a/client/src/components/songs/ScoreSheet.jsx b/client/src/components/songs/ScoreSheet.jsx
index 77de906fae..f1b4e6f187 100644
--- a/client/src/components/songs/ScoreSheet.jsx
+++ b/client/src/components/songs/ScoreSheet.jsx
@@ -311,6 +311,8 @@ export default function ScoreSheet({ text, className = '', controls = true, acti
if (note.chord) {
els.push(<text key={`${key}-ch`} x={cx} y={chordY} fontSize={12} fontWeight="600" style={fillStyle(CHORD)} textAnchor="middle" fontFamily="ui-sans-serif, system-ui, sans-serif">{note.chord}</text>);
}
+ // `hideLyrics` lets training mode obscure the words (sing from memory)
+ // without stripping them from the score text the editor still owns.
if (note.lyric && !hideLyrics) {
els.push(<text key={`${key}-ly`} x={cx} y={lyricY} fontSize={11} style={fillStyle(LYRIC)} textAnchor="middle" fontFamily="ui-sans-serif, system-ui, sans-serif">{note.lyric}</text>);
}
diff --git a/server/services/songs.js b/server/services/songs.js
index 9d43583540..28e1d8883e 100644
--- a/server/services/songs.js
+++ b/server/services/songs.js
@@ -191,7 +191,10 @@ const sanitizeProgress = (p) => {
for (const [scope, attempts] of Object.entries(rawHistory)) {
if (scopeCount >= PROGRESS_SCOPES_MAX) break;
const key = trimField(scope, ID_MAX_LENGTH);
- if (!key) continue;
+ // Skip empty keys and the prototype-pollution-prone keys — a section id is
+ // always `sec-N` (or the `__whole__` sentinel), never one of these, so a
+ // hand-edited `__proto__`/`constructor` scope is a malformed file, not data.
+ if (!key || key === '__proto__' || key === 'constructor' || key === 'prototype') continue;
const cleaned = sanitizeList(attempts, sanitizeAttempt, PROGRESS_HISTORY_MAX);
if (!cleaned.length) continue;
history[key] = cleaned;
diff --git a/server/services/songs.test.js b/server/services/songs.test.js
index 8d2caffc68..9494da1a60 100644
--- a/server/services/songs.test.js
+++ b/server/services/songs.test.js
@@ -260,6 +260,16 @@ describe('songs service', () => {
expect(song.progress.history['sec-2']).toHaveLength(1);
});
+ it('drops prototype-pollution-prone scope keys from a hand-edited file', () => {
+ const song = svc.sanitizeSong({
+ id: 'x',
+ progress: { history: { '__proto__': [{ percentInTune: 90, graded: 3 }], 'sec-1': [{ percentInTune: 70, graded: 3 }] } },
+ });
+ expect(Object.keys(song.progress.history)).toEqual(['sec-1']);
+ // The Object prototype was not polluted.
+ expect({}.percentInTune).toBeUndefined();
+ });
+
it('clamps an oversized per-scope history to PROGRESS_HISTORY_MAX', () => {
const attempts = Array.from({ length: svc.PROGRESS_HISTORY_MAX + 20 }, () => ({ percentInTune: 80, graded: 3 }));
const song = svc.sanitizeSong({ id: 'x', progress: { history: { 'sec-1': attempts } } });