Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Sotopia aact frontend #253

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
cf1623c
first draft of frontend
akhatua2 Nov 21, 2024
c113227
More UI changes
akhatua2 Nov 22, 2024
c2f4d57
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 22, 2024
7f7a0c2
Handing user messages from the frontend
akhatua2 Nov 22, 2024
f73adc8
Cleaning up some comments
akhatua2 Nov 22, 2024
2fcdd4c
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 22, 2024
ef126e1
Adding Sidebar and empty scene context
akhatua2 Nov 22, 2024
b07e7ea
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 22, 2024
21b3322
Added icon to terminal
akhatua2 Nov 22, 2024
36646a8
Fixing logic in chat interface and terminal
akhatua2 Nov 22, 2024
0ab65a2
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 22, 2024
a05ff89
Fix logic in file system
akhatua2 Nov 22, 2024
5eff79d
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 22, 2024
1333c74
Making small changes to the prompt
akhatua2 Nov 22, 2024
f275702
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 22, 2024
b3ee78f
Fix some code editor formatting and add thought
akhatua2 Nov 22, 2024
334bce3
Pass in scenecontext on the sidebar
akhatua2 Nov 22, 2024
bd05074
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 22, 2024
f143d73
Updated readme and made some visual improvements.
akhatua2 Nov 22, 2024
89f60a3
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 22, 2024
b360b9f
Added some cool logic to the terminal to follow the file path the use…
akhatua2 Nov 22, 2024
1be2f29
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 22, 2024
2381b03
Fix file tree setup
akhatua2 Nov 22, 2024
5fe47ab
Adding comments to app.tsx and refactoring file handling
akhatua2 Nov 22, 2024
91030f3
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 22, 2024
c8be137
Added bunch of comments
akhatua2 Nov 22, 2024
700fbd9
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 22, 2024
aba978f
added a next js frontend
ProKil Nov 22, 2024
e0d8b66
add use client to client side components
ProKil Nov 22, 2024
7a4897f
Small change to terminal init logic
akhatua2 Nov 22, 2024
938144c
Connected code editor to runtime
akhatua2 Nov 23, 2024
2fc1bfa
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 23, 2024
9b8fa77
Handle saved and unsaved files (adding a * to unsaved files)
akhatua2 Nov 23, 2024
9f79a7f
filesystem refresh works (kind of)
akhatua2 Nov 23, 2024
70e660a
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 23, 2024
077044d
Connected filesystem to runtime and setup on init
akhatua2 Nov 23, 2024
50a88c1
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 23, 2024
6f54198
termina, filesystem, coding and chat done for human data collection
akhatua2 Nov 23, 2024
35e9294
Merge branch 'sotopia-aact-frontend' of https://github.com/sotopia-la…
akhatua2 Nov 23, 2024
1b9c4b1
Adding human-llm interview setting
akhatua2 Nov 23, 2024
bfaddfe
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 23, 2024
f1cbd73
Added up and down arrow support in terminal
akhatua2 Nov 23, 2024
27f5269
Merge branch 'sotopia-aact-frontend' of https://github.com/sotopia-la…
akhatua2 Nov 23, 2024
feec40f
Adding file input feature in file system
akhatua2 Nov 23, 2024
4436ac9
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 23, 2024
9eacd4e
Minor UI change
akhatua2 Nov 23, 2024
b8fbaaf
Chat input handling multi lines and then reset
akhatua2 Nov 23, 2024
5aa3c09
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 23, 2024
77a74f7
Double click on file to retrieve file content
akhatua2 Nov 23, 2024
530439f
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 23, 2024
a8aabac
nextjs migrate
alexjyc Dec 10, 2024
d816e52
nextjs migrate
alexjyc Dec 10, 2024
419f44f
next migration
alexjyc Dec 12, 2024
e3724c8
next migration
alexjyc Dec 12, 2024
77b90bb
next migration
alexjyc Dec 12, 2024
ee4d456
next migration deploy
alexjyc Dec 12, 2024
f4c9bf6
next migration deploy
alexjyc Dec 12, 2024
d76f5f8
next migration deploy
alexjyc Dec 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/experimental/interview_frontend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
}
40 changes: 40 additions & 0 deletions examples/experimental/interview_frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions examples/experimental/interview_frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
Binary file not shown.
7 changes: 7 additions & 0 deletions examples/experimental/interview_frontend/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
};

export default nextConfig;
35 changes: 35 additions & 0 deletions examples/experimental/interview_frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "interview_frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"react": "<19.0.0",
"react-dom": "<19.0.0",
"next": "15.0.3",
"@codemirror/lang-css": "^6.3.0",
"@codemirror/lang-html": "^6.4.9",
"@codemirror/lang-javascript": "^6.2.2",
"@codemirror/lang-python": "^6.1.6",
"@uiw/codemirror-theme-github": "^4.23.6",
"@uiw/react-codemirror": "^4.23.6",
"lucide-react": "^0.460.0",
"react-icons": "^5.3.0",
"socket.io-client": "^4.8.1"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"eslint": "^8",
"eslint-config-next": "15.0.3"
}
}
8 changes: 8 additions & 0 deletions examples/experimental/interview_frontend/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
tailwindcss: {},
},
};

export default config;
1 change: 1 addition & 0 deletions examples/experimental/interview_frontend/public/file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/experimental/interview_frontend/public/globe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/experimental/interview_frontend/public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/experimental/interview_frontend/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/experimental/interview_frontend/public/window.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
21 changes: 21 additions & 0 deletions examples/experimental/interview_frontend/src/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
--background: #ffffff;
--foreground: #171717;
}

@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
}
}

body {
color: var(--foreground);
background: var(--background);
font-family: Arial, Helvetica, sans-serif;
}
22 changes: 22 additions & 0 deletions examples/experimental/interview_frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";

const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
title: "NextJS IDE",
description: "Interactive Development Environment",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>
);
}
174 changes: 174 additions & 0 deletions examples/experimental/interview_frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
'use client';

import { useEffect, useState } from 'react';
import io, { Socket } from 'socket.io-client';
import CodeEditor from '@/components/CodeEditor/CodeEditor';
import { FileSystem } from '@/components/CodeEditor/FileSystem';
import { Terminal } from '@/components/Terminal/Terminal';
import { ChatInterface } from '@/components/ChatInterface/ChatInterface';
import { Browser } from '@/components/Browser/Browser';
import { Sidebar } from '@/components/Sidebar/Sidebar';
import { SceneContext } from '@/components/Sidebar/SceneContext';

type FilesType = {
[key: string]: string;
};

type PanelOption = 'fileSystem' | 'sceneContext';

let socket: Socket;

export default function Home() {
const [files, setFiles] = useState<FilesType>({
"/workspace/index.html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <title>Document</title>\n</head>\n<body>\n <h1>Hello World</h1>\n</body>\n</html>",
"/workspace/style.css": "body {\n background-color: #f0f0f0;\n font-family: Arial, sans-serif;\n}",
"/workspace/script.js": "console.log('Hello, World!');",
"/workspace/interview.py": "# Python code here"
});

const [currentFile, setCurrentFile] = useState("/workspace/interview.py");
const [messages, setMessages] = useState<Array<{text: string, type: 'message' | 'status'}>>([]);
const [terminalMessages, setTerminalMessages] = useState<string[]>([]);
const [activeTab, setActiveTab] = useState<'editor' | 'browser'>('editor');
const [browserUrl, setBrowserUrl] = useState('https://example.com');
const [activePanel, setActivePanel] = useState<PanelOption>('fileSystem');
const [isConnected, setIsConnected] = useState(false);

useEffect(() => {
socket = io(process.env.NEXT_PUBLIC_SOCKET_URL || 'http://localhost:8000', {
transports: ['websocket'],
reconnection: true
});

socket.on('connect', () => {
setIsConnected(true);
console.log('Connected to server with ID:', socket.id);
});

socket.on('connect_error', (error) => {
console.error('Connection error:', error);
setIsConnected(false);
});

return () => {
socket.disconnect();
};
}, []);

useEffect(() => {
if (!socket) return;

const handleNewMessage = (data: any) => {
const messageData = JSON.parse(data.message);
if (messageData.data.data_type === "agent_action") {
handleAgentAction(messageData);
} else if (messageData.data.data_type === "text" && messageData.data.text.includes("CmdOutputObservation")) {
const parts = messageData.data.text.split("**CmdOutputObservation (source=None, exit code=0)**");
if (parts.length > 1) {
const outputText = parts[1].trim();
setTerminalMessages((prev) => [...prev, outputText]);
}
}
};

socket.on('new_message', handleNewMessage);
return () => {
socket.off('new_message', handleNewMessage);
};
}, [socket]);

const handleAgentAction = (messageData: any) => {
const actionType = messageData.data.action_type;
const agentName = messageData.data.agent_name;

switch (actionType) {
case "speak":
setMessages(prev => [...prev, {
text: `${agentName}: ${messageData.data.argument}`,
type: 'message' as const
}]);
break;
case "write":
const filePath = messageData.data.path;
const fileContent = messageData.data.argument;
setFiles(prevFiles => ({ ...prevFiles, [filePath]: fileContent }));
setActiveTab('editor');
setMessages(prev => [...prev, {
text: `${agentName} is writing code...`,
type: 'status' as const
}]);
break;
case "run":
setTerminalMessages(prev => [...prev, `$ ${messageData.data.argument}`]);
setMessages(prev => [...prev, {
text: `${agentName} is executing a command...`,
type: 'status' as const
}]);
break;
case "browse":
const url = messageData.data.argument;
setBrowserUrl(url);
setActiveTab('browser');
setMessages(prev => [...prev, {
text: `${agentName} is browsing ${url}`,
type: 'status' as const
}]);
break;
}
};

if (!isConnected) {
return <div className="flex items-center justify-center min-h-screen bg-gray-900 text-white">
Connecting to server...
</div>;
}

return (
<div className="flex h-screen bg-gray-900">
<Sidebar onSelect={setActivePanel} />
<div className="flex flex-1">
{activePanel === 'fileSystem' && (
<div id="file-explorer" className="w-64 bg-gray-800 border-r border-gray-700">
<FileSystem onFileSelect={setCurrentFile} />
</div>
)}
{activePanel === 'sceneContext' && (
<div id="scene-context" className="w-64 bg-gray-800 border-r border-gray-700">
<SceneContext />
</div>
)}
<div className="flex-1 flex flex-col">
<div className="flex border-b border-gray-700">
<button
onClick={() => setActiveTab('editor')}
className={`px-4 py-2 ${activeTab === 'editor' ? 'bg-gray-700 text-white' : 'text-gray-400 hover:bg-gray-800'}`}
>
Code Editor
</button>
<button
onClick={() => setActiveTab('browser')}
className={`px-4 py-2 ${activeTab === 'browser' ? 'bg-gray-700 text-white' : 'text-gray-400 hover:bg-gray-800'}`}
>
Browser
</button>
</div>
<div className="flex-1">
{activeTab === 'editor' ? (
<CodeEditor
code={files[currentFile]}
onChange={(newCode) => setFiles(prev => ({ ...prev, [currentFile]: newCode }))}
filename={currentFile}
/>
) : (
<Browser url={browserUrl} />
)}
</div>
<Terminal externalMessages={terminalMessages} socket={socket} />
</div>
<div className="w-[600px] border-l border-gray-700">
<ChatInterface messages={messages} socket={socket} />
</div>
</div>
</div>
);
}
Loading
Loading