From 6177ba3fc40b9a7290a2eca37f50c2f32754cf06 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 17 Jul 2025 03:39:08 +0200 Subject: [PATCH] fix hide inline error and position --- core/llm/countTokens.ts | 13 +++++-------- gui/src/components/mainInput/ContinueInputBox.tsx | 2 -- gui/src/components/mainInput/InlineErrorMessage.tsx | 8 ++++---- gui/src/pages/gui/Chat.tsx | 2 ++ 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index 65a7cca1f..852638d1c 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -444,13 +444,6 @@ function compileChatMessages({ msgsCopy = addSpaceToAnyEmptyMessages(msgsCopy); - while (msgsCopy.length > 1) { - if (isUserOrToolMsg(msgsCopy.at(-1))) { - break; - } - msgsCopy.pop(); - } - // Extract the tool sequence from the end of the message array const toolSequence = extractToolSequence(msgsCopy); @@ -531,7 +524,11 @@ function compileChatMessages({ reassembled.push(...historyWithTokens.map(({ tokens, ...rest }) => rest)); reassembled.push(...toolSequence); - const contextPercentage = currentTotal / contextLength; + const inputTokens = + currentTotal + systemMsgTokens + toolTokens + lastMessagesTokens; + const availableTokens = + contextLength - countingSafetyBuffer - minOutputTokens; + const contextPercentage = inputTokens / availableTokens; return { compiledChatMessages: reassembled, didPrune, diff --git a/gui/src/components/mainInput/ContinueInputBox.tsx b/gui/src/components/mainInput/ContinueInputBox.tsx index 7234fa03c..c731b761b 100644 --- a/gui/src/components/mainInput/ContinueInputBox.tsx +++ b/gui/src/components/mainInput/ContinueInputBox.tsx @@ -7,7 +7,6 @@ import { selectSlashCommandComboBoxInputs } from "../../redux/selectors"; import { ContextItemsPeek } from "./belowMainInput/ContextItemsPeek"; import { RulesPeek } from "./belowMainInput/RulesPeek"; import { GradientBorder } from "./GradientBorder"; -import InlineErrorMessage from "./InlineErrorMessage"; import { ToolbarOptions } from "./InputToolbar"; import { Lump } from "./Lump"; import { TipTapEditor } from "./TipTapEditor"; @@ -120,7 +119,6 @@ function ContinueInputBox(props: ContinueInputBoxProps) { /> )} - {props.isLastUserInput && } ); } diff --git a/gui/src/components/mainInput/InlineErrorMessage.tsx b/gui/src/components/mainInput/InlineErrorMessage.tsx index 631b939c1..d23fc7813 100644 --- a/gui/src/components/mainInput/InlineErrorMessage.tsx +++ b/gui/src/components/mainInput/InlineErrorMessage.tsx @@ -1,10 +1,12 @@ import { useContext } from "react"; import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { useAppSelector } from "../../redux/hooks"; +import { useAppDispatch, useAppSelector } from "../../redux/hooks"; +import { setInlineErrorMessage } from "../../redux/slices/sessionSlice"; export type InlineErrorMessageType = "out-of-context"; export default function InlineErrorMessage() { + const dispatch = useAppDispatch(); const ideMessenger = useContext(IdeMessengerContext); const inlineErrorMessage = useAppSelector( (state) => state.session.inlineErrorMessage, @@ -33,9 +35,7 @@ export default function InlineErrorMessage() { { - ideMessenger.post("config/openProfile", { - profileId: undefined, - }); + dispatch(setInlineErrorMessage(undefined)); }} > Hide diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 46377e094..93d51cc2e 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -44,6 +44,7 @@ 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"; import { ExploreDialogWatcher } from "./ExploreDialogWatcher"; @@ -389,6 +390,7 @@ export function Chat() { > {renderChatHistoryItem(item, index)} + {index === history.length - 1 && } ))}