From 9cac985ce31517b6bd6d9139415d16e811d256d6 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 16 Oct 2024 18:49:03 +0700 Subject: [PATCH 1/5] improv: history ui --- gui/src/components/History.tsx | 365 ------------------ .../components/History/HistoryTableRow.tsx | 128 ++++++ gui/src/components/History/index.tsx | 192 +++++++++ gui/tailwind.config.cjs | 19 + 4 files changed, 339 insertions(+), 365 deletions(-) delete mode 100644 gui/src/components/History.tsx create mode 100644 gui/src/components/History/HistoryTableRow.tsx create mode 100644 gui/src/components/History/index.tsx diff --git a/gui/src/components/History.tsx b/gui/src/components/History.tsx deleted file mode 100644 index b930d304e..000000000 --- a/gui/src/components/History.tsx +++ /dev/null @@ -1,365 +0,0 @@ -import { PencilSquareIcon, TrashIcon } from "@heroicons/react/24/outline"; -import { SessionInfo } from "core"; -import MiniSearch from "minisearch"; -import React, { Fragment, useEffect, useState } from "react"; -import { useDispatch } from "react-redux"; -import { useNavigate } from "react-router-dom"; -import styled from "styled-components"; -import { - defaultBorderRadius, - Input, - vscBadgeBackground, - vscForeground, - vscInputBackground, -} from "."; -import ButtonWithTooltip from "./ButtonWithTooltip"; -import useHistory from "../hooks/useHistory"; -import { getFontSize } from "../util"; - -const SearchBarContainer = styled.div` - display: flex; - max-width: 500px; - padding: 0 8px 0 8px; - margin: 0 auto; - align-items: center; - justify-content: center; -`; - -const SearchBar = styled.input` - padding: 4px 8px; - border-radius: ${defaultBorderRadius}; - border: 0.5px solid #888; - outline: none; - margin: 8px auto; - display: block; - background-color: ${vscInputBackground}; - color: ${vscForeground}; - &:focus { - border: 0.5px solid ${vscBadgeBackground}; - outline: none; - } -`; - -const Tr = styled.tr` - &:hover { - background-color: ${vscInputBackground}; - } - - overflow-wrap: anywhere; - - border-bottom: 1px solid ${vscInputBackground}; - border-top: 1px solid ${vscInputBackground}; -`; - -const parseDate = (date: string): Date => { - let dateObj = new Date(date); - if (isNaN(dateObj.getTime())) { - dateObj = new Date(parseInt(date)); - } - return dateObj; -}; - -const SectionHeader = styled.tr` - display: flex; - user-select: none; - padding: 4px; - background-color: ${vscInputBackground}; - width: calc(100% - 8px); - font-weight: bold; - text-align: center; - align-items: center; - justify-content: center; - margin: 0; - position: sticky; - height: 1.5em; -`; - -function TableRow({ - session, - date, - onDelete, -}: { - session: SessionInfo; - date: Date; - onDelete: (sessionId: string) => void; -}) { - const dispatch = useDispatch(); - const navigate = useNavigate(); - const apiUrl = window.serverUrl; - const workspacePaths = window.workspacePaths || [""]; - const [hovered, setHovered] = useState(false); - const [editing, setEditing] = useState(false); - const [sessionTitleEditValue, setSessionTitleEditValue] = useState( - session.title, - ); - - const { saveSession, deleteSession, loadSession, getSession, updateSession } = - useHistory(dispatch); - - const handleKeyUp = async (e: React.KeyboardEvent) => { - if (e.key === "Enter") { - if (sessionTitleEditValue !== session.title) { - session.title = sessionTitleEditValue; - const persistedSessionInfo = await getSession(session.sessionId); - persistedSessionInfo.title = sessionTitleEditValue; - await updateSession(persistedSessionInfo); - setEditing(false); - } - } else if (e.key === "Escape") { - setEditing(false); - setSessionTitleEditValue(session.title); - } - }; - - return ( - setHovered(true)} - onMouseLeave={() => setHovered(false)} - > -
{ - // Save current session - saveSession(); - await loadSession(session.sessionId); - navigate("/"); - }} - > -
- {editing ? ( -
- titleInput && titleInput.focus()} - value={sessionTitleEditValue} - onChange={(e) => setSessionTitleEditValue(e.target.value)} - onKeyUp={(e) => handleKeyUp(e)} - onBlur={() => setEditing(false)} - /> -
- ) : ( - - {JSON.stringify(session.title).slice(1, -1)} - - )} - -
- {lastPartOfPath(session.workspaceDirectory || "")} - {!hovered && ( - - {date.toLocaleString("en-US", { - year: "2-digit", - month: "2-digit", - day: "2-digit", - hour: "numeric", - minute: "2-digit", - hour12: true, - })} - - )} -
-
- - {hovered && ( -
- { - e.stopPropagation(); - setEditing(true); - }} - > - - - { - deleteSession(session.sessionId); - onDelete(session.sessionId); - }} - > - - -
- )} -
- - ); -} - -function lastPartOfPath(path: string): string { - const sep = path.includes("/") ? "/" : "\\"; - return path.split(sep).pop() || path; -} - -export function History() { - const [sessions, setSessions] = useState([]); - const [filteredAndSortedSessions, setFilteredAndSortedSessions] = useState< - SessionInfo[] - >([]); - const apiUrl = window.serverUrl; - const workspacePaths = window.workspacePaths || []; - - const deleteSessionInUI = async (sessionId: string) => { - setSessions((prev) => - prev.filter((session) => session.sessionId !== sessionId), - ); - }; - - const searchInputRef = React.useRef(null); - - const dispatch = useDispatch(); - const { getHistory, lastSessionId } = useHistory(dispatch); - - const [minisearch, setMinisearch] = useState< - MiniSearch<{ title: string; sessionId: string }> - >( - new MiniSearch({ - fields: ["title"], - storeFields: ["title", "sessionId", "id"], - }), - ); - const [searchTerm, setSearchTerm] = useState(""); - - useEffect(() => { - const fetchSessions = async () => { - const sessions = await getHistory(); - setSessions(sessions); - minisearch.addAll( - sessions.map((session) => ({ - title: session.title, - sessionId: session.sessionId, - id: session.sessionId, - })), - ); - }; - fetchSessions(); - }, [lastSessionId]); - - useEffect(() => { - // When searchTerm is empty only show sessions from the current workspace - let filteringByWorkspace = searchTerm === ""; - - // When the searchTerm is wildcard (asterisk) then show ALL sessions, otherwise use minisearch to search for user input - const sessionIds = minisearch - .search(searchTerm === "*" ? "" : searchTerm, { - fuzzy: 0.1, - }) - .map((result) => result.id); - - setFilteredAndSortedSessions( - sessions - .filter((session) => { - if ( - !filteringByWorkspace || - typeof workspacePaths === "undefined" || - typeof session.workspaceDirectory === "undefined" - ) { - return true; - } - return workspacePaths.includes(session.workspaceDirectory); - }) - // Filter by search term - .filter((session) => { - return ( - searchTerm === "*" || - filteringByWorkspace || - sessionIds.includes(session.sessionId) - ); - }) - .sort( - (a, b) => - parseDate(b.dateCreated).getTime() - - parseDate(a.dateCreated).getTime(), - ), - ); - }, [sessions, searchTerm, minisearch]); - - const yesterday = new Date(Date.now() - 1000 * 60 * 60 * 24); - const lastWeek = new Date(Date.now() - 1000 * 60 * 60 * 24 * 7); - const lastMonth = new Date(Date.now() - 1000 * 60 * 60 * 24 * 30); - const earlier = new Date(0); - - return ( -
- - setSearchTerm(e.target.value)} - /> - { - if (searchInputRef.current.value === "") { - searchInputRef.current.value = "*"; - setSearchTerm("*"); - } else { - searchInputRef.current.value = ""; - setSearchTerm(""); - } - }} - > - {searchTerm === "" ? "Show All" : "Clear"} - - - - {filteredAndSortedSessions.length === 0 && ( -
- No past sessions found. To start a new session, either click the "+" - button or use the keyboard shortcut: Option + Command + N -
- )} - - - - {filteredAndSortedSessions.map((session, index) => { - const prevDate = - index > 0 - ? parseDate(filteredAndSortedSessions[index - 1].dateCreated) - : earlier; - const date = parseDate(session.dateCreated); - return ( - - {index === 0 && date > yesterday && ( - Today - )} - {date < yesterday && - date > lastWeek && - prevDate > yesterday && ( - This Week - )} - {date < lastWeek && date > lastMonth && prevDate > lastWeek && ( - This Month - )} - {date < lastMonth && prevDate > lastMonth && ( - Older - )} - - - deleteSessionInUI(session.sessionId)} - > - - - ); - })} - -
-
- - All session data is saved in ~/.continue/sessions - -
- ); -} diff --git a/gui/src/components/History/HistoryTableRow.tsx b/gui/src/components/History/HistoryTableRow.tsx new file mode 100644 index 000000000..124f6249a --- /dev/null +++ b/gui/src/components/History/HistoryTableRow.tsx @@ -0,0 +1,128 @@ +import { PencilSquareIcon, TrashIcon } from "@heroicons/react/24/outline"; +import { SessionInfo } from "core"; +import React, { useState } from "react"; +import { useDispatch } from "react-redux"; +import { useNavigate } from "react-router-dom"; +import { Input } from ".."; +import ButtonWithTooltip from "../ButtonWithTooltip"; +import useHistory from "../../hooks/useHistory"; + +function lastPartOfPath(path: string): string { + const sep = path.includes("/") ? "/" : "\\"; + return path.split(sep).pop() || path; +} + +export function HistoryTableRow({ + session, + date, + onDelete, +}: { + session: SessionInfo; + date: Date; + onDelete: (sessionId: string) => void; +}) { + const dispatch = useDispatch(); + const navigate = useNavigate(); + + const [hovered, setHovered] = useState(false); + const [editing, setEditing] = useState(false); + const [sessionTitleEditValue, setSessionTitleEditValue] = useState( + session.title, + ); + + const { saveSession, deleteSession, loadSession, getSession, updateSession } = + useHistory(dispatch); + + const handleKeyUp = async (e: React.KeyboardEvent) => { + if (e.key === "Enter") { + if (sessionTitleEditValue !== session.title) { + session.title = sessionTitleEditValue; + const persistedSessionInfo = await getSession(session.sessionId); + persistedSessionInfo.title = sessionTitleEditValue; + await updateSession(persistedSessionInfo); + } + setEditing(false); + } else if (e.key === "Escape") { + setEditing(false); + setSessionTitleEditValue(session.title); + } + }; + + return ( + + setHovered(true)} + onMouseLeave={() => setHovered(false)} + > +
{ + // Save current session + saveSession(); + await loadSession(session.sessionId); + navigate("/"); + }} + > +
+ {editing ? ( +
+ titleInput && titleInput.focus()} + value={sessionTitleEditValue} + onChange={(e) => setSessionTitleEditValue(e.target.value)} + onKeyUp={(e) => handleKeyUp(e)} + onBlur={() => setEditing(false)} + /> +
+ ) : ( + + {JSON.stringify(session.title).slice(1, -1)} + + )} + +
+ {lastPartOfPath(session.workspaceDirectory || "")} + {/* Uncomment to show the date */} + {/* + {date.toLocaleString("en-US", { + year: "2-digit", + month: "2-digit", + day: "2-digit", + hour: "numeric", + minute: "2-digit", + hour12: true, + })} + */} +
+
+ + {hovered && !editing && ( +
+ { + e.stopPropagation(); + setEditing(true); + }} + > + + + { + deleteSession(session.sessionId); + onDelete(session.sessionId); + }} + > + + +
+ )} +
+ + + ); +} diff --git a/gui/src/components/History/index.tsx b/gui/src/components/History/index.tsx new file mode 100644 index 000000000..26da632e5 --- /dev/null +++ b/gui/src/components/History/index.tsx @@ -0,0 +1,192 @@ +import { SessionInfo } from "core"; +import MiniSearch from "minisearch"; +import React, { Fragment, useEffect, useState } from "react"; +import { useDispatch } from "react-redux"; +import { + vscBadgeBackground, + vscButtonBackground, + vscButtonForeground, + vscEditorBackground, + vscForeground, + vscInputBackground, + vscInputBorder, +} from ".."; +import useHistory from "../../hooks/useHistory"; +import { getFontSize } from "../../util"; +import { HistoryTableRow } from "./HistoryTableRow"; + +const parseDate = (date: string): Date => { + let dateObj = new Date(date); + if (isNaN(dateObj.getTime())) { + dateObj = new Date(parseInt(date)); + } + return dateObj; +}; + +const HEADER_CLASS = + "flex user-select-none pt-2 pb-3 opacity-75 text-center font-bold items-center justify-center sticky h-6"; + +export function History() { + const [sessions, setSessions] = useState([]); + const [filteredAndSortedSessions, setFilteredAndSortedSessions] = useState< + SessionInfo[] + >([]); + const apiUrl = window.serverUrl; + const workspacePaths = window.workspacePaths || []; + + const deleteSessionInUI = async (sessionId: string) => { + setSessions((prev) => + prev.filter((session) => session.sessionId !== sessionId), + ); + }; + + const searchInputRef = React.useRef(null); + + const dispatch = useDispatch(); + const { getHistory, lastSessionId } = useHistory(dispatch); + + const [minisearch, setMinisearch] = useState< + MiniSearch<{ title: string; sessionId: string }> + >( + new MiniSearch({ + fields: ["title"], + storeFields: ["title", "sessionId", "id"], + }), + ); + const [searchTerm, setSearchTerm] = useState(""); + + useEffect(() => { + const fetchSessions = async () => { + const sessions = await getHistory(); + setSessions(sessions); + minisearch.addAll( + sessions.map((session) => ({ + title: session.title, + sessionId: session.sessionId, + id: session.sessionId, + })), + ); + }; + fetchSessions(); + }, [lastSessionId]); + + useEffect(() => { + // When searchTerm is empty only show sessions from the current workspace + let filteringByWorkspace = searchTerm === ""; + + // When the searchTerm is wildcard (asterisk) then show ALL sessions, otherwise use minisearch to search for user input + const sessionIds = minisearch + .search(searchTerm === "*" ? "" : searchTerm, { + fuzzy: 0.1, + }) + .map((result) => result.id); + + setFilteredAndSortedSessions( + sessions + .filter((session) => { + if ( + !filteringByWorkspace || + typeof workspacePaths === "undefined" || + typeof session.workspaceDirectory === "undefined" + ) { + return true; + } + return workspacePaths.includes(session.workspaceDirectory); + }) + // Filter by search term + .filter((session) => { + return ( + searchTerm === "*" || + filteringByWorkspace || + sessionIds.includes(session.sessionId) + ); + }) + .sort( + (a, b) => + parseDate(b.dateCreated).getTime() - + parseDate(a.dateCreated).getTime(), + ), + ); + }, [sessions, searchTerm, minisearch]); + + const yesterday = new Date(Date.now() - 1000 * 60 * 60 * 24); + const lastWeek = new Date(Date.now() - 1000 * 60 * 60 * 24 * 7); + const lastMonth = new Date(Date.now() - 1000 * 60 * 60 * 24 * 30); + const earlier = new Date(0); + + return ( +
+
+ setSearchTerm(e.target.value)} + /> + { + if (searchInputRef.current.value === "") { + searchInputRef.current.value = "*"; + setSearchTerm("*"); + } else { + searchInputRef.current.value = ""; + setSearchTerm(""); + } + }} + > + {searchTerm === "" ? "Show All" : "Clear"} + +
+ + {filteredAndSortedSessions.length === 0 && ( +
+ No past sessions found. To start a new session, either click the "+" + button or use the keyboard shortcut: Option + Command + N +
+ )} + + + + {filteredAndSortedSessions.map((session, index) => { + const prevDate = + index > 0 + ? parseDate(filteredAndSortedSessions[index - 1].dateCreated) + : earlier; + const date = parseDate(session.dateCreated); + return ( + + {index === 0 && date > yesterday && ( + Today + )} + {date < yesterday && + date > lastWeek && + prevDate > yesterday && ( + This Week + )} + {date < lastWeek && date > lastMonth && prevDate > lastWeek && ( + This Month + )} + {date < lastMonth && prevDate > lastMonth && ( + Older + )} + + deleteSessionInUI(session.sessionId)} + /> + + ); + })} + +
+
+ + All session data is saved in ~/.continue/sessions + +
+ ); +} diff --git a/gui/tailwind.config.cjs b/gui/tailwind.config.cjs index 49d569e78..75dacf2c0 100644 --- a/gui/tailwind.config.cjs +++ b/gui/tailwind.config.cjs @@ -27,6 +27,25 @@ module.exports = { colors: { "vsc-background": "rgb(var(--vsc-background) / )", "secondary-dark": "rgb(var(--secondary-dark) / )", + "vsc-input-background": "var(--vscode-input-background, rgb(45 45 45))", + "vsc-quick-input-background": + "var(--vscode-quickInput-background, var(--vscode-input-background, rgb(45 45 45)))", + "vsc-background": "var(--vscode-sideBar-background, rgb(30 30 30))", + "vsc-foreground": "var(--vscode-editor-foreground, #fff)", + "vsc-button-background": "var(--vscode-button-background, #1bbe84)", + "vsc-button-foreground": "var(--vscode-button-foreground, #ffffff)", + "vsc-editor-background": + "var(--vscode-editor-background, var(--vscode-sideBar-background, rgb(30 30 30)))", + "vsc-list-active-background": + "var(--vscode-list-activeSelectionBackground, #1bbe84)", + "vsc-focus-border": "var(--vscode-focus-border, #1bbe84)", + "vsc-list-active-foreground": + "var(--vscode-quickInputList-focusForeground, var(--vscode-editor-foreground))", + "vsc-input-border": "var(--vscode-input-border, #999998)", + "vsc-input-border-focus": "var(--vscode-focusBorder, #999998)", + "vsc-badge-background": "var(--vscode-badge-background, #1bbe84)", + "vsc-badge-foreground": "var(--vscode-badge-foreground, #fff)", + "vsc-sidebar-border": "var(--vscode-sideBar-border, transparent)", }, }, }, From 75b8293957a5a047c16f99d586f8c276025df76e Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 16 Oct 2024 15:27:14 -0700 Subject: [PATCH 2/5] fix type error --- core/package-lock.json | 20 ++++++++++++++++++++ core/package.json | 1 + extensions/vscode/package-lock.json | 6 ++++-- gui/package-lock.json | 2 ++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index 7e5d49778..ade0b719d 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -82,6 +82,7 @@ "@types/node-fetch": "^2.6.11", "@types/pg": "^8.11.6", "@types/request": "^2.48.12", + "@types/tar": "^6.1.13", "@types/uuid": "^9.0.7", "@types/win-ca": "^3.5.4", "cross-env": "^7.0.3", @@ -5121,6 +5122,25 @@ "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==", "dev": true }, + "node_modules/@types/tar": { + "version": "6.1.13", + "resolved": "https://registry.npmjs.org/@types/tar/-/tar-6.1.13.tgz", + "integrity": "sha512-IznnlmU5f4WcGTh2ltRu/Ijpmk8wiWXfF0VA4s+HPjHZgvFggk1YaIkbo5krX/zUCzWF8N/l4+W/LNxnvAJ8nw==", + "dev": true, + "dependencies": { + "@types/node": "*", + "minipass": "^4.0.0" + } + }, + "node_modules/@types/tar/node_modules/minipass": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz", + "integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/@types/tough-cookie": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz", diff --git a/core/package.json b/core/package.json index 678a65572..951f84856 100644 --- a/core/package.json +++ b/core/package.json @@ -25,6 +25,7 @@ "@types/node-fetch": "^2.6.11", "@types/pg": "^8.11.6", "@types/request": "^2.48.12", + "@types/tar": "^6.1.13", "@types/uuid": "^9.0.7", "@types/win-ca": "^3.5.4", "cross-env": "^7.0.3", diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 36f98bcf5..8bb6aa229 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.216", + "version": "0.9.217", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.216", + "version": "0.9.217", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", @@ -144,6 +144,7 @@ "sqlite": "^5.1.1", "sqlite3": "^5.1.7", "system-ca": "^1.0.3", + "tar": "^7.4.3", "tree-sitter-wasms": "^0.1.11", "uuid": "^9.0.1", "vectordb": "^0.4.20", @@ -167,6 +168,7 @@ "@types/node-fetch": "^2.6.11", "@types/pg": "^8.11.6", "@types/request": "^2.48.12", + "@types/tar": "^6.1.13", "@types/uuid": "^9.0.7", "@types/win-ca": "^3.5.4", "cross-env": "^7.0.3", diff --git a/gui/package-lock.json b/gui/package-lock.json index 9c10b7f68..ff7fe9945 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -137,6 +137,7 @@ "sqlite": "^5.1.1", "sqlite3": "^5.1.7", "system-ca": "^1.0.3", + "tar": "^7.4.3", "tree-sitter-wasms": "^0.1.11", "uuid": "^9.0.1", "vectordb": "^0.4.20", @@ -160,6 +161,7 @@ "@types/node-fetch": "^2.6.11", "@types/pg": "^8.11.6", "@types/request": "^2.48.12", + "@types/tar": "^6.1.13", "@types/uuid": "^9.0.7", "@types/win-ca": "^3.5.4", "cross-env": "^7.0.3", From e8db9309d2f035519f836dd8aeb374c0f5ebed9b Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 17 Oct 2024 20:49:44 +0700 Subject: [PATCH 3/5] improv: history ui --- extensions/vscode/package.json | 11 --- extensions/vscode/src/commands.ts | 34 +-------- gui/src/components/History/index.tsx | 108 +++++++++------------------ gui/src/pages/gui/index.tsx | 12 +-- 4 files changed, 43 insertions(+), 122 deletions(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index bd74f59fc..e25c050b3 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -189,12 +189,6 @@ "icon": "$(fullscreen)", "group": "Continue" }, - { - "command": "continue.toggleNewWindow", - "category": "Continue", - "title": "Open New Window", - "icon": "$(link-external)" - }, { "command": "continue.openConfigJson", "category": "Continue", @@ -458,11 +452,6 @@ "command": "continue.toggleFullScreen", "group": "navigation@3", "when": "view == continue.continueGUIView" - }, - { - "command": "continue.toggleNewWindow", - "group": "navigation@4", - "when": "view == continue.continueGUIView" } ], "editor/title": [ diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 36245b6ab..babc695e3 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -483,21 +483,12 @@ const commandsMap: ( "continue.applyCodeFromChat": () => { sidebar.webviewProtocol.request("applyCodeFromChat", undefined); }, - "continue.toggleFullScreen": ({ - newWindow, - }: { newWindow?: boolean } = {}) => { + "continue.toggleFullScreen": () => { focusGUI(); // Check if full screen is already open by checking open tabs const fullScreenTab = getFullScreenTab(); - // Check if the active editor is the Continue GUI View - if (fullScreenTab && fullScreenTab.isActive) { - //Full screen open and focused - close it - vscode.commands.executeCommand("workbench.action.closeActiveEditor"); //this will trigger the onDidDispose listener below - return; - } - if (fullScreenTab && fullScreenPanel) { //Full screen open, but not focused - focus it fullScreenPanel.reveal(); @@ -537,17 +528,7 @@ const commandsMap: ( extensionContext.subscriptions, ); - if (newWindow) { - vscode.commands.executeCommand( - "workbench.action.copyEditorToNewWindow", - ); - } - }, - "continue.toggleNewWindow": () => { - focusGUI(); - vscode.commands.executeCommand("continue.toggleFullScreen", { - newWindow: true, - }); + vscode.commands.executeCommand("workbench.action.copyEditorToNewWindow"); }, "continue.openConfigJson": () => { ide.openFile(getConfigJsonPath()); @@ -651,8 +632,8 @@ const commandsMap: ( currentStatus === StatusBarStatus.Paused ? StatusBarStatus.Enabled : currentStatus === StatusBarStatus.Disabled - ? StatusBarStatus.Paused - : StatusBarStatus.Disabled; + ? StatusBarStatus.Paused + : StatusBarStatus.Disabled; } else { // Toggle between Disabled and Enabled targetStatus = @@ -670,9 +651,6 @@ const commandsMap: ( { label: "$(screen-full) Open full screen chat (Cmd+K Cmd+M)", }, - { - label: "$(link-external) Open chat in a new window", - }, { label: quickPickStatusText(targetStatus), }, @@ -724,10 +702,6 @@ const commandsMap: ( "$(screen-full) Open full screen chat (Cmd+K Cmd+M)" ) { vscode.commands.executeCommand("continue.toggleFullScreen"); - } else if ( - selectedOption === "$(link-external) Open chat in a new window" - ) { - vscode.commands.executeCommand("continue.toggleNewWindow"); } else if (selectedOption === "$(question) Open help center") { focusGUI(); vscode.commands.executeCommand("continue.navigateTo", "/more"); diff --git a/gui/src/components/History/index.tsx b/gui/src/components/History/index.tsx index 26da632e5..7ed525626 100644 --- a/gui/src/components/History/index.tsx +++ b/gui/src/components/History/index.tsx @@ -1,19 +1,12 @@ import { SessionInfo } from "core"; import MiniSearch from "minisearch"; -import React, { Fragment, useEffect, useState } from "react"; +import React, { Fragment, useEffect, useMemo, useState } from "react"; import { useDispatch } from "react-redux"; -import { - vscBadgeBackground, - vscButtonBackground, - vscButtonForeground, - vscEditorBackground, - vscForeground, - vscInputBackground, - vscInputBorder, -} from ".."; + import useHistory from "../../hooks/useHistory"; import { getFontSize } from "../../util"; import { HistoryTableRow } from "./HistoryTableRow"; +import { XMarkIcon } from "@heroicons/react/24/solid"; const parseDate = (date: string): Date => { let dateObj = new Date(date); @@ -28,11 +21,6 @@ const HEADER_CLASS = export function History() { const [sessions, setSessions] = useState([]); - const [filteredAndSortedSessions, setFilteredAndSortedSessions] = useState< - SessionInfo[] - >([]); - const apiUrl = window.serverUrl; - const workspacePaths = window.workspacePaths || []; const deleteSessionInUI = async (sessionId: string) => { setSessions((prev) => @@ -45,15 +33,14 @@ export function History() { const dispatch = useDispatch(); const { getHistory, lastSessionId } = useHistory(dispatch); - const [minisearch, setMinisearch] = useState< - MiniSearch<{ title: string; sessionId: string }> - >( - new MiniSearch({ + const [searchTerm, setSearchTerm] = useState(""); + + const minisearch = useMemo(() => { + return new MiniSearch({ fields: ["title"], storeFields: ["title", "sessionId", "id"], - }), - ); - const [searchTerm, setSearchTerm] = useState(""); + }); + }, []); useEffect(() => { const fetchSessions = async () => { @@ -70,43 +57,22 @@ export function History() { fetchSessions(); }, [lastSessionId]); - useEffect(() => { - // When searchTerm is empty only show sessions from the current workspace - let filteringByWorkspace = searchTerm === ""; - - // When the searchTerm is wildcard (asterisk) then show ALL sessions, otherwise use minisearch to search for user input + const filteredAndSortedSessions: SessionInfo[] = useMemo(() => { const sessionIds = minisearch - .search(searchTerm === "*" ? "" : searchTerm, { + .search(searchTerm, { fuzzy: 0.1, }) .map((result) => result.id); - setFilteredAndSortedSessions( - sessions - .filter((session) => { - if ( - !filteringByWorkspace || - typeof workspacePaths === "undefined" || - typeof session.workspaceDirectory === "undefined" - ) { - return true; - } - return workspacePaths.includes(session.workspaceDirectory); - }) - // Filter by search term - .filter((session) => { - return ( - searchTerm === "*" || - filteringByWorkspace || - sessionIds.includes(session.sessionId) - ); - }) - .sort( - (a, b) => - parseDate(b.dateCreated).getTime() - - parseDate(a.dateCreated).getTime(), - ), - ); + return sessions + .filter((session) => { + return searchTerm === "" || sessionIds.includes(session.sessionId); + }) + .sort( + (a, b) => + parseDate(b.dateCreated).getTime() - + parseDate(a.dateCreated).getTime(), + ); }, [sessions, searchTerm, minisearch]); const yesterday = new Date(Date.now() - 1000 * 60 * 60 * 24); @@ -116,38 +82,36 @@ export function History() { return (
-
+
setSearchTerm(e.target.value)} /> - { - if (searchInputRef.current.value === "") { - searchInputRef.current.value = "*"; - setSearchTerm("*"); - } else { - searchInputRef.current.value = ""; + {searchTerm && ( + { setSearchTerm(""); - } - }} - > - {searchTerm === "" ? "Show All" : "Clear"} - + if (searchInputRef.current) { + searchInputRef.current.focus(); + } + }} + /> + )}
{filteredAndSortedSessions.length === 0 && ( -
+
No past sessions found. To start a new session, either click the "+" button or use the keyboard shortcut: Option + Command + N
)} - +
{filteredAndSortedSessions.map((session, index) => { const prevDate = @@ -184,7 +148,7 @@ export function History() {

- + All session data is saved in ~/.continue/sessions
diff --git a/gui/src/pages/gui/index.tsx b/gui/src/pages/gui/index.tsx index 53e184027..2f37027ee 100644 --- a/gui/src/pages/gui/index.tsx +++ b/gui/src/pages/gui/index.tsx @@ -1,20 +1,14 @@ import { Chat } from "./Chat"; import { History } from "../../components/History"; -import styled from "styled-components"; -import { vscSidebarBorder } from "../../components"; - -export const Aside = styled.aside` - border-right: 1px solid ${vscSidebarBorder}; -`; export default function GUI() { return (
- -
+
From 0a49200cd135cf8cddda2e915fa8913015e5722c Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 17 Oct 2024 21:25:48 -0700 Subject: [PATCH 4/5] update z-index of history header --- gui/src/pages/history/HistoryHeader.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/src/pages/history/HistoryHeader.tsx b/gui/src/pages/history/HistoryHeader.tsx index ec64c1377..9f7af691e 100644 --- a/gui/src/pages/history/HistoryHeader.tsx +++ b/gui/src/pages/history/HistoryHeader.tsx @@ -1,7 +1,7 @@ +import { ArrowLeftIcon } from "@heroicons/react/24/outline"; import { useNavigate } from "react-router-dom"; import { lightGray, vscBackground } from "../../components"; import { useNavigationListener } from "../../hooks/useNavigationListener"; -import { ArrowLeftIcon } from "@heroicons/react/24/outline"; import { getFontSize } from "../../util"; export const HistoryHeader = () => { @@ -10,7 +10,7 @@ export const HistoryHeader = () => { return (
Date: Thu, 17 Oct 2024 21:28:49 -0700 Subject: [PATCH 5/5] minimal addition of y padding to pill in history row --- gui/src/components/History/HistoryTableRow.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gui/src/components/History/HistoryTableRow.tsx b/gui/src/components/History/HistoryTableRow.tsx index 124f6249a..ca140c8ab 100644 --- a/gui/src/components/History/HistoryTableRow.tsx +++ b/gui/src/components/History/HistoryTableRow.tsx @@ -4,8 +4,8 @@ import React, { useState } from "react"; import { useDispatch } from "react-redux"; import { useNavigate } from "react-router-dom"; import { Input } from ".."; -import ButtonWithTooltip from "../ButtonWithTooltip"; import useHistory from "../../hooks/useHistory"; +import ButtonWithTooltip from "../ButtonWithTooltip"; function lastPartOfPath(path: string): string { const sep = path.includes("/") ? "/" : "\\"; @@ -56,7 +56,7 @@ export function HistoryTableRow({ onMouseLeave={() => setHovered(false)} >
{ // Save current session saveSession(); @@ -64,7 +64,7 @@ export function HistoryTableRow({ navigate("/"); }} > -
+
{editing ? (
) : ( - + {JSON.stringify(session.title).slice(1, -1)} )} @@ -100,7 +100,7 @@ export function HistoryTableRow({
{hovered && !editing && ( -
+
{