@@ -31,7 +31,8 @@ import { loadCredentials, saveCredentials } from './utils/aws-credentials.ts'
3131import { fetchVolumeFromUrl , fetchVolumeFromS3 , s3UriToHttps , fetchVolumeJsonGz } from './utils/fetch-volume.ts'
3232import { decompressGzip } from './utils/gzip.ts'
3333import { SSOAuthFlow } from './components/SSOAuthFlow.tsx'
34- import { MaterialsSearch } from './MaterialsSearch.tsx'
34+ import { MaterialsSearch , MATERIALS_MANIFEST } from './MaterialsSearch.tsx'
35+ import { resolveLoadUrl } from '@elvis/corpora'
3536import { BrowseMaterials } from './BrowseMaterials.tsx'
3637import type { FetchProgress } from './utils/fetch-volume.ts'
3738import type { AWSCredentials } from './utils/aws-credentials.ts'
@@ -221,6 +222,7 @@ export default function App() {
221222 const [ cam , setCam ] = useUrlState ( 'c' , camParam )
222223 const [ camTarget , setCamTarget ] = useUrlState ( 'ct' , camTargetParam , { debounce : 500 } )
223224 const [ materialId , setMaterialId ] = useUrlState ( 'm' , stringParam ( DEFAULT_MP_ID ) , { push : true } )
225+ const [ srcRole , setSrcRole ] = useUrlState ( 'src' , stringParam ( 'label' ) ) as [ 'input' | 'label' , ( v : 'input' | 'label' ) => void ]
224226 const [ currentVolumeId , setCurrentVolumeIdRaw ] = useState < string | null > (
225227 ( ) => sessionStorage . getItem ( 'elvis-active-volume' ) ,
226228 )
@@ -501,6 +503,27 @@ export default function App() {
501503 defaultBindings : [ 'shift+z' ] ,
502504 handler : ( ) => setUseZarr ( ! useZarr ) ,
503505 } )
506+ useAction ( 'data:toggle-src' , {
507+ label : 'Toggle SAD input vs DFT label' ,
508+ description : 'Switch between SAD initial guess (input) and converged DFT (label) density' ,
509+ keywords : [ 'input' , 'label' , 'sad' , 'dft' , 'source' , 'role' ] ,
510+ group : 'Data' ,
511+ defaultBindings : [ 'i' ] ,
512+ handler : ( ) => {
513+ const next : 'input' | 'label' = srcRole === 'input' ? 'label' : 'input'
514+ setSrcRole ( next )
515+ // The URL param `m` may be a material_id (mp-573119) OR a task_id (mp-1775579) —
516+ // ElectrAI S3 uses task IDs while the corpora manifest indexes by material ID.
517+ const record = MATERIALS_MANIFEST . records . find ( r =>
518+ r . id === materialId ||
519+ Object . values ( r . datasets ) . some ( d => d ?. task_ids ?. includes ( materialId ) ) ,
520+ )
521+ if ( record ) {
522+ const url = resolveLoadUrl ( record , next , useZarr ? 'zarr' : 'chgcar' )
523+ if ( url ) handleUrlSubmit ( url )
524+ }
525+ } ,
526+ } )
504527 useAction ( 'view:toggle-color-by-density' , {
505528 label : 'Toggle iso color by density' ,
506529 description : 'Color/opacity of isosurface varies with iso-level quantile' ,
@@ -1304,6 +1327,7 @@ export default function App() {
13041327 />
13051328 ) : (
13061329 < DensityViewer
1330+ label = { srcRole === 'input' ? 'Input (SAD)' : 'Label (DFT)' }
13071331 volume = { primaryFile . data }
13081332 isoLevel = { effectiveIsoLevel }
13091333 opacity = { opacity }
@@ -1502,8 +1526,8 @@ export default function App() {
15021526 />
15031527
15041528 < ShortcutsModal editable arrowIcon = "move" TooltipComponent = { MuiTooltip } />
1505- < MaterialsSearch onSelect = { handleUrlSubmit } format = { useZarr ? 'zarr' : 'chgcar' } />
1506- < BrowseMaterials open = { browseOpen } onClose = { ( ) => setBrowseOpen ( false ) } onSelect = { handleUrlSubmit } format = { useZarr ? 'zarr' : 'chgcar' } />
1529+ < MaterialsSearch onSelect = { handleUrlSubmit } role = { srcRole } format = { useZarr ? 'zarr' : 'chgcar' } />
1530+ < BrowseMaterials open = { browseOpen } onClose = { ( ) => setBrowseOpen ( false ) } onSelect = { handleUrlSubmit } role = { srcRole } format = { useZarr ? 'zarr' : 'chgcar' } />
15071531 < Omnibar />
15081532 < SequenceModal />
15091533 < LookupModal />
0 commit comments