diff --git a/gui/src/components/StepContainer/ResponseActions.tsx b/gui/src/components/StepContainer/ResponseActions.tsx
index 9461bbf9309..1931c8d6c49 100644
--- a/gui/src/components/StepContainer/ResponseActions.tsx
+++ b/gui/src/components/StepContainer/ResponseActions.tsx
@@ -32,14 +32,26 @@ export default function ResponseActions({
(state) => state.session.contextPercentage,
);
const isPruned = useAppSelector((state) => state.session.isPruned);
+ const history = useAppSelector((state) => state.session.history);
- const percent = Math.round((contextPercentage ?? 0) * 100);
+ // contextPercentage is undefined until first message is sent
+ const hasContextData = contextPercentage !== undefined;
+
+ // Format: show 1 decimal place when < 1%, integer otherwise
+ const displayPercent = hasContextData ? contextPercentage * 100 : 0;
+ const percentFormatted = hasContextData
+ ? displayPercent < 1
+ ? displayPercent.toFixed(1)
+ : Math.round(displayPercent).toString()
+ : "";
+ const percent = hasContextData ? Math.round(displayPercent) : 0;
const buttonColorClass =
isLast && (isPruned || percent > 80)
? "text-warning"
: "text-description-muted";
- const showLabel = isLast && (isPruned || percent >= 60);
+ // Always show label on last message when there's history
+ const showLabel = isLast && history.length > 0;
const compactConversation = useCompactConversation();
@@ -63,7 +75,7 @@ export default function ResponseActions({
- Compact conversation
+ {hasContextData ? `${percentFormatted}% · ` : ""}Compact
)}
diff --git a/gui/src/components/mainInput/ContextStatus.tsx b/gui/src/components/mainInput/ContextStatus.tsx
index 63be8f18000..a01fdbecf15 100644
--- a/gui/src/components/mainInput/ContextStatus.tsx
+++ b/gui/src/components/mainInput/ContextStatus.tsx
@@ -15,9 +15,21 @@ const ContextStatus = () => {
const previousHistoryLength = useRef(null);
const previousSelectedChatModel = useRef(null);
const history = useAppSelector((state) => state.session.history);
- const percent = Math.round((contextPercentage ?? 0) * 100);
const isPruned = useAppSelector((state) => state.session.isPruned);
+ // contextPercentage is undefined until the first message is sent
+ // (it's only computed in compileChatMessages during streamNormalInput)
+ const hasContextData = contextPercentage !== undefined;
+
+ // Format: show 1 decimal place when < 1%, integer otherwise
+ const displayPercent = hasContextData ? contextPercentage * 100 : 0;
+ const percentFormatted = hasContextData
+ ? displayPercent < 1
+ ? displayPercent.toFixed(1)
+ : Math.round(displayPercent).toString()
+ : "—";
+ const percent = hasContextData ? Math.round(displayPercent) : 0;
+
const isDifferentModelAndSameHistory = useMemo(() => {
if (!selectedChatModel) return false;
// only reset if history changes
@@ -30,7 +42,10 @@ const ContextStatus = () => {
}, [history.length, selectedChatModel]);
const compactConversation = useCompactConversation();
- if (!isPruned && percent < 60) {
+
+ // Always show context usage when there's history, regardless of percentage
+ // Previously: if (!isPruned && percent < 60) return null;
+ if (history.length === 0) {
return null;
}
@@ -39,13 +54,18 @@ const ContextStatus = () => {
return null;
}
- const barColorClass = isPruned ? "bg-error" : "bg-description";
+ const barColorClass = isPruned
+ ? "bg-error"
+ : percent >= 80
+ ? "bg-warning"
+ : percent >= 60
+ ? "bg-description"
+ : "bg-description-muted";
return (
-
+
{
content={
- {`${percent}% of context filled.`}
+ {hasContextData
+ ? `${percentFormatted}% of context filled.`
+ : `Context usage will be shown after sending a message.`}
{isPruned && (
@@ -93,10 +115,15 @@ const ContextStatus = () => {
+ = 80 ? "text-warning" : percent >= 60 ? "text-description" : "text-description-muted"}`}
+ >
+ {hasContextData ? `${percentFormatted}%` : "—"}
+
);
};