## Summary What changed and why? ## Change Type - [ ] Cowork feature - [ ] Bug fix - [ ] Core AI contribution - [ ] Test / hardening - [ ] Performance - [ ] Documentation ## Related Work Cowork Task: Core Repo: http://34.143.229.138/gitea-admin/fsg-ai-core-assets Core AI Issue: Core Task: Related PR: ## Scope What is intentionally included? What is intentionally NOT included? ## Validation - [ ] Unit tests - [ ] Integration tests - [ ] Manual verification - [ ] Regression check Commands / evidence: ## Security Impact Permission / credential / network / customer data impact: ## Compatibility - [ ] No breaking change - [ ] Breaking change documented ## Reviewer Notes Anything Cowork reviewers should pay attention to. --------- Co-authored-by: thanhnv <thanhnv.ip@gmail.com> Co-authored-by: Vu Dam Tuan <vudt15@fpt.com> Reviewed-on: #9
This commit was merged in pull request #9.
This commit is contained in:
@@ -199,6 +199,14 @@ class _NodeItem(QGraphicsObject):
|
||||
e.accept()
|
||||
return
|
||||
super().mousePressEvent(e)
|
||||
if self.isSelected():
|
||||
# itemChange() only emits node_selected when the SELECTION STATE
|
||||
# actually flips (ItemSelectedHasChanged) — clicking a node that
|
||||
# was already selected (e.g. left selected when a run started)
|
||||
# never re-fires it, so the property panel silently kept showing
|
||||
# stale data and looked "locked" while the node ran. Emit
|
||||
# explicitly on every click so the panel always reloads.
|
||||
self.canvas.node_selected.emit(self.node.id)
|
||||
|
||||
def mouseMoveEvent(self, e):
|
||||
"""Rê chuột trong lúc kéo nối: vẽ lại đường nét đứt theo con trỏ."""
|
||||
|
||||
@@ -273,6 +273,15 @@ class Co4ECanvas(_CanvasInteractionMixin, QGraphicsView):
|
||||
item.status = status
|
||||
item.update()
|
||||
|
||||
def node_status(self, node_id: str) -> str:
|
||||
"""Trạng thái chạy hiện tại của một node — "idle" nếu không tìm thấy.
|
||||
|
||||
Dùng để quyết định có khóa bảng thuộc tính bên phải hay không khi
|
||||
người dùng chọn node (xem ``StepConfigPanel.set_locked``).
|
||||
"""
|
||||
item = self._nodes.get(node_id)
|
||||
return item.status if item is not None else "idle"
|
||||
|
||||
def reset_statuses(self) -> None:
|
||||
"""Đưa mọi node về trạng thái chờ — gọi trước mỗi lần chạy lại luồng."""
|
||||
for it in self._nodes.values():
|
||||
|
||||
@@ -101,6 +101,11 @@ class Co4EFlowTabsMixin:
|
||||
self.center_stack.setCurrentIndex(1)
|
||||
self._sync_runs_toggle(False)
|
||||
self._apply_workflow(self._flows[flow_idx])
|
||||
# _apply_workflow() rebuilds the canvas from wf.nodes/edges, which
|
||||
# resets every node's live status to "idle" — without this, coming
|
||||
# back to a flow that's still running (e.g. from the Runs page)
|
||||
# shows every node as idle even though it's actually mid-run.
|
||||
self._reflect_active_run(self._flows[flow_idx].id)
|
||||
def _sync_runs_toggle(self, on: bool) -> None:
|
||||
"""Keep the Runs toggle showing which page is up, however it got there
|
||||
(a double-click in the runs table also switches pages)."""
|
||||
|
||||
@@ -17,6 +17,7 @@ from PySide6.QtWidgets import QInputDialog, QMenu, QMessageBox, QTableWidget, QT
|
||||
from ...core import co4e
|
||||
from ...i18n import tr
|
||||
from ...theme import current_palette
|
||||
from .co4e_workflow_crud import _LOCKED_NODE_STATUSES
|
||||
|
||||
|
||||
class Co4ERunsMixin:
|
||||
@@ -155,7 +156,14 @@ class Co4ERunsMixin:
|
||||
t = ev.get("type")
|
||||
if t == "node_status":
|
||||
if shown:
|
||||
self.canvas.update_node_status(ev.get("node_id"), ev.get("status"))
|
||||
nid = ev.get("node_id")
|
||||
self.canvas.update_node_status(nid, ev.get("status"))
|
||||
# If the panel is showing THIS node right now (e.g. it was
|
||||
# idle and the user had it open when the run started), keep
|
||||
# the lock in sync instead of waiting for the next click.
|
||||
if nid == getattr(self.config, "_node_id", None):
|
||||
self.config.set_locked(
|
||||
self.canvas.node_status(nid) in _LOCKED_NODE_STATUSES)
|
||||
elif t == "node_output":
|
||||
if run_wf is not None:
|
||||
self._outputs_for(run_wf)[ev["node_id"]] = ev.get("output", "")
|
||||
|
||||
@@ -10,10 +10,13 @@ from typing import List, Optional
|
||||
from PySide6.QtCore import QSize, Qt
|
||||
from PySide6.QtWidgets import QInputDialog, QMenu
|
||||
from ...core import co4e
|
||||
from ...core.co4e import STEP_DONE, STEP_RUNNING
|
||||
from ...i18n import tr
|
||||
from ...ui.icons import icon
|
||||
from ...presentation.co4e.co4e_chat_view import _skill_names
|
||||
|
||||
_LOCKED_NODE_STATUSES = (STEP_RUNNING, STEP_DONE)
|
||||
|
||||
|
||||
class Co4EWorkflowCrudMixin:
|
||||
"""Phần tạo/mở/lưu/xoá luồng của Co4E Studio.
|
||||
@@ -163,10 +166,15 @@ class Co4EWorkflowCrudMixin:
|
||||
self.canvas.add_palette_step(co4e.Step(label="New Step"),
|
||||
self.canvas.mapToScene(self.canvas.rect().center()))
|
||||
def _on_node_selected(self, node_id: str) -> None:
|
||||
"""Chọn một node thì nạp bước đó vào bảng thuộc tính, tự mở bảng nếu đang gập."""
|
||||
"""Chọn một node thì nạp bước đó vào bảng thuộc tính, tự mở bảng nếu đang gập.
|
||||
|
||||
Bước đang chạy hoặc đã chạy xong thì khoá ô nhập liệu ngay khi nạp —
|
||||
tránh sửa nhầm cấu hình của lần chạy đang xem kết quả.
|
||||
"""
|
||||
for n in self.canvas.nodes():
|
||||
if n.id == node_id:
|
||||
self.config.load_step(node_id, n.data, _skill_names())
|
||||
self.config.set_locked(self.canvas.node_status(node_id) in _LOCKED_NODE_STATUSES)
|
||||
if self._config_collapsed:
|
||||
self._toggle_config()
|
||||
return
|
||||
|
||||
@@ -38,7 +38,7 @@ from PySide6.QtWidgets import (
|
||||
)
|
||||
|
||||
from ...config import PROVIDER_LABELS
|
||||
from ...core.co4e import PERMISSION_PRESETS, Step
|
||||
from ...core.co4e import PERMISSION_PRESETS, STEP_DONE, STEP_RUNNING, Step
|
||||
from ...i18n import tr
|
||||
from ...ui.icons import icon, icon_picker_combo
|
||||
from .node_property_actions_mixin import _StepConfigActionsMixin
|
||||
@@ -65,6 +65,8 @@ class StepConfigPanel(_StepConfigActionsMixin, QScrollArea):
|
||||
self._step: Optional[Step] = None
|
||||
self._node_id = ""
|
||||
self._loading = False
|
||||
self._ctx_available = ctx is not None
|
||||
self._locked = False
|
||||
self.setWidgetResizable(True)
|
||||
host = QWidget()
|
||||
self.setWidget(host)
|
||||
@@ -281,6 +283,27 @@ class StepConfigPanel(_StepConfigActionsMixin, QScrollArea):
|
||||
self.sub_list.addItem(sub.agent)
|
||||
self._loading = False
|
||||
|
||||
def set_locked(self, locked: bool) -> None:
|
||||
"""Khoá/mở khoá các trường chỉnh sửa theo trạng thái chạy của bước.
|
||||
|
||||
Bước đang chạy hoặc đã chạy xong thì khoá lại — tránh sửa nhầm cấu
|
||||
hình trong lúc đang xem kết quả của chính lần chạy đó (sửa xong
|
||||
không rõ là áp dụng cho lần chạy đã xong hay lần chạy tiếp theo).
|
||||
Nút Chạy/Chạy từ đây/Xoá bước vẫn hoạt động bình thường khi khoá —
|
||||
chỉ ô nhập liệu bị khoá, không phải cả panel.
|
||||
"""
|
||||
self._locked = locked
|
||||
editable = not locked
|
||||
for w in (self.label_edit, self.role_edit, self.icon_edit,
|
||||
self.instructions_edit, self.context_edit,
|
||||
self.model_combo, self.perm_combo, self.verify_chk,
|
||||
self.rounds_spin, self.skills_list,
|
||||
self.attach_add_btn, self.attach_del_btn,
|
||||
self.sub_add_btn, self.sub_del_btn, self.sub_list):
|
||||
w.setEnabled(editable)
|
||||
self.gen_btn.setEnabled(editable and self._ctx_available)
|
||||
self.load_models_btn.setEnabled(editable and self._ctx_available)
|
||||
|
||||
def clear_step(self) -> None:
|
||||
"""Xoá bảng khi không có bước nào được chọn."""
|
||||
self._step = None
|
||||
|
||||
@@ -21,9 +21,9 @@ from __future__ import annotations
|
||||
from typing import List, Optional
|
||||
|
||||
from PySide6.QtWidgets import (
|
||||
QComboBox, QHBoxLayout, QLabel, QLineEdit, QPushButton, QVBoxLayout, QWidget,
|
||||
QComboBox, QHBoxLayout, QLabel, QPlainTextEdit, QPushButton, QVBoxLayout, QWidget,
|
||||
)
|
||||
from PySide6.QtCore import Signal
|
||||
from PySide6.QtCore import Qt, Signal
|
||||
|
||||
from cowork_local.i18n import on_language_changed, tr
|
||||
from cowork_local.presentation.folder.ai_edit_model_resolver import AiEditModelResolver
|
||||
@@ -32,6 +32,45 @@ from cowork_local.theme import current_palette
|
||||
from cowork_local.ui.chat_view import ChatView
|
||||
|
||||
|
||||
class _AutoExpandInput(QPlainTextEdit):
|
||||
"""Instruction box: grows with content (1..~6 lines, then scrolls), Enter
|
||||
submits, Shift+Enter inserts a newline — same convention as the Cowork
|
||||
composer (``presentation/chat/chat_input_box.py::_Input``), minus its
|
||||
``/skill``/``/agent`` popups and drag-drop attachment handling, which
|
||||
don't apply to a single AI-edit instruction. DF-008: a fixed-height
|
||||
single-line ``QLineEdit`` read as cramped for a full instruction; this
|
||||
replaces it instead of just nudging the height up further."""
|
||||
|
||||
submit = Signal()
|
||||
|
||||
MIN_HEIGHT = 36 # matches the old QLineEdit's bumped-up height
|
||||
MAX_HEIGHT = 140 # ~6 lines, then it scrolls instead of growing further
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setTabChangesFocus(True) # Tab moves focus, doesn't insert a tab
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
self.textChanged.connect(self._adjust_height)
|
||||
self._adjust_height()
|
||||
|
||||
def _adjust_height(self) -> None:
|
||||
# QPlainTextEdit reports the document height in LINES, not pixels —
|
||||
# convert via line spacing (same approach as chat_input_box.py).
|
||||
lines = self.document().size().height() or 1
|
||||
line_px = self.fontMetrics().lineSpacing()
|
||||
h = int(lines * line_px + 2 * self.frameWidth() + 12)
|
||||
h = max(self.MIN_HEIGHT, min(self.MAX_HEIGHT, h))
|
||||
if h != self.height():
|
||||
self.setFixedHeight(h)
|
||||
|
||||
def keyPressEvent(self, e) -> None: # noqa: N802
|
||||
if e.key() in (Qt.Key_Return, Qt.Key_Enter) and not (e.modifiers() & Qt.ShiftModifier):
|
||||
self.submit.emit()
|
||||
return
|
||||
super().keyPressEvent(e)
|
||||
|
||||
|
||||
class AiFileEditorDialog(QWidget):
|
||||
"""Collapsible panel: a Cowork-style inline chat timeline, this panel's
|
||||
OWN model picker + routing toggle, an instruction box, and an Apply/
|
||||
@@ -94,9 +133,9 @@ class AiFileEditorDialog(QWidget):
|
||||
ctx, self.ai_model_combo, self.ai_chat.add_status, self._confirm_routing_switch)
|
||||
|
||||
row = QHBoxLayout()
|
||||
self.ai_input = QLineEdit()
|
||||
self.ai_input = _AutoExpandInput()
|
||||
self.ai_input.setPlaceholderText(tr("folder.ai_placeholder"))
|
||||
self.ai_input.returnPressed.connect(self._ai_send)
|
||||
self.ai_input.submit.connect(self._ai_send)
|
||||
row.addWidget(self.ai_input, 1)
|
||||
self.ai_send_btn = QPushButton(tr("folder.ai_send"))
|
||||
self.ai_send_btn.setObjectName("primary")
|
||||
@@ -170,7 +209,7 @@ class AiFileEditorDialog(QWidget):
|
||||
if not self.preview.root:
|
||||
self.ai_chat.add_error(tr("folder.ai_no_file"))
|
||||
return
|
||||
instruction = self.ai_input.text().strip()
|
||||
instruction = self.ai_input.toPlainText().strip()
|
||||
if not instruction:
|
||||
return
|
||||
self.ai_input.clear()
|
||||
|
||||
@@ -10,6 +10,7 @@ the ``status_message`` signal, ``select_subtab(index)``, ``nav_subtabs()``,
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date, timedelta
|
||||
from typing import List
|
||||
|
||||
from PySide6.QtCore import QTimer, Signal
|
||||
@@ -25,11 +26,24 @@ from .tabs.overview_tab import OverviewTab
|
||||
from .tabs.security_events_tab import SecurityEventsTab
|
||||
|
||||
_REFRESH_MS = 3000
|
||||
# Comfortably larger than any realistic audit-log size — the event tables
|
||||
# have never had pagination controls, so every tab still shows "all matching
|
||||
# events" exactly like before; MonitoringQueryService's pagination support
|
||||
# is exercised for real here, just not surfaced as UI (yet).
|
||||
# Comfortably larger than any realistic audit-log size for the WINDOW of
|
||||
# events _load_events() now actually reads (see _LOG_WINDOW_DAYS below) — this
|
||||
# is MonitoringQueryService's query-side page size, kept unbounded so it
|
||||
# always returns every matching event within the window; the user-facing
|
||||
# "Số dòng/trang" control (DF-006 — see shared/event_table.py::set_page_size,
|
||||
# shared/filter_scaffold.py::build_filter_scaffold's with_page_size) trims
|
||||
# that down for DISPLAY, client-side, per event tab.
|
||||
_UNBOUNDED_PAGE_SIZE = 100_000
|
||||
# _load_events() re-reads the audit log from disk every _REFRESH_MS (3s) via
|
||||
# _auto_refresh(), and audit_log.load_events()/load_shared_audit_events() are
|
||||
# day-sharded JSONL — unbounded start/end means EVERY day file ever written
|
||||
# gets re-read and re-parsed on EVERY tick, which is what actually made
|
||||
# Monitoring "gây nặng khi log lớn" (see DF-006): the slowness was never in
|
||||
# rendering (EventTable already caps display at 300 rows — see
|
||||
# shared/event_table.py::_MAX_ROWS), it was this repeated full-history read.
|
||||
# 30 days is a live-monitoring window, not a hard retention limit — nothing
|
||||
# is deleted, older days are simply not re-read on every 3s tick.
|
||||
_LOG_WINDOW_DAYS = 30
|
||||
|
||||
|
||||
class MonitoringTab(QWidget):
|
||||
@@ -259,14 +273,20 @@ class MonitoringTab(QWidget):
|
||||
|
||||
Có cấu hình thư mục chia sẻ VÀ đọc ra được dữ liệu thì dùng nó, để cả đội
|
||||
nhìn chung một bức tranh; rỗng thì rơi về nhật ký của máy này.
|
||||
|
||||
Chỉ đọc ``_LOG_WINDOW_DAYS`` ngày gần nhất — cả hai nguồn đều lưu theo
|
||||
file JSONL từng ngày, nên bounding ở đây tránh việc đọc lại TOÀN BỘ
|
||||
lịch sử mỗi 3 giây (xem ``_auto_refresh``), là nguyên nhân thật của
|
||||
DF-006 (gây nặng khi log lớn).
|
||||
"""
|
||||
start = date.today() - timedelta(days=_LOG_WINDOW_DAYS)
|
||||
shared_dir = self.ctx.config.shared_dir
|
||||
if shared_dir:
|
||||
from ...core import telemetry_shared
|
||||
shared_events = telemetry_shared.load_shared_audit_events(shared_dir)
|
||||
shared_events = telemetry_shared.load_shared_audit_events(shared_dir, start=start)
|
||||
if shared_events:
|
||||
return shared_events
|
||||
return audit_log.load_events()
|
||||
return audit_log.load_events(start=start)
|
||||
|
||||
def _apply_events_to_event_tabs(self, events: List[dict]) -> None:
|
||||
"""Filters the ALREADY-LOADED event list (see ``_load_events`` — one
|
||||
|
||||
@@ -18,6 +18,7 @@ from .badges import action_label
|
||||
from .formatters import agent_avatar_icon, fmt_event_time
|
||||
|
||||
_MAX_ROWS = 300
|
||||
PAGE_SIZE_OPTIONS = (50, 100, 300, 500, 1000)
|
||||
|
||||
|
||||
class _TimeItem(QTableWidgetItem):
|
||||
@@ -70,6 +71,8 @@ class EventTable(QTableWidget):
|
||||
là thất bại nên cột ấy chỉ tốn chỗ.
|
||||
"""
|
||||
self._show_result = show_result
|
||||
self._page_size = _MAX_ROWS
|
||||
self._last_events: List[dict] = []
|
||||
super().__init__(0, 7 if show_result else 6)
|
||||
self.setEditTriggers(QTableWidget.NoEditTriggers)
|
||||
self.setSelectionBehavior(QTableWidget.SelectRows)
|
||||
@@ -98,13 +101,25 @@ class EventTable(QTableWidget):
|
||||
cols += [tr("monitoring.col_detail_block") if not self._show_result else tr("monitoring.col_detail")]
|
||||
self.setHorizontalHeaderLabels(cols)
|
||||
|
||||
def page_size(self) -> int:
|
||||
"""Số dòng đang hiển thị mỗi trang."""
|
||||
return self._page_size
|
||||
|
||||
def set_page_size(self, n: int) -> None:
|
||||
"""Đổi số dòng hiển thị mỗi trang rồi vẽ lại với dữ liệu đã có sẵn
|
||||
(không cần refresh lại từ nguồn — set_events() đã lưu lại lần đổ gần nhất)."""
|
||||
self._page_size = n
|
||||
self.set_events(self._last_events)
|
||||
|
||||
def set_events(self, events: List[dict]) -> None:
|
||||
"""Đổ danh sách sự kiện vào bảng: mới nhất lên đầu, cắt ở ``_MAX_ROWS``.
|
||||
"""Đổ danh sách sự kiện vào bảng: mới nhất lên đầu, cắt ở ``self._page_size``
|
||||
(đổi được qua ``set_page_size`` — control "Số dòng/trang" ở filter_scaffold.py).
|
||||
|
||||
Tắt sắp xếp trong lúc đổ dữ liệu — để bật, Qt sắp lại sau mỗi dòng và việc
|
||||
nạp chậm đi theo bậc hai.
|
||||
"""
|
||||
events = sorted(events, key=lambda e: e.get("ts", ""), reverse=True)[:_MAX_ROWS]
|
||||
self._last_events = events
|
||||
events = sorted(events, key=lambda e: e.get("ts", ""), reverse=True)[:self._page_size]
|
||||
self.setSortingEnabled(False)
|
||||
self.setRowCount(len(events))
|
||||
for row, ev in enumerate(events):
|
||||
|
||||
@@ -16,13 +16,13 @@ from typing import Callable, Dict, Optional
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtGui import QKeySequence, QShortcut
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication, QHBoxLayout, QLabel, QLineEdit, QPushButton, QSplitter,
|
||||
QTableWidget, QVBoxLayout, QWidget,
|
||||
QApplication, QComboBox, QHBoxLayout, QLabel, QLineEdit, QPushButton,
|
||||
QSplitter, QTableWidget, QVBoxLayout, QWidget,
|
||||
)
|
||||
|
||||
from ....i18n import tr
|
||||
from ....ui.icons import icon
|
||||
from .event_table import ClickOutsideCloser, EventTable
|
||||
from .event_table import PAGE_SIZE_OPTIONS, ClickOutsideCloser, EventTable
|
||||
from .event_detail_panel import EventDetailPanel
|
||||
|
||||
|
||||
@@ -47,11 +47,12 @@ def _sync_event_detail(table: EventTable, panel: EventDetailPanel) -> None:
|
||||
def build_filter_scaffold(
|
||||
page: QWidget, table: QTableWidget, *, on_refresh: Callable[[], None],
|
||||
title_key: Optional[str] = None, with_search: bool = True,
|
||||
with_detail: bool = False,
|
||||
with_detail: bool = False, with_page_size: bool = False,
|
||||
on_ai_filter: Optional[Callable[[QLineEdit, QPushButton], None]] = None,
|
||||
) -> Dict[str, object]:
|
||||
"""Dựng khung chung cho một tab sự kiện: tiêu đề, nút làm mới, ô tìm kiếm,
|
||||
nút lọc bằng AI và panel chi tiết.
|
||||
nút lọc bằng AI, control "Số dòng/trang" (nếu ``with_page_size``) và panel
|
||||
chi tiết.
|
||||
|
||||
Bốn tab sự kiện của màn Giám sát chỉ khác nhau ở nguồn dữ liệu, nên phần vỏ
|
||||
này được dựng một lần và dùng chung.
|
||||
@@ -88,6 +89,23 @@ def build_filter_scaffold(
|
||||
ai_btn.clicked.connect(lambda: on_ai_filter(search, ai_btn))
|
||||
row.addWidget(search, 1)
|
||||
row.addWidget(ai_btn)
|
||||
if with_page_size and isinstance(table, EventTable):
|
||||
# DF-006: the item-per-page count was never surfaced anywhere in
|
||||
# the UI (design called for it) — EventTable already trims to a
|
||||
# page size internally (default 300), this just makes that
|
||||
# number visible AND user-choosable instead of a fixed constant.
|
||||
page_size_lbl = QLabel(tr("monitoring.page_size_label"))
|
||||
page_size_combo = QComboBox()
|
||||
for n in PAGE_SIZE_OPTIONS:
|
||||
page_size_combo.addItem(str(n), n)
|
||||
current = table.page_size()
|
||||
page_size_combo.setCurrentIndex(
|
||||
PAGE_SIZE_OPTIONS.index(current) if current in PAGE_SIZE_OPTIONS else 2)
|
||||
page_size_combo.currentIndexChanged.connect(
|
||||
lambda i: table.set_page_size(page_size_combo.itemData(i)))
|
||||
row.addWidget(page_size_lbl)
|
||||
row.addWidget(page_size_combo)
|
||||
parts.update(page_size_label=page_size_lbl, page_size_combo=page_size_combo)
|
||||
lay.addLayout(row)
|
||||
parts.update(filter_edit=search, ai_filter_btn=ai_btn)
|
||||
|
||||
|
||||
@@ -25,13 +25,15 @@ class ActionLogsTab(QWidget):
|
||||
parts = build_filter_scaffold(
|
||||
self, self.table, on_refresh=on_refresh_all,
|
||||
title_key="monitoring.action_logs_title",
|
||||
with_search=True, with_detail=True, on_ai_filter=self._start_ai_filter)
|
||||
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."""
|
||||
@@ -44,6 +46,7 @@ class ActionLogsTab(QWidget):
|
||||
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."""
|
||||
|
||||
@@ -25,13 +25,15 @@ class McpTab(QWidget):
|
||||
parts = build_filter_scaffold(
|
||||
self, self.table, on_refresh=on_refresh_all,
|
||||
title_key="monitoring.mcp_history_title",
|
||||
with_search=True, with_detail=True, on_ai_filter=self._start_ai_filter)
|
||||
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."""
|
||||
@@ -44,6 +46,7 @@ class McpTab(QWidget):
|
||||
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."""
|
||||
|
||||
@@ -31,13 +31,15 @@ class SecurityEventsTab(QWidget):
|
||||
parts = build_filter_scaffold(
|
||||
self, self.table, on_refresh=on_refresh_all,
|
||||
title_key="monitoring.security_events_title",
|
||||
with_search=True, with_detail=True, on_ai_filter=self._start_ai_filter)
|
||||
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."""
|
||||
@@ -50,6 +52,7 @@ class SecurityEventsTab(QWidget):
|
||||
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."""
|
||||
|
||||
@@ -212,6 +212,11 @@ class MainWindow(NavRailMixin, RailProjectMixin, TopBarMixin,
|
||||
self._set_nav_width_range(_NAV_MIN_WIDTH, self._nav_max_width())
|
||||
# Keep the floating Help assistant pinned to the bottom-right corner.
|
||||
if getattr(self, "help_agent", None) is not None:
|
||||
# The Cowork composer can wrap an extra control row as the window
|
||||
# narrows/widens, which changes how much bottom guard the dock
|
||||
# needs — recompute it on every resize, not just reposition with
|
||||
# whatever guard height was last measured at tab-entry time.
|
||||
self._update_dock_guard()
|
||||
self.help_agent.reposition()
|
||||
|
||||
def showEvent(self, event): # noqa: N802 - Qt override
|
||||
|
||||
@@ -81,7 +81,7 @@ class NavRailMixin:
|
||||
# 16px icon up with the nav items' icons below (1px list frame + item
|
||||
# padding) — same indent level, same icon size as e.g. Dashboard.
|
||||
toggle_row = QHBoxLayout()
|
||||
toggle_row.setContentsMargins(0, 8, 10, 8)
|
||||
toggle_row.setContentsMargins(10, 8, 10, 8)
|
||||
toggle_row.addWidget(self._nav_toggle_btn, 0, Qt.AlignLeft)
|
||||
toggle_row.addStretch(1)
|
||||
nvl.addLayout(toggle_row)
|
||||
@@ -111,7 +111,7 @@ class NavRailMixin:
|
||||
self.nav_project_btn.menu().aboutToShow.connect(self._fill_rail_project_menu)
|
||||
self.nav_project_btn.setVisible(False)
|
||||
head = QVBoxLayout()
|
||||
head.setContentsMargins(6, 0, 6, 6)
|
||||
head.setContentsMargins(10, 0, 10, 6)
|
||||
head.setSpacing(6)
|
||||
head.addWidget(self.nav_project)
|
||||
head.addWidget(self.nav_project_btn)
|
||||
@@ -136,7 +136,7 @@ class NavRailMixin:
|
||||
self._nav_scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
scroll_body = QWidget()
|
||||
sv = QVBoxLayout(scroll_body)
|
||||
sv.setContentsMargins(0, 0, 0, 0)
|
||||
sv.setContentsMargins(6, 0, 6, 0)
|
||||
sv.setSpacing(0)
|
||||
sv.addWidget(self.nav, 0)
|
||||
# RECENTS — the threads of the project named in the picker above, right
|
||||
|
||||
@@ -13,7 +13,7 @@ from PySide6.QtWidgets import QStyledItemDelegate
|
||||
# ---- kích thước ---------------------------------------------------------
|
||||
_NAV_EXPANDED_WIDTH = 150
|
||||
_NAV_COLLAPSED_WIDTH = 54
|
||||
_NAV_ROW_INSET = 4
|
||||
_NAV_ROW_INSET = 8
|
||||
_NAV_ROW_GAP = 6
|
||||
_NAV_MIN_WIDTH = 132
|
||||
_NAV_MAX_SHARE = 0.22
|
||||
|
||||
Reference in New Issue
Block a user