Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Keep short messages visible and fix preview clipping (#1384)

Regan Bell29b95bfe8fac
diff --git a/docs/screenshots/prompt-preview-after.png b/docs/screenshots/prompt-preview-after.png
new file mode 100644
index 000000000..2947fe0e8
Binary files /dev/null and b/docs/screenshots/prompt-preview-after.png differ
diff --git a/docs/screenshots/prompt-preview-before.png b/docs/screenshots/prompt-preview-before.png
new file mode 100644
index 000000000..211e9e90b
Binary files /dev/null and b/docs/screenshots/prompt-preview-before.png differ
diff --git a/plugins/web-ui/src/shell.css b/plugins/web-ui/src/shell.css
index 7e6ade910..07738bc09 100644
--- a/plugins/web-ui/src/shell.css
+++ b/plugins/web-ui/src/shell.css
@@ -2003,10 +2003,17 @@ qm-markdown .tok-in {
line-height: inherit;
}
.message-stack .user-row:not(:has(~ .user-row)):not(.pin-expanded) .user-bubble > .pin-content {
- position: relative;
- max-height: 2lh;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 6;
overflow: hidden;
}
+.message-stack
+ .user-row:not(:has(~ .user-row)):not(.pin-expanded)
+ .user-bubble
+ > .pin-content:has(code-block, pre, table, img, svg, math, .katex-display, video, iframe) {
+ max-height: 6lh;
+}
.message-stack .user-row.pin-expanded .user-bubble > .pin-content {
max-height: var(--pin-expanded-max);
overflow: auto;
diff --git a/plugins/web-ui/test/pinned-composer-polish.test.ts b/plugins/web-ui/test/pinned-composer-polish.test.ts
index 815eb9d9a..bbd96e3cf 100644
--- a/plugins/web-ui/test/pinned-composer-polish.test.ts
+++ b/plugins/web-ui/test/pinned-composer-polish.test.ts
@@ -48,11 +48,21 @@ test("queued cards tuck beneath the next card just as the queue tucks beneath th
assert.match(stacked, /margin-top: -10px;/);
});
-test("collapsed prompt content uses a readable two-line cutoff", () => {
+test("collapsed prompt content uses a readable six-line cutoff", () => {
const selector = ".message-stack .user-row:not(:has(~ .user-row)):not(.pin-expanded) .user-bubble > .pin-content";
const rule = css.slice(css.indexOf(`${selector} {`)).split("}")[0] ?? "";
- assert.match(rule, /max-height: 2lh;/);
+ assert.match(rule, /display: -webkit-box;/);
+ assert.match(rule, /-webkit-box-orient: vertical;/);
+ assert.match(rule, /-webkit-line-clamp: 6;/);
+ assert.doesNotMatch(rule, /max-height:/);
assert.match(rule, /overflow: hidden;/);
assert.doesNotMatch(rule, /mask-image|blur/);
assert.equal(css.includes(`${selector}::after`), false);
});
+
+test("collapsed rich prompts retain a height bound across nested formatting contexts", () => {
+ assert.match(
+ css,
+ /> \.pin-content:has\(code-block, pre, table, img, svg, math, .katex-display, video, iframe\) \{\s*max-height: 6lh;/,
+ );
+});
diff --git a/plugins/web-ui/test/pinned-prompt-collapse.test.ts b/plugins/web-ui/test/pinned-prompt-collapse.test.ts
index 2a95110e0..98fe0fd49 100644
--- a/plugins/web-ui/test/pinned-prompt-collapse.test.ts
+++ b/plugins/web-ui/test/pinned-prompt-collapse.test.ts
@@ -25,7 +25,7 @@ function fixture() {
const limit = row.style.getPropertyValue("--pin-expanded-max");
return Math.min(fullHeight, limit ? parseFloat(limit) : fullHeight);
}
- return Math.min(fullHeight, 46.5);
+ return Math.min(fullHeight, 139.5);
},
},
});
@@ -89,7 +89,7 @@ function fixture() {
test("long prompts clamp to the pane and expand or collapse through their button", () => {
const f = fixture();
try {
- assert.equal(f.content.clientHeight, 46.5);
+ assert.equal(f.content.clientHeight, 139.5);
assert.equal(f.toggle.hidden, false);
f.toggle.click();
assert.equal(f.row.classList.contains("pin-expanded"), true);
@@ -107,9 +107,9 @@ test("pane resizes keep the compact preview height", () => {
const f = fixture();
try {
f.resize(100);
- assert.equal(f.content.clientHeight, 46.5);
+ assert.equal(f.content.clientHeight, 139.5);
f.resize(2000);
- assert.equal(f.content.clientHeight, 46.5);
+ assert.equal(f.content.clientHeight, 139.5);
} finally {
f.close();
}
@@ -218,7 +218,7 @@ test("expanding a scrolled prompt stays sticky with a bounded scrollable body",
f.toggle.click();
assert.equal(f.content.scrollTop, 0);
assert.equal(f.row.classList.contains("stuck"), true);
- assert.equal(f.content.clientHeight, 46.5);
+ assert.equal(f.content.clientHeight, 139.5);
assert.equal(f.scroller.scrollTop, 500);
} finally {
f.close();
@@ -282,3 +282,20 @@ test("repeated prompt measurement preserves the disclosure text node", () => {
f.close();
}
});
+
+test("ordinary multi-line prompts stay fully visible without a disclosure", () => {
+ const f = fixture();
+ try {
+ for (const height of [70, 100, 139]) {
+ f.grow(height);
+ assert.equal(f.content.clientHeight, height);
+ assert.equal(f.toggle.hidden, true);
+ }
+ f.grow(250);
+ assert.equal(f.toggle.hidden, false);
+ f.toggle.click();
+ assert.equal(f.content.clientHeight, 250);
+ } finally {
+ f.close();
+ }
+});
diff --git a/plugins/web-ui/test/user-message-cap.test.ts b/plugins/web-ui/test/user-message-cap.test.ts
index 470a45658..1ef0bb1e0 100644
--- a/plugins/web-ui/test/user-message-cap.test.ts
+++ b/plugins/web-ui/test/user-message-cap.test.ts
@@ -11,7 +11,7 @@ test("only the collapsed pinned prompt is capped and overflow clips instead of n
css.match(
/\.message-stack\s+\.user-row:not\(:has\(~ \.user-row\)\):not\(\.pin-expanded\)\s+\.user-bubble\s+>\s+\.pin-content \{[^}]*\}/,
)?.[0] ?? "";
- assert.match(bubble, /max-height: 2lh;/);
+ assert.match(bubble, /-webkit-line-clamp: 6;/);
assert.match(bubble, /overflow: hidden;/);
assert.doesNotMatch(css, /\.user-bubble > (?:markdown-block|\.slack-wire-text)\s*\{/);
const base = css.match(/\n\.user-bubble \{[^}]*\}/)?.[0] ?? "";