Auto-compact Threshold UI improvements (#5354)
This commit is contained in:
@@ -142,7 +142,6 @@ export default function ChatInput({
|
||||
const { getCurrentModelAndProvider, currentModel, currentProvider } = useModelAndProvider();
|
||||
const [tokenLimit, setTokenLimit] = useState<number>(TOKEN_LIMIT_DEFAULT);
|
||||
const [isTokenLimitLoaded, setIsTokenLimitLoaded] = useState(false);
|
||||
const [autoCompactThreshold, setAutoCompactThreshold] = useState<number>(0.8); // Default to 80%
|
||||
|
||||
// Draft functionality - get chat context and global draft context
|
||||
// We need to handle the case where ChatInput is used without ChatProvider (e.g., in Hub)
|
||||
@@ -501,22 +500,6 @@ export default function ChatInput({
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [currentModel, currentProvider]);
|
||||
|
||||
// Load auto-compact threshold
|
||||
const loadAutoCompactThreshold = useCallback(async () => {
|
||||
try {
|
||||
const threshold = await read('GOOSE_AUTO_COMPACT_THRESHOLD', false);
|
||||
if (threshold !== undefined && threshold !== null) {
|
||||
setAutoCompactThreshold(threshold as number);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error fetching auto-compact threshold:', err);
|
||||
}
|
||||
}, [read]);
|
||||
|
||||
useEffect(() => {
|
||||
loadAutoCompactThreshold();
|
||||
}, [loadAutoCompactThreshold]);
|
||||
|
||||
// Handle tool count alerts and token usage
|
||||
useEffect(() => {
|
||||
clearAlerts();
|
||||
@@ -542,10 +525,6 @@ export default function ChatInput({
|
||||
handleSubmit(customEvent);
|
||||
},
|
||||
compactIcon: <ScrollText size={12} />,
|
||||
autoCompactThreshold: autoCompactThreshold,
|
||||
onThresholdChange: (newThreshold: number) => {
|
||||
setAutoCompactThreshold(newThreshold);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -563,15 +542,7 @@ export default function ChatInput({
|
||||
}
|
||||
// We intentionally omit setView as it shouldn't trigger a re-render of alerts
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [
|
||||
numTokens,
|
||||
toolCount,
|
||||
tokenLimit,
|
||||
isTokenLimitLoaded,
|
||||
addAlert,
|
||||
clearAlerts,
|
||||
autoCompactThreshold,
|
||||
]);
|
||||
}, [numTokens, toolCount, tokenLimit, isTokenLimitLoaded, addAlert, clearAlerts]);
|
||||
|
||||
// Cleanup effect for component unmount - prevent memory leaks
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user