Task 7: Point Git, file tree, and watchers at live Herdr cwd
Summary
Point Git, the file tree, and watchers at live Herdr cwd for parent plan #436. After Task 6 (#448 on task-6-herdr-session-store) tabs restore from session.snapshot / pane_id, but leftover sqlite Git/FS helpers and watch roots can still use profiles.worktree_path and disagree with live Herdr. This task makes every path used by Git IPC, filesystem watch, the sidebar tree, and editor/open-in-app joins come from the focused Herdr workspace. No sqlite cache that can go stale and still win.
A profile remains an open Herdr workspace. The profile id is the Herdr workspace_id (wN). Join key: canonical projects.folder ↔ live checkout / pane cwd (Task 1 contract, docs/herdr-integration.md). Reuse reconcile_profile_checkout / live_workspace_checkout (worktree.list then snapshot pane cwd). Do not write profiles.worktree_path. Do not DROP profiles / mapping tables (Task 8). Do not delete Local PTY (Task 9). Do not launch/adopt the project-folder default (Task 10). Do not start a second events.subscribe / name HerdrRuntimeSync in lib.rs. Do not redesign Git / file-tree / notes / tab clicks or labels. Pin stays v0.9.0. Local remains TWOCODE_RUNTIME=local until Task 9. Local must never own a worktree Herdr already owns.
Handlers already call reconcile_profile_checkout for Git IPC and most file-tree IPC (Task 3). Leftover service Git/FS functions still repo::profile::find_by_id (get_diff, search_file, delete_check, and siblings). Integration tests still exercise those sqlite paths. Watcher roots come from list_with_runtime DTOs (live at poll) but are not proven to ignore leftover sqlite /stale. This task closes those holes.
Dependencies: Parent plan #436. Prerequisites: #437 (Task 1), #439 (Task 2), #441 (Task 3), #443 (Task 4), #445 (Task 5), #448 (Task 6). Open #438, #440, #442, #444 are line-count tracking only — not blockers. Open #446 is a Task 5 Local-flag delete gap (wait for Task 8/9 or a dedicated follow-up) — not this branch. Open #447 was Task 6 session-store work — not this branch. Open #394 issues #395–#434 (including #394 Task 16 / #432) must not be implemented or closed here.
Work to complete
-
Git IPC and leftover Git service helpers use live cwd
- Herdr-selected Git must call
reconcile_profile_checkout(liveworkspace_id→worktree.listpath / snapshot panecwd). Do notrepo::profile::find_by_idfor the checkout. sqliteprofiles.worktree_pathmust not win over a different live path. - Rewire leftover service helpers that still sqlite-resolve:
get_diff,get_diff_stats,get_log,get_commit_diff,get_binary_preview,commit_changes,discard_file_changes,get_ahead_count,push, anddelete_check(Git stats only). Handlers may keep calling infra::git after reconcile, or go through the rewired service functions — one Herdr path, no sqlite checkout. get_github_avatarstays on sqliteprojects.folder(project catalog, not a profile path).TWOCODE_RUNTIME=localkeeps sqlitefind_by_id/reconcile_local_profile_checkout.- Herdr-selected + absent/incompatible sidecar or unknown
workspace_id: fail closed (NotFound/ existing Herdr-absent errors). Do not sqlite-fill/stale. Do not flip the selector to Local.
- Herdr-selected Git must call
-
File tree, search, reveal, and editor-open paths use the same live seam
- Delete or stop calling sqlite-only
search_file/get_file_tree_git_status. Production already has*_for_profilewrappers; make those the only path. Integration tests must not keep a sqlite-winning helper alive. - Sidebar tree IPC already takes
profileId(FileTreePanel→list_file_tree_child_paths/ git status). Keep those clicks. TherootPath/worktreePathprops may stay as the Herdr-derived catalog DTO for clipboard, absolute-path join, and Git discard/open — that DTO is live-listed, not sqlite authority. Do not read leftoverprofiles.worktree_pathin the GUI. - Topbar editor/terminal launch (
open_topbar_appviacontrols.tsx) may keep a path argument if it is the live catalog DTO. Do not add a sqlite lookup. Do not redesign the buttons. - Reveal / open-in-default-app already reconcile; keep them on that seam.
- Delete or stop calling sqlite-only
-
Watcher roots from live Herdr cwd, not leftover sqlite
watcher_targetsmust watch Herdr-derivedlist_with_runtimecheckouts when Herdr is selected. Leftover sqlite/stalethat is not an open workspace must not be a watch root.- Keep today's shape: one watch per open profile, plus
projects.folderonly when no profile checkout is the project folder (empty Herdr until Task 10). Do not add a new watcher UI. Do not watch disk git worktrees withoutopen_workspace_id. - Source roots from the live list/reconcile seam. Do not persist listed paths to sqlite. Do not add a path-cache table/column. The existing 3s
list_with_runtimepoll is enough if that list is Herdr-derived; do not start a secondevents.subscribeor nameHerdrRuntimeSyncinlib.rs. Task 6 already starts sync on GUI connect. TWOCODE_RUNTIME=localkeeps sqlite nested-profile roots.
-
Prove without swallowing later tasks
- Colocated / integration tests with a fake
HerdrWorktreeClient: Git diff/log/status/commit/discard/ahead/push/delete-check againstworkspace_iduse live/listed, not leftover sqlite/stale; unknownwNis NotFound (no sqlite fallback); Local flag still sqlite; Herdr-down does not sqlite-fill; watcher targets omit leftover/staleand include live listed paths; file search / tree git status same seam. - Invert
integration_git.rs/integration_filesystem.rscallers of sqliteget_diff/search_fileso they cannot pass on a Herdr router by reading leftover rows. Keep Local-flag coverage for those helpers if they remain. - Update
docs/herdr-integration.md: Task 7 done on this branch. Do not bump v0.9.0. If line count grows past the estimate, open a tracking issue; do not fold Task 8+ into this branch.
- Colocated / integration tests with a fake
Likely files and directories
- Update:
src-tauri/crates/service/src/project.rs— Git helpers onreconcile_profile_checkout; invert sqlite-winning tests. - Update:
src-tauri/crates/service/src/filesystem.rs— remove or Local-only the sqlitesearch_file/get_file_tree_git_statushelpers. - Update:
src-tauri/crates/service/src/watcher.rs— prove / keep roots from live list DTOs; no leftover sqlite/stale. - Update if delete-check still sqlite-resolves:
src-tauri/crates/service/src/profile.rs(delete_checkonly). - Update:
src-tauri/tests/integration_git.rs,src-tauri/tests/integration_filesystem.rs. - Update:
docs/herdr-integration.md— Task 7 done on this branch. - Touch only if a command still find_by_id the GUI profileId:
src-tauri/src/handler/project.rs,src-tauri/src/handler/filesystem.rs,src-tauri/src/handler/profile.rs,src-tauri/src/handler/topbar.rs. - Do not change: Diesel migrations, dropping
profiles/ mapping tables, Local adapter internals, PTY spawn, sidecar pin, Settings runtime toggle, Herdr create/delete/list/session-store behavior, launch/adopt on project open, Git/file-tree feature redesign.
Estimated changes: 350–600 lines total, additions plus deletions, including tests; excluding generated files, lockfile churn and binary artifacts. Material scope growth should become a separate issue.
Acceptance criteria
- [ ] Herdr-selected Git IPC and leftover Git service helpers resolve checkout via live
worktree.list/ snapshot panecwd(reconcile_profile_checkout). sqliteprofiles.worktree_pathis not consulted and cannot win over a different live path. sqliteprofilesis not source of truth. - [ ] File tree, search, reveal, open-in-app, and editor-launch paths use that same live seam (or the Herdr-derived catalog DTO). No sqlite
find_by_idcheckout on the Herdr path. - [ ] Watcher roots are live Herdr checkouts from
list_with_runtime. Leftover sqlite/stalethat is not an open workspace is not watched. Empty Herdr still falls back toprojects.folderonly (until Task 10). No persisted path cache. - [ ]
TWOCODE_RUNTIME=localstill uses sqlite nested-profile paths for Git/FS/watcher. Herdr-selected + absent/incompatible sidecar or unknownworkspace_idfail closed; they do not sqlite-fill. - [ ] Git / file-tree / notes / tab clicks and labels stay. No new named UX exception. Prior exceptions remain: route ids are
workspace_id; tab ids arepane_id; empty profile list until Task 10; splits flattened as extra tabs. - [ ] sqlite
profiles/ mapping tables /pty_sessionsare not DROPped. No launch/adopt of the project-folder default. No Local PTY deletion. No secondevents.subscribe.lib.rsstill does not nameHerdrRuntimeSync. Pin stays v0.9.0. GUI exit still does notserver stop. - [ ] Tests:
cargo test --workspacefromsrc-tauri(orcargo test --workspace --exclude codewhere GTK is unavailable). Frontend lint/typecheck/tests if frontend scope is introduced.bun run typegenif IPC signatures change; do not editsrc/generated/by hand. - [ ] No pull request until parent #436 is complete.
Out of scope
- DROP sqlite
profiles/ mapping tables, or moving notes offprofiles(Task 8). - Deleting the Local PTY runtime (Task 9).
- Launch/adopt of the project-folder default (
worktree.open/workspace.createon project open) (Task 10). - Live path join so Local-flag delete of unmapped leftover extras cannot git-remove a Herdr-open checkout (#446).
- Session store / leftover sqlite UUID on New Tab (#447; Task 6).
- Starting a new
HerdrRuntimeSync/events.subscribe, changing the v0.9.0 pin, or #394 Task 16 / #432. - Implementing or closing #394 issues #395–#434 or line-count trackers.
- Opening a pull request.
Standing constraints
- Do not treat sqlite
profilesas source of truth. Do not add a path cache that can disagree with live Herdr and still win. projects(and project groups / notes-as-2code-data) remain 2code sqlite.- Join key remains path ↔ live Herdr cwd/worktree group.
- Never let Local and Herdr own the same worktree.
- Preserve existing 2code interaction. UX change is allowed only when Herdr cannot back the old clicks/labels; this task names no new exception.
- One task; stack on
task-6-herdr-session-store. Do not open a PR until the parent plan is complete.