okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
85269ca15
main
1/** 2* Scripted UI flows for verification screenshots. 3* 4* node scripts/flow.mjs chat|expert|setup|serving|light 5*/ 6import { chromium } from 'playwright-core' ; 7import { existsSync , mkdirSync } from 'node:fs' ; 8import { join , resolve } from 'node:path' ; 9import { homedir } from 'node:os' ; 10import { requireChromium } from './browser.mjs' ; 11 12const executablePath = requireChromium (); 13 14const BASE = process . env . STRATA_URL ?? 'http://localhost:5199' ; 15const flow = process . argv [ 2 ] ?? 'chat' ; 16const shots = resolve ( '.shots' ); 17mkdirSync ( shots , { recursive :true }); 18 19const browser = await chromium . launch ({ executablePath, args :[ '--no-sandbox' , '--disable-gpu' ] }); 20const page = await browser . newPage ({ viewport :{ width :1512 , height :1110 }, deviceScaleFactor :1 }); 21 22const problems = []; 23 24/** 25* A flow that deliberately breaks something — aborting a request to exercise a 26* failure path — would otherwise report its own instrumentation as a problem. 27* Flows declare the failures they intend; anything else is still a problem. 28*/ 29const expectedFailures = []; 30const expectFailure = ( pattern ) => expectedFailures . push ( pattern ); 31 32page . on ( 'pageerror' , ( e ) => problems . push ( `pageerror: ${ e . message } ` )); 33page . on ( 'console' , ( m ) => { 34if ( m . type () !== 'error' ) return ; 35const text = m . text (); 36if ( expectedFailures . some (( re ) => re . test ( text ))) return ; 37problems . push ( `console: ${ text } ` ); 38}); 39 40const shot = async ( name ) => { 41await page . screenshot ({ path :join ( shots , ` ${ name } .png` ) }); 42console . log ( join ( shots , ` ${ name } .png` )); 43}; 44 45await page . goto ( ` ${ BASE } /#/launch` , { waitUntil :'domcontentloaded' }); 46await page . waitForTimeout ( 1200 ); 47 48if ( flow === 'chat' ) { 49await page . click ( 'text=New conversation' ); 50await page . waitForTimeout ( 500 ); 51await page . fill ( 'textarea' , 'Explain what a KV cache does, in plain words' ); 52await page . waitForTimeout ( 200 ); 53await page . keyboard . press ( 'Enter' ); 54await page . waitForTimeout ( 2600 ); 55await shot ( '20-chat-streaming' ); 56await page . waitForTimeout ( 6000 ); 57await shot ( '21-chat-done' ); 58await page . goto ( ` ${ BASE } /#/monitor` , { waitUntil :'domcontentloaded' }); 59await page . waitForTimeout ( 1600 ); 60await shot ( '22-monitor-after-chat' ); 61await page . goto ( ` ${ BASE } /#/serving` , { waitUntil :'domcontentloaded' }); 62await page . waitForTimeout ( 1400 ); 63await shot ( '23-serving-with-requests' ); 64} 65 66if ( flow === 'expert' ) { 67await page . goto ( ` ${ BASE } /#/tuning` , { waitUntil :'domcontentloaded' }); 68await page . waitForTimeout ( 900 ); 69/* The mode control is `.st-tab`, not `.seg__btn` — the flow kept the older 70class and had been failing on a selector that no longer existed. */ 71await page . click ( '.st-tab:has-text("Expert")' ); 72await page . waitForTimeout ( 900 ); 73await shot ( '30-tuning-expert' ); 74await page . fill ( 'input[placeholder="Search parameters"]' , 'cache' ); 75await page . waitForTimeout ( 600 ); 76await shot ( '31-tuning-expert-search' ); 77await page . click ( '.st-tab:has-text("Raw")' ); 78await page . waitForTimeout ( 600 ); 79await shot ( '32-tuning-raw' ); 80} 81 82if ( flow === 'expert-light' ) { 83await page . goto ( ` ${ BASE } /#/tuning` , { waitUntil :'domcontentloaded' }); 84await page . waitForTimeout ( 1200 ); 85await page . click ( '.st-tab:has-text("Expert")' ); 86await page . waitForTimeout ( 800 ); 87await shot ( '98-expert-light' ); 88} 89 90if ( flow === 'setup' ) { 91const next = () => page . getByRole ( 'button' , { name :'Continue' , exact :true }). first (); 92await page . goto ( ` ${ BASE } /#/setup` , { waitUntil :'domcontentloaded' }); 93await page . waitForTimeout ( 1800 ); 94await shot ( '40-setup-1-check' ); 95/* The wizard only offers "Continue" while it is still being worked through. 96Once setup is complete the host says so and the screen shows the finished 97path instead — so this flow reports that rather than timing out on a button 98that is correctly absent. */ 99const state = await page . evaluate ( async () => { 100const r = await fetch ( '/api/setup' ). then (( x ) => x . json ()); 101return { complete :r . complete }; 102}); 103if ( state . complete ) { 104console . log ( 'setup is already complete on this host — the wizard shows its finished path.' ); 105console . log ( 'The mid-wizard steps are not reachable without resetting it; see plan 09.' ); 106await browser . close (); 107process . exit ( 0 ); 108} 109await next (). click (); 110await page . waitForTimeout ( 900 ); 111await shot ( '41-setup-2-model' ); 112await page . getByText ( 'Qwen · Q2_K' , { exact :true }). first (). click (); 113await page . waitForTimeout ( 400 ); 114await next (). click (); 115await page . waitForTimeout ( 800 ); 116await shot ( '42-setup-3-basics' ); 117await page . getByRole ( 'button' , { name :/ Download & install / }). click (); 118await page . waitForTimeout ( 3400 ); 119await shot ( '43-setup-4-install' ); 120await page . waitForTimeout ( 17000 ); 121await shot ( '44-setup-4-done' ); 122} 123 124if ( flow === 'tools' ) { 125await page . click ( 'text=New conversation' ); 126await page . waitForTimeout ( 500 ); 127await page . fill ( 'textarea' , 'Read the README in this workspace and summarise it for me' ); 128await page . keyboard . press ( 'Enter' ); 129await page . waitForTimeout ( 3200 ); 130await shot ( '70-tool-approval' ); 131await page . keyboard . press ( 'Enter' ); 132await page . waitForTimeout ( 700 ); 133await shot ( '71-tool-approved' ); 134await page . waitForTimeout ( 6000 ); 135await shot ( '72-tool-answered' ); 136} 137 138if ( flow === 'readysummary' ) { 139await page . goto ( ` ${ BASE } /#/settings` , { waitUntil :'domcontentloaded' }); 140await page . waitForTimeout ( 2300 ); 141await page . click ( 'text=Run setup again' ); 142await page . waitForTimeout ( 2500 ); 143const here = await page . evaluate (() => document . querySelector ( '.step[aria-current]' )?. textContent . replace ( / \s +/ g , ' ' ). trim ()); 144console . log ( 'wizard opens at:' , here ); 145 146const out = await page . evaluate (() => { 147const grids = [ ...document . querySelectorAll ( '.setupmodal__surface .metricgrid' )]; 148const grid = grids [ grids . length - 1 ]; 149if ( ! grid ) return null ; 150const cards = [ ...grid . querySelectorAll ( '.st-metric' )]; 151const tops = cards . map (( m ) => Math . round ( m . closest ( '.st-card' ). getBoundingClientRect (). top )); 152const perRow = {}; 153tops . forEach (( t ) => { perRow [ t ] = ( perRow [ t ] ?? 0 ) + 1 ; }); 154return { 155items :cards . map (( m ) => ({ 156label :m . querySelector ( '.st-metric__label' )?. textContent . trim (), 157value :m . querySelector ( '.st-metric__value' )?. textContent . trim (), 158sub :m . querySelector ( '.spec__sub' )?. textContent . trim (), 159})), 160perRow :Object . values ( perRow ), 161}; 162}); 163if ( ! out ) { console . log ( 'summary not found' ); } 164else { 165out . items . forEach (( c ) => console . log ( ` ${ String ( c . label ). padEnd ( 14 )} ${ String ( c . value ). padEnd ( 22 )} ${ c . sub ?? '' } ` )); 166const ctx = out . items . find (( c ) => c . label === 'Context' ); 167const api = out . items . find (( c ) => c . label === 'Local API' ); 168console . log ( 'context shows a size, not a choice:' , / ^\d + K$ / i . test ( ctx ?. value ?? '' ), '<- it said "Recommended"' ); 169console . log ( 'local API leads with plain meaning:' , api ?. value === 'On this computer' , '<- it said "127.0.0.1"' ); 170console . log ( 'cards per row :' , JSON . stringify ( out . perRow ), 171out . perRow . every (( n ) => n === out . perRow [ 0 ]) ?'(balanced)' :'(one orphaned)' ); 172} 173await shot ( '580-ready-summary' ); 174} 175 176if ( flow === 'addskill' ) { 177const calls = []; 178await page . route ( '**/api/skills/add' , ( r ) => { 179calls . push ( r . request (). method ()); 180return r . fulfill ({ status :200 , contentType :'application/json' , body :JSON . stringify ({ cancelled :true }) }); 181}); 182await page . goto ( ` ${ BASE } /#/skills` , { waitUntil :'domcontentloaded' }); 183await page . waitForTimeout ( 1800 ); 184 185await page . fill ( 'input[placeholder="Search skills"]' , 'commit' ); 186await page . waitForTimeout ( 400 ); 187const typed = await page . inputValue ( 'input[placeholder="Search skills"]' ); 188await page . click ( 'text=Add from folder' ); 189await page . waitForTimeout ( 1100 ); 190const after = await page . inputValue ( 'input[placeholder="Search skills"]' ); 191console . log ( 'search box untouched:' , after === typed , '<- the button used to clear it, and do nothing else' ); 192console . log ( 'asks the host to add:' , calls . length === 1 , `( ${ calls [ 0 ] ?? 'no' } request)` ); 193 194const titles = await page . evaluate (() => 195[ ...document . querySelectorAll ( '.st-tab' )]. slice ( 0 , 3 ). map (( t ) => ` ${ t . textContent } — ${ t . title } ` )); 196console . log ( 'scope options now say:' ); 197titles . forEach (( t ) => console . log ( ' ' , t )); 198console . log ( '"Here" names the workspace:' , / design-iteration | workspace / . test ( titles [ 1 ] ?? '' ), '<- it said only "Here"' ); 199await shot ( '570-add-from-folder' ); 200} 201 202if ( flow === 'filepreview' ) { 203await page . goto ( ` ${ BASE } /#/workspace` , { waitUntil :'domcontentloaded' }); 204await page . waitForTimeout ( 1800 ); 205await page . evaluate (() => { 206const file = [ ...document . querySelectorAll ( '.treerow' )]. find (( r ) => r . dataset . kind === 'file' ); 207file ?. click (); 208}); 209await page . waitForTimeout ( 1300 ); 210 211const read = () => page . evaluate (() => { 212const el = document . querySelector ( '.filepreview__body' ); 213if ( ! el ) return null ; 214const parse = ( c ) => { const n = String ( c ). match ( / [ \d . ] +/ g ); return n ?{ r :+ n [ 0 ], g :+ n [ 1 ], b :+ n [ 2 ], a :n [ 3 ] === undefined ?1 :+ n [ 3 ] } :null ; }; 215const lum = ({ r, g, b}) => { const f = ( v ) => { v /= 255 ; return v <= 0.03928 ?v / 12.92 :(( v + 0.055 ) / 1.055 ) ** 2.4 ; }; return 0.2126 * f ( r ) + 0.7152 * f ( g ) + 0.0722 * f ( b ); }; 216const ratio = ( a , b ) => { const [ hi , lo ] = [ lum ( a ), lum ( b )]. sort (( x , y ) => y - x ); return Number ((( hi + 0.05 ) / ( lo + 0.05 )). toFixed ( 2 )); }; 217const cs = getComputedStyle ( el ); 218let bg = null ; 219let n = el ; 220while ( n ) { const c = parse ( getComputedStyle ( n ). backgroundColor ); if ( c && c . a > 0.9 ) { bg = c ; break ; } n = n . parentElement ; } 221return { 222ratio :ratio ( parse ( cs . color ), bg ), 223overflowX :cs . overflowX , 224clipped :el . scrollWidth - el . clientWidth , 225scrollable :el . scrollWidth > el . clientWidth && cs . overflowX !== 'hidden' , 226lines :el . textContent . split ( '\n' ). length , 227longest :Math . max ( ...el . textContent . split ( '\n' ). map (( l ) => l . length )), 228}; 229}); 230 231const before = await read (); 232console . log ( 'contrast :' , before . ratio , '(needs 4.5) <- it was #303030 on #1b1f23, a ratio of 1.26' ); 233console . log ( 'lines / longest :' , before . lines , '/' , before . longest , 'chars' ); 234console . log ( 'overflows by :' , before . clipped + 'px' ); 235console . log ( 'can be reached :' , before . scrollable , '<- overflow was hidden, so the rest of every long line was unreachable' ); 236 237await page . evaluate (() => { document . querySelector ( '.filepreview__body' ). scrollLeft = 300 ; }); 238await page . waitForTimeout ( 300 ); 239const scrolled = await page . evaluate (() => document . querySelector ( '.filepreview__body' ). scrollLeft ); 240console . log ( 'scrolls :' , scrolled > 0 , `(scrollLeft ${ scrolled } )` ); 241await shot ( '560-file-preview' ); 242} 243 244if ( flow === 'endpoints' ) { 245await page . goto ( ` ${ BASE } /#/serving` , { waitUntil :'domcontentloaded' }); 246await page . waitForTimeout ( 2000 ); 247const read = () => page . evaluate (() => [ ...document . querySelectorAll ( '.compatrow' )]. map (( r ) => { 248const url = r . querySelector ( '.compatrow__url' ); 249const lines = ( el ) => { const rg = document . createRange (); rg . selectNodeContents ( el ); return rg . getClientRects (). length ; }; 250return { 251label :r . querySelector ( '.compatrow__label' ). textContent , 252url :url . textContent , 253clipped :url . scrollWidth > url . clientWidth + 1 , 254urlLines :lines ( url ), 255rowH :Math . round ( r . getBoundingClientRect (). height ), 256}; 257})); 258 259const wide = await read (); 260wide . forEach (( r ) => console . log ( ` ${ r . label . padEnd ( 22 )} ${ r . rowH } px url ${ r . urlLines } line(s) ${ r . clipped ? 'CLIPPED' : 'full' } ` )); 261console . log ( 'nothing truncated :' , wide . every (( r ) => ! r . clipped ), '<- the longest address used to end in "…/completi…"' ); 262console . log ( 'rows equal at this width:' , new Set ( wide . map (( r ) => r . rowH )). size === 1 ); 263 264const access = await page . evaluate (() => { 265const card = [ ...document . querySelectorAll ( '.grid--2 > .st-card' )]. find (( c ) => / ^Access / . test ( c . textContent . trim ())); 266const r = card . getBoundingClientRect (); 267const rows = [ ...card . querySelectorAll ( '.field, .row' )]; 268const last = Math . max ( ...rows . map (( x ) => x . getBoundingClientRect (). bottom )); 269return { cardH :Math . round ( r . height ), contentH :Math . round ( last - r . top ) }; 270}); 271console . log ( 'access card :' , access . cardH + 'px card,' , access . contentH + 'px content' , 272'<- it was 758px tall holding 260px' ); 273 274await page . click ( '.compatrow .st-btn--icon >> nth=0' ); 275await page . waitForTimeout ( 400 ); 276const copied = await page . evaluate (() => navigator . clipboard . readText (). catch (() => 'unavailable' )); 277console . log ( 'copy still returns the full url:' , copied ); 278await shot ( '550-endpoints' ); 279} 280 281if ( flow === 'contexthistory' ) { 282await page . goto ( ` ${ BASE } /#/chat` , { waitUntil :'domcontentloaded' }); 283await page . waitForTimeout ( 1500 ); 284await page . click ( 'text=New session' ); 285await page . waitForTimeout ( 400 ); 286const ctx = () => page . evaluate ( async () => { 287const m = await fetch ( '/api/monitor' ). then (( r ) => r . json ()); 288return { used :m . context . usedTokens , msgs :m . context . parts . messages , pct :Number ( m . context . pct . toFixed ( 1 )) }; 289}); 290const start = await ctx (); 291console . log ( 'start :' , JSON . stringify ( start )); 292 293let prev = start . msgs ; 294let grew = 0 ; 295for ( const msg of [ 'write a short paragraph about tides' , 'and one about the moon' , 'and one about wind' ]) { 296await page . fill ( 'textarea' , msg ); 297await page . keyboard . press ( 'Enter' ); 298await page . waitForTimeout ( 8000 ); 299await page . keyboard . press ( 'Enter' ). catch (() => {}); 300await page . waitForTimeout ( 4000 ); 301const c = await ctx (); 302const up = c . msgs > prev ; 303if ( up ) grew += 1 ; 304console . log ( `turn ${ grew + 1 } : used ${ c . used } , messages-part ${ c . msgs } ` , up ?'' :'<- NO GROWTH' ); 305prev = c . msgs ; 306} 307console . log ( 'grows with the conversation:' , grew >= 2 , '<- it sat at ~350 however long the conversation got' ); 308console . log ( 'the model receives prior turns:' , grew >= 2 , '<- history was never sent, so every message was a first message' ); 309const end = await ctx (); 310console . log ( 'used == current occupancy, not a running total:' , end . used < 32768 , `( ${ end . pct } %)` ); 311await shot ( '540-context-history' ); 312} 313 314if ( flow === 'effectpanel' ) { 315await page . goto ( ` ${ BASE } /#/tuning` , { waitUntil :'domcontentloaded' }); 316await page . waitForTimeout ( 2000 ); 317const out = await page . evaluate (() => { 318const rows = [ ...document . querySelectorAll ( '.effectrow' )]. map (( r ) => { 319const label = r . querySelector ( ':first-child' ); 320const value = r . querySelector ( ':last-child' ); 321// where does the text actually break? 322const range = document . createRange (); 323range . selectNodeContents ( value ); 324const boxes = [ ...range . getClientRects ()]. map (( b ) => Math . round ( b . width )); 325return { label :label . textContent . trim (), value :value . textContent . trim (), lines :boxes . length , widths :boxes }; 326}); 327const notes = [ ...document . querySelectorAll ( '.st-card ul li' )]. map (( li ) => li . textContent . trim ()); 328return { rows, notes, breakdown :notes . filter (( n ) => / weights / . test ( n )). length }; 329}); 330out . rows . forEach (( r ) => console . log ( ` ${ r . label . padEnd ( 16 )} ${ r . lines } line(s) ${ JSON . stringify ( r . widths )} ${ r . value } ` )); 331console . log ( 'model breakdown mentioned:' , out . breakdown , 'time(s) <- it appeared twice' ); 332console . log ( 'notes carry it once :' , out . breakdown === 1 ); 333await shot ( '530-effect-panel' ); 334} 335 336if ( flow === 'loadguard' ) { 337await page . goto ( ` ${ BASE } /#/models` , { waitUntil :'domcontentloaded' }); 338await page . waitForTimeout ( 1900 ); 339 340const rows = await page . evaluate (() => 341[ ...document . querySelectorAll ( '.listrow' )] 342. filter (( r ) => r . querySelector ( '.listrow__title' )) 343. map (( r ) => { 344const btn = r . querySelector ( '.listrow__side .st-btn' ); 345return { 346model :r . querySelector ( '.listrow__title' ). textContent . trim (). slice ( 0 , 20 ), 347verdict :[ ...r . querySelectorAll ( '.st-pill' )]. map (( x ) => x . textContent . trim ()). join ( '/' ), 348button :btn ?. textContent . trim (), 349primary :btn ?btn . className . includes ( 'primary' ) :null , 350}; 351})); 352const oversized = rows . filter (( r ) => / Too large / . test ( r . verdict )); 353console . log ( 'unusable variants :' , oversized . length ); 354console . log ( 'their button :' , JSON . stringify ( oversized . map (( r ) => r . button ))); 355console . log ( 'none is a primary action:' , oversized . every (( r ) => r . primary === false ), 356'<- a green one-click Load invited an action the app itself says cannot work' ); 357 358// clicking one must ask first, and say what will happen 359let asked = null ; 360page . on ( 'dialog' , async ( d ) => { 361asked = d . message (); 362await d . dismiss (); 363}); 364await page . evaluate (() => { 365const r = [ ...document . querySelectorAll ( '.listrow' )]. find (( x ) => / Too large / . test ( x . textContent )); 366r ?. querySelector ( '.listrow__side .st-btn' )?. click (); 367}); 368await page . waitForTimeout ( 1200 ); 369console . log ( 'asks first :' , asked !== null ); 370console . log ( 'names the cost :' , JSON . stringify ( asked ?. split ( '\n' )[ 0 ])); 371const loaded = await page . evaluate ( async () => ( await fetch ( '/api/models' ). then (( x ) => x . json ())). loaded ); 372console . log ( 'dismissing loads nothing:' , loaded === 'qwen2.5-0.5b-q4km' , `(loaded: ${ loaded } )` ); 373await shot ( '520-load-guard' ); 374} 375 376if ( flow === 'focusmode' ) { 377await page . goto ( ` ${ BASE } /#/chat` , { waitUntil :'domcontentloaded' }); 378await page . waitForTimeout ( 1500 ); 379await page . click ( 'text=New session' ); 380await page . waitForTimeout ( 400 ); 381await page . fill ( 'textarea' , 'say hello in one line' ); 382await page . keyboard . press ( 'Enter' ); 383await page . waitForTimeout ( 8000 ); 384await page . keyboard . press ( 'Enter' ). catch (() => {}); 385await page . waitForTimeout ( 4000 ); 386// A second turn, so there is an earlier exchange to recede. 387await page . fill ( 'textarea' , 'and one more line' ); 388await page . keyboard . press ( 'Enter' ); 389await page . waitForTimeout ( 8000 ); 390await page . keyboard . press ( 'Enter' ). catch (() => {}); 391await page . waitForTimeout ( 4000 ); 392 393const read = () => page . evaluate (() => { 394const g = ( sel ) => { 395const el = document . querySelector ( sel ); 396if ( ! el ) return null ; 397const r = el . getBoundingClientRect (); 398return { l :Math . round ( r . left ), r :Math . round ( r . right ), h :Math . round ( r . height ) }; 399}; 400const bubble = g ( '.st-msg--assistant .st-bubble' ); 401const composer = g ( '.st-composer' ); 402return { 403composer :composer ?. h , 404reading :Math . round ( document . querySelector ( '.main__body.chat' ). getBoundingClientRect (). height ), 405alignL :bubble && composer ?bubble . l - composer . l :null , 406alignR :bubble && composer ?composer . r - bubble . r :null , 407hints :(() => { const e = document . querySelector ( '.composer__hints' ); return e ?getComputedStyle ( e ). display :'absent' ; })(), 408icons :[ ...document . querySelectorAll ( '.st-composer__bar .st-btn--icon' )]. filter (( x ) => getComputedStyle ( x ). display !== 'none' ). length , 409telemetry :(() => { const e = document . querySelector ( '.telemetry' ); return e ?getComputedStyle ( e ). display :'absent' ; })(), 410canType :!! document . querySelector ( '.composer textarea' ), 411barKeys :[ ...document . querySelectorAll ( '.focusbar__keys > span' )]. map (( s ) => s . textContent . replace ( / \s +/ g , ' ' ). trim ()), 412exitLabel :document . querySelector ( '.focusbar button:last-of-type' )?. textContent . trim () ?? '' , 413exitTitle :document . querySelector ( '.focusbar button:last-of-type' )?. getAttribute ( 'title' ), 414}; 415}); 416 417const normal = await read (); 418console . log ( 'normal : composer' , normal . composer + 'px, reading area' , normal . reading + 'px, alignment' , normal . alignL ); 419 420await page . keyboard . press ( 'Meta+Shift+F' ); 421await page . mouse . move ( 1200 , 820 ); 422await page . waitForTimeout ( 1100 ); 423const focus = await read (); 424console . log ( 'focus : composer' , focus . composer + 'px, reading area' , focus . reading + 'px' ); 425console . log ( 'reclaimed :' , focus . reading - normal . reading , 'px for the conversation' ); 426console . log ( 'composer aligns with the cards:' , focus . alignL === 0 && focus . alignR === 0 ); 427console . log ( 'hint line :' , focus . hints , '| icon strip:' , focus . icons , 'icons | telemetry:' , focus . telemetry ); 428console . log ( 'still usable:' , focus . canType , '- the point is removing chrome, not the ability to reply' ); 429console . log ( 'keys grouped:' , JSON . stringify ( focus . barKeys )); 430console . log ( 'exit is quiet:' , focus . exitLabel === '' , '| labelled' , JSON . stringify ( focus . exitTitle )); 431 432/* Earlier turns recede — or did not, for as long as this mode has existed. 433`.st-msg` carried `animation: st-enter ... both`, and an animated value 434outranks a normal declaration, so the keyframe's closing `opacity: 1` held 435every turn at full strength. The dimming rule was in the stylesheet, 436matched the element, and lost the cascade. */ 437const opacities = await page . evaluate (() => 438[ ...document . querySelectorAll ( '.chat__inner > .st-msg' )]. map (( m ) => getComputedStyle ( m ). opacity )); 439const earlier = opacities . slice ( 0 , - 2 ); 440const current = opacities . slice ( - 2 ); 441console . log ( 'earlier turns recede :' , earlier . length > 0 && earlier . every (( o ) => Number ( o ) < 0.9 ), 442JSON . stringify ( opacities ), `( ${ opacities . length } turns)` ); 443console . log ( 'current stays full :' , current . every (( o ) => Number ( o ) > 0.9 )); 444await shot ( '510-focus-mode' ); 445} 446 447if ( flow === 'railgeometry' ) { 448await page . click ( 'text=New session' ); 449await page . waitForTimeout ( 400 ); 450await page . fill ( 'textarea' , 'read the readme' ); 451await page . keyboard . press ( 'Enter' ); 452await page . waitForTimeout ( 7000 ); 453await page . keyboard . press ( 'Enter' ). catch (() => {}); 454await page . waitForTimeout ( 4000 ); 455await page . evaluate (() => document . querySelector ( '.nav__collapse' )?. click ()); 456await page . mouse . move ( 900 , 700 ); 457await page . waitForTimeout ( 800 ); 458 459const out = await page . evaluate (() => { 460const nav = document . querySelector ( '.nav' ); 461const right = nav . getBoundingClientRect (). right ; 462const items = [ ...nav . querySelectorAll ( 'button, a, .navsession, .ws__name, .nav__brand' )] 463. filter (( el ) => { const r = el . getBoundingClientRect (); return r . width > 0 && r . height > 0 ; }); 464// text actually painted, not merely present in the DOM 465const painted = ( el ) => [ ...el . querySelectorAll ( '*' )]. some (( c ) => 466! c . children . length && getComputedStyle ( c ). display !== 'none' && 467c . getBoundingClientRect (). width > 6 && c . textContent . trim ()); 468return { 469items :items . length , 470overflowing :items . filter (( el ) => el . getBoundingClientRect (). right > right + 0.5 ). length , 471clippedText :items . filter ( painted ). length , 472sizes :[ ...new Set ( items . map (( el ) => { 473const r = el . getBoundingClientRect (); 474return ` ${ Math . round ( r . width )} x ${ Math . round ( r . height )} ` ; 475}))], 476unlabelled :items . filter (( el ) => el . querySelector ( 'svg' ) && 477! ( el . getAttribute ( 'title' ) || el . getAttribute ( 'aria-label' ) || el . textContent . trim ())). length , 478}; 479}); 480console . log ( 'items :' , out . items ); 481console . log ( 'clipped text :' , out . clippedText , '<- a conversation used to render as the first 5px of its title' ); 482console . log ( 'overflowing the rail:' , out . overflowing , '<- the 22px tree indent pushed a session past the edge' ); 483console . log ( 'target sizes :' , JSON . stringify ( out . sizes )); 484console . log ( 'icons with no label:' , out . unlabelled ); 485await shot ( '500-rail-geometry' ); 486} 487 488if ( flow === 'archive' ) { 489for ( const m of [ 'keep me' , 'archive me' ]) { 490await page . click ( 'text=New session' ); 491await page . waitForTimeout ( 400 ); 492await page . fill ( 'textarea' , m ); 493await page . keyboard . press ( 'Enter' ); 494await page . waitForTimeout ( 7000 ); 495await page . keyboard . press ( 'Enter' ). catch (() => {}); 496await page . waitForTimeout ( 3200 ); 497} 498const rows = () => page . evaluate (() => 499[ ...document . querySelectorAll ( '.navsession__title' )]. map (( t ) => t . textContent )); 500console . log ( 'before :' , JSON . stringify ( await rows ())); 501 502await page . click ( '.navsession >> nth=0' , { button :'right' }); 503await page . waitForTimeout ( 500 ); 504console . log ( 'menu :' , JSON . stringify ( await page . evaluate (() => 505[ ...document . querySelectorAll ( '.menu__item' )]. map (( i ) => i . textContent . trim ())))); 506await page . click ( '.menu__item:has-text("Archive")' ); 507await page . waitForTimeout ( 700 ); 508console . log ( 'after archive :' , JSON . stringify ( await rows ()), '<- leaves the list, nothing deleted' ); 509 510// the search field is behind its own toggle, so open it the way the sidebar does 511await page . evaluate (() => { 512const b = [ ...document . querySelectorAll ( 'button' )] 513. find (( x ) => / search / i . test ( x . getAttribute ( 'title' ) ?? x . getAttribute ( 'aria-label' ) ?? '' )); 514b ?. click (); 515}); 516await page . waitForTimeout ( 500 ); 517await page . fill ( 'input[placeholder="Search conversations"]' , 'archive me' ); 518await page . waitForTimeout ( 700 ); 519console . log ( 'found by search:' , JSON . stringify ( await rows ()), '<- archived stays findable' ); 520await shot ( '490-archive' ); 521} 522 523if ( flow === 'aboutengine' ) { 524await page . goto ( ` ${ BASE } /#/settings` , { waitUntil :'domcontentloaded' }); 525await page . waitForTimeout ( 2100 ); 526const metrics = await page . evaluate (() => 527[ ...document . querySelectorAll ( '.settings-body .st-metric' )] 528. map (( m ) => ({ 529label :m . querySelector ( '.st-metric__label' )?. textContent . trim (), 530value :m . querySelector ( '.st-metric__value' )?. textContent . trim (), 531sub :m . querySelector ( '.spec__sub' )?. textContent . trim (), 532})) 533. filter (( m ) => m . label )); 534metrics . forEach (( m ) => console . log ( ` ${ String ( m . label ). padEnd ( 14 )} ${ String ( m . value ). padEnd ( 10 )} ${ m . sub ?? '' } ` )); 535const engine = metrics . find (( m ) => m . label === 'Engine' ); 536console . log ( 'engine named :' , !! engine , '<- the one thing About was missing' ); 537console . log ( 'with its backend:' , / metal | vulkan | cuda | cpu / . test ( engine ?. sub ?? '' )); 538// folder paths belong to Storage, not duplicated here 539console . log ( 'no duplicated paths:' , ! metrics . some (( m ) => / folder / i . test ( m . label ))); 540await shot ( '480-about-engine' ); 541} 542 543if ( flow === 'rowweight' ) { 544await page . goto ( ` ${ BASE } /#/models` , { waitUntil :'domcontentloaded' }); 545await page . waitForTimeout ( 1900 ); 546const rows = await page . evaluate (() => 547[ ...document . querySelectorAll ( '.listrow' )] 548. filter (( r ) => r . querySelector ( '.listrow__title' )) 549. map (( r ) => ({ 550title :r . querySelector ( '.listrow__title' ). textContent . trim (). slice ( 0 , 22 ), 551rec :r . hasAttribute ( 'data-recommended' ), 552size :getComputedStyle ( r . querySelector ( '.listrow__title' )). fontSize , 553edge :getComputedStyle ( r , '::after' ). width , 554separator :getComputedStyle ( r , '::before' ). height , 555}))); 556const rec = rows . find (( r ) => r . rec ); 557const rest = rows . filter (( r ) => ! r . rec ); 558console . log ( 'recommended row :' , JSON . stringify ( rec )); 559console . log ( 'one step larger :' , rec && rest . every (( r ) => parseFloat ( rec . size ) > parseFloat ( r . size ))); 560console . log ( 'accent edge only on it:' , rec ?. edge === '2px' && rest . every (( r ) => r . edge === 'auto' )); 561console . log ( 'separator intact :' , rows . every (( r ) => r . separator === '1px' ), '<- the edge uses ::after, so ::before keeps the separator' ); 562await shot ( '470-model-weight' ); 563} 564 565if ( flow === 'dismissal' ) { 566// Needs a transcript with room to scroll, or "scroll" tests nothing. 567const tall = await browser . newPage ({ viewport :{ width :1512 , height :560 }, deviceScaleFactor :1 }); 568await tall . goto ( ` ${ BASE } /#/chat` , { waitUntil :'domcontentloaded' }); 569await tall . waitForTimeout ( 1500 ); 570await tall . click ( 'text=New session' ); 571await tall . waitForTimeout ( 400 ); 572for ( const m of [ 'write a paragraph about tides' , 'and another about the moon' ]) { 573await tall . fill ( 'textarea' , m ); 574await tall . keyboard . press ( 'Enter' ); 575await tall . waitForTimeout ( 7500 ); 576await tall . keyboard . press ( 'Enter' ). catch (() => {}); 577await tall . waitForTimeout ( 3200 ); 578} 579const room = await tall . evaluate (() => { 580const el = document . querySelector ( '.main__body.chat' ); 581return el . scrollHeight - el . clientHeight ; 582}); 583console . log ( 'scroll room :' , room , 'px (needed, or the scroll test proves nothing)' ); 584 585const isOpen = ( kind ) => tall . evaluate (( k ) => 586k === 'telepop' ?!! document . querySelector ( '.telepop' ) :!! document . querySelector ( '.modal[data-open="true"]' ), kind ); 587const blur = () => tall . evaluate (() => document . activeElement ?. blur ()); 588 589for ( const [ name , open ] of [ 590[ 'palette' , async () => { await blur (); await tall . keyboard . press ( 'Meta+k' ); }], 591[ 'shortcuts' , async () => { await blur (); await tall . keyboard . press ( '?' ); }], 592[ 'telepop' , async () => { await tall . click ( '.telemetry__chip >> nth=0' ); }], 593]) { 594const out = []; 595for ( const [ how , act ] of [ 596[ 'esc' , async () => { await blur (); await tall . keyboard . press ( 'Escape' ); }], 597[ 'outside' , async () => { await tall . mouse . click ( 200 , 300 ); }], 598[ 'scroll' , async () => { 599// upward: the transcript starts pinned to the bottom, so adding to 600// scrollTop clamps to nothing and no scroll event fires 601await tall . evaluate (() => { 602const el = document . querySelector ( '.main__body.chat' ); 603el . scrollTop = Math . max ( 0 , el . scrollTop - 150 ); 604}); 605}], 606]) { 607await open (); 608await tall . waitForTimeout ( 550 ); 609if ( ! ( await isOpen ( name ))) { out . push ( ` ${ how } : N/A` ); continue ; } 610await act (); 611await tall . waitForTimeout ( 500 ); 612out . push ( ` ${ how } : ${( await isOpen ( name )) ? 'stays' : 'closes' } ` ); 613} 614console . log ( ` ${ name . padEnd ( 10 )} : ${ out . join ( ' | ' )} ` ); 615await tall . keyboard . press ( 'Escape' ); 616await tall . waitForTimeout ( 300 ); 617} 618console . log ( 'rule: anchored overlays leave with their content; unanchored ones ignore scroll' ); 619await tall . screenshot ({ path :'.shots/460-dismissal.png' }); 620await tall . close (); 621} 622 623if ( flow === 'railweight' ) { 624await page . click ( 'text=New session' ); 625await page . waitForTimeout ( 400 ); 626await page . fill ( 'textarea' , 'say hello' ); 627await page . keyboard . press ( 'Enter' ); 628await page . waitForTimeout ( 7000 ); 629await page . keyboard . press ( 'Enter' ). catch (() => {}); 630await page . waitForTimeout ( 3500 ); 631await page . click ( 'button[title="Conversation context"]' ); 632await page . waitForTimeout ( 800 ); 633 634const out = await page . evaluate (() => { 635const sec = document . querySelector ( '.railsection' ); 636const cs = getComputedStyle ( sec ); 637const body = document . querySelector ( '.contextpanel__body' )?. innerText ?? '' ; 638return { 639sectionIsQuiet :cs . backgroundColor === 'rgba(0, 0, 0, 0)' && cs . boxShadow === 'none' , 640panelIsOneSurface :getComputedStyle ( document . querySelector ( '.contextpanel' )). backgroundColor !== 'rgba(0, 0, 0, 0)' , 641heads :[ ...document . querySelectorAll ( '.railsection .h4' )]. map (( h ) => h . textContent . trim ()), 642contextWindowMentions :( body . match ( / Context window / g ) ?? []). length , 643}; 644}); 645console . log ( 'sections are quiet :' , out . sectionIsQuiet , '(no fill, no shadow)' ); 646console . log ( 'the rail is one object:' , out . panelIsOneSurface ); 647console . log ( 'section heads :' , JSON . stringify ( out . heads )); 648console . log ( 'no repeated heading :' , out . contextWindowMentions === 1 , '<- read "Context window / Context window / 6%" before' ); 649await shot ( '450-rail-weight' ); 650} 651 652if ( flow === 'skillscope' ) { 653await page . goto ( ` ${ BASE } /#/skills` , { waitUntil :'domcontentloaded' }); 654await page . waitForTimeout ( 1900 ); 655const read = () => page . evaluate (() => 656[ ...document . querySelectorAll ( '.listrow' )]. map (( r ) => ({ 657name :r . querySelector ( '.listrow__title' )?. textContent . slice ( 0 , 18 ), 658where :r . querySelector ( '.skillScope__where' )?. textContent . trim () ?? null , 659}))); 660console . log ( 'at rest :' , JSON . stringify ( await read ())); 661 662// narrow the first skill to this workspace, through the control 663await page . evaluate (() => { 664const row = document . querySelector ( '.listrow' ); 665const here = [ ...row . querySelectorAll ( '.skillScope button' )]. find (( b ) => / Here / . test ( b . textContent )); 666here ?. click (); 667}); 668await page . waitForTimeout ( 900 ); 669const scoped = await read (); 670console . log ( 'after Here :' , JSON . stringify ( scoped [ 0 ]), '<- narrowed' ); 671 672// the host should honour it: fires here, not elsewhere 673await page . evaluate ( async () => { 674await fetch ( '/api/chat/stream' , { 675method :'POST' , 676headers :{ 'content-type' :'application/json' }, 677body :JSON . stringify ({ message :'write a commit message for these changes' , workspaceId :'root' }), 678}); 679}); 680await page . waitForTimeout ( 2500 ); 681const here = await page . evaluate ( async () => { 682const r = await fetch ( '/api/skills' ). then (( x ) => x . json ()); 683return r [ 0 ]. useCount ; 684}); 685await page . evaluate ( async () => { 686await fetch ( '/api/chat/stream' , { 687method :'POST' , 688headers :{ 'content-type' :'application/json' }, 689body :JSON . stringify ({ message :'write a commit message for these changes' , workspaceId :'elsewhere' }), 690}); 691}); 692await page . waitForTimeout ( 2500 ); 693const elsewhere = await page . evaluate ( async () => { 694const r = await fetch ( '/api/skills' ). then (( x ) => x . json ()); 695return r [ 0 ]. useCount ; 696}); 697console . log ( 'fires in its workspace :' , here ); 698console . log ( 'silent in another :' , elsewhere === here ); 699 700// widen again so the flow leaves no trace 701await page . evaluate (() => { 702const row = document . querySelector ( '.listrow' ); 703const always = [ ...row . querySelectorAll ( '.skillScope button' )]. find (( b ) => / Always / . test ( b . textContent )); 704always ?. click (); 705}); 706await page . waitForTimeout ( 900 ); 707console . log ( 'restored :' , JSON . stringify (( await read ())[ 0 ])); 708await shot ( '440-skill-scope' ); 709} 710 711if ( flow === 'turnnav' ) { 712const tall = await browser . newPage ({ viewport :{ width :1512 , height :640 }, deviceScaleFactor :1 }); 713await tall . goto ( ` ${ BASE } /#/chat` , { waitUntil :'domcontentloaded' }); 714await tall . waitForTimeout ( 1500 ); 715await tall . click ( 'text=New session' ); 716await tall . waitForTimeout ( 400 ); 717for ( const m of [ 'first question about tides' , 'second question about the moon' , 'third question about wind' ]) { 718await tall . fill ( 'textarea' , m ); 719await tall . keyboard . press ( 'Enter' ); 720await tall . waitForTimeout ( 7500 ); 721await tall . keyboard . press ( 'Enter' ). catch (() => {}); 722await tall . waitForTimeout ( 3200 ); 723} 724await tall . keyboard . press ( 'Meta+Shift+F' ); 725await tall . waitForTimeout ( 800 ); 726console . log ( 'focus bar :' , await tall . evaluate (() => !! document . querySelector ( '.focusbar' ))); 727console . log ( 'keys taught:' , await tall . evaluate (() => 728document . querySelector ( '.focusbar__keys' )?. textContent . replace ( / \s +/ g , ' ' ). trim ())); 729 730const pos = () => tall . evaluate (() => Math . round ( document . querySelector ( '.main__body.chat' ). scrollTop )); 731await tall . evaluate (() => { document . querySelector ( '.main__body.chat' ). scrollTop = 0 ; }); 732await tall . waitForTimeout ( 600 ); 733const down = [ await pos ()]; 734for ( let i = 0 ; i < 4 ; i += 1 ) { 735await tall . keyboard . press ( 'Alt+ArrowDown' ); 736await tall . waitForTimeout ( 750 ); 737down . push ( await pos ()); 738} 739console . log ( 'Alt+Down :' , JSON . stringify ( down )); 740console . log ( 'distinct :' , new Set ( down ). size , 'of' , down . length , '<- every press advances, none stick' ); 741const up = []; 742for ( let i = 0 ; i < 2 ; i += 1 ) { 743await tall . keyboard . press ( 'Alt+ArrowUp' ); 744await tall . waitForTimeout ( 750 ); 745up . push ( await pos ()); 746} 747console . log ( 'Alt+Up :' , JSON . stringify ( up ), '<- retreats' ); 748await tall . keyboard . press ( 'Meta+ArrowDown' ); 749await tall . waitForTimeout ( 1000 ); 750console . log ( 'Cmd+Down : gap' , await tall . evaluate (() => { 751const el = document . querySelector ( '.main__body.chat' ); 752return Math . round ( el . scrollHeight - el . scrollTop - el . clientHeight ); 753}), '<- ~0' ); 754await tall . screenshot ({ path :'.shots/430-focus-turns.png' }); 755await tall . close (); 756} 757 758if ( flow === 'herorest' ) { 759await page . goto ( ` ${ BASE } /#/monitor` , { waitUntil :'domcontentloaded' }); 760await page . waitForTimeout ( 1900 ); 761const idle = await page . evaluate (() => { 762const rest = document . querySelector ( '.herorest' ); 763return { 764resting :!! rest , 765figures :rest 766 ?[ ...rest . querySelectorAll ( '.eyebrow' )]. map (( e , i ) => 767` ${ e . textContent } : ${ rest . querySelectorAll ( '.h3' )[ i ]?. textContent . replace ( / \s +/ g , ' ' ). trim ()} ` ) 768 :[], 769/* Scoped to the hero. The page has five other progress bars — VRAM, RAM, 770temperature and two unlabelled — and an unscoped query finds those and 771reports the hero as unchanged. */ 772bar :( document . querySelector ( '.stack .st-card' )?. querySelectorAll ( '.st-progress' ). length ?? 0 ) > 0 , 773}; 774}); 775console . log ( 'idle — resting block :' , idle . resting ); 776console . log ( 'idle — figures :' , JSON . stringify ( idle . figures , null , 1 )); 777console . log ( 'idle — 0% bar gone :' , ! idle . bar ); 778 779await page . evaluate (() => { 780void fetch ( '/api/chat/stream' , { 781method :'POST' , 782headers :{ 'content-type' :'application/json' }, 783body :JSON . stringify ({ message :'write a long paragraph about the sea and the moon' }), 784}); 785}); 786await page . waitForTimeout ( 2200 ); 787const busy = await page . evaluate (() => ({ 788phase :document . querySelector ( '.stack .st-card .h2' )?. textContent , 789resting :!! document . querySelector ( '.herorest' ), 790bar :( document . querySelector ( '.stack .st-card' )?. querySelectorAll ( '.st-progress' ). length ?? 0 ) > 0 , 791label :[ ...document . querySelectorAll ( '.stack .st-card .muted' )]. map (( e ) => e . textContent )[ 0 ], 792})); 793console . log ( 'busy — phase :' , JSON . stringify ( busy . phase )); 794console . log ( 'busy — progress bar :' , busy . bar , '| labelled' , JSON . stringify ( busy . label ), '| resting hidden:' , ! busy . resting ); 795await shot ( '420-hero-rest' ); 796} 797 798if ( flow === 'sparkhover' ) { 799await page . goto ( ` ${ BASE } /#/monitor` , { waitUntil :'domcontentloaded' }); 800await page . waitForTimeout ( 1500 ); 801// give the series something to show 802await page . evaluate (() => { 803void fetch ( '/api/chat/stream' , { 804method :'POST' , 805headers :{ 'content-type' :'application/json' }, 806body :JSON . stringify ({ message :'write a long paragraph about the sea and the moon and the wind' }), 807}); 808}); 809await page . waitForTimeout ( 9000 ); 810const box = await page . evaluate (() => { 811const el = document . querySelector ( '.spark' ); 812const r = el . getBoundingClientRect (); 813return { x :Math . round ( r . x ), y :Math . round ( r . y ), w :Math . round ( r . width ), h :Math . round ( r . height ) }; 814}); 815for ( const frac of [ 0.75 , 0.9 , 0.98 ]) { 816await page . mouse . move ( box . x + box . w * frac , box . y + box . h / 2 ); 817await page . waitForTimeout ( 300 ); 818console . log ( `at ${ String ( Math . round ( frac * 100 )). padStart ( 2 )} % :` , JSON . stringify ( await page . evaluate (() => 819document . querySelector ( '.spark__readout' )?. textContent ?? 'no readout' ))); 820} 821console . log ( 'marker drawn :' , await page . evaluate (() => !! document . querySelector ( '.spark line' ))); 822await page . mouse . move ( 10 , 400 ); 823await page . waitForTimeout ( 300 ); 824console . log ( 'clears on leave:' , await page . evaluate (() => ! document . querySelector ( '.spark__readout' ))); 825await shot ( '410-spark-hover' ); 826} 827 828if ( flow === 'whythisone' ) { 829await page . goto ( ` ${ BASE } /#/models` , { waitUntil :'domcontentloaded' }); 830await page . waitForTimeout ( 1900 ); 831const out = await page . evaluate (() => { 832const why = document . querySelector ( '.whyline' ); 833return { 834recommendedPills :[ ...document . querySelectorAll ( '.st-pill' )]. filter (( x ) => / Recommended / . test ( x . textContent )). length , 835why :why ?. textContent . replace ( / \s +/ g , ' ' ). trim () ?? null , 836onRow :why ?. closest ( '.listrow' )?. querySelector ( '.listrow__title' )?. textContent . trim (). slice ( 0 , 28 ) ?? null , 837// exactly one variant is recommended, so exactly one explains itself 838whyCount :document . querySelectorAll ( '.whyline' ). length , 839}; 840}); 841console . log ( 'recommended pills:' , out . recommendedPills , '(want exactly 1)' ); 842console . log ( 'explains itself :' , JSON . stringify ( out . why )); 843console . log ( 'on which row :' , JSON . stringify ( out . onRow )); 844console . log ( 'one reason only :' , out . whyCount === 1 ); 845await shot ( '400-why-this-one' ); 846} 847 848if ( flow === 'paramgroups' ) { 849await page . goto ( ` ${ BASE } /#/tuning` , { waitUntil :'domcontentloaded' }); 850await page . waitForTimeout ( 1700 ); 851await page . click ( '.st-tab:has-text("Expert")' ); 852await page . waitForTimeout ( 900 ); 853const out = await page . evaluate (() => ({ 854headings :[ ...document . querySelectorAll ( '.paramgroup' )]. map (( r ) => r . textContent . replace ( / \s +/ g , ' ' ). trim ()), 855params :document . querySelectorAll ( '.st-table tbody tr:not(.paramgroup)' ). length , 856// the group name should appear as a heading, not repeated on every row 857repeats :[ ...document . querySelectorAll ( 'td .xs.muted' )] 858. filter (( e ) => / ^ ( Context & memory | Performance | Sampling | Server | Advanced ) $ / . test ( e . textContent )). length , 859})); 860console . log ( 'sections :' , JSON . stringify ( out . headings , null , 1 )); 861console . log ( 'param rows :' , out . params ); 862console . log ( 'name repeats :' , out . repeats , '<- 0 means structure, not a label read 30 times' ); 863await page . fill ( 'input[placeholder="Search parameters"]' , 'cache' ); 864await page . waitForTimeout ( 600 ); 865console . log ( 'after search :' , JSON . stringify ( await page . evaluate (() => 866[ ...document . querySelectorAll ( '.paramgroup' )]. map (( r ) => r . textContent . replace ( / \s +/ g , ' ' ). trim ())))); 867await shot ( '390-param-groups' ); 868} 869 870if ( flow === 'dlcost' ) { 871await page . goto ( ` ${ BASE } /#/models` , { waitUntil :'domcontentloaded' }); 872await page . waitForTimeout ( 1800 ); 873console . log ( 'visible rows:' , await page . evaluate (() => document . querySelectorAll ( '.listrow' ). length )); 874/* Scoped to the body: the sidebar also has a "More" button, and an unscoped 875text match clicks that one instead. */ 876await page . click ( '.main__body button:has-text("Show")' ); 877await page . waitForTimeout ( 900 ); 878const cost = await page . evaluate (() => 879[ ...document . querySelectorAll ( 'button' )]. map (( b ) => b . textContent . trim ()). filter (( t ) => / Download / . test ( t ))); 880console . log ( 'download cost as size and time:' , JSON . stringify ( cost , null , 1 )); 881console . log ( 'every download names a time:' , cost . length > 0 && cost . every (( c ) => / about \d + min / . test ( c ))); 882await shot ( '380-download-cost' ); 883} 884 885if ( flow === 'servingsort' ) { 886await page . goto ( ` ${ BASE } /#/serving` , { waitUntil :'domcontentloaded' }); 887await page . waitForTimeout ( 1800 ); 888const first = () => page . evaluate (() => { 889const row = document . querySelector ( 'tbody tr' ); 890return row ?[ ...row . querySelectorAll ( 'td' )]. map (( td ) => td . textContent . trim ())[ 0 ] :'no rows' ; 891}); 892const active = () => page . evaluate (() => { 893const th = document . querySelector ( 'th [aria-sort]:not([aria-sort="none"])' ); 894return th ?` ${ th . textContent . trim ()} ${ th . getAttribute ( 'aria-sort' )} ` :'none' ; 895}); 896console . log ( 'rows :' , await page . evaluate (() => document . querySelectorAll ( 'tbody tr' ). length )); 897console . log ( 'default :' , await active (), '| first row' , await first ()); 898await page . click ( 'th:has-text("Duration") button' ); 899await page . waitForTimeout ( 450 ); 900console . log ( 'by duration :' , await active (), '| first row' , await first ()); 901await page . click ( 'th:has-text("Duration") button' ); 902await page . waitForTimeout ( 450 ); 903console . log ( 'reversed :' , await active (), '| first row' , await first (), '<- the order really changed' ); 904await page . click ( 'th:has-text("Client") button' ); 905await page . waitForTimeout ( 450 ); 906console . log ( 'by client :' , await active ()); 907console . log ( 'one column sorted at a time:' , await page . evaluate (() => 908document . querySelectorAll ( 'th [aria-sort]:not([aria-sort="none"])' ). length ) === 1 ); 909await shot ( '370-serving-sort' ); 910} 911 912if ( flow === 'skillgroups' ) { 913await page . goto ( ` ${ BASE } /#/skills` , { waitUntil :'domcontentloaded' }); 914await page . waitForTimeout ( 1900 ); 915const read = () => page . evaluate (() => ({ 916groups :[ ...document . querySelectorAll ( '.skillgroup__head' )]. map (( h ) => h . textContent . replace ( / \s +/ g , ' ' ). trim ()), 917rows :document . querySelectorAll ( '.listrow' ). length , 918})); 919const all = await read (); 920console . log ( 'groups :' , JSON . stringify ( all . groups )); 921console . log ( 'rows :' , all . rows ); 922await page . fill ( 'input[type=search], .st-input' , 'commit' ); 923await page . waitForTimeout ( 600 ); 924const filtered = await read (); 925console . log ( 'filtered :' , JSON . stringify ( filtered . groups ), '<- empty groups drop out' ); 926console . log ( 'matching rows :' , JSON . stringify ( await page . evaluate (() => 927[ ...document . querySelectorAll ( '.listrow__title' )]. map (( t ) => t . textContent )))); 928await shot ( '360-skill-groups' ); 929} 930 931if ( flow === 'overlayresize' ) { 932const wide = await browser . newPage ({ viewport :{ width :1512 , height :1000 }, deviceScaleFactor :1 }); 933await wide . goto ( ` ${ BASE } /#/chat` , { waitUntil :'domcontentloaded' }); 934await wide . waitForTimeout ( 1500 ); 935await wide . click ( 'text=New session' ); 936await wide . waitForTimeout ( 400 ); 937await wide . fill ( 'textarea' , 'hello' ); 938await wide . keyboard . press ( 'Enter' ); 939await wide . waitForTimeout ( 7000 ); 940await wide . keyboard . press ( 'Enter' ). catch (() => {}); 941await wide . waitForTimeout ( 3500 ); 942await wide . click ( '.telemetry__chip >> nth=0' ); 943await wide . waitForTimeout ( 500 ); 944 945const read = () => wide . evaluate (() => { 946const el = document . querySelector ( '.telepop' ); 947if ( ! el ) return { present :false }; 948const r = el . getBoundingClientRect (); 949return { present :true , right :Math . round ( r . right ), vw :window . innerWidth , 950offscreen :r . right > window . innerWidth + 2 || r . left < - 2 }; 951}); 952console . log ( 'at 1512 :' , JSON . stringify ( await read ())); 953for ( const w of [ 1100 , 900 ]) { 954await wide . setViewportSize ({ width :w , height :1000 }); 955await wide . waitForTimeout ( 500 ); 956console . log ( `at ${ w } :` , JSON . stringify ( await read ()), '<- follows its chip, stays on screen' ); 957} 958await wide . setViewportSize ({ width :1512 , height :1000 }); 959await wide . close (); 960} 961 962if ( flow === 'completioncue' ) { 963const short = await browser . newPage ({ viewport :{ width :1512 , height :520 }, deviceScaleFactor :1 }); 964await short . goto ( ` ${ BASE } /#/chat` , { waitUntil :'domcontentloaded' }); 965await short . waitForTimeout ( 1500 ); 966await short . click ( 'text=New session' ); 967await short . waitForTimeout ( 400 ); 968for ( const m of [ 'write a paragraph about tides' , 'and another about the moon' ]) { 969await short . fill ( 'textarea' , m ); 970await short . keyboard . press ( 'Enter' ); 971await short . waitForTimeout ( 8000 ); 972await short . keyboard . press ( 'Enter' ). catch (() => {}); 973await short . waitForTimeout ( 3500 ); 974} 975await short . evaluate (() => { document . querySelector ( '.main__body.chat' ). scrollTop = 0 ; }); 976await short . waitForTimeout ( 700 ); 977console . log ( 'pill while scrolled up:' , await short . locator ( '.jumplatest' ). count ()); 978 979await short . fill ( 'textarea' , 'one more paragraph please' ); 980await short . keyboard . press ( 'Enter' ); 981let saw = false ; 982for ( let i = 0 ; i < 90 ; i += 1 ) { 983if ( await short . evaluate (() => document . querySelector ( '.jumplatest' )?. hasAttribute ( 'data-finished' ) ?? false )) { 984saw = true ; 985break ; 986} 987await short . waitForTimeout ( 300 ); 988} 989console . log ( 'completion cue fired :' , saw , '<- a reply finished off screen and said so' ); 990console . log ( 'cue animation :' , JSON . stringify ( await short . evaluate (() => { 991const cs = getComputedStyle ( document . querySelector ( '.jumplatest' )); 992return { name :cs . animationName , duration :cs . animationDuration }; 993}))); 994await short . screenshot ({ path :'.shots/350-completion-cue.png' }); 995await short . close (); 996} 997 998if ( flow === 'privacy' ) { 999await page . goto ( ` ${ BASE } /#/settings` , { waitUntil :'domcontentloaded' }); 1000await page . waitForTimeout ( 2200 ); 1001const state = () => page . evaluate (() => { 1002const t = [ ...document . querySelectorAll ( '.st-toggle' )] 1003. find (( x ) => / usage data / i . test ( x . getAttribute ( 'aria-label' ) ?? '' )); 1004return { 1005checked :t ?. getAttribute ( 'aria-checked' ), 1006stored :JSON . parse ( localStorage . getItem ( 'strata.prefs.v2' ) ?? '{}' ). shareTelemetry , 1007}; 1008}); 1009console . log ( 'at rest :' , JSON . stringify ( await state ()), '<- a real false, not an omitted attribute' ); 1010await page . click ( '.st-toggle[aria-label="Share anonymous usage data"]' ); 1011await page . waitForTimeout ( 700 ); 1012console . log ( 'after toggling:' , JSON . stringify ( await state ())); 1013await page . reload ({ waitUntil :'domcontentloaded' }); 1014await page . waitForTimeout ( 2200 ); 1015console . log ( 'after reload :' , JSON . stringify ( await state ()), '<- the choice is recorded' ); 1016 1017// a privacy choice is not an appearance setting 1018await page . fill ( '.settingsindex__search' , 'reset appearance' , { timeout :8000 }); 1019await page . waitForTimeout ( 600 ); 1020const clickIn = ( label ) => page . evaluate (( t ) => { 1021const f = [ ...document . querySelectorAll ( '.settings-body .field' )]. find (( x ) => ! x . hidden ); 1022[ ...f . querySelectorAll ( 'button' )]. find (( b ) => b . textContent . trim () === t ). click (); 1023}, label ); 1024await clickIn ( 'Reset' ); 1025await page . waitForTimeout ( 400 ); 1026await clickIn ( 'Reset' ); 1027await page . waitForTimeout ( 900 ); 1028console . log ( 'after a reset:' , JSON . stringify ( await state ()), '<- untouched by an appearance reset' ); 1029await shot ( '340-privacy' ); 1030} 1031 1032if ( flow === 'railclose' ) { 1033await page . click ( 'text=New session' ); 1034await page . waitForTimeout ( 400 ); 1035await page . fill ( 'textarea' , 'say hello' ); 1036await page . keyboard . press ( 'Enter' ); 1037await page . waitForTimeout ( 7000 ); 1038await page . keyboard . press ( 'Enter' ). catch (() => {}); 1039await page . waitForTimeout ( 3500 ); 1040await page . click ( 'button[title="Conversation context"]' ); 1041await page . waitForTimeout ( 700 ); 1042console . log ( 'header :' , JSON . stringify ( await page . evaluate (() => { 1043const head = document . querySelector ( '.contextpanel__head' ); 1044const btn = head ?. querySelector ( 'button' ); 1045return { closeTitle :btn ?. getAttribute ( 'title' ), buttonText :btn ?. textContent . trim () }; 1046}))); 1047console . log ( 'sections :' , await page . evaluate (() => 1048document . querySelectorAll ( '.contextpanel__sections .railsection' ). length )); 1049await page . click ( '.contextpanel__head button' ); 1050await page . waitForTimeout ( 800 ); 1051console . log ( 'rail dismissed:' , await page . evaluate (() => 1052getComputedStyle ( document . querySelector ( '.contextpanel' )). visibility === 'hidden' )); 1053await shot ( '330-rail-close' ); 1054} 1055 1056if ( flow === 'treekeys' ) { 1057await page . goto ( ` ${ BASE } /#/workspace` , { waitUntil :'domcontentloaded' }); 1058await page . waitForTimeout ( 1800 ); 1059const at = () => page . evaluate (() => { 1060const el = document . activeElement ; 1061return el ?. classList . contains ( 'treerow' ) ?` ${ el . dataset . path } (d ${ el . dataset . depth } )` :el ?. tagName ; 1062}); 1063console . log ( 'tabbable rows:' , await page . evaluate (() => 1064document . querySelectorAll ( '.treerow[tabindex="0"]' ). length ), '(want exactly 1 — roving tabindex)' ); 1065console . log ( 'of :' , await page . evaluate (() => document . querySelectorAll ( '.treerow' ). length ), 'rows' ); 1066 1067await page . evaluate (() => document . querySelector ( '.treerow[tabindex="0"]' ). focus ()); 1068console . log ( 'start :' , await at ()); 1069await page . keyboard . press ( 'ArrowDown' ); 1070console . log ( 'Down :' , await at ()); 1071await page . keyboard . press ( 'ArrowDown' ); 1072console . log ( 'Down :' , await at ()); 1073await page . keyboard . press ( 'ArrowUp' ); 1074console . log ( 'Up :' , await at ()); 1075await page . keyboard . press ( 'ArrowRight' ); 1076await page . waitForTimeout ( 350 ); 1077console . log ( 'Right :' , await at (), '<- opens or steps in' ); 1078await page . keyboard . press ( 'ArrowLeft' ); 1079await page . waitForTimeout ( 350 ); 1080console . log ( 'Left :' , await at (), '<- closes or steps out' ); 1081await page . keyboard . press ( 'End' ); 1082console . log ( 'End :' , await at ()); 1083await page . keyboard . press ( 'Home' ); 1084console . log ( 'Home :' , await at ()); 1085console . log ( 'one tabbable after moving:' , await page . evaluate (() => 1086document . querySelectorAll ( '.treerow[tabindex="0"]' ). length ) === 1 ); 1087console . log ( 'scope figures:' , await page . evaluate (() => 1088document . querySelector ( '.scopes' )?. textContent . replace ( / \s +/ g , ' ' ). trim ())); 1089await shot ( '320-tree-keys' ); 1090} 1091 1092if ( flow === 'readmark' ) { 1093await page . goto ( ` ${ BASE } /#/chat` , { waitUntil :'domcontentloaded' }); 1094await page . waitForTimeout ( 1600 ); 1095await page . click ( 'text=New session' ); 1096await page . waitForTimeout ( 400 ); 1097await page . fill ( 'textarea' , 'read the readme file in the repo' ); 1098await page . keyboard . press ( 'Enter' ); 1099await page . waitForTimeout ( 9000 ); 1100console . log ( 'proposal names a real file:' , 1101await page . evaluate (() => / strata\/README\.md / . test ( document . body . innerText ))); 1102await page . click ( 'button:has-text("Approve")' ); 1103await page . waitForTimeout ( 2500 ); 1104console . log ( 'persisted :' , await page . evaluate (() => localStorage . getItem ( 'strata.touched.v1' ))); 1105 1106await page . reload ({ waitUntil :'domcontentloaded' }); 1107await page . waitForTimeout ( 1800 ); 1108await page . evaluate (() => { window . location . hash = '#/workspace' ; }); 1109await page . waitForTimeout ( 2000 ); 1110console . log ( 'marked rows:' , JSON . stringify ( await page . evaluate (() => 1111[ ...document . querySelectorAll ( '.treerow[data-touched]' )]. map (( r ) => r . textContent . trim (). slice ( 0 , 22 ))))); 1112console . log ( 'marker title:' , await page . evaluate (() => 1113document . querySelector ( '.treerow[data-touched]' )?. getAttribute ( 'title' ))); 1114console . log ( 'unread files unmarked:' , await page . evaluate (() => 1115document . querySelectorAll ( '.treerow:not([data-touched])' ). length > 50 )); 1116await shot ( '310-read-marker' ); 1117} 1118 1119if ( flow === 'settingsreset' ) { 1120await page . goto ( ` ${ BASE } /#/settings` , { waitUntil :'domcontentloaded' }); 1121// seed a deliberately non-default set, then reload so the app applies it 1122await page . evaluate (() => { 1123localStorage . setItem ( 'strata.prefs.v2' , JSON . stringify ({ 1124theme :'dark' , rail :true , focus :false , contentFontSize :22 , 1125density :'compact' , motion :'reduced' , transparency :'opaque' , uiScale :1.25 , 1126})); 1127}); 1128await page . reload ({ waitUntil :'domcontentloaded' }); 1129await page . waitForTimeout ( 2200 ); 1130const read = () => page . evaluate (() => ({ 1131theme :document . documentElement . dataset . theme ?? '(none)' , 1132scale :getComputedStyle ( document . documentElement ). getPropertyValue ( '--st-ui-scale' ). trim (), 1133rail :JSON . parse ( localStorage . getItem ( 'strata.prefs.v2' ) ?? '{}' ). rail , 1134})); 1135console . log ( 'seeded :' , JSON . stringify ( await read ())); 1136 1137await page . fill ( '.settingsindex__search' , 'reset appearance' , { timeout :8000 }); 1138await page . waitForTimeout ( 600 ); 1139console . log ( 'visible fields:' , JSON . stringify ( await page . evaluate (() => 1140[ ...document . querySelectorAll ( '.settings-body .field' )]. filter (( f ) => ! f . hidden ) 1141. map (( f ) => f . querySelector ( '.field__label' )?. textContent )))); 1142 1143const clickIn = ( labelText ) => page . evaluate (( t ) => { 1144const f = [ ...document . querySelectorAll ( '.settings-body .field' )]. find (( x ) => ! x . hidden ); 1145[ ...f . querySelectorAll ( 'button' )]. find (( b ) => b . textContent . trim () === t ). click (); 1146}, labelText ); 1147 1148await clickIn ( 'Reset' ); 1149await page . waitForTimeout ( 400 ); 1150console . log ( 'confirmation :' , JSON . stringify ( await page . evaluate (() => { 1151const f = [ ...document . querySelectorAll ( '.settings-body .field' )]. find (( x ) => ! x . hidden ); 1152return [ ...f . querySelectorAll ( 'button' )]. map (( b ) => b . textContent . trim ()); 1153}))); 1154await clickIn ( 'Keep' ); 1155await page . waitForTimeout ( 400 ); 1156console . log ( 'after Keep :' , JSON . stringify ( await read ()), '<- unchanged' ); 1157 1158await clickIn ( 'Reset' ); 1159await page . waitForTimeout ( 400 ); 1160await clickIn ( 'Reset' ); 1161await page . waitForTimeout ( 900 ); 1162console . log ( 'after Reset :' , JSON . stringify ( await read ()), '<- theme and scale restored, rail untouched' ); 1163await shot ( '300-settings-reset' ); 1164} 1165 1166if ( flow === 'jumplatest' ) { 1167const short = await browser . newPage ({ viewport :{ width :1512 , height :520 }, deviceScaleFactor :1 }); 1168await short . goto ( ` ${ BASE } /#/chat` , { waitUntil :'domcontentloaded' }); 1169await short . waitForTimeout ( 1500 ); 1170await short . click ( 'text=New session' ); 1171await short . waitForTimeout ( 400 ); 1172for ( const m of [ 'write a paragraph about tides' , 'and another about the moon' , 'and one about the wind' ]) { 1173await short . fill ( 'textarea' , m ); 1174await short . keyboard . press ( 'Enter' ); 1175await short . waitForTimeout ( 8000 ); 1176await short . keyboard . press ( 'Enter' ). catch (() => {}); 1177await short . waitForTimeout ( 4000 ); 1178} 1179const gap = () => short . evaluate (() => { 1180const el = document . querySelector ( '.main__body.chat' ); 1181return Math . round ( el . scrollHeight - el . scrollTop - el . clientHeight ); 1182}); 1183console . log ( 'turns :' , await short . locator ( '.st-msg' ). count ()); 1184console . log ( 'content-visibility:' , await short . evaluate (() => getComputedStyle ( document . querySelector ( '.st-msg' )). contentVisibility )); 1185console . log ( 'pinned at rest : gap' , await gap (), '| pill:' , await short . locator ( '.jumplatest' ). count (), '<- 0 and hidden' ); 1186await short . evaluate (() => { document . querySelector ( '.main__body.chat' ). scrollTop = 0 ; }); 1187await short . waitForTimeout ( 900 ); 1188console . log ( 'scrolled up : gap' , await gap (), '| pill:' , await short . locator ( '.jumplatest' ). count ()); 1189await short . click ( '.jumplatest' ); 1190await short . waitForTimeout ( 2200 ); 1191console . log ( 'after jump : gap' , await gap (), '| pill:' , await short . locator ( '.jumplatest' ). count (), '<- 0 and hidden' ); 1192await short . screenshot ({ path :'.shots/290-jumplatest.png' }); 1193await short . close (); 1194} 1195 1196if ( flow === 'settingssearch' ) { 1197await page . goto ( ` ${ BASE } /#/settings` , { waitUntil :'domcontentloaded' }); 1198await page . waitForTimeout ( 1700 ); 1199const vis = () => page . evaluate (() => ({ 1200fields :[ ...document . querySelectorAll ( '.settings-body .field' )]. filter (( f ) => ! f . hidden ) 1201. map (( f ) => f . querySelector ( '.field__label' )?. textContent ), 1202sections :[ ...document . querySelectorAll ( '.settings-body section[id^=settings-]' )]. filter (( s ) => ! s . hidden ). length , 1203})); 1204const rest = await vis (); 1205console . log ( 'at rest :' , rest . fields . length , 'fields in' , rest . sections , 'sections' ); 1206 1207await page . fill ( '.settingsindex__search' , 'dark' ); 1208await page . waitForTimeout ( 450 ); 1209console . log ( 'search "dark" :' , JSON . stringify (( await vis ()). fields ), '<- matched on the hint, not just the label' ); 1210 1211await page . fill ( '.settingsindex__search' , 'cache' ); 1212await page . waitForTimeout ( 450 ); 1213console . log ( 'search "cache":' , JSON . stringify (( await vis ()). fields )); 1214 1215await page . fill ( '.settingsindex__search' , 'zzzz' ); 1216await page . waitForTimeout ( 450 ); 1217console . log ( 'no match :' , await page . evaluate (() => document . querySelector ( '.empty__title' )?. textContent ), 1218'| action:' , await page . evaluate (() => document . querySelector ( '.empty button' )?. textContent . trim ())); 1219await page . click ( '.empty button' ); 1220await page . waitForTimeout ( 500 ); 1221const back = await vis (); 1222console . log ( 'after clear :' , back . fields . length , 'fields in' , back . sections , 'sections' ); 1223await shot ( '280-settings-search' ); 1224} 1225 1226if ( flow === 'unread' ) { 1227await page . click ( 'text=New session' ); 1228await page . waitForTimeout ( 400 ); 1229await page . fill ( 'textarea' , 'a thread' ); 1230await page . keyboard . press ( 'Enter' ); 1231await page . waitForTimeout ( 7000 ); 1232await page . keyboard . press ( 'Enter' ). catch (() => {}); 1233await page . waitForTimeout ( 3500 ); 1234await page . click ( 'text=New session' ); 1235await page . waitForTimeout ( 600 ); 1236 1237// make the older conversation look updated since it was last read 1238await page . evaluate ( async () => { 1239// The chats are files on the host (owner decision 11-04): read them and save the older one again, as the page would. 1240const h = { 'x-strata-client' :'ui' }; 1241const list = await ( await fetch ( '/api/chats' , { headers :h })). json (); 1242const raw = await Promise . all ( list . chats . map ( async ( c ) => ( await ( await fetch ( '/api/chats/' + encodeURIComponent ( c . id ), { headers :h })). json ()). session )); 1243const older = raw . filter (( s ) => s . messages . length > 0 ). at ( - 1 ); 1244if ( older ) { 1245older . updatedAt = new Date ( Date . now () + 120000 ). toISOString (); 1246older . lastReadAt = new Date ( Date . now () - 120000 ). toISOString (); 1247await fetch ( '/api/chats/' + encodeURIComponent ( older . id ), { method :'PUT' , headers :h , body :JSON . stringify ( older ) }); 1248} 1249}); 1250await page . reload ({ waitUntil :'domcontentloaded' }); 1251await page . waitForTimeout ( 1800 ); 1252const info = await page . evaluate (() => { 1253const rows = [ ...document . querySelectorAll ( '.ws__session' )]; 1254const unread = rows . find (( r ) => r . querySelector ( '.navsession__unread' )); 1255return { 1256marked :rows . map (( r ) => r . querySelector ( '.navsession__unread' ) ?r . querySelector ( '.navsession__title' )?. textContent :null ). filter ( Boolean ), 1257dot :unread ?getComputedStyle ( unread . querySelector ( '.navsession__unread' )). width :null , 1258metaFlex :rows [ 0 ] ?getComputedStyle ( rows [ 0 ]. querySelector ( '.navsession__meta' )). flex :null , 1259}; 1260}); 1261console . log ( 'unread rows :' , JSON . stringify ( info . marked )); 1262console . log ( 'dot is a dot :' , info . dot , '(a broad `.navsession span` rule made this 42px)' ); 1263console . log ( 'timestamp not stretched:' , info . metaFlex ); 1264await shot ( '270-unread' ); 1265} 1266 1267if ( flow === 'servingfilter' ) { 1268await page . goto ( ` ${ BASE } /#/serving` , { waitUntil :'domcontentloaded' }); 1269await page . waitForTimeout ( 1600 ); 1270const rows = () => page . locator ( 'tbody tr' ). count (); 1271const all = await rows (); 1272console . log ( 'rows total :' , all ); 1273console . log ( 'filter chips :' , JSON . stringify ( await page . evaluate (() => 1274[ ...document . querySelectorAll ( '.servefilter button' )]. map (( x ) => x . textContent . trim ())))); 1275 1276await page . click ( '.servefilter >> text=Errors' ); 1277await page . waitForTimeout ( 500 ); 1278console . log ( 'errors filter :' , await rows (), 'rows |' , 1279await page . evaluate (() => document . querySelector ( '.empty__title' )?. textContent ?? 'table shown' )); 1280 1281await page . click ( '.servefilter >> text=All' ); 1282await page . waitForTimeout ( 400 ); 1283await page . fill ( 'input[aria-label="Filter requests by client"]' , 'zzzz' ); 1284await page . waitForTimeout ( 500 ); 1285console . log ( 'no match :' , await page . evaluate (() => document . querySelector ( '.empty__title' )?. textContent ?? 'NO MESSAGE' ), 1286'| action:' , await page . evaluate (() => document . querySelector ( '.empty button' )?. textContent . trim ())); 1287await page . click ( '.empty button' ); 1288await page . waitForTimeout ( 500 ); 1289console . log ( 'after clear :' , await rows (), 'rows (was' , all + ')' ); 1290console . log ( 'state pills carry a glyph:' , await page . evaluate (() => 1291!! document . querySelector ( 'tbody .st-badge svg use' ))); 1292await shot ( '260-serving-filter' ); 1293} 1294 1295if ( flow === 'empties' ) { 1296// Every empty state should state the next move, not only the absence. 1297const read = () => page . evaluate (() => { 1298const el = document . querySelector ( '.empty' ); 1299return el 1300 ?{ title :el . querySelector ( '.empty__title' )?. textContent , 1301action :el . querySelector ( 'button' )?. textContent . trim () ?? null } 1302 :null ; 1303}); 1304 1305await page . goto ( ` ${ BASE } /#/skills` , { waitUntil :'domcontentloaded' }); 1306await page . waitForTimeout ( 1500 ); 1307await page . fill ( 'input[type=search], .st-input' , 'zzzzz' ); 1308await page . waitForTimeout ( 600 ); 1309console . log ( 'skills filtered :' , JSON . stringify ( await read ())); 1310await page . click ( '.empty button' ); 1311await page . waitForTimeout ( 600 ); 1312console . log ( 'cleared :' , await page . locator ( '.listrow' ). count (), 'skills back' ); 1313 1314await page . goto ( ` ${ BASE } /#/workspace` , { waitUntil :'domcontentloaded' }); 1315await page . waitForTimeout ( 1500 ); 1316await page . fill ( 'input[placeholder="Filter files"]' , 'zzzzz' ); 1317await page . waitForTimeout ( 600 ); 1318console . log ( 'workspace filtered:' , JSON . stringify ( await read ())); 1319await page . click ( '.empty button' ); 1320await page . waitForTimeout ( 700 ); 1321console . log ( 'cleared :' , await page . locator ( '.treerow' ). count (), 'rows back' ); 1322// the assertion that matters: the pane is not blank, and it offers a way back 1323const after = await read (); 1324console . log ( 'filtered pane is not blank:' , after !== null || ( await page . locator ( '.treerow' ). count ()) > 0 ); 1325await shot ( '250-empty-states' ); 1326} 1327 1328if ( flow === 'branch' ) { 1329await page . click ( 'text=New session' ); 1330await page . waitForTimeout ( 400 ); 1331await page . fill ( 'textarea' , 'say hello' ); 1332await page . keyboard . press ( 'Enter' ); 1333await page . waitForTimeout ( 7000 ); 1334await page . keyboard . press ( 'Enter' ); 1335await page . waitForTimeout ( 6500 ); 1336 1337const view = () => page . evaluate (() => ({ 1338roles :[ ...document . querySelectorAll ( '.st-msg' )]. map (( m ) => 1339m . classList . contains ( 'st-msg--user' ) ?'user' :'assistant' ), 1340url :location . hash . slice ( 0 , 24 ), 1341})); 1342console . log ( 'before :' , JSON . stringify ( await view ())); 1343 1344// Continue is only offered on the newest reply, so check it before branching 1345// away from the state that has one. 1346const offeredBefore = await page . evaluate (() => 1347[ ...document . querySelectorAll ( '.st-msg--assistant' )]. map (( m ) => 1348[ ...m . querySelectorAll ( 'button' )]. some (( b ) => b . title === 'Continue from here' ))); 1349console . log ( 'continue on the newest reply only:' , JSON . stringify ( offeredBefore )); 1350await page . click ( '.st-msg--assistant .st-msg__actions button[title="Continue from here"]' ); 1351await page . waitForTimeout ( 1200 ); 1352console . log ( 'after continue:' , JSON . stringify (( await view ()). roles ), '<- a new turn was added' ); 1353await page . waitForTimeout ( 8000 ); 1354 1355// remember the original so "untouched" means unchanged by the branch, not a 1356// hardcoded length 1357const before = await page . evaluate (() => 1358( async () => { const h = { 'x-strata-client' :'ui' }; const l = await ( await fetch ( '/api/chats' , { headers :h })). json (); return Promise . all ( l . chats . map ( async ( c ) => ( await ( await fetch ( '/api/chats/' + encodeURIComponent ( c . id ), { headers :h })). json ()). session )); })() 1359. map (( s ) => ({ title :s . title , roles :s . messages . map (( m ) => m . role ) }))); 1360const originalBefore = before . find (( s ) => ! s . title . includes ( 'branch' )); 1361 1362// now branch, from the very first user turn 1363await page . click ( '.st-msg--user >> nth=0' ); 1364await page . hover ( '.st-msg--user >> nth=0' ); 1365await page . waitForTimeout ( 300 ); 1366await page . click ( '.st-msg--user >> nth=0 >> xpath=.. >> css=.st-msg__actions button[title="Branch from here"]' ). catch ( async () => { 1367await page . evaluate (() => { 1368const u = document . querySelector ( '.st-msg--user' ); 1369[ ...u . querySelectorAll ( 'button' )]. find (( b ) => b . title === 'Branch from here' ). click (); 1370}); 1371}); 1372await page . waitForTimeout ( 1100 ); 1373console . log ( 'from user :' , JSON . stringify ( await view ()), '<- branch must show only the user turn, and the url must follow' ); 1374 1375const sessions = await page . evaluate (() => 1376( async () => { const h = { 'x-strata-client' :'ui' }; const l = await ( await fetch ( '/api/chats' , { headers :h })). json (); return Promise . all ( l . chats . map ( async ( c ) => ( await ( await fetch ( '/api/chats/' + encodeURIComponent ( c . id ), { headers :h })). json ()). session )); })() 1377. map (( s ) => ({ title :s . title , roles :s . messages . map (( m ) => m . role ) }))); 1378console . log ( 'stored :' , JSON . stringify ( sessions )); 1379const originalAfter = sessions . find (( s ) => ! s . title . includes ( 'branch' )); 1380console . log ( 'original untouched by the branch:' , 1381JSON . stringify ( originalAfter ) === JSON . stringify ( originalBefore )); 1382 1383await shot ( '240-branch-continue' ); 1384} 1385 1386if ( flow === 'loaderror' ) { 1387await page . goto ( ` ${ BASE } /#/models` , { waitUntil :'domcontentloaded' }); 1388await page . waitForTimeout ( 1600 ); 1389console . log ( 'at rest:' , ( await page . locator ( '.verror' ). count ()) === 0 ); 1390 1391expectFailure ( / Failed to load resource | ERR_FAILED / ); 1392await page . route ( '**/api/models/*/load' , ( r ) => r . abort ()); 1393/* Every installed variant on this machine is either already loaded or rated 1394beyond it, so the load action is "Load anyway" and asks first. The flow 1395accepts the confirmation and exercises the failure path behind it. */ 1396page . on ( 'dialog' , ( d ) => void d . accept ()); 1397await page . evaluate (() => { 1398const btn = [ ...document . querySelectorAll ( 'button' )] 1399. find (( b ) => / ^load ( anyway ) ? $ / i . test ( b . textContent . trim ())); 1400btn ?. click (); 1401}); 1402await page . waitForTimeout ( 1400 ); 1403console . log ( 'failed load:' , await page . evaluate (() => { 1404const el = document . querySelector ( '.verror' ); 1405return el ?el . textContent . replace ( / \s +/ g , ' ' ). trim (). slice ( 0 , 60 ) :'NOT SHOWN' ; 1406})); 1407await page . waitForTimeout ( 7000 ); 1408console . log ( 't=8.4s inline:' , await page . locator ( '.verror' ). count (), '| toasts:' , await page . locator ( '.st-toast' ). count ()); 1409await page . unroute ( '**/api/models/*/load' ); 1410await page . click ( '.verror button' ); 1411await page . waitForTimeout ( 3000 ); 1412console . log ( 'retry when recovered:' , ( await page . locator ( '.verror' ). count ()) === 0 ?'cleared' :'STILL SHOWING' ); 1413await shot ( '230-load-error' ); 1414} 1415 1416if ( flow === 'actionerror' ) { 1417await page . goto ( ` ${ BASE } /#/tuning` , { waitUntil :'domcontentloaded' }); 1418await page . waitForTimeout ( 1600 ); 1419console . log ( 'no error at rest:' , ( await page . locator ( '.verror' ). count ()) === 0 ); 1420 1421// make the engine action fail — the abort is the point of this flow, so the 1422// network error it produces is expected rather than a regression 1423expectFailure ( / Failed to load resource | ERR_FAILED / ); 1424await page . route ( '**/api/engine/restart' , ( r ) => r . abort ()); 1425await page . evaluate (() => { 1426[ ...document . querySelectorAll ( 'button' )]. find (( b ) => / restart engine / i . test ( b . textContent ))?. click (); 1427}); 1428await page . waitForTimeout ( 1200 ); 1429console . log ( 't=1.2s inline:' , await page . locator ( '.verror' ). count (), '| toasts:' , await page . locator ( '.st-toast' ). count ()); 1430await page . waitForTimeout ( 7000 ); 1431console . log ( 't=8.2s inline:' , await page . locator ( '.verror' ). count (), '| toasts:' , await page . locator ( '.st-toast' ). count (), 1432'<- toast expired, failure remains' ); 1433 1434// retry while still failing, then with the route restored 1435await page . click ( '.verror button' ); 1436await page . waitForTimeout ( 1400 ); 1437console . log ( 'retry while failing :' , ( await page . locator ( '.verror' ). count ()) > 0 ?'error returns' :'SILENTLY CLEARED' ); 1438await page . unroute ( '**/api/engine/restart' ); 1439await page . click ( '.verror button' ); 1440await page . waitForTimeout ( 2000 ); 1441console . log ( 'retry when recovered:' , ( await page . locator ( '.verror' ). count ()) === 0 ?'cleared' :'STILL SHOWING' ); 1442await shot ( '220-action-error' ); 1443} 1444 1445if ( flow === 'skilluse' ) { 1446// a prompt that should trigger one skill and nothing else 1447await page . goto ( ` ${ BASE } /#/chat` , { waitUntil :'domcontentloaded' }); 1448await page . waitForTimeout ( 1500 ); 1449await page . click ( 'text=New session' ); 1450await page . waitForTimeout ( 400 ); 1451await page . fill ( 'textarea' , 'review this code and check my code for bugs' ); 1452await page . keyboard . press ( 'Enter' ); 1453await page . waitForTimeout ( 7000 ); 1454await page . keyboard . press ( 'Enter' ). catch (() => {}); 1455await page . waitForTimeout ( 4000 ); 1456 1457await page . goto ( ` ${ BASE } /#/skills` , { waitUntil :'domcontentloaded' }); 1458await page . waitForTimeout ( 1500 ); 1459const rows = await page . evaluate (() => 1460[ ...document . querySelectorAll ( '.listrow' )]. map (( r ) => ({ 1461name :r . querySelector ( '.listrow__title' )?. textContent , 1462meta :[ ...r . querySelectorAll ( '.xs.muted' )]. map (( e ) => e . textContent ). find (( t ) => / Used | Not used / . test ( t )), 1463}))); 1464for ( const r of rows ) console . log ( ` ${ String ( r . name ). padEnd ( 20 )} ${ r . meta } ` ); 1465console . log ( 'every skill states its usage:' , rows . every (( r ) => r . meta )); 1466await shot ( '210-skills-usage' ); 1467} 1468 1469if ( flow === 'sessionmenu' ) { 1470for ( const msg of [ 'keep this one' , 'delete this one' ]) { 1471await page . click ( 'text=New session' ); 1472await page . waitForTimeout ( 350 ); 1473await page . fill ( 'textarea' , msg ); 1474await page . keyboard . press ( 'Enter' ); 1475await page . waitForTimeout ( 3200 ); 1476} 1477const count = () => page . locator ( '.navsession' ). count (); 1478console . log ( 'sessions:' , await count ()); 1479 1480await page . click ( '.navsession >> nth=0' , { button :'right' }); 1481await page . waitForTimeout ( 400 ); 1482console . log ( 'menu:' , JSON . stringify ( await page . evaluate (() => 1483[ ...document . querySelectorAll ( '.menu__item' )]. map (( i ) => i . textContent . trim ())))); 1484await page . click ( '.menu__item--danger' ); 1485await page . waitForTimeout ( 400 ); 1486await page . click ( '.st-btn--danger' ); 1487await page . waitForTimeout ( 600 ); 1488console . log ( 'after delete:' , await count ()); 1489 1490await page . evaluate (() => document . querySelector ( '.navsession' ). focus ()); 1491await page . keyboard . press ( 'Delete' ); 1492await page . waitForTimeout ( 350 ); 1493console . log ( 'Delete key arms confirm:' , ( await page . locator ( '.st-btn--danger' ). count ()) > 0 ); 1494await page . keyboard . press ( 'Escape' ); 1495await shot ( '200-session-menu' ); 1496} 1497 1498if ( flow === 'rail' ) { 1499await page . click ( 'text=New session' ); 1500await page . waitForTimeout ( 400 ); 1501await page . fill ( 'textarea' , 'read the readme' ); 1502await page . keyboard . press ( 'Enter' ); 1503await page . waitForTimeout ( 7000 ); 1504await page . keyboard . press ( 'Enter' ); 1505await page . waitForTimeout ( 6000 ); 1506await page . click ( 'button[title="Conversation context"]' ); 1507await page . waitForTimeout ( 700 ); 1508 1509const state = () => page . evaluate (() => { 1510const body = document . querySelector ( '.contextpanel__body' ); 1511const secs = [ ...document . querySelectorAll ( '.railsection' )]; 1512return { 1513sections :secs . length , 1514scrolls :body . scrollHeight > body . clientHeight + 2 , 1515firstRows :getComputedStyle ( secs [ 0 ]. querySelector ( '.railsection__body' )). gridTemplateRows , 1516}; 1517}); 1518console . log ( 'all open :' , JSON . stringify ( await state ())); 1519await page . click ( '.railsection__head >> nth=0' ); 1520await page . waitForTimeout ( 120 ); 1521console . log ( 'mid-collapse:' , JSON . stringify ( await state ()), '<- animating, not snapping' ); 1522await page . waitForTimeout ( 450 ); 1523console . log ( 'collapsed :' , JSON . stringify ( await state ())); 1524 1525const tools = await page . evaluate (() => { 1526const sec = [ ...document . querySelectorAll ( '.railsection' )]. find (( x ) => x . textContent . includes ( 'Tools in reach' )); 1527return [ ...sec . querySelectorAll ( '.railsection__inner .row' )]. map (( r ) => ({ 1528name :r . querySelector ( '.small.strong' )?. textContent , 1529used :r . hasAttribute ( 'data-used' ), 1530})); 1531}); 1532console . log ( 'tools used :' , JSON . stringify ( tools . filter (( t ) => t . used ). map (( t ) => t . name ))); 1533await shot ( '190-context-rail' ); 1534} 1535 1536if ( flow === 'skills' ) { 1537await page . goto ( ` ${ BASE } /#/skills` , { waitUntil :'domcontentloaded' }); 1538await page . waitForTimeout ( 1500 ); 1539const rows = await page . locator ( '.listrow' ). count (); 1540console . log ( 'skills listed:' , rows ); 1541await page . click ( 'text=Read instructions >> nth=0' ); 1542await page . waitForTimeout ( 400 ); 1543const detail = await page . evaluate (() => { 1544const el = document . querySelector ( '.skilldetail__body' ); 1545const tr = document . querySelector ( '.skilldetail__triggers' ); 1546return { chars :el ?. textContent . length ?? 0 , triggers :tr ?tr . querySelectorAll ( '.st-pill' ). length :0 }; 1547}); 1548console . log ( 'instructions shown:' , detail . chars , 'chars ·' , detail . triggers , 'triggers' ); 1549const all = await page . evaluate ( async () => { 1550const r = await fetch ( '/api/skills' ). then (( x ) => x . json ()); 1551return r . filter (( s ) => ! s . body ). map (( s ) => s . name ); 1552}); 1553console . log ( 'skills with no instruction text:' , all . length ?all :'none' ); 1554await shot ( '180-skills-instructions' ); 1555} 1556 1557if ( flow === 'sidebar' ) { 1558for ( const msg of [ 'alpha conversation' , 'beta conversation' ]) { 1559await page . click ( 'text=New session' ); 1560await page . waitForTimeout ( 350 ); 1561await page . fill ( 'textarea' , msg ); 1562await page . keyboard . press ( 'Enter' ); 1563await page . waitForTimeout ( 3200 ); 1564} 1565const titles = () => page . evaluate (() => 1566[ ...document . querySelectorAll ( '.navsession__title' )]. map (( e ) => e . textContent )); 1567console . log ( 'newest first :' , JSON . stringify ( await titles ())); 1568 1569await page . evaluate (() => { 1570const rows = [ ...document . querySelectorAll ( '.ws__session' )]; 1571rows [ rows . length - 1 ]. querySelector ( '.ws__pin' ). click (); 1572}); 1573await page . waitForTimeout ( 450 ); 1574console . log ( 'after pinning:' , JSON . stringify ( await titles ())); 1575 1576await page . evaluate (() => document . querySelector ( '.nav__collapse' ). focus ()); 1577const walk = []; 1578for ( let i = 0 ; i < 4 ; i += 1 ) { 1579await page . keyboard . press ( 'ArrowDown' ); 1580walk . push ( await page . evaluate (() => ( document . activeElement ?. textContent ?? '' ). trim (). slice ( 0 , 20 ))); 1581} 1582console . log ( 'arrow walk :' , JSON . stringify ( walk )); 1583await page . keyboard . press ( 'End' ); 1584console . log ( 'End -> ' , await page . evaluate (() => ( document . activeElement ?. textContent ?? '' ). trim (). slice ( 0 , 20 ))); 1585await shot ( '170-sidebar-keys' ); 1586} 1587 1588if ( flow === 'retryedit' ) { 1589await page . click ( 'text=New session' ); 1590await page . waitForTimeout ( 400 ); 1591await page . fill ( 'textarea' , 'read the readme' ); 1592await page . keyboard . press ( 'Enter' ); 1593await page . waitForTimeout ( 7000 ); 1594await page . keyboard . press ( 'Enter' ); 1595await page . waitForTimeout ( 7000 ); 1596 1597const counts = () => page . evaluate (() => ({ 1598user :document . querySelectorAll ( '.st-msg--user' ). length , 1599assistant :document . querySelectorAll ( '.st-msg--assistant' ). length , 1600})); 1601console . log ( 'after a turn :' , JSON . stringify ( await counts ())); 1602 1603await page . hover ( '.st-msg--assistant' ); 1604await page . waitForTimeout ( 250 ); 1605await page . click ( 'button[title="Ask again"]' ); 1606await page . waitForTimeout ( 600 ); 1607console . log ( 'mid-retry :' , JSON . stringify ( await counts ()), '<- reply dropped, not duplicated' ); 1608await page . waitForTimeout ( 8000 ); 1609await page . keyboard . press ( 'Enter' ). catch (() => {}); 1610await page . waitForTimeout ( 6000 ); 1611console . log ( 'after retry :' , JSON . stringify ( await counts ())); 1612 1613await page . hover ( '.st-msg--user' ); 1614await page . waitForTimeout ( 250 ); 1615await page . click ( 'button[title="Edit and ask again"]' ); 1616await page . waitForTimeout ( 600 ); 1617console . log ( 'after edit :' , JSON . stringify ( await counts ()), 1618'| composer:' , JSON . stringify ( await page . inputValue ( 'textarea' )), 1619'| focus:' , await page . evaluate (() => document . activeElement ?. tagName )); 1620await shot ( '160-retry-edit' ); 1621} 1622 1623if ( flow === 'palette' ) { 1624await page . keyboard . press ( 'Meta+k' ); 1625await page . waitForTimeout ( 500 ); 1626 1627// focus must land inside the surface, and stay there 1628const inside = () => page . evaluate (() => { 1629const m = [ ...document . querySelectorAll ( '.modal' )]. find (( x ) => x . dataset . open === 'true' ); 1630return !! ( m && document . activeElement && m . contains ( document . activeElement )); 1631}); 1632console . log ( 'focus inside on open:' , await inside ()); 1633for ( let i = 0 ; i < 14 ; i += 1 ) await page . keyboard . press ( 'Tab' ); 1634console . log ( 'focus inside after 14 Tabs:' , await inside ()); 1635 1636const top = () => page . evaluate (() => 1637[ ...document . querySelectorAll ( '.palette__row' )]. slice ( 0 , 2 ). map (( r ) => 1638( r . querySelector ( '.navitem__text' )?. textContent ?? '' ) + 1639'[' + [ ...r . querySelectorAll ( 'mark' )]. map (( m ) => m . textContent ). join ( '' ) + ']' )); 1640for ( const q of [ 'mtr' , 'tune' , 'api' , '>unload' , '@' ]) { 1641await page . fill ( '.modal input' , q ); 1642await page . waitForTimeout ( 260 ); 1643console . log ( ` ${ q . padEnd ( 9 )} -> ${ JSON . stringify ( await top ())} ` ); 1644} 1645await page . keyboard . press ( 'Escape' ); 1646await page . waitForTimeout ( 400 ); 1647console . log ( 'closed:' , await page . locator ( '.modal[data-open="true"]' ). count () === 0 ); 1648await shot ( '150-palette-fuzzy' ); 1649} 1650 1651if ( flow === 'telemetry' ) { 1652await page . click ( 'text=New session' ); 1653await page . waitForTimeout ( 400 ); 1654await page . fill ( 'textarea' , 'read the readme and summarise it' ); 1655await page . keyboard . press ( 'Enter' ); 1656await page . waitForTimeout ( 7000 ); 1657await page . keyboard . press ( 'Enter' ); 1658await page . waitForTimeout ( 7000 ); 1659 1660const chips = await page . locator ( '.telemetry__chip' ). count (); 1661console . log ( 'telemetry chips:' , chips ); 1662const titles = [ 'Session statistics' , 'Token usage' , 'Context' ]; 1663for ( let i = 0 ; i < titles . length ; i += 1 ) { 1664await page . locator ( '.telemetry__chip' ). nth ( i ). click (); 1665await page . waitForTimeout ( 450 ); 1666const head = await page . textContent ( '.telepop__head' ). catch (() => null ); 1667const rows = await page . locator ( '.telepop__row' ). count (); 1668console . log ( ` ${ titles [ i ]} : head=" ${ head ?. trim ()} " rows= ${ rows } ` ); 1669await shot ( `14 ${ i } -telepop- ${ titles [ i ]. toLowerCase (). replace ( / / g , '-' )} ` ); 1670await page . keyboard . press ( 'Escape' ); 1671await page . waitForTimeout ( 300 ); 1672const gone = await page . locator ( '.telepop' ). count (); 1673if ( gone !== 0 ) console . log ( ` WARNING: ${ titles [ i ]} did not close on Escape` ); 1674} 1675await page . click ( 'button[title="Switch to dark"]' ); 1676await page . waitForTimeout ( 500 ); 1677await page . locator ( '.telemetry__chip' ). nth ( 2 ). click (); 1678await page . waitForTimeout ( 450 ); 1679await shot ( '143-telepop-dark' ); 1680await page . keyboard . press ( 'Escape' ); 1681} 1682 1683if ( flow === 'focus' ) { 1684await page . click ( 'text=New conversation' ); 1685await page . waitForTimeout ( 400 ); 1686await page . fill ( 'textarea' , 'Explain what a KV cache does, in plain words' ); 1687await page . keyboard . press ( 'Enter' ); 1688await page . waitForTimeout ( 7000 ); 1689await shot ( '130-chat-normal' ); 1690await page . keyboard . press ( 'Meta+Shift+F' ); 1691await page . waitForTimeout ( 900 ); 1692await shot ( '131-focus-mode' ); 1693// reading size should move only the conversation 1694await page . keyboard . press ( 'Escape' ); 1695await page . waitForTimeout ( 700 ); 1696const exited = await page . evaluate (() => ! document . documentElement . dataset . focus ); 1697console . log ( 'Esc left focus mode:' , exited ); 1698} 1699 1700if ( flow === 'overlays' ) { 1701await page . goto ( ` ${ BASE } /#/launch` , { waitUntil :'domcontentloaded' }); 1702await page . waitForTimeout ( 1200 ); 1703await page . keyboard . press ( 'Meta+k' ); 1704await page . waitForTimeout ( 700 ); 1705await shot ( '120-palette' ); 1706await page . type ( '.modal input' , 'serv' ); 1707await page . waitForTimeout ( 500 ); 1708await shot ( '121-palette-filtered' ); 1709await page . keyboard . press ( 'Escape' ); 1710await page . waitForTimeout ( 400 ); 1711await page . keyboard . press ( 'Meta+Slash' ); 1712await page . waitForTimeout ( 700 ); 1713await shot ( '122-shortcuts' ); 1714} 1715 1716if ( flow === 'panel' ) { 1717await page . click ( 'text=New conversation' ); 1718await page . waitForTimeout ( 500 ); 1719await page . fill ( 'textarea' , 'Read the README and summarise it' ); 1720await page . keyboard . press ( 'Enter' ); 1721await page . waitForTimeout ( 5200 ); 1722await page . click ( 'button[title="Conversation context"]' ); 1723await page . waitForTimeout ( 1000 ); 1724await shot ( '100-context-panel' ); 1725} 1726 1727if ( flow === 'sampling' ) { 1728await page . click ( 'text=New conversation' ); 1729await page . waitForTimeout ( 500 ); 1730await page . click ( 'button[title="Sampling — temperature and friends"]' ); 1731await page . waitForTimeout ( 900 ); 1732await shot ( '95-sampling-drawer' ); 1733const slider = page . locator ( '.st-slider' ). first (); 1734await slider . focus (); 1735for ( let i = 0 ; i < 6 ; i += 1 ) await page . keyboard . press ( 'ArrowRight' ); 1736await page . waitForTimeout ( 900 ); 1737await shot ( '96-sampling-changed' ); 1738} 1739 1740if ( flow === 'commands' ) { 1741await page . click ( 'text=New conversation' ); 1742await page . waitForTimeout ( 400 ); 1743await page . click ( 'textarea' ); 1744await page . type ( 'textarea' , '/' ); 1745await page . waitForTimeout ( 600 ); 1746await shot ( '80-slash-menu' ); 1747await page . type ( 'textarea' , 'mon' ); 1748await page . waitForTimeout ( 500 ); 1749await shot ( '81-slash-filtered' ); 1750await page . keyboard . press ( 'Escape' ); 1751await page . waitForTimeout ( 300 ); 1752await page . keyboard . press ( 'Meta+Slash' ); 1753await page . waitForTimeout ( 700 ); 1754await shot ( '82-shortcuts' ); 1755} 1756 1757if ( flow . startsWith ( 'tour' )) { 1758const prefix = process . argv [ 3 ] ?? 'tour' ; 1759// tour-dark flips the theme first so both palettes are captured from one run. 1760if ( flow === 'tour-dark' ) { 1761await page . click ( 'button[title="Switch to dark"]' ); 1762await page . waitForTimeout ( 600 ); 1763} 1764const routes = [ 'launch' , 'chat' , 'models' , 'tuning' , 'serving' , 'monitor' , 'workspace' , 'skills' , 'settings' ]; 1765for ( const r of routes ) { 1766await page . goto ( ` ${ BASE } /#/ ${ r } ` , { waitUntil :'domcontentloaded' }); 1767await page . waitForTimeout ( 1600 ); 1768await shot ( ` ${ prefix } - ${ r } ` ); 1769} 1770await page . goto ( ` ${ BASE } /#/setup` , { waitUntil :'domcontentloaded' }); 1771await page . waitForTimeout ( 2000 ); 1772await shot ( ` ${ prefix } -setup` ); 1773} 1774 1775if ( flow === 'light' ) { 1776/* Sets the theme rather than toggling to it: this flow used to click 1777"Switch to light", which only exists while the app is dark. Light is the 1778default now, so the control was correctly absent and the flow failed on a 1779button that should not have been there. */ 1780await page . evaluate (() => { 1781const raw = JSON . parse ( localStorage . getItem ( 'strata.prefs.v2' ) ?? '{}' ); 1782localStorage . setItem ( 'strata.prefs.v2' , JSON . stringify ({ ...raw , theme :'light' })); 1783}); 1784await page . reload ({ waitUntil :'domcontentloaded' }); 1785await page . waitForTimeout ( 1200 ); 1786await page . goto ( ` ${ BASE } /#/models` , { waitUntil :'domcontentloaded' }); 1787await page . waitForTimeout ( 1200 ); 1788await shot ( '50-models-light' ); 1789await page . goto ( ` ${ BASE } /#/monitor` , { waitUntil :'domcontentloaded' }); 1790await page . waitForTimeout ( 1400 ); 1791await shot ( '51-monitor-light' ); 1792} 1793 1794await browser . close (); 1795console . log ( problems . length ?`problems:\n ${ problems . slice ( 0 , 10 ). join ( '\n ' )} ` :'no console errors' );