Skip to content

Commit ee09df8

Browse files
committed
remove some unused code, and fixed tools trustall and list
1 parent 50f3f47 commit ee09df8

File tree

10 files changed

+100
-534
lines changed

10 files changed

+100
-534
lines changed

crates/chat-cli/src/cli/chat/command_execution_tests.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@ mod command_execution_tests {
158158
Ok(())
159159
}
160160

161+
#[tokio::test]
162+
async fn test_command_context_adapter_terminal_width() -> Result<()> {
163+
// Create a mock ChatContext
164+
let mut chat_context = create_test_chat_context().await?;
165+
166+
// Create a CommandContextAdapter
167+
let adapter = chat_context.command_context_adapter();
168+
169+
// Verify that the terminal_width method returns the expected value
170+
assert_eq!(adapter.terminal_width(), 80);
171+
172+
Ok(())
173+
}
174+
161175
async fn create_test_chat_context() -> Result<ChatContext> {
162176
// Create a context - Context::new_fake() already returns an Arc<Context>
163177
let ctx = Context::new_fake();

crates/chat-cli/src/cli/chat/commands/context_adapter.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::cli::chat::{
2+
ChatContext,
23
ConversationState,
34
InputSource,
45
SharedWriter,
@@ -36,27 +37,29 @@ pub struct CommandContextAdapter<'a> {
3637
/// User settings
3738
#[allow(dead_code)]
3839
pub settings: &'a Settings,
40+
41+
/// Terminal width
42+
pub terminal_width: usize,
3943
}
4044

4145
impl<'a> CommandContextAdapter<'a> {
4246
/// Create a new CommandContextAdapter from a ChatContext
43-
pub fn new(
44-
context: &'a Context,
45-
output: &'a mut SharedWriter,
46-
conversation_state: &'a mut ConversationState,
47-
tool_permissions: &'a mut ToolPermissions,
48-
interactive: bool,
49-
input_source: &'a mut InputSource,
50-
settings: &'a Settings,
51-
) -> Self {
47+
pub fn from_chat_context(chat_context: &'a mut ChatContext) -> Self {
48+
let terminal_width = chat_context.terminal_width();
5249
Self {
53-
context,
54-
output,
55-
conversation_state,
56-
tool_permissions,
57-
interactive,
58-
input_source,
59-
settings,
50+
context: &chat_context.ctx,
51+
output: &mut chat_context.output,
52+
conversation_state: &mut chat_context.conversation_state,
53+
tool_permissions: &mut chat_context.tool_permissions,
54+
interactive: chat_context.interactive,
55+
input_source: &mut chat_context.input_source,
56+
settings: &chat_context.settings,
57+
terminal_width,
6058
}
6159
}
60+
61+
/// Get the current terminal width
62+
pub fn terminal_width(&self) -> usize {
63+
self.terminal_width
64+
}
6265
}

0 commit comments

Comments
 (0)