chenbhao commited on
Commit
404d693
1 Parent(s): 7728560

fix: move ctx line to rightdown

Browse files
src/components/LogoV2/LogoV2.tsx CHANGED
@@ -43,8 +43,6 @@ import { useAppState, useSetAppState } from '../../state/AppState.js';
43
  import { getEffortSuffix } from '../../utils/effort.js';
44
  import { useMainLoopModel } from '../../hooks/useMainLoopModel.js';
45
  import { renderModelSetting } from '../../utils/model/model.js';
46
- import { CtxProgressBar } from '../CtxProgressBar.js';
47
- import { useContextUsage } from '../../hooks/useContextUsage.js';
48
  const LEFT_PANEL_MAX_WIDTH = 50;
49
  export function LogoV2() {
50
  const $ = _c(94);
@@ -160,7 +158,6 @@ export function LogoV2() {
160
  useEffect(t7, t8);
161
  const model = useMainLoopModel();
162
  const fullModelDisplayName = renderModelSetting(model);
163
- const contextUsage = useContextUsage();
164
  const setAppState = useSetAppState();
165
 
166
  // Poll for OpenRouter models when using 'default' model
@@ -384,7 +381,7 @@ export function LogoV2() {
384
  t18 = $[42];
385
  t19 = $[43];
386
  }
387
- return <><OffscreenFreeze><Box flexDirection="column" borderStyle="round" borderColor="startupAccent" borderText={t11} paddingX={1} paddingY={1} alignItems="center" width={columns}><Text bold={true}>{welcomeMessage}</Text>{t12}{t13}{contextUsage.hasData && <CtxProgressBar currentTokens={contextUsage.currentTokens} contextWindowTokens={contextUsage.contextWindowTokens} compactionTargetTokens={contextUsage.compactionTargetTokens} utilizationPct={contextUsage.utilizationPct} />}<Text dimColor={true}>{billingType}</Text><Text dimColor={true}>{agentName ? `@${agentName} 路 ${truncatedCwd}` : truncatedCwd}</Text></Box></OffscreenFreeze>{t14}{t15}{t16}{t17}{t18}{t19}</>;
388
  }
389
  const welcomeMessage_0 = formatWelcomeMessage(username);
390
  const modelLine = !process.env.IS_DEMO && config.oauthAccount?.organizationName ? `${modelDisplayName} 路 ${billingType} 路 ${config.oauthAccount.organizationName}` : `${modelDisplayName} 路 ${billingType}`;
@@ -451,7 +448,7 @@ export function LogoV2() {
451
  }
452
  let t22;
453
  if ($[53] !== t20 || $[54] !== t21) {
454
- t22 = <Box flexDirection="column" alignItems="center">{t20}{contextUsage.hasData && <CtxProgressBar currentTokens={contextUsage.currentTokens} contextWindowTokens={contextUsage.contextWindowTokens} compactionTargetTokens={contextUsage.compactionTargetTokens} utilizationPct={contextUsage.utilizationPct} />}{t21}</Box>;
455
  $[53] = t20;
456
  $[54] = t21;
457
  $[55] = t22;
 
43
  import { getEffortSuffix } from '../../utils/effort.js';
44
  import { useMainLoopModel } from '../../hooks/useMainLoopModel.js';
45
  import { renderModelSetting } from '../../utils/model/model.js';
 
 
46
  const LEFT_PANEL_MAX_WIDTH = 50;
47
  export function LogoV2() {
48
  const $ = _c(94);
 
158
  useEffect(t7, t8);
159
  const model = useMainLoopModel();
160
  const fullModelDisplayName = renderModelSetting(model);
 
161
  const setAppState = useSetAppState();
162
 
163
  // Poll for OpenRouter models when using 'default' model
 
381
  t18 = $[42];
382
  t19 = $[43];
383
  }
384
+ return <><OffscreenFreeze><Box flexDirection="column" borderStyle="round" borderColor="startupAccent" borderText={t11} paddingX={1} paddingY={1} alignItems="center" width={columns}><Text bold={true}>{welcomeMessage}</Text>{t12}{t13}<Text dimColor={true}>{billingType}</Text><Text dimColor={true}>{agentName ? `@${agentName} 路 ${truncatedCwd}` : truncatedCwd}</Text></Box></OffscreenFreeze>{t14}{t15}{t16}{t17}{t18}{t19}</>;
385
  }
386
  const welcomeMessage_0 = formatWelcomeMessage(username);
387
  const modelLine = !process.env.IS_DEMO && config.oauthAccount?.organizationName ? `${modelDisplayName} 路 ${billingType} 路 ${config.oauthAccount.organizationName}` : `${modelDisplayName} 路 ${billingType}`;
 
448
  }
449
  let t22;
450
  if ($[53] !== t20 || $[54] !== t21) {
451
+ t22 = <Box flexDirection="column" alignItems="center">{t20}{t21}</Box>;
452
  $[53] = t20;
453
  $[54] = t21;
454
  $[55] = t22;
src/components/TokenWarning.tsx CHANGED
@@ -7,6 +7,7 @@ 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
  type Props = {
11
  tokenUsage: number;
12
  model: string;
@@ -163,10 +164,13 @@ export function TokenWarning(t0) {
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;
 
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
  }
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 ? <><CtxProgressBar currentTokens={tokenUsage} contextWindowTokens={effectiveWindow} compactionTargetTokens={compactionTargetTokens} utilizationPct={utilizationPct} />{upgradeMessage && <Text dimColor={true}> {upgradeMessage}</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>;
174
  $[9] = autocompactLabel;
175
  $[10] = isAboveErrorThreshold;
176
  $[11] = percentLeft;