feat: refactor API key configuration and enhance application initialization
- Renamed `check_environment` to `check_api_key_configured` for clarity, simplifying the API key validation logic. - Removed the blocking behavior of the API key check during application startup, allowing the app to run while providing a prompt for configuration. - Updated `LocalAgentApp` to accept an `api_configured` parameter, enabling conditional messaging for API key setup. - Enhanced the `SandboxRunner` to support backup management and improved execution result handling with detailed metrics. - Integrated data governance strategies into the `HistoryManager`, ensuring compliance and improved data management. - Added privacy settings and metrics tracking across various components to enhance user experience and application safety.
This commit is contained in:
@@ -503,7 +503,14 @@ class HistoryView:
|
||||
# 加载历史记录
|
||||
records = self.history.get_all()
|
||||
|
||||
# 用于跟踪已插入的ID,避免重复
|
||||
inserted_ids = set()
|
||||
|
||||
for record in records:
|
||||
# 如果task_id已存在,跳过或使用唯一ID
|
||||
if record.task_id in inserted_ids:
|
||||
continue
|
||||
|
||||
# 使用任务描述(如果有)或截断的用户输入
|
||||
description = getattr(record, 'task_summary', None) or record.user_input
|
||||
if len(description) > 20:
|
||||
@@ -512,12 +519,27 @@ class HistoryView:
|
||||
status = "✓ 成功" if record.success else "✗ 失败"
|
||||
duration = f"{record.duration_ms}ms"
|
||||
|
||||
self.tree.insert_with_checkbox('', tk.END, iid=record.task_id, values=(
|
||||
record.timestamp,
|
||||
description,
|
||||
status,
|
||||
duration
|
||||
))
|
||||
try:
|
||||
self.tree.insert_with_checkbox('', tk.END, iid=record.task_id, values=(
|
||||
record.timestamp,
|
||||
description,
|
||||
status,
|
||||
duration
|
||||
))
|
||||
inserted_ids.add(record.task_id)
|
||||
except tk.TclError as e:
|
||||
# 如果ID已存在,使用带时间戳的唯一ID
|
||||
if "already exists" in str(e):
|
||||
unique_id = f"{record.task_id}_{len(inserted_ids)}"
|
||||
self.tree.insert_with_checkbox('', tk.END, iid=unique_id, values=(
|
||||
record.timestamp,
|
||||
description,
|
||||
status,
|
||||
duration
|
||||
))
|
||||
inserted_ids.add(unique_id)
|
||||
else:
|
||||
raise
|
||||
|
||||
# 更新统计信息
|
||||
self._update_stats()
|
||||
|
||||
Reference in New Issue
Block a user