Skip to content

Commit 8411a05

Browse files
committed
Align the remaining token calculation in the context utilization component with the displayed token formatting
1 parent b01ef66 commit 8411a05

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎packages/shared/src/constants/dictionary.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const dictionary = {
8383
GROUP_HAS_NO_SELECTED_PRESETS:
8484
'The chosen group has no selected presets to run.',
8585
CONTEXT_SIZE_WARNING: (threshold: string, percentage: number) =>
86-
`Context is now larger than set threshold of ${threshold} tokens by ${percentage}%. Unreasonably large context may degrade response quality, hit allowed usage limit faster or increase costs.`,
86+
`Context exceeds threshold of ${threshold} tokens by ${percentage}%. Unreasonably large context may degrade response quality, hurt plan's usage allowance or incur significant costs.`,
8787
FAILED_TO_CREATE_FILE: (file_path: string) =>
8888
`Failed to create file: ${file_path}`,
8989
FAILED_TO_APPLY_CHANGES_TO_FILE: (file_path: string) =>

‎packages/ui/src/components/editor/panel/ContextUtilisation/ContextUtilisation.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ export const ContextUtilisation: React.FC<Props> = (props) => {
3838

3939
if (!is_above_threshold) {
4040
const remaining_tokens =
41-
props.context_size_warning_threshold - props.current_context_size
41+
props.context_size_warning_threshold -
42+
(props.current_context_size < 1000
43+
? props.current_context_size
44+
: Math.floor(props.current_context_size / 1000) * 1000)
4245
const formatted_remaining_tokens = format_tokens(remaining_tokens)
4346
title_text = `${formatted_remaining_tokens} tokens remaining until threshold warning`
4447
} else {

0 commit comments

Comments
 (0)