@@ -13,7 +13,7 @@ export const compressCommand: SlashCommand = {
1313 description : 'Compresses the context by replacing it with a summary' ,
1414 kind : CommandKind . BUILT_IN ,
1515 autoExecute : true ,
16- action : async ( context ) => {
16+ action : ( context ) => {
1717 const { ui } = context ;
1818 if ( ui . pendingItem ) {
1919 ui . addItem (
@@ -36,48 +36,51 @@ export const compressCommand: SlashCommand = {
3636 } ,
3737 } ;
3838
39- try {
40- ui . setPendingItem ( pendingMessage ) ;
41- const promptId = `compress-${ Date . now ( ) } ` ;
42- const compressed =
43- await context . services . agentContext ?. geminiClient ?. tryCompressChat (
44- promptId ,
45- true ,
46- ) ;
47- if ( compressed ) {
48- ui . addItem (
49- {
50- type : MessageType . COMPRESSION ,
51- compression : {
52- isPending : false ,
53- originalTokenCount : compressed . originalTokenCount ,
54- newTokenCount : compressed . newTokenCount ,
55- compressionStatus : compressed . compressionStatus ,
39+ ui . setPendingItem ( pendingMessage ) ;
40+
41+ void ( async ( ) => {
42+ try {
43+ const promptId = `compress-${ Date . now ( ) } ` ;
44+ const compressed =
45+ await context . services . agentContext ?. geminiClient ?. tryCompressChat (
46+ promptId ,
47+ true ,
48+ ) ;
49+ if ( compressed ) {
50+ ui . addItem (
51+ {
52+ type : MessageType . COMPRESSION ,
53+ compression : {
54+ isPending : false ,
55+ originalTokenCount : compressed . originalTokenCount ,
56+ newTokenCount : compressed . newTokenCount ,
57+ compressionStatus : compressed . compressionStatus ,
58+ } ,
59+ } as HistoryItemCompression ,
60+ Date . now ( ) ,
61+ ) ;
62+ } else {
63+ ui . addItem (
64+ {
65+ type : MessageType . ERROR ,
66+ text : 'Failed to compress chat history.' ,
5667 } ,
57- } as HistoryItemCompression ,
58- Date . now ( ) ,
59- ) ;
60- } else {
68+ Date . now ( ) ,
69+ ) ;
70+ }
71+ } catch ( e ) {
6172 ui . addItem (
6273 {
6374 type : MessageType . ERROR ,
64- text : 'Failed to compress chat history.' ,
75+ text : `Failed to compress chat history: ${
76+ e instanceof Error ? e . message : String ( e )
77+ } `,
6578 } ,
6679 Date . now ( ) ,
6780 ) ;
81+ } finally {
82+ ui . setPendingItem ( null ) ;
6883 }
69- } catch ( e ) {
70- ui . addItem (
71- {
72- type : MessageType . ERROR ,
73- text : `Failed to compress chat history: ${
74- e instanceof Error ? e . message : String ( e )
75- } `,
76- } ,
77- Date . now ( ) ,
78- ) ;
79- } finally {
80- ui . setPendingItem ( null ) ;
81- }
84+ } ) ( ) ;
8285 } ,
8386} ;
0 commit comments