Conversation
… annotations `spec_generator.dart` now detects raw string literals and constants containing template patterns to determine when to allow string interpolation in generated `key` and `tag` expressions. Added `_quoteString` logic to properly escape special characters while preserving valid interpolation markers. - Add support for raw string templates in `key` and `tag` fields. - Improve string escaping for literals (backslashes, newlines, etc.). - Add recursive resolution of constant string references to detect interpolation needs. - Add comprehensive tests for escaped literals and template strings.
…poseInstanceController` and `ViewModel` - Rename "watcher" terminology to "binding" across the core instance management classes for better clarity. - Enhance `AutoDisposeInstanceController` with improved disposal logic, ensuring listeners are removed before unbinding to prevent potential crashes. - Add comprehensive error handling and logging via `ViewModelConfig.onListenerError` and `onDisposeError` across lifecycle methods (`onCreate`, `onBind`, `onUnbind`, `onDispose`). - Fix a potential memory leak in `AutoDisposeController` by ensuring the internal disposal list is correctly managed. - Improve `CachedViewModelBuilder` to report errors in release mode when a requested ViewModel is missing. - Refactor `PauseAwareController` and related providers to ensure robust state management and cleanup. - Optimize `InstanceHandle` to use unmodifiable lists for external access while maintaining internal performance. - Update documentation and examples to reflect the "binding" terminology and initialization patterns.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6369cbdb55
ℹ️ 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".
|
|
||
| List<VM> readCachesByTag<VM extends ViewModel>(Object tag) { | ||
| return _instanceController.getInstancesByTag<VM>(tag, listen: false); | ||
| return _instanceController.getInstancesByTag<VM>(tag, listen: true); |
There was a problem hiding this comment.
Keep readCachesByTag non-listening
readCachesByTag now passes listen: true, which makes a read-only API register bindings/recreate listeners via AutoDisposeInstanceController.getInstancesByTag. That means callers doing a snapshot read can still be wired into lifecycle updates (including rebuilds on recreate) and can keep instances alive longer than expected, which is a behavioral regression from the prior non-listening read path.
Useful? React with 👍 / 👎.
| category: normalizedCategory == null || normalizedCategory.isEmpty | ||
| ? null |
There was a problem hiding this comment.
Preserve category when editTodo omits newCategory
This logic now treats newCategory == null as "clear category", but newCategory is optional and defaults to null, so calling editTodo(id, title) unintentionally wipes an existing category instead of leaving it unchanged. The previous behavior preserved the current category when no new category was provided, so this introduces an API-level regression for title-only edits.
Useful? React with 👍 / 👎.
- 在 AutoDisposeInstanceController 中防止重复添加 notifier - 修复 InstanceHandle.action 的文档说明,明确其在回调期间和 dispose 后的行为 - 改进 ObserverBuilder 生命周期管理,在 initState 和 didUpdateWidget 中确保 ViewModel 初始化 - 优化实例回收逻辑,确保 action 状态正确设置和清理
将 dispose/unbind 相关的 catch 块从 viewModelLog 改为使用 ViewModelConfig.onDisposeError 回调,保持 onListenerError 仅用于 notifyListeners 和 state listener 的错误处理。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
新增 ErrorType 枚举(listener/dispose),替换原来的两个独立回调 为单一的 onError(Object, StackTrace?, ErrorType),简化 API 设计。 同时修复 ViewModel.onCreate()/onBind() 中 lifecycle observer 错误 不走用户回调的盲区问题。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 扩展 ErrorType 为 4 值枚举:listener / lifecycle / dispose / pauseResume - 新增 reportViewModelError 统一辅助函数,提供二级 try-catch 兜底, 防止 onError 回调自身抛异常导致 dispose 链断裂 - 错误日志改用 debugPrint 直接输出,不再受 isLoggingEnabled 控制, 解决默认配置下异常被完全静默吞掉的问题 - 修复 _attachRecreateListener 未走统一 onError 路径的遗漏 - 修正 ErrorType 分类:onCreate/onBind/onUnbind 改为 lifecycle, PauseAwareController 回调改为 pauseResume - 消除全代码库约 20 处重复的内联错误处理模式 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…uro` dependency Updated the Codecov CI workflow to use `ubuntu-latest` instead of self-hosted runners and replaced the `puro` toolchain manager with the standard `subosito/flutter-action`. - Switch `runs-on` to `ubuntu-latest`. - Upgrade `actions/checkout` to `v4`. - Add Flutter setup step using `subosito/flutter-action@v2`. - Replace all `puro dart` and `puro flutter` commands with standard `dart` and `flutter` executables. - Update `.gitignore` to include `.claude/settings.local.json`.
- 新增 ErrorType.lifecycle、ErrorType.pauseResume 测试 - 新增 reportViewModelError 二次 catch 测试 - 新增 isLoggingEnabled=false 时错误仍输出的测试 - 二次 catch 增加 handlerStack 堆栈输出 - 统一 fallbackMessage 命名风格 - 统一 catch 变量命名为 (e, stack) - CI 添加 cache/permissions/PR trigger - SKILL.md 文档同步 4 个 ErrorType 枚举值 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
….1 (view_model) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- **view_model**:
- Add `try-catch` blocks and error reporting to `performForAllInstances`, `DevTool` data retrieval, `DependencyTracker` listeners, and `ViewModelBinding` disposal.
- Improve error logging for `notifyListeners` after disposal and handle errors in `PauseProvider` streams.
- Optimize `hashCode` implementations using `Object.hash`.
- Simplify instance lookup logic in `Store`.
- Update `view_model_annotation` dependency to `1.0.3-dev.0`.
- **view_model_generator**:
- Fix string literal normalization to correctly handle escaping backslashes, dollar signs, and quotes when converting from raw strings.
- Improve parsing of escaped characters in string buffers.
- Update `view_model_annotation` dependency to `1.0.3-dev.1`.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
No description provided.