@@ -807,11 +807,13 @@ impl ChatSession {
807
807
808
808
if self . spinner . is_some ( ) {
809
809
drop ( self . spinner . take ( ) ) ;
810
- queue ! (
811
- self . stderr,
812
- terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
813
- cursor:: MoveToColumn ( 0 ) ,
814
- ) ?;
810
+ if !self . quiet {
811
+ queue ! (
812
+ self . stderr,
813
+ terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
814
+ cursor:: MoveToColumn ( 0 ) ,
815
+ ) ?;
816
+ }
815
817
}
816
818
817
819
let ( context, report, display_err_message) = match err {
@@ -1872,7 +1874,9 @@ impl ChatSession {
1872
1874
1873
1875
queue ! ( self . stderr, style:: SetForegroundColor ( Color :: Magenta ) ) ?;
1874
1876
queue ! ( self . stderr, style:: SetForegroundColor ( Color :: Reset ) ) ?;
1875
- queue ! ( self . stderr, cursor:: Hide ) ?;
1877
+ if !self . quiet {
1878
+ queue ! ( self . stderr, cursor:: Hide ) ?;
1879
+ }
1876
1880
1877
1881
if self . interactive {
1878
1882
self . spinner = Some ( Spinner :: new ( Spinners :: Dots , "Thinking..." . to_owned ( ) ) ) ;
@@ -1921,6 +1925,7 @@ impl ChatSession {
1921
1925
. settings
1922
1926
. get_bool ( Setting :: ChatEnableNotifications )
1923
1927
. unwrap_or ( false )
1928
+ && !self . quiet
1924
1929
{
1925
1930
play_notification_bell ( !allowed) ;
1926
1931
}
@@ -1983,7 +1988,9 @@ impl ChatSession {
1983
1988
cursor:: Show
1984
1989
) ?;
1985
1990
}
1986
- execute ! ( self . stdout, style:: Print ( "\n " ) ) ?;
1991
+ if !self . quiet {
1992
+ execute ! ( self . stdout, style:: Print ( "\n " ) ) ?;
1993
+ }
1987
1994
1988
1995
let tool_end_time = Instant :: now ( ) ;
1989
1996
let tool_time = tool_end_time. duration_since ( tool_start) ;
@@ -2087,18 +2094,22 @@ impl ChatSession {
2087
2094
if !image_blocks. is_empty ( ) {
2088
2095
let images = image_blocks. into_iter ( ) . map ( |( block, _) | block) . collect ( ) ;
2089
2096
self . conversation . add_tool_results_with_images ( tool_results, images) ;
2090
- execute ! (
2091
- self . stderr,
2092
- style:: SetAttribute ( Attribute :: Reset ) ,
2093
- style:: SetForegroundColor ( Color :: Reset ) ,
2094
- style:: Print ( "\n " )
2095
- ) ?;
2097
+ if !self . quiet {
2098
+ execute ! (
2099
+ self . stderr,
2100
+ style:: SetAttribute ( Attribute :: Reset ) ,
2101
+ style:: SetForegroundColor ( Color :: Reset ) ,
2102
+ style:: Print ( "\n " )
2103
+ ) ?;
2104
+ }
2096
2105
} else {
2097
2106
self . conversation . add_tool_results ( tool_results) ;
2098
2107
}
2099
2108
2100
2109
execute ! ( self . stderr, cursor:: Hide ) ?;
2101
- execute ! ( self . stderr, style:: Print ( "\n " ) , style:: SetAttribute ( Attribute :: Reset ) ) ?;
2110
+ if !self . quiet {
2111
+ execute ! ( self . stderr, style:: Print ( "\n " ) , style:: SetAttribute ( Attribute :: Reset ) ) ?;
2112
+ }
2102
2113
if self . interactive {
2103
2114
self . spinner = Some ( Spinner :: new ( Spinners :: Dots , "Thinking..." . to_string ( ) ) ) ;
2104
2115
}
@@ -2135,7 +2146,7 @@ impl ChatSession {
2135
2146
let mut ended = false ;
2136
2147
let mut state = ParseState :: new (
2137
2148
Some ( self . terminal_width ( ) ) ,
2138
- os. database . settings . get_bool ( Setting :: ChatDisableMarkdownRendering ) ,
2149
+ Some ( self . quiet || os. database . settings . get_bool ( Setting :: ChatDisableMarkdownRendering ) . unwrap_or ( false ) ) ,
2139
2150
) ;
2140
2151
let mut response_prefix_printed = false ;
2141
2152
@@ -2144,13 +2155,15 @@ impl ChatSession {
2144
2155
2145
2156
if self . spinner . is_some ( ) {
2146
2157
drop ( self . spinner . take ( ) ) ;
2147
- queue ! (
2148
- self . stderr,
2149
- style:: SetForegroundColor ( Color :: Reset ) ,
2150
- cursor:: MoveToColumn ( 0 ) ,
2151
- cursor:: Show ,
2152
- terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
2153
- ) ?;
2158
+ if !self . quiet {
2159
+ queue ! (
2160
+ self . stderr,
2161
+ style:: SetForegroundColor ( Color :: Reset ) ,
2162
+ cursor:: MoveToColumn ( 0 ) ,
2163
+ cursor:: Show ,
2164
+ terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
2165
+ ) ?;
2166
+ }
2154
2167
}
2155
2168
2156
2169
loop {
@@ -2161,7 +2174,9 @@ impl ChatSession {
2161
2174
parser:: ResponseEvent :: ToolUseStart { name } => {
2162
2175
// We need to flush the buffer here, otherwise text will not be
2163
2176
// printed while we are receiving tool use events.
2164
- buf. push ( '\n' ) ;
2177
+ if !self . quiet {
2178
+ buf. push ( '\n' ) ;
2179
+ }
2165
2180
tool_name_being_recvd = Some ( name) ;
2166
2181
} ,
2167
2182
parser:: ResponseEvent :: AssistantText ( text) => {
@@ -2234,7 +2249,9 @@ impl ChatSession {
2234
2249
duration. as_secs( )
2235
2250
) ;
2236
2251
2237
- execute ! ( self . stderr, cursor:: Hide ) ?;
2252
+ if !self . quiet {
2253
+ execute ! ( self . stderr, cursor:: Hide ) ?;
2254
+ }
2238
2255
self . spinner = Some ( Spinner :: new ( Spinners :: Dots , "Dividing up the work..." . to_string ( ) ) ) ;
2239
2256
2240
2257
// For stream timeouts, we'll tell the model to try and split its response into
@@ -2324,12 +2341,14 @@ impl ChatSession {
2324
2341
2325
2342
if tool_name_being_recvd. is_none ( ) && !buf. is_empty ( ) && self . spinner . is_some ( ) {
2326
2343
drop ( self . spinner . take ( ) ) ;
2327
- queue ! (
2328
- self . stderr,
2329
- terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
2330
- cursor:: MoveToColumn ( 0 ) ,
2331
- cursor:: Show
2332
- ) ?;
2344
+ if !self . quiet {
2345
+ queue ! (
2346
+ self . stderr,
2347
+ terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
2348
+ cursor:: MoveToColumn ( 0 ) ,
2349
+ cursor:: Show
2350
+ ) ?;
2351
+ }
2333
2352
}
2334
2353
2335
2354
// Print the response for normal cases
@@ -2355,7 +2374,9 @@ impl ChatSession {
2355
2374
2356
2375
// Set spinner after showing all of the assistant text content so far.
2357
2376
if tool_name_being_recvd. is_some ( ) {
2358
- queue ! ( self . stderr, cursor:: Hide ) ?;
2377
+ if !self . quiet {
2378
+ queue ! ( self . stderr, cursor:: Hide ) ?;
2379
+ }
2359
2380
if self . interactive {
2360
2381
self . spinner = Some ( Spinner :: new ( Spinners :: Dots , "Thinking..." . to_string ( ) ) ) ;
2361
2382
}
@@ -2367,12 +2388,15 @@ impl ChatSession {
2367
2388
. settings
2368
2389
. get_bool ( Setting :: ChatEnableNotifications )
2369
2390
. unwrap_or ( false )
2391
+ && !self . quiet
2370
2392
{
2371
2393
// For final responses (no tools suggested), always play the bell
2372
2394
play_notification_bell ( tool_uses. is_empty ( ) ) ;
2373
2395
}
2374
2396
2375
- queue ! ( self . stderr, style:: ResetColor , style:: SetAttribute ( Attribute :: Reset ) ) ?;
2397
+ if !self . quiet {
2398
+ queue ! ( self . stderr, style:: ResetColor , style:: SetAttribute ( Attribute :: Reset ) ) ?;
2399
+ }
2376
2400
execute ! ( self . stdout, style:: Print ( "\n " ) ) ?;
2377
2401
2378
2402
for ( i, citation) in & state. citations {
0 commit comments