feat: design merch from the agent tab - #91
Closed
jsnapoli1 wants to merge 0 commit into
Closed
Conversation
AJFrio
added a commit
that referenced
this pull request
Sep 11, 2026
AJFrio
force-pushed
the
feat/agent-merch-designer
branch
from
September 11, 2026 00:25
363713f to
6b80873
Compare
AJFrio
force-pushed
the
feat/agent-merch-designer
branch
from
September 11, 2026 00:25
6b80873 to
7956c15
Compare
Owner
|
Merged into Note on status: the branch was rebased before merging (to pick up the OpenRouter-only refactor), so GitHub's auto-merge detection lost track of the original head and this PR shows as closed rather than merged. All of its content — the merch designer, |
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 it does
Selling a new item currently means generating an image elsewhere, uploading it, then describing the product again to create the listing. This makes it one conversation:
The agent generates the mockup, stores it, and creates the product with the image attached.
Four fields, not one prompt
The agent tab gains model / pose / product / logo, each able to carry a reference image.
A single free-text prompt tends to lose whichever element the model decides to skip, and passing several unlabelled images leaves it guessing which is the garment and which is the artwork. So:
Image 2 is the artwork or logo to place on the item). A model told the second image is the logo will use the wrong picture if the order drifts.Endpoint and tool
POST /api/admin/ai/generate-merch-imagegenerates, stores to R2, adds to the media library, returns a URL.Deliberately separate from
/generate-image, which returns base64 for the media picker to preview. The agent needs a persisted URL; round-tripping base64 through the model's context would be slow and expensive.The agent gets
generate_product_imageand is instructed to call it beforecreate_product, passing the URL through. Reference images never enter the chat history — they're attached to the request and read by the tool when it runs, which keeps the context window intact.A storage failure says so explicitly:
...rather than a generic 500, because retrying would repeat the expensive half for the same reason.
Also fixes the agent's "not configured" error, which still told users to run
wrangler secret puteven though Developer Settings (#87) exists.Verification
Adds
tests/integration/merch-designer.test.js(9 cases): each field appears as its own clause, blank pose inherits from the reference, no pose language without a model, blank fields omitted entirely, reference ordering matches the caption legend, the cap holds, malformed references are dropped, and storage failure is distinguished from generation failure.npm run lint— 0 errors. Build clean; verified both halves reach their bundles (UI strings in the client, tool + prompt in the worker).Not verified end-to-end. I have no image-generation API key, so no real image was produced. Prompt composition, reference ordering, tool wiring and error paths are covered by tests against mocked providers, but the actual generate → store → attach round trip needs a smoke test with real credentials.
Requires an R2 bucket. Storage uses the existing
IMAGESbinding; a worker without it gets the explicit 503 above rather than a crash.https://claude.ai/code/session_015XLFFfHWNeazSuz6UcsQ4C