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
drop duplicated opening-quote fragments in the manuscript Format pass
[._.]/ Adam Eivyc26b12979903
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex fd17becc25..2bbbdc6c22 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -4,7 +4,7 @@- **Video LoRAs now fuse on the bf16 LTX-2.3 Unified Beta (mlx_video runtime), not just dgrauet** — Previously a video LoRA like `ltx2.3-audio-reactive-lora` only worked on the dgrauet `ltx2` runtime; selecting the higher-quality **LTX-2.3 Unified Beta** (notapalindrome's `mlx_video` runtime) silently hid the LoRA picker. The stock `mlx_video.generate_av` CLI has no `--lora` flag, but the `mlx-video-with-audio` package ships an LTX-aware LoRA subsystem (`mlx_video.lora`) that's simply never called from the AV generator. A new wrapper (`scripts/generate_av_lora.py`) closes that gap without reimplementing the ~1000-line generation loop: it loads the user LoRAs, monkeypatches generate_av's two transformer-weight load seams to merge the LoRA deltas into the transformer (bf16, `quantization_bits=0`), then runs generate_av's own `main()` — so the SSE progress protocol is byte-for-byte identical to the non-LoRA path. The VideoGen picker now appears for non-quantized LTX-2.x `mlx_video` models too (gated by `isMlxVideoLtxLoraCapable`); if a LoRA's keys don't match the model the render fails loudly rather than silently producing a base video. Scoped to bf16 — the quantized Distilled Q4/Q8 variants stay on the dgrauet path for now and show an inline hint pointing at the supported models. (`scripts/generate_av_lora.py`, `server/lib/runners.js`, `server/services/videoGen/local.js`, `server/routes/videoGen.js`, `client/src/lib/runnerFamilies.js`, `client/src/pages/VideoGen.jsx`)-- **"Format" button on each manuscript section cleans up pasted-PDF artifacts.** Text pasted out of a PDF export arrives hard-wrapped at the page margin (every visual line a real `\n`), with stylized drop-caps split onto their own line ("T\nhe dawn …"), words hyphenated across the wrap ("approxi-\nmating"), and closing quotes orphaned from the text they terminate (alone on a line, wrapped to the next line, or with a stray space before them) — so a paragraph reads as a column of ragged lines. A new **Format** button in each section's header (both Live and Review modes) normalizes the section: it rejoins drop-caps, repairs hyphen splits, strips trailing whitespace, and collapses runaway blank lines for every stage, and — for **prose** only — re-attaches orphaned closing quotes and reflows the soft-wrapped lines back into paragraphs (comic/teleplay keep their structural line breaks). The reflow joins a line onto the previous one only when it begins with a lowercase letter — a real sentence/paragraph/heading never starts lowercase, so headings and attributions keep their own line and two paragraphs are never fused (a global line-width threshold is unsound on documents that mix already-joined and still-wrapped paragraphs). The prior text is snapshotted server-side, so History ▸ Revert undoes a format in one click. (`client/src/lib/manuscriptFormat.js`, `client/src/components/pipeline/manuscript/ManuscriptSectionFrame.jsx`, `client/src/pages/PipelineManuscriptEditor.jsx`)+- **"Format" button on each manuscript section cleans up pasted-PDF artifacts.** Text pasted out of a PDF export arrives hard-wrapped at the page margin (every visual line a real `\n`), with stylized drop-caps split onto their own line ("T\nhe dawn …"), words hyphenated across the wrap ("approxi-\nmating"), and closing quotes orphaned from the text they terminate (alone on a line, wrapped to the next line, or with a stray space before them) — so a paragraph reads as a column of ragged lines. A new **Format** button in each section's header (both Live and Review modes) normalizes the section: it rejoins drop-caps, repairs hyphen splits, strips trailing whitespace, and collapses runaway blank lines for every stage, and — for **prose** only — re-attaches orphaned closing quotes, drops a stray opening-quote fragment the export duplicated onto its own line (`"I\n"I need …` → `"I need …`, guarded so genuine back-to-back dialogue is untouched), and reflows the soft-wrapped lines back into paragraphs (comic/teleplay keep their structural line breaks). The reflow joins a line onto the previous one only when it begins with a lowercase letter — a real sentence/paragraph/heading never starts lowercase, so headings and attributions keep their own line and two paragraphs are never fused (a global line-width threshold is unsound on documents that mix already-joined and still-wrapped paragraphs). The prior text is snapshotted server-side, so History ▸ Revert undoes a format in one click. (`client/src/lib/manuscriptFormat.js`, `client/src/components/pipeline/manuscript/ManuscriptSectionFrame.jsx`, `client/src/pages/PipelineManuscriptEditor.jsx`)## Changeddiff --git a/client/src/lib/manuscriptFormat.js b/client/src/lib/manuscriptFormat.jsindex 9be0f992c1..410236ba98 100644--- a/client/src/lib/manuscriptFormat.js+++ b/client/src/lib/manuscriptFormat.js@@ -80,6 +80,30 @@ const reattachQuotes = (text) => text// relationships. " → relationships.".replace(/([.!?])[ \t]+"(?=[ \t]*$)/gm, '$1"');+// Drop a stray opening-quote fragment the source duplicated onto its own line+// just before the real quoted line — a PDF/LLM export artifact:+// "I+// "I need a calibration partner … → "I need a calibration partner …+// Only fires when the fragment is an INCOMPLETE opening (a `"` plus a few+// non-terminal chars, no closing quote) AND the next line begins with that+// exact fragment followed by a word boundary. So genuine back-to-back short+// dialogue ("Yes. / "No.) and a merely-similar next word ("I / "Information)+// are left alone — we only collapse a true leading duplicate.+const dropDuplicatedQuoteFragments = (text) => {+ const lines = text.split('\n');+ const out = [];+ for (let i = 0; i < lines.length; i += 1) {+ const cur = lines[i];+ const next = lines[i + 1];+ const isFragment = /^"[^".!?]{1,20}$/.test(cur);+ const dupOfNext = next !== undefined && next.startsWith(cur)+ && (next.length === cur.length || /\W/.test(next.charAt(cur.length)));+ if (isFragment && dupOfNext) continue; // drop the duplicated fragment line+ out.push(cur);+ }+ return out.join('\n');+};+// Collapse 3+ consecutive newlines to a single blank line, then trim the ends.const tidyBlankLines = (text) => text.replace(/\n{3,}/g, '\n\n').trim();@@ -121,6 +145,7 @@ export function formatManuscript(text, stageId) {out = rejoinDropCaps(out);if (REFLOW_STAGES.has(stageId)) {out = reattachQuotes(out);+ out = dropDuplicatedQuoteFragments(out);out = reflowProse(out);}out = tidyBlankLines(out);diff --git a/client/src/lib/manuscriptFormat.test.js b/client/src/lib/manuscriptFormat.test.jsindex 9fe2ce9c27..8904915114 100644--- a/client/src/lib/manuscriptFormat.test.js+++ b/client/src/lib/manuscriptFormat.test.js@@ -149,6 +149,28 @@ describe('formatManuscript — orphaned closing quotes (prose)', () => {].join('\n'));});+ it('drops a stray opening-quote fragment the source duplicated before the real line', () => {+ // Real PDF/LLM export artifact: the opening `"I` was copied onto its own+ // line right before the actual `"I need …` paragraph.+ const input = [+ 'what they said.',+ '"I',+ '"I need a calibration partner who knows',+ "what they're doing.",+ ].join('\n');+ expect(formatManuscript(input, 'prose')).toBe(+ 'what they said.\n"I need a calibration partner who knows what they\'re doing.',+ );+ });++ it('does NOT drop genuine back-to-back short dialogue', () => {+ expect(formatManuscript('"Yes.\n"No.', 'prose')).toBe('"Yes.\n"No.');+ });++ it('does NOT drop a line that merely shares a prefix with a different next word', () => {+ expect(formatManuscript('"I\n"Information is power.', 'prose')).toBe('"I\n"Information is power.');+ });+it('leaves script quotes alone — no reflow or quote surgery off the prose path', () => {const input = 'CAPTION: "Good morning,\n" she says.';expect(formatManuscript(input, 'comicScript')).toBe(input);