Skip to content

Commit 09940d7

Browse files
committed
Implement context utilization display for the "no-context" prompt type
1 parent b2421c6 commit 09940d7

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import cn from 'classnames'
44
type Props = {
55
current_context_size: number
66
context_size_warning_threshold: number
7+
is_context_disabled?: boolean
78
}
89

910
const format_tokens = (tokens: number): string => {
@@ -15,6 +16,17 @@ const format_tokens = (tokens: number): string => {
1516
}
1617

1718
export const ContextUtilisation: React.FC<Props> = (props) => {
19+
if (props.is_context_disabled) {
20+
return (
21+
<div className={styles.container}>
22+
<div className={styles.bar} />
23+
<span className={styles.label} style={{ fontStyle: 'italic' }}>
24+
Context disabled
25+
</span>
26+
</div>
27+
)
28+
}
29+
1830
const is_above_threshold =
1931
props.current_context_size > props.context_size_warning_threshold
2032
const progress = Math.min(

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ export const MainView: React.FC<Props> = (props) => {
108108
(props.mode == MODE.WEB && props.web_prompt_type == 'edit-context') ||
109109
(props.mode == MODE.API && props.api_prompt_type == 'edit-context')
110110

111+
const is_in_no_context_prompt_type =
112+
props.mode == MODE.WEB && props.web_prompt_type == 'no-context'
113+
111114
const handle_input_change = (value: string) => {
112115
props.set_instructions(value)
113116
}
@@ -229,6 +232,7 @@ export const MainView: React.FC<Props> = (props) => {
229232
context_size_warning_threshold={
230233
props.context_size_warning_threshold
231234
}
235+
is_context_disabled={is_in_no_context_prompt_type}
232236
/>
233237
</div>
234238

0 commit comments

Comments
 (0)