fix-ui-restore-task-status-categories
Core regression / Python core and release configuration (push) Successful in 15s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 16s
Core regression / JavaScript syntax (pull_request) Successful in 4s

This commit is contained in:
阿白叔 committed 2026-11-03 11:02:27 +08:00
1 parent ba1d50cdfc
commit 63835afba8
6 files changed
+137 -7

No files matched your search

@@ -0,0 +1,17 @@
# Task status categories
The earlier task navigation retained a hidden, disconnected status selector. The visible selector below search now offers All tasks, Unfinished, Completed and Failed, with the existing SVG icon set. Unfinished includes Draft, Ready, Running, Paused and Failed; deleted tasks remain in the recycle bin.
Filtering operates on the cached task list and combines with search. Refreshing tasks reapplies the chosen category against the updated status. The current task is remembered when hidden, so changing display categories does not switch the right-hand task or discard its draft. The window retains the complete task collection for batch execution; filtering never narrows the execution scope. Moving tasks is disabled while a status filter hides part of the saved order.
The recycle bin ignores the normal status filter and disables that selector while open; returning restores the chosen category. The status selector is a display preference for this window and defaults to All tasks on a new launch.
Validation:
- Seven new cases first failed against the hidden/disconnected selector. They now cover category membership, combined search, completion on refresh, preserving task identity, cached reads, unchanged batch scope, ordering gates and recycle-bin independence.
- `python -m pytest -q tests/ui tests/v1_1/test_task_navigation.py --tb=short --junitxml=build/task-category-ui-tests.xml`: **181 passed**.
- After adding the status SVG icons, category and navigation tests: **9 passed**.
- `python tools/accept_acrylic_ui.py --output build/task-categories-final --webengine-roundtrip`: passed on Windows 11 build 26200 at 125% scaling, including status category visibility, return from Chromium, reduced transparency and the 980×700 layout.
- Python compilation and `git diff --check`: passed.
No DSH functionality or task execution implementation changed. No CAD or model requests were made. No release executable was built.
@@ -117,7 +117,6 @@ class TrialTaskCenterWindow(MaterialMainWindow):
self.resize(1280, 880)
self.setStyleSheet(APP_STYLESHEET)
self.task_list = TaskList(self.open_task)
self.task_list.filter.currentTextChanged.connect(self._refresh_task_list)
self.task_list.recycle_button.toggled.connect(self._refresh_task_list)
self.task_list.new_button.clicked.connect(self._new_task)
self.task_list.edit_button.clicked.connect(self._edit_task)
@@ -484,7 +483,8 @@ class TrialTaskCenterWindow(MaterialMainWindow):
self.project_summary.refresh_button.setEnabled(not busy and bool(
self._task_id if read_failed else context and not context.legacy))
self.task_list.list.setEnabled(not self._workers or self._batch_stop is not None)
self.task_list.filter.setEnabled(not self._workers or self._batch_stop is not None)
self.task_list.filter.setEnabled((not self._workers or self._batch_stop is not None)
and not self.task_list.recycle_button.isChecked())
self.task_list.search.setEnabled(not self._workers or self._batch_stop is not None)
self.task_list.recycle_button.setEnabled(not busy)
self.task_list.select_all_button.setEnabled(not busy and bool(self.task_list.list.count()))
@@ -508,8 +508,9 @@ class TrialTaskCenterWindow(MaterialMainWindow):
for button in (self.task_list.up_button, self.task_list.down_button):
button.setEnabled(grouped and not busy and not group_active
and self.task_list.sort.currentData() == 'execution'
and self.task_list.filter.currentData() == 'all'
and not self.task_list.search.text().strip())
button.setToolTip('清空搜索并切换到执行顺序后,可调整本批任务的执行位置。')
button.setToolTip('清空搜索、选择全部任务并切换到执行顺序后,可调整本批任务的执行位置。')
if not self._message:
self.run_panel.operator_band.setText(state.message)
if self._loading and not self._message:
@@ -79,9 +79,11 @@ class TaskList(QWidget):
self.recycle_button.setCheckable(True)
self.count = QLabel(objectName='taskCount')
self.filter = QComboBox(objectName="taskFilter")
self.filter.addItems(("进行中", "已完成", "已删除"))
self.filter.setVisible(False)
self.filter.setMaximumHeight(0)
for label, key, picture in (('全部任务', 'all', 'grid'), ('未完成', 'unfinished', 'clock'),
('已完成', 'completed', 'check-circle'), ('失败', 'failed', 'warning')):
self.filter.addItem(icon(picture), label, key)
self.filter.setAccessibleName('任务状态分类')
self.filter.setToolTip('未完成包括待配置、待执行、执行中、已暂停和失败的任务;分类只筛选显示。')
self.list = QListWidget(objectName="taskList")
self.list.setItemDelegate(TaskItemDelegate(self.list))
self.list.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
@@ -137,6 +139,7 @@ class TaskList(QWidget):
layout.setSpacing(11)
layout.addLayout(heading)
layout.addWidget(self.search)
layout.addWidget(self.filter)
layout.addLayout(batch)
layout.addLayout(selection)
layout.addWidget(self.list, 1)
@@ -152,6 +155,7 @@ class TaskList(QWidget):
self.select_all_button.clicked.connect(self.select_all_tasks)
self.clear_selection_button.clicked.connect(self.clear_task_selection)
self.search.textChanged.connect(self._render)
self.filter.currentIndexChanged.connect(self._render)
self.sort.currentIndexChanged.connect(self._render)
def current_task_id(self) -> str | None:
@@ -202,6 +206,11 @@ class TaskList(QWidget):
query = self.search.text().strip().casefold().replace('\\', '/')
tasks = [task for task in self._tasks if query in ' '.join(str(getattr(task, name, '') or '')
for name in ('name', 'discovery_root', 'note')).casefold().replace('\\', '/')]
category = self.filter.currentData()
if not self.recycle_button.isChecked() and category != 'all':
tasks = [task for task in tasks if
(task.status.value not in {'completed', 'deleted'} if category == 'unfinished'
else task.status.value == category)]
mode = self.sort.currentData()
if mode.startswith('name_'):
tasks.sort(key=lambda task: tuple(int(part) if part.isdigit() else part
+91
View File
@@ -0,0 +1,91 @@
from dataclasses import replace
from datetime import datetime, timezone
from pathlib import Path
import pytest
from PySide6.QtCore import Qt
from dx_productivity.trial_task_center.models import TaskRecord, TaskStatus
from dx_productivity.trial_task_center.ui.task_list import TaskList
@pytest.fixture
def navigation(qtbot):
opened=[]
panel=TaskList(opened.append)
qtbot.addWidget(panel)
now=datetime.now(timezone.utc)
tasks=tuple(TaskRecord(status.value, 'Board '+status.value, 'audio', Path('F:/Projects'),
status, now, now, group_id='batch', group_position=index)
for index,status in enumerate(TaskStatus) if status is not TaskStatus.DELETED)
panel.populate(tasks,selected_task_id='ready')
panel.show()
return panel,tasks,opened
def visible_ids(panel):
return [panel.list.item(index).data(Qt.ItemDataRole.UserRole) for index in range(panel.list.count())]
@pytest.mark.parametrize(('category','expected'),[
('all',['draft','ready','running','paused','completed','failed']),
('unfinished',['draft','ready','running','paused','failed']),
('completed',['completed']),
('failed',['failed']),
])
def test_visible_status_category_filters_task_list(navigation,category,expected):
panel,tasks,opened=navigation
assert panel.filter.isVisible()
index=panel.filter.findData(category)
assert index>=0
panel.filter.setCurrentIndex(index)
assert visible_ids(panel)==expected
assert panel._tasks==tasks
assert opened==[]
def test_category_and_search_combine_and_refresh_tracks_new_status(navigation):
panel,tasks,opened=navigation
panel.filter.setCurrentIndex(panel.filter.findData('unfinished'))
panel.search.setText('Board ready')
assert visible_ids(panel)==['ready']
updated=tuple(replace(task,status=TaskStatus.COMPLETED) if task.task_id=='ready' else task for task in tasks)
panel.populate(updated,selected_task_id='ready')
assert visible_ids(panel)==[]
assert '当前任务已隐藏' in panel.count.text()
panel.filter.setCurrentIndex(panel.filter.findData('completed'))
assert visible_ids(panel)==['ready']
assert panel.current_task_id()=='ready'
assert opened==[]
def test_category_is_local_and_never_changes_batch_scope(ui,monkeypatch):
window=ui.window
before=window._tasks
def unexpected_read(**kwargs):
raise AssertionError('Category changes must use cached tasks')
monkeypatch.setattr(ui.service,'tasks',unexpected_read)
panel=window.task_list
panel.filter.setCurrentIndex(panel.filter.findData('completed'))
assert panel.list.count()==0
assert window._tasks==before
assert window._task_id==ui.tasks[0].task_id
assert not panel.up_button.isEnabled()
assert not panel.down_button.isEnabled()
panel.filter.setCurrentIndex(panel.filter.findData('all'))
assert panel.list.count()==len(before)
def test_recycle_bin_ignores_active_status_category(ui):
panel=ui.window.task_list
panel.filter.setCurrentIndex(panel.filter.findData('completed'))
ui.service.delete_task(ui.tasks[1].task_id)
panel.recycle_button.setChecked(True)
ui.settle()
assert not panel.filter.isEnabled()
assert visible_ids(panel)==[ui.tasks[1].task_id]
panel.recycle_button.setChecked(False)
ui.settle()
assert panel.filter.isEnabled()
assert panel.filter.currentData()=='completed'
assert visible_ids(panel)==[]
+1 -1
View File
@@ -11,7 +11,7 @@ def test_shell_has_stable_automation_controls_and_current_navigation(ui):
'boundProjectPath','exportBomTemplate','importBomPlan','toggleLogButton'):
assert w.findChild(QWidget,name) is not None,name
assert w.windowTitle()==f'DxDesigner 器件替换 · {VERSION}'
assert not w.task_list.filter.isVisible()
assert w.task_list.filter.isVisible()
assert w.workspace_splitter.orientation()==Qt.Orientation.Horizontal
assert not w.workspace_splitter.childrenCollapsible()
assert w.detail_splitter.count()==2
+12
View File
@@ -157,6 +157,15 @@ def main():
assert report['empty_search_feedback']
capture('native-app-empty-search')
window.plan_panel.clear_find();window.plan_panel.table.clearSelection()
task_id=window._task_id
window.task_list.filter.setCurrentIndex(window.task_list.filter.findData('completed'))
assert window.task_list.list.count()==0 and window._task_id==task_id
capture('native-app-completed-category')
window.task_list.filter.setCurrentIndex(window.task_list.filter.findData('unfinished'))
assert window.task_list.list.count()==len(tasks)
window.task_list.filter.setCurrentIndex(window.task_list.filter.findData('all'))
assert window.task_list.current_task_id()==task_id
report['status_categories']=True
window.reduced_transparency_button.setChecked(True);capture('native-app-solid')
assert not window.property('acrylicEnabled')
solid=captures['native-app-solid']
@@ -178,6 +187,9 @@ def main():
report['compact_table_height']=window.plan_panel.table.viewport().height()
assert report['compact_size']==[980,700]
assert report['compact_table_height']>=100
assert window.task_list.filter.isVisible()
point=window.task_list.filter.mapTo(window,window.task_list.filter.rect().bottomRight())
assert 0<=point.x()<window.width() and 0<=point.y()<window.height()
# Preview UI gates with an owned StopControl; never dispatch a worker.
window._begin_run(tasks[0].task_id);window._update_gates();settle(.2)
report['force_stop_direct']=window.run_panel.force_stop_button.isVisible()