feat: 🚧 Router and new history page
This commit is contained in:
parent
98de69abbd
commit
f19345c652
22 changed files with 5524 additions and 158 deletions
|
|
@ -1,7 +1,7 @@
|
|||
from functools import cached_property
|
||||
import traceback
|
||||
import time
|
||||
from typing import Callable, Coroutine, Dict, List, Union
|
||||
from typing import Callable, Coroutine, Dict, List, Optional, Union
|
||||
from aiohttp import ClientPayloadError
|
||||
from pydantic import root_validator
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ class Autopilot(ContinueBaseModel):
|
|||
|
||||
started: bool = False
|
||||
|
||||
async def start(self):
|
||||
async def start(self, full_state: Optional[FullState] = None):
|
||||
self.continue_sdk = await ContinueSDK.create(self)
|
||||
if override_policy := self.continue_sdk.config.policy_override:
|
||||
self.policy = override_policy
|
||||
|
|
@ -84,6 +84,12 @@ class Autopilot(ContinueBaseModel):
|
|||
logger.debug("Loading index")
|
||||
create_async_task(self.context_manager.load_index(
|
||||
self.ide.workspace_directory))
|
||||
|
||||
if full_state is not None:
|
||||
self.history = full_state.history
|
||||
self.context_manager.context_providers["code"].adding_highlighted_code = full_state.adding_highlighted_code
|
||||
await self.context_manager.set_selected_items(full_state.selected_context_items)
|
||||
|
||||
self.started = True
|
||||
|
||||
class Config:
|
||||
|
|
|
|||
|
|
@ -263,6 +263,12 @@ class FullState(ContinueBaseModel):
|
|||
selected_context_items: List[ContextItem]
|
||||
|
||||
|
||||
class SessionInfo(ContinueBaseModel):
|
||||
session_id: str
|
||||
title: str
|
||||
date_created: str
|
||||
|
||||
|
||||
class ContinueSDK:
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,12 @@ def getSessionFilePath(session_id: str):
|
|||
return path
|
||||
|
||||
|
||||
def getSessionsListFilePath():
|
||||
path = os.path.join(getSessionsFolderPath(), "sessions.json")
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
return path
|
||||
|
||||
|
||||
def getConfigFilePath() -> str:
|
||||
path = os.path.join(getGlobalFolderPath(), "config.py")
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from .main import *
|
||||
from .filesystem import RangeInFile, FileEdit
|
||||
from .filesystem_edit import FileEditWithFullContents
|
||||
from ..core.main import History, HistoryNode, FullState
|
||||
from ..core.main import History, HistoryNode, FullState, SessionInfo
|
||||
from ..core.context import ContextItem
|
||||
from pydantic import schema_json_of
|
||||
import os
|
||||
|
|
@ -13,7 +13,7 @@ MODELS_TO_GENERATE = [
|
|||
] + [
|
||||
FileEditWithFullContents
|
||||
] + [
|
||||
History, HistoryNode, FullState
|
||||
History, HistoryNode, FullState, SessionInfo
|
||||
] + [
|
||||
ContextItem
|
||||
]
|
||||
|
|
|
|||
|
|
@ -154,6 +154,9 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
|
|||
create_async_task(
|
||||
self.session.autopilot.select_context_item(id, query), self.on_error)
|
||||
|
||||
async def reconnect_at_session(self, session_id: str):
|
||||
await self._send_json("reconnect_at_session", {"session_id": session_id})
|
||||
|
||||
|
||||
@router.websocket("/ws")
|
||||
async def websocket_endpoint(websocket: WebSocket, session: Session = Depends(websocket_session)):
|
||||
|
|
|
|||
|
|
@ -11,13 +11,14 @@ import argparse
|
|||
|
||||
from .ide import router as ide_router
|
||||
from .gui import router as gui_router
|
||||
from .session_manager import session_manager
|
||||
from .session_manager import session_manager, router as sessions_router
|
||||
from ..libs.util.logging import logger
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.include_router(ide_router)
|
||||
app.include_router(gui_router)
|
||||
app.include_router(sessions_router)
|
||||
|
||||
# Add CORS support
|
||||
app.add_middleware(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import os
|
||||
import traceback
|
||||
from fastapi import WebSocket
|
||||
from fastapi import WebSocket, APIRouter
|
||||
from typing import Any, Coroutine, Dict, Union
|
||||
from uuid import uuid4
|
||||
import json
|
||||
|
|
@ -8,14 +8,16 @@ import json
|
|||
from fastapi.websockets import WebSocketState
|
||||
|
||||
from ..plugins.steps.core.core import MessageStep
|
||||
from ..libs.util.paths import getSessionFilePath, getSessionsFolderPath
|
||||
from ..core.main import FullState, HistoryNode
|
||||
from ..libs.util.paths import getSessionFilePath, getSessionsFolderPath, getSessionsListFilePath
|
||||
from ..core.main import FullState, HistoryNode, SessionInfo
|
||||
from ..core.autopilot import Autopilot
|
||||
from .ide_protocol import AbstractIdeProtocolServer
|
||||
from ..libs.util.create_async_task import create_async_task
|
||||
from ..libs.util.errors import SessionNotFound
|
||||
from ..libs.util.logging import logger
|
||||
|
||||
router = APIRouter(prefix="/sessions", tags=["sessions"])
|
||||
|
||||
|
||||
class Session:
|
||||
session_id: str
|
||||
|
|
@ -74,12 +76,12 @@ class SessionManager:
|
|||
|
||||
# Start the autopilot (must be after session is added to sessions) and the policy
|
||||
try:
|
||||
await autopilot.start()
|
||||
await autopilot.start(full_state=full_state)
|
||||
except Exception as e:
|
||||
# Have to manually add to history because autopilot isn't started
|
||||
formatted_err = '\n'.join(traceback.format_exception(e))
|
||||
msg_step = MessageStep(
|
||||
name="Error loading context manager", message=formatted_err)
|
||||
name="Error starting Autopilot", message=formatted_err)
|
||||
msg_step.description = f"```\n{formatted_err}\n```"
|
||||
autopilot.history.add_node(HistoryNode(
|
||||
step=msg_step,
|
||||
|
|
@ -87,7 +89,7 @@ class SessionManager:
|
|||
depth=0,
|
||||
active=False
|
||||
))
|
||||
logger.warning(f"Error loading context manager: {e}")
|
||||
logger.warning(f"Error starting Autopilot: {e}")
|
||||
|
||||
def on_error(e: Exception) -> Coroutine:
|
||||
err_msg = '\n'.join(traceback.format_exception(e))
|
||||
|
|
@ -112,6 +114,27 @@ class SessionManager:
|
|||
with open(getSessionFilePath(session_id), "w") as f:
|
||||
json.dump(full_state.dict(), f)
|
||||
|
||||
# Read and update the sessions list
|
||||
with open(getSessionsListFilePath(), "r") as f:
|
||||
sessions_list = json.load(f)
|
||||
|
||||
sessions_list.append(SessionInfo(
|
||||
session_info=full_state.session_info
|
||||
))
|
||||
|
||||
async def load_session(self, old_session_id: str, new_session_id: str):
|
||||
"""Load the session's FullState from a json file"""
|
||||
|
||||
# First persist the current state
|
||||
await self.persist_session(old_session_id)
|
||||
|
||||
# Delete the old session, but keep the IDE
|
||||
ide = self.registered_ides[old_session_id]
|
||||
self.registered_ides[old_session_id] = None
|
||||
|
||||
# Start the new session
|
||||
await self.new_session(ide, session_id=new_session_id)
|
||||
|
||||
def register_websocket(self, session_id: str, ws: WebSocket):
|
||||
self.sessions[session_id].ws = ws
|
||||
logger.debug(f"Registered websocket for session {session_id}")
|
||||
|
|
@ -130,3 +153,11 @@ class SessionManager:
|
|||
|
||||
|
||||
session_manager = SessionManager()
|
||||
|
||||
|
||||
@router.get("/list")
|
||||
async def list_sessions():
|
||||
"""List all sessions"""
|
||||
sessions_list_file = getSessionsListFilePath()
|
||||
sessions = json.load(open(sessions_list_file, "r"))
|
||||
return sessions
|
||||
|
|
|
|||
5226
extension/react-app/package-lock.json
generated
5226
extension/react-app/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -19,6 +19,7 @@
|
|||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-redux": "^8.0.5",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"react-switch": "^7.0.0",
|
||||
"react-syntax-highlighter": "^15.5.0",
|
||||
"react-tooltip": "^5.18.0",
|
||||
|
|
@ -28,6 +29,7 @@
|
|||
"devDependencies": {
|
||||
"@types/react": "^18.0.27",
|
||||
"@types/react-dom": "^18.0.10",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
"@types/react-syntax-highlighter": "^15.5.7",
|
||||
"@types/styled-components": "^5.1.26",
|
||||
"@vitejs/plugin-react-swc": "^3.0.0",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,26 @@
|
|||
import DebugPanel from "./components/DebugPanel";
|
||||
import GUI from "./pages/gui";
|
||||
import { createContext } from "react";
|
||||
import History from "./pages/history";
|
||||
import Layout from "./components/Layout";
|
||||
import { createContext, useEffect } from "react";
|
||||
import useContinueGUIProtocol from "./hooks/useWebsocket";
|
||||
import ContinueGUIClientProtocol from "./hooks/ContinueGUIClientProtocol";
|
||||
import {
|
||||
BrowserRouter as Router,
|
||||
Route,
|
||||
Routes,
|
||||
BrowserRouter,
|
||||
} from "react-router-dom";
|
||||
import { useDispatch } from "react-redux";
|
||||
import {
|
||||
setApiUrl,
|
||||
setVscMachineId,
|
||||
setSessionId,
|
||||
setVscMediaUrl,
|
||||
setDataSwitchOn,
|
||||
} from "./redux/slices/configSlice";
|
||||
import { updateFileSystem } from "./redux/slices/debugContexSlice";
|
||||
import { setHighlightedCode } from "./redux/slices/miscSlice";
|
||||
import { postVscMessage } from "./vscode";
|
||||
|
||||
export const GUIClientContext = createContext<
|
||||
ContinueGUIClientProtocol | undefined
|
||||
|
|
@ -11,9 +29,35 @@ export const GUIClientContext = createContext<
|
|||
function App() {
|
||||
const client = useContinueGUIProtocol();
|
||||
|
||||
const dispatch = useDispatch();
|
||||
useEffect(() => {
|
||||
const eventListener = (event: any) => {
|
||||
switch (event.data.type) {
|
||||
case "onLoad":
|
||||
dispatch(setApiUrl(event.data.apiUrl));
|
||||
dispatch(setVscMachineId(event.data.vscMachineId));
|
||||
dispatch(setSessionId(event.data.sessionId));
|
||||
dispatch(setVscMediaUrl(event.data.vscMediaUrl));
|
||||
dispatch(setDataSwitchOn(event.data.dataSwitchOn));
|
||||
break;
|
||||
case "highlightedCode":
|
||||
dispatch(setHighlightedCode(event.data.rangeInFile));
|
||||
dispatch(updateFileSystem(event.data.filesystem));
|
||||
break;
|
||||
}
|
||||
};
|
||||
window.addEventListener("message", eventListener);
|
||||
postVscMessage("onLoad", {});
|
||||
return () => window.removeEventListener("message", eventListener);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<GUIClientContext.Provider value={client}>
|
||||
<DebugPanel tabs={[{ element: <GUI />, title: "GUI" }]} />
|
||||
<Routes>
|
||||
<Route path="/" element={<Layout />} />
|
||||
<Route path="/gui" element={<GUI />} />
|
||||
<Route path="/history" element={<History />} />
|
||||
</Routes>
|
||||
</GUIClientContext.Provider>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,99 +0,0 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import { postVscMessage } from "../vscode";
|
||||
import { useDispatch } from "react-redux";
|
||||
import {
|
||||
setApiUrl,
|
||||
setVscMachineId,
|
||||
setSessionId,
|
||||
setVscMediaUrl,
|
||||
setDataSwitchOn,
|
||||
} from "../redux/slices/configSlice";
|
||||
import { setHighlightedCode } from "../redux/slices/miscSlice";
|
||||
import { updateFileSystem } from "../redux/slices/debugContexSlice";
|
||||
import { defaultBorderRadius, secondaryDark, vscBackground } from ".";
|
||||
interface DebugPanelProps {
|
||||
tabs: {
|
||||
element: React.ReactElement;
|
||||
title: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
const TabBar = styled.div<{ numTabs: number }>`
|
||||
display: grid;
|
||||
grid-template-columns: repeat(${(props) => props.numTabs}, 1fr);
|
||||
`;
|
||||
|
||||
const TabsAndBodyDiv = styled.div`
|
||||
height: 100%;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
scrollbar-base-color: transparent;
|
||||
`;
|
||||
|
||||
function DebugPanel(props: DebugPanelProps) {
|
||||
const dispatch = useDispatch();
|
||||
useEffect(() => {
|
||||
const eventListener = (event: any) => {
|
||||
switch (event.data.type) {
|
||||
case "onLoad":
|
||||
dispatch(setApiUrl(event.data.apiUrl));
|
||||
dispatch(setVscMachineId(event.data.vscMachineId));
|
||||
dispatch(setSessionId(event.data.sessionId));
|
||||
dispatch(setVscMediaUrl(event.data.vscMediaUrl));
|
||||
dispatch(setDataSwitchOn(event.data.dataSwitchOn));
|
||||
break;
|
||||
case "highlightedCode":
|
||||
dispatch(setHighlightedCode(event.data.rangeInFile));
|
||||
dispatch(updateFileSystem(event.data.filesystem));
|
||||
break;
|
||||
}
|
||||
};
|
||||
window.addEventListener("message", eventListener);
|
||||
postVscMessage("onLoad", {});
|
||||
return () => window.removeEventListener("message", eventListener);
|
||||
}, []);
|
||||
|
||||
const [currentTab, setCurrentTab] = useState(0);
|
||||
|
||||
return (
|
||||
<TabsAndBodyDiv>
|
||||
{props.tabs.length > 1 && (
|
||||
<TabBar numTabs={props.tabs.length}>
|
||||
{props.tabs.map((tab, index) => {
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
className={`p-2 cursor-pointer text-center ${
|
||||
index === currentTab
|
||||
? "bg-secondary-dark"
|
||||
: "bg-vsc-background"
|
||||
}`}
|
||||
onClick={() => setCurrentTab(index)}
|
||||
>
|
||||
{tab.title}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</TabBar>
|
||||
)}
|
||||
{props.tabs.map((tab, index) => {
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
hidden={index !== currentTab}
|
||||
style={{
|
||||
scrollbarGutter: "stable both-edges",
|
||||
minHeight: "100%",
|
||||
display: "grid",
|
||||
gridTemplateRows: "1fr auto",
|
||||
}}
|
||||
>
|
||||
{tab.element}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</TabsAndBodyDiv>
|
||||
);
|
||||
}
|
||||
|
||||
export default DebugPanel;
|
||||
28
extension/react-app/src/components/Layout.tsx
Normal file
28
extension/react-app/src/components/Layout.tsx
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import styled from "styled-components";
|
||||
import { defaultBorderRadius } from ".";
|
||||
import { Outlet } from "react-router-dom";
|
||||
|
||||
const LayoutTopDiv = styled.div`
|
||||
height: 100%;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
scrollbar-base-color: transparent;
|
||||
scrollbar-width: thin;
|
||||
`;
|
||||
const Layout = () => {
|
||||
return (
|
||||
<LayoutTopDiv>
|
||||
<div
|
||||
style={{
|
||||
scrollbarGutter: "stable both-edges",
|
||||
minHeight: "100%",
|
||||
display: "grid",
|
||||
gridTemplateRows: "1fr auto",
|
||||
}}
|
||||
>
|
||||
<Outlet />
|
||||
</div>
|
||||
</LayoutTopDiv>
|
||||
);
|
||||
};
|
||||
|
||||
export default Layout;
|
||||
|
|
@ -30,6 +30,8 @@ abstract class AbstractContinueGUIClientProtocol {
|
|||
abstract showLogsAtIndex(index: number): void;
|
||||
|
||||
abstract selectContextItem(id: string, query: string): void;
|
||||
|
||||
abstract onReconnectAtSession(session_id: string): void;
|
||||
}
|
||||
|
||||
export default AbstractContinueGUIClientProtocol;
|
||||
|
|
|
|||
|
|
@ -4,15 +4,18 @@ import { Messenger, WebsocketMessenger } from "./messenger";
|
|||
import { VscodeMessenger } from "./vscodeMessenger";
|
||||
|
||||
class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol {
|
||||
messenger: Messenger;
|
||||
messenger?: Messenger;
|
||||
// Server URL must contain the session ID param
|
||||
serverUrlWithSessionId: string;
|
||||
useVscodeMessagePassing: boolean;
|
||||
|
||||
constructor(
|
||||
private connectMessenger(
|
||||
serverUrlWithSessionId: string,
|
||||
useVscodeMessagePassing: boolean
|
||||
) {
|
||||
super();
|
||||
if (this.messenger) {
|
||||
// this.messenger.close(); TODO
|
||||
}
|
||||
this.serverUrlWithSessionId = serverUrlWithSessionId;
|
||||
this.messenger = useVscodeMessagePassing
|
||||
? new VscodeMessenger(serverUrlWithSessionId)
|
||||
|
|
@ -24,26 +27,52 @@ class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol {
|
|||
this.messenger.onError((error) => {
|
||||
console.log("GUI -> IDE websocket error", error);
|
||||
});
|
||||
|
||||
this.messenger.onMessageType("reconnect_at_session", (data: any) => {
|
||||
if (data.session_id) {
|
||||
this.onReconnectAtSession(data.session_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
constructor(
|
||||
serverUrlWithSessionId: string,
|
||||
useVscodeMessagePassing: boolean
|
||||
) {
|
||||
super();
|
||||
this.serverUrlWithSessionId = serverUrlWithSessionId;
|
||||
this.useVscodeMessagePassing = useVscodeMessagePassing;
|
||||
this.connectMessenger(serverUrlWithSessionId, useVscodeMessagePassing);
|
||||
}
|
||||
|
||||
onReconnectAtSession(session_id: string): void {
|
||||
this.connectMessenger(
|
||||
this.serverUrlWithSessionId.replace(
|
||||
/\/session\/[a-zA-Z0-9-]+/,
|
||||
`/session/${session_id}`
|
||||
),
|
||||
this.useVscodeMessagePassing
|
||||
);
|
||||
}
|
||||
|
||||
sendMainInput(input: string) {
|
||||
this.messenger.send("main_input", { input });
|
||||
this.messenger?.send("main_input", { input });
|
||||
}
|
||||
|
||||
reverseToIndex(index: number) {
|
||||
this.messenger.send("reverse_to_index", { index });
|
||||
this.messenger?.send("reverse_to_index", { index });
|
||||
}
|
||||
|
||||
sendRefinementInput(input: string, index: number) {
|
||||
this.messenger.send("refinement_input", { input, index });
|
||||
this.messenger?.send("refinement_input", { input, index });
|
||||
}
|
||||
|
||||
sendStepUserInput(input: string, index: number) {
|
||||
this.messenger.send("step_user_input", { input, index });
|
||||
this.messenger?.send("step_user_input", { input, index });
|
||||
}
|
||||
|
||||
onStateUpdate(callback: (state: any) => void) {
|
||||
this.messenger.onMessageType("state_update", (data: any) => {
|
||||
this.messenger?.onMessageType("state_update", (data: any) => {
|
||||
if (data.state) {
|
||||
callback(data.state);
|
||||
}
|
||||
|
|
@ -53,7 +82,7 @@ class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol {
|
|||
onAvailableSlashCommands(
|
||||
callback: (commands: { name: string; description: string }[]) => void
|
||||
) {
|
||||
this.messenger.onMessageType("available_slash_commands", (data: any) => {
|
||||
this.messenger?.onMessageType("available_slash_commands", (data: any) => {
|
||||
if (data.commands) {
|
||||
callback(data.commands);
|
||||
}
|
||||
|
|
@ -61,37 +90,37 @@ class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol {
|
|||
}
|
||||
|
||||
sendClear() {
|
||||
this.messenger.send("clear_history", {});
|
||||
this.messenger?.send("clear_history", {});
|
||||
}
|
||||
|
||||
retryAtIndex(index: number) {
|
||||
this.messenger.send("retry_at_index", { index });
|
||||
this.messenger?.send("retry_at_index", { index });
|
||||
}
|
||||
|
||||
deleteAtIndex(index: number) {
|
||||
this.messenger.send("delete_at_index", { index });
|
||||
this.messenger?.send("delete_at_index", { index });
|
||||
}
|
||||
|
||||
deleteContextWithIds(ids: ContextItemId[]) {
|
||||
this.messenger.send("delete_context_with_ids", {
|
||||
this.messenger?.send("delete_context_with_ids", {
|
||||
ids: ids.map((id) => `${id.provider_title}-${id.item_id}`),
|
||||
});
|
||||
}
|
||||
|
||||
setEditingAtIds(ids: string[]) {
|
||||
this.messenger.send("set_editing_at_ids", { ids });
|
||||
this.messenger?.send("set_editing_at_ids", { ids });
|
||||
}
|
||||
|
||||
toggleAddingHighlightedCode(): void {
|
||||
this.messenger.send("toggle_adding_highlighted_code", {});
|
||||
this.messenger?.send("toggle_adding_highlighted_code", {});
|
||||
}
|
||||
|
||||
showLogsAtIndex(index: number): void {
|
||||
this.messenger.send("show_logs_at_index", { index });
|
||||
this.messenger?.send("show_logs_at_index", { index });
|
||||
}
|
||||
|
||||
selectContextItem(id: string, query: string): void {
|
||||
this.messenger.send("select_context_item", { id, query });
|
||||
this.messenger?.send("select_context_item", { id, query });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@
|
|||
--button-color-hover: rgba(113, 28, 59, 0.667);
|
||||
--def-border-radius: 5px;
|
||||
|
||||
/* --vscode-editor-background: rgb(30, 30, 30);
|
||||
--vscode-editor-background: rgb(30, 30, 30);
|
||||
--vscode-editor-foreground: rgb(197, 200, 198);
|
||||
--vscode-textBlockQuote-background: rgba(255, 255, 255, 0.05); */
|
||||
--vscode-textBlockQuote-background: rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
html,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,14 @@ import "./index.css";
|
|||
|
||||
import posthog from "posthog-js";
|
||||
import { PostHogProvider } from "posthog-js/react";
|
||||
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
||||
|
||||
const router = createBrowserRouter([
|
||||
{
|
||||
path: "/",
|
||||
element: <App />,
|
||||
},
|
||||
]);
|
||||
|
||||
console.log("Starting React");
|
||||
|
||||
|
|
@ -19,7 +27,7 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
|||
<React.StrictMode>
|
||||
<PostHogProvider client={posthog}>
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
<RouterProvider router={router} />
|
||||
</Provider>
|
||||
</PostHogProvider>
|
||||
</React.StrictMode>
|
||||
|
|
|
|||
|
|
@ -16,11 +16,12 @@ import {
|
|||
BookOpenIcon,
|
||||
ChatBubbleOvalLeftEllipsisIcon,
|
||||
TrashIcon,
|
||||
PlusCircleIcon,
|
||||
FolderIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import ComboBox from "../components/ComboBox";
|
||||
import TextDialog from "../components/TextDialog";
|
||||
import HeaderButtonWithText from "../components/HeaderButtonWithText";
|
||||
import ReactSwitch from "react-switch";
|
||||
import { usePostHog } from "posthog-js/react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { RootStore } from "../redux/store";
|
||||
|
|
@ -589,7 +590,16 @@ If you already have an LLM deployed on your own infrastructure, or would like to
|
|||
}}
|
||||
text="Clear"
|
||||
>
|
||||
<TrashIcon width="1.4em" height="1.4em" />
|
||||
<PlusCircleIcon width="1.4em" height="1.4em" />
|
||||
</HeaderButtonWithText>
|
||||
<HeaderButtonWithText
|
||||
onClick={() => {
|
||||
// Go to /history page
|
||||
document.location.href = "/history";
|
||||
}}
|
||||
text="History"
|
||||
>
|
||||
<FolderIcon width="1.4em" height="1.4em" />
|
||||
</HeaderButtonWithText>
|
||||
<a
|
||||
href="https://continue.dev/docs/how-to-use-continue"
|
||||
|
|
|
|||
55
extension/react-app/src/pages/history.tsx
Normal file
55
extension/react-app/src/pages/history.tsx
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import React, { useContext, useEffect, useState } from "react";
|
||||
import { SessionInfo } from "../../../schema/SessionInfo";
|
||||
import { GUIClientContext } from "../App";
|
||||
import fetch from "node-fetch";
|
||||
import { useSelector } from "react-redux";
|
||||
import { RootStore } from "../redux/store";
|
||||
|
||||
function History() {
|
||||
const [sessions, setSessions] = useState<SessionInfo[]>([]);
|
||||
const client = useContext(GUIClientContext);
|
||||
const apiUrl = useSelector((state: RootStore) => state.config.apiUrl);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchSessions = async () => {
|
||||
console.log("fetching sessions");
|
||||
if (!apiUrl) {
|
||||
return;
|
||||
}
|
||||
const response = await fetch(`${apiUrl}/sessions/list`);
|
||||
const json = await response.json();
|
||||
console.log(json);
|
||||
setSessions(json);
|
||||
};
|
||||
fetchSessions();
|
||||
}, [client]);
|
||||
|
||||
return (
|
||||
<div style={{ width: "100%" }}>
|
||||
<table style={{ width: "100%" }}>
|
||||
<tbody>
|
||||
{sessions.map((session, index) => (
|
||||
<tr key={index}>
|
||||
<td>
|
||||
<div
|
||||
style={{ cursor: "pointer" }}
|
||||
onClick={() => {
|
||||
// client?.loadSession(session.id);
|
||||
// document.location.href = "/gui";
|
||||
}}
|
||||
>
|
||||
<div>{session.title}</div>
|
||||
<div style={{ color: "lightgray" }}>
|
||||
{session.date_created}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default History;
|
||||
2
extension/schema/FullState.d.ts
vendored
2
extension/schema/FullState.d.ts
vendored
|
|
@ -26,7 +26,6 @@ export type Timeline = HistoryNode[];
|
|||
export type CurrentIndex = number;
|
||||
export type Active1 = boolean;
|
||||
export type UserInputQueue = string[];
|
||||
export type DefaultModel = string;
|
||||
export type Name3 = string;
|
||||
export type Description1 = string;
|
||||
export type SlashCommands = SlashCommandDescription[];
|
||||
|
|
@ -47,7 +46,6 @@ export interface FullState1 {
|
|||
history: History;
|
||||
active: Active1;
|
||||
user_input_queue: UserInputQueue;
|
||||
default_model: DefaultModel;
|
||||
slash_commands: SlashCommands;
|
||||
adding_highlighted_code: AddingHighlightedCode;
|
||||
selected_context_items: SelectedContextItems;
|
||||
|
|
|
|||
18
extension/schema/SessionInfo.d.ts
vendored
Normal file
18
extension/schema/SessionInfo.d.ts
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* eslint-disable */
|
||||
/**
|
||||
* This file was automatically generated by json-schema-to-typescript.
|
||||
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
||||
* and run json-schema-to-typescript to regenerate this file.
|
||||
*/
|
||||
|
||||
export type SessionInfo = SessionInfo1;
|
||||
export type SessionId = string;
|
||||
export type Title = string;
|
||||
export type DateCreated = string;
|
||||
|
||||
export interface SessionInfo1 {
|
||||
session_id: SessionId;
|
||||
title: Title;
|
||||
date_created: DateCreated;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
|
|
@ -264,10 +264,6 @@
|
|||
"type": "string"
|
||||
}
|
||||
},
|
||||
"default_model": {
|
||||
"title": "Default Model",
|
||||
"type": "string"
|
||||
},
|
||||
"slash_commands": {
|
||||
"title": "Slash Commands",
|
||||
"type": "array",
|
||||
|
|
@ -291,7 +287,6 @@
|
|||
"history",
|
||||
"active",
|
||||
"user_input_queue",
|
||||
"default_model",
|
||||
"slash_commands",
|
||||
"adding_highlighted_code",
|
||||
"selected_context_items"
|
||||
|
|
|
|||
29
schema/json/SessionInfo.json
Normal file
29
schema/json/SessionInfo.json
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"title": "SessionInfo",
|
||||
"$ref": "#/definitions/src__continuedev__core__main__SessionInfo",
|
||||
"definitions": {
|
||||
"src__continuedev__core__main__SessionInfo": {
|
||||
"title": "SessionInfo",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"session_id": {
|
||||
"title": "Session Id",
|
||||
"type": "string"
|
||||
},
|
||||
"title": {
|
||||
"title": "Title",
|
||||
"type": "string"
|
||||
},
|
||||
"date_created": {
|
||||
"title": "Date Created",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"session_id",
|
||||
"title",
|
||||
"date_created"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue