Skip to content

Commit

Permalink
Merge branch 'main' into kevin
Browse files Browse the repository at this point in the history
  • Loading branch information
SmartManoj committed Aug 13, 2024
2 parents b5d662d + 98e6756 commit 956052d
Show file tree
Hide file tree
Showing 49 changed files with 1,892 additions and 74 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ updates:
docusaurus:
patterns:
- "*docusaurus*"
eslint:
patterns:
- "*eslint*"

- package-ecosystem: "npm"
directory: "/docs"
Expand All @@ -30,3 +33,6 @@ updates:
docusaurus:
patterns:
- "*docusaurus*"
eslint:
patterns:
- "*eslint*"
11 changes: 11 additions & 0 deletions config.template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ llm_config = 'gpt3'
# Enable auto linting after editing
#enable_auto_lint = false

#################################### Security ###################################
# Configuration for security features
##############################################################################
[security]

# Enable confirmation mode
#confirmation_mode = true

# The security analyzer to use
#security_analyzer = ""

#################################### Eval ####################################
# Configuration for the evaluation, please refer to the specific evaluation
# plugin for the available options
Expand Down
8 changes: 4 additions & 4 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"prism-react-renderer": "^2.3.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.2.1",
"react-icons": "^5.3.0",
"react-use": "^17.5.1"
},
"devDependencies": {
Expand Down
32 changes: 16 additions & 16 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@xterm/xterm": "^5.4.0",
"clsx": "^2.1.1",
"eslint-config-airbnb-typescript": "^18.0.0",
"i18next": "^23.12.2",
"i18next": "^23.12.3",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-http-backend": "^2.5.2",
"jose": "^5.6.3",
Expand All @@ -26,11 +26,11 @@
"react-highlight": "^0.15.0",
"react-hot-toast": "^2.4.1",
"react-i18next": "^15.0.1",
"react-icons": "^5.2.1",
"react-icons": "^5.3.0",
"react-markdown": "^9.0.1",
"react-redux": "^9.1.2",
"react-syntax-highlighter": "^15.5.0",
"tailwind-merge": "^2.5.1",
"tailwind-merge": "^2.5.2",
"vite": "^5.4.0",
"web-vitals": "^3.5.2"
},
Expand Down Expand Up @@ -83,7 +83,7 @@
"eslint-plugin-react-hooks": "^4.6.2",
"husky": "^9.1.4",
"jsdom": "^24.1.1",
"lint-staged": "^15.2.8",
"lint-staged": "^15.2.9",
"postcss": "^8.4.41",
"prettier": "^3.3.3",
"tailwindcss": "^3.4.9",
Expand Down
39 changes: 36 additions & 3 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useDisclosure } from "@nextui-org/react";
import React, { useEffect } from "react";
import { Toaster } from "react-hot-toast";
import { IoLockClosed } from "react-icons/io5";
import CogTooth from "#/assets/cog-tooth";
import ChatInterface from "#/components/chat/ChatInterface";
import Errors from "#/components/Errors";
Expand All @@ -15,13 +16,20 @@ 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";
import { getSettings, settingsAreUpToDate } from "#/services/settings";
import Security from "./components/modals/security/Security";

interface Props {
setSettingOpen: (isOpen: boolean) => void;
setSecurityOpen: (isOpen: boolean) => void;
showSecurityLock: boolean;
}

function Controls({ setSettingOpen }: Props): JSX.Element {
function Controls({
setSettingOpen,
setSecurityOpen,
showSecurityLock,
}: 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">
Expand All @@ -33,6 +41,15 @@ function Controls({ setSettingOpen }: Props): JSX.Element {
<div style={{ marginRight: "8px" }}>
<VolumeIcon />
</div>
{showSecurityLock && (
<div
className="cursor-pointer hover:opacity-80 transition-all"
style={{ marginRight: "8px" }}
onClick={() => setSecurityOpen(true)}
>
<IoLockClosed size={20} />
</div>
)}
<div
className="cursor-pointer hover:opacity-80 transition-all"
onClick={() => setSettingOpen(true)}
Expand Down Expand Up @@ -60,6 +77,14 @@ function App(): JSX.Element {
onOpenChange: onLoadPreviousSessionModalOpenChange,
} = useDisclosure();

const {
isOpen: securityModalIsOpen,
onOpen: onSecurityModalOpen,
onOpenChange: onSecurityModalOpenChange,
} = useDisclosure();

const { SECURITY_ANALYZER } = getSettings();

useEffect(() => {
if (initOnce) return;
initOnce = true;
Expand Down Expand Up @@ -98,11 +123,19 @@ function App(): JSX.Element {
secondClassName="flex flex-col overflow-hidden"
/>
</div>
<Controls setSettingOpen={onSettingsModalOpen} />
<Controls
setSettingOpen={onSettingsModalOpen}
setSecurityOpen={onSecurityModalOpen}
showSecurityLock={!!SECURITY_ANALYZER}
/>
<SettingsModal
isOpen={settingsModalIsOpen}
onOpenChange={onSettingsModalOpenChange}
/>
<Security
isOpen={securityModalIsOpen}
onOpenChange={onSecurityModalOpenChange}
/>
<LoadPreviousSessionModal
isOpen={loadPreviousSessionModalIsOpen}
onOpenChange={onLoadPreviousSessionModalOpenChange}
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/components/AgentControlBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ function AgentControlBar() {
return;
}


setDesiredState(action);
changeAgentState(action);

if (action === AgentState.STOPPED) {
Session._history = [];
store.dispatch(clearMessages());
} else {
setIsLoading(true);
}

setDesiredState(action);
changeAgentState(action);
};

useEffect(() => {
Expand Down
16 changes: 11 additions & 5 deletions frontend/src/components/modals/base-modal/BaseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ interface BaseModalProps {
isOpen: boolean;
onOpenChange: (isOpen: boolean) => void;
title: string;
contentClassName?: string;
bodyClassName?: string;
isDismissable?: boolean;
subtitle?: string;
actions?: Action[];
Expand All @@ -24,6 +26,8 @@ function BaseModal({
isOpen,
onOpenChange,
title,
contentClassName = "max-w-[30rem] p-[40px]",
bodyClassName = "px-0 py-[20px]",
isDismissable = true,
subtitle = undefined,
actions = [],
Expand All @@ -42,14 +46,16 @@ function BaseModal({
size="sm"
className="bg-neutral-900 rounded-lg"
>
<ModalContent className="max-w-[30rem] p-[40px]">
<ModalContent className={contentClassName}>
{(closeModal) => (
<>
<ModalHeader className="flex flex-col p-0">
<HeaderContent title={title} subtitle={subtitle} />
</ModalHeader>
{title && (
<ModalHeader className="flex flex-col p-0">
<HeaderContent title={title} subtitle={subtitle} />
</ModalHeader>
)}

<ModalBody className="px-0 py-[20px]">{children}</ModalBody>
<ModalBody className={bodyClassName}>{children}</ModalBody>

{actions && actions.length > 0 && (
<ModalFooter className="flex-col flex justify-start p-0">
Expand Down
40 changes: 40 additions & 0 deletions frontend/src/components/modals/security/Security.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from "react";
import SecurityInvariant from "./invariant/Invariant";
import BaseModal from "../base-modal/BaseModal";
import { getSettings } from "#/services/settings";

interface SecurityProps {
isOpen: boolean;
onOpenChange: (isOpen: boolean) => void;
}

enum SecurityAnalyzerOption {
INVARIANT = "invariant",
}

const SecurityAnalyzers: Record<SecurityAnalyzerOption, React.ElementType> = {
[SecurityAnalyzerOption.INVARIANT]: SecurityInvariant,
};

function Security({ isOpen, onOpenChange }: SecurityProps): JSX.Element {
const { SECURITY_ANALYZER } = getSettings();
const AnalyzerComponent =
SECURITY_ANALYZER &&
SecurityAnalyzers[SECURITY_ANALYZER as SecurityAnalyzerOption]
? SecurityAnalyzers[SECURITY_ANALYZER as SecurityAnalyzerOption]
: () => <div>Unknown security analyzer chosen</div>;

return (
<BaseModal
isOpen={isOpen && !!SECURITY_ANALYZER}
contentClassName="max-w-[80%] h-[80%]"
bodyClassName="px-0 py-0 max-h-[100%]"
onOpenChange={onOpenChange}
title=""
>
<AnalyzerComponent />
</BaseModal>
);
}

export default Security;
Loading

0 comments on commit 956052d

Please sign in to comment.