feat(canvas): attach uploaded image names to model prompts
Add modelImageReferences to preprocess agent contents, uploading local image references and surfacing their names in the prompt so the model can cite them. Wire the preparer into the canvas agent submission path, pass imageName through the floating composer references, and relax the prompt directive parser to accept names containing arbitrary characters. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,7 @@ import { SharePopover } from "@/ui/components/SharePopover";
|
||||
import { autoImageAdjustments, defaultImageAdjustments, parseImageAdjustments, serializeImageAdjustments } from "@/ui/lib/imageAdjustments";
|
||||
import { friendlyProjectFailureMessage } from "@/ui/lib/friendlyAgentErrors";
|
||||
import { canvasImageUrl } from "@/ui/lib/imageDelivery";
|
||||
import { createModelAgentContentPreparer } from "@/ui/lib/modelImageReferences";
|
||||
import { visiblePromptText } from "@/ui/lib/promptImageReferences";
|
||||
import { isImageGeneratorThreadMessage, visibleAgentMessages } from "./canvas/agentMessageFilters";
|
||||
import { CanvasColorPopover } from "./canvas/CanvasColorPopover";
|
||||
@@ -90,6 +91,7 @@ const defaultCanvasBackgroundColor = "#F7F7F4";
|
||||
const canvasBackgroundSwatches = ["#F5F5F5", "#000000", "#FFFFFF", "#00F016", "#A855F7", "#E9D5FF"];
|
||||
const canvasSidePanelWidth = 268;
|
||||
const newAgentConversationId = "__new_agent_conversation__";
|
||||
const prepareModelAgentContents = createModelAgentContentPreparer({ uploadImage: designGateway.uploadImage });
|
||||
const canvasWheelGuardSelector = [
|
||||
".ui-popover-content",
|
||||
".ui-dropdown-menu-content",
|
||||
@@ -2769,10 +2771,11 @@ export function CanvasWorkspace({ projectId, shareAccess = ownerWorkspaceAccess
|
||||
if (dirty) {
|
||||
await saveCanvasSnapshot({ quiet: true });
|
||||
}
|
||||
const modelContents = await prepareModelAgentContents(contents);
|
||||
startAgentSocket(
|
||||
project.id,
|
||||
{
|
||||
messages: [{ role: "user", contents }],
|
||||
messages: [{ role: "user", contents: modelContents }],
|
||||
mode: source === "image-generator" ? "image-generator" : activeMode === "image" ? "image" : "design",
|
||||
threadId,
|
||||
threadIdType: 9,
|
||||
|
||||
Reference in New Issue
Block a user