mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-04 07:33:18 +00:00
* fix(app): smooth chat history pagination and reserve image space Select the range at the pending reading offset before a prepend mounts rows. Reuse committed geometry for scroll input so a layout correction cannot hide the user's movement. Reserve image dimensions before loading and measure transient mounts in the browser regression. * fix(app): scope cached image dimensions to their source Raw file-path aliases let one workspace supply dimensions for another. Keep file metadata tied to its daemon and workspace, and close the delayed-image test server even when setup fails. * fix(app): retain local image context in row height estimates Pass the rendering server and workspace through height estimation so scoped image metadata remains usable before an older row mounts. * refactor(app): name row height estimate inputs
63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
export interface InlineImageDimensions {
|
|
width: number;
|
|
height: number;
|
|
}
|
|
|
|
export interface InlineImageExplicitDimensions {
|
|
width?: number;
|
|
height?: number;
|
|
}
|
|
|
|
const INLINE_IMAGE_MAX_WIDTH = 240;
|
|
const INLINE_IMAGE_MAX_HEIGHT = 160;
|
|
|
|
export function resolveInlineImageSize(input: {
|
|
explicit: InlineImageExplicitDimensions;
|
|
natural: InlineImageDimensions | null;
|
|
}): InlineImageDimensions {
|
|
const dimensions = resolveInlineImageDimensions(input);
|
|
const scale = Math.min(
|
|
1,
|
|
INLINE_IMAGE_MAX_WIDTH / dimensions.width,
|
|
INLINE_IMAGE_MAX_HEIGHT / dimensions.height,
|
|
);
|
|
|
|
return {
|
|
width: Math.round(dimensions.width * scale),
|
|
height: Math.round(dimensions.height * scale),
|
|
};
|
|
}
|
|
|
|
function resolveInlineImageDimensions(input: {
|
|
explicit: InlineImageExplicitDimensions;
|
|
natural: InlineImageDimensions | null;
|
|
}): InlineImageDimensions {
|
|
if (input.explicit.width && input.explicit.height) {
|
|
return { width: input.explicit.width, height: input.explicit.height };
|
|
}
|
|
|
|
if (input.explicit.width && input.natural) {
|
|
return {
|
|
width: input.explicit.width,
|
|
height: input.explicit.width * (input.natural.height / input.natural.width),
|
|
};
|
|
}
|
|
|
|
if (input.explicit.height && input.natural) {
|
|
return {
|
|
width: input.explicit.height * (input.natural.width / input.natural.height),
|
|
height: input.explicit.height,
|
|
};
|
|
}
|
|
|
|
if (input.explicit.width) {
|
|
return { width: input.explicit.width, height: input.explicit.width };
|
|
}
|
|
|
|
if (input.explicit.height) {
|
|
return { width: input.explicit.height, height: input.explicit.height };
|
|
}
|
|
|
|
return input.natural ?? { width: INLINE_IMAGE_MAX_WIDTH, height: INLINE_IMAGE_MAX_HEIGHT };
|
|
}
|