forked from enricoros/big-AGI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from enricoros/main
Big AGI update
- Loading branch information
Showing
33 changed files
with
1,077 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import * as React from 'react'; | ||
import Image from 'next/image'; | ||
import { useRouter } from 'next/router'; | ||
|
||
import { Alert, Box, Button, CircularProgress, Typography } from '@mui/joy'; | ||
import ArrowBackIcon from '@mui/icons-material/ArrowBack'; | ||
|
||
import { useComposerStore } from '../src/apps/chat/components/composer/store-composer'; | ||
|
||
// import { callBrowseFetchSinglePage } from '~/modules/browse/browse.client'; | ||
|
||
import { AppLayout } from '~/common/layouts/AppLayout'; | ||
import { asValidURL } from '~/common/util/urlUtils'; | ||
|
||
|
||
const LogoProgress = (props: { showProgress: boolean }) => | ||
<Box sx={{ | ||
width: 64, | ||
height: 64, | ||
position: 'relative', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}}> | ||
<Box sx={{ position: 'absolute', mt: 0.75 }}> | ||
<Image src='/icons/favicon-32x32.png' alt='App Logo' width={32} height={32} /> | ||
</Box> | ||
{props.showProgress && <CircularProgress size='lg' sx={{ position: 'absolute' }} />} | ||
</Box>; | ||
|
||
|
||
/** | ||
* This page will be invoked on mobile when sharing Text/URLs/Files from other APPs | ||
* Example URL: https://get.big-agi.com/share?title=This+Title&text=https%3A%2F%2Fexample.com%2Fapp%2Fpath | ||
*/ | ||
export default function SharePage() { | ||
|
||
// state | ||
const [errorMessage, setErrorMessage] = React.useState<string | null>(null); | ||
const [intentText, setIntentText] = React.useState<string | null>(null); | ||
const [intentURL, setIntentURL] = React.useState<string | null>(null); | ||
const [isDownloading, setIsDownloading] = React.useState(false); | ||
|
||
// external state | ||
const { query, push: routerPush, replace: routerReplace } = useRouter(); | ||
|
||
|
||
const queueComposerTextAndLaunchApp = React.useCallback((text: string) => { | ||
useComposerStore.getState().setStartupText(text); | ||
routerReplace('/').then(() => null); | ||
}, [routerReplace]); | ||
|
||
|
||
// Detect the share Intent from the query | ||
React.useEffect(() => { | ||
// skip when query is not parsed yet | ||
if (!Object.keys(query).length) | ||
return; | ||
|
||
// single item from the query | ||
let queryTextItem: string[] | string | null = query.url || query.text || null; | ||
if (Array.isArray(queryTextItem)) | ||
queryTextItem = queryTextItem[0]; | ||
|
||
// check if the item is a URL | ||
const url = asValidURL(queryTextItem); | ||
if (url) | ||
setIntentURL(url); | ||
else if (queryTextItem) | ||
setIntentText(queryTextItem); | ||
else | ||
setErrorMessage('No text or url. Received: ' + JSON.stringify(query)); | ||
|
||
}, [query.url, query.text, query]); | ||
|
||
|
||
// Text -> Composer | ||
React.useEffect(() => { | ||
if (intentText) | ||
queueComposerTextAndLaunchApp(intentText); | ||
}, [intentText, queueComposerTextAndLaunchApp]); | ||
|
||
|
||
// URL -> download -> Composer | ||
React.useEffect(() => { | ||
if (intentURL) { | ||
setIsDownloading(true); | ||
// TEMP: until the Browse module is ready, just use the URL, verbatim | ||
queueComposerTextAndLaunchApp(intentURL); | ||
setIsDownloading(false) | ||
/*callBrowseFetchSinglePage(intentURL) | ||
.then(pageContent => { | ||
if (pageContent) | ||
queueComposerTextAndLaunchApp('\n\n```' + intentURL + '\n' + pageContent + '\n```\n'); | ||
else | ||
setErrorMessage('Could not read any data'); | ||
}) | ||
.catch(error => setErrorMessage(error?.message || error || 'Unknown error')) | ||
.finally(() => setIsDownloading(false));*/ | ||
} | ||
}, [intentURL, queueComposerTextAndLaunchApp]); | ||
|
||
|
||
return ( | ||
<AppLayout noSettings noModelsSetup> | ||
|
||
<Box sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
minHeight: '100vh', | ||
}}> | ||
|
||
{/* Logo with Circular Progress */} | ||
<LogoProgress showProgress={isDownloading} /> | ||
|
||
{/* Title */} | ||
<Typography level='h5' sx={{ mt: 2, mb: 1 }}> | ||
{isDownloading ? 'Loading...' : errorMessage ? '' : intentURL ? 'Done' : 'Receiving...'} | ||
</Typography> | ||
|
||
{/* Possible Error */} | ||
{errorMessage && <> | ||
<Alert variant='soft' color='danger' sx={{ my: 1 }}> | ||
<Typography>{errorMessage}</Typography> | ||
</Alert> | ||
<Button | ||
variant='solid' color='danger' | ||
onClick={() => routerPush('/')} | ||
endDecorator={<ArrowBackIcon />} | ||
sx={{ mt: 2 }} | ||
> | ||
Cancel | ||
</Button> | ||
</>} | ||
|
||
{/* URL under analysis */} | ||
<Typography level='body3'> | ||
{intentURL} | ||
</Typography> | ||
</Box> | ||
|
||
</AppLayout> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ec92683
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
bigagi – ./
bigagi.vercel.app
bigagi-raphaelmansuy.vercel.app
bigagi-git-main-raphaelmansuy.vercel.app