diff --git a/crates/ide-agent/src/lib.rs b/crates/ide-agent/src/lib.rs index 84f9c48e..0b9c3208 100644 --- a/crates/ide-agent/src/lib.rs +++ b/crates/ide-agent/src/lib.rs @@ -1060,6 +1060,7 @@ impl Task { self.push_entry(AgentEntry::User { text: prompt.text, attachments, + images: prompt.images, sent_ms: Some(now_ms()), done_ms: None, steered: true, @@ -1080,6 +1081,7 @@ impl Task { self.push_entry(AgentEntry::User { text: prompt.text.clone(), attachments, + images: prompt.images.clone(), sent_ms: Some(now_ms()), done_ms: None, steered: false, diff --git a/crates/ide-agent/src/model.rs b/crates/ide-agent/src/model.rs index c777ef2e..d0984aab 100644 --- a/crates/ide-agent/src/model.rs +++ b/crates/ide-agent/src/model.rs @@ -240,6 +240,9 @@ pub enum AgentEntry { text: String, /// Names of the files and images sent with it. attachments: Vec, + /// The images sent with it, shown in the conversation. + #[serde(default)] + images: Vec, /// When it was sent (ms since the epoch); `None` in tasks saved before this was kept. #[serde(default)] sent_ms: Option, diff --git a/crates/ide-agent/src/timeline.rs b/crates/ide-agent/src/timeline.rs index f707aa64..e2efaea0 100644 --- a/crates/ide-agent/src/timeline.rs +++ b/crates/ide-agent/src/timeline.rs @@ -446,6 +446,7 @@ mod tests { let user = |sent: f64| AgentEntry::User { text: "q".into(), attachments: vec![], + images: vec![], sent_ms: Some(sent), done_ms: None, steered: false, diff --git a/src/bindings.ts b/src/bindings.ts index 32d839fe..77c4f29e 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -1124,6 +1124,8 @@ export type AgentConfigVia = export type AgentEntry = { type: "user"; text: string; /** Names of the files and images sent with it. */ attachments: string[]; +/** The images sent with it, shown in the conversation. */ +images?: AgentImage[]; /** When it was sent (ms since the epoch); `None` in tasks saved before this was kept. */ sentMs?: number | null; /** When the turn it started ended; `None` while it runs or when it was cut off. */ diff --git a/src/features/agents/Composer.module.css b/src/features/agents/Composer.module.css index d051b3d8..f803502f 100644 --- a/src/features/agents/Composer.module.css +++ b/src/features/agents/Composer.module.css @@ -72,6 +72,15 @@ box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; } +.previewImage { + display: block; + width: 100%; + height: 100%; + padding: 0; + border: 0; + background: none; + cursor: zoom-in; +} .image img { width: 100%; height: 100%; diff --git a/src/features/agents/Composer.tsx b/src/features/agents/Composer.tsx index 22a045aa..4334e7fb 100644 --- a/src/features/agents/Composer.tsx +++ b/src/features/agents/Composer.tsx @@ -29,6 +29,7 @@ import { type FileRef, } from "./composerModel"; import { composerDraft, updateComposer, useAgents } from "./store"; +import { ImagePreview, imageSrc } from "./ImagePreview"; import { useCompletionAnchor } from "./useCompletionAnchor"; import styles from "./Composer.module.css"; import { isImeKey } from "@/platform/ime"; @@ -69,6 +70,7 @@ export function Composer(props: ComposerProps) { const draft = useAgents((s) => s.composers.get(id)); const text = draft?.text ?? ""; const images = draft?.images ?? []; + const [preview, setPreview] = useState(null); const ref = useRef(null); const boxRef = useRef(null); const imageInput = useRef(null); @@ -361,7 +363,9 @@ export function Composer(props: ComposerProps) {
e.stopPropagation()}> {images.map((img, i) => ( - {img.name +
)}