Skip to content

Bug: Imported Codex worktree sessions are registered as top-level folders instead of under repo root #552

Description

@Luis-WowApps

When importing Codex sessions whose cwd is a Git worktree of an already-open repo, CodeG sometimes registers the worktree folder as a top-level workspace folder instead of grouping it under the repo root.

Example local state:

  • Root repo: C:\_Data\Projects\WowApps
  • Worktree grouped correctly:
    • C:\_Data\Projects\worktrees\churn-report-edit-entries
  • Worktrees shown incorrectly as top-level:
    • C:\_Data\Projects\worktrees\admin-danger-zone-edit-area-on-vendor-edit
    • C:\_Data\Projects\worktrees\pricing-investigation

DB evidence:

  • folder.id = 32, path ...\churn-report-edit-entries, parent_id = 1
  • folder.id = 33, path ...\admin-danger-zone-edit-area-on-vendor-edit, parent_id = NULL
  • folder.id = 34, path ...\pricing-investigation, parent_id = NULL

All three are valid Git worktrees from C:\_Data\Projects\WowApps according to git -C C:\_Data\Projects\WowApps worktree list --porcelain.

Likely cause:

The normal worktree registration path uses open_worktree_folder_core, which writes the parent repo id via folder_service::add_folder_with_parent(...).

But the session import path in src-tauri/src/commands/conversations.rs calls plain folder_service::add_folder(...) for imported session cwd paths. That creates/reopens a normal folder and leaves parent_id = NULL. It does not resolve whether the imported cwd is a Git worktree belonging to an existing root folder.

Expected behavior:

When importing a session whose cwd is a Git worktree of an already-open folder, CodeG should register/reconcile that folder as a worktree child of the root repo, same as open_worktree_folder_core does.

Relevant code:

  • src-tauri/src/commands/folders.rs
    • open_worktree_folder_core(...)
  • src-tauri/src/db/service/folder_service.rs
    • add_folder(...)
    • add_folder_with_parent(...)
  • src-tauri/src/commands/conversations.rs
    • import_selected_from_summaries(...) currently calls folder_service::add_folder(...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions