Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

fix(web-ui): elevate chat surfaces above scrolling responses

16francej368e4904f340
diff --git a/docs/images/chat-surface-elevation.png b/docs/images/chat-surface-elevation.png
new file mode 100644
index 000000000..c6bb7e1e3
Binary files /dev/null and b/docs/images/chat-surface-elevation.png differ
diff --git a/plugins/web-ui/src/chat.ts b/plugins/web-ui/src/chat.ts
index cf49fc66f..35e0c91a8 100644
--- a/plugins/web-ui/src/chat.ts
+++ b/plugins/web-ui/src/chat.ts
@@ -2660,15 +2660,6 @@ export function createChatSurface(
function onTranscriptScroll(e: Event): void {
const s = e.currentTarget as HTMLElement;
stickToBottom = s.scrollHeight - s.scrollTop - s.clientHeight <= 120;
- markStuckUserRow(s);
- }
-
- function markStuckUserRow(scroller: HTMLElement): void {
- const rows = scroller.querySelectorAll<HTMLElement>(".message-stack .user-row");
- const row = rows.length ? rows[rows.length - 1] : undefined;
- if (!row) return;
- const stuck = row.getBoundingClientRect().top <= scroller.getBoundingClientRect().top + 0.5;
- row.classList.toggle("stuck", stuck);
}
function scrollToBottom(): void {
@@ -2679,10 +2670,8 @@ export function createChatSurface(
function scrollTranscript(force = false): void {
const scroller = ctx.container()?.querySelector<HTMLElement>(".chat-scroll");
if (!scroller) return;
- markStuckUserRow(scroller);
if (!force && !stickToBottom) return;
requestAnimationFrame(() => {
- markStuckUserRow(scroller);
if (force) {
const prev = scroller.style.scrollBehavior;
scroller.style.scrollBehavior = "auto";
diff --git a/plugins/web-ui/src/shell.css b/plugins/web-ui/src/shell.css
index b63343211..c2b5c0f1d 100644
--- a/plugins/web-ui/src/shell.css
+++ b/plugins/web-ui/src/shell.css
@@ -11,6 +11,7 @@
--radius-lg: 16px;
--chat-pad: 16px;
--composer-inset: 13px;
+ --chat-surface-shadow: 0 2px 5px rgb(0 0 0 / 0.08), 0 8px 24px rgb(0 0 0 / 0.1);
/* Height reserved at the bottom of every chat message for its own hover footer; it doubles
as the rhythm between message blocks. */
--meta-lane: 18px;
@@ -1312,55 +1313,16 @@ a.chat-row-open {
--chat-scroll-pad-top: 28px;
container-type: size;
- --chat-edge-fade: 24px;
+ --chat-edge-space: 24px;
+ --chat-scroll-pad-bottom: calc(var(--chat-edge-space) + 16px);
min-height: 0;
overflow-y: auto;
scrollbar-gutter: stable;
- padding: var(--chat-scroll-pad-top) var(--chat-pad) 0;
+ padding: var(--chat-scroll-pad-top) var(--chat-pad) var(--chat-scroll-pad-bottom);
scroll-behavior: smooth;
}
-.chat-scroll::before,
-.chat-scroll::after {
- content: "";
- display: block;
- position: sticky;
- z-index: 2;
- height: var(--chat-edge-fade);
- margin-left: calc(-1 * var(--chat-pad));
- margin-right: calc(-1 * var(--chat-pad));
- pointer-events: none;
- backdrop-filter: blur(1px);
- -webkit-backdrop-filter: blur(1px);
-}
-.chat-scroll::before {
- top: calc(-1 * var(--chat-scroll-pad-top));
- margin-top: calc(-1 * var(--chat-scroll-pad-top));
- margin-bottom: calc(var(--chat-scroll-pad-top) - var(--chat-edge-fade));
- background: linear-gradient(
- to bottom,
- var(--background),
- color-mix(in srgb, var(--background) 74%, transparent) 38%,
- color-mix(in srgb, var(--background) 32%, transparent) 68%,
- transparent
- );
- mask-image: linear-gradient(to bottom, #000, rgb(0 0 0 / 0.74) 38%, rgb(0 0 0 / 0.32) 68%, transparent);
- -webkit-mask-image: linear-gradient(to bottom, #000, rgb(0 0 0 / 0.74) 38%, rgb(0 0 0 / 0.32) 68%, transparent);
-}
-.chat-scroll::after {
- bottom: 0;
- background: linear-gradient(
- to top,
- var(--background),
- color-mix(in srgb, var(--background) 74%, transparent) 38%,
- color-mix(in srgb, var(--background) 32%, transparent) 68%,
- transparent
- );
- mask-image: linear-gradient(to top, #000, rgb(0 0 0 / 0.74) 38%, rgb(0 0 0 / 0.32) 68%, transparent);
- -webkit-mask-image: linear-gradient(to top, #000, rgb(0 0 0 / 0.74) 38%, rgb(0 0 0 / 0.32) 68%, transparent);
-}
-
.fork-origin-row {
display: flex;
align-items: center;
@@ -1427,6 +1389,7 @@ a.chat-row-open {
display: flex;
flex-direction: column;
gap: 4px;
+ box-shadow: var(--chat-surface-shadow);
}
.pinned-strip.expanded {
padding: 6px 10px;
@@ -1571,34 +1534,14 @@ a.chat-row-open {
z-index: 3;
padding-top: 14px;
margin-top: -14px;
- margin-bottom: var(--chat-edge-fade);
- background: var(--background);
-}
-
-.message-stack .user-row:not(:has(~ .user-row))::after {
- content: "";
- position: absolute;
- left: calc(-1 * var(--chat-pad));
- right: calc(-1 * var(--chat-pad));
- top: 100%;
- height: var(--chat-edge-fade, 20px);
+ margin-bottom: var(--chat-edge-space);
+ background: transparent;
pointer-events: none;
- opacity: 0;
- background: linear-gradient(
- to bottom,
- var(--background),
- color-mix(in srgb, var(--background) 74%, transparent) 38%,
- color-mix(in srgb, var(--background) 32%, transparent) 68%,
- transparent
- );
- mask-image: linear-gradient(to bottom, #000, rgb(0 0 0 / 0.74) 38%, rgb(0 0 0 / 0.32) 68%, transparent);
- -webkit-mask-image: linear-gradient(to bottom, #000, rgb(0 0 0 / 0.74) 38%, rgb(0 0 0 / 0.32) 68%, transparent);
- backdrop-filter: blur(3px);
- -webkit-backdrop-filter: blur(3px);
- transition: opacity 120ms ease;
}
-.message-stack .user-row.stuck:not(:has(~ .user-row))::after {
- opacity: 1;
+
+.message-stack .user-row:not(:has(~ .user-row)) > .user-bubble {
+ pointer-events: auto;
+ box-shadow: var(--chat-surface-shadow);
}
.assistant-row + .user-row {
@@ -2474,8 +2417,13 @@ a.chat-row-open {
}
.chat-bottom-dock {
+ position: relative;
+ z-index: 4;
min-width: 0;
}
+.custom-chat-shell:has(> .chat-scroll):not(.empty-chat) > .chat-bottom-dock {
+ margin-top: -16px;
+}
.bg-chip {
display: inline-flex;
@@ -2837,6 +2785,7 @@ a.chat-row-open {
border: 1px solid var(--border);
border-radius: 24px;
background: var(--background);
+ box-shadow: var(--chat-surface-shadow);
}
.composer-input {
width: 100%;
@@ -7242,8 +7191,8 @@ h3.ambient-field-label {
[data-density="compact"] .chat-scroll {
--chat-scroll-pad-top: 14px;
- --chat-edge-fade: 14px;
- padding: var(--chat-scroll-pad-top) var(--chat-pad) 0;
+ --chat-edge-space: 14px;
+ padding: var(--chat-scroll-pad-top) var(--chat-pad) var(--chat-scroll-pad-bottom);
}
[data-density="compact"] .message-row {
--meta-lane: 16px;
@@ -8772,11 +8721,11 @@ h3.ambient-field-label {
}
.mini-convo-body .chat-scroll {
--chat-scroll-pad-top: 12px;
- --chat-edge-fade: 12px;
+ --chat-edge-space: 12px;
--chat-pad: 12px;
container-type: normal;
max-height: 250px;
- padding: var(--chat-scroll-pad-top) var(--chat-pad) 0;
+ padding: var(--chat-scroll-pad-top) var(--chat-pad) var(--chat-scroll-pad-bottom);
}
.mini-convo-body .message-stack {
width: 100%;
diff --git a/plugins/web-ui/test/chat-elevation.test.ts b/plugins/web-ui/test/chat-elevation.test.ts
new file mode 100644
index 000000000..14efcd2a2
--- /dev/null
+++ b/plugins/web-ui/test/chat-elevation.test.ts
@@ -0,0 +1,28 @@
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import test from "node:test";
+
+const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");
+
+test("transcript edges do not blur or mask the response", () => {
+ assert.doesNotMatch(css, /\.chat-scroll::(?:before|after)/);
+ assert.doesNotMatch(css, /\.message-stack \.user-row[^{}]*::after/);
+ assert.doesNotMatch(css, /--chat-edge-fade/);
+});
+
+test("the pinned prompt and composer have elevated solid surfaces", () => {
+ const pinned =
+ css.match(/\.message-stack \.user-row:not\(:has\(~ \.user-row\)\) > \.user-bubble \{[^}]*\}/)?.[0] ?? "";
+ const composer = css.match(/^\.composer-wrap \{[^}]*\}/m)?.[0] ?? "";
+ assert.match(pinned, /box-shadow: var\(--chat-surface-shadow\);/);
+ assert.match(composer, /background: var\(--background\);/);
+ assert.match(composer, /box-shadow: var\(--chat-surface-shadow\);/);
+});
+
+test("prompt elevation is shared by every transcript without scroll-handler state", () => {
+ const root = css.match(/:root \{[^}]*\}/)?.[0] ?? "";
+ const chat = readFileSync(new URL("../src/chat.ts", import.meta.url), "utf8");
+ assert.match(root, /--chat-surface-shadow:/);
+ assert.doesNotMatch(css, /\.user-row\.stuck/);
+ assert.doesNotMatch(chat, /markStuckUserRow/);
+});
diff --git a/plugins/web-ui/test/css-vars.test.ts b/plugins/web-ui/test/css-vars.test.ts
index 30373858e..800ce2b28 100644
--- a/plugins/web-ui/test/css-vars.test.ts
+++ b/plugins/web-ui/test/css-vars.test.ts
@@ -32,10 +32,26 @@ test("every drop zone the canvas renders has a positioning rule in shell.css", (
assert.deepEqual(missing, [], "drop zones rendered with no .zone-<edge> rule (they collapse to 0×0)");
});
-test("no surface paints a shadow", () => {
- const painted = [...(shellCss + tsSource).matchAll(/(?:box|text)-shadow\s*:\s*([^;}]+)/g)]
+test("only the elevated chat surfaces paint a shadow", () => {
+ const elevated = [
+ ".pinned-strip",
+ ".message-stack .user-row:not(:has(~ .user-row)) > .user-bubble",
+ ".composer-wrap",
+ ];
+ const rules = shellCss.replace(/\/\*[\s\S]*?\*\//g, "");
+ const painted = [...rules.matchAll(/([^{}]+)\{([^{}]*)\}/g)].flatMap((rule) =>
+ [...rule[2].matchAll(/(box|text)-shadow\s*:\s*([^;}]+)/g)]
+ .filter((shadow) => shadow[2].trim() !== "none")
+ .map((shadow) => [rule[1].trim(), shadow[1], shadow[2].trim()]),
+ );
+ assert.deepEqual(
+ painted,
+ elevated.map((selector) => [selector, "box", "var(--chat-surface-shadow)"]),
+ "only the pinned strip, latest prompt bubble, and composer may use the shared elevation shadow",
+ );
+ const inlineShadows = [...tsSource.matchAll(/(?:box|text)-shadow\s*:\s*([^;}]+)/g)]
.map((m) => m[1].trim())
.filter((v) => v !== "none");
- assert.deepEqual(painted, [], "shadows are not part of this app's surface treatment");
+ assert.deepEqual(inlineShadows, [], "inline styles must not introduce additional shadows");
assert.doesNotMatch(shellCss + tsSource, /drop-shadow\(/);
});
diff --git a/plugins/web-ui/test/sticky-prompt-fade.test.ts b/plugins/web-ui/test/sticky-prompt-fade.test.ts
deleted file mode 100644
index fd185a999..000000000
--- a/plugins/web-ui/test/sticky-prompt-fade.test.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import assert from "node:assert/strict";
-import { readFileSync } from "node:fs";
-import test from "node:test";
-
-const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");
-
-test("the sticky prompt reserves the space painted by its lower fade", () => {
- const prompt = css.match(/\.message-stack \.user-row:not\(:has\(~ \.user-row\)\) \{[^}]*\}/)?.[0] ?? "";
- const fade = css.match(/\.message-stack \.user-row:not\(:has\(~ \.user-row\)\)::after \{[^}]*\}/)?.[0] ?? "";
-
- assert.match(prompt, /margin-bottom: var\(--chat-edge-fade\);/);
- assert.match(fade, /top: 100%;/);
- assert.match(fade, /height: var\(--chat-edge-fade, 20px\);/);
-});