Skip to content

Commit 128f7b5

Browse files
committed
Add clickable skill links in prompt field that open external URLs for remote skills
1 parent f6507f4 commit 128f7b5

13 files changed

Lines changed: 82 additions & 6 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ We believe the agentic context retrieval is inherently flawed. Since the model h
4343
CWC proposes a non-agentic approach, where all the necessary for the task files, includnig useful examples, are picked with engineer's intent. Such guided model is easy to prompt and as accurate as it can get.
4444

4545
> [!TIP]
46-
> Use the prompt type _Prune context_ to narrow down roughly picked context.
46+
> The prompt type _Prune context_ will help you narrow down roughly picked context.
4747
4848
When pair-programming with Code Web Chat you foster codebase understanding, iterate on changes easier to review, and enter the flow state like in the good old days!
4949

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,18 @@
220220
content: '\ec59';
221221
}
222222

223+
&--skill &__text {
224+
cursor: pointer;
225+
226+
&:hover {
227+
background-color: color-mix(
228+
in srgb,
229+
var(--vscode-charts-blue) 30%,
230+
transparent
231+
);
232+
}
233+
}
234+
223235
&--changes &__icon::before {
224236
content: '\ebdb';
225237
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const Empty = () => (
3636
on_pasted_lines_click={(path, start, end) =>
3737
console.log('Pasted lines clicked:', path, start, end)
3838
}
39+
on_open_url={(url) => console.log('Open URL:', url)}
3940
/>
4041
)
4142

@@ -70,6 +71,7 @@ export const WithText = () => (
7071
on_pasted_lines_click={(path, start, end) =>
7172
console.log('Pasted lines clicked:', path, start, end)
7273
}
74+
on_open_url={(url) => console.log('Open URL:', url)}
7375
/>
7476
)
7577

@@ -104,6 +106,7 @@ export const LongText = () => (
104106
on_pasted_lines_click={(path, start, end) =>
105107
console.log('Pasted lines clicked:', path, start, end)
106108
}
109+
on_open_url={(url) => console.log('Open URL:', url)}
107110
/>
108111
)
109112

@@ -138,6 +141,7 @@ export const WithPlaceholderSavedContext = () => (
138141
on_pasted_lines_click={(path, start, end) =>
139142
console.log('Pasted lines clicked:', path, start, end)
140143
}
144+
on_open_url={(url) => console.log('Open URL:', url)}
141145
/>
142146
)
143147

@@ -178,6 +182,7 @@ export const WithPlaceholderSelection = () => (
178182
on_pasted_lines_click={(path, start, end) =>
179183
console.log('Pasted lines clicked:', path, start, end)
180184
}
185+
on_open_url={(url) => console.log('Open URL:', url)}
181186
/>
182187
)
183188

@@ -212,6 +217,7 @@ export const WithCommit = () => (
212217
on_pasted_lines_click={(path, start, end) =>
213218
console.log('Pasted lines clicked:', path, start, end)
214219
}
220+
on_open_url={(url) => console.log('Open URL:', url)}
215221
/>
216222
)
217223

@@ -246,6 +252,7 @@ export const WithCommitWithQuotes = () => (
246252
on_pasted_lines_click={(path, start, end) =>
247253
console.log('Pasted lines clicked:', path, start, end)
248254
}
255+
on_open_url={(url) => console.log('Open URL:', url)}
249256
/>
250257
)
251258
export const WithContextAtCommit = () => (
@@ -279,6 +286,7 @@ export const WithContextAtCommit = () => (
279286
on_pasted_lines_click={(path, start, end) =>
280287
console.log('Pasted lines clicked:', path, start, end)
281288
}
289+
on_open_url={(url) => console.log('Open URL:', url)}
282290
/>
283291
)
284292

@@ -316,6 +324,7 @@ export const WithEditFormatSelector = () => {
316324
on_pasted_lines_click={(path, start, end) =>
317325
console.log('Pasted lines clicked:', path, start, end)
318326
}
327+
on_open_url={(url) => console.log('Open URL:', url)}
319328
/>
320329
)
321330
}
@@ -351,5 +360,6 @@ export const WithFilePaths = () => (
351360
on_pasted_lines_click={(path, start, end) =>
352361
console.log('Pasted lines clicked:', path, start, end)
353362
}
363+
on_open_url={(url) => console.log('Open URL:', url)}
354364
/>
355365
)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export type PromptFieldProps = {
6767
prune_context_instructions_prefix: string
6868
on_prune_context_instructions_prefix_change: (value: string) => void
6969
on_pasted_lines_click: (path: string, start?: string, end?: string) => void
70+
on_open_url: (url: string) => void
7071
}
7172

7273
export const PromptField: React.FC<PromptFieldProps> = (props) => {

‎packages/ui/src/components/editor/panel/PromptField/hooks/use-handlers.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,23 @@ export const use_handlers = (
500500
}
501501
}
502502

503+
const skill_keyword_element = text_element.closest<HTMLElement>(
504+
'[data-type="skill-keyword"]'
505+
)
506+
if (skill_keyword_element) {
507+
const repo = skill_keyword_element.dataset.repo
508+
const skill_name = skill_keyword_element.dataset.skillName
509+
510+
if (repo && repo != 'local' && skill_name) {
511+
const parts = repo.split(':')
512+
if (parts.length == 2) {
513+
const [user, repo_name] = parts
514+
const url = `https://skills.sh/${user}/${repo_name}/${skill_name}`
515+
props.on_open_url(url)
516+
}
517+
}
518+
}
519+
503520
if (input_ref.current) {
504521
input_ref.current.focus()
505522
}

‎packages/ui/src/components/editor/panel/PromptField/utils/get-highlighted-text.tsx‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,23 @@ export const get_highlighted_text = (params: {
175175
const agent = skill_match[1]
176176
const repo = skill_match[2]
177177
const skill_name = skill_match[3]
178+
let title = `Skill: ${skill_name} (${agent})`
179+
180+
if (repo && repo != 'local') {
181+
const parts = repo.split(':')
182+
if (parts.length == 2) {
183+
title = `${parts[0]}/${parts[1]}`
184+
}
185+
}
186+
178187
return `<span class="${cn(
179188
styles['keyword'],
180189
styles['keyword--skill']
181190
)}" data-type="skill-keyword" data-agent="${escape_html(
182191
agent
183192
)}" data-repo="${escape_html(repo)}" data-skill-name="${escape_html(
184193
skill_name
185-
)}" title="Skill: ${escape_html(skill_name)} (${escape_html(
186-
agent
187-
)})"><span class="${
194+
)}" title="${escape_html(title)}"><span class="${
188195
styles['keyword__icon']
189196
}" data-role="keyword-icon"></span><span class="${
190197
styles['keyword__text']
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as vscode from 'vscode'
2+
import { OpenExternalUrlMessage } from '../../types/messages'
3+
4+
export const handle_open_external_url = async (
5+
message: OpenExternalUrlMessage
6+
) => {
7+
await vscode.env.openExternal(vscode.Uri.parse(message.url))
8+
}

‎packages/vscode/src/views/panel/backend/message-handlers/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ export * from './handle-cancel-intelligent-update-file-in-preview'
6464
export * from './handle-get-prune-context-instructions-prefix'
6565
export * from './handle-save-prune-context-instructions-prefix'
6666
export * from './handle-open-file-and-select'
67+
export * from './handle-open-external-url'

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ import {
8282
handle_cancel_intelligent_update_file_in_preview,
8383
handle_get_prune_context_instructions_prefix,
8484
handle_save_prune_context_instructions_prefix,
85-
handle_open_file_and_select
85+
handle_open_file_and_select,
86+
handle_open_external_url
8687
} from './message-handlers'
8788
import { SelectionState } from '../types/messages'
8889
import {
@@ -744,6 +745,8 @@ export class PanelProvider implements vscode.WebviewViewProvider {
744745
message.command == 'SAVE_PRUNE_CONTEXT_INSTRUCTIONS_PREFIX'
745746
) {
746747
await handle_save_prune_context_instructions_prefix(message.prefix)
748+
} else if (message.command == 'OPEN_EXTERNAL_URL') {
749+
await handle_open_external_url(message)
747750
}
748751
} catch (error: any) {
749752
Logger.error({

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type Props = {
6363
are_keyboard_shortcuts_disabled: boolean
6464
prune_context_instructions_prefix: string
6565
on_prune_context_instructions_prefix_change: (prefix: string) => void
66+
on_open_url: (url: string) => void
6667
}
6768

6869
export const Main: React.FC<Props> = (props) => {
@@ -818,6 +819,7 @@ export const Main: React.FC<Props> = (props) => {
818819
on_prune_context_instructions_prefix_change={
819820
props.on_prune_context_instructions_prefix_change
820821
}
822+
on_open_url={props.on_open_url}
821823
/>
822824
)
823825
}

0 commit comments

Comments
 (0)