@@ -26,6 +26,12 @@ let browser: Browser;
2626let controlUi : ControlUiE2eServer ;
2727const contexts = new Set < BrowserContext > ( ) ;
2828
29+ type TranscriptGeometry = {
30+ width : number ;
31+ rowGap : number ;
32+ assistantUserGap : number ;
33+ } ;
34+
2935function boardSnapshot ( chatDock : "right" | "hidden" , revision = 1 ) {
3036 return {
3137 sessionKey,
@@ -58,6 +64,43 @@ async function visibleTranscriptState(page: Page) {
5864 } ) ;
5965}
6066
67+ async function firstSidebarResizeFrame ( page : Page , resize : ( ) => Promise < void > ) {
68+ const firstFrame = page . evaluate (
69+ ( ) =>
70+ new Promise < TranscriptGeometry > ( ( resolve , reject ) => {
71+ const panel = document . querySelector < HTMLElement > ( ".side-panel" ) ;
72+ if ( ! panel ) {
73+ throw new Error ( "Board chat side panel is missing" ) ;
74+ }
75+ const observer = new MutationObserver ( ( ) => {
76+ observer . disconnect ( ) ;
77+ requestAnimationFrame ( ( ) => {
78+ const [ assistantRow , userRow ] =
79+ panel . querySelectorAll < HTMLElement > ( ".chat-virtual-row" ) ;
80+ const assistant = assistantRow ?. querySelector < HTMLElement > (
81+ ".chat-group.assistant .chat-text" ,
82+ ) ;
83+ const user = userRow ?. querySelector < HTMLElement > ( ".chat-group.user .chat-bubble" ) ;
84+ if ( ! assistantRow || ! userRow || ! assistant || ! user ) {
85+ reject ( new Error ( "Adjacent assistant and user transcript rows are missing" ) ) ;
86+ return ;
87+ }
88+ resolve ( {
89+ width : panel . getBoundingClientRect ( ) . width ,
90+ rowGap :
91+ userRow . getBoundingClientRect ( ) . top - assistantRow . getBoundingClientRect ( ) . bottom ,
92+ assistantUserGap :
93+ user . getBoundingClientRect ( ) . top - assistant . getBoundingClientRect ( ) . bottom ,
94+ } ) ;
95+ } ) ;
96+ } ) ;
97+ observer . observe ( panel , { attributes : true , attributeFilter : [ "style" ] } ) ;
98+ } ) ,
99+ ) ;
100+ await resize ( ) ;
101+ return await firstFrame ;
102+ }
103+
61104async function showDashboard ( page : Page ) {
62105 const settingsKey = controlUiBundledSettingsStorageKey ( controlUi . baseUrl ) ;
63106 await page . addInitScript (
@@ -161,6 +204,69 @@ describeControlUiE2e("Board split transcript restore", () => {
161204 . waitFor ( { state : "visible" , timeout : 2_000 } ) ;
162205 } , 120_000 ) ;
163206
207+ it ( "keeps adjacent Board chat rows separated throughout a real side-panel resize" , async ( ) => {
208+ const context = await browser . newContext ( { viewport : { width : 1720 , height : 1250 } } ) ;
209+ contexts . add ( context ) ;
210+ try {
211+ const page = await context . newPage ( ) ;
212+ const now = Date . now ( ) ;
213+ await installMockGateway ( page , {
214+ sessionKey,
215+ featureMethods : [ "board.get" , "chat.history" , "chat.metadata" , "chat.startup" ] ,
216+ methodResponses : { "board.get" : boardSnapshot ( "right" ) } ,
217+ historyMessages : [
218+ {
219+ role : "assistant" ,
220+ content :
221+ "Created **Project Board** with a full-screen four-column dashboard:\n\n- Working\n- Idle\n- Review\n- Complete\n\nThe board can refresh active work and show a concise operator summary.\n\nSource: [project-board.html](project-board.html)\n\n" +
222+ "Keep the work board visible while tracking active sessions, reviews, approvals, and completed tasks. " . repeat (
223+ 8 ,
224+ ) ,
225+ timestamp : now - 1 ,
226+ } ,
227+ {
228+ role : "user" ,
229+ content : "Please use the existing work board feature." ,
230+ timestamp : now ,
231+ } ,
232+ ] ,
233+ } ) ;
234+
235+ await showDashboard ( page ) ;
236+ const sidePanel = page . locator ( ".side-panel" ) ;
237+ await page . getByText ( "Source: project-board.html" , { exact : false } ) . waitFor ( ) ;
238+ await page . getByText ( "Please use the existing work board feature." ) . waitFor ( ) ;
239+ const initialWidth = await sidePanel . evaluate (
240+ ( element ) => element . getBoundingClientRect ( ) . width ,
241+ ) ;
242+
243+ const divider = page . getByRole ( "separator" , { name : "Resize side panel" } ) ;
244+ const dividerBounds = await divider . boundingBox ( ) ;
245+ expect ( dividerBounds ) . not . toBeNull ( ) ;
246+ const startX = dividerBounds ! . x + dividerBounds ! . width / 2 ;
247+ const pointerY = dividerBounds ! . y + Math . min ( 80 , dividerBounds ! . height / 2 ) ;
248+ await page . mouse . move ( startX , pointerY ) ;
249+ await page . mouse . down ( ) ;
250+ const frame = await firstSidebarResizeFrame ( page , ( ) =>
251+ page . mouse . move ( startX + 64 , pointerY ) ,
252+ ) ;
253+ await page . mouse . up ( ) ;
254+
255+ expect ( frame . width ) . toBeLessThan ( initialWidth ) ;
256+ expect (
257+ frame . rowGap ,
258+ `first frame width=${ frame . width } px; assistant-to-user gap=${ frame . assistantUserGap } px` ,
259+ ) . toBeGreaterThanOrEqual ( 0 ) ;
260+ expect (
261+ frame . assistantUserGap ,
262+ `assistant text overlaps the user bubble at width=${ frame . width } px` ,
263+ ) . toBeGreaterThanOrEqual ( 0 ) ;
264+ } finally {
265+ contexts . delete ( context ) ;
266+ await context . close ( ) ;
267+ }
268+ } , 120_000 ) ;
269+
164270 it ( "closes and reopens the whole multi-tab dashboard side panel" , async ( ) => {
165271 const context = await browser . newContext ( { viewport : { width : 1400 , height : 900 } } ) ;
166272 contexts . add ( context ) ;
0 commit comments