feat(mcp): enhance MCP server registration with error handling and improve transport process management
refactor: update various tools for better error handling and path resolution fix: improve markdown rendering and input display in TUI
This commit is contained in:
@@ -17,8 +17,7 @@ pub fn init_schema(conn: &Connection) -> Result<()> {
|
||||
tool_call_id TEXT,
|
||||
tool_name TEXT,
|
||||
tool_arguments TEXT,
|
||||
created_at INTEGER NOT NULL,
|
||||
FOREIGN KEY (session_id) REFERENCES archives(session_id)
|
||||
created_at INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS archives (
|
||||
|
||||
@@ -237,12 +237,12 @@ pub fn render_markdown(text: &str, width: u16, dim: bool) -> Vec<Span<'static>>
|
||||
}
|
||||
if r == 0 {
|
||||
spans.push(Span::styled(
|
||||
" |",
|
||||
" | ",
|
||||
apply_dim(Style::default().fg(Theme::BORDER), dim),
|
||||
));
|
||||
for w in &col_widths {
|
||||
spans.push(Span::styled(
|
||||
format!("{}-|", "-".repeat(*w + 2)),
|
||||
format!("{}| ", "-".repeat(*w + 1)),
|
||||
apply_dim(Style::default().fg(Theme::BORDER), dim),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -147,7 +147,13 @@ fn render_input_bar(frame: &mut Frame, area: Rect, state: &AppStateRest) {
|
||||
} else {
|
||||
let (before, after) = input_text.split_at(cursor_pos);
|
||||
spans.push(Span::raw(before.to_string()));
|
||||
let cursor_char = if after.is_empty() { " " } else { &after[..1] };
|
||||
let (cursor_char, after_char) = if after.is_empty() {
|
||||
(" ".to_string(), "")
|
||||
} else {
|
||||
let c = after.chars().next().unwrap();
|
||||
let char_len = c.len_utf8();
|
||||
(c.to_string(), &after[char_len..])
|
||||
};
|
||||
spans.push(Span::styled(
|
||||
cursor_char,
|
||||
Style::default()
|
||||
@@ -155,8 +161,8 @@ fn render_input_bar(frame: &mut Frame, area: Rect, state: &AppStateRest) {
|
||||
.fg(Theme::BG)
|
||||
.add_modifier(Modifier::BOLD),
|
||||
));
|
||||
if after.len() > 1 {
|
||||
spans.push(Span::raw(after[1..].to_string()));
|
||||
if !after_char.is_empty() {
|
||||
spans.push(Span::raw(after_char.to_string()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,19 +22,18 @@ pub fn render(
|
||||
))
|
||||
.border_style(Style::default().fg(Theme::WARNING));
|
||||
let input_text = &state.input.buffer;
|
||||
let display = if input_text.is_empty() {
|
||||
" Type your API key..."
|
||||
let char_count = input_text.chars().count();
|
||||
let display: String = if input_text.is_empty() {
|
||||
" Type your API key...".to_string()
|
||||
} else if char_count > 8 {
|
||||
input_text.chars().take(4).collect()
|
||||
} else {
|
||||
if input_text.len() > 8 {
|
||||
&input_text[..4]
|
||||
} else {
|
||||
input_text.as_str()
|
||||
}
|
||||
input_text.to_string()
|
||||
};
|
||||
let masked = if input_text.is_empty() {
|
||||
display.to_string()
|
||||
display
|
||||
} else {
|
||||
let suffix = if input_text.len() > 8 { "****" } else { "" };
|
||||
let suffix = if char_count > 8 { "****" } else { "" };
|
||||
format!("{display}{suffix}")
|
||||
};
|
||||
let lines = vec![
|
||||
|
||||
@@ -89,12 +89,12 @@ pub fn render(
|
||||
let max_lines = h_chunks[0].height.saturating_sub(2) as usize;
|
||||
let selected = state.misc.selected_index;
|
||||
let start_idx = if selected >= max_lines {
|
||||
selected - max_lines + 1
|
||||
selected.saturating_sub(max_lines).saturating_add(1)
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let end_idx = (start_idx + max_lines).min(left_lines.len());
|
||||
let visible_lines = if left_lines.is_empty() {
|
||||
let visible_lines = if left_lines.is_empty() || start_idx >= left_lines.len() {
|
||||
Vec::new()
|
||||
} else {
|
||||
left_lines[start_idx..end_idx].to_vec()
|
||||
|
||||
Reference in New Issue
Block a user