Skip to content
Merged

Dev #24

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions examples/cortex-mem-tars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ reqwest = { version = "0.12", features = ["json"] }
# Utilities
uuid = { version = "1.10", features = ["v4"] }
clipboard = "0.5"

# CLI
clap = { version = "4.5", features = ["derive"] }
25 changes: 22 additions & 3 deletions examples/cortex-mem-tars/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ impl App {
self.show_help();
}
}
crate::ui::KeyAction::ShowThemes => {
log::info!("收到 ShowThemes 动作,当前状态: {:?}", self.ui.state);
if self.ui.state == AppState::Chat {
log::info!("调用 show_themes()");
self.show_themes();
log::info!("show_themes() 调用完成,theme_modal_visible: {}", self.ui.theme_modal_visible);
} else {
log::warn!("不在 Chat 状态,无法显示主题");
}
}
crate::ui::KeyAction::DumpChats => {
if self.ui.state == AppState::Chat {
self.dump_chats();
Expand Down Expand Up @@ -322,6 +332,9 @@ impl App {
crate::ui::KeyAction::ShowHelp => {
self.show_help();
}
crate::ui::KeyAction::ShowThemes => {
self.show_themes();
}
crate::ui::KeyAction::DumpChats => {
self.dump_chats();
}
Expand Down Expand Up @@ -462,9 +475,15 @@ impl App {
/// 显示帮助信息
fn show_help(&mut self) {
log::info!("显示帮助信息");
let help_message = ChatMessage::assistant(AppUi::get_help_message());
self.ui.messages.push(help_message);
self.ui.auto_scroll = true;
self.ui.help_modal_visible = true;
self.ui.help_scroll_offset = 0;
}

/// 显示主题选择
fn show_themes(&mut self) {
log::info!("显示主题选择");
self.ui.theme_modal_visible = true;
log::info!("主题弹窗可见性已设置为: {}", self.ui.theme_modal_visible);
}

/// 导出会话到剪贴板
Expand Down
19 changes: 15 additions & 4 deletions examples/cortex-mem-tars/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,29 @@ mod ui;

use anyhow::{Context, Result};
use app::{create_default_bots, App};
use clap::Parser;
use config::ConfigManager;
use infrastructure::Infrastructure;
use logger::init_logger;
use std::sync::Arc;

#[derive(Parser, Debug)]
#[command(name = "cortex-mem-tars")]
#[command(about = "TARS, An Interactive Demonstration Program Based on Cortex Memory")]
#[command(author = "Sopaco")]
#[command(version)]
struct Args {
/// 启用增强记忆保存功能,退出时自动保存对话到记忆系统
#[arg(long, action)]
enhance_memory_saver: bool,
}

#[tokio::main]
async fn main() -> Result<()> {
// 解析命令行参数
let args: Vec<String> = std::env::args().collect();
let enhance_memory_saver = args.contains(&"--enhance-memory-saver".to_string());
let args = Args::parse();

if enhance_memory_saver {
if args.enhance_memory_saver {
log::info!("已启用增强记忆保存功能");
}

Expand Down Expand Up @@ -63,7 +74,7 @@ async fn main() -> Result<()> {
app.run().await.context("应用运行失败")?;

// 退出时保存对话到记忆系统(仅在启用增强记忆保存功能时)
if enhance_memory_saver {
if args.enhance_memory_saver {
if let Some(_inf) = infrastructure {
println!("\n╔══════════════════════════════════════════════════════════════════════════════╗");
println!("║ 🧠 Cortex Memory - 退出流程 ║");
Expand Down
Loading