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: Switch to using jquery
Kilian Liereta4c05684cef0
diff --git a/sweagent/web/static/scripts/mainscript.js b/sweagent/web/static/scripts/mainscript.jsindex 5b7e0b7e..d95fe268 100644--- a/sweagent/web/static/scripts/mainscript.js+++ b/sweagent/web/static/scripts/mainscript.js@@ -1,39 +1,32 @@function addMessageToFeed(feedID, title, text, format) {console.log("in addMessageToFeed");- const feed = document.getElementById(feedID);- const messageBlock = document.createElement('div');- messageBlock.className = 'message';- if ( title != null && title.length > 0 ) {- const messageTitle = document.createElement('h4');- messageTitle.textContent = title;- messageBlock.appendChild(messageTitle);- }+ const $feed = $(feedID);+ const $messageBlock = $('<div>', { class: 'message' });- let messageText;- if ( format == "text" ) {- messageText = document.createElement('p');- messageText.textContent = text;- }- else if ( format == "markdown" ) {- messageText = document.createElement('md-block');- messageText.textContent = text;+ if (title) {+ $('<h4>', { text: title }).appendTo($messageBlock);}- else {++ let $messageText;+ if (format === "text") {+ $messageText = $('<p>', { text: text });+ } else if (format === "markdown") {+ $messageText = $('<md-block>', { text: text }); // Note: Custom elements need to be handled properly in jQuery+ } else {console.error("Unknown format: " + format);+ return;}- messageBlock.appendChild(messageText);-- feed.appendChild(messageBlock);- feed.scrollTop = feed.scrollHeight;+ $messageBlock.append($messageText).appendTo($feed);+ $feed.scrollTop($feed.prop("scrollHeight")); // jQuery method to scroll to the bottom}document.addEventListener('DOMContentLoaded', function() {const socket = io();socket.on('update', function(data) {- feed = data["feed"] + "Feed";+ feed = '#' + data["feed"] + "Feed";addMessageToFeed(feed, data["title"], data["message"], data["format"]);});});\ No newline at end of filediff --git a/sweagent/web/templates/index.html b/sweagent/web/templates/index.htmlindex e945794c..282a4283 100644--- a/sweagent/web/templates/index.html+++ b/sweagent/web/templates/index.html@@ -2,10 +2,25 @@<html><head><title>Run Command</title>- <link rel= "stylesheet" type= "text/css" href="{{ url_for('static',filename='styles/mainpage.css') }}">+ <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='styles/mainpage.css') }}"><script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.0/socket.io.js"></script>- <script src="{{ url_for('static',filename='scripts/mainscript.js') }}"> </script>+ <script src="{{ url_for('static',filename='scripts/mainscript.js') }}"></script><script type="module" src="https://md-block.verou.me/md-block.js"></script>+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>+ <script>+ $(document).ready(function() {+ $('#dataForm').on('submit', function(event) {+ event.preventDefault();+ const dataPath = $('#data_path').val();+ const testRun = $('#test_run').is(':checked');+ $.get(`/run`, { data_path: dataPath, test_run: testRun }, function(response) {+ $('#responseMessage').text(response);+ }).fail(function(error) {+ console.error('Error:', error);+ });+ });+ });+ </script></head><body><h1>Start run</h1>@@ -18,20 +33,6 @@</form><div id="responseMessage"></div><div id="update"></div>- <script>- document.getElementById('dataForm').addEventListener('submit', function(event) {- console.log("submit!");- event.preventDefault();- var dataPath = document.getElementById('data_path').value;- var testRun = document.getElementById('test_run').checked;- fetch(`/run?asdf=true&data_path=${encodeURIComponent(dataPath)}&test_run=${testRun}`, {- method: 'GET'- })- .then(response => response.text())- .then(text => document.getElementById('responseMessage').innerText = text)- .catch(error => console.error('Error:', error));- });- </script><h2>Trajectory</h2><div id="container"><div id="agentFeed">@@ -42,4 +43,4 @@</div></div></body>-</html>\ No newline at end of file+</html>