@@ -72,62 +72,13 @@ use hooks::{
7272 Hook ,
7373 HookTrigger ,
7474} ;
75+ use input_source:: InputSource ;
7576use message:: {
7677 AssistantMessage ,
7778 AssistantToolUse ,
7879 ToolUseResult ,
7980 ToolUseResultBlock ,
8081} ;
81- use rand:: distr:: {
82- Alphanumeric ,
83- SampleString ,
84- } ;
85- use tokio:: signal:: ctrl_c;
86- use util:: shared_writer:: SharedWriter ;
87- use util:: ui:: draw_box;
88-
89- use crate :: api_client:: StreamingClient ;
90- use crate :: api_client:: clients:: SendMessageOutput ;
91- use crate :: api_client:: model:: {
92- ChatResponseStream ,
93- Tool as FigTool ,
94- ToolResultStatus ,
95- } ;
96- use crate :: database:: Database ;
97- use crate :: database:: settings:: Setting ;
98- use crate :: platform:: Context ;
99- use crate :: telemetry:: TelemetryThread ;
100- use crate :: telemetry:: core:: ToolUseEventBuilder ;
101-
102- /// Help text for the compact command
103- fn compact_help_text ( ) -> String {
104- color_print:: cformat!(
105- r#"
106- <magenta,em>Conversation Compaction</magenta,em>
107-
108- The <em>/compact</em> command summarizes the conversation history to free up context space
109- while preserving essential information. This is useful for long-running conversations
110- that may eventually reach memory constraints.
111-
112- <cyan!>Usage</cyan!>
113- <em>/compact</em> <black!>Summarize the conversation and clear history</black!>
114- <em>/compact [prompt]</em> <black!>Provide custom guidance for summarization</black!>
115-
116- <cyan!>When to use</cyan!>
117- • When you see the memory constraint warning message
118- • When a conversation has been running for a long time
119- • Before starting a new topic within the same session
120- • After completing complex tool operations
121-
122- <cyan!>How it works</cyan!>
123- • Creates an AI-generated summary of your conversation
124- • Retains key information, code, and tool executions in the summary
125- • Clears the conversation history to free up space
126- • The assistant will reference the summary context in future responses
127- "#
128- )
129- }
130- use input_source:: InputSource ;
13182use parse:: {
13283 ParseState ,
13384 interpret_markdown,
@@ -136,6 +87,10 @@ use parser::{
13687 RecvErrorKind ,
13788 ResponseParser ,
13889} ;
90+ use rand:: distr:: {
91+ Alphanumeric ,
92+ SampleString ,
93+ } ;
13994use regex:: Regex ;
14095use serde_json:: Map ;
14196use spinners:: {
@@ -147,6 +102,7 @@ use token_counter::{
147102 TokenCount ,
148103 TokenCounter ,
149104} ;
105+ use tokio:: signal:: ctrl_c;
150106use tool_manager:: {
151107 GetPromptError ,
152108 McpServerConfig ,
@@ -171,6 +127,8 @@ use tracing::{
171127} ;
172128use unicode_width:: UnicodeWidthStr ;
173129use util:: images:: RichImageBlock ;
130+ use util:: shared_writer:: SharedWriter ;
131+ use util:: ui:: draw_box;
174132use util:: {
175133 animate_output,
176134 drop_matched_context_files,
@@ -181,10 +139,52 @@ use uuid::Uuid;
181139use winnow:: Partial ;
182140use winnow:: stream:: Offset ;
183141
142+ use crate :: api_client:: StreamingClient ;
143+ use crate :: api_client:: clients:: SendMessageOutput ;
144+ use crate :: api_client:: model:: {
145+ ChatResponseStream ,
146+ Tool as FigTool ,
147+ ToolResultStatus ,
148+ } ;
149+ use crate :: database:: Database ;
150+ use crate :: database:: settings:: Setting ;
184151use crate :: mcp_client:: {
185152 Prompt ,
186153 PromptGetResult ,
187154} ;
155+ use crate :: platform:: Context ;
156+ use crate :: telemetry:: TelemetryThread ;
157+ use crate :: telemetry:: core:: ToolUseEventBuilder ;
158+ use crate :: util:: CHAT_BINARY_NAME ;
159+
160+ /// Help text for the compact command
161+ fn compact_help_text ( ) -> String {
162+ color_print:: cformat!(
163+ r#"
164+ <magenta,em>Conversation Compaction</magenta,em>
165+
166+ The <em>/compact</em> command summarizes the conversation history to free up context space
167+ while preserving essential information. This is useful for long-running conversations
168+ that may eventually reach memory constraints.
169+
170+ <cyan!>Usage</cyan!>
171+ <em>/compact</em> <black!>Summarize the conversation and clear history</black!>
172+ <em>/compact [prompt]</em> <black!>Provide custom guidance for summarization</black!>
173+
174+ <cyan!>When to use</cyan!>
175+ • When you see the memory constraint warning message
176+ • When a conversation has been running for a long time
177+ • Before starting a new topic within the same session
178+ • After completing complex tool operations
179+
180+ <cyan!>How it works</cyan!>
181+ • Creates an AI-generated summary of your conversation
182+ • Retains key information, code, and tool executions in the summary
183+ • Clears the conversation history to free up space
184+ • The assistant will reference the summary context in future responses
185+ "#
186+ )
187+ }
188188
189189const WELCOME_TEXT : & str = color_print:: cstr! { "<cyan!>
190190 ⢠⣶⣶⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⣿⣶⣦⡀⠀
@@ -311,7 +311,10 @@ pub async fn chat(
311311 trust_tools : Option < Vec < String > > ,
312312) -> Result < ExitCode > {
313313 if !crate :: util:: system_info:: in_cloudshell ( ) && !crate :: auth:: is_logged_in ( database) . await {
314- bail ! ( "You are not logged in, please log in with {}" , "q login" . bold( ) ) ;
314+ bail ! (
315+ "You are not logged in, please log in with {}" ,
316+ format!( "{CHAT_BINARY_NAME} login" ) . bold( )
317+ ) ;
315318 }
316319
317320 region_check ( "chat" ) ?;
0 commit comments