| ... | @@ -1656,6 +1656,98 @@ describe("MessagesTimeline", () => { | ... | @@ -1656,6 +1656,98 @@ describe("MessagesTimeline", () => { |
| 1656 | expect(markup).not.toContain("tool call failed"); | 1656 | expect(markup).not.toContain("tool call failed"); |
| 1657 | }); | 1657 | }); |
| 1658 | | 1658 | |
| | 1659 | it.each( |
| | 1660 | ( |
| | 1661 | [ |
| | 1662 | [ |
| | 1663 | "**Viewing image first** with *care*, ~~old~~ `code` and [context](https://example.com)", |
| | 1664 | "Viewing image first with care, old code and context", |
| | 1665 | 1, |
| | 1666 | ], |
| | 1667 | ["first paragraph\n\nsecond paragraph", "first paragraph second paragraph", 0], |
| | 1668 | ["- first\n- second", "first second", 0], |
| | 1669 | ["first \nsecond", "first second", 0], |
| | 1670 | ["", "image description", 0], |
| | 1671 | ["", "Thought", 0], |
| | 1672 | ["---", "Thought", 0], |
| | 1673 | ] as const |
| | 1674 | ).flatMap(([markdown, expected, strongCount]) => |
| | 1675 | [false, true].map((streaming) => ({ |
| | 1676 | markdown, |
| | 1677 | expected, |
| | 1678 | strongCount, |
| | 1679 | streaming, |
| | 1680 | })), |
| | 1681 | ), |
| | 1682 | )( |
| | 1683 | "shows a plain thought preview for $markdown, streaming=$streaming", |
| | 1684 | async ({ markdown, expected, strongCount, streaming }) => { |
| | 1685 | vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true); |
| | 1686 | vi.stubGlobal("requestAnimationFrame", () => 0); |
| | 1687 | vi.stubGlobal("cancelAnimationFrame", () => {}); |
| | 1688 | const turnId = TurnId.make("turn-thought"); |
| | 1689 | const thought = buildAssistantTimelineEntry(markdown); |
| | 1690 | let renderer: ReactTestRenderer | undefined; |
| | 1691 | try { |
| | 1692 | await act(() => { |
| | 1693 | renderer = create( |
| | 1694 | <MessagesTimeline |
| | 1695 | {...buildProps()} |
| | 1696 | isWorking |
| | 1697 | runningTurnId={turnId} |
| | 1698 | timelineEntries={[ |
| | 1699 | { |
| | 1700 | id: "work-entry", |
| | 1701 | kind: "work", |
| | 1702 | createdAt: MESSAGE_CREATED_AT, |
| | 1703 | entry: { |
| | 1704 | id: "work", |
| | 1705 | createdAt: MESSAGE_CREATED_AT, |
| | 1706 | turnId, |
| | 1707 | label: "Read image", |
| | 1708 | tone: "tool", |
| | 1709 | itemType: "command_execution", |
| | 1710 | command: "cat image.png", |
| | 1711 | toolLifecycleStatus: "completed", |
| | 1712 | }, |
| | 1713 | }, |
| | 1714 | { |
| | 1715 | ...thought, |
| | 1716 | message: { ...thought.message, role: "reasoning", turnId, streaming }, |
| | 1717 | }, |
| | 1718 | ]} |
| | 1719 | />, |
| | 1720 | ); |
| | 1721 | }); |
| | 1722 | await act(() => renderer!.root.findByProps({ "aria-expanded": false }).props.onClick()); |
| | 1723 | const text = renderer!.root.findByProps({ |
| | 1724 | className: "relative min-w-0 flex-1 truncate text-secondary-label", |
| | 1725 | }); |
| | 1726 | const preview = text.parent!; |
| | 1727 | expect( |
| | 1728 | text |
| | 1729 | .findAll(() => true) |
| | 1730 | .flatMap((node) => node.children) |
| | 1731 | .filter((child) => typeof child === "string") |
| | 1732 | .join(""), |
| | 1733 | ).toBe( |
| | 1734 | (streaming && expected === "Thought" ? "Thinking" : expected).repeat(streaming ? 2 : 1), |
| | 1735 | ); |
| | 1736 | expect( |
| | 1737 | preview.findAll((node) => |
| | 1738 | ["strong", "em", "del", "code", "a"].includes(String(node.type)), |
| | 1739 | ), |
| | 1740 | ).toHaveLength(0); |
| | 1741 | await act(() => preview.props.onClick()); |
| | 1742 | expect(renderer!.root.findAllByType("strong")).toHaveLength(strongCount); |
| | 1743 | await act(() => preview.props.onClick()); |
| | 1744 | expect(renderer!.root.findAllByType("strong")).toHaveLength(0); |
| | 1745 | } finally { |
| | 1746 | await act(() => renderer?.unmount()); |
| | 1747 | } |
| | 1748 | }, |
| | 1749 | ); |
| | 1750 | |
| 1659 | it("renders initial thinking as the shared live activity row", () => { | 1751 | it("renders initial thinking as the shared live activity row", () => { |
| 1660 | const turnId = TurnId.make("turn-live"); | 1752 | const turnId = TurnId.make("turn-live"); |
| 1661 | const markup = renderToStaticMarkup( | 1753 | const markup = renderToStaticMarkup( |