Skip to content

fix(worktree): defer isolation until first prompt - #1820

Merged
bobleer merged 2 commits into
GCWing:mainfrom
bobleer:bob/lazy-worktree-first-turn
Jul 28, 2026
Merged

fix(worktree): defer isolation until first prompt#1820
bobleer merged 2 commits into
GCWing:mainfrom
bobleer:bob/lazy-worktree-first-turn

Conversation

@bobleer

@bobleer bobleer commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • make the Desktop checkbox and CLI /worktree command arm an empty-session preference without running Git I/O
  • materialize or release the worktree only after the first prompt is visibly submitted, then start the backend turn in the resolved execution root
  • keep the stable project root as the session persistence locator while the worktree remains the execution root, including legacy caller normalization
  • expose pending worktree state in both the Desktop branch strip and CLI workspace status

Type and Areas

Type: regression fix / UI/UX

Areas: Rust core, desktop/Tauri, Web UI, CLI/TUI, Peer Host adapter

Motivation / Impact

Checking worktree isolation previously performed synchronous worktree creation. The following prompt then passed the worktree execution path as a session-storage locator, causing Session ID is already bound to another workspace and preventing the message from being sent.

After this change, checking the control is immediate. Worktree creation starts only after prompt submission, and session persistence continues to resolve through the owning project root on Windows, macOS, and Linux. Remote-workspace support remains explicitly unchanged.

Verification

  • pnpm run type-check:web
  • pnpm --dir src/web-ui run test:run src/flow_chat/utils/sessionWorktree.test.ts src/flow_chat/components/ChatInputWorkspaceStrip.test.tsx src/flow_chat/store/FlowChatStore.test.ts — 79 passed
  • pnpm run lint:web
  • pnpm run i18n:audit — 0 warnings
  • cargo check --workspace
  • cargo test -p bitfun-core worktree_execution_root_is_a_legacy_alias_for_project_storage --lib
  • cargo test -p bitfun-core unrelated_workspace_is_not_rewritten_to_the_project_storage_root --lib
  • cargo test -p bitfun-core dialog_port_preserves_invalid_request_for_wrong_workspace --lib
  • cargo test -p bitfun-cli — all unit and integration tests passed
  • cargo test -p bitfun-desktop — 226 passed, 2 pre-existing permission-gated tests ignored
  • node scripts/check-core-boundaries.mjs
  • pnpm run check:repo-hygiene
  • git diff --check

Reviewer Notes

The storage-locator fallback intentionally rewrites only the loaded session own execution root to its project root. Unrelated workspace paths are preserved and still rejected by the existing session identity guard. No screenshot is included because the UI shape is unchanged; the visible behavior change is that the checked state is immediate and reports a pending state until first send.

This change was AI-assisted and fully tested with the commands above.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

@bobleer

bobleer commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

CI follow-up: the first Ubuntu full-core run exposed that an omitted workspace locator was being synthesized from the loaded session and re-resolved against ambient storage settings. Commit 3899c804b now preserves the loaded session storage binding when the caller omits the locator, while still normalizing an explicitly supplied worktree execution root to the project root.

Reverification after the fix:

  • both originally failing scheduler tests pass
  • the new omitted-locator regression test passes
  • explicit worktree-root normalization and wrong-workspace rejection tests pass
  • cargo test -p bitfun-core --lib: 1543 passed, 1 ignored

@bobleer
bobleer merged commit cfcf462 into GCWing:main Jul 28, 2026
7 checks passed
1688mengdie pushed a commit to 1688mengdie/BitFun that referenced this pull request Jul 28, 2026
* fix(worktree): defer isolation until first prompt

* fix(core): preserve loaded session storage binding
1688mengdie pushed a commit to 1688mengdie/BitFun that referenced this pull request Jul 28, 2026
* fix(worktree): defer isolation until first prompt

* fix(core): preserve loaded session storage binding
1688mengdie pushed a commit to 1688mengdie/BitFun that referenced this pull request Jul 28, 2026
* fix(worktree): defer isolation until first prompt

* fix(core): preserve loaded session storage binding
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.

1 participant