Server-side /generate routing + UI autocomplete + MCP tool#44
Merged
jonnyparris merged 1 commit intomainfrom Apr 23, 2026
Merged
Server-side /generate routing + UI autocomplete + MCP tool#44jonnyparris merged 1 commit intomainfrom
jonnyparris merged 1 commit intomainfrom
Conversation
Follow-up to #42. Three things: 1. Slash command autocomplete in the chat input. Type '/' to see a menu of available commands (currently just /generate). Arrow keys + Enter/Tab complete, Escape dismisses. Menu positioned above the input, styled to match the rest of the app. 2. Server-side /generate routing. handleMessage and handlePrompt now detect /generate in the content and delegate to the image-generation core (runImageGeneration). This means /generate works from: - Browser UI (client intercept + this server fallback) - MCP send_message / send_prompt tools - Any future HTTP clients Previously the slash command only worked in the browser because the client JS was the only layer that knew about it. 3. New MCP tool: generate_image. Calls /generate directly with a prompt string. Lets LLM agents (incl. myself) invoke FLUX from conversations. Refactor: - Extract runImageGeneration() core from handleGenerate — shared entry point for the dedicated endpoint and slash-routed messages. - GENERATE_SLASH_REGEX + extractGeneratePrompt() in shared-index so the browser and server agree on what counts as a /generate request. Tests: - 6 new unit tests for extractGeneratePrompt (happy path, null on non-/ messages, whitespace handling, multi-line, case-insensitive) - Updated existing slash-regex tests to use the canonical shared export - All 401 tests pass
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
dodo | e1386a2 | Apr 23 2026, 09:40 PM |
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
Follow-up to #42. Makes /generate actually work from every entry point, adds slash-command autocomplete to the UI, and exposes a
generate_imageMCP tool.Why
After #42 shipped, I tried
/generate a cyberpunk catvia the Dodo MCPsend_messagetool and got GPT-5.4 offering to write a prompt for me. Turned out the slash command only worked in the browser — the server was happily passing/generate ...through to the LLM. So I fixed that.What changed
Server-side slash routing
handleMessageandhandlePromptnow detect/generatecontent and delegate torunImageGenerationbefore touching the LLM.send_message,send_prompt), and any future HTTP clients./generateendpoint — same 409 on concurrent prompts, same 400 on prompt >2048 chars, samemessage_attachmentsSSE event.UI autocomplete
/in the chat input pops a suggestions menu above the textarea.SLASH_COMMANDSarray — adding a new command = one edit.New MCP tool
generate_image(sessionId, prompt)calls/generatedirectly. Lets LLM agents invoke FLUX from conversations without going through the chat model.Refactor
runImageGeneration(...)core fromhandleGenerateso the endpoint handler and the slash-routed handlers share a single image-generation code path.extractGeneratePrompt()helper +GENERATE_SLASH_REGEXconstant inshared-index.ts. Browser and server now reference the same regex.Tests
extractGeneratePrompt(happy path, null on non-slash messages, whitespace handling, multi-line prompts, case-insensitive keyword)Test plan
npx tsc --noEmitpassesnpx vitest run— all 401 tests pass/in the chat UI, verify autocomplete menu appearsgenerate_imageMCP tool and verify FLUX respondsNotes
/generateintercept indodo-chat.jsis kept on purpose — it routes straight to the synchronous/generateendpoint for snappier UX than going through/prompt(which would queue)./generateprompt are ignored. FLUX-1-schnell is text-to-image only; multi-reference inputs are a FLUX.2 feature.beep-boop-🤖