fix(markdown): address inline image review feedback

Keep the leading slash when resolving relative paths against an absolute
markdown file, retry an inline image when its source changes after a load
failure, and render linked markdown images without a nested expand button.
This commit is contained in:
Chris Scott committed 2026-10-13 01:46:51 +00:00
1 parent 458f26134b
commit f488b8762d
7 files changed
+118 -22

No files matched your search

@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { render, screen, fireEvent } from '@testing-library/react'
import { render, screen, fireEvent, within } from '@testing-library/react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { MemoryRouter } from 'react-router-dom'
import { MessagePart } from './MessagePart'
@@ -175,6 +175,22 @@ describe('MessagePart', () => {
expect(container.querySelector('img')).toBeNull()
})
it('renders a linked image without a nested expand button', () => {
renderWithProviders(
<MessagePart part={textPart('[![logo](https://example.com/a.png)](https://example.com)')} />,
)
const link = screen.getByRole('link')
expect(within(link).getByAltText('logo')).toHaveAttribute('src', 'https://example.com/a.png')
expect(within(link).queryByRole('button')).toBeNull()
})
it('renders an expand button for an unlinked image', () => {
renderWithProviders(<MessagePart part={textPart('![logo](https://example.com/a.png)')} />)
expect(screen.getByRole('button', { name: 'Expand image: logo' })).toBeInTheDocument()
})
})
describe('reasoning', () => {