feat(chat): Prompt Explorer modal for iterative prompt enrichment#4198
Open
vibegui wants to merge 2 commits into
Open
feat(chat): Prompt Explorer modal for iterative prompt enrichment#4198vibegui wants to merge 2 commits into
vibegui wants to merge 2 commits into
Conversation
Adds an "Explore" entry point in the chat composer that opens a modal for turning a rough idea into a richer, more complete prompt. A fast model rewrites the draft in the user's own voice and language, inserting [bracketed] fill-in placeholders for missing details, and grows the prompt gradually (~2-3x per iteration) instead of ballooning it. - New SSE route POST /api/:org/prompt-explorer/stream (streamText, fast tier) - Pure, unit-tested system-prompt builder (voice/person/language preserving, length-budgeted) - usePromptEnricher hook with an idle-completion guard so a withheld finish frame / connection close can't hang the UI - Versions sidebar with Iterate/rollback; Enter -> Iterate, Cmd/Ctrl+Enter -> Send Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Drive enricher status from useState instead of react-query. The React Compiler memoized the derived flag against react-query's referentially- stable mutation result, so `isPending` never updated and the modal hung on "Enriching…" forever even after the stream completed. Removes the useMutation wrapper and the idle-timer workaround; the stream terminates reliably on the `finish` frame or connection close. - System prompt: never emit bracket placeholders; each iteration expands the draft into a concrete, ready-to-use prompt (fixes "version 2 identical to version 1"). - Rename the feature UI from Explore/Iterate to "Improve" with the loop icon (composer button, modal title, primary action, and copy). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ca71aeb to
8d4ab28
Compare
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.
Summary
Adds an Explore button to the chat composer that opens a modal for turning a rough idea into a richer, more complete prompt. A fast-tier model rewrites the draft in the user's own voice and language, inserts
[bracketed]fill-in placeholders for missing details, and grows the prompt gradually (~2-3×/iteration) rather than ballooning it.POST /api/:org/prompt-explorer/stream(apps/mesh/src/api/routes/prompt-explorer.ts) — calls theaiSDKstreamTextagainst the org'sfasttier (mirrorssuggest-commit-message.ts); no thread/NATS machinery. Registered inorg-scoped.ts.apps/mesh/src/lib/prompt-explorer-system.ts) that preserves voice/grammatical-person/language and enforces a length budget.usePromptEnricherhook (use-prompt-enricher.ts) +PromptExplorerDialog(prompt-explorer-dialog.tsx); versions sidebar with Iterate + rollback; Enter → Iterate, Cmd/Ctrl+Enter → Send, Shift+Enter → newline. Wired intochat/input.tsx.How to test
[blanks].Notes / context for reviewers
finishframe + connection-close were intermittently withheld by the dev tunnel (*.localhost), which made the spinner appear to hang forever even though the server completes in ~1.4–2.7s. Verified server-side (direct + Vite +:80) that the stream deliversfinishand closes cleanly, and that output is first-person + capped. The idle-completion guard inusePromptEnricher(resolve after ~2s of token silence) makes the UI robust to that regardless of transport. Curious whether others see the spinner resolve cleanly without the tunnel quirk.bun run fmt,bun run lint(no new warnings),bun run check, and theprompt-explorer-systemunit tests all pass.🤖 Generated with Claude Code
Summary by cubic
Adds an Improve prompt modal in chat that turns rough ideas into a concrete, ready-to-use prompt in the user’s own voice and language, expanding gradually each iteration. Results stream from the org’s fast tier and can be improved again or sent to the composer.
POST /api/:org/prompt-explorer/streamstreams enriched text and reasoning from the org’sfasttier.usePromptEnricherhook streams text/reasoning with cancel support; status is driven byuseStatefor reliable completion onfinishor connection close.Written for commit 8d4ab28. Summary will update on new commits.