Skip to content

Commit

Permalink
feat(app): terminate any running AI processes before closing or resta…
Browse files Browse the repository at this point in the history
…rting #22
  • Loading branch information
KindaBrazy committed Nov 2, 2024
1 parent 454fe3a commit b683de6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/renderer/src/App/Components/MainContents/StatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ const classNames = 'flex size-full items-center overflow-x-scroll scrollbar-hide
const StatusBar = () => {
const [statusBar] = useState(extensionsData.statusBar);

console.log(statusBar);

const isEmptyAdd = useMemo(() => {
return isEmpty(statusBar.addStart) && isEmpty(statusBar.addCenter) && isEmpty(statusBar.addEnd);
}, [statusBar]);
Expand Down
18 changes: 15 additions & 3 deletions src/renderer/src/App/Components/TitleBar/WindowButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,24 @@ export default function WindowButtons() {
[dispatch],
);

const close = useCallback(() => {
rendererIpc.pty.process('stop', '');
// Close the app with a delay so ensure pty terminated
setTimeout(() => rendererIpc.win.changeWinState('close'), 200);
}, []);

const restart = useCallback(() => {
rendererIpc.pty.process('stop', '');
// Close the app with a delay so ensure pty terminated
setTimeout(() => rendererIpc.win.changeWinState('restart'), 200);
}, []);

const changeWindowState = useCallback(
(operation: WindowOperation) => {
if (operation === 'close') {
rendererIpc.storage.update('app', {lastPage: currentPage});
if (isHotkeyPressed('control') || !showCloseConfirm) {
rendererIpc.win.changeWinState('close');
close();
} else if (!isConfigVisible) {
setIsConfigVisible(true);
Modal.error({
Expand Down Expand Up @@ -67,10 +79,10 @@ export default function WindowButtons() {
Stay
</Button>
<div className="space-x-2">
<Button size="sm" color="warning" onPress={() => rendererIpc.win.changeWinState('restart')}>
<Button size="sm" color="warning" onPress={restart}>
Restart
</Button>
<Button size="sm" color="danger" onPress={() => rendererIpc.win.changeWinState('close')}>
<Button size="sm" color="danger" onPress={close}>
Exit
</Button>
</div>
Expand Down

0 comments on commit b683de6

Please sign in to comment.