@@ -14,6 +14,7 @@ use crate::cli::chat::consts::{
1414 AGENT_FORMAT_HOOKS_DOC_URL ,
1515 CONTEXT_FILES_MAX_SIZE ,
1616} ;
17+ use crate :: cli:: chat:: context:: ContextFilePath ;
1718use crate :: cli:: chat:: token_counter:: TokenCounter ;
1819use crate :: cli:: chat:: util:: drop_matched_context_files;
1920use crate :: cli:: chat:: {
@@ -82,26 +83,37 @@ impl ContextSubcommand {
8283
8384 match self {
8485 Self :: Show { expand } => {
85- let profile_context_files = HashSet :: < ( String , String ) > :: new ( ) ;
86+ // the bool signifies if the resources is temporary (i.e. is it session based as
87+ // opposed to agent based)
88+ let mut profile_context_files = HashSet :: < ( String , String , bool ) > :: new ( ) ;
89+
90+ let ( agent_owned_list, session_owned_list) = context_manager
91+ . paths
92+ . iter ( )
93+ . partition :: < Vec < _ > , _ > ( |p| matches ! ( * * p, ContextFilePath :: Agent ( _) ) ) ;
94+
8695 execute ! (
8796 session. stderr,
8897 style:: SetAttribute ( Attribute :: Bold ) ,
8998 style:: SetForegroundColor ( Color :: Magenta ) ,
90- style:: Print ( format!( "\n 👤 Agent ({}):\n " , context_manager. current_profile) ) ,
99+ style:: Print ( format!( "👤 Agent ({}):\n " , context_manager. current_profile) ) ,
91100 style:: SetAttribute ( Attribute :: Reset ) ,
92101 ) ?;
93102
94- if context_manager . paths . is_empty ( ) {
103+ if agent_owned_list . is_empty ( ) {
95104 execute ! (
96105 session. stderr,
97106 style:: SetForegroundColor ( Color :: DarkGrey ) ,
98107 style:: Print ( " <none>\n \n " ) ,
99108 style:: SetForegroundColor ( Color :: Reset )
100109 ) ?;
101110 } else {
102- for path in & context_manager. paths {
103- execute ! ( session. stderr, style:: Print ( format!( " {} " , path) ) ) ?;
104- if let Ok ( context_files) = context_manager. get_context_files_by_path ( os, path) . await {
111+ for path in & agent_owned_list {
112+ execute ! ( session. stderr, style:: Print ( format!( " {} " , path. get_path_as_str( ) ) ) ) ?;
113+ if let Ok ( context_files) = context_manager
114+ . get_context_files_by_path ( os, path. get_path_as_str ( ) )
115+ . await
116+ {
105117 execute ! (
106118 session. stderr,
107119 style:: SetForegroundColor ( Color :: Green ) ,
@@ -112,6 +124,48 @@ impl ContextSubcommand {
112124 ) ) ,
113125 style:: SetForegroundColor ( Color :: Reset )
114126 ) ?;
127+ profile_context_files
128+ . extend ( context_files. into_iter ( ) . map ( |( path, content) | ( path, content, false ) ) ) ;
129+ }
130+ execute ! ( session. stderr, style:: Print ( "\n " ) ) ?;
131+ }
132+ execute ! ( session. stderr, style:: Print ( "\n " ) ) ?;
133+ }
134+
135+ execute ! (
136+ session. stderr,
137+ style:: SetAttribute ( Attribute :: Bold ) ,
138+ style:: SetForegroundColor ( Color :: Magenta ) ,
139+ style:: Print ( "💬 Session (temporary):\n " ) ,
140+ style:: SetAttribute ( Attribute :: Reset ) ,
141+ ) ?;
142+
143+ if session_owned_list. is_empty ( ) {
144+ execute ! (
145+ session. stderr,
146+ style:: SetForegroundColor ( Color :: DarkGrey ) ,
147+ style:: Print ( " <none>\n \n " ) ,
148+ style:: SetForegroundColor ( Color :: Reset )
149+ ) ?;
150+ } else {
151+ for path in & session_owned_list {
152+ execute ! ( session. stderr, style:: Print ( format!( " {} " , path. get_path_as_str( ) ) ) ) ?;
153+ if let Ok ( context_files) = context_manager
154+ . get_context_files_by_path ( os, path. get_path_as_str ( ) )
155+ . await
156+ {
157+ execute ! (
158+ session. stderr,
159+ style:: SetForegroundColor ( Color :: Green ) ,
160+ style:: Print ( format!(
161+ "({} match{})" ,
162+ context_files. len( ) ,
163+ if context_files. len( ) == 1 { "" } else { "es" }
164+ ) ) ,
165+ style:: SetForegroundColor ( Color :: Reset )
166+ ) ?;
167+ profile_context_files
168+ . extend ( context_files. into_iter ( ) . map ( |( path, content) | ( path, content, true ) ) ) ;
115169 }
116170 execute ! ( session. stderr, style:: Print ( "\n " ) ) ?;
117171 }
@@ -129,7 +183,7 @@ impl ContextSubcommand {
129183 let total = profile_context_files. len ( ) ;
130184 let total_tokens = profile_context_files
131185 . iter ( )
132- . map ( |( _, content) | TokenCounter :: count_tokens ( content) )
186+ . map ( |( _, content, _ ) | TokenCounter :: count_tokens ( content) )
133187 . sum :: < usize > ( ) ;
134188 execute ! (
135189 session. stderr,
@@ -144,11 +198,12 @@ impl ContextSubcommand {
144198 style:: SetAttribute ( Attribute :: Reset )
145199 ) ?;
146200
147- for ( filename, content) in & profile_context_files {
201+ for ( filename, content, is_temporary ) in & profile_context_files {
148202 let est_tokens = TokenCounter :: count_tokens ( content) ;
203+ let icon = if * is_temporary { "💬" } else { "👤" } ;
149204 execute ! (
150205 session. stderr,
151- style:: Print ( format!( "👤 {} " , filename) ) ,
206+ style:: Print ( format!( "{} {} " , icon , filename) ) ,
152207 style:: SetForegroundColor ( Color :: DarkGrey ) ,
153208 style:: Print ( format!( "(~{} tkns)\n " , est_tokens) ) ,
154209 style:: SetForegroundColor ( Color :: Reset ) ,
@@ -167,7 +222,10 @@ impl ContextSubcommand {
167222 execute ! ( session. stderr, style:: Print ( format!( "{}\n \n " , "▔" . repeat( 3 ) ) ) , ) ?;
168223 }
169224
170- let mut files_as_vec = profile_context_files. iter ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
225+ let mut files_as_vec = profile_context_files
226+ . iter ( )
227+ . map ( |( path, content, _) | ( path. clone ( ) , content. clone ( ) ) )
228+ . collect :: < Vec < _ > > ( ) ;
171229 let dropped_files = drop_matched_context_files ( & mut files_as_vec, CONTEXT_FILES_MAX_SIZE ) . ok ( ) ;
172230
173231 execute ! (
@@ -240,7 +298,8 @@ impl ContextSubcommand {
240298 execute ! (
241299 session. stderr,
242300 style:: SetForegroundColor ( Color :: Green ) ,
243- style:: Print ( format!( "\n Added {} path(s) to context.\n \n " , paths. len( ) ) ) ,
301+ style:: Print ( format!( "\n Added {} path(s) to context.\n " , paths. len( ) ) ) ,
302+ style:: Print ( "Note: Context modifications via slash command is temporary.\n \n " ) ,
244303 style:: SetForegroundColor ( Color :: Reset )
245304 ) ?;
246305 } ,
@@ -259,6 +318,7 @@ impl ContextSubcommand {
259318 session. stderr,
260319 style:: SetForegroundColor ( Color :: Green ) ,
261320 style:: Print ( format!( "\n Removed {} path(s) from context.\n \n " , paths. len( ) , ) ) ,
321+ style:: Print ( "Note: Context modifications via slash command is temporary.\n \n " ) ,
262322 style:: SetForegroundColor ( Color :: Reset )
263323 ) ?;
264324 } ,
@@ -276,7 +336,8 @@ impl ContextSubcommand {
276336 execute ! (
277337 session. stderr,
278338 style:: SetForegroundColor ( Color :: Green ) ,
279- style:: Print ( "\n Cleared context\n \n " ) ,
339+ style:: Print ( "\n Cleared context\n " ) ,
340+ style:: Print ( "Note: Context modifications via slash command is temporary.\n \n " ) ,
280341 style:: SetForegroundColor ( Color :: Reset )
281342 ) ?;
282343 } ,
0 commit comments