fix: resolve navigation-cache regressions and todo UX

This commit is contained in:
qzl
2026-03-20 16:45:08 +08:00
parent 3f1858d733
commit 55f3805ee9
15 changed files with 160 additions and 105 deletions
+20
View File
@@ -196,3 +196,23 @@ Home 首页历史消息加载与滚动策略属于高回归模块,必须遵循
- controller-level state transition tests
- widget-level unread indicator and scroll behavior tests
- route-return stability tests when navigation behavior changes
## 11) Cache & Repository Rules (MUST)
前端缓存与数据访问属于高回归区域,必须遵循以下约束:
- **MUST** route feature data reads/writes through repository layer when cache, invalidation, or optimistic update is involved.
- Feature/UI code **MUST NOT** call raw `*Api` methods directly for mutation paths that affect list/detail consistency.
- Exceptions are allowed only for bootstrapping or truly stateless read operations, and must be documented in code review notes.
- **MUST** keep cache key ownership centralized in repository classes.
- UI/Bloc/Cubit **MUST NOT** hardcode cache keys or perform ad-hoc cache writes.
- **MUST** define cache invalidation at mutation boundaries (create/update/delete/archive/complete/reorder).
- Mutation success must either update cache atomically or invalidate and trigger deterministic refresh.
- **MUST** preserve route-return consistency for data freshness.
- Pages that mutate entity data must return an explicit changed signal to caller routes.
- Caller list pages must consume that signal and refresh using repository path.
- **MUST** ensure list item widgets that carry local interaction state use stable identity keys (e.g. `ValueKey(entity.id)`) to prevent state leakage across reused cells.
- **MUST** add/maintain regression tests when changing cache/repository behavior:
- repository tests for optimistic update + rollback + invalidation
- route-return refresh tests for list/detail/edit flows
- widget tests for stable keyed interaction state where applicable