Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

Preserve full image prompts and add expandable activity display

Flightdeck Agentc58174b4e911
diff --git a/backend/agent/tools/runtime.py b/backend/agent/tools/runtime.py
index ab8f493b..ab70ea15 100644
--- a/backend/agent/tools/runtime.py
+++ b/backend/agent/tools/runtime.py
@@ -453,7 +453,7 @@ class AgentToolRuntime:
},
summary={
"image": {
- "prompt": summarize_text(prompt, 240),
+ "prompt": prompt,
"image_urls": [summarize_text(url, 100) for url in unique_urls],
"result_url": None,
"status": "error",
@@ -472,7 +472,7 @@ class AgentToolRuntime:
}
summary = {
"image": {
- "prompt": summarize_text(prompt, 240),
+ "prompt": prompt,
"image_urls": [summarize_text(url, 100) for url in unique_urls],
"result_url": result_url,
"status": "ok",
diff --git a/backend/tests/test_tool_image_outputs.py b/backend/tests/test_tool_image_outputs.py
index 55c86f1b..33a0c249 100644
--- a/backend/tests/test_tool_image_outputs.py
+++ b/backend/tests/test_tool_image_outputs.py
@@ -293,15 +293,51 @@ async def test_edit_image_emits_url_part(monkeypatch: pytest.MonkeyPatch) -> Non
openai_api_key=None,
openai_base_url=None,
)
+ prompt = " ".join(["Preserve every detail in the source image."] * 10)
+ assert len(prompt) > 240
+
result = await runtime.execute(
ToolCall(
id="t",
name="edit_image",
- arguments={"prompt": "bw", "image_urls": ["https://x/in.png"]},
+ arguments={"prompt": prompt, "image_urls": ["https://x/in.png"]},
)
)
+
assert result.multimodal_parts is not None
assert result.multimodal_parts[0].image_url == "https://replicate.delivery/edited.png"
+ assert result.summary["image"]["prompt"] == prompt
+
+
+async def test_edit_image_error_summary_preserves_full_prompt(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ monkeypatch.setattr("agent.tools.runtime.REPLICATE_API_KEY", "fake-key")
+
+ async def fake_edit_image(**kwargs: Any) -> str:
+ raise RuntimeError("image edit failed")
+
+ monkeypatch.setattr("agent.tools.runtime.edit_image", fake_edit_image)
+ runtime = AgentToolRuntime(
+ file_state=AgentFileState(),
+ should_generate_images=True,
+ openai_api_key=None,
+ openai_base_url=None,
+ )
+ prompt = " ".join(["Keep the image-editing instruction intact."] * 10)
+ assert len(prompt) > 240
+
+ result = await runtime.execute(
+ ToolCall(
+ id="t",
+ name="edit_image",
+ arguments={"prompt": prompt, "image_urls": ["https://x/in.png"]},
+ )
+ )
+
+ assert result.ok is True
+ assert result.summary["image"]["prompt"] == prompt
@pytest.mark.asyncio
diff --git a/frontend/src/components/agent/AgentActivity.tsx b/frontend/src/components/agent/AgentActivity.tsx
index 5d2f7b64..cfc63c9e 100644
--- a/frontend/src/components/agent/AgentActivity.tsx
+++ b/frontend/src/components/agent/AgentActivity.tsx
@@ -30,6 +30,57 @@ import { groupCompletedAgentEvents } from "./activity-order";
SyntaxHighlighterBase.registerLanguage("html", html);
const SyntaxHighlighter = SyntaxHighlighterBase as any;
+function ExpandablePrompt({ prompt }: { prompt: string }) {
+ const [isExpanded, setIsExpanded] = useState(false);
+ const [isClamped, setIsClamped] = useState(false);
+ const promptRef = useRef<HTMLParagraphElement>(null);
+
+ useEffect(() => {
+ setIsExpanded(false);
+ }, [prompt]);
+
+ useEffect(() => {
+ const element = promptRef.current;
+ if (!element) return;
+
+ const updateClampedState = () => {
+ setIsClamped(element.scrollHeight > element.clientHeight + 1);
+ };
+
+ updateClampedState();
+ if (typeof ResizeObserver === "undefined") return;
+
+ const resizeObserver = new ResizeObserver(updateClampedState);
+ resizeObserver.observe(element);
+ return () => resizeObserver.disconnect();
+ }, [prompt, isExpanded]);
+
+ return (
+ <div>
+ <p
+ ref={promptRef}
+ className={`whitespace-pre-wrap break-words text-xs text-gray-600 dark:text-gray-300 ${
+ !isExpanded ? "line-clamp-4" : ""
+ }`}
+ >
+ {prompt}
+ </p>
+ {(isClamped || isExpanded) && (
+ <div className="mt-1 flex justify-end">
+ <button
+ type="button"
+ onClick={() => setIsExpanded((previous) => !previous)}
+ aria-expanded={isExpanded}
+ className="rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600 transition-colors hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"
+ >
+ {isExpanded ? "Less" : "More"}
+ </button>
+ </div>
+ )}
+ </div>
+ );
+}
+
function CodePreviewBlock({ code, isGenerating }: { code: string; isGenerating: boolean }) {
const containerRef = useRef<HTMLDivElement>(null);
@@ -273,6 +324,12 @@ function renderToolDetails(event: AgentEvent, variantCode?: string) {
const output = event.output as any;
const input = event.input as any;
+ const editImagePrompt =
+ typeof input?.prompt === "string"
+ ? input.prompt
+ : typeof output?.image?.prompt === "string"
+ ? output.image.prompt
+ : null;
const hasError = Boolean(output?.error);
const images =
output && Array.isArray(output.images) ? (output.images as Array<any>) : null;
@@ -456,11 +513,7 @@ function renderToolDetails(event: AgentEvent, variantCode?: string) {
<div>
{event.status === "running" && input?.image_urls && Array.isArray(input.image_urls) && (
<div className="space-y-3">
- {input.prompt && (
- <div className="text-xs text-gray-600 dark:text-gray-300">
- {input.prompt}
- </div>
- )}
+ {editImagePrompt && <ExpandablePrompt prompt={editImagePrompt} />}
<div className="divide-y divide-gray-100 dark:divide-gray-800">
{input.image_urls.map((url: string, index: number) => (
<div key={`${url}-${index}`} className="py-2">
@@ -480,9 +533,7 @@ function renderToolDetails(event: AgentEvent, variantCode?: string) {
)}
{event.status !== "running" && output?.image && (
<div className="space-y-3">
- <div className="text-xs text-gray-600 dark:text-gray-300">
- {output.image.prompt}
- </div>
+ {editImagePrompt && <ExpandablePrompt prompt={editImagePrompt} />}
<div className="grid gap-3 sm:grid-cols-2">
<div>
<div className="text-xs text-gray-500 dark:text-gray-400 mb-1">