Skip to content

修复:任务列表改用差量协调 - #92

Open
amazing-fish wants to merge 2 commits into
mainfrom
agent/issue-91-differential-crud
Open

修复:任务列表改用差量协调#92
amazing-fish wants to merge 2 commits into
mainfrom
agent/issue-91-differential-crud

Conversation

@amazing-fish

@amazing-fish amazing-fish commented Aug 14, 2026

Copy link
Copy Markdown
Owner

变更概述

  • 主窗口维护稳定的 task_id -> QListWidgetItem / TodoItemWidget 映射,update_list_widget() 改为差量协调目标集合和顺序。
  • 新增只创建目标卡片;编辑、完成切换和提醒处置原位更新目标;删除只释放目标;筛选与排序复用并移动已有对象。
  • TodoItemWidget.update_todo() 只在正文、优先级、完成态或计时呈现实际变化时写入 Qt 控件。
  • 正常 CRUD 不调用 QListWidget.clear();仅映射异常恢复路径保留完整重建。
  • 差量操作记录并恢复首个可见任务的像素锚点;滚动条宽度变化时才执行全卡片尺寸同步。
  • 版本更新至 v2.1.4,并同步 README 与 anchor。

根因与影响

此前每次用户操作都会销毁并重建全部卡片,导致未变化任务重复创建控件、图标、详情浮层和信号连接。现在每次操作只承担目标卡片和必要排序位置的成本,同时保持同步 save_todos()、筛选排序、提醒及空列表占位语义。

验证

  • python -m compileall -q todo_app tests
  • git diff --check
  • ✅ GitHub Actions“自动化测试” refactor:增加 pip 缓存提升打包速度 #26:Python 3.11 / Qt offscreen,编译检查通过,Ran 86 tests in 2.172s — OK
  • ✅ 卡片排序移动后显式处理 DeferredDelete,原 QListWidgetItem / TodoItemWidget 仍有效。
  • ⚠️ 当前本地容器缺少系统库 libEGL.so.1,无法在本机启动 PySide6 GUI 用例;远端 CI 已覆盖完整 GUI 自动化测试。
  • 待手工:Windows 开发版与单文件 EXE 下比较增删改/完成切换响应,并观察长列表滚动锚点。

Closes #91
Relates #82

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6679b78ac1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread todo_app/main_window.py
Comment on lines +965 to +966
if len(target_ids) != len(set(target_ids)):
raise RuntimeError("筛选和排序结果中存在重复任务 ID")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 在协调前修复重复任务 ID

当现有 todos.json 中两个原本可加载的条目被规范化为同一 ID(例如 1"1")时,storage.py::_migrate_and_validate_todo_item 会把两者都转换为 int,但不会解决冲突,而这里会在窗口初始化的首次 update_list_widget() 中直接抛出 RuntimeError。旧实现仍能打开并展示此类数据,因此升级后会导致整个应用无法启动;应在迁移或协调阶段为重复 ID 生成新 ID,而不是让 UI 初始化崩溃。

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[#82-B] 用差量协调替代任务 CRUD 的整表重建

1 participant