diff --git a/packages/app/src/composer/editor/editor.tsx b/packages/app/src/composer/editor/editor.tsx index 6cbfda96575..9cef41e73f7 100644 --- a/packages/app/src/composer/editor/editor.tsx +++ b/packages/app/src/composer/editor/editor.tsx @@ -862,7 +862,7 @@ function ComposerAttachments(props: { const missing = () => url.state === "errored" || (url.state === "ready" && !url()) return ( -
+
} > - }> + }> {(value) => ( {attachment.filename} props.onAttachmentClick?.(attachment, event.currentTarget)} /> )} diff --git a/packages/session-ui/component-tests/session-message-projection.spec.ts b/packages/session-ui/component-tests/session-message-projection.spec.ts index e273f2da61a..9e2294d7bd7 100644 --- a/packages/session-ui/component-tests/session-message-projection.spec.ts +++ b/packages/session-ui/component-tests/session-message-projection.spec.ts @@ -547,8 +547,12 @@ story("a stored image that fails to load shows a failed tile that retries", asyn await expect(failed.getByRole("img", { name: "Unable to load image." })).toBeVisible() await expect(failed).not.toHaveAttribute("data-placeholder") + const tileSize = { width: 132, height: 88 } + expect(await failed.boundingBox()).toMatchObject(tileSize) + await failed.click() await expect(timeline.getByAltText("flaky.svg")).toBeVisible() + expect(await failed.boundingBox()).toMatchObject(tileSize) }) story("shows note selectors and keeps annotation subtitles with or without comments", async ({ mount, page }) => { diff --git a/packages/session-ui/src/components/message-file.test.ts b/packages/session-ui/src/components/message-file.test.ts index 2f5d6d7c2d4..ba654d3ce15 100644 --- a/packages/session-ui/src/components/message-file.test.ts +++ b/packages/session-ui/src/components/message-file.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test" import type { PromptFileAttachment } from "@opencode/client/promise" -import { attached, imageAttachmentPlaceholderStyle, MIN_IMAGE_PLACEHOLDER_PX, typeLabel } from "./message-file" +import { attached, typeLabel } from "./message-file" function file(source: PromptFileAttachment["source"], mention = false): PromptFileAttachment { const item: PromptFileAttachment = { @@ -32,19 +32,4 @@ describe("message-file", () => { expect(typeLabel(".gitignore", "text/plain", "File")).toBe("File") expect(typeLabel("/repo/.env", "text/plain", "File")).toBe("File") }) - - test("keeps a sane minimum placeholder size on 401/error when width and height are missing", () => { - expect(imageAttachmentPlaceholderStyle({ loaded: false })).toEqual({ - "min-width": `${MIN_IMAGE_PLACEHOLDER_PX}px`, - "min-height": `${MIN_IMAGE_PLACEHOLDER_PX}px`, - }) - expect(imageAttachmentPlaceholderStyle({ width: 800, height: 600, loaded: false })).toEqual({ - "aspect-ratio": "800 / 600", - "min-width": `${MIN_IMAGE_PLACEHOLDER_PX}px`, - "min-height": `${MIN_IMAGE_PLACEHOLDER_PX}px`, - }) - expect(imageAttachmentPlaceholderStyle({ width: 800, height: 600, loaded: true })).toEqual({ - "aspect-ratio": "800 / 600", - }) - }) }) diff --git a/packages/session-ui/src/components/message-file.ts b/packages/session-ui/src/components/message-file.ts index 3fa7177e5fd..22924d9e489 100644 --- a/packages/session-ui/src/components/message-file.ts +++ b/packages/session-ui/src/components/message-file.ts @@ -1,31 +1,6 @@ import { getFilename } from "@opencode/util/path" import type { PromptAttachment } from "@opencode/client/promise" -export const MIN_IMAGE_PLACEHOLDER_PX = 96 - -export function imageAttachmentPlaceholderStyle(input: { - readonly width?: number - readonly height?: number - readonly loaded: boolean -}) { - if (input.width && input.height && input.loaded) return { "aspect-ratio": `${input.width} / ${input.height}` } - - if (input.width && input.height) { - return { - "aspect-ratio": `${input.width} / ${input.height}`, - "min-width": `${Math.min(input.width, MIN_IMAGE_PLACEHOLDER_PX)}px`, - "min-height": `${Math.min(input.height, MIN_IMAGE_PLACEHOLDER_PX)}px`, - } - } - - return input.loaded - ? undefined - : { - "min-width": `${MIN_IMAGE_PLACEHOLDER_PX}px`, - "min-height": `${MIN_IMAGE_PLACEHOLDER_PX}px`, - } -} - export function attached(file: PromptAttachment) { if (file.mention) return false diff --git a/packages/session-ui/src/components/message-part.css b/packages/session-ui/src/components/message-part.css index 90cf40df5e4..6ed1a521a83 100644 --- a/packages/session-ui/src/components/message-part.css +++ b/packages/session-ui/src/components/message-part.css @@ -58,8 +58,8 @@ &[data-type="image"] { position: relative; - width: 58px; - height: 46px; + height: 88px; + aspect-ratio: 3 / 2; border: none; /* inset box-shadows do not paint over content, so the hairline is an overlay */ diff --git a/packages/session-ui/src/message/message-content.tsx b/packages/session-ui/src/message/message-content.tsx index 1d8e3831ea9..0db7c12e580 100644 --- a/packages/session-ui/src/message/message-content.tsx +++ b/packages/session-ui/src/message/message-content.tsx @@ -60,7 +60,7 @@ import type { import type { SessionUserActions, SessionUserAttachmentReference, SessionUserComment } from "../actions" import { agentLabel } from "./agent-label" import { isInterruptedError } from "../timeline/turn-phase-machine" -import { attached, imageAttachmentPlaceholderStyle, typeLabel } from "../components/message-file" +import { attached, typeLabel } from "../components/message-file" import { DISPOSED_ATTACHMENT_MEDIA_EVENT, INITIAL_ATTACHMENT_MEDIA_STATE, @@ -578,13 +578,6 @@ export function CurrentUserMessageDisplay(props: { return "height" in current ? current.height : undefined } - const placeholderStyle = () => - imageAttachmentPlaceholderStyle({ - width: width(), - height: height(), - loaded: mediaView().status === "ready", - }) - return ( { const src = mediaView().src const origin = event.currentTarget