okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
a1cc285fa
main
1import { CopyBtn } from '../components/CopyBtn' ; 2import { tr } from '../lib/i18n' ; 3import { appBaseUrl } from '../lib/connect-urls' ; 4import { deviceLabel , instanceLabel } from '../lib/runtime-models' ; 5import { nativeRouting , useNative } from '../lib/native' ; 6/** Connection facts first. Instructions and request details open only on demand. */ 7import { CloudflareDialog } from '../components/CloudflareDialog' ; 8import { useEffect , useRef , useState } from 'react' ; 9import { Btn , Dialog , Empty , Icon , IconBtn , Seg , Select , ErrorNotice } from '../components/ui' ; 10import { Screen , SectionHead } from '../components/layout' ; 11import { clockTime , duration , tokens } from '../lib/format' ; 12import { cancelRequest , setLocalSharing , setServingAccess , useStore } from '../lib/store' ; 13export function ServingScreen () { 14const serving = useStore ( s => s . serving ); 15const storedRuntime = useStore ( s => s . runtime ), hardware = useStore ( s => s . hardware ); 16const native = useNative (); 17const runtime = nativeRouting ( native , hardware ) ?? storedRuntime ; 18const [ modelFilter , setModelFilter ] = useState ( 'all' ), [ guideModel , setGuideModel ] = useState ( '' ); 19const [ selectedId , setSelectedId ] = useState < string | null >( null ); 20const [ guide , setGuide ] = useState ( false ); 21const [ protocol , setProtocol ] = useState < 'openai' | 'responses' | 'anthropic' >( 'openai' ); 22const [ filter , setFilter ] = useState < 'all' | 'active' | 'done' | 'error' >( 'all' ); 23const [ query , setQuery ] = useState ( '' ); 24const [ sort , setSort ] = useState < 'at' | 'durationMs' >( 'at' ); 25const [ cloudflareOpen , setCloudflareOpen ] = useState ( false ); 26const [ returnToTunnel , setReturnToTunnel ] = useState ( false ); 27const [ keyOpen , setKeyOpen ] = useState ( false ); 28const [ keyVisible , setKeyVisible ] = useState ( false ); 29const [ sharingOpen , setSharingOpen ] = useState ( false ); 30const [ generated , setGenerated ] = useState ( false ); 31const [ removeKeyOpen , setRemoveKeyOpen ] = useState ( false ); 32const [ keyDraft , setKeyDraft ] = useState ( '' ); 33const [ pending , setPending ] = useState ( false ); 34const [ error , setError ] = useState ( '' ); 35function generateKey () { setKeyVisible ( false ); const bytes = crypto . getRandomValues ( new Uint8Array ( 32 )); setKeyDraft ( 'sk-strata-' + Array . from ( bytes , v => v . toString ( 16 ). padStart ( 2 , '0' )). join ( '' )); setGenerated ( true ); } 36function closeKey () { 37setKeyVisible ( false ); 38setKeyOpen ( false ); 39setKeyDraft ( '' ); 40if ( returnToTunnel ) { 41setReturnToTunnel ( false ); 42setCloudflareOpen ( true ); 43} 44} 45const selected = serving ?. requests . find ( r => r . id === selectedId ); 46const requestedCancel = useRef < string | null >( null ); 47const cancelResult = useRef < HTMLDivElement >( null ); 48useEffect (() => { 49if ( selected ?. id === requestedCancel . current && selected ?. cancellable === false && cancelResult . current ) { 50cancelResult . current . focus (); 51requestedCancel . current = null ; 52} 53}, [ selected ?. id , selected ?. cancellable ]); 54if ( ! serving ) 55return < Screen title = { tr ( "Serving" )}>< p className = "muted" >{ tr ( "Waiting for API status\u2026" )}</ p ></ Screen >; 56const multipleModels = ( runtime ?. instances . length ?? 0 ) > 1 ; 57const filterId = multipleModels && runtime ?. instances . some ( i => i . id === modelFilter ) ?modelFilter :'all' ; 58const loaded = runtime ?. instances . find ( i => i . apiModelId === guideModel ) ?? runtime ?. instances . find ( i => i . id === runtime . defaultId ); 59const scopeRequests = filterId === 'all' ?serving . requests :serving . requests . filter ( r => r . instanceId === filterId ); 60const scopeStats = filterId === 'all' ?serving . stats :{ running :scopeRequests . filter ( r => r . state === 'generating' ). length , waiting :scopeRequests . filter ( r => r . state === 'queued' ). length , completed :scopeRequests . filter ( r => r . state === 'done' ). length }; 61const modelOptions = ( runtime ?. instances ?? []). map ( i => ({ value :i . apiModelId , label :` ${ instanceLabel ( i )} · ${ deviceLabel ( i . gpuIds , hardware )} ` })); 62const requests = serving . requests . filter ( r => ( filterId === 'all' || r . instanceId === filterId ) && ( filter === 'all' || ( filter === 'active' ?[ 'generating' , 'queued' ]. includes ( r . state ) :r . state === filter )) && ` ${ r . client } ${ r . id } ${ r . endpoint } ${ r . model } ` . toLowerCase (). includes ( query . toLowerCase ())). sort (( a , b ) => sort === 'durationMs' ?b . durationMs - a . durationMs :b . at . localeCompare ( a . at )); 63async function operation ( action :() => Promise < void >) { 64setPending ( true ); 65setError ( '' ); 66try { 67await action (); 68} 69catch ( e ) { 70setError ( e instanceof Error ?e . message :String ( e )); 71} 72finally { 73setPending ( false ); 74} 75} 76// While sharing is on there are two addresses: the app's own, and the one other devices use on its own port (#4798). 77const twoAddresses = !! serving . sharing ?. active && !! serving . sharing . url && !! serving . localUrl && serving . localUrl !== serving . sharing . url ; 78const code = `curl ${ serving . baseUrl } ${ protocol === 'responses' ? '/responses' : protocol === 'openai' ? serving . endpoints . openai : serving . endpoints . anthropic } \\\n -H 'Content-Type: application/json' ${ serving . access . apiKeySet ? " \\\n -H 'Authorization: Bearer YOUR_API_KEY'" : '' } \\\n -d ' ${ JSON . stringify ({ model : loaded ?. apiModelId ?? 'YOUR_MODEL_ID' , ... ( protocol === 'responses' ? { input : 'Hello' , store : false } : { ... ( protocol === 'anthropic' ? { max_tokens : 256 } : {}), messages : [{ role : 'user' , content : 'Hello' }] }) }, null , 2 )} '` ; 79return < Screen title = { tr ( "Serving" )} actions = {<>< Btn icon = "link" onClick = {() => setCloudflareOpen ( true )}>{ tr ( "Cloudflare tunnel" )}</ Btn >< IconBtn name = "info" title = { tr ( "Connection guide" )} onClick = {() => setGuide ( true )}/></>}>< div className = "stack stack--lg" > 80< section className = "st-card serving-overview" >< dl className = "summary-list" >< div >< dt >{ tr ( twoAddresses ?"API base URL on this computer" :"API base URL" )}</ dt >< dd className = "row" >< code style = {{ overflowWrap :'anywhere' }}>{ twoAddresses ?serving . localUrl :serving . baseUrl }</ code >< CopyBtn text = {( twoAddresses ?serving . localUrl :serving . baseUrl ) ?? '' } label = "API base URL" title = "Copy API base URL" /></ dd ></ div >{ tr ( twoAddresses ?< div >< dt >{ tr ( "Address for other devices" )}</ dt >< dd >< div className = "row" >< code style = {{ overflowWrap :'anywhere' }}>{ serving . sharing ! . url }</ code >< CopyBtn text = { serving . sharing ! . url ! } label = "Local network URL" title = "Copy local network URL" /></ div >< p className = "xs muted serving-two-addresses" >{ tr ( "Other devices use this address. It has its own port, separate from the one Strata's window uses, because only the model's API is shared on the network, not the app." )}</ p ></ dd ></ div > :null )}{ tr ( ! multipleModels ?< div >< dt >{ tr ( "Model ID" )}</ dt >< dd className = "row" >< code >{ loaded ?. apiModelId ?? 'No model loaded' }</ code >< CopyBtn text = { loaded ?. apiModelId ?? '' } label = "Model ID" title = "Copy Model ID" disabled = { ! loaded }/></ dd ></ div > :null )}< div >< dt >{ tr ( "Status" )}</ dt >< dd >< span className = "api-status" data-active = { serving . running }>< span className = "api-status__dot" />{ tr ( serving . running ?'API listening' :'API stopped' )} · { tr ( multipleModels ?` ${ runtime ?. instances . length } models loaded` :loaded ?'Model ready' :'Model not ready' )}</ span ></ dd ></ div >< div >< dt >{ tr ( "Local network" )}</ dt >< dd className = "row" >< span className = "request-status" data-state = { serving . sharing ?. active ?"shared" :"queued" }>{ tr ( serving . sharing ?. active ?"Shared on local network" :"Off" )}</ span >< Btn size = "sm" onClick = {() => { setError ( '' ); setSharingOpen ( true ); }}>{ tr ( serving . sharing ?. active ?"Manage / stop" :"Share" )}</ Btn ></ dd ></ div >{ tr ( serving . tunnel ?. status === "connected" && serving . tunnel . url ?< div >< dt >{ tr ( "Cloudflare tunnel" )}</ dt >< dd className = "row" >< code style = {{ overflowWrap :"anywhere" }}>{ serving . tunnel . url }</ code >< CopyBtn text = { serving . tunnel . url } label = "Cloudflare tunnel URL" title = "Copy Cloudflare tunnel URL" />< IconBtn name = "settings" title = { tr ( "Manage Cloudflare tunnel" )} onClick = {() => setCloudflareOpen ( true )}/></ dd ></ div > :serving . tunnel ?. status === "starting" ?< div >< dt >{ tr ( "Cloudflare tunnel" )}</ dt >< dd role = "status" >{ tr ( "Connecting\u2026" )}</ dd ></ div > :null )}< div className = "serving-access-row" >< dt >{ tr ( "API key" )}</ dt >< dd >< div className = "serving-access-status" >{ tr ( serving . access . apiKeySet ?< span className = "small muted" >{ tr ( "Required \u00B7 " )}{ tr ( serving . access . apiKeyHint )}</ span > :null )}< div className = "row" >< Btn size = "sm" onClick = {() => { setError ( '' ); generateKey (); setKeyOpen ( true ); }}>{ tr ( serving . access . apiKeySet ?'Change key' :'Set key' )}</ Btn >{ tr ( serving . access . apiKeySet ?< Btn size = "sm" onClick = {() => { setError ( '' ); setRemoveKeyOpen ( true ); }}>{ tr ( "Remove key" )}</ Btn > :null )}</ div ></ div >{ tr ( serving . access . otherDevices ?< span className = "xs muted" >{ tr ( "Keep a key while the API is available to other devices." )}</ span > :null )}</ dd ></ div ></ dl ></ section > 81{ tr ( multipleModels ?< section className = "st-card serving-models" aria-label = { tr ( "Available API models" )}>< div className = "section-toolbar" >< h2 className = "h4" >{ tr ( "Available models" )}</ h2 >< span className = "xs muted" >{ tr ( "One API URL \u00B7 route by model ID" )}</ span ></ div > 82{ tr ( runtime ?. instances . length ?< div className = "serving-models__list" >{ tr ( runtime . instances . map ( i => < div key = { i . id } className = "serving-model" >< div >< strong >{ tr ( i . family )}</ strong >< small >{ tr ( i . name )} · { tr ( i . memory . context / 1024 )}{ tr ( "K \u00B7 " )}{ tr ( deviceLabel ( i . gpuIds , hardware ))}</ small ></ div >< code >{ i . apiModelId }</ code >< CopyBtn text = { i . apiModelId } label = "Model ID" title = { tr ( "Copy model ID {0}" , [ i . apiModelId ])}/></ div >))}</ div > :< p className = "small muted" >{ tr ( "Load a model in Models to make it available here." )}</ p >)} 83< p className = "xs muted" >{ tr ( "Set " )}< code > model </ code >{ tr ( " in each request. Each model has its own queue." )}{ tr ( runtime ?. mode === 'simulated' ?' Design preview · responses are illustrative.' :'' )}</ p > 84</ section > :null )} 85< section className = "request-section" >< SectionHead title = { tr ( "Requests" )}/>< p className = "small muted" >{ tr ( scopeStats . running )}{ tr ( " active \u00B7 " )}{ tr ( scopeStats . waiting )}{ tr ( " queued \u00B7 " )}{ tr ( scopeStats . completed )}{ tr ( " completed" )}</ p >< div className = "section-toolbar" >< Seg value = { filter } ariaLabel = { tr ( "Request status filter" )} options = {[{ value :'all' , label :'All' }, { value :'active' , label :'Active' }, { value :'done' , label :'Done' }, { value :'error' , label :'Errors' }]} onChange = { setFilter }/>{ tr ( multipleModels ?< Select ariaLabel = { tr ( "Serving model filter" )} value = { filterId } options = {[{ value :'all' , label :'All models' }, ...( runtime ?. instances ?? []). map ( i => ({ value :i . id , label :instanceLabel ( i ) }))]} onChange = { setModelFilter }/> :null )}< input className = "st-input" aria-label = { tr ( "Search requests" )} placeholder = { tr ( "Client, model or request ID…" )} value = { query } onChange = { e => setQuery ( e . target . value )}/></ div > 86{ tr ( requests . length ?< div className = "st-tablewrap" >< table className = "st-table" >< thead >< tr >< th aria-sort = { sort === 'at' ?'descending' :'none' }>< button className = "st-btn st-btn--ghost st-btn--sm" onClick = {() => setSort ( 'at' )}>{ tr ( "Time" )}</ button ></ th >< th >{ tr ( "Client / endpoint" )}</ th >{ tr ( multipleModels ?< th >{ tr ( "Model" )}</ th > :null )}< th >{ tr ( "Status" )}</ th >< th >{ tr ( "Tokens in / out" )}</ th >< th aria-sort = { sort === 'durationMs' ?'descending' :'none' }>< button className = "st-btn st-btn--ghost st-btn--sm" onClick = {() => setSort ( 'durationMs' )}>{ tr ( "Duration" )}</ button ></ th ></ tr ></ thead >< tbody >{ tr ( requests . map ( r => < tr key = { r . id }>< td >< button className = "st-btn st-btn--ghost st-btn--sm" aria-label = { tr ( "View request {0}" , [ r . id ])} onClick = {() => setSelectedId ( r . id )}>{ tr ( clockTime ( r . at ))}</ button ></ td >< td >{ tr ( r . client )}< div className = "xs muted" >{ tr ( r . endpoint )}</ div ></ td >{ tr ( multipleModels ?< td >< code className = "xs" >{ r . model }</ code ></ td > :null )}< td >{ tr (< span className = "request-status" data-state = { r . state }>{ tr ( r . cancelRequested ?r . cancellable ?'Cancelling…' :'Cancelled' :r . state . charAt ( 0 ). toUpperCase () + r . state . slice ( 1 ))}</ span >)}</ td >< td className = "num" >{ tr ( tokens ( r . tokensIn ))} / { tr ( tokens ( r . tokensOut ))}< div className = "xs muted" >{ tr ( r . usageSource === 'demo' ?'Simulated' :r . usageSource === 'reported' ?'Reported by model' :'Usage unavailable' )}</ div ></ td >< td className = "num" >{ tr ( r . durationMs ?duration ( r . durationMs ) :'—' )}</ td ></ tr >))}</ tbody ></ table ></ div > :< Empty icon = "link" title = { tr ( serving . requests . length ?'No matching requests' :'No requests yet' )} body = { serving . requests . length ?'Try another filter or client name.' :'Requests appear here when a client or Strata chat uses the API.' } action = { tr ( serving . requests . length ?< Btn onClick = {() => { setQuery ( '' ); setFilter ( 'all' ); setModelFilter ( 'all' ); }}>{ tr ( "Clear filters" )}</ Btn > :< Btn variant = "primary" onClick = {() => setGuide ( true )}>{ tr ( "Connect an app" )}</ Btn >)}/>)}</ section > 87 88{ tr ( error ?< ErrorNotice message = { error }/> :null )} 89</ div >< Dialog open = { guide } title = { tr ( "Connect Strata to an app" )} onClose = {() => setGuide ( false )} headerActions = {< div className = "protocol-switch" >< Seg panelId = "api-protocol-panel" value = { protocol } ariaLabel = { tr ( "API protocol" )} options = {[{ value :'openai' , label :'Chat Completions' }, { value :'responses' , label :'Responses' }, { value :'anthropic' , label :'Anthropic' }]} onChange = { setProtocol }/></ div >} sheet >< div className = "stack" >{ tr ( multipleModels ?< label className = "input-field" >< span >{ tr ( "Model for this app" )}</ span >< Select ariaLabel = { tr ( "Connection guide model" )} value = { loaded ?. apiModelId ?? '' } options = { modelOptions } disabled = { ! modelOptions . length } onChange = { setGuideModel }/></ label > :null )}< ol >< li >{ tr ( "In your client, choose a compatible provider." )}</ li >< li >{ tr ( "Set its base URL to " )}< code >{ appBaseUrl ( serving . baseUrl , protocol )}</ code > . </ li >< li >{ tr ( "Use model ID " )}< code >{ loaded ?. apiModelId ?? 'from the Models screen after loading' }</ code > . </ li >< li >{ tr ( serving . access . apiKeySet ?'Enter your existing API key in the client.' :'This local API has no key configured.' )}</ li ></ ol >{ tr ( protocol === 'anthropic' ?< p className = "small muted" >{ tr ( "Anthropic apps add /v1/messages themselves, so this address has no /v1 at the end. In Claude Code, set ANTHROPIC_BASE_URL to it." )}</ p > :null )}{ tr ( protocol === 'responses' && ( ! native ?. instances . some ( i => i . status === 'ready' ) || native . capabilities . responses === false ) ?< p className = "small muted" >{ tr ( "Responses requires a running native model and a Strata version that supports this API. Update the native installation in Settings \u2192 About if needed." )}</ p > :null )}< div id = "api-protocol-panel" role = "tabpanel" aria-labelledby = { `api-protocol-panel-tab- ${ protocol } ` } tabIndex = { 0 }>< div className = "st-code" >< div className = "st-code__head" >< span >{ tr ( "curl" )}</ span >< CopyBtn text = { code } label = "Request template" title = "Copy request template" /></ div >< pre >{ code }</ pre ></ div >< p className = "xs muted" >{ tr ( "Model list: " )}{ tr ( serving . baseUrl )}{ tr ( serving . endpoints . models )}{ tr ( ". Network access depends on the host\u2019s listen address and your firewall." )}</ p ></ div ></ div ></ Dialog > 90< Dialog open = { !! selectedId } title = { tr ( "Request details" )} onClose = {() => setSelectedId ( null )} sheet >{ tr ( selected ?<>< dl className = "summary-list" >< div >< dt >{ tr ( "ID" )}</ dt >< dd className = "mono" >{ tr ( selected . id )}</ dd ></ div >< div >< dt >{ tr ( "State" )}</ dt >< dd >{ tr ( selected . cancelRequested ?selected . cancellable ?'Cancelling…' :'Cancelled' :selected . state )}</ dd ></ div >< div >< dt >{ tr ( "Model" )}</ dt >< dd >{ tr ( selected . model )}</ dd ></ div >< div >< dt >{ tr ( "Tokens in / out" )}</ dt >< dd >{ tr ( tokens ( selected . tokensIn ))} / { tr ( tokens ( selected . tokensOut ))}</ dd ></ div >< div >< dt >{ tr ( "Usage source" )}</ dt >< dd >{ tr ( selected . usageSource === 'demo' ?'Simulated' :selected . usageSource === 'reported' ?'Reported by model' :'Unavailable' )}</ dd ></ div >< div >< dt >{ tr ( "Recorded duration" )}</ dt >< dd >{ tr ( selected . durationMs ?duration ( selected . durationMs ) :'Not yet available' )}</ dd ></ div ></ dl >{ tr ( selected . error ?< div ref = { cancelResult } tabIndex = { - 1 }>< ErrorNotice message = { selected . error } next = { tr ( "Check the client connection and try the request again." )}/></ div > :null )}< p className = "small muted" >{ tr ( "Prompt content and historical queue position are not retained. This view updates while the request runs." )}</ p >{ tr ( selected . cancellable !== false && [ 'queued' , 'generating' ]. includes ( selected . state ) ?< Btn disabled = { pending || selected . cancelRequested } onClick = {() => { requestedCancel . current = selected . id ; void operation (() => cancelRequest ( selected . id )); }}>{ tr ( selected . cancelRequested ?'Cancelling…' :'Cancel request' )}</ Btn > :null )}{ tr ( error ?< ErrorNotice message = { error }/> :null )}</> :< p >{ tr ( "This request is no longer retained in the session log." )}</ p >)}</ Dialog > 91< Dialog open = { sharingOpen } title = { tr ( "Local sharing" )} onClose = {() => ! pending && setSharingOpen ( false )} actions = {<>< Btn disabled = { pending } onClick = {() => setSharingOpen ( false )}>{ tr ( "Close" )}</ Btn >< Btn variant = "primary" disabled = { pending } onClick = {() => void operation ( async () => { await setLocalSharing ( ! serving . sharing ?. active ); setSharingOpen ( false ); })}>{ tr ( pending ?'Updating…' :serving . sharing ?. active ?'Stop sharing' :'Start sharing' )}</ Btn ></>}>< div className = "form-stack" >< span className = "dialog-feature-icon" >< Icon name = "link" size = { 28 }/></ span >< p >{ tr ( serving . sharing ?. active ?'Your inference API is available to devices on this network.' :'Let another device on your network use your loaded models.' )}</ p >< p className = "small muted" >{ tr ( "Only the inference API is shared. Clients need your API key when one is set. Use a trusted local network; this connection uses HTTP." )}</ p >{ tr ( serving . sharing ?. active ?< div className = "row" >< code className = "key-url" >{ serving . sharing . url }</ code >< CopyBtn text = { serving . sharing . url ! } label = "Local network URL" title = "Copy local network URL" /></ div > :null )}{ tr ( ! serving . access . apiKeySet ?<>< p className = "small muted" >< Icon name = "warning" size = { 16 }/>{ tr ( " Without an API key, any device on this network can use your model." )}</ p >< Btn onClick = {() => { generateKey (); setSharingOpen ( false ); setKeyOpen ( true ); }}>{ tr ( "Create an API key (recommended)" )}</ Btn ></> :< p className = "small muted" >< Icon name = "shield" size = { 16 }/>{ tr ( " API key required" )}</ p >)}{ tr ( error ?< ErrorNotice message = { error }/> :null )}</ div ></ Dialog > 92< Dialog open = { keyOpen } className = "serving-key-dialog" title = { tr ( serving . access . apiKeySet ?'Change API key' :'Create an API key' )} onClose = {() => { 93if ( ! pending ) 94closeKey (); 95}} actions = {<>< Btn disabled = { pending } onClick = { closeKey }>{ tr ( "Cancel" )}</ Btn >< Btn variant = "primary" disabled = { pending || ! keyDraft . trim ()} onClick = {() => void operation ( async () => { await setServingAccess ({ apiKey :keyDraft . trim () }); closeKey (); })}>{ tr ( pending ?'Saving…' :'Use this key' )}< Icon name = "chevron" className = "wizard-next" size = { 14 }/></ Btn ></>}> 96< div className = "tunnel-wizard" >< section className = "tunnel-stage key-stage" aria-labelledby = "key-stage-title" > 97< span className = "tunnel-stage__symbol" >< Icon name = "shield" size = { 26 }/></ span > 98< h3 id = "key-stage-title" className = "h3" >{ tr ( "Protect your connection" )}</ h3 > 99< p className = "small muted" >{ tr ( "A key lets your other apps connect to Strata." )}</ p > 100< div className = "input-field" >< label htmlFor = "api-key" >{ tr ( generated ?'Your new key' :'Your own key' )}</ label >< div className = "key-input" > 101< input id = "api-key" aria-label = { tr ( "API key" )} className = "st-input" type = { keyVisible ?'text' :'password' } autoComplete = "new-password" spellCheck = { false } value = { keyDraft } onChange = { e => { setKeyDraft ( e . target . value ); setGenerated ( false ); }}/> 102< button type = "button" className = "st-btn st-btn--secondary st-btn--sm" aria-label = { tr ( keyVisible ?'Hide API key' :'Show API key' )} aria-pressed = { keyVisible } disabled = { ! keyDraft || pending } onClick = {() => setKeyVisible ( v => ! v )}>{ tr ( keyVisible ?'Hide' :'Show' )}</ button > 103{ tr ( keyDraft ?< CopyBtn text = { keyDraft } label = "API key" title = "Copy new API key" /> :null )} 104</ div ></ div > 105< div className = "key-stage__choices" >< Btn size = "sm" icon = "bolt" disabled = { pending } onClick = { generateKey }>{ tr ( "Generate another" )}</ Btn >< Btn size = "sm" variant = "ghost" disabled = { pending } onClick = {() => { setKeyDraft ( '' ); setGenerated ( false ); setKeyVisible ( false ); }}>{ tr ( "Use my own key" )}</ Btn ></ div > 106< p className = "small muted" >{ tr ( "Copy this key into your client. It takes effect when you choose Use this key." )}{ tr ( serving . access . apiKeySet ?' Your old key will stop working.' :'' )}</ p > 107{ tr ( error ?< ErrorNotice message = { error }/> :null )} 108</ section ></ div > 109</ Dialog > 110< Dialog open = { removeKeyOpen } compact title = { tr ( "Remove API key?" )} onClose = {() => ! pending && setRemoveKeyOpen ( false )} actions = {<>< Btn disabled = { pending } onClick = {() => setRemoveKeyOpen ( false )}>{ tr ( "Keep key" )}</ Btn >< Btn variant = "danger" disabled = { pending } onClick = {() => void operation ( async () => { await setServingAccess ({ apiKey :null }); setRemoveKeyOpen ( false ); })}>{ tr ( pending ?'Removing…' :'Remove key' )}</ Btn ></>}>< p >{ tr ( "Apps on this computer will be able to send requests without a key. Existing clients can keep their current key field." )}</ p >{ tr ( serving . access . otherDevices ?< p className = "small muted" >< Icon name = "warning" size = { 16 }/>{ tr ( " Without an API key, anyone who can reach this address can use your model." )}</ p > :null )}{ tr ( error ?< ErrorNotice message = { error }/> :null )}</ Dialog > 111< CloudflareDialog open = { cloudflareOpen } onClose = {() => setCloudflareOpen ( false )} onCreateKey = {() => { setReturnToTunnel ( true ); setCloudflareOpen ( false ); generateKey (); setKeyOpen ( true ); }}/> 112</ Screen >; 113}