feat(studio): auto-advance from content phase to style phase#52
Conversation
After the content-collection turn, if the agent reply does not contain <!-- hv-phase:content-question --> (the structured marker the content prompt requires when still collecting), immediately spawn a second agent in the same SSE stream to present the style options card — eliminating the extra user round-trip between content and style phases.
lefarcen
left a comment
There was a problem hiding this comment.
Hey @walliai-chenlb! Impressive turnaround — you filed the bug, identified the root cause at the right file:line, and opened a PR within the 1–3 day window. The server-side auto-advance approach is exactly the right direction.
One thing needs fixing before this can land: the auto-advance check will never fire for a well-behaved agent in the current state. Details inline. There's also a smaller DRY issue worth cleaning up at the same time.
DRY note (line 1170): the stylePrompt block duplicates the style phase builder verbatim from buildHtmlGenerationPrompt's phase === 'style' branch (~line 2579) — same question text, same five options, same trailing instructions. If someone adds a sixth style option or changes a hint there, this copy will silently drift. Once the P1 fix is in, it's worth extracting buildHtmlGenerationPrompt's style section into a small shared helper (e.g. buildStylePhasePrompt(pickedType)) that both places call.
…ompt helper The content prompt told the agent to always append <!-- hv-phase:content-question --> even when it had enough info and was writing a "Got it, next: style" confirmation. Because the marker was always present, the server-side !regex.test() check never triggered and auto-advance was a no-op. Fix: rewrite the "already have enough" branch to explicitly instruct the agent NOT to append the marker when it's done — the server advances automatically on its absence. Also extract the duplicated style-phase prompt block (present verbatim in both the auto-advance path and buildHtmlGenerationPrompt's style branch) into a shared buildStylePhasePrompt(pickedType) helper so future edits only need to happen once.
lefarcen
left a comment
There was a problem hiding this comment.
Both issues fixed — nice work on the turnaround.
P1 looks exactly right. The old prompt said "end with the marker" in both branches, so the server's !regex.test() never fired. The new wording explicitly splits the two paths — marker when you still need info, no marker (and a note saying so) when you're done — which is exactly what the server logic needs. The trailing-instruction cleanup (Reply in plain text. → dropped the old + the marker suffix) closes the last escape hatch.
DRY: buildStylePhasePrompt(pickedType) is clean. The array-push style matches the surrounding code, both call sites are updated, and the style branch in buildHtmlGenerationPrompt now delegates to it correctly.
No further concerns from my side. @PerishCode — picking up the code review baton from here. ✨
After the content-collection turn, if the agent reply does not contain (the structured marker the content prompt requires when still collecting), immediately spawn a second agent in the same SSE stream to present the style options card — eliminating the extra user round-trip between content and style phases.
Resolves #43