fix(cloud_object): allow deleting locally-created objects (rules etc.)#313
Open
zerx-lab wants to merge 1 commit into
Open
fix(cloud_object): allow deleting locally-created objects (rules etc.)#313zerx-lab wants to merge 1 commit into
zerx-lab wants to merge 1 commit into
Conversation
Fixes #311 Root cause: app/src/cloud_object/update_manager.rs:1444 (before this change) — `delete_object_with_initiated_by` returned early unless `id.server_id()` was `Some`. Since the cloud backend was removed during the localization refactor, every newly created object (e.g. an AI Rule created via `create_object` at update_manager.rs:1057) only gets a `SyncId::ClientId`, never a `SyncId::ServerId`. So the guard always failed and clicking "Delete rule" silently did nothing. Fix: drop the server_id requirement and delete by the object's `SyncId` directly via `on_object_delete_success`, mirroring the existing local-object handling already used by `trash_object` / `untrash_object` in the same file. Also stopped reporting a fabricated `ServerId` in the emitted `ObjectOperationComplete` event for non-server objects — `id.server_id()` (None for local objects) is used instead. Checked all consumers of that event's `server_id` field; none rely on it being `Some` for the `Delete` operation. Added a regression test (test_delete_local_object_removes_it in app/src/cloud_object/model/model_test.rs) that creates a local AI fact via UpdateManager::create_ai_fact and asserts it is actually removed after delete_object_by_user. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015fT7HYd9iZnDgLHirQJczb
zerx-lab
commented
Jul 10, 2026
zerx-lab
left a comment
Owner
Author
There was a problem hiding this comment.
整体判断倾向:Approve。修复精准、影响范围可控、测试到位,未发现阻塞问题。
阻塞问题
无。
建议
test_delete_local_object_removes_it使用ClientId::default()(即零值 ID)作为测试主键。在当前App::test()每次创建隔离沙箱的前提下不会冲突,但若将来测试框架改为在同一 model 里并发跑多个 case,建议改为ClientId::new_v4()或等价的唯一生成方式。不阻塞。
看起来不错的地方
- 修复集中在
delete_object_with_initiated_by一处,所有调用路径自动受益,无需逐一修改四个调用点。 - 将
server_id字段从Some(ServerId::from_string_lossy(&uid))改为id.server_id()(即Nonefor local objects)前,逐一核查了所有消费者对该字段的.expect()路径,论证充分。 - 回归测试直接模拟出 PR 描述中的失败场景(
ClientId→ 点击删除 → 对象仍存在),失败信息明确,覆盖了修复的核心路径。 - PR 描述对根因和 sibling 函数已有正确实现的对比分析非常清晰。
— 由 Claude Routine 自动生成;如需复评请 @ 维护者人工触发。
Generated by Claude Code
Owner
Author
|
Thanks for the review! Re: the // app/src/server/ids.rs
impl Default for ClientId {
fn default() -> Self {
ClientId::new() // Uuid::new_v4()
}
}So Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #311 — "Delete rule" in Settings > Agents > Knowledge > Manage Rules > Global has no effect; the rule remains after clicking Delete.
Root cause:
app/src/cloud_object/update_manager.rs—delete_object_with_initiated_bystarted with:This guard is a holdover from before the cloud backend was removed ("Zap 本地化" refactor). Since then, every newly created object — including AI Rules created via
UpdateManager::create_ai_fact→create_object(update_manager.rs:1057:let object_id = SyncId::ClientId(client_id);) — only ever gets aSyncId::ClientId, never aSyncId::ServerId. Soid.server_id()is alwaysNonefor any rule a user creates today, the guard always hit, and the function returned before doing anything. Clicking "Delete rule" silently no-oped.The sibling functions
trash_object/untrash_objectin the same file already handle this correctly — they branch onid.server_id()and fall back to a local-only path keyed byid.uid()when it'sNone.delete_object_with_initiated_bynever got that treatment.Fix: drop the server-id requirement and delete by the object's
SyncIddirectly via the existingon_object_delete_success(which already works offSyncId::uid(), not specificallyServerId). The emittedObjectOperationComplete.server_idnow reportsid.server_id()(i.e.Nonefor local objects) instead of fabricating one viaServerId::from_string_lossy. I checked every consumer of that field (workspace/view.rs,workflows/workflow_view.rs,drive/import/queue.rs,cloud_object/model/view.rs,ai/blocklist/*.rs) — the ones that.expect()aSomevalue only do so forObjectOperation::Create/Update, neverDelete, so this is safe.Testing
Added
test_delete_local_object_removes_itinapp/src/cloud_object/model/model_test.rs: creates a local AI fact viaUpdateManager::create_ai_fact, asserts it exists, callsdelete_object_by_user, asserts it's gone. This test fails (times out returningSome, i.e. the object is never removed) against the pre-fix code and passes with the fix.Ran the full
cloud_object::modeltest suite before and after:5d874456):test_unshared_team_objectalready fails (unrelated — aSpace::Teamcomputation assertion, nothing to do with delete).15 passed; 1 failed— same single pre-existingtest_unshared_team_objectfailure, confirmed identical on both commits. No regressions.test cloud_object::model::persistence::tests::test_delete_local_object_removes_it ... okAlso ran
cargo check -p warp --libclean (only a pre-existing unrelated warning interminal/view.rs).Diff is scoped to exactly 2 files / 60 lines (
git diff --stat 5d874456→app/src/cloud_object/model/model_test.rs+55,app/src/cloud_object/update_manager.rs+14/-9), matchingdelete_object_by_user's 4 other call sites (drive/index.rs,ai/mcp/templatable_manager/native.rsx2,ai/facts/view/rule.rs) — none needed changes since the fix is centralized in the shared function.Server API dependencies
N/A — purely local, no server dependency.
Agent Mode
Changelog Entries for Stable
CHANGELOG-BUG-FIX: Fixed "Delete rule" in Settings > Agents > Knowledge having no effect
Generated by Claude Code