New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: installer populates vector store #76
Changes from 2 commits
b71253c
5a99750
0b59642
7f22e85
0551689
0e1a089
1b06c02
440f019
b88cba7
e9d43be
3fbd2bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
import { AppFrame } from "@captn/joy/app-frame"; | ||
import { TitleBar } from "@captn/joy/title-bar"; | ||
import Box from "@mui/joy/Box"; | ||
import Button from "@mui/joy/Button"; | ||
import CircularProgress from "@mui/joy/CircularProgress"; | ||
import Input from "@mui/joy/Input"; | ||
import Typography from "@mui/joy/Typography"; | ||
import type { InferGetStaticPropsType } from "next"; | ||
import { useTranslation } from "next-i18next"; | ||
import { useEffect, useState } from "react"; | ||
|
||
import { buildKey } from "#/build-key"; | ||
import { ID } from "#/enums"; | ||
import { Captain } from "@/atoms/logo/captain"; | ||
import { makeStaticProperties } from "@/ions/i18n/get-static"; | ||
|
||
function DummyPrompt() { | ||
const { t } = useTranslation(["labels", "texts"]); | ||
return ( | ||
<Box | ||
sx={{ | ||
position: "relative", | ||
fontSize: 24, | ||
my: "1em", | ||
mx: 1, | ||
overflow: "hidden", | ||
boxShadow: "md", | ||
}} | ||
> | ||
<Input | ||
readOnly | ||
placeholder={t("labels:placeholder.prompt")} | ||
endDecorator={ | ||
<Box | ||
sx={{ | ||
flex: 1, | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
height: 44, | ||
width: 44, | ||
}} | ||
> | ||
<Captain sx={{ height: "100%" }} /> | ||
</Box> | ||
} | ||
sx={{ | ||
fontSize: "inherit", | ||
lineHeight: 1.25, | ||
p: 2, | ||
flexDirection: "row", | ||
}} | ||
/> | ||
</Box> | ||
); | ||
} | ||
|
||
export default function Page(_properties: InferGetStaticPropsType<typeof getStaticProps>) { | ||
const { t } = useTranslation(["labels", "texts"]); | ||
const [loading, setLoading] = useState(true); | ||
const [starting, setStarting] = useState(false); | ||
|
||
useEffect(() => { | ||
const unsubscribeInitialized = window.ipc.on( | ||
buildKey([ID.INSTALL], { suffix: ":initialized" }), | ||
() => { | ||
setLoading(false); | ||
} | ||
); | ||
|
||
const unsubscribeError = window.ipc.on(buildKey([ID.INSTALL], { suffix: ":error" }), () => { | ||
setLoading(true); | ||
}); | ||
|
||
window.ipc.send(buildKey([ID.INSTALL], { suffix: ":initialize" })); | ||
|
||
return () => { | ||
unsubscribeInitialized(); | ||
unsubscribeError(); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<AppFrame titleBar={<TitleBar disableMaximize />}> | ||
<Box sx={{ minHeight: "100%", display: "flex", flexDirection: "column" }}> | ||
<Box sx={{ height: 200, alignContent: "center", px: 2 }}> | ||
<DummyPrompt /> | ||
</Box> | ||
|
||
<Typography level="h1" sx={{ my: 2, textAlign: "center" }}> | ||
{t("labels:finishing")} | ||
</Typography> | ||
|
||
<Box | ||
sx={{ | ||
flex: 1, | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "center", | ||
mx: 8, | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
p: 2, | ||
backgroundColor: "background.default", | ||
borderRadius: "8px", | ||
flexDirection: "column", | ||
}} | ||
> | ||
<Typography level="body-lg" sx={{ my: 2, textAlign: "center" }}> | ||
{t("texts:howToUseCaptain")} | ||
</Typography> | ||
|
||
<Typography level="body-lg" sx={{ my: 2, textAlign: "center" }}> | ||
{loading ? t("texts:preparation") : t("texts:preparationDone")} | ||
</Typography> | ||
</Box> | ||
</Box> | ||
|
||
<Box sx={{ display: "flex", justifyContent: "flex-end", m: 1 }}> | ||
<Box sx={{ display: "flex", gap: 1 }}> | ||
<Button | ||
endDecorator={ | ||
loading || starting ? <CircularProgress size="sm" /> : null | ||
} | ||
onClick={() => { | ||
setStarting(true); | ||
window.ipc.send(buildKey([ID.APP], { suffix: ":ready" }), true); | ||
}} | ||
> | ||
{(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no self calling functions. please use a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was updated! |
||
if (loading) { | ||
return t("labels:preparation"); | ||
} | ||
|
||
if (starting) { | ||
return t("labels:starting"); | ||
} | ||
|
||
return t("labels:start"); | ||
})()} | ||
</Button> | ||
</Box> | ||
</Box> | ||
</Box> | ||
</AppFrame> | ||
); | ||
} | ||
|
||
export const getStaticProps = makeStaticProperties(["common", "installer", "texts", "labels"]); | ||
|
||
export { getStaticPaths } from "@/ions/i18n/get-static"; |
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.
why does an error set loading to true?
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.
This was changed to
setLoading(false)
and I added error handling to show the actual problem.