Skip to content

Commit 585fee2

Browse files
authored
feat(/tools ux): improve UI and refactor codes (#1233)
1 parent c633c9d commit 585fee2

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

crates/q_cli/src/cli/chat/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,7 @@ where
18671867
.tools
18681868
.iter()
18691869
.map(|FigTool::ToolSpecification(spec)| {
1870-
let width = longest - spec.name.len() + 4;
1870+
let width = longest - spec.name.len() + 10;
18711871
format!(
18721872
"- {}{:>width$}{}",
18731873
spec.name,
@@ -1880,12 +1880,16 @@ where
18801880

18811881
queue!(
18821882
self.output,
1883-
style::SetForegroundColor(Color::Green),
1884-
style::Print("\nCurrent tool permissions:"),
1885-
style::SetForegroundColor(Color::Reset),
1883+
style::Print("\nTrusted tools can be run without confirmation\n"),
18861884
style::Print(format!("\n{}\n", tool_permissions.join("\n"))),
1885+
style::SetForegroundColor(Color::DarkGrey),
1886+
style::Print(format!("\n{}\n", "* Default settings")),
1887+
style::Print("\n💡 Use "),
18871888
style::SetForegroundColor(Color::Green),
1888-
style::Print("\nUse /tools help to edit permissions."),
1889+
style::Print("/tools help"),
1890+
style::SetForegroundColor(Color::Reset),
1891+
style::SetForegroundColor(Color::DarkGrey),
1892+
style::Print(" to edit permissions."),
18891893
style::SetForegroundColor(Color::Reset),
18901894
)?;
18911895
},

crates/q_cli/src/cli/chat/tools/mod.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use aws_smithy_types::{
1515
Document,
1616
Number as SmithyNumber,
1717
};
18+
use crossterm::style::Stylize;
1819
use execute_bash::ExecuteBash;
1920
use eyre::Result;
2021
use fig_api_client::model::{
@@ -171,9 +172,9 @@ impl ToolPermissions {
171172
pub fn display_label(&self, tool_name: &str) -> String {
172173
if self.has(tool_name) {
173174
if self.is_trusted(tool_name) {
174-
"Trusted".to_string()
175+
format!(" {}", "trusted".dark_green().bold())
175176
} else {
176-
"Per-request".to_string()
177+
format!(" {}", "not trusted".dark_grey())
177178
}
178179
} else {
179180
Self::default_permission_label(tool_name)
@@ -207,15 +208,15 @@ impl ToolPermissions {
207208
// This "static" way avoids needing to construct a tool instance.
208209
fn default_permission_label(tool_name: &str) -> String {
209210
let label = match tool_name {
210-
"fs_read" => "Trusted",
211-
"fs_write" => "Per-request",
212-
"execute_bash" => "Write-only commands",
213-
"use_aws" => "Write-only commands",
214-
"report_issue" => "Trusted",
215-
_ => "Per-request",
211+
"fs_read" => "trusted".dark_green().bold(),
212+
"fs_write" => "not trusted".dark_grey(),
213+
"execute_bash" => "trust read-only commands".dark_grey(),
214+
"use_aws" => "trust read-only commands".dark_grey(),
215+
"report_issue" => "trusted".dark_green().bold(),
216+
_ => "not trusted".dark_grey(),
216217
};
217218

218-
format!("{label} [Default] ")
219+
format!("{} {label}", "*".reset())
219220
}
220221
}
221222

0 commit comments

Comments
 (0)