move context status to input toolbar
This commit is contained in:
parent
6177ba3fc4
commit
99eeec3806
4 changed files with 49 additions and 41 deletions
|
|
@ -1,52 +1,63 @@
|
|||
import { Tooltip } from "react-tooltip";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import { saveCurrentSession } from "../../redux/thunks/session";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
|
||||
const ContextStatus = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const contextPercentage = useAppSelector(
|
||||
(state) => state.session.contextPercentage,
|
||||
);
|
||||
const history = useAppSelector((state) => state.session.history);
|
||||
const percent = Math.round((contextPercentage ?? 0) * 100);
|
||||
const isPruned = useAppSelector((state) => state.session.isPruned);
|
||||
if (!isPruned && percent < 60) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<div className="text-description-muted my-0.5 flex flex-row items-center gap-2 text-xs">
|
||||
<span
|
||||
className="cursor-pointer underline"
|
||||
onClick={() => {
|
||||
dispatch(
|
||||
saveCurrentSession({
|
||||
openNewSession: true,
|
||||
generateTitle: false,
|
||||
}),
|
||||
);
|
||||
}}
|
||||
>
|
||||
New Session
|
||||
</span>
|
||||
{contextPercentage !== undefined && (
|
||||
<>
|
||||
<span data-tooltip-id="percent-tooltip">{percent}%</span>
|
||||
<ToolTip id="percent-tooltip">
|
||||
{`${percent}% of context is filled`}
|
||||
</ToolTip>
|
||||
</>
|
||||
)}
|
||||
|
||||
{isPruned && (
|
||||
<>
|
||||
<div
|
||||
data-tooltip-id="prune-tooltip"
|
||||
className="bg-warning h-2 w-2 rounded-full"
|
||||
></div>
|
||||
<ToolTip id="prune-tooltip">
|
||||
Chat history exceeds context limit, old messages are being removed
|
||||
</ToolTip>
|
||||
</>
|
||||
)}
|
||||
const barColorClass = percent > 80 ? "bg-warning" : "bg-description";
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Tooltip
|
||||
id="context-status"
|
||||
closeEvents={{
|
||||
// blur: false,
|
||||
mouseleave: true,
|
||||
click: true,
|
||||
mouseup: false,
|
||||
}}
|
||||
clickable
|
||||
>
|
||||
<div className="flex flex-col gap-0">
|
||||
<span> {`${percent}% of context filled`}</span>
|
||||
{isPruned && <span>Old messages are being removed</span>}
|
||||
{history.length > 0 && (
|
||||
<span
|
||||
className="cursor-pointer underline"
|
||||
onClick={() => {
|
||||
dispatch(
|
||||
saveCurrentSession({
|
||||
openNewSession: true,
|
||||
generateTitle: false,
|
||||
}),
|
||||
);
|
||||
}}
|
||||
>
|
||||
New Session
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</Tooltip>
|
||||
<div
|
||||
data-tooltip-id="context-status"
|
||||
className="border-description-muted relative h-[10px] w-[5px] rounded-[1px] border-[0.5px] border-solid"
|
||||
>
|
||||
{/* <div className="absolute bottom-full left-1/4 h-[1px] w-1/2 border-[0.5px] border-solid" /> */}
|
||||
<div
|
||||
className={`transition-height absolute bottom-0 left-0 w-full duration-300 ease-in-out ${barColorClass}`}
|
||||
style={{ height: `${percent}%` }}
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import ModelSelect from "../modelSelection/ModelSelect";
|
|||
import { ModeSelect } from "../ModeSelect";
|
||||
import { Button } from "../ui";
|
||||
import { useFontSize } from "../ui/font";
|
||||
import ContextStatus from "./ContextStatus";
|
||||
import HoverItem from "./InputToolbar/HoverItem";
|
||||
|
||||
export interface ToolbarOptions {
|
||||
|
|
@ -170,6 +171,7 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
fontSize: tinyFont,
|
||||
}}
|
||||
>
|
||||
{!isInEdit && <ContextStatus />}
|
||||
{!props.toolbarOptions?.hideUseCodebase && !isInEdit && (
|
||||
<div
|
||||
className={`${toolsSupported ? "md:flex" : "int:flex"} hover:underline" hidden transition-colors duration-200`}
|
||||
|
|
@ -209,7 +211,6 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
</span>
|
||||
</HoverItem>
|
||||
)}
|
||||
|
||||
<Button
|
||||
data-tooltip-id="enter-tooltip"
|
||||
variant={props.isMainInput ? "primary" : "secondary"}
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ function ModelSelect() {
|
|||
{modelSelectTitle(selectedModel) || "Select model"}
|
||||
</span>
|
||||
<ChevronDownIcon
|
||||
className="h-2 w-2 flex-shrink-0 hover:brightness-110"
|
||||
className="hidden h-2 w-2 flex-shrink-0 hover:brightness-110 min-[200px]:flex"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</ListboxButton>
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ import { streamResponseThunk } from "../../redux/thunks/streamResponse";
|
|||
import { isJetBrains, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import { ToolCallDiv } from "./ToolCallDiv";
|
||||
|
||||
import ContextStatus from "../../components/mainInput/ContextStatus";
|
||||
import InlineErrorMessage from "../../components/mainInput/InlineErrorMessage";
|
||||
import { cancelStream } from "../../redux/thunks/cancelStream";
|
||||
import { EmptyChatBody } from "./EmptyChatBody";
|
||||
|
|
@ -427,9 +426,6 @@ export function Chat() {
|
|||
</NewSessionButton>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
<ContextStatus />
|
||||
</div>
|
||||
</div>
|
||||
{!hasDismissedExploreDialog && <ExploreDialogWatcher />}
|
||||
{history.length === 0 && (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue