Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@types/node": "25.5.2",
"@codemirror/state": "6.5.4"
},
"ignoredBuiltDependencies": [
"onlyBuiltDependencies": [
"chromedriver"
]
},
Expand Down
73 changes: 51 additions & 22 deletions packages/app/src/components/browser/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ export class DevtoolsBrowser extends Element {

iframe {
background-color: white;
flex: 1;
position: absolute;
top: 0;
left: 0;
border: none;
border-radius: 0 0 0.5rem 0.5rem;
min-height: 0;
}

.screenshot-overlay {
Expand Down Expand Up @@ -169,6 +170,7 @@ export class DevtoolsBrowser extends Element {
position: relative;
flex: 1;
min-height: 0;
overflow: hidden;
display: flex;
flex-direction: column;
}
Expand Down Expand Up @@ -249,7 +251,7 @@ export class DevtoolsBrowser extends Element {

#setIframeSize() {
const metadata = this.metadata
if (!this.section || !this.iframe || !this.header || !metadata) {
if (!this.section || !this.header || !metadata) {
return
}

Expand All @@ -262,26 +264,46 @@ export class DevtoolsBrowser extends Element {
return
}

this.iframe.removeAttribute('style')
const frameSize = this.getBoundingClientRect()
const headerSize = this.header.getBoundingClientRect()

let scale = frameSize.width / viewportWidth
if (scale > 0.85) {
/**
* Make sure we stop scaling at 85% of the viewport width to ensure
* we keep the aspect ratio. We substract 0.05 to have a bit of a
* padding
*/
scale = frameSize.height / viewportHeight - 0.05
}
this.iframe?.removeAttribute('style')

// Defer to next frame so we read post-reflow dimensions on resize events.
requestAnimationFrame(() => {
if (!this.section || !this.header) {
return
}
const frameSize = this.getBoundingClientRect()
const headerSize = this.header.getBoundingClientRect()
const hostStyle = getComputedStyle(this)

// getBoundingClientRect returns the padding-box; subtract host padding
// so a height-limited scale doesn't push section.width past the edge.
const padX =
parseFloat(hostStyle.paddingLeft || '0') +
parseFloat(hostStyle.paddingRight || '0')
const padY =
parseFloat(hostStyle.paddingTop || '0') +
parseFloat(hostStyle.paddingBottom || '0')

const effectiveViewportH = viewportHeight

const availW = Math.max(0, frameSize.width - padX)
const availH = Math.max(0, frameSize.height - padY - headerSize.height)
const scale = Math.max(
0,
Math.min(availW / viewportWidth, availH / effectiveViewportH)
)

this.section.style.width = `${viewportWidth * scale}px`
this.section.style.height = `${effectiveViewportH * scale + headerSize.height}px`

this.section.style.width = `${viewportWidth * scale}px`
this.section.style.height = `${Math.min(frameSize.height, viewportHeight * scale)}px`
this.iframe.style.width = `${viewportWidth}px`
// this.iframe.style.height = `${(Math.min(frameSize.height, viewportHeight * scale) - headerSize.height)}px`
this.iframe.style.height = `${viewportHeight - headerSize.height / scale}px`
this.iframe.style.transform = `scale(${scale})`
// Iframe absent in screenshot/video modes — section sizing above still runs.
if (this.iframe) {
this.iframe.style.width = `${viewportWidth}px`
this.iframe.style.height = `${viewportHeight}px`
this.iframe.style.transformOrigin = '0 0'
this.iframe.style.transform = `scale(${scale})`
}
})
}

#handleShowCommand = (event: Event) =>
Expand Down Expand Up @@ -320,6 +342,11 @@ export class DevtoolsBrowser extends Element {
this.requestUpdate()
}

// View-mode flips swap the iframe with <img>/<video> and don't fire resize.
updated() {
this.#setIframeSize()
}

async #renderNewDocument(doc: SimplifiedVNode, baseUrl: string) {
const root = transform(doc)
const baseTag = h('base', { href: baseUrl })
Expand Down Expand Up @@ -351,6 +378,8 @@ export class DevtoolsBrowser extends Element {
*/
;[...this.#vdom.querySelectorAll('script')].forEach((el) => el.remove())
docEl.ownerDocument.replaceChild(this.#vdom, docEl)

this.#setIframeSize()
}

async #handleMutation(mutation: TraceMutation) {
Expand Down
12 changes: 11 additions & 1 deletion packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,17 @@ export async function start(
return
}

// Strip videoPath before forwarding — the UI fetches via /api/video/:sessionId.
if (parsed.scope === 'config' && parsed.data?.configFile) {
testRunner.registerConfigFile(parsed.data.configFile)
log.info(
`Registered config file for reruns: ${parsed.data.configFile}`
)
return
}

// Intercept screencast messages: store the absolute videoPath in the
// registry (backend-only), then forward only the sessionId to the UI
// so the UI can request the video via GET /api/video/:sessionId.
if (parsed.scope === 'screencast' && parsed.data?.sessionId) {
const { sessionId, videoPath } = parsed.data
if (videoPath) {
Expand Down
Loading
Loading