Commit c8bb17c
feat: add configurable worktree project mappings (#481)
Closes #416.
Adds user-configurable rules that map worktree paths back to a canonical
project, so worktree sessions group with the parent repo instead of
becoming
a separate project derived from the branch name.
The built-in parser infers a session's project from its `cwd`, which
works for
standard layouts but not custom worktree conventions like
`~/code/{project}.worktrees/feat/my-feature/` — those sessions end up
under
`my-feature` rather than `{project}`. This branch adds a manual override
that
lives in SQLite, is scoped to the current machine, and is applied both
as new
sessions stream in and to existing sessions on demand.
## How it works
- New `worktree_project_mappings` table keyed by `(machine,
path_prefix)` with
an `enabled` flag. Path prefixes are cleaned and have trailing
separators
stripped so matches are stable regardless of how a user types the
prefix.
- The sync engine loads the active mappings for the host machine on each
pass
and rewrites `project` for any session whose `cwd` falls under an
enabled
prefix. The resolver is wired into all ingestion paths: single-session
writes, incremental sync, bulk resync, and the rebuild-and-swap full
resync. Excluded, trashed, and skipped session files are left alone so
the
rewriter does not resurrect intentionally removed data.
- REST API under `/api/v1/settings/worktree-mappings` (list / create /
update /
delete / apply). The server derives the machine identifier itself
instead
of accepting it from the client, so a mapping created on one machine
never
bleeds into another machine's view of synced sessions.
- Settings panel in the SPA for adding, editing, toggling, and deleting
mappings, plus an Apply action that runs the rewrite over
already-imported
sessions and reports how many were matched and updated.
## Notes
- Mappings are explicit and manual — there is no auto-discovery. The
intent
is to let users formalize their personal layout once and have it stick.
- Mappings only mutate `project`; the rest of the session record,
including
data carried through the bulk resync's rebuild-and-copy path, is
preserved.
---------
Co-authored-by: OpenAI Codex <noreply@openai.com>
Co-authored-by: Wes McKinney <wesmckinn+git@gmail.com>1 parent 9beed32 commit c8bb17c
14 files changed
Lines changed: 2956 additions & 19 deletions
File tree
- frontend/src/lib
- api
- components/settings
- internal
- db
- server
- sync
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
813 | 813 | | |
814 | 814 | | |
815 | 815 | | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
816 | 885 | | |
817 | 886 | | |
818 | 887 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| |||
0 commit comments