Elffuss BraidHub

kikocis/continue public

fix hide inline error and position
Changeset9f61c1672388fee0841cb5437b6e1542fb8e8a5316b213d2003633fc49629b0f
AuthorDallin Romney <dallinromney@gmail.com> · 2025-07-17 03:39 +02:00
CommitterDallin Romney <dallinromney@gmail.com> · 2025-07-17 03:39 +02:00
Parentse1c15e4ba824

Browse the files at this changeset

4 files changed

modified core/llm/countTokens.ts +5 −8
@@ -444,13 +444,6 @@
444444
445445 msgsCopy = addSpaceToAnyEmptyMessages(msgsCopy);
446446
447- while (msgsCopy.length > 1) {
448- if (isUserOrToolMsg(msgsCopy.at(-1))) {
449- break;
450- }
451- msgsCopy.pop();
452- }
453-
454447 // Extract the tool sequence from the end of the message array
455448 const toolSequence = extractToolSequence(msgsCopy);
456449
@@ -531,7 +524,11 @@
531524 reassembled.push(...historyWithTokens.map(({ tokens, ...rest }) => rest));
532525 reassembled.push(...toolSequence);
533526
534- const contextPercentage = currentTotal / contextLength;
527+ const inputTokens =
528+ currentTotal + systemMsgTokens + toolTokens + lastMessagesTokens;
529+ const availableTokens =
530+ contextLength - countingSafetyBuffer - minOutputTokens;
531+ const contextPercentage = inputTokens / availableTokens;
535532 return {
536533 compiledChatMessages: reassembled,
537534 didPrune,
modified gui/src/components/mainInput/ContinueInputBox.tsx +0 −2
@@ -7,7 +7,6 @@
77 import { ContextItemsPeek } from "./belowMainInput/ContextItemsPeek";
88 import { RulesPeek } from "./belowMainInput/RulesPeek";
99 import { GradientBorder } from "./GradientBorder";
10-import InlineErrorMessage from "./InlineErrorMessage";
1110 import { ToolbarOptions } from "./InputToolbar";
1211 import { Lump } from "./Lump";
1312 import { TipTapEditor } from "./TipTapEditor";
@@ -120,7 +119,6 @@
120119 />
121120 </div>
122121 )}
123- {props.isLastUserInput && <InlineErrorMessage />}
124122 </div>
125123 );
126124 }
modified gui/src/components/mainInput/InlineErrorMessage.tsx +4 −4
@@ -1,10 +1,12 @@
11 import { useContext } from "react";
22 import { IdeMessengerContext } from "../../context/IdeMessenger";
3-import { useAppSelector } from "../../redux/hooks";
3+import { useAppDispatch, useAppSelector } from "../../redux/hooks";
4+import { setInlineErrorMessage } from "../../redux/slices/sessionSlice";
45
56 export type InlineErrorMessageType = "out-of-context";
67
78 export default function InlineErrorMessage() {
9+ const dispatch = useAppDispatch();
810 const ideMessenger = useContext(IdeMessengerContext);
911 const inlineErrorMessage = useAppSelector(
1012 (state) => state.session.inlineErrorMessage,
@@ -33,9 +35,7 @@
3335 <span
3436 className="cursor-pointer text-xs hover:underline"
3537 onClick={() => {
36- ideMessenger.post("config/openProfile", {
37- profileId: undefined,
38- });
38+ dispatch(setInlineErrorMessage(undefined));
3939 }}
4040 >
4141 Hide
modified gui/src/pages/gui/Chat.tsx +2 −0
@@ -44,6 +44,7 @@
4444 import { ToolCallDiv } from "./ToolCallDiv";
4545
4646 import ContextStatus from "../../components/mainInput/ContextStatus";
47+import InlineErrorMessage from "../../components/mainInput/InlineErrorMessage";
4748 import { cancelStream } from "../../redux/thunks/cancelStream";
4849 import { EmptyChatBody } from "./EmptyChatBody";
4950 import { ExploreDialogWatcher } from "./ExploreDialogWatcher";
@@ -389,6 +390,7 @@
389390 >
390391 {renderChatHistoryItem(item, index)}
391392 </ErrorBoundary>
393+ {index === history.length - 1 && <InlineErrorMessage />}
392394 </div>
393395 ))}
394396 </StepsDiv>