Merge branch 'add-history-tittle-change' of https://github.com/priyashpatil/continue into priyashpatil-add-history-tittle-change
This commit is contained in:
commit
52daee8887
3 changed files with 62 additions and 16 deletions
|
|
@ -102,7 +102,6 @@ class HistoryManager {
|
|||
if (sessionInfo.sessionId === session.sessionId) {
|
||||
sessionInfo.title = session.title;
|
||||
sessionInfo.workspaceDirectory = session.workspaceDirectory;
|
||||
sessionInfo.dateCreated = String(Date.now());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,13 +40,16 @@ function useHistory(dispatch: Dispatch) {
|
|||
dispatch(newSession());
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
|
||||
let title = truncateText(
|
||||
stripImages(stateCopy.history[0].message.content)
|
||||
.split("\n")
|
||||
.filter((l) => l.trim() !== "")
|
||||
.slice(-1)[0] || "",
|
||||
50,
|
||||
);
|
||||
let title =
|
||||
stateCopy.title === "New Session"
|
||||
? truncateText(
|
||||
stripImages(stateCopy.history[0].message.content)
|
||||
.split("\n")
|
||||
.filter((l) => l.trim() !== "")
|
||||
.slice(-1)[0] || "",
|
||||
50,
|
||||
)
|
||||
: (await getSession(stateCopy.sessionId)).title; // to ensure titles are synced with updates from history page.
|
||||
|
||||
if (
|
||||
false && // Causing maxTokens to be set to 20 for main requests sometimes, so disabling until resolved
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import { ArrowLeftIcon, TrashIcon } from "@heroicons/react/24/outline";
|
||||
import { SessionInfo } from "core";
|
||||
import {
|
||||
ArrowLeftIcon,
|
||||
PencilSquareIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { PersistedSessionInfo, SessionInfo } from "core";
|
||||
import MiniSearch from "minisearch";
|
||||
import React, { Fragment, useEffect, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
|
|
@ -91,8 +95,24 @@ function TableRow({
|
|||
const apiUrl = window.serverUrl;
|
||||
const workspacePaths = window.workspacePaths || [""];
|
||||
const [hovered, setHovered] = useState(false);
|
||||
const [editing, setEditing] = useState(false);
|
||||
const [sessionTitle, setSessionTitle] = useState(session.title);
|
||||
|
||||
const { saveSession, deleteSession, loadSession } = useHistory(dispatch);
|
||||
const { saveSession, deleteSession, loadSession, getSession, updateSession } =
|
||||
useHistory(dispatch);
|
||||
|
||||
const handleKeyUp = async (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
if (sessionTitle !== session.title) {
|
||||
session.title = sessionTitle;
|
||||
const persistedSessionInfo = await getSession(session.sessionId);
|
||||
persistedSessionInfo.title = sessionTitle;
|
||||
await updateSession(persistedSessionInfo);
|
||||
}
|
||||
|
||||
if (e.key === "Enter" || e.key === "Escape") {
|
||||
setEditing(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<td
|
||||
|
|
@ -104,15 +124,27 @@ function TableRow({
|
|||
onClick={async () => {
|
||||
// Save current session
|
||||
saveSession();
|
||||
|
||||
await loadSession(session.sessionId);
|
||||
navigate("/");
|
||||
}}
|
||||
>
|
||||
<div className="text-md">
|
||||
{JSON.stringify(session.title).slice(1, -1)}
|
||||
<div className="text-md w-100">
|
||||
{editing ? (
|
||||
<input
|
||||
type="text"
|
||||
style={{ width: "100%" }}
|
||||
ref={(titleInput) => titleInput && titleInput.focus()}
|
||||
value={sessionTitle}
|
||||
onChange={(e) => setSessionTitle(e.target.value)}
|
||||
onKeyUp={(e) => handleKeyUp(e)}
|
||||
onBlur={() => setEditing(false)}
|
||||
/>
|
||||
) : (
|
||||
JSON.stringify(session.title).slice(1, -1)
|
||||
)}
|
||||
</div>
|
||||
<div className="text-gray-400">
|
||||
|
||||
<div style={{ color: "#9ca3af" }}>
|
||||
{date.toLocaleString("en-US", {
|
||||
year: "2-digit",
|
||||
month: "2-digit",
|
||||
|
|
@ -122,10 +154,22 @@ function TableRow({
|
|||
hour12: true,
|
||||
})}
|
||||
{" | "}
|
||||
{lastPartOfPath(session.workspaceDirectory || "")}/
|
||||
{lastPartOfPath(session.workspaceDirectory || "")}
|
||||
</div>
|
||||
</TdDiv>
|
||||
|
||||
{hovered && (
|
||||
<HeaderButtonWithText
|
||||
className="mr-2"
|
||||
text="Edit"
|
||||
onClick={async () => {
|
||||
setEditing(true);
|
||||
}}
|
||||
>
|
||||
<PencilSquareIcon width="1.3em" height="1.3em" />
|
||||
</HeaderButtonWithText>
|
||||
)}
|
||||
|
||||
{hovered && (
|
||||
<HeaderButtonWithText
|
||||
className="mr-2"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue