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

fix: restart current sentence on re-click + detect indented blank-line breaks (#1304)

[._.]/ Adam Eivydd231c9f34ee
diff --git a/client/src/components/pipeline/manuscript/ManuscriptReadAloud.jsx b/client/src/components/pipeline/manuscript/ManuscriptReadAloud.jsx
index 57a55900b9..41c7dcdefc 100644
--- a/client/src/components/pipeline/manuscript/ManuscriptReadAloud.jsx
+++ b/client/src/components/pipeline/manuscript/ManuscriptReadAloud.jsx
@@ -116,6 +116,16 @@ export default function ManuscriptReadAloud({ open, onClose, section }) {
};
const jumpTo = (idx) => {
+ // Re-clicking the already-current sentence keeps both state values
+ // unchanged, so the play effect won't re-fire and the <audio> src won't
+ // reload — restart it imperatively so "play that line again" works.
+ const audio = audioRef.current;
+ if (idx === currentIndex && audio) {
+ audio.currentTime = 0;
+ audio.play().catch(() => {});
+ setIsPlaying(true);
+ return;
+ }
setCurrentIndex(idx);
setIsPlaying(true);
};
diff --git a/server/services/pipeline/manuscriptNarration.js b/server/services/pipeline/manuscriptNarration.js
index 52ef3763cf..dba0ac7fd4 100644
--- a/server/services/pipeline/manuscriptNarration.js
+++ b/server/services/pipeline/manuscriptNarration.js
@@ -98,8 +98,10 @@ export function splitProseIntoSentences(text) {
continue;
}
// A blank line (paragraph break) also ends the current sentence so prose
- // without terminal punctuation (poetry, fragments) still segments.
- if (ch === '\n' && /\n[ \t]*\n/.test(text.slice(i, i + 3))) {
+ // without terminal punctuation (poetry, fragments) still segments. The
+ // window is bounded (a blank "line" is a newline + horizontal whitespace +
+ // newline) but generous enough to span indented blank lines.
+ if (ch === '\n' && /^\n[ \t]*\n/.test(text.slice(i, i + 64))) {
push(i);
}
i += 1;
diff --git a/server/services/pipeline/manuscriptNarration.test.js b/server/services/pipeline/manuscriptNarration.test.js
index 4beb02ea4b..075d79fd1d 100644
--- a/server/services/pipeline/manuscriptNarration.test.js
+++ b/server/services/pipeline/manuscriptNarration.test.js
@@ -55,6 +55,11 @@ describe('splitProseIntoSentences', () => {
expect(segs.map((s) => s.text)).toEqual(['A fragment', 'Another fragment']);
});
+ it('treats an indented blank line (whitespace between newlines) as a boundary', () => {
+ const segs = splitProseIntoSentences('A fragment\n \nAnother fragment');
+ expect(segs.map((s) => s.text)).toEqual(['A fragment', 'Another fragment']);
+ });
+
it('treats a lowercase continuation after a terminator as the same sentence', () => {
// Ellipsis/interrobang followed by a lowercase word reads as one breath
// aloud; the capitalized "No." starts a new sentence.