Skip to content
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: surface repair mode in UI and logs #49

Merged
merged 2 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/install-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export class InstallManager {
this.abortController = null;
}

logRepairModeMessages = (): void => {
this.log.info('Try installing again with Repair mode enabled to fix this.\r\n');
this.log.info('Ask for help on Discord or GitHub if you continue to have issues.\r\n');
};

getStatus = (): WithTimestamp<InstallProcessStatus> => {
return this.status;
};
Expand Down Expand Up @@ -188,6 +193,7 @@ export class InstallManager {

if (installPythonResult.isErr()) {
this.log.error(`Failed to install Python: ${installPythonResult.error.message}\r\n`);
this.logRepairModeMessages();
this.updateStatus({
type: 'error',
error: {
Expand Down Expand Up @@ -258,6 +264,7 @@ export class InstallManager {

if (createVenvResult.isErr()) {
this.log.error(`Failed to create virtual environment: ${createVenvResult.error.message}\r\n`);
this.logRepairModeMessages();
this.updateStatus({
type: 'error',
error: {
Expand Down Expand Up @@ -308,6 +315,7 @@ export class InstallManager {

if (installAppResult.isErr()) {
this.log.error(`Failed to install invokeai python package: ${installAppResult.error.message}\r\n`);
this.logRepairModeMessages();
this.updateStatus({
type: 'error',
error: {
Expand Down
55 changes: 31 additions & 24 deletions src/renderer/features/InstallFlow/InstallFlowStepReview.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import {
Button,
Checkbox,
Divider,
Flex,
FormControl,
FormLabel,
Heading,
ListItem,
Spacer,
Text,
Tooltip,
UnorderedList,
useShiftModifier,
} from '@invoke-ai/ui-library';
import { useStore } from '@nanostores/react';
import { memo } from 'react';
import type { ChangeEvent } from 'react';
import { memo, useCallback } from 'react';
import { assert } from 'tsafe';

import { BodyContainer, BodyContent, BodyFooter, BodyHeader } from '@/renderer/common/layout';
Expand All @@ -27,10 +32,12 @@ const GPU_LABEL_MAP: Record<GpuType, string> = {
};

export const InstallFlowStepReview = memo(() => {
const { dirDetails, gpuType, release } = useStore(installFlowApi.$choices);
const { dirDetails, gpuType, release, repairMode } = useStore(installFlowApi.$choices);
const installType = useStore(installFlowApi.$installType);

const shift = useShiftModifier();
const onChangeRepairMode = useCallback((e: ChangeEvent<HTMLInputElement>) => {
installFlowApi.$choices.set({ ...installFlowApi.$choices.get(), repairMode: e.target.checked });
}, []);

assert(dirDetails !== null);
assert(gpuType !== null);
Expand Down Expand Up @@ -68,32 +75,32 @@ export const InstallFlowStepReview = memo(() => {
</Text>
</ListItem>
</UnorderedList>
{/* {shift && (
<Alert status="info" w="auto" mt={8}>
<AlertIcon />
<AlertDescription fontSize="sm">
Repair mode forcibly reinstalls python and recreates the virtual environment.
</AlertDescription>
</Alert>
)} */}
<Spacer />
</BodyContent>
<BodyFooter>
<Tooltip
label={
<Flex flexDir="column" gap={1}>
<Text fontWeight="semibold">Repair mode can fix installation or update issues.</Text>
<Text>It reinstalls python and recreates the virtual environment.</Text>
</Flex>
}
>
<FormControl w="min-content">
<FormLabel m={0} fontWeight="normal" fontSize="md">
Repair mode
</FormLabel>
<Checkbox isChecked={repairMode} onChange={onChangeRepairMode} />
</FormControl>
</Tooltip>
<Divider orientation="vertical" />
<Button onClick={installFlowApi.prevStep} variant="link">
Back
</Button>
<Divider orientation="vertical" />
{shift && (
<Tooltip isOpen label="Repair mode forcibly reinstalls python and recreates the virtual environment.">
<Button w={24} onClick={installFlowApi.startInstallWithRepair} colorScheme="invokeRed">
Repair
</Button>
</Tooltip>
)}
{!shift && (
<Button w={24} onClick={installFlowApi.startInstallWithoutRepair} colorScheme="invokeYellow">
Install
</Button>
)}
<Button w={24} onClick={installFlowApi.startInstall} colorScheme="invokeYellow">
Install
</Button>
</BodyFooter>
</BodyContainer>
);
Expand Down
17 changes: 7 additions & 10 deletions src/renderer/features/InstallFlow/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ const $choices = map<{
dirDetails: DirDetails | null;
gpuType: GpuType | null;
release: { version: string; isPrerelease: boolean } | null;
repairMode: boolean;
}>({
dirDetails: null,
gpuType: null,
release: null,
repairMode: false,
});

const $activeStep = atom(0);
Expand Down Expand Up @@ -77,7 +79,7 @@ export const installFlowApi = {
$activeStep.set(clamp(currentStep - 1, 0, installFlowApi.steps.length - 1));
},
beginFlow: (dirDetails?: DirDetails) => {
$choices.set({ dirDetails: dirDetails ?? null, gpuType: null, release: null });
$choices.set({ dirDetails: dirDetails ?? null, gpuType: null, release: null, repairMode: false });
$activeStep.set(0);
$isStarted.set(true);
},
Expand All @@ -86,25 +88,20 @@ export const installFlowApi = {
dirDetails: null,
gpuType: null,
release: null,
repairMode: false,
});
$activeStep.set(0);
$isStarted.set(false);
},
startInstall: (repair?: boolean) => {
const { dirDetails, gpuType, release } = $choices.get();
startInstall: () => {
const { dirDetails, gpuType, release, repairMode } = $choices.get();
if (!dirDetails || !dirDetails.canInstall || !release || !gpuType) {
return;
}
$installProcessLogs.set([]);
emitter.invoke('install-process:start-install', dirDetails.path, gpuType, release.version, repair);
emitter.invoke('install-process:start-install', dirDetails.path, gpuType, release.version, repairMode);
installFlowApi.nextStep();
},
startInstallWithoutRepair: () => {
installFlowApi.startInstall(false);
},
startInstallWithRepair: () => {
installFlowApi.startInstall(true);
},
cancelInstall: async () => {
await emitter.invoke('install-process:cancel-install');
$isFinished.set(true);
Expand Down
Loading