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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): honor stored format when rendering, hide ChordPro meta directives, clear stale auto-fill on meta-less imports
[._.]/ Adam Eivyddce3ad4ea1f
diff --git a/client/src/components/songbook/TabSheetView.jsx b/client/src/components/songbook/TabSheetView.jsxindex c895f1c60c..da8a0dc114 100644--- a/client/src/components/songbook/TabSheetView.jsx+++ b/client/src/components/songbook/TabSheetView.jsx@@ -61,8 +61,15 @@ const ChordLyricLine = ({ line }) => (</div>);-function TabSheetView({ text, fontSizeRem = 0.875, className = '' }) {- const { lines } = useMemo(() => parseTabSheet(text), [text]);+function TabSheetView({ text, format = 'tab', fontSizeRem = 0.875, className = '' }) {+ const plain = format === 'plain';+ const { lines } = useMemo(+ // 'plain' is the explicit opt-out of notation parsing: render every line+ // verbatim (no section headings, no chord highlighting) so the stored+ // format selector has an observable effect.+ () => (plain ? { lines: [] } : parseTabSheet(text)),+ [text, plain],+ );// Group consecutive tabstaff lines into one horizontally-scrollable block so// the six strings of a staff scroll together.@@ -76,6 +83,17 @@ function TabSheetView({ text, fontSizeRem = 0.875, className = '' }) {return out;}, [lines]);+ if (plain) {+ return (+ <div+ className={`font-mono text-gray-200 whitespace-pre-wrap ${className}`}+ style={{ fontSize: `${fontSizeRem}rem`, lineHeight: 1.5 }}+ >+ {text}+ </div>+ );+ }+return (<div className={`font-mono text-gray-200 ${className}`} style={{ fontSize: `${fontSizeRem}rem`, lineHeight: 1.5 }}>{blocks.map((block, bi) => {@@ -103,6 +121,10 @@ function TabSheetView({ text, fontSizeRem = 0.875, className = '' }) {return <ChordLyricLine key={bi} line={line} />;case 'blank':return <div key={bi}>{' '}</div>;+ case 'directive':+ // ChordPro meta plumbing ({title:}/{key:}/{capo:}) — the values+ // surface in the viewer's badges/fields, not as raw text.+ return null;case 'lyric':case 'text':default:diff --git a/client/src/components/songbook/TabSheetView.test.jsx b/client/src/components/songbook/TabSheetView.test.jsxindex ab2f6fc4a0..ec0c1a5b6f 100644--- a/client/src/components/songbook/TabSheetView.test.jsx+++ b/client/src/components/songbook/TabSheetView.test.jsx@@ -58,4 +58,22 @@ describe('TabSheetView', () => {const { container } = render(<TabSheetView text="" />);expect(container.firstChild).toBeTruthy();});++ it('hides ChordPro meta directives — values belong in badges, not the sheet', () => {+ const { container } = render(+ <TabSheetView text={'{title: Example Song}\n{capo: 3}\nC G\nNonsense line'} />,+ );+ expect(container.textContent).not.toContain('{title: Example Song}');+ expect(container.textContent).not.toContain('{capo: 3}');+ expect(container.textContent).toContain('Nonsense line');+ });++ it("format='plain' renders verbatim: no headings, no chord highlighting", () => {+ const { container } = render(<TabSheetView text={SAMPLE} format="plain" />);+ // The raw [Verse 1] marker stays literal text (not a styled heading)...+ expect(container.textContent).toContain('[Verse 1]');+ expect(container.querySelector('.uppercase.tracking-wide')).toBeNull();+ // ...and no chord token gets the accent highlight.+ expect(container.querySelector('.text-port-accent.font-semibold')).toBeNull();+ });});diff --git a/client/src/lib/tabNotation.js b/client/src/lib/tabNotation.jsindex 09eee7b0a9..bb0f75abb4 100644--- a/client/src/lib/tabNotation.js+++ b/client/src/lib/tabNotation.js@@ -25,8 +25,9 @@// 'chordlyric' — ChordPro inline [C]lyric; text is the bare lyric, chords// carry col offsets into it// 'blank' — whitespace-only-// 'text' — everything else (incl. {directive} lines; meta directives-// still populate meta)+// 'directive' — ChordPro meta directives ({title:}/{artist:}/{key:}/{capo:});+// values populate meta, renderers hide the raw line+// 'text' — everything else (incl. non-meta {directive} lines)// ---------------------------------------------------------------------------// Chord tokens@@ -169,13 +170,16 @@ const classifyLine = (raw) => {const meta = META_DIRECTIVE_RE.exec(line);if (meta) {+ // 'directive' (not 'text'): the value is extracted into meta, so renderers+ // hide the raw {title:}/{artist:}/{key:}/{capo:} line instead of showing+ // ChordPro plumbing above the song.const key = META_ALIASES[meta[1].toLowerCase()] || meta[1].toLowerCase();const value = meta[2];if (key === 'capo') {- if (/^\d{1,2}$/.test(value)) return { type: 'text', text: line, meta: { capo: Number(value) }, chordpro: true };- return { type: 'text', text: line, error: `invalid capo value "${value}"`, chordpro: true };+ if (/^\d{1,2}$/.test(value)) return { type: 'directive', text: line, meta: { capo: Number(value) }, chordpro: true };+ return { type: 'directive', text: line, error: `invalid capo value "${value}"`, chordpro: true };}- return { type: 'text', text: line, meta: { [key]: value }, chordpro: true };+ return { type: 'directive', text: line, meta: { [key]: value }, chordpro: true };}const cpSection = CHORDPRO_SECTION_RE.exec(line);diff --git a/client/src/lib/tabNotation.test.js b/client/src/lib/tabNotation.test.jsindex ef2f5bdd85..992b826070 100644--- a/client/src/lib/tabNotation.test.js+++ b/client/src/lib/tabNotation.test.js@@ -229,6 +229,15 @@ describe('parseTabSheet — meta + errors', () => {expect(meta).toEqual({ title: 'Example Song', artist: 'The Placeholders', key: 'G', capo: 2 });});+ it("classifies meta directives as 'directive' so renderers hide the raw line", () => {+ const { lines } = parseTabSheet('{title: Example Song}\n{capo: 2}\n{capo: banana}\nplain words');+ expect(lines.map((l) => l.type)).toEqual(['directive', 'directive', 'directive', 'text']);+ // Non-meta directives stay 'text' (e.g. {comment: ...} conventionally shows).+ expect(parseTabSheet('{comment: watch the bridge}').lines[0].type).toBe('text');+ // transposeText passes directive lines through untouched.+ expect(transposeText('{key: G}\nC G', 2)).toBe('{key: G}\nD A');+ });+it('supports the short aliases {t:} and {st:}', () => {const { meta } = parseTabSheet('{t: Example Song}\n{st: The Placeholders}');expect(meta).toEqual({ title: 'Example Song', artist: 'The Placeholders' });diff --git a/client/src/pages/SongBookImport.jsx b/client/src/pages/SongBookImport.jsxindex 71f254e6fd..191e664d4c 100644--- a/client/src/pages/SongBookImport.jsx+++ b/client/src/pages/SongBookImport.jsx@@ -87,16 +87,14 @@ export default function SongBookImport() {const applyMetaDefaults = useCallback((meta) => {// Prefill untouched fields; a field still holding the PREVIOUS auto-fill- // counts as untouched, so importing song B after song A refreshes it.+ // counts as untouched, so importing song B after song A refreshes it —+ // including CLEARING it when B carries no metadata (otherwise A's title+ // silently saves onto B's content). Genuine user edits are never touched.const prev = { ...autoFilledRef.current };- if (meta?.title) {- autoFilledRef.current.title = meta.title;- setTitle((cur) => (!cur || cur === prev.title ? meta.title : cur));- }- if (meta?.artist) {- autoFilledRef.current.artist = meta.artist;- setArtist((cur) => (!cur || cur === prev.artist ? meta.artist : cur));- }+ const next = { title: meta?.title || '', artist: meta?.artist || '' };+ autoFilledRef.current = next;+ setTitle((cur) => (!cur || cur === prev.title ? next.title : cur));+ setArtist((cur) => (!cur || cur === prev.artist ? next.artist : cur));}, []);const onPasteButton = useCallback(async () => {@@ -252,7 +250,7 @@ export default function SongBookImport() {<div className="mb-4"><div className="text-xs text-gray-400 mb-1">Preview</div><div className="bg-port-card border border-port-border rounded-lg p-3 max-h-[50vh] overflow-y-auto overflow-x-auto">- <TabSheetView text={contentText} />+ <TabSheetView text={contentText} format={contentFormat} /></div></div>)}diff --git a/client/src/pages/SongBookImport.test.jsx b/client/src/pages/SongBookImport.test.jsxindex eddc591ed5..909e4473ba 100644--- a/client/src/pages/SongBookImport.test.jsx+++ b/client/src/pages/SongBookImport.test.jsx@@ -59,6 +59,29 @@ describe('SongBookImport', () => {expect('capo' in body).toBe(false); // 13 is outside 0..12 — dropped, POST can't 400});+ it('a second meta-less import clears a stale auto-fill but never a user edit', async () => {+ renderPage();+ const textarea = screen.getByLabelText('Pasted tab content');+ const title = screen.getByLabelText('Title');++ // Song A auto-fills the title from its ChordPro directive on blur.+ fireEvent.change(textarea, { target: { value: '{title: First Song}\nC G' } });+ fireEvent.blur(textarea);+ await waitFor(() => expect(title.value).toBe('First Song'));++ // Song B has NO metadata — the stale auto-fill must clear, not silently+ // save First Song's title onto B's content.+ fireEvent.change(textarea, { target: { value: 'D A\nDifferent invented line' } });+ fireEvent.blur(textarea);+ await waitFor(() => expect(title.value).toBe(''));++ // A user-typed title survives a later meta-less import.+ fireEvent.change(title, { target: { value: 'My Own Name' } });+ fireEvent.change(textarea, { target: { value: 'E B\nThird invented line' } });+ fireEvent.blur(textarea);+ expect(title.value).toBe('My Own Name');+ });+it('sends an in-range pasted capo through unchanged', async () => {renderPage();fireEvent.change(screen.getByLabelText('Pasted tab content'), {diff --git a/client/src/pages/SongBookViewer.jsx b/client/src/pages/SongBookViewer.jsxindex 91c1eb858e..ac11e8419e 100644--- a/client/src/pages/SongBookViewer.jsx+++ b/client/src/pages/SongBookViewer.jsx@@ -455,7 +455,7 @@ export default function SongBookViewer() {<div><div className="text-xs text-gray-400 mb-1">Preview</div><div className="bg-port-card border border-port-border rounded-lg p-3 overflow-x-auto">- <TabSheetView text={draft.text} fontSizeRem={fontSize} />+ <TabSheetView text={draft.text} format={draft.format} fontSizeRem={fontSize} /></div></div></div>@@ -545,7 +545,12 @@ export default function SongBookViewer() {<div ref={scrollRef} className="flex-1 overflow-y-auto px-4 py-4">{song.content?.text ? (- <TabSheetView text={renderedText} fontSizeRem={fontSize} className="max-w-4xl" />+ <TabSheetView+ text={renderedText}+ format={song?.content?.format || 'tab'}+ fontSizeRem={fontSize}+ className="max-w-4xl"+ />) : (<p className="text-sm text-gray-500">No sheet content yet — <button type="button" onClick={() => setMode('edit')} className="text-port-accent hover:underline">add some in Edit mode</button>.