Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

fix: stabilize pinned prompt scroll geometry (#1600)

Joshua Franced2ecc49f3e17
diff --git a/plugins/web-ui/src/shell.css b/plugins/web-ui/src/shell.css
index 9a4c8de74..8960e6449 100644
--- a/plugins/web-ui/src/shell.css
+++ b/plugins/web-ui/src/shell.css
@@ -2048,21 +2048,7 @@ qm-markdown .tok-in {
.user-row.stuck:not(.pin-expanded)
.user-bubble
> .pin-content:has(code-block, pre, table, img, svg, math, .katex-display, video, iframe) {
- max-height: var(--pin-content-max, 2lh);
-}
-.message-stack .user-row.pin-condensed:not(.pin-expanded) .user-bubble > .pin-content {
- -webkit-line-clamp: 2;
-}
-.message-stack
- .user-row.pin-condensed:not(.pin-expanded)
- .user-bubble
- > .pin-content
- :is(p, ul, ol, blockquote, h1, h2, h3, h4, h5, h6) {
- margin-block: 0;
-}
-.message-stack .user-row.pin-condensed:not(.pin-expanded) .user-bubble > .pin-content :is(h1, h2, h3, h4, h5, h6) {
- font-size: inherit;
- line-height: inherit;
+ max-height: var(--pin-content-max, 6lh);
}
.pin-toggle {
display: none;
@@ -2389,6 +2375,11 @@ qm-markdown .tok-in {
display: inline;
}
}
+.message-stack .user-row.stuck > .message-files > .attachment-images {
+ flex-wrap: nowrap;
+ overflow-x: auto;
+ justify-content: safe flex-end;
+}
.message-stack .user-row.stuck > .message-files .file-image {
--attachment-compact: 1;
display: inline-flex;
diff --git a/plugins/web-ui/src/transcript-viewport.ts b/plugins/web-ui/src/transcript-viewport.ts
index c76d5b3cf..9ba9a5308 100644
--- a/plugins/web-ui/src/transcript-viewport.ts
+++ b/plugins/web-ui/src/transcript-viewport.ts
@@ -132,6 +132,7 @@ export function createTranscriptViewport() {
const edge = anchorEdge();
if (!stuck) gap = prompt.getBoundingClientRect().top - edge;
condense(stuck && !expanded, line - edge - (gap ?? restingGap(promptStyle)));
+ syncPrompt();
}
function anchorEdge(): number {
@@ -159,8 +160,9 @@ export function createTranscriptViewport() {
contentHeight = content.scrollHeight;
const inner =
prompt.getBoundingClientRect().height -
- (parseFloat(promptStyle.paddingTop) || 0) -
- (parseFloat(promptStyle.paddingBottom) || 0);
+ (promptStyle.boxSizing === "border-box"
+ ? 0
+ : (parseFloat(promptStyle.paddingTop) || 0) + (parseFloat(promptStyle.paddingBottom) || 0));
prompt.style.setProperty("--pin-rest-height", `${Math.max(0, inner)}px`);
const contentStyle = getComputedStyle(content);
const lineHeight = parseFloat(contentStyle.lineHeight) || (parseFloat(contentStyle.fontSize) || 0) * 1.5;
diff --git a/plugins/web-ui/test/pinned-prompt-collapse.test.ts b/plugins/web-ui/test/pinned-prompt-collapse.test.ts
index b509ed864..300e42653 100644
--- a/plugins/web-ui/test/pinned-prompt-collapse.test.ts
+++ b/plugins/web-ui/test/pinned-prompt-collapse.test.ts
@@ -393,13 +393,8 @@ test("the disclosure rides the last visible line while clamped and drops to a ro
);
});
-test("the condensed strip is a css contract on the condensed class, with a scroll-driven height on stuck", () => {
+test("the condensed strip keeps the resting line layout, with a scroll-driven height on stuck", () => {
const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");
- const condensed =
- css.match(
- /\.message-stack \.user-row\.pin-condensed:not\(\.pin-expanded\) \.user-bubble > \.pin-content \{[^}]*\}/,
- )?.[0] ?? "";
- assert.match(condensed, /-webkit-line-clamp: 2/);
const stuck =
css.match(/\.message-stack \.user-row\.stuck:not\(\.pin-expanded\) \.user-bubble > \.pin-content \{[^}]*\}/)?.[0] ??
"";
@@ -408,7 +403,7 @@ test("the condensed strip is a css contract on the condensed class, with a scrol
assert.match(css, /\.user-row\.stuck:not\(\.pin-expanded\) \{\s*min-height: var\(--pin-rest-height\)/);
assert.match(
css,
- /\.user-row\.stuck:not\(\.pin-expanded\)\s+\.user-bubble\s+> \.pin-content:has\(code-block[^{]*\{\s*max-height: var\(--pin-content-max, 2lh\)/,
+ /\.user-row\.stuck:not\(\.pin-expanded\)\s+\.user-bubble\s+> \.pin-content:has\(code-block[^{]*\{\s*max-height: var\(--pin-content-max, 6lh\)/,
);
const rest =
css.match(
@@ -494,3 +489,32 @@ test("ordinary multi-line prompts stay fully visible without a disclosure", () =
f.close();
}
});
+
+test("condensing clips content without changing its typography", () => {
+ const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");
+ const rules = css.match(/[^{}]*\.pin-condensed[^{}]*\{[^}]*\}/g) ?? [];
+ for (const rule of rules) assert.doesNotMatch(rule, /margin|font-size|line-height|line-clamp/);
+});
+
+test("border-box prompts reserve the entire row including the metadata lane", () => {
+ const f = fixture();
+ try {
+ f.row.style.boxSizing = "border-box";
+ f.row.style.paddingTop = "8px";
+ f.row.style.paddingBottom = "24px";
+ f.resize(400);
+ assert.equal(f.row.style.getPropertyValue("--pin-rest-height"), "163.5px");
+ f.scroll(50);
+ assert.equal(f.row.style.getPropertyValue("--pin-rest-height"), "163.5px");
+ } finally {
+ f.close();
+ }
+});
+
+test("pinned image chips cannot grow into more rows than their thumbnails", () => {
+ const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");
+ const rule = css.match(/\.user-row\.stuck > \.message-files > \.attachment-images \{[^}]*\}/)?.[0] ?? "";
+ assert.match(rule, /flex-wrap: nowrap/);
+ assert.match(rule, /overflow-x: auto/);
+ assert.match(rule, /justify-content: safe flex-end/);
+});