feat: keep ctx line online
Browse files
src/components/PromptInput/Notifications.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import { useMainLoopModel } from '../../hooks/useMainLoopModel.js';
|
|
| 13 |
import { useVoiceEnabled } from '../../hooks/useVoiceEnabled.js';
|
| 14 |
import { Box, Text } from '../../ink.js';
|
| 15 |
import { useClaudeAiLimits } from '../../services/claudeAiLimitsHook.js';
|
| 16 |
-
import { calculateTokenWarningState } from '../../services/compact/autoCompact.js';
|
| 17 |
import type { MCPServerConnection } from '../../services/mcp/types.js';
|
| 18 |
import type { Message } from '../../types/message.js';
|
| 19 |
import { getApiKeyHelperElapsedMs, getConfiguredApiKeyHelper, getSubscriptionType } from '../../utils/auth.js';
|
|
@@ -31,6 +31,7 @@ import { IdeStatusIndicator } from '../IdeStatusIndicator.js';
|
|
| 31 |
import { MemoryUsageIndicator } from '../MemoryUsageIndicator.js';
|
| 32 |
import { SentryErrorBoundary } from '../SentryErrorBoundary.js';
|
| 33 |
import { TokenWarning } from '../TokenWarning.js';
|
|
|
|
| 34 |
import { SandboxPromptFooterHint } from './SandboxPromptFooterHint.js';
|
| 35 |
|
| 36 |
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
@@ -318,6 +319,7 @@ function NotificationContent({
|
|
| 318 |
{tokenUsage} tokens
|
| 319 |
</Text>
|
| 320 |
</Box>}
|
|
|
|
| 321 |
{!isBriefOnly && <TokenWarning tokenUsage={tokenUsage} model={mainLoopModel} />}
|
| 322 |
{shouldShowAutoUpdater && <AutoUpdaterWrapper verbose={verbose} onAutoUpdaterResult={onAutoUpdaterResult} autoUpdaterResult={autoUpdaterResult} isUpdating={isAutoUpdating} onChangeIsUpdating={onChangeIsUpdating} showSuccessMessage={!isShowingCompactMessage} />}
|
| 323 |
{feature('VOICE_MODE') ? voiceEnabled && voiceError && <Box>
|
|
|
|
| 13 |
import { useVoiceEnabled } from '../../hooks/useVoiceEnabled.js';
|
| 14 |
import { Box, Text } from '../../ink.js';
|
| 15 |
import { useClaudeAiLimits } from '../../services/claudeAiLimitsHook.js';
|
| 16 |
+
import { calculateTokenWarningState, getEffectiveContextWindowSize } from '../../services/compact/autoCompact.js';
|
| 17 |
import type { MCPServerConnection } from '../../services/mcp/types.js';
|
| 18 |
import type { Message } from '../../types/message.js';
|
| 19 |
import { getApiKeyHelperElapsedMs, getConfiguredApiKeyHelper, getSubscriptionType } from '../../utils/auth.js';
|
|
|
|
| 31 |
import { MemoryUsageIndicator } from '../MemoryUsageIndicator.js';
|
| 32 |
import { SentryErrorBoundary } from '../SentryErrorBoundary.js';
|
| 33 |
import { TokenWarning } from '../TokenWarning.js';
|
| 34 |
+
import { CtxProgressBar } from '../CtxProgressBar.js';
|
| 35 |
import { SandboxPromptFooterHint } from './SandboxPromptFooterHint.js';
|
| 36 |
|
| 37 |
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
|
|
| 319 |
{tokenUsage} tokens
|
| 320 |
</Text>
|
| 321 |
</Box>}
|
| 322 |
+
{apiKeyStatus !== 'invalid' && apiKeyStatus !== 'missing' && tokenUsage > 0 && <CtxProgressBar currentTokens={tokenUsage} contextWindowTokens={getEffectiveContextWindowSize(mainLoopModel)} compactionTargetTokens={getEffectiveContextWindowSize(mainLoopModel) - 13_000} utilizationPct={Math.round((tokenUsage / Math.max(1, getEffectiveContextWindowSize(mainLoopModel))) * 100)} />}
|
| 323 |
{!isBriefOnly && <TokenWarning tokenUsage={tokenUsage} model={mainLoopModel} />}
|
| 324 |
{shouldShowAutoUpdater && <AutoUpdaterWrapper verbose={verbose} onAutoUpdaterResult={onAutoUpdaterResult} autoUpdaterResult={autoUpdaterResult} isUpdating={isAutoUpdating} onChangeIsUpdating={onChangeIsUpdating} showSuccessMessage={!isShowingCompactMessage} />}
|
| 325 |
{feature('VOICE_MODE') ? voiceEnabled && voiceError && <Box>
|
src/components/TokenWarning.tsx
CHANGED
|
@@ -7,7 +7,6 @@ import { getFeatureValue_CACHED_MAY_BE_STALE } from '../services/analytics/growt
|
|
| 7 |
import { calculateTokenWarningState, getEffectiveContextWindowSize, isAutoCompactEnabled } from '../services/compact/autoCompact.js';
|
| 8 |
import { useCompactWarningSuppression } from '../services/compact/compactWarningHook.js';
|
| 9 |
import { getUpgradeMessage } from '../utils/model/contextWindowUpgradeCheck.js';
|
| 10 |
-
import { CtxProgressBar } from './CtxProgressBar.js';
|
| 11 |
type Props = {
|
| 12 |
tokenUsage: number;
|
| 13 |
model: string;
|
|
@@ -164,13 +163,10 @@ export function TokenWarning(t0) {
|
|
| 164 |
}
|
| 165 |
return t4;
|
| 166 |
}
|
| 167 |
-
const effectiveWindow = getEffectiveContextWindowSize(model);
|
| 168 |
-
const utilizationPct = Math.round((tokenUsage / Math.max(1, effectiveWindow)) * 100);
|
| 169 |
-
const compactionTargetTokens = effectiveWindow - 13_000;
|
| 170 |
const autocompactLabel = reactiveOnlyMode ? `${100 - displayPercentLeft}% context used` : `${displayPercentLeft}% until auto-compact`;
|
| 171 |
let t4;
|
| 172 |
if ($[9] !== autocompactLabel || $[10] !== isAboveErrorThreshold || $[11] !== percentLeft) {
|
| 173 |
-
t4 = <Box flexDirection="row">{showAutoCompactWarning ? <
|
| 174 |
$[9] = autocompactLabel;
|
| 175 |
$[10] = isAboveErrorThreshold;
|
| 176 |
$[11] = percentLeft;
|
|
|
|
| 7 |
import { calculateTokenWarningState, getEffectiveContextWindowSize, isAutoCompactEnabled } from '../services/compact/autoCompact.js';
|
| 8 |
import { useCompactWarningSuppression } from '../services/compact/compactWarningHook.js';
|
| 9 |
import { getUpgradeMessage } from '../utils/model/contextWindowUpgradeCheck.js';
|
|
|
|
| 10 |
type Props = {
|
| 11 |
tokenUsage: number;
|
| 12 |
model: string;
|
|
|
|
| 163 |
}
|
| 164 |
return t4;
|
| 165 |
}
|
|
|
|
|
|
|
|
|
|
| 166 |
const autocompactLabel = reactiveOnlyMode ? `${100 - displayPercentLeft}% context used` : `${displayPercentLeft}% until auto-compact`;
|
| 167 |
let t4;
|
| 168 |
if ($[9] !== autocompactLabel || $[10] !== isAboveErrorThreshold || $[11] !== percentLeft) {
|
| 169 |
+
t4 = <Box flexDirection="row">{showAutoCompactWarning ? <Text dimColor={true} wrap="truncate">{upgradeMessage ? `${autocompactLabel} \u00b7 ${upgradeMessage}` : autocompactLabel}</Text> : <Text color={isAboveErrorThreshold ? "error" : "warning"} wrap="truncate">{upgradeMessage ? `Context low (${percentLeft}% remaining) \u00b7 ${upgradeMessage}` : `Context low (${percentLeft}% remaining) \u00b7 Run /compact to compact & continue`}</Text>}</Box>;
|
| 170 |
$[9] = autocompactLabel;
|
| 171 |
$[10] = isAboveErrorThreshold;
|
| 172 |
$[11] = percentLeft;
|