feat(session): 增加 Todo 状态持久化与校验#280
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
/simplify |
Completed
Commit
Not Done
|
- repair garbled UTF-8 text in session persistence todo section - extract ensureTodoID to reduce duplicated id normalization - add regression test for empty todo id behavior Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Yumiue <188874804+Yumiue@users.noreply.github.com>
|
/review |
| break | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
normalizeAndValidateTodos 在 len(items)==0 时返回 nil,会让 Save/Load 后 Session.Todos 在 nil 与 [] 之间切换。当前 NewWithWorkdir 初始化为 []TodoItem{},且文档将 todos 描述为固定结构字段;该行为会带来语义不一致与序列化不稳定(omitempty 下字段可能被省略)。建议这里返回空切片([]TodoItem{})或在 Save/Load 层统一规范为空切片。
| } | ||
| if err := session.UpdateTodoStatus("todo-1", TodoStatus("paused")); err == nil || !strings.Contains(err.Error(), `invalid todo status`) { | ||
| t.Fatalf("expected invalid status error, got %v", err) | ||
| } |
There was a problem hiding this comment.
建议补一组 nil receiver 用例((*Session)(nil).AddTodo/UpdateTodoStatus/DeleteTodo)。当前生产代码在对应分支返回错误,但测试未锁定这些保护分支,后续重构时容易回归为 panic 或错误信息漂移。
| @@ -0,0 +1,47 @@ | |||
| # Session Todo 设计说明 | |||
There was a problem hiding this comment.
Reviewed end-to-end against the current implementation in internal/session; no inconsistencies found here.
| @@ -51,6 +52,22 @@ NeoCode 当前使用本地 JSON 文件持久化会话,以保持实现简单、 | |||
| - `user_constraints` | |||
There was a problem hiding this comment.
Re-checked this section in the latest commit: the UTF-8 text is readable and aligned with the current Todo persistence behavior.
| break | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
normalizeAndValidateTodos 在空输入时返回 nil,会让 Session.Todos 在 nil/[] 之间切换。当前 NewWithWorkdir 初始化为 []TodoItem{},如果希望持久化前后语义更稳定,可考虑统一规范为空切片。
|
@xgopilot 这个Pr完美的实现了issues/261吗 |
结论不算“完美实现” issue #261;当前 PR 只覆盖了其中一部分基础能力。 未覆盖或不满足的关键点
已覆盖的部分(仅限本 PR 范围)
如果要达到 issue #261 的“完整验收标准”,还需要补齐上面 1-7 项。 |
背景
为
Session增加结构化 Todo 状态,沿用现有internal/sessionJSON 持久化链路,不引入新的存储子系统。本次修改
internal/session新增TodoItem和TodoStatusSession增加Todos []TodoItem字段Save/Load路径中增加 Todo 的规范化和校验todos字段时按空列表兼容加载FindTodoAddTodoUpdateTodoStatusDeleteTodo校验规则
pendingin_progresscompletedidcontent测试
已通过:
link #261