Elffuss BraidHub

kikocis/continue public

Merge pull request #7704 from uinstinct/context-fill-display

feat: do not show context fill display when model changes
Changesetb83510677c3942a2b49fc3513baf94c7e2f0e8a0e567b3e3b081c3beea644684
AuthorTing-Wai <40179554+tingwai@users.noreply.github.com> · 2025-09-11 09:53 -07:00
CommitterGitHub <noreply@github.com> · 2025-09-11 09:53 -07:00
Parentsb804d5856fb5, 20b9c3efac21

Browse the files at this changeset

1 file changed

modified gui/src/components/mainInput/ContextStatus.tsx +22 −0
@@ -1,3 +1,4 @@
1+import { useMemo, useRef } from "react";
12 import { useAppDispatch, useAppSelector } from "../../redux/hooks";
23 import { saveCurrentSession } from "../../redux/thunks/session";
34 import { useCompactConversation } from "../../util/compactConversation";
@@ -8,15 +9,36 @@
89 const contextPercentage = useAppSelector(
910 (state) => state.session.contextPercentage,
1011 );
12+ const selectedChatModel = useAppSelector(
13+ (state) => state.config.config.selectedModelByRole.chat?.model,
14+ );
15+ const previousHistoryLength = useRef<number | null>(null);
16+ const previousSelectedChatModel = useRef<string | null>(null);
1117 const history = useAppSelector((state) => state.session.history);
1218 const percent = Math.round((contextPercentage ?? 0) * 100);
1319 const isPruned = useAppSelector((state) => state.session.isPruned);
1420
21+ const isDifferentModelAndSameHistory = useMemo(() => {
22+ if (!selectedChatModel) return false;
23+ // only reset if history changes
24+ if (previousHistoryLength.current !== history.length) {
25+ previousHistoryLength.current = history.length;
26+ previousSelectedChatModel.current = selectedChatModel;
27+ return false;
28+ }
29+ return previousSelectedChatModel.current !== selectedChatModel;
30+ }, [history.length, selectedChatModel]);
31+
1532 const compactConversation = useCompactConversation();
1633 if (!isPruned && percent < 60) {
1734 return null;
1835 }
1936
37+ // if user changed to a different model, we shouldn't show the context status until the user sends a new message
38+ if (isDifferentModelAndSameHistory) {
39+ return null;
40+ }
41+
2042 const barColorClass = isPruned ? "bg-error" : "bg-description";
2143
2244 return (