Skip to content

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: Factor out Feed.js; fix highlighting of step == null

Kilian Lieret88cfef873d79
diff --git a/sweagent/frontend/src/App.js b/sweagent/frontend/src/App.js
index 8a67f328..69d9bab4 100644
--- a/sweagent/frontend/src/App.js
+++ b/sweagent/frontend/src/App.js
@@ -2,6 +2,7 @@ import React, { useState, useRef, useEffect } from 'react';
import axios from 'axios';
import io from 'socket.io-client';
import './App.css';
+import Feed from './components/panels/Feed';
const url = ''; // Will get this from .env
// Connect to Socket.io
@@ -111,49 +112,5 @@ function App() {
);
}
-const Feed = ({ feed, title, highlightedStep, handleMouseEnter, selfRef, otherRef, isComputing }) => {
- // Scroll to the bottom of the feed whenever the feed data changes
- useEffect(() => {
- if (selfRef.current) {
- selfRef.current.scrollTop = selfRef.current.scrollHeight;
- }
- }, [feed, selfRef]);
-
- // Scroll to the first message of the highlighted step from the other feed
- useEffect(() => {
- if (!isComputing && highlightedStep && otherRef.current) {
- const firstStepMessage = [...otherRef.current.children].find(
- child => child.classList.contains(`step${highlightedStep}`)
- );
- if (firstStepMessage) {
- window.requestAnimationFrame(() => {
- otherRef.current.scrollTo({
- top: firstStepMessage.offsetTop - otherRef.current.offsetTop,
- behavior: 'smooth'
- });
- });
- }
- }
- }, [highlightedStep, otherRef, isComputing]);
-
-
- const feedID = title.toLowerCase().replace(' ', '');
-
- return (
- <div id={feedID} ref={selfRef} >
- <h3>{title}</h3>
- {feed.map((item, index) => (
- <div key={index}
- className={`message ${item.format} step${item.step} ${highlightedStep === item.step ? 'highlight' : ''}`}
- onMouseEnter={() => handleMouseEnter(item.step)}
- >
- <h4>{item.title}</h4>
- {item.message}
- </div>
- ))}
- </div>
- )
-};
-
export default App;
diff --git a/sweagent/frontend/src/components/panels/Feed.js b/sweagent/frontend/src/components/panels/Feed.js
new file mode 100644
index 00000000..7a646b9a
--- /dev/null
+++ b/sweagent/frontend/src/components/panels/Feed.js
@@ -0,0 +1,52 @@
+import React, { useEffect } from 'react';
+
+const Feed = ({ feed, title, highlightedStep, handleMouseEnter, selfRef, otherRef, isComputing }) => {
+ // Scroll to the bottom of the feed whenever the feed data changes
+ useEffect(() => {
+ if (selfRef.current) {
+ selfRef.current.scrollTop = selfRef.current.scrollHeight;
+ }
+ }, [feed, selfRef]);
+
+ // Scroll to the first message of the highlighted step from the other feed
+ useEffect(() => {
+ if (!isComputing && highlightedStep && otherRef.current) {
+ const firstStepMessage = [...otherRef.current.children].find(
+ child => child.classList.contains(`step${highlightedStep}`)
+ );
+ if (firstStepMessage) {
+ window.requestAnimationFrame(() => {
+ otherRef.current.scrollTo({
+ top: firstStepMessage.offsetTop - otherRef.current.offsetTop,
+ behavior: 'smooth'
+ });
+ });
+ }
+ }
+ }, [highlightedStep, otherRef, isComputing]);
+
+
+ const feedID = title.toLowerCase().replace(' ', '');
+
+ return (
+ <div id={feedID} ref={selfRef} >
+ <h3>{title}</h3>
+ {feed.map((item, index) => {
+ const stepClass = item.step !== null ? `step${item.step}` : '';
+ const highlightClass = item.step !== null && highlightedStep === item.step ? 'highlight' : '';
+ return (
+ <div key={index}
+ className={`message ${item.format} ${stepClass} ${highlightClass}`}
+ onMouseEnter={() => handleMouseEnter(item.step)}
+ >
+ <h4>{item.title}</h4>
+ {item.message}
+ </div>
+ );
+ }
+ )}
+ </div>
+ )
+};
+
+export default Feed;
\ No newline at end of file
diff --git a/sweagent/frontend/src/controls/LRunControl.js b/sweagent/frontend/src/controls/LRunControl.js
new file mode 100644
index 00000000..e69de29b