diff --git a/gui/src/pages/history.tsx b/gui/src/components/History.tsx similarity index 51% rename from gui/src/pages/history.tsx rename to gui/src/components/History.tsx index 2bfa45355..937064304 100644 --- a/gui/src/pages/history.tsx +++ b/gui/src/components/History.tsx @@ -1,8 +1,4 @@ -import { - ArrowLeftIcon, - PencilSquareIcon, - TrashIcon, -} from "@heroicons/react/24/outline"; +import { PencilSquareIcon, TrashIcon } from "@heroicons/react/24/outline"; import { SessionInfo } from "core"; import MiniSearch from "minisearch"; import React, { Fragment, useEffect, useState } from "react"; @@ -12,16 +8,12 @@ import styled from "styled-components"; import { defaultBorderRadius, Input, - lightGray, - vscBackground, vscBadgeBackground, vscForeground, vscInputBackground, -} from "../components"; -import ButtonWithTooltip from "../components/ButtonWithTooltip"; +} from "."; +import ButtonWithTooltip from "./ButtonWithTooltip"; import useHistory from "../hooks/useHistory"; -import { useNavigationListener } from "../hooks/useNavigationListener"; -import { getFontSize } from "../util"; const SearchBarContainer = styled.div` display: flex; @@ -71,7 +63,7 @@ const SectionHeader = styled.tr` user-select: none; padding: 4px; background-color: ${vscInputBackground}; - width: 100%; + width: calc(100% - 8px); font-weight: bold; text-align: center; align-items: center; @@ -81,15 +73,6 @@ const SectionHeader = styled.tr` height: 1.5em; `; -const TdDiv = styled.div` - cursor: pointer; - flex-grow: 1; - padding-left: 1rem; - padding-right: 1rem; - padding-top: 0.5rem; - padding-bottom: 0.5rem; -`; - function TableRow({ session, date, @@ -132,17 +115,18 @@ function TableRow({ onMouseEnter={() => setHovered(true)} onMouseLeave={() => setHovered(false)} > -
- { - // Save current session - saveSession(); - await loadSession(session.sessionId); - navigate("/"); - }} - > -
- {editing ? ( +
{ + // Save current session + saveSession(); + await loadSession(session.sessionId); + navigate("/"); + }} + > +
+ {editing ? ( +
handleKeyUp(e)} onBlur={() => setEditing(false)} /> - ) : ( - JSON.stringify(session.title).slice(1, -1) - )} -
+
+ ) : ( + + {JSON.stringify(session.title).slice(1, -1)} + + )} -
- {lastPartOfPath(session.workspaceDirectory || "")} +
+ {lastPartOfPath(session.workspaceDirectory || "")} {!hovered && ( - + {date.toLocaleString("en-US", { year: "2-digit", month: "2-digit", @@ -172,31 +158,29 @@ function TableRow({ )}
- +
{hovered && ( - { - setEditing(true); - }} - > - - - )} - - {hovered && ( - { - deleteSession(session.sessionId); - onDelete(session.sessionId); - }} - > - - +
+ { + e.stopPropagation(); + setEditing(true); + }} + > + + + { + deleteSession(session.sessionId); + onDelete(session.sessionId); + }} + > + + +
)}
@@ -208,10 +192,7 @@ function lastPartOfPath(path: string): string { return path.split(sep).pop() || path; } -function History() { - useNavigationListener(); - const navigate = useNavigate(); - +export function History() { const [sessions, setSessions] = useState([]); const [filteredAndSortedSessions, setFilteredAndSortedSessions] = useState< SessionInfo[] @@ -227,9 +208,6 @@ function History() { const searchInputRef = React.useRef(null); - const stickyHistoryHeaderRef = React.useRef(null); - const [headerHeight, setHeaderHeight] = useState(0); - const dispatch = useDispatch(); const { getHistory } = useHistory(dispatch); @@ -297,138 +275,90 @@ function History() { ); }, [sessions, searchTerm, minisearch]); - useEffect(() => { - setHeaderHeight(stickyHistoryHeaderRef.current?.clientHeight || 100); - }, [stickyHistoryHeaderRef.current]); - 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(""); + } }} > - navigate("/")} - className="inline-block ml-4 cursor-pointer" - /> -

History

+ {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
- {/* {workspacePaths && workspacePaths.length > 0 && ( - setFilteringByWorkspace((prev) => !prev)} - title={`Show only sessions from ${lastPartOfPath( - workspacePaths[workspacePaths.length - 1] - )}/`} - /> - )} */} -
+ )} -
- - 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 - +
+ + {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 - -
+ + deleteSessionInUI(session.sessionId)} + > + + + ); + })} + + +
+ + All session data is saved in ~/.continue/sessions +
); } - -export default History; diff --git a/gui/src/pages/gui.tsx b/gui/src/pages/gui/Chat.tsx similarity index 92% rename from gui/src/pages/gui.tsx rename to gui/src/pages/gui/Chat.tsx index 156c0b3b2..243657462 100644 --- a/gui/src/pages/gui.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -24,43 +24,43 @@ import { lightGray, vscBackground, vscForeground, -} from "../components"; -import { ChatScrollAnchor } from "../components/ChatScrollAnchor"; -import StepContainer from "../components/gui/StepContainer"; -import TimelineItem from "../components/gui/TimelineItem"; -import ContinueInputBox from "../components/mainInput/ContinueInputBox"; -import { defaultInputModifiers } from "../components/mainInput/inputModifiers"; -import { TutorialCard } from "../components/mainInput/TutorialCard"; +} from "../../components"; +import { ChatScrollAnchor } from "../../components/ChatScrollAnchor"; +import StepContainer from "../../components/gui/StepContainer"; +import TimelineItem from "../../components/gui/TimelineItem"; +import ContinueInputBox from "../../components/mainInput/ContinueInputBox"; +import { defaultInputModifiers } from "../../components/mainInput/inputModifiers"; +import { TutorialCard } from "../../components/mainInput/TutorialCard"; import { OnboardingCard, useOnboardingCard, -} from "../components/OnboardingCard"; -import { IdeMessengerContext } from "../context/IdeMessenger"; -import useChatHandler from "../hooks/useChatHandler"; -import useHistory from "../hooks/useHistory"; -import { useTutorialCard } from "../hooks/useTutorialCard"; -import { useWebviewListener } from "../hooks/useWebviewListener"; -import { defaultModelSelector } from "../redux/selectors/modelSelectors"; +} from "../../components/OnboardingCard"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import useChatHandler from "../../hooks/useChatHandler"; +import useHistory from "../../hooks/useHistory"; +import { useTutorialCard } from "../../hooks/useTutorialCard"; +import { useWebviewListener } from "../../hooks/useWebviewListener"; +import { defaultModelSelector } from "../../redux/selectors/modelSelectors"; import { clearLastResponse, deleteMessage, newSession, setInactive, -} from "../redux/slices/stateSlice"; +} from "../../redux/slices/stateSlice"; import { setDialogEntryOn, setDialogMessage, setShowDialog, -} from "../redux/slices/uiStateSlice"; -import { RootState } from "../redux/store"; +} from "../../redux/slices/uiStateSlice"; +import { RootState } from "../../redux/store"; import { getFontSize, getMetaKeyLabel, isJetBrains, isMetaEquivalentKeyPressed, -} from "../util"; -import { FREE_TRIAL_LIMIT_REQUESTS } from "../util/freeTrial"; -import { getLocalStorage, setLocalStorage } from "../util/localStorage"; +} from "../../util"; +import { FREE_TRIAL_LIMIT_REQUESTS } from "../../util/freeTrial"; +import { getLocalStorage, setLocalStorage } from "../../util/localStorage"; const TopGuiDiv = styled.div<{ showScrollbar?: boolean; @@ -144,7 +144,7 @@ function fallbackRender({ error, resetErrorBoundary }: any) { ); } -function GUI() { +export function Chat() { const posthog = usePostHog(); const dispatch = useDispatch(); const ideMessenger = useContext(IdeMessengerContext); @@ -528,5 +528,3 @@ function GUI() { ); } - -export default GUI; diff --git a/gui/src/pages/gui/index.tsx b/gui/src/pages/gui/index.tsx new file mode 100644 index 000000000..53e184027 --- /dev/null +++ b/gui/src/pages/gui/index.tsx @@ -0,0 +1,22 @@ +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 ( +
+ + +
+ +
+
+ ); +} diff --git a/gui/src/pages/history/HistoryHeader.tsx b/gui/src/pages/history/HistoryHeader.tsx new file mode 100644 index 000000000..4a8d4688c --- /dev/null +++ b/gui/src/pages/history/HistoryHeader.tsx @@ -0,0 +1,37 @@ +import { useNavigate } from "react-router-dom"; +import { lightGray, vscBackground } from "../../components"; +import { useNavigationListener } from "../../hooks/useNavigationListener"; +import { ArrowLeftIcon } from "@heroicons/react/24/outline"; + +export const HistoryHeader = () => { + useNavigationListener(); + const navigate = useNavigate(); + + return ( +
+
+ navigate("/")} + className="inline-block ml-4 cursor-pointer" + /> +

History

+
+ {/* {workspacePaths && workspacePaths.length > 0 && ( + setFilteringByWorkspace((prev) => !prev)} + title={`Show only sessions from ${lastPartOfPath( + workspacePaths[workspacePaths.length - 1] + )}/`} + /> + )} */} +
+ ); +}; diff --git a/gui/src/pages/history/index.tsx b/gui/src/pages/history/index.tsx new file mode 100644 index 000000000..6d31c60bc --- /dev/null +++ b/gui/src/pages/history/index.tsx @@ -0,0 +1,12 @@ +import { History } from "../../components/History"; +import { getFontSize } from "../../util"; +import { HistoryHeader } from "./HistoryHeader"; + +export default function HistoryPage() { + return ( +
+ + +
+ ); +} diff --git a/gui/tailwind.config.cjs b/gui/tailwind.config.cjs index a20bdecf7..63e0c2810 100644 --- a/gui/tailwind.config.cjs +++ b/gui/tailwind.config.cjs @@ -10,12 +10,15 @@ module.exports = { theme: { // Note that these breakpoints are primarily optimized for the input toolbar screens: { - xxs: "170px", // Smallest width for Primary Sidebar in VS Code + "2xs": "170px", // Smallest width for Primary Sidebar in VS Code xs: "250px", // Avg default sidebar width in VS Code sm: "330px", md: "460px", lg: "590px", xl: "720px", + "2xl": "860px", + "3xl": "1000px", + "4xl": "1140px", }, extend: { animation: {