@@ -44,7 +44,9 @@ import {
4444 deriveTimelineEntriesFromVisibleTurnItems ,
4545} from "../../session-logic" ;
4646import type { Root } from "mdast" ;
47+ import { ViewedImagesTimelineRow } from "./TimelineWorkEntryRow" ;
4748import { remarkThoughtPreview , THOUGHT_PREVIEW_MAX_LENGTH } from "./TimelineWorkEntryRow.logic" ;
49+ import { TimelineRowCtx } from "./timelineRowContext" ;
4850import { parseMarkdownWithMath } from "@t3tools/shared/markdownMath" ;
4951import { collectThreadFindRanges } from "./threadFindHighlights" ;
5052import { toastManager } from "../ui/toast" ;
@@ -74,14 +76,14 @@ vi.mock(import("~/state/query"), async (original) => ({
7476 } ) ) as never ,
7577} ) ) ;
7678
77- const audioAsset = vi . hoisted ( ( ) => ( { url : "" } ) ) ;
79+ const stubbedAsset = vi . hoisted ( ( ) => ( { url : "" } ) ) ;
7880vi . mock ( import ( "~/assets/assetUrls" ) , async ( original ) => {
7981 const actual = await original ( ) ;
8082 return {
8183 ...actual ,
8284 useAssetUrlState : ( ( ...args : Parameters < typeof actual . useAssetUrlState > ) =>
83- audioAsset . url
84- ? { _tag : "Success" , url : audioAsset . url }
85+ stubbedAsset . url
86+ ? { _tag : "Success" , url : stubbedAsset . url }
8587 : actual . useAssetUrlState ( ...args ) ) as typeof actual . useAssetUrlState ,
8688 } ;
8789} ) ;
@@ -1457,9 +1459,9 @@ describe("MessagesTimeline attachments", () => {
14571459 ) ;
14581460 const src =
14591461 "data:audio/wav;base64,UklGRiUAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQEAAACA" ;
1460- audioAsset . url = src ;
1462+ stubbedAsset . url = src ;
14611463 onTestFinished ( ( ) => {
1462- audioAsset . url = "" ;
1464+ stubbedAsset . url = "" ;
14631465 } ) ;
14641466 const props = baseProps ( ) ;
14651467 await using screen = await renderTimeline (
@@ -1527,6 +1529,44 @@ describe("MessagesTimeline attachments", () => {
15271529 } ) ;
15281530 await vi . waitFor ( ( ) => expect ( one ! . isConnected ) . toBe ( false ) ) ;
15291531 } ) ;
1532+
1533+ it ( "opens a viewed image as a gallery of the images beside it" , async ( ) => {
1534+ stubbedAsset . url =
1535+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" ;
1536+ onTestFinished ( ( ) => {
1537+ stubbedAsset . url = "" ;
1538+ } ) ;
1539+ const onImageExpand = vi . fn < ComponentProps < typeof MessagesTimeline > [ "onImageExpand" ] > ( ) ;
1540+ await using screen = await renderElement (
1541+ < TimelineRowCtx
1542+ value = {
1543+ {
1544+ threadRef : { environmentId : ENVIRONMENT_ID , threadId : ThreadId . make ( "thread-1" ) } ,
1545+ workspaceRoot : "/repo" ,
1546+ onImageExpand,
1547+ } as never
1548+ }
1549+ >
1550+ < ViewedImagesTimelineRow
1551+ row = { {
1552+ kind : "viewed-images" ,
1553+ id : "viewed" ,
1554+ createdAt : CREATED_AT ,
1555+ paths : [ "/repo/first.png" , "/repo/second.png" , "/repo/third.png" ] ,
1556+ } }
1557+ />
1558+ </ TimelineRowCtx > ,
1559+ ) ;
1560+ await screen . getByRole ( "button" , { name : "Preview second.png" } ) . click ( ) ;
1561+ expect ( onImageExpand ) . toHaveBeenCalledExactlyOnceWith (
1562+ expect . objectContaining ( {
1563+ index : 1 ,
1564+ images : [ "first.png" , "second.png" , "third.png" ] . map ( ( name ) =>
1565+ expect . objectContaining ( { name } ) ,
1566+ ) ,
1567+ } ) ,
1568+ ) ;
1569+ } ) ;
15301570} ) ;
15311571
15321572describe ( "MessagesTimeline thread find" , ( ) => {
0 commit comments