@@ -808,11 +808,13 @@ impl ChatSession {
808
808
809
809
if self . spinner . is_some ( ) {
810
810
drop ( self . spinner . take ( ) ) ;
811
- queue ! (
812
- self . stderr,
813
- terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
814
- cursor:: MoveToColumn ( 0 ) ,
815
- ) ?;
811
+ if !self . quiet {
812
+ queue ! (
813
+ self . stderr,
814
+ terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
815
+ cursor:: MoveToColumn ( 0 ) ,
816
+ ) ?;
817
+ }
816
818
}
817
819
818
820
let ( context, report, display_err_message) = match err {
@@ -1873,7 +1875,9 @@ impl ChatSession {
1873
1875
1874
1876
queue ! ( self . stderr, style:: SetForegroundColor ( Color :: Magenta ) ) ?;
1875
1877
queue ! ( self . stderr, style:: SetForegroundColor ( Color :: Reset ) ) ?;
1876
- queue ! ( self . stderr, cursor:: Hide ) ?;
1878
+ if !self . quiet {
1879
+ queue ! ( self . stderr, cursor:: Hide ) ?;
1880
+ }
1877
1881
1878
1882
if self . interactive {
1879
1883
self . spinner = Some ( Spinner :: new ( Spinners :: Dots , "Thinking..." . to_owned ( ) ) ) ;
@@ -1940,6 +1944,7 @@ impl ChatSession {
1940
1944
. settings
1941
1945
. get_bool ( Setting :: ChatEnableNotifications )
1942
1946
. unwrap_or ( false )
1947
+ && !self . quiet
1943
1948
{
1944
1949
play_notification_bell ( !allowed) ;
1945
1950
}
@@ -2002,7 +2007,9 @@ impl ChatSession {
2002
2007
cursor:: Show
2003
2008
) ?;
2004
2009
}
2005
- execute ! ( self . stdout, style:: Print ( "\n " ) ) ?;
2010
+ if !self . quiet {
2011
+ execute ! ( self . stdout, style:: Print ( "\n " ) ) ?;
2012
+ }
2006
2013
2007
2014
let tool_end_time = Instant :: now ( ) ;
2008
2015
let tool_time = tool_end_time. duration_since ( tool_start) ;
@@ -2133,18 +2140,22 @@ impl ChatSession {
2133
2140
if !image_blocks. is_empty ( ) {
2134
2141
let images = image_blocks. into_iter ( ) . map ( |( block, _) | block) . collect ( ) ;
2135
2142
self . conversation . add_tool_results_with_images ( tool_results, images) ;
2136
- execute ! (
2137
- self . stderr,
2138
- style:: SetAttribute ( Attribute :: Reset ) ,
2139
- style:: SetForegroundColor ( Color :: Reset ) ,
2140
- style:: Print ( "\n " )
2141
- ) ?;
2143
+ if !self . quiet {
2144
+ execute ! (
2145
+ self . stderr,
2146
+ style:: SetAttribute ( Attribute :: Reset ) ,
2147
+ style:: SetForegroundColor ( Color :: Reset ) ,
2148
+ style:: Print ( "\n " )
2149
+ ) ?;
2150
+ }
2142
2151
} else {
2143
2152
self . conversation . add_tool_results ( tool_results) ;
2144
2153
}
2145
2154
2146
2155
execute ! ( self . stderr, cursor:: Hide ) ?;
2147
- execute ! ( self . stderr, style:: Print ( "\n " ) , style:: SetAttribute ( Attribute :: Reset ) ) ?;
2156
+ if !self . quiet {
2157
+ execute ! ( self . stderr, style:: Print ( "\n " ) , style:: SetAttribute ( Attribute :: Reset ) ) ?;
2158
+ }
2148
2159
if self . interactive {
2149
2160
self . spinner = Some ( Spinner :: new ( Spinners :: Dots , "Thinking..." . to_string ( ) ) ) ;
2150
2161
}
@@ -2181,7 +2192,7 @@ impl ChatSession {
2181
2192
let mut ended = false ;
2182
2193
let mut state = ParseState :: new (
2183
2194
Some ( self . terminal_width ( ) ) ,
2184
- os. database . settings . get_bool ( Setting :: ChatDisableMarkdownRendering ) ,
2195
+ Some ( self . quiet || os. database . settings . get_bool ( Setting :: ChatDisableMarkdownRendering ) . unwrap_or ( false ) ) ,
2185
2196
) ;
2186
2197
let mut response_prefix_printed = false ;
2187
2198
@@ -2190,13 +2201,15 @@ impl ChatSession {
2190
2201
2191
2202
if self . spinner . is_some ( ) {
2192
2203
drop ( self . spinner . take ( ) ) ;
2193
- queue ! (
2194
- self . stderr,
2195
- style:: SetForegroundColor ( Color :: Reset ) ,
2196
- cursor:: MoveToColumn ( 0 ) ,
2197
- cursor:: Show ,
2198
- terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
2199
- ) ?;
2204
+ if !self . quiet {
2205
+ queue ! (
2206
+ self . stderr,
2207
+ style:: SetForegroundColor ( Color :: Reset ) ,
2208
+ cursor:: MoveToColumn ( 0 ) ,
2209
+ cursor:: Show ,
2210
+ terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
2211
+ ) ?;
2212
+ }
2200
2213
}
2201
2214
2202
2215
loop {
@@ -2207,7 +2220,9 @@ impl ChatSession {
2207
2220
parser:: ResponseEvent :: ToolUseStart { name } => {
2208
2221
// We need to flush the buffer here, otherwise text will not be
2209
2222
// printed while we are receiving tool use events.
2210
- buf. push ( '\n' ) ;
2223
+ if !self . quiet {
2224
+ buf. push ( '\n' ) ;
2225
+ }
2211
2226
tool_name_being_recvd = Some ( name) ;
2212
2227
} ,
2213
2228
parser:: ResponseEvent :: AssistantText ( text) => {
@@ -2280,7 +2295,9 @@ impl ChatSession {
2280
2295
duration. as_secs( )
2281
2296
) ;
2282
2297
2283
- execute ! ( self . stderr, cursor:: Hide ) ?;
2298
+ if !self . quiet {
2299
+ execute ! ( self . stderr, cursor:: Hide ) ?;
2300
+ }
2284
2301
self . spinner = Some ( Spinner :: new ( Spinners :: Dots , "Dividing up the work..." . to_string ( ) ) ) ;
2285
2302
2286
2303
// For stream timeouts, we'll tell the model to try and split its response into
@@ -2370,12 +2387,14 @@ impl ChatSession {
2370
2387
2371
2388
if tool_name_being_recvd. is_none ( ) && !buf. is_empty ( ) && self . spinner . is_some ( ) {
2372
2389
drop ( self . spinner . take ( ) ) ;
2373
- queue ! (
2374
- self . stderr,
2375
- terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
2376
- cursor:: MoveToColumn ( 0 ) ,
2377
- cursor:: Show
2378
- ) ?;
2390
+ if !self . quiet {
2391
+ queue ! (
2392
+ self . stderr,
2393
+ terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
2394
+ cursor:: MoveToColumn ( 0 ) ,
2395
+ cursor:: Show
2396
+ ) ?;
2397
+ }
2379
2398
}
2380
2399
2381
2400
// Print the response for normal cases
@@ -2401,7 +2420,9 @@ impl ChatSession {
2401
2420
2402
2421
// Set spinner after showing all of the assistant text content so far.
2403
2422
if tool_name_being_recvd. is_some ( ) {
2404
- queue ! ( self . stderr, cursor:: Hide ) ?;
2423
+ if !self . quiet {
2424
+ queue ! ( self . stderr, cursor:: Hide ) ?;
2425
+ }
2405
2426
if self . interactive {
2406
2427
self . spinner = Some ( Spinner :: new ( Spinners :: Dots , "Thinking..." . to_string ( ) ) ) ;
2407
2428
}
@@ -2413,12 +2434,15 @@ impl ChatSession {
2413
2434
. settings
2414
2435
. get_bool ( Setting :: ChatEnableNotifications )
2415
2436
. unwrap_or ( false )
2437
+ && !self . quiet
2416
2438
{
2417
2439
// For final responses (no tools suggested), always play the bell
2418
2440
play_notification_bell ( tool_uses. is_empty ( ) ) ;
2419
2441
}
2420
2442
2421
- queue ! ( self . stderr, style:: ResetColor , style:: SetAttribute ( Attribute :: Reset ) ) ?;
2443
+ if !self . quiet {
2444
+ queue ! ( self . stderr, style:: ResetColor , style:: SetAttribute ( Attribute :: Reset ) ) ?;
2445
+ }
2422
2446
execute ! ( self . stdout, style:: Print ( "\n " ) ) ?;
2423
2447
2424
2448
for ( i, citation) in & state. citations {
0 commit comments