Skip to content

Commit 72d8c38

Browse files
committed
Implement dedicated SVG icons for chat input prompt commands and remove file upload logic from the Perplexity chatbot integration
1 parent f3f33ad commit 72d8c38

8 files changed

Lines changed: 45 additions & 69 deletions

File tree

‎packages/browser/src/content-scripts/send-prompt-content-script/chatbots/perplexity.ts‎

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,64 +9,7 @@ import {
99
} from '../utils/report-initialization-error'
1010

1111
export const perplexity: Chatbot = {
12-
// wait_until_ready: async () => {
13-
// await new Promise((resolve) => {
14-
// const check_for_element = () => {
15-
// if (
16-
// document.querySelector(
17-
// 'path[d="M8 8a3.5 3 0 0 1 3.5 -3h1a3.5 3 0 0 1 3.5 3a3 3 0 0 1 -2 3a3 4 0 0 0 -2 4"]'
18-
// )
19-
// ) {
20-
// resolve(null)
21-
// } else {
22-
// setTimeout(check_for_element, 100)
23-
// }
24-
// }
25-
// check_for_element()
26-
// })
27-
// },
2812
enter_message_and_send: async (params) => {
29-
let instructions = params.message
30-
if (params.message.includes('<files>')) {
31-
instructions = params.message.split('<files>')[0].trim()
32-
const context = params.message
33-
.split('<files>')[1]
34-
.split('</files>')[0]
35-
.trim()
36-
37-
// Upload file
38-
const file_input = document.querySelector(
39-
'input[type="file"]'
40-
) as HTMLInputElement
41-
if (!file_input) {
42-
report_initialization_error({
43-
function_name: 'enter_message_and_send',
44-
log_message: 'File input not found',
45-
alert_message: InitializationError.UNABLE_TO_UPLOAD_FILE
46-
})
47-
return
48-
}
49-
const blob = new Blob([`<files>\n${context}\n</files>`], {
50-
type: 'text/plain'
51-
})
52-
const file = new File([blob], 'files.txt', { type: 'text/plain' })
53-
const data_transfer = new DataTransfer()
54-
data_transfer.items.add(file)
55-
file_input.files = data_transfer.files
56-
file_input.dispatchEvent(new Event('change', { bubbles: true }))
57-
await new Promise((r) => requestAnimationFrame(r))
58-
await new Promise((resolve) => {
59-
const check_for_element = () => {
60-
if (document.querySelector('div[data-testid="file-type-icon"]')) {
61-
resolve(null)
62-
} else {
63-
setTimeout(check_for_element, 100)
64-
}
65-
}
66-
check_for_element()
67-
})
68-
}
69-
7013
const input_element = document.querySelector(
7114
'div[contenteditable=true]'
7215
) as HTMLElement
@@ -84,7 +27,7 @@ export const perplexity: Chatbot = {
8427
bubbles: true,
8528
cancelable: true,
8629
inputType: 'insertText',
87-
data: instructions
30+
data: params.message
8831
})
8932
)
9033

Lines changed: 7 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Loading

‎packages/ui/src/assets/icons/slack.svg‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎packages/ui/src/components/editor/common/Icon/Icon.tsx‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import AIStudio from '../../../../assets/icons/ai-studio.svg'
2+
import AtSign from '../../../../assets/icons/at-sign.svg'
23
import BuyMeACoffeeLogo from '../../../../assets/icons/buy-me-a-coffee-logo.svg'
34
import BuyMeACoffeeText from '../../../../assets/icons/buy-me-a-coffee-text.svg'
45
import ChatGPT from '../../../../assets/icons/openai.svg'
@@ -7,13 +8,15 @@ import CodeWebChatLogo from '../../../../assets/icons/code-web-chat-logo.svg'
78
import CodeWebChatText from '../../../../assets/icons/code-web-chat-text.svg'
89
import Command from '../../../../assets/icons/command.svg'
910
import Copilot from '../../../../assets/icons/copilot.svg'
11+
import CurlyBraces from '../../../../assets/icons/curly-braces.svg'
1012
import GithubCopilot from '../../../../assets/icons/github-copilot.svg'
1113
import DeepSeek from '../../../../assets/icons/deepseek.svg'
1214
import Discord from '../../../../assets/icons/discord.svg'
1315
import Doubao from '../../../../assets/icons/doubao.svg'
1416
import Enter from '../../../../assets/icons/enter.svg'
1517
import Gemini from '../../../../assets/icons/gemini.svg'
1618
import Grok from '../../../../assets/icons/grok.svg'
19+
import HashSign from '../../../../assets/icons/hash-sign.svg'
1720
import HuggingChat from '../../../../assets/icons/hugging-chat.svg'
1821
import Kimi from '../../../../assets/icons/kimi.svg'
1922
import Meta from '../../../../assets/icons/meta.svg'
@@ -31,6 +34,7 @@ import ZAI from '../../../../assets/icons/z-ai.svg'
3134
export namespace Icon {
3235
export type Variant =
3336
| 'AI_STUDIO'
37+
| 'AT_SIGN'
3438
| 'BUY_ME_A_COFFEE_LOGO'
3539
| 'BUY_ME_A_COFFEE_TEXT'
3640
| 'CHATGPT'
@@ -39,13 +43,15 @@ export namespace Icon {
3943
| 'CODE_WEB_CHAT_TEXT'
4044
| 'COMMAND'
4145
| 'COPILOT'
46+
| 'CURLY_BRACES'
4247
| 'DEEPSEEK'
4348
| 'DISCORD'
4449
| 'DOUBAO'
4550
| 'ENTER'
4651
| 'GEMINI'
4752
| 'GITHUB_COPILOT'
4853
| 'GROK'
54+
| 'HASH_SIGN'
4955
| 'HUGGING_CHAT'
5056
| 'KIMI'
5157
| 'META'
@@ -72,6 +78,9 @@ export const Icon: React.FC<Icon.Props> = ({ variant }) => {
7278
case 'AI_STUDIO':
7379
icon = <AIStudio />
7480
break
81+
case 'AT_SIGN':
82+
icon = <AtSign />
83+
break
7584
case 'BUY_ME_A_COFFEE_LOGO':
7685
icon = <BuyMeACoffeeLogo />
7786
break
@@ -96,6 +105,9 @@ export const Icon: React.FC<Icon.Props> = ({ variant }) => {
96105
case 'COPILOT':
97106
icon = <Copilot />
98107
break
108+
case 'CURLY_BRACES':
109+
icon = <CurlyBraces />
110+
break
99111
case 'DEEPSEEK':
100112
icon = <DeepSeek />
101113
break
@@ -117,6 +129,9 @@ export const Icon: React.FC<Icon.Props> = ({ variant }) => {
117129
case 'GROK':
118130
icon = <Grok />
119131
break
132+
case 'HASH_SIGN':
133+
icon = <HashSign />
134+
break
120135
case 'HUGGING_CHAT':
121136
icon = <HuggingChat />
122137
break

‎packages/ui/src/components/editor/panel/ChatInput/ChatInput.module.scss‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,15 @@
185185
height: var(--size);
186186
width: var(--size);
187187
border-radius: 5px;
188-
color: var(--vscode-icon-foreground);
189188

190189
&:hover {
191190
background-color: var(--vscode-toolbar-hoverBackground);
192191
}
193192

194-
> span {
195-
padding-bottom: var(--padding-2px);
193+
> svg {
194+
width: 14px;
195+
height: 14px;
196+
fill: var(--vscode-icon-foreground);
196197
}
197198
}
198199
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,23 +202,23 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
202202
className={cn(styles['footer__left__button'])}
203203
title="Reference file"
204204
>
205-
<span>@</span>
205+
<Icon variant="AT_SIGN" />
206206
</button>
207207
{!props.is_in_code_completions_mode && (
208208
<button
209209
onClick={props.on_hash_sign_click}
210210
className={cn(styles['footer__left__button'])}
211211
title="Insert symbol"
212212
>
213-
<span>#</span>
213+
<Icon variant="HASH_SIGN" />
214214
</button>
215215
)}
216216
<button
217217
onClick={props.on_curly_braces_click}
218218
className={cn(styles['footer__left__button'])}
219219
title="Prompt templates"
220220
>
221-
<span className="codicon codicon-json" />
221+
<Icon variant="CURLY_BRACES" />
222222
</button>
223223
</div>
224224
<div

0 commit comments

Comments
 (0)