forked from All-Hands-AI/OpenHands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
116 lines (105 loc) · 3.79 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { useDisclosure } from "@nextui-org/react";
import React, { useEffect } from "react";
import { Toaster } from "react-hot-toast";
import CogTooth from "#/assets/cog-tooth";
import ChatInterface from "#/components/chat/ChatInterface";
import Errors from "#/components/Errors";
import { Container, Orientation } from "#/components/Resizable";
import Workspace from "#/components/Workspace";
import LoadPreviousSessionModal from "#/components/modals/load-previous-session/LoadPreviousSessionModal";
import SettingsModal from "#/components/modals/settings/SettingsModal";
import "./App.css";
import AgentControlBar from "./components/AgentControlBar";
import AgentStatusBar from "./components/AgentStatusBar";
import VolumeIcon from "./components/VolumeIcon";
import Terminal from "./components/terminal/Terminal";
import Session from "#/services/session";
import { getToken } from "#/services/auth";
import { settingsAreUpToDate } from "#/services/settings";
interface Props {
setSettingOpen: (isOpen: boolean) => void;
}
function Controls({ setSettingOpen }: Props): JSX.Element {
return (
<div className="flex w-full p-4 bg-neutral-900 items-center shrink-0 justify-between">
<div className="flex items-center gap-4">
<AgentControlBar />
</div>
<AgentStatusBar />
<div style={{ display: "flex", alignItems: "center" }}>
<div style={{ marginRight: "8px" }}>
<VolumeIcon />
</div>
<div
className="cursor-pointer hover:opacity-80 transition-all"
onClick={() => setSettingOpen(true)}
>
<CogTooth />
</div>
</div>
</div>
);
}
// React.StrictMode will cause double rendering, use this to prevent it
let initOnce = false;
function App(): JSX.Element {
const {
isOpen: settingsModalIsOpen,
onOpen: onSettingsModalOpen,
onOpenChange: onSettingsModalOpenChange,
} = useDisclosure();
const {
isOpen: loadPreviousSessionModalIsOpen,
onOpen: onLoadPreviousSessionModalOpen,
onOpenChange: onLoadPreviousSessionModalOpenChange,
} = useDisclosure();
useEffect(() => {
if (initOnce) return;
initOnce = true;
if (!settingsAreUpToDate()) {
onSettingsModalOpen();
} else if (getToken()) {
onLoadPreviousSessionModalOpen();
} else {
Session.startNewSession();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (
<div className="h-screen w-screen flex flex-col">
<div className="flex grow bg-neutral-900 text-white min-h-0">
<Container
orientation={Orientation.HORIZONTAL}
className="grow h-full min-h-0 min-w-0 px-3 pt-3"
initialSize={500}
firstChild={<ChatInterface />}
firstClassName="min-w-[500px] rounded-xl overflow-hidden border border-neutral-600"
secondChild={
<Container
orientation={Orientation.VERTICAL}
className="grow h-full min-h-0 min-w-0"
initialSize={window.innerHeight - 300}
firstChild={<Workspace />}
firstClassName="min-h-72 rounded-xl border border-neutral-600 bg-neutral-800 flex flex-col overflow-hidden"
secondChild={<Terminal />}
secondClassName="min-h-72 rounded-xl border border-neutral-600 bg-neutral-800"
/>
}
secondClassName="flex flex-col overflow-hidden grow min-w-[500px]"
/>
</div>
<Controls setSettingOpen={onSettingsModalOpen} />
<SettingsModal
isOpen={settingsModalIsOpen}
onOpenChange={onSettingsModalOpenChange}
/>
<LoadPreviousSessionModal
isOpen={loadPreviousSessionModalIsOpen}
onOpenChange={onLoadPreviousSessionModalOpenChange}
/>
<Errors />
<Toaster />
</div>
);
}
export default App;