Skip to content

Commit 4013f07

Browse files
committed
Correct a typo in the ContextUtilisation component and related files, changing context_size_warning_treshold to context_size_warning_threshold
1 parent a45eec9 commit 4013f07

6 files changed

Lines changed: 22 additions & 15 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ export default {
77
export const BelowThreshold = () => (
88
<ContextUtilisation
99
current_context_size={5000}
10-
context_size_warning_treshold={100000}
10+
context_size_warning_threshold={100000}
1111
/>
1212
)
1313

1414
export const AboveThreshold = () => (
1515
<ContextUtilisation
1616
current_context_size={120000}
17-
context_size_warning_treshold={100000}
17+
context_size_warning_threshold={100000}
1818
/>
1919
)
2020

2121
export const AtThreshold = () => (
2222
<ContextUtilisation
2323
current_context_size={100000}
24-
context_size_warning_treshold={100000}
24+
context_size_warning_threshold={100000}
2525
/>
2626
)

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import cn from 'classnames'
44

55
type Props = {
66
current_context_size: number
7-
context_size_warning_treshold: number
7+
context_size_warning_threshold: number
88
}
99

1010
const format_number = (num: number): string => {
@@ -15,11 +15,11 @@ const format_number = (num: number): string => {
1515
}
1616

1717
export const ContextUtilisation: FC<Props> = (props) => {
18-
const { current_context_size, context_size_warning_treshold } = props
18+
const { current_context_size, context_size_warning_threshold } = props
1919
const is_above_threshold =
20-
current_context_size > context_size_warning_treshold
20+
current_context_size > context_size_warning_threshold
2121
const progress = Math.min(
22-
(current_context_size / context_size_warning_treshold) * 100,
22+
(current_context_size / context_size_warning_threshold) * 100,
2323
100
2424
)
2525

@@ -37,7 +37,7 @@ export const ContextUtilisation: FC<Props> = (props) => {
3737
/>
3838
</div>
3939
<span className={styles.label}>
40-
{format_number(context_size_warning_treshold)}
40+
{format_number(context_size_warning_threshold)}
4141
</span>
4242
</div>
4343
)

‎packages/vscode/src/views/panel/backend/panel-provider.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export class ViewProvider implements vscode.WebviewViewProvider {
194194
if (
195195
event.affectsConfiguration('codeWebChat.contextSizeWarningThreshold')
196196
) {
197-
this.send_context_size_warning_threshold()
197+
this._send_context_size_warning_threshold()
198198
}
199199

200200
const all_api_config_keys = [
@@ -364,6 +364,8 @@ export class ViewProvider implements vscode.WebviewViewProvider {
364364
handle_request_editor_selection_state(this)
365365
} else if (message.command == 'GET_CURRENT_TOKEN_COUNT') {
366366
this.calculate_token_count()
367+
} else if (message.command == 'GET_CONTEXT_SIZE_WARNING_THRESHOLD') {
368+
this._send_context_size_warning_threshold()
367369
} else if (message.command == 'REPLACE_PRESETS') {
368370
await handle_replace_presets(this, message)
369371
} else if (message.command == 'UPDATE_PRESET') {
@@ -506,7 +508,6 @@ export class ViewProvider implements vscode.WebviewViewProvider {
506508
)
507509

508510
this.send_presets_to_webview(webview_view.webview)
509-
this.send_context_size_warning_threshold()
510511
// We need to wait until the webview fully initialized
511512
setTimeout(() => {
512513
this.send_message({
@@ -690,10 +691,10 @@ export class ViewProvider implements vscode.WebviewViewProvider {
690691
})
691692
}
692693

693-
public send_context_size_warning_threshold() {
694+
private _send_context_size_warning_threshold() {
694695
if (!this._webview_view) return
695696
const config = vscode.workspace.getConfiguration('codeWebChat')
696-
const threshold = config.get<number>('contextSizeWarningThreshold', 60000)
697+
const threshold = config.get<number>('contextSizeWarningThreshold')!
697698
this.send_message({
698699
command: 'CONTEXT_SIZE_WARNING_THRESHOLD',
699700
threshold

‎packages/vscode/src/views/panel/frontend/Main/MainView/MainView.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ export const MainView: React.FC<Props> = (props) => {
420420
/>
421421
<UiContextUtilisation
422422
current_context_size={props.token_count}
423-
context_size_warning_treshold={
423+
context_size_warning_threshold={
424424
props.context_size_warning_threshold
425425
}
426426
/>

‎packages/vscode/src/views/panel/frontend/Panel.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export const Panel = () => {
218218
)
219219
}
220220
}
221-
} else if (message.command === 'CONTEXT_SIZE_WARNING_THRESHOLD') {
221+
} else if (message.command == 'CONTEXT_SIZE_WARNING_THRESHOLD') {
222222
set_context_size_warning_threshold(message.threshold)
223223
}
224224
}
@@ -234,7 +234,8 @@ export const Panel = () => {
234234
{ command: 'GET_CONNECTION_STATUS' },
235235
{ command: 'REQUEST_EDITOR_STATE' },
236236
{ command: 'REQUEST_EDITOR_SELECTION_STATE' },
237-
{ command: 'GET_WORKSPACE_STATE' }
237+
{ command: 'GET_WORKSPACE_STATE' },
238+
{ command: 'GET_CONTEXT_SIZE_WARNING_THRESHOLD' }
238239
]
239240
initial_messages.forEach((message) => post_message(vscode, message))
240241

‎packages/vscode/src/views/panel/types/messages.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ export interface GetCurrentTokenCountMessage extends BaseMessage {
109109
command: 'GET_CURRENT_TOKEN_COUNT'
110110
}
111111

112+
export interface GetContextSizeWarningThresholdMessage extends BaseMessage {
113+
command: 'GET_CONTEXT_SIZE_WARNING_THRESHOLD'
114+
}
115+
112116
export interface UpdatePresetMessage extends BaseMessage {
113117
command: 'UPDATE_PRESET'
114118
updating_preset: Preset
@@ -326,6 +330,7 @@ export type FrontendMessage =
326330
| GetHistoryMessage
327331
| SaveHistoryMessage
328332
| GetCurrentTokenCountMessage
333+
| GetContextSizeWarningThresholdMessage
329334
| UpdatePresetMessage
330335
| DeletePresetMessage
331336
| DuplicatePresetMessage

0 commit comments

Comments
 (0)