Elffuss BraidHub

kikocis/continue public

feat: do not show context fill display when model changes
Changeset20b9c3efac21024470d8d0d445818afbd52f0c798c0d8dd4988ead8f04c6aa28
Authoruinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-11 12:50 +05:30
Committeruinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-11 12:50 +05:30
Parentsac1a04b04a8f

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 (