Skip to content

Commit 78fa9df

Browse files
committed
include in --expand
1 parent 5277b3d commit 78fa9df

File tree

1 file changed

+50
-38
lines changed

1 file changed

+50
-38
lines changed

crates/q_chat/src/lib.rs

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,25 +1685,27 @@ impl ChatContext {
16851685
}
16861686
}
16871687

1688-
queue!(
1689-
self.output,
1690-
style::SetAttribute(Attribute::Bold),
1691-
style::SetForegroundColor(Color::DarkYellow),
1692-
style::Print("\n 🔧 Hooks:\n")
1693-
)?;
1694-
Self::print_hook_section(
1695-
&mut self.output,
1696-
&context_manager.global_config.hooks,
1697-
HookTrigger::ConversationStart,
1698-
)
1699-
.map_err(map_chat_error)?;
1688+
if expand {
1689+
queue!(
1690+
self.output,
1691+
style::SetAttribute(Attribute::Bold),
1692+
style::SetForegroundColor(Color::DarkYellow),
1693+
style::Print("\n 🔧 Hooks:\n")
1694+
)?;
1695+
Self::print_hook_section(
1696+
&mut self.output,
1697+
&context_manager.global_config.hooks,
1698+
HookTrigger::ConversationStart,
1699+
)
1700+
.map_err(map_chat_error)?;
17001701

1701-
Self::print_hook_section(
1702-
&mut self.output,
1703-
&context_manager.global_config.hooks,
1704-
HookTrigger::PerPrompt,
1705-
)
1706-
.map_err(map_chat_error)?;
1702+
Self::print_hook_section(
1703+
&mut self.output,
1704+
&context_manager.global_config.hooks,
1705+
HookTrigger::PerPrompt,
1706+
)
1707+
.map_err(map_chat_error)?;
1708+
}
17071709

17081710
// Display profile context
17091711
execute!(
@@ -1744,25 +1746,27 @@ impl ChatContext {
17441746
execute!(self.output, style::Print("\n"))?;
17451747
}
17461748

1747-
queue!(
1748-
self.output,
1749-
style::SetAttribute(Attribute::Bold),
1750-
style::SetForegroundColor(Color::DarkYellow),
1751-
style::Print(" 🔧 Hooks:\n")
1752-
)?;
1753-
Self::print_hook_section(
1754-
&mut self.output,
1755-
&context_manager.profile_config.hooks,
1756-
HookTrigger::ConversationStart,
1757-
)
1758-
.map_err(map_chat_error)?;
1759-
Self::print_hook_section(
1760-
&mut self.output,
1761-
&context_manager.profile_config.hooks,
1762-
HookTrigger::PerPrompt,
1763-
)
1764-
.map_err(map_chat_error)?;
1765-
execute!(self.output, style::Print("\n"))?;
1749+
if expand {
1750+
queue!(
1751+
self.output,
1752+
style::SetAttribute(Attribute::Bold),
1753+
style::SetForegroundColor(Color::DarkYellow),
1754+
style::Print(" 🔧 Hooks:\n")
1755+
)?;
1756+
Self::print_hook_section(
1757+
&mut self.output,
1758+
&context_manager.profile_config.hooks,
1759+
HookTrigger::ConversationStart,
1760+
)
1761+
.map_err(map_chat_error)?;
1762+
Self::print_hook_section(
1763+
&mut self.output,
1764+
&context_manager.profile_config.hooks,
1765+
HookTrigger::PerPrompt,
1766+
)
1767+
.map_err(map_chat_error)?;
1768+
execute!(self.output, style::Print("\n"))?;
1769+
}
17661770

17671771
if global_context_files.is_empty() && profile_context_files.is_empty() {
17681772
execute!(
@@ -1841,8 +1845,16 @@ impl ChatContext {
18411845
style::Print(format!("\nTotal: ~{} tokens\n\n", total_tokens)),
18421846
)?;
18431847

1844-
self.compact_history(Some(tool_uses.clone()), pending_tool_index, None, true, false)
1848+
if expand {
1849+
self.compact_history(
1850+
Some(tool_uses.clone()),
1851+
pending_tool_index,
1852+
None,
1853+
true,
1854+
false,
1855+
)
18451856
.await?;
1857+
}
18461858

18471859
execute!(self.output, style::Print("\n"))?;
18481860
}

0 commit comments

Comments
 (0)