okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
ea2d565e6
main
1import { tr } from '../lib/i18n' ; 2import { useEffect , useRef , useState } from 'react' ; 3import { Brand } from './Brand' ; 4import { Icon } from './ui' ; 5/** Vector artwork stays sharp, interactive and honours reduced motion. */ 6export function OnboardingArt ({ kind= 'welcome' , progress= 0 , counter} :{ 7kind ?:'welcome' | 'download' | 'tune' ; 8progress ?:number ; 9counter ?:{ 10value :number | undefined ; 11label :string ; 12key :string ; 13}; 14}) { 15return < div className = { `onboard-art onboard-art-- ${ kind } ` } aria-hidden = { kind !== 'download' }> 16< div aria-hidden = "true" className = "onboard-orbit onboard-orbit--one" />< div className = "onboard-orbit onboard-orbit--two" /> 17< div className = "onboard-art-grid" /> 18{ tr ( kind === 'welcome' ?<> 19< div className = "onboard-float onboard-float--chat" >< Icon name = "chat" size = { 19 }/>< span >{ tr ( "A little help." )}< br />< strong >{ tr ( "A lot more possible." )}</ strong ></ span ></ div > 20< div className = "onboard-float onboard-float--file" >< Icon name = "file" size = { 20 }/>< span >{ tr ( "your-next-idea.md" )}< small >{ tr ( "Right here, on your computer" )}</ small ></ span ></ div > 21< div className = "onboard-local-machine" >< div className = "onboard-machine-screen" >< Brand variant = "mark" height = { 36 } decorative />< div className = "onboard-machine-line" />< div className = "onboard-machine-line short" />< div className = "onboard-machine-answer" >< i />< i />< i /></ div ></ div >< div className = "onboard-machine-base" />< span className = "onboard-local-badge" >< span />{ tr ( " Local AI. Yours." )}</ span ></ div > 22< div className = "onboard-float onboard-float--spark" >< Icon name = "bolt" size = { 20 }/></ div > 23</> :kind === 'download' ?<> 24< div aria-hidden = "true" className = "onboard-data-packet packet-one" >< Icon name = "file" size = { 18 }/></ div >< div aria-hidden = "true" className = "onboard-data-packet packet-two" >< Icon name = "image" size = { 18 }/></ div >< div aria-hidden = "true" className = "onboard-data-packet packet-three" >< Icon name = "file" size = { 18 }/></ div > 25< div aria-hidden = "true" className = "onboard-download-core" >< div className = "onboard-download-ring" style = {{ '--download-progress' :` ${ Math . min ( 100 , Math . max ( 0 , progress ))} %` } as React . CSSProperties }>< Icon name = "models" size = { 40 }/></ div >< div className = "onboard-download-stack" >< i />< i />< i /></ div ></ div > 26{ tr ( counter ?< DownloadCounter key = { counter . key } value = { counter . value } label = { tr ( counter . label )}/> :null )} 27</> :<> 28< div className = "onboard-chip" >< div className = "onboard-chip-pins" />< Icon name = "cpu" size = { 56 }/>< div className = "onboard-chip-light" /></ div > 29< div className = "onboard-float onboard-float--cpu" >< Icon name = "cpu" size = { 18 }/>< span >{ tr ( "Your CPU" )}< small >{ tr ( "Finding its rhythm" )}</ small ></ span ></ div > 30< div className = "onboard-float onboard-float--gpu" >< Icon name = "gpu" size = { 18 }/>< span >{ tr ( "Your GPU" )}< small >{ tr ( "Working together" )}</ small ></ span ></ div > 31< span className = "onboard-local-badge" >< span />{ tr ( " Tuned to your computer" )}</ span > 32</>)} 33</ div >; 34} 35function DownloadCounter ({ value, label} :{ 36value :number | undefined ; 37label :string ; 38}) { 39// Reset at each shard; animate only from reported download data. 40const [ shown , setShown ] = useState ( value ), previous = useRef ( value ); 41useEffect (() => { 42const from = previous . current ; 43previous . current = value ; 44if ( value === undefined || from === undefined || matchMedia ( '(prefers-reduced-motion: reduce)' ). matches ) { 45setShown ( value ); 46return ; 47} 48const start = performance . now (); 49let frame = 0 ; 50const tick = ( now :number ) => { const t = Math . min ( 1 , ( now - start ) / 650 ); setShown ( from + ( value - from ) * ( 1 - Math . pow ( 1 - t , 3 ))); if ( t < 1 ) 51frame = requestAnimationFrame ( tick ); }; 52frame = requestAnimationFrame ( tick ); 53return () => cancelAnimationFrame ( frame ); 54}, [ value ]); 55return < div className = "onboard-download-counter" role = "img" aria-label = { tr ( value === undefined ?label :` ${ value . toFixed ( 1 )} ${ label } ` )}>< Icon name = "download" size = { 18 }/>< strong aria-hidden = "true" >{ tr ( shown === undefined ?'···' :shown . toFixed ( 1 ))}</ strong >< span aria-hidden = "true" >{ tr ( label )}</ span ></ div >; 56} 57const tour = [ 58{ label :'Time-skip' , command :'/time-skip' , prompt :'Improve this launch plan.' , title :'Keep the stronger idea.' , description :'Type /time-skip and what you want to improve. Strata explores a revision, compares it with the original, and keeps the stronger version.' , badge :'' , steps :[ 'Save the original' , 'Explore a revision' , 'Compare and keep' ] }, 59{ label :'Goal' , command :'/goal' , prompt :'Get my portfolio ready to publish.' , title :'Give your AI a finish line.' , description :'A goal describes the outcome you want. Strata will plan the work, check its progress, and keep going until that outcome is reached.' , badge :'' , steps :[ 'Set the outcome' , 'Work through the plan' , 'Check the result' ] }, 60{ label :'Loop' , command :'/loop' , prompt :'10m check whether the build passes.' , title :'Let useful work repeat.' , description :'Type /loop, how often, and what to do — for example /loop 10m check the build. Strata sends it again and again while the chat is open. For work that must go on with Strata closed, use Tasks.' , badge :'' , steps :[ 'Say how often' , 'Say what to do' , 'Stop any time' ] }, 61{ label :'Subagents' , command :'Spawn subagents' , prompt :'to research, draft and review my launch plan.' , title :'More hands, one conversation.' , description :'Ask “spawn subagents” in chat and describe the jobs. Separate agents can research, write and review in parallel, then bring their work back to you.' , badge :'' , steps :[ 'Describe the jobs' , 'Agents work in parallel' , 'Bring the results together' ] }, 62] as const ; 63export function OnboardingTour ({ page, onChange} :{ 64page :number ; 65onChange :( page :number ) => void ; 66}) { 67const [ phase , setPhase ] = useState ( 0 ), [ replay , setReplay ] = useState ( 0 ); 68useEffect (() => { const motion = matchMedia ( '(prefers-reduced-motion: reduce)' ); setPhase ( motion . matches ?2 :0 ); if ( motion . matches ) 69return ; const timer = setInterval (() => setPhase ( value => ( value + 1 ) % 3 ), 2600 ); return () => clearInterval ( timer ); }, [ page , replay ]); 70const item = tour [ page % tour . length ]; 71return < section className = "onboard-tour" aria-label = { tr ( "A quick tour of Strata" )}> 72< div className = "onboard-tour-top" >< span >{ tr ( "Try this in Strata" )}</ span >< div role = "tablist" aria-label = { tr ( "Tour topic" )}>{ tr ( tour . map (( t , i ) => < button key = { t . label } type = "button" role = "tab" id = { `onboard-tour-tab- ${ i } ` } aria-controls = "onboard-tour-content" aria-selected = { page === i } tabIndex = { page === i ?0 :- 1 } onClick = {() => onChange ( i )} onKeyDown = { e => { if ([ 'ArrowLeft' , 'ArrowRight' , 'Home' , 'End' ]. includes ( e . key )) { 73e . preventDefault (); 74const next = e . key === 'Home' ?0 :e . key === 'End' ?tour . length - 1 :( page + ( e . key === 'ArrowLeft' ?- 1 :1 ) + tour . length ) % tour . length ; 75onChange ( next ); 76e . currentTarget . parentElement ?. querySelectorAll < HTMLButtonElement >( '[role=tab]' )[ next ]?. focus (); 77} }}>{ tr ( t . label )}</ button >))}</ div ></ div > 78< div className = "onboard-tour-content" role = "tabpanel" id = "onboard-tour-content" aria-labelledby = { `onboard-tour-tab- ${ page } ` } key = { ` ${ page } - ${ replay } ` }> 79< div className = "onboard-tour-demo-label" >< span >{ tr ( "Example" )}</ span >{ tr ( item . badge ?< span >{ tr ( item . badge )}</ span > :null )}</ div > 80< div className = { `onboard-tour-preview preview- ${ page } ` } data-phase = { phase } aria-hidden = "true" > 81< div className = "tour-prompt" >< Icon name = "chat" size = { 15 }/>< span >< strong >{ tr ( item . command )}</ strong >{ tr ( item . prompt ?` ${ item . prompt } ` :'' )}</ span >< Icon name = "send" size = { 14 }/></ div > 82{ tr ( page === 0 ?<>< div className = "tour-directions" >< div data-active = { phase === 0 }>< Icon name = "file" size = { 19 }/>< strong >{ tr ( "Original" )}</ strong >< small >{ tr ( "Saved safely" )}</ small >< i />< i /></ div >< div data-active = { phase > 0 }>< Icon name = "branch" size = { 19 }/>< strong >{ tr ( "Revision" )}</ strong >< small >{ tr ( phase === 2 ?'Clearer next steps' :'Exploring an idea' )}</ small >< i />< i /></ div ></ div >< div className = "tour-outcome" key = { phase }>< Icon name = { phase === 2 ?'check' :'branch' } size = { 15 }/>{ tr ([ 'Original saved' , 'Trying a new direction' , 'Stronger version kept' ][ phase ])}</ div ></> :page === 1 ?<>< div className = "tour-goal" >< Icon name = "gauge" size = { 22 }/>< span >{ tr ( "Portfolio ready to publish" )}< small >{ tr ( "Clear outcome \u00B7 measurable progress" )}</ small ></ span ></ div >< div className = "tour-goal-checks" >{ tr ([ 'Choose the best work' , 'Write project stories' , 'Check every page' ]. map (( label , i ) => < span key = { label } data-complete = { phase >= i }>< Icon name = { phase >= i ?'check' :'clock' } size = { 13 }/>{ tr ( label )}</ span >))}</ div ></> :page === 2 ?<>< div className = "tour-loop" >< div >< Icon name = "clock" size = { 20 }/>< strong >{ tr ( "Daily briefing" )}</ strong >< span > 08:00 </ span ></ div >< div className = "tour-week" >{ tr ([ 'M' , 'T' , 'W' , 'T' , 'F' , 'S' , 'S' ]. map (( day , i ) => < span key = { i } data-selected = { i < 5 } data-active = { i === phase }>{ tr ( day )}</ span >))}</ div >< small >{ tr ( "Repeats every weekday" )}</ small ></ div >< div className = "tour-outcome" key = { phase }>< Icon name = { phase === 2 ?'check' :'clock' } size = { 15 }/>{ tr ([ 'Schedule your task' , 'Tomorrow is already planned' , 'A fresh briefing, every morning' ][ phase ])}</ div ></> :<>< div className = "tour-agents" >{ tr ([{ name :'Research' , icon :'search' }, { name :'Draft' , icon :'pencil' }, { name :'Review' , icon :'check' }]. map (( agent , i ) => < div key = { agent . name } style = {{ '--agent-delay' :` ${ i * .18 } s` } as React . CSSProperties }>< Icon name = { agent . icon as 'search' | 'pencil' | 'check' } size = { 19 }/>< strong >{ tr ( agent . name )}</ strong >< span >{ tr ( phase === 2 ?'Done' :'Working…' )}</ span >< i /></ div >))}</ div >< div className = "tour-outcome" key = { phase }>< Icon name = { phase === 2 ?'check' :'experts' } size = { 15 }/>{ tr ( phase === 2 ?'One plan, brought together' :'Three jobs moving together' )}</ div ></>)} 83</ div >< h3 >{ tr ( item . title )}</ h3 >< p >{ tr ( item . description )}</ p >< ol className = "onboard-tour-steps" >{ tr ( item . steps . map (( text , i ) => < li key = { text } data-active = { phase === i }>< span >{ tr ( i + 1 )}</ span >{ tr ( text )}</ li >))}</ ol > 84</ div >< div className = "onboard-tour-bottom" >< button type = "button" aria-label = { tr ( "Replay this tip" )} onClick = {() => setReplay ( value => value + 1 )}>< Icon name = "refresh" size = { 13 }/>{ tr ( "Replay" )}</ button >< span >{ tr ( page + 1 )} / { tr ( tour . length )}</ span >< button type = "button" onClick = {() => onChange (( page + 1 ) % tour . length )}>{ tr ( page === tour . length - 1 ?'Start again' :'Next tip' )}< Icon name = "chevron" size = { 14 }/></ button ></ div > 85</ section >; 86}