File tree Expand file tree Collapse file tree
apps/editor/src/views/prompt
packages/ui/src/components/editor/common/prompts Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import * as vscode from 'vscode'
2+ import { replace_saved_context_symbol } from '../utils/symbols/saved-context/replace-saved-context-symbol'
3+ import { preview_text_in_temp_file } from '../utils/preview-text-in-temp-file'
4+ import { PromptViewProvider } from '../prompt-view-provider'
5+
6+ export const handle_preview_saved_context_symbol = async ( params : {
7+ prompt_view_provider : PromptViewProvider
8+ message : { context_type : string ; context_name : string }
9+ } ) => {
10+ try {
11+ const instruction = `#SavedContext(${ params . message . context_type } "${ params . message . context_name } ")`
12+ const { context_definitions } = await replace_saved_context_symbol ( {
13+ instructions : [ instruction ] ,
14+ extension_context : params . prompt_view_provider . extension_context ,
15+ workspace_provider : params . prompt_view_provider . workspace_provider
16+ } )
17+
18+ if ( context_definitions ) {
19+ await preview_text_in_temp_file ( {
20+ prefix : 'cwc-context' ,
21+ content : context_definitions . trim ( ) ,
22+ extension : '.md'
23+ } )
24+ } else {
25+ vscode . window . showInformationMessage (
26+ 'Failed to generate context preview.'
27+ )
28+ }
29+ } catch ( error ) {
30+ vscode . window . showErrorMessage ( `Failed to preview context: ${ error } ` )
31+ }
32+ }
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ export * from './handle-install-browser-extension'
5757export * from './handle-preview-changes-symbol'
5858export * from './handle-preview-commit-symbol'
5959export * from './handle-preview-skill-symbol'
60+ export * from './handle-preview-saved-context-symbol'
6061export * from './configurations'
6162export * from './handle-pick-agent'
6263export * from './handle-get-completed-tasks'
Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ import {
101101 handle_clear_completed_tasks
102102} from './message-handlers'
103103import { handle_agentic_search } from './message-handlers/handle-agentic-search'
104+ import { handle_preview_saved_context_symbol } from './message-handlers/handle-preview-saved-context-symbol'
104105import { SelectionState } from '../types/messages'
105106import {
106107 EDIT_FORMAT_STATE_KEY ,
@@ -895,6 +896,11 @@ export class PromptViewProvider implements vscode.WebviewViewProvider {
895896 await handle_preview_commit_symbol ( message )
896897 } else if ( message . command == 'PREVIEW_SKILL_SYMBOL' ) {
897898 await handle_preview_skill_symbol ( message )
899+ } else if ( message . command == 'PREVIEW_SAVED_CONTEXT_SYMBOL' ) {
900+ await handle_preview_saved_context_symbol ( {
901+ prompt_view_provider : this ,
902+ message
903+ } )
898904 } else if ( message . command == 'AGENTIC_SEARCH' ) {
899905 await handle_agentic_search ( this )
900906 } else if ( message . command == 'GET_CLI_CONFIGURATIONS' ) {
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ type Props = {
9292}
9393
9494export const Main : React . FC < Props > = ( props ) => {
95+ const { vscode } = props
9596 const [ web_configurations , set_web_configurations ] =
9697 useState < WebConfiguration [ ] > ( )
9798 const [
@@ -719,7 +720,21 @@ export const Main: React.FC<Props> = (props) => {
719720 on_preview_prompt = { props . on_preview_prompt }
720721 on_changes_click = { props . on_changes_click }
721722 on_commit_click = { props . on_commit_click }
722- on_skill_click = { props . on_skill_click }
723+ on_skill_click = { ( agent , repo , skill_name ) => {
724+ post_message ( vscode , {
725+ command : 'PREVIEW_SKILL_SYMBOL' ,
726+ agent,
727+ repo,
728+ skill_name
729+ } )
730+ } }
731+ on_saved_context_click = { ( context_type , context_name ) => {
732+ post_message ( vscode , {
733+ command : 'PREVIEW_SAVED_CONTEXT_SYMBOL' ,
734+ context_type,
735+ context_name
736+ } )
737+ } }
723738 on_install_browser_extension = { handle_install_browser_extension }
724739 on_agentic_search = { props . on_agentic_search }
725740 on_clear_context = { handle_clear_context }
Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ type Props = {
145145 commit_message ?: string
146146 ) => void
147147 on_skill_click ?: ( agent : string , repo : string , skill_name : string ) => void
148+ on_saved_context_click ?: ( context_type : string , context_name : string ) => void
148149 on_install_browser_extension : ( ) => void
149150 on_agentic_search : ( ) => void
150151 on_clear_context : ( ) => void
@@ -506,6 +507,7 @@ export const MainView: React.FC<Props> = (props) => {
506507 on_clear_context = { props . on_clear_context }
507508 on_commit_click = { props . on_commit_click }
508509 on_skill_click = { props . on_skill_click }
510+ on_saved_context_click = { props . on_saved_context_click }
509511 on_preview_prompt = { props . on_preview_prompt }
510512 is_recording = { props . is_recording }
511513 on_recording_started = { props . on_recording_started }
Original file line number Diff line number Diff line change @@ -591,6 +591,12 @@ export interface PreviewSkillSymbolMessage extends BaseMessage {
591591 skill_name : string
592592}
593593
594+ export interface PreviewSavedContextSymbolMessage extends BaseMessage {
595+ command : 'PREVIEW_SAVED_CONTEXT_SYMBOL'
596+ context_type : string
597+ context_name : string
598+ }
599+
594600export interface AgenticSearchMessage extends BaseMessage {
595601 command : 'AGENTIC_SEARCH'
596602}
@@ -712,6 +718,7 @@ export type FrontendMessage =
712718 | PreviewChangesSymbolMessage
713719 | PreviewCommitSymbolMessage
714720 | PreviewSkillSymbolMessage
721+ | PreviewSavedContextSymbolMessage
715722 | AgenticSearchMessage
716723 | GetAgentConfigurationsMessage
717724 | ReorderAgentConfigurationsMessage
Original file line number Diff line number Diff line change @@ -75,6 +75,10 @@ export namespace PromptField {
7575 commit_message ?: string
7676 ) => void
7777 on_skill_click ?: ( agent : string , repo : string , skill_name : string ) => void
78+ on_saved_context_click ?: (
79+ context_type : string ,
80+ context_name : string
81+ ) => void
7882 on_preview_prompt ?: ( ) => void
7983 is_recording : boolean
8084 on_recording_started : ( ) => void
Original file line number Diff line number Diff line change @@ -75,6 +75,18 @@ export const create_handle_input_click = ({
7575 }
7676 }
7777
78+ const saved_context_symbol_element = text_element . closest < HTMLElement > (
79+ '[data-type="saved-context-symbol"]'
80+ )
81+ if ( saved_context_symbol_element ) {
82+ const context_type = saved_context_symbol_element . dataset . contextType
83+ const context_name = saved_context_symbol_element . dataset . contextName
84+
85+ if ( context_type && context_name ) {
86+ props . on_saved_context_click ?.( context_type , context_name )
87+ }
88+ }
89+
7890 const image_symbol_element = text_element . closest < HTMLElement > (
7991 '[data-type="image-symbol"]'
8092 )
Original file line number Diff line number Diff line change 170170 content : ' \eab3 ' ;
171171 }
172172
173+ & --saved-context & __text {
174+ cursor : pointer ;
175+
176+ & :hover {
177+ background-color : color-mix (
178+ in srgb ,
179+ var (--vscode-charts-blue ) 30% ,
180+ transparent
181+ );
182+ }
183+ }
184+
173185 & --pasted-lines & __icon ::before {
174186 content : ' \eac0 ' ;
175187 }
You can’t perform that action at this time.
0 commit comments