Skip to content

fix: allow deleting assistants and sessions whose workspace directory is unavailable - #3152

Merged
bobleer merged 8 commits into
openBitFun:mainfrom
legenddcr:fix/invalid-workspace-item-deletion
Nov 2, 2026
Merged

bobleer merged 8 commits into
openBitFun:mainfrom
legenddcr:fix/invalid-workspace-item-deletion

Conversation

@legenddcr

Copy link
Copy Markdown
Contributor

Fixes #3150

Summary

Two related fixes so items whose workspace directory is unavailable can still be deleted.

1. Assistant workspaces with legacy or missing directories (desktop)

delete_assistant_workspace, reset_assistant_workspace, and reset_workspace_persona_files rejected any assistant whose registry record still points at the legacy BitFun root ~/.bitfun/personal_assistant/workspace-<id> (directories the brand migration never relocated), and there was no path for records whose directory is already gone — the assistant could never be deleted from the UI.

  • New WorkspaceService::is_manageable_assistant_workspace_path accepts both the current layout (~/.openbitfun/personal_assistant/workspace[-<id>]) and the legacy layout (~/.bitfun/personal_assistant/workspace[-<id>]). The legacy root name comes from the new legacy_hidden_data_directory() in core-types; the private constant in legacy-migration now reuses it.
  • delete_assistant_workspace: managed paths delete the directory as before; unmanaged records whose directory no longer exists fall back to a registry-only cleanup (logged in English); existing directories outside both managed layouts are still refused — the deletion safety boundary is unchanged.
  • reset_assistant_workspace and reset_workspace_persona_files accept both layouts.

2. Sessions whose workspace path is missing (web-ui)

FlowChatStore.deleteSession still required a workspace path before calling the backend, so sessions whose workspace directory is missing never reached the ID-first delete_session command; failures were swallowed and the session reappeared after reload.

  • The guard is removed; the workspace id is snapshotted synchronously before the first await, pre-ID sessions fail loudly, and backend delete failures surface through the existing notification path after local cleanup.
  • LocalSessionDriver cleanup moved into try/finally so local state is cleared even when backend cleanup fails.

Verification

  • cargo test -p openbitfun-core --no-default-features --features agent-runtime,git --lib service::workspace::service::tests — 20 passed
  • cargo test -p openbitfun-desktop --lib api::commands::assistant_workspace_delete_tests — 3 passed
  • cargo test -p openbitfun-legacy-migration --test migration_engine_contracts — 10 passed
  • cargo check -p openbitfun-desktop on this branch
  • Front-end suites (FlowChatStore 146 passed, SessionModule 52 passed, session-drivers 14 passed) were run on the pre-rebase working tree; the touched front-end files are unchanged between that baseline and this branch's base, so the results carry over.

Remote scenarios

Deletion and reset are local registry + local filesystem operations invoked through existing Tauri commands; no remote-surface contract changed and no new commands were added.

legenddcr and others added 4 commits September 20, 2026 17:42
…ath is missing

FlowChatStore.deleteSession kept a stale workspace-path guard, so the
ID-first backend delete was never invoked and the session reappeared
after reload.

Refs openBitFun#3150
…spaces

Assistant workspace records left at the legacy BitFun root
(~/.bitfun/personal_assistant/) by the brand migration, and orphaned
records whose directory is already gone, can now be deleted or reset.
Existing directories outside the managed layouts are still refused.
The legacy_hidden_data_directory() constant now comes from core-types,
replacing the private copy in legacy-migration.

Fixes openBitFun#3150
…ce-item-deletion

Main now keeps a session whose backend deletion fails, so take its
deleteSession and LocalSessionDriver and only drop the workspace path
guard, the part openBitFun#3428 also identified.

Co-authored-by: skyfire <skyfire@users.noreply.github.com>
Split root resolution from the environment so the test no longer calls
set_var, restore the hidden_data_directory doc link, and word the
registry-only log before the removal happens.
@bobleer

bobleer commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Merged main and made a few changes so this can be the single fix for #3150 (it overlaps #3428).

Why this PR: its backend covers both issue symptoms. It handles records whose directory is gone, not only legacy paths; it keeps is_assistant_workspace_path for the current layout, so opening a folder under ~/.bitfun/personal_assistant is not reclassified as an assistant; and it resolves the legacy root the same way as the data migrator (BITFUN_HOME / BITFUN_E2E_HOME). Existing directories outside both layouts are still refused.

Changed:

  • Conflict with main: deleteSession was redesigned there, so a rejected deletion now keeps the session and its parent. The previous "clean up locally, then rethrow" and the LocalSessionDriver try/finally no longer apply and are dropped. The frontend fix is now only the guard removal, which is what @skyfireitdiy's fix(workspace): recognize legacy BitFun assistant workspaces and allow session deletion #3428 does (credited as co-author on the merge commit). A session without a workspace ID still fails loudly.
  • Tests updated to match: rejected deletions keep the session.
  • The legacy root test no longer calls std::env::set_var, which races other tests in the same binary; resolution is now a pure function tested directly.
  • Restored the hidden_data_directory doc link, which had been changed to point at itself.
  • The registry-only log now reads "removing", since it runs before the removal.

Tests: FlowChatStore and session drivers/module vitest (375 passed); core service::workspace::service::tests with remote-workspace (32 passed); desktop assistant_workspace_delete_tests (3 passed, with stubbed bundled resources); migration_engine_contracts (10 passed); check:core-boundaries.

Remote scenarios: these are host-side registry and filesystem operations on Proxied commands, unit-tested only, not exercised on a live peer.

…dary

Move root resolution to core's legacy_migration module so the retired
name stays inside the product identity audit's allowlisted boundary, and
restore core-types and the migrator's paths to main.
@bobleer

bobleer commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

CI follow-up: the product identity audit rejected the retired name in service.rs, commands.rs and core-types. The legacy root resolution now lives in core's allowlisted legacy_migration module, which is compiled unconditionally with only the adapter re-export behind legacy-migration. core-types and legacy-migration/src/paths.rs are back to main, so legacy_hidden_data_directory is gone. check:repo-hygiene and the core and desktop delete tests pass.

…imports

An import reorder moved the cfg attribute from the remote SSH import to
the bootstrap import, breaking builds without remote-workspace.
@bobleer

bobleer commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

CI follow-up: my earlier import reorder in workspace/service.rs moved #[cfg(feature = "remote-workspace")] from the remote SSH import onto the bootstrap import, which broke builds without remote-workspace, the CLI build included. The gating now matches main again. Checked cargo check for openbitfun-cli, core default, core product-full, and core agent-runtime,git; core workspace tests, repo hygiene and core-boundaries pass.

@bobleer
bobleer merged commit 8ccc8ac into openBitFun:main Nov 2, 2026
13 checks passed
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.

[Bug]: 无法删除工作区路径失效的个人助理(Workspace path is not a managed assistant workspace)

2 participants