feat(web): optional loop-phrase prompt prefix (loop-focused workflow)#264
Draft
leszko wants to merge 1 commit into
Draft
feat(web): optional loop-phrase prompt prefix (loop-focused workflow)#264leszko wants to merge 1 commit into
leszko wants to merge 1 commit into
Conversation
Acts on the loop-prompting experiment finding: prepending "a short perfect loop of <prompt>" lowers the loop-seam discontinuity ~12-14% on average (techno -22%, deep house -18%; neutral on smooth pads) with no measured downside. Mirrors the auto_prepend_lora_triggers pattern exactly: a client-side, WYSIWYG-respecting wire transform. The Tags A/B textareas stay the operator's clean text; the phrase is injected onto the wire at send-time in wirePromptTransform and stripped on the next send, so there is no double-prepend. Rides the existing `prompt` WS command (tags/tags_b) -- no server, protocol, or wire-type change. - engine.auto_prepend_loop_phrase (default false, opt-in pending ear confirmation) + engine.loop_phrase (default "a short perfect loop of"). Toggle live via web/public/config.json + refresh, same as the LoRA flag. - lib/loopPhrase.ts: loopPhrasePrefix() + stripLeadingLoopPhrase(). - wirePromptTransform composes <lora triggers><loop phrase><clean tags>. - 14 unit tests: gating, custom phrase, idempotency, trigger composition. typecheck + next build clean; vitest green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Acts on the loop-prompting experiment finding: prepending
a short perfect loop of <prompt>lowers the loop-seam discontinuity ~12–14% on average (techno −22%, deep house −18%; neutral on smooth pads) with no measured downside.This adds an opt-in, client-side, WYSIWYG-respecting loop-phrase prefix that mirrors the existing
auto_prepend_lora_triggerspattern exactly.How (and why it's low-risk)
promptWS command (tags/tags_b). The phrase is injected onto the wire at send-time inwirePromptTransformand stripped from the incoming text first, so there's no double-prepend and toggling it takes effect on the next send.<lora triggers><loop phrase><clean tags>— triggers stay at the head as activation tokens, the phrase wraps the prompt.Surface
lib/config.ts:engine.auto_prepend_loop_phrase(defaultfalse— opt-in, pending ear confirmation) andengine.loop_phrase(default"a short perfect loop of", the study's best performer; edged"seamless repeating loop of").lib/loopPhrase.ts:loopPhrasePrefix()+stripLeadingLoopPhrase().lib/loraTriggers.ts:wirePromptTransformcomposes the two prefixes.tests/unit/loopPhrase.test.ts: 14 tests — gating, custom phrase, idempotency, blank-phrase guard, trigger composition.How to test
Edit
demos/realtime_motion_graph_web/web/public/config.jsonand set:{ "engine": { "auto_prepend_loop_phrase": true } }then refresh (same live-config workflow as the LoRA flag — no rebuild). A/B against
false. Try"loop_phrase": "seamless repeating loop of"too. The win is biggest on rhythmic material where the loop wrap is audible.Checks
npm run typecheckclean ·npm run buildclean ·vitest run tests/unit/loopPhrase.test.ts→ 14 passed.Caveats
The effect is distributional (per-seed variance is large) and was measured with objective proxies — it's defaulted off until confirmed by ear in the live app, which is exactly what this PR enables. The companion latent-size finding (20–30 s window) is not in this PR — it needs a sub-60 s TRT engine profile build, tracked separately.
🤖 Generated with Claude Code