Skip to content

Commit 76fdc58

Browse files
committed
Trim prompt instructions across handlers, remove configuration dimming, and update status bar gradients
- should dim configurations in API target, when instructions are empty - should trim current instructions upon use - istead of static '40px', calculate with formula: character count * 3 + 20 ├── .prettierrc ├── apps │ └── editor │ └── src │ ├── utils │ │ └── changes-integration │ │ └── diff-processor │ │ └── test-cases │ │ └── generic-6 │ │ ├── expected.txt │ │ └── original.txt │ └── views │ └── prompt │ ├── backend │ │ ├── message-handlers │ │ │ ├── handle-agentic-search │ │ │ │ ├── agentic-search.ts │ │ │ │ └── handle-agentic-search.ts │ │ │ ├── handle-at-sign-quick-pick │ │ │ │ └── handle-at-sign-quick-pick.ts │ │ │ ├── handle-autofill.ts │ │ │ ├── handle-hash-sign-quick-pick │ │ │ │ └── handle-hash-sign-quick-pick.ts │ │ │ ├── handle-make-api-call.ts │ │ │ ├── handle-preview-web-configuration.ts │ │ │ ├── handle-template-quick-pick.ts │ │ │ └── utils │ │ │ └── build-prompt-payload.ts │ │ └── prompt-view-provider.ts │ └── frontend │ ├── Main │ │ ├── Main.tsx │ │ └── MainView │ │ └── MainView.tsx │ ├── Prompt.tsx │ └── hooks │ └── use-prompt │ └── hooks │ └── use-instructions.ts └── packages └── ui └── src └── components └── editor └── prompt └── StatusBar ├── StatusBar.module.scss └── StatusBar.tsx
1 parent 099b1e1 commit 76fdc58

12 files changed

Lines changed: 50 additions & 40 deletions

File tree

‎apps/editor/src/views/prompt/backend/message-handlers/handle-agentic-search/handle-agentic-search.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const handle_agentic_search = async (
1515
return
1616
}
1717

18-
const current_instructions = prompt_view_provider.current_instructions
18+
const current_instructions = prompt_view_provider.current_instructions.trim()
1919

2020
const last_query_state =
2121
prompt_view_provider.extension_context.workspaceState.get<{

‎apps/editor/src/views/prompt/backend/message-handlers/handle-autofill.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ export const handle_autofill = async (params: {
5454

5555
let sent = false
5656

57-
const current_instructions = params.prompt_view_provider.current_instructions
57+
const current_instructions =
58+
params.prompt_view_provider.current_instructions.trim()
5859

5960
const {
6061
other_files,

‎apps/editor/src/views/prompt/backend/message-handlers/handle-make-api-call.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export const handle_make_api_call = async (
154154
prompt_view_provider.extension_context
155155
)
156156

157-
const current_instructions = prompt_view_provider.current_instructions
157+
const current_instructions = prompt_view_provider.current_instructions.trim()
158158

159159
if (!current_instructions) {
160160
vscode.window.showInformationMessage(

‎apps/editor/src/views/prompt/backend/message-handlers/handle-preview-web-configuration.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const handle_preview_web_configuration = async (
1818
): Promise<void> => {
1919
await vscode.workspace.saveAll()
2020

21-
const current_instructions = prompt_view_provider.current_instructions
21+
const current_instructions = prompt_view_provider.current_instructions.trim()
2222

2323
const {
2424
other_files,

‎apps/editor/src/views/prompt/backend/message-handlers/utils/build-prompt-payload.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const build_prompt_payload = async (params: {
2727

2828
const { instructions: processed_instructions, skill_definitions } =
2929
await replace_symbols({
30-
instructions: prompt_view_provider.current_instructions || '',
30+
instructions: prompt_view_provider.current_instructions.trim() || '',
3131
extension_context: prompt_view_provider.extension_context,
3232
workspace_provider: prompt_view_provider.workspace_provider,
3333
remove_images

‎apps/editor/src/views/prompt/backend/prompt-view-provider.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,14 +515,14 @@ export class PromptViewProvider implements vscode.WebviewViewProvider {
515515

516516
public async send_token_count() {
517517
const edit_instructions_result = await replace_symbols({
518-
instructions: this.current_edit_files_instruction,
518+
instructions: this.current_edit_files_instruction.trim(),
519519
extension_context: this.extension_context,
520520
workspace_provider: this.workspace_provider,
521521
remove_images: true,
522522
symbols_cache: this.symbols_cache
523523
})
524524
const ask_instructions_result = await replace_symbols({
525-
instructions: this.current_ask_about_context_instruction,
525+
instructions: this.current_ask_about_context_instruction.trim(),
526526
extension_context: this.extension_context,
527527
workspace_provider: this.workspace_provider,
528528
remove_images: true,

‎apps/editor/src/views/prompt/frontend/Main/Main.tsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ export const Main: React.FC<Props> = (props) => {
168168
props.target == TARGET.WEB ? props.web_prompt_type : props.api_prompt_type
169169

170170
const update_chat_history = (instruction: string) => {
171-
if (!instruction.trim()) {
171+
const trimmed_instruction = instruction.trim()
172+
if (!trimmed_instruction) {
172173
return
173174
}
174175

@@ -188,10 +189,13 @@ export const Main: React.FC<Props> = (props) => {
188189
}
189190

190191
const is_duplicate =
191-
history && history.length > 0 && history[0] === instruction
192+
history && history.length > 0 && history[0] == trimmed_instruction
192193

193194
if (!is_duplicate) {
194-
const new_history = [instruction, ...(history || [])].slice(0, 100)
195+
const new_history = [trimmed_instruction, ...(history || [])].slice(
196+
0,
197+
100
198+
)
195199
set_history(new_history)
196200

197201
post_message(props.vscode, {

‎apps/editor/src/views/prompt/frontend/Main/MainView/MainView.tsx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,6 @@ export const MainView: React.FC<Props> = (props) => {
558558
<UiConfigurations
559559
configurations={web_configurations}
560560
empty_landscape_placeholder_above={configurations_placeholder_above}
561-
is_dimmed={is_context_empty || !props.is_connected}
562561
on_create={(params) => {
563562
props.on_create_web_configuration(params)
564563
}}
@@ -599,7 +598,6 @@ export const MainView: React.FC<Props> = (props) => {
599598
{props.target == TARGET.API && (
600599
<UiConfigurations
601600
configurations={api_configurations_ui}
602-
is_dimmed={is_context_empty || !props.api_configurations.length}
603601
on_configuration_click={props.on_api_configuration_click}
604602
on_reorder={(reordered) =>
605603
props.on_api_configurations_reorder(reordered)

‎packages/ui/src/components/editor/prompt/Configurations/Configurations.module.scss‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@
3232
}
3333
}
3434

35-
&--dimmed {
36-
.configurations__item__left__icon,
37-
.configurations__item__left__text {
38-
opacity: var(--dimmed-opacity);
39-
}
40-
}
41-
4235
&--highlighted {
4336
background-color: var(--vscode-list-inactiveSelectionBackground);
4437

‎packages/ui/src/components/editor/prompt/Configurations/Configurations.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export namespace Configurations {
2626
}) => void
2727
on_edit: (id: string) => void
2828
on_delete: (id: string) => void
29-
is_dimmed?: boolean
3029
empty_landscape_placeholder_above?: React.ReactNode
3130
empty_landscape_placeholder_below?: React.ReactNode
3231
translations: {
@@ -55,8 +54,7 @@ export const Configurations: React.FC<Configurations.Props> = (props) => {
5554
key={configuration.id}
5655
className={cn(styles.configurations__item, {
5756
[styles['configurations__item--highlighted']]:
58-
active_configuration_id == configuration.id,
59-
[styles['configurations__item--dimmed']]: props.is_dimmed
57+
active_configuration_id == configuration.id
6058
})}
6159
onClick={() => props.on_configuration_click(configuration.id)}
6260
role="button"

0 commit comments

Comments
 (0)