Batch of fixes for defects tracked in "Task Tracking Template.xlsx" (sheet Defect Management), verified against the sheet's Root Cause/Cach xu ly columns before this commit: - DF-002: Co4E node status not reflected after tab switch + missing edit-lock on running/done nodes (node_property_panel.py, co4e_runs.py, co4e_workflow_crud.py, co4e_canvas_widget.py, co4e_flow_tabs.py, canvas_items.py) - DF-003: hide the run.bat console window unless the app exits with an error (run.bat, scripts/console_visibility.ps1 - new) - DF-004: floating Help Assistant icon covering the Send button after a window resize (presentation/shell/main_window.py) - DF-005: "block network" toggle didn't stop ICMP/raw-socket tools like ping (infrastructure/filesystem/command_tools.py, security/command_risk_classifier.py) - DF-006: Monitoring "gay nang khi log lon" - root cause was re-reading the ENTIRE audit log history every 3s tick, not missing pagination; bounded to a 30-day window (presentation/monitoring/monitoring_tab.py) AND added the "So dong/trang" page-size control the ticket also asked for (presentation/monitoring/shared/event_table.py, shared/filter_scaffold.py, tabs/action_logs_tab.py, tabs/mcp_tab.py, tabs/security_events_tab.py, i18n/agents_admin_tab.py) - DF-007: support choosing a OneDrive/SharePoint folder as a project's working directory via Microsoft Graph, downloaded as a local mirror with manual sync (core/projects.py, core/ms365_graph.py, core/cloud_workspace_sync.py - new, ui/ms365_signin_dialog.py - new, ui/cloud_folder_picker_dialog.py - new, i18n/cloud_workspace.py - new, ui/workspace_tab.py) - DF-008: AI-edit instruction box was a fixed-height single-line QLineEdit; replaced with an auto-expanding, Enter-to-send/Shift+Enter-newline input (presentation/folder/ai_file_editor_dialog.py) - DF-011: run_command failed with WinError 267 for a project whose per-turn output directory had never been created (application/conversations/core_runtime_adapter.py) DF-009 (AI-edit Apply/Discard buttons easy to miss) and DF-010 (AI reply language - dev-confirmed not a bug) are intentionally NOT part of this commit: DF-009 has no code fix yet (still "Assigned" in the sheet, only a UX recommendation was recorded), DF-010 was rejected as expected behavior. Tests: tests/test_cloud_workspace_sync.py, tests/test_ms365_cloud_dialogs.py, tests/test_ai_file_editor_input.py, tests/test_monitoring_page_size.py (all new, all passing). Full suite: 896 passed, 13 known-and-documented failures unrelated to this change (an existing core/audit_log.py bug, this checkout not being a git repo before now, and a repo/subprocess folder-naming mismatch affecting ~66 characterization tests) - see the sheet's DF-006 Evidence column for details.
54 lines
2.3 KiB
Python
54 lines
2.3 KiB
Python
"""MCP Call History tab — the audit log filtered to ``kind="mcp_call"``.
|
|
Extracted from ``ui/monitoring_tab.py``'s MCP-table wiring inside
|
|
``MonitoringTab.__init__``.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Callable, List
|
|
|
|
from PySide6.QtWidgets import QLineEdit, QPushButton, QWidget
|
|
|
|
from ....i18n import tr
|
|
from ..shared.ai_filter import start_ai_filter
|
|
from ..shared.event_table import EventTable
|
|
from ..shared.filter_scaffold import build_filter_scaffold
|
|
|
|
|
|
class McpTab(QWidget):
|
|
"""Tab "Lịch sử MCP": bảng các lượt gọi tool MCP kèm độ trễ và kết quả."""
|
|
def __init__(self, ctx, on_refresh_all: Callable[[], None]):
|
|
"""Tab Lịch sử MCP: bảng sự kiện kèm bộ lọc dùng chung."""
|
|
super().__init__()
|
|
self._ctx = ctx
|
|
self._ai_state: dict = {}
|
|
self.table = EventTable()
|
|
parts = build_filter_scaffold(
|
|
self, self.table, on_refresh=on_refresh_all,
|
|
title_key="monitoring.mcp_history_title",
|
|
with_search=True, with_detail=True, with_page_size=True,
|
|
on_ai_filter=self._start_ai_filter)
|
|
self.title_lbl = parts["title_lbl"]
|
|
self.title_key = parts["title_key"]
|
|
self.title_refresh_btn = parts["title_refresh_btn"]
|
|
self.filter_edit = parts["filter_edit"]
|
|
self.ai_filter_btn = parts["ai_filter_btn"]
|
|
self.detail_panel = parts["detail_panel"]
|
|
self.page_size_label = parts["page_size_label"]
|
|
|
|
def set_events(self, events: List[dict]) -> None:
|
|
"""Đổ danh sách sự kiện vào bảng."""
|
|
self.table.set_events(events)
|
|
|
|
def retranslate(self) -> None:
|
|
"""Áp lại chữ theo ngôn ngữ đang chọn."""
|
|
self.table.retranslate()
|
|
self.filter_edit.setPlaceholderText(tr("monitoring.filter_placeholder"))
|
|
self.detail_panel.retranslate()
|
|
self.title_lbl.setText(tr(self.title_key))
|
|
self.title_refresh_btn.setText(tr("monitoring.refresh"))
|
|
self.page_size_label.setText(tr("monitoring.page_size_label"))
|
|
|
|
def _start_ai_filter(self, search: QLineEdit, ai_btn: QPushButton) -> None:
|
|
"""Nhờ AI dịch câu tìm kiếm tự nhiên thành từ khoá lọc."""
|
|
start_ai_filter(self._ctx, search, ai_btn, self._ai_state)
|