SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
Web WIP: Styling and refactoring
Kilian Lieret1d31a4b704d3
diff --git a/sweagent/frontend/src/App.js b/sweagent/frontend/src/App.jsindex 84035725..d330c815 100644--- a/sweagent/frontend/src/App.js+++ b/sweagent/frontend/src/App.js@@ -2,7 +2,9 @@ import React, { useState, useRef, useEffect } from 'react';import axios from 'axios';import io from 'socket.io-client';import './static/app.css';-import Feed from './components/panels/Feed';+import AgentFeed from './components/panels/AgentFeed';+import EnvFeed from './components/panels/EnvFeed';+import LogPanel from './components/panels/LogPanel';const url = ''; // Will get this from .env// Connect to Socket.io@@ -17,6 +19,9 @@ function App() {const [logs, setLogs] = useState('');const [isComputing, setIsComputing] = useState(false);+ const [isTerminalExpanded, setIsTerminalExpanded] = useState(false);+ const [isLogsExpanded, setIsLogsExpanded] = useState(false);+const agentFeedRef = useRef(null);const envFeedRef = useRef(null);const logsRef = useRef(null);@@ -127,12 +132,9 @@ function App() {<div id="demo"><hr /><div className="panels">- <Feed feed={agentFeed} id="agent" highlightedStep={highlightedStep} handleMouseEnter={handleMouseEnter} selfRef={agentFeedRef} otherRef={envFeedRef} isComputing={isComputing} title="Agent Feed" />- <Feed feed={envFeed} id="env" highlightedStep={highlightedStep} handleMouseEnter={handleMouseEnter} selfRef={envFeedRef} otherRef={agentFeedRef} isComputing={isComputing} title="Environment Feed" />- <div id="log" className="logPanel" ref={logsRef}>- <h3>Logs</h3>- <pre >{logs}</pre>- </div>+ <AgentFeed feed={agentFeed} id="agent" highlightedStep={highlightedStep} handleMouseEnter={handleMouseEnter} selfRef={agentFeedRef} otherRef={envFeedRef} title="Agent Feed" />+ <EnvFeed feed={envFeed} id="env" highlightedStep={highlightedStep} handleMouseEnter={handleMouseEnter} selfRef={envFeedRef} otherRef={agentFeedRef} setIsTerminalExpanded={setIsTerminalExpanded} title="Environment Feed" />+ <LogPanel logs={logs} logsRef={logsRef} setIsTerminalExpanded={setIsLogsExpanded} /></div></div></div>diff --git a/sweagent/frontend/src/components/MacBar.js b/sweagent/frontend/src/components/MacBar.jsnew file mode 100644index 00000000..0e694599--- /dev/null+++ b/sweagent/frontend/src/components/MacBar.js@@ -0,0 +1,75 @@+import React from "react";+import PropTypes from "prop-types"; // Import PropTypes for type checking++import ExpandIcon from "./utils/icons/ExpandIcon";+import "../static/macbar.css";++import Message from './Message';++const MacBar = ({+ setIsTyping,+ text,+ barStyle,+ messageStyle,+ setIsExpanded,+ expandFillColor,+ showIcons = true,+}) => {+ const messageStyleMerged = {+ backgroundColor: "transparent",+ boxShadow: "none",+ color: "black",+ left: "50%",+ fontSize: "smaller",+ margin: "0em",+ padding: "0em",+ position: 'absolute',+ transform: "translateX(-50%)",+ ...messageStyle,+ };++ const expandFillColorMerged = expandFillColor || "#ffffff";++ return (+ <div className="mac-window-top-bar" style={barStyle}>+ {showIcons && (+ <>+ <div className="mac-window-button close"></div>+ <div className="mac-window-button minimize"></div>+ <div className="mac-window-button expand"></div>+ </>+ )}+ {!!text && <Message+ animationType="type"+ id="title"+ onTypingEnd={() => {setIsTyping(false)}}+ onTypingStart={() => {setIsTyping(true)}}+ style={messageStyleMerged}+ text={text}+ />}+ {!!setIsExpanded && (+ <div+ style={{ position: "absolute", right: "0em" }}+ onClick={() => setIsExpanded((prev) => !prev)}+ >+ <ExpandIcon+ fillColor={expandFillColorMerged}+ height="0.75em"+ style={{ marginRight: "0.75em", cursor: "pointer" }}+ />+ </div>+ )}+ </div>+ );+};++// PropTypes for type checking+MacBar.propTypes = {+ setIsTyping: PropTypes.func,+ text: PropTypes.string,+ barStyle: PropTypes.object,+ messageStyle: PropTypes.object,+ setIsExpanded: PropTypes.func,+};++export default MacBar;diff --git a/sweagent/frontend/src/components/panels/Feed.js b/sweagent/frontend/src/components/panels/AgentFeed.jssimilarity index 81%rename from sweagent/frontend/src/components/panels/Feed.jsrename to sweagent/frontend/src/components/panels/AgentFeed.jsindex 08bbf085..90dfb37a 100644--- a/sweagent/frontend/src/components/panels/Feed.js+++ b/sweagent/frontend/src/components/panels/AgentFeed.js@@ -1,6 +1,7 @@import React, { useEffect } from 'react';import Message from '../Message';+import workspaceLogo from '../../assets/panel_icons/workspace.png';function useScrollToBottom(feed, ref) {useEffect(() => {@@ -10,7 +11,7 @@ function useScrollToBottom(feed, ref) {}, [feed, ref]);}-const Feed = ({ feed, id, title, highlightedStep, handleMouseEnter, selfRef}) => {+const AgentFeed = ({ feed, id, title, highlightedStep, handleMouseEnter, selfRef, }) => {useScrollToBottom(feed, selfRef);const feedID = id + "Feed";@@ -18,7 +19,7 @@ const Feed = ({ feed, id, title, highlightedStep, handleMouseEnter, selfRef}) =>return (<div id={feedID} className={feedID}><div id="label">- {/* <img src={workspaceLogo} alt="workspace" /> */}+ <img src={workspaceLogo} alt="workspace" /><span>{title}</span></div><div className="scrollableDiv" ref={selfRef} >@@ -39,4 +40,4 @@ const Feed = ({ feed, id, title, highlightedStep, handleMouseEnter, selfRef}) =>);};-export default Feed;+export default AgentFeed;diff --git a/sweagent/frontend/src/components/panels/EnvFeed.js b/sweagent/frontend/src/components/panels/EnvFeed.jsnew file mode 100644index 00000000..1f649780--- /dev/null+++ b/sweagent/frontend/src/components/panels/EnvFeed.js@@ -0,0 +1,49 @@+import React, { useEffect } from 'react';+import Message from '../Message';++import MacBar from '../MacBar';+import terminalLogo from '../../assets/panel_icons/terminal.png';++function useScrollToBottom(feed, ref) {+ useEffect(() => {+ if (ref.current) {+ ref.current.scrollTop = ref.current.scrollHeight;+ }+ }, [feed, ref]);+}++const EnvFeed = ({ feed, id, title, highlightedStep, handleMouseEnter, selfRef, setIsTerminalExpanded}) => {+ useScrollToBottom(feed, selfRef);++ const feedID = id + "Feed";++ return (+ <div id={feedID} className={feedID}>+ <div id="label">+ <img src={terminalLogo} alt="workspace" />+ <span>{title}</span>+ </div>+ <MacBar+ barStyle={{ height: "2em" }}+ expandFillColor={"black"}+ setIsExpanded={setIsTerminalExpanded}+ />+ <div className="scrollableDiv" ref={selfRef} >+ <div className="innerDiv">+ {feed.map((item, index) => (+ <Message+ key={index}+ item={item}+ handleMouseEnter={handleMouseEnter}+ isHighlighted={item.step !== null && highlightedStep === item.step}+ feedRef={selfRef}+ />+ ))}+ <div style={{ clear: "both", marginTop: '1em' }}/>+ </div>+ </div>+ </div>+ );+};++export default EnvFeed;diff --git a/sweagent/frontend/src/components/panels/LogPanel.js b/sweagent/frontend/src/components/panels/LogPanel.jsnew file mode 100644index 00000000..c6ac54d7--- /dev/null+++ b/sweagent/frontend/src/components/panels/LogPanel.js@@ -0,0 +1,39 @@+import React, { useEffect } from 'react';+import Message from '../Message';++import MacBar from '../MacBar';+import editorLogo from '../../assets/panel_icons/editor.png';++const LogPanel = ({ logs, logsRef, setIsTerminalExpanded}) => {+++ return (+ <div id="logPanel" className="logPanel">+ <div id="label">+ <img src={editorLogo} alt="log panel" />+ <span>Logs</span>+ </div>+ <MacBar+ barStyle={{+ background: "linear-gradient(to bottom, rgba(0,0,0,0.6), rgba(0,0,0,0.9))",+ height: "2em",+ }}+ messageStyle={{+ color: "white",+ fontSize: "smaller",+ marginBottom: "0.1em",+ }}+ expandFillColor={"black"}+ setIsExpanded={setIsTerminalExpanded}+ />+ <div className="scrollableDiv" ref={logsRef} >+ <div className="innerDiv">+ <pre>{logs}</pre>+ <div style={{ clear: "both", marginTop: '1em' }}/>+ </div>+ </div>+ </div>+ );+};++export default LogPanel;diff --git a/sweagent/frontend/src/components/utils/icons/ExpandIcon.js b/sweagent/frontend/src/components/utils/icons/ExpandIcon.jsnew file mode 100644index 00000000..838358a9--- /dev/null+++ b/sweagent/frontend/src/components/utils/icons/ExpandIcon.js@@ -0,0 +1,25 @@+import React from 'react';++const ExpandIcon = ({ fillColor, height, style }) => (+ <svg fill={fillColor} height={height} viewBox="0 0 242.133 242.133" xmlns="http://www.w3.org/2000/svg" style={style}>+ <g id="XMLID_25_">+ <path id="XMLID_26_" d="M89.247,131.673l-47.732,47.73l-15.909-15.91c-4.29-4.291-10.742-5.572-16.347-3.252+ C3.654,162.563,0,168.033,0,174.1v53.032c0,8.284,6.716,15,15,15l53.033,0.001c0.007-0.001,0.012-0.001,0.019,0+ c8.285,0,15-6.716,15-15c0-4.377-1.875-8.316-4.865-11.059l-15.458-15.458l47.73-47.729c5.858-5.858,5.858-15.355,0-21.213+ C104.603,125.815,95.104,125.816,89.247,131.673z"/>+ <path id="XMLID_28_" d="M227.133,0H174.1c-6.067,0-11.536,3.655-13.858,9.26c-2.321,5.605-1.038,12.057,3.252,16.347l15.911,15.911+ l-47.729,47.73c-5.858,5.858-5.858,15.355,0,21.213c2.929,2.929,6.768,4.393,10.606,4.393c3.839,0,7.678-1.464,10.606-4.394+ l47.73-47.73l15.909,15.91c2.869,2.87,6.706,4.394,10.609,4.394c1.933,0,3.882-0.373,5.737-1.142+ c5.605-2.322,9.26-7.792,9.26-13.858V15C242.133,6.716,235.417,0,227.133,0z"/>+ </g>+ </svg>+);++// Set default props+ExpandIcon.defaultProps = {+ fillColor: "#000000",+ height: "24px",+ style: {}+};++export default ExpandIcon;diff --git a/sweagent/frontend/src/index.css b/sweagent/frontend/src/index.cssindex ec2585e8..605a75c0 100644--- a/sweagent/frontend/src/index.css+++ b/sweagent/frontend/src/index.css@@ -1,13 +1,45 @@body {- margin: 0;- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',- 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',- sans-serif;- -webkit-font-smoothing: antialiased;- -moz-osx-font-smoothing: grayscale;+ font-family: 'basic-sans';+ background-color: #FFF7EC;}-code {- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',- monospace;+hr {+ border: none;+ border-top: 1px solid #bbb;+ margin: 0 auto;+ margin-top: 1em;+}++.container-demo {+ margin: 0 auto;+ width: 54%;+}++.container-about {+ margin: 0 auto;+ width: 50%;+}++@media only screen and (max-width: 768px) {+ hr {+ width: 95%;+ }+ .container-demo {+ width: 95%;+ }+ .container-about {+ width: 95%;+ }+}++@media only screen and (max-width: 1440px) {+ .container-about {+ width: 75%;+ }+}++@media only screen and (max-width: 2400px) {+ .container-demo {+ width: 80%;+ }}diff --git a/sweagent/frontend/src/static/app.css b/sweagent/frontend/src/static/app.cssindex 3f9ec81a..80838b68 100644--- a/sweagent/frontend/src/static/app.css+++ b/sweagent/frontend/src/static/app.css@@ -63,15 +63,6 @@-#log {- height: 300px;- max-width: 50%;- border: 1px solid #ccc;- border-radius: 5px;- padding: 10px;- overflow-y: auto;-}-#demo hr {border-top: 1px dotted #bbb;margin: 0.5em 0;diff --git a/sweagent/frontend/src/static/macbar.css b/sweagent/frontend/src/static/macbar.cssnew file mode 100644index 00000000..57dc7fdf--- /dev/null+++ b/sweagent/frontend/src/static/macbar.css@@ -0,0 +1,40 @@+.mac-window-top-bar {+ background-color: #f0f0f0;+ background-image: linear-gradient(to bottom, #f0f0f0, #e0e0e0); /* Gradient effect */+ border-top-left-radius: 0.5em;+ border-top-right-radius: 0.5em;+ height: 1.2em;+ position: relative;+ display: flex;+ align-items: center;+}++.mac-window-button {+ width: 0.5em;+ height: 0.5em;+ border-radius: 50%;+ position: absolute;+ top: 50%;+ transform: translateY(-50%);+ cursor: pointer;+ transition: background-color 0.3s ease;+}++.mac-window-button:hover {+ background-color: #c0c0c0;+}++.mac-window-button.close {+ background-color: #FF605C;+ left: 0.5em;+}++.mac-window-button.minimize {+ background-color: #FFBD44;+ left: 1.25em;+}++.mac-window-button.expand {+ background-color: #00CA4E;+ left: 2em;+}\ No newline at end of file