Multiplayer agent harness for work.
Preserve pane scroll across layout changes (#698)
Joshua France08634457453a
diff --git a/plugins/web-ui/src/chat.ts b/plugins/web-ui/src/chat.tsindex 0d9089b6d..9ff43b31d 100644--- a/plugins/web-ui/src/chat.ts+++ b/plugins/web-ui/src/chat.ts@@ -1082,17 +1082,13 @@ export function createChatSurface(: nothing}${glanceTier || ctx.pane ? nothing : sessionTopbar()}- ${- glanceTier- ? paneGlance(agent, messages, glanceTier)- : html`<section class="chat-scroll" @scroll=${onTranscriptScroll}>- <div class="message-stack ${messages.length || chatState.forkSession ? "" : "empty-stack"}">- ${inheritedHeader()} ${chatState.earlierCount > 0 ? earlierNotice(agent) : nothing}- ${messageContent}- ${showStateError(messages, agent.state.errorMessage) ? html`<div class="composer-error inline">${agent.state.errorMessage}</div>` : nothing}- </div>- </section>`- }+ ${glanceTier ? paneGlance(agent, messages, glanceTier) : nothing}+ <section class="chat-scroll" @scroll=${onTranscriptScroll}>+ <div class="message-stack ${messages.length || chatState.forkSession ? "" : "empty-stack"}">+ ${inheritedHeader()} ${chatState.earlierCount > 0 ? earlierNotice(agent) : nothing} ${messageContent}+ ${showStateError(messages, agent.state.errorMessage) ? html`<div class="composer-error inline">${agent.state.errorMessage}</div>` : nothing}+ </div>+ </section><div class="chat-bottom-dock">${backgroundActivityStrip()} ${liveWorkDock(agent)} ${ctx.composer.composerForm(agent)}</div>diff --git a/plugins/web-ui/src/conversations.ts b/plugins/web-ui/src/conversations.tsindex 1e8f21dda..9edd1ceed 100644--- a/plugins/web-ui/src/conversations.ts+++ b/plugins/web-ui/src/conversations.ts@@ -48,9 +48,11 @@ export function mainConversation(): Conversation {return main;}-export function paneDensity(el: HTMLElement): DensityTier {+export function paneDensity(el: HTMLElement): DensityTier | null {const r = el.getBoundingClientRect();- return densityTierFor(r.width || el.clientWidth, r.height || el.clientHeight);+ const width = r.width || el.clientWidth;+ const height = r.height || el.clientHeight;+ return width > 0 && height > 0 ? densityTierFor(width, height) : null;}let exitCanvas: () => void = () => {};diff --git a/plugins/web-ui/src/shell.css b/plugins/web-ui/src/shell.cssindex d2aa7580b..08e458f58 100644--- a/plugins/web-ui/src/shell.css+++ b/plugins/web-ui/src/shell.css@@ -7284,6 +7284,11 @@ h3.ambient-field-label {[data-density] .composer-error {flex-basis: 100%;}+[data-density="card"] .chat-scroll,+[data-density="strip"] .chat-scroll {+ display: none;+}+.pane-card {min-height: 0;overflow: hidden;diff --git a/plugins/web-ui/src/split.ts b/plugins/web-ui/src/split.tsindex 2ddd52d19..a270f4e7e 100644--- a/plugins/web-ui/src/split.ts+++ b/plugins/web-ui/src/split.ts@@ -851,13 +851,14 @@ class PaneContent implements IContentRenderer {return;}this.syncDensity();- this.conversation.drawActiveChat(undefined, { forceScroll: true });});if (p.api.isVisible) void this.load();}private syncDensity(): void {- this.element.dataset.density = this.density = paneDensity(this.element);+ const next = paneDensity(this.element);+ if (!next || next === this.density) return;+ this.element.dataset.density = this.density = next;for (const handler of this.redrawOnResize) handler();}diff --git a/plugins/web-ui/test/tab-switch-scroll-snap.test.ts b/plugins/web-ui/test/tab-switch-scroll-snap.test.tsindex fd50c190f..6c5148510 100644--- a/plugins/web-ui/test/tab-switch-scroll-snap.test.ts+++ b/plugins/web-ui/test/tab-switch-scroll-snap.test.ts@@ -5,22 +5,22 @@ import test from "node:test";const split = readFileSync(new URL("../src/split.ts", import.meta.url), "utf8");const chat = readFileSync(new URL("../src/chat.ts", import.meta.url), "utf8");-test("re-activating a pane tab force-scrolls the transcript (already-loaded panes snap to bottom)", () => {+test("pane visibility changes preserve the transcript viewport", () => {const handler = split.match(/onDidVisibilityChange\(\(e\) => \{[\s\S]*?\}\);/)?.[0] ?? "";- assert.match(handler, /drawActiveChat\(undefined, \{ forceScroll: true \}\)/);- assert.match(handler, /if \(!this\.loaded\)/, "only already-loaded panes redraw; first show still loads");- const density = handler.indexOf("this.syncDensity()");- const draw = handler.indexOf("drawActiveChat(undefined, { forceScroll: true })");- assert.ok(- density >= 0 && density < draw,- "density resyncs before the forced redraw — a hidden pane measured 0\u00d70 and would render scroller-less glance UI",+ assert.doesNotMatch(handler, /forceScroll/, "grid visibility is presentation state, not scroll intent");+ assert.match(handler, /this\.syncDensity\(\)/, "shown panes still refresh their responsive presentation");+});++test("responsive pane summaries do not replace the transcript scroller", () => {+ assert.match(chat, /glanceTier\s*\?\s*paneGlance\([^)]+\)\s*:\s*nothing[\s\S]*?<section class="chat-scroll"/);+ assert.doesNotMatch(+ chat,+ /glanceTier\s*\?\s*paneGlance\([^)]+\)\s*:\s*html`<section class="chat-scroll"/,+ "presentation changes must not destroy the element that owns scrollTop",);});-test("a forced transcript scroll bypasses the smooth scroll-behavior (snaps instantly)", () => {- const fn = chat.match(/function scrollTranscript\(force = false\): void \{[\s\S]*?\n {2}\}/)?.[0] ?? "";- const setAuto = fn.indexOf('scroller.style.scrollBehavior = "auto"');- const write = fn.indexOf("scroller.scrollTop = scroller.scrollHeight");- assert.ok(setAuto >= 0, "forced path must set scroll-behavior:auto");- assert.ok(write > setAuto, "the snap write must come after behavior is set to auto");+test("hidden panes retain their last meaningful density", () => {+ const fn = split.match(/private syncDensity\(\): void \{[\s\S]*?\n {2}\}/)?.[0] ?? "";+ assert.match(fn, /if \(!next\s*\|\|\s*next === this\.density\) return;/);});