Lane N3 (Co4E Studio) — dùng bộ workflow refactor-god-file, mỗi bước có characterization test trước khi tách, hậu kiểm ranh giới tầng sau mỗi bước: - skills_list_panel.py / agent_list_panel.py — 2 khu vực sidebar - co4e_canvas_widget.py + canvas_items.py + canvas_interaction_mixin.py — Co4ECanvas tách 3 file (vượt 400 dòng nếu đứng một mình) - node_property_panel.py + node_property_actions_mixin.py + step_config_section.py — StepConfigPanel, cùng lý do - co4e_run_control_widget.py — RunsPagePanel (trang Flow Status) - co4e_chat_view.py — ChatPanel + _ChatInput + helper autocomplete - palette_list.py — _PaletteList dời khỏi ui/co4e_tab.py, hết import ngược presentation -> ui (agent/skills panel giờ import top-level) ui/co4e_tab.py giảm 2089 -> 1878 dòng, chỉ còn phần wiring + business logic (Co4ERunManager/AgentWorker chưa đổi — nằm ngoài phạm vi này, xem docstring presentation/co4e/co4e_tab.py). ui/co4e_canvas.py và ui/co4e_config_panel.py còn lại là compat shim re-export, không đổi API cho bên gọi. Thêm tests/test_co4e_integration.py — dựng thật Co4ETab qua build_co4e_tab(), lái luồng qua nhiều panel trong cùng instance (thêm node, mở/gập chat, chuyển trang Flow Status rồi quay lại không mất state canvas) — bắt lỗi wiring xuyên-panel mà characterization test từng panel riêng không thấy được. Đã xác minh: pytest 348 passed/1 skipped, tools/check_co4e.py sạch, không file nào >400 dòng, domain/application không import PySide6, và so pixel before/after (git worktree tại HEAD cũ) ra 0/1.125.000 pixel khác biệt. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
39 lines
2.4 KiB
Python
39 lines
2.4 KiB
Python
"""Co4E node canvas — a QGraphicsView node-graph editor.
|
|
|
|
Renders workflow nodes as draggable cards and edges as rounded orthogonal
|
|
("elbow with rounded corners") arrows. Supports: drag to move (positions
|
|
persist), click to select (→ right config panel), drag-to-connect from a node's
|
|
output port (bottom) to another node, a context-menu "connect" mode, "add step
|
|
below" (auto-connected child), delete, zoom (Ctrl+wheel / buttons), auto-fit,
|
|
and drops from the sidebar palette (agent/skill/parallel/whole-flow) via the
|
|
``application/x-co4e-step`` mime type.
|
|
|
|
Kept UI-only; the graph model lives in ``core/co4e.py``.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
# _NodeItem/_EdgeItem (hằng số vẽ + hai lớp QGraphicsItem) đã dời sang
|
|
# presentation/co4e/canvas_items.py; Co4ECanvas (mutation đồ thị) đã dời sang
|
|
# presentation/co4e/co4e_canvas_widget.py, phần tương tác view (zoom/pan/
|
|
# relayout/phím tắt/kéo-thả) nằm trong _CanvasInteractionMixin cùng thư mục.
|
|
# Không đổi hành vi — xem characterization test cùng tên và docstring ở từng
|
|
# file đích. Import ĐÍCH DANH tên gốc, không alias — nếu đổi thành
|
|
# `import co4e_canvas_widget as _w` thì các chỗ gọi bên dưới (và cả test cũ)
|
|
# vẫn chạy được vì Python cho phép, nhưng lại sai mục đích của việc giữ nguyên
|
|
# tên: test characterization import trực tiếp các tên này TỪ module này,
|
|
# alias sẽ làm test đó ngưng chứng minh được điều nó cần chứng minh.
|
|
from ..presentation.co4e.canvas_items import (
|
|
_NODE_H, _NODE_W, _PORT_HIT, _PORT_R, _EdgeItem, _NodeItem, _status_color,
|
|
)
|
|
# 8 hàm hình học thuần đã dời sang canvas_geometry.py (không đổi hành vi, xem
|
|
# characterization test cùng tên). Import ĐÍCH DANH tên gốc, không alias — nếu
|
|
# đổi thành `import canvas_geometry as _g` thì các chỗ gọi bên dưới (và cả
|
|
# test cũ) vẫn chạy được vì Python cho phép, nhưng lại sai mục đích của việc
|
|
# giữ nguyên tên: test characterization import trực tiếp các tên này TỪ module
|
|
# này, alias sẽ làm test đó ngưng chứng minh được điều nó cần chứng minh.
|
|
from ..presentation.co4e.canvas_geometry import (
|
|
_dist, _elide, _hits, _ortho_path, _route, _rounded_path, _seg_hits_rect,
|
|
_towards,
|
|
)
|
|
from ..presentation.co4e.co4e_canvas_widget import Co4ECanvas, CO4E_MIME
|