|
| 1 | +# Worktrees |
| 2 | + |
| 3 | +Git worktrees share tracked files with the main checkout, but ignored local files are separate per worktree. Before running a dev server, browser preview, or private-data test from a worktree, copy or link the local environment and data cache from the main checkout. |
| 4 | + |
| 5 | +## Required local files |
| 6 | + |
| 7 | +The main checkout normally has local-only files that are intentionally ignored by git: |
| 8 | + |
| 9 | +- `.env.local` - private environment variables loaded by Vite/SvelteKit. |
| 10 | +- `data/` - local cache for large private datasets, including `data/cleaned-vault-prices-1h.parquet`. |
| 11 | + |
| 12 | +Without these files, vault metadata may still load if `TS_PRIVATE_TOP_VAULTS_URL` is set manually, but chart endpoints that need the historical parquet can fail with 500 responses. |
| 13 | + |
| 14 | +## Environment variables |
| 15 | + |
| 16 | +Copy or symlink `.env.local` from the main checkout so the worktree gets the same private server configuration: |
| 17 | + |
| 18 | +```shell |
| 19 | +ln -s /home/mikko/code/frontend/.env.local .env.local |
| 20 | +``` |
| 21 | + |
| 22 | +The important vault data variables are: |
| 23 | + |
| 24 | +```env |
| 25 | +TS_PRIVATE_R2_ACCOUNT_ID= |
| 26 | +TS_PRIVATE_R2_ACCESS_KEY_ID= |
| 27 | +TS_PRIVATE_R2_SECRET_ACCESS_KEY= |
| 28 | +TS_PRIVATE_R2_BUCKET_NAME= |
| 29 | +TS_PRIVATE_TOP_VAULTS_URL= |
| 30 | +TS_PRIVATE_VAULT_PRICES_PARQUET_URL= |
| 31 | +``` |
| 32 | + |
| 33 | +R2 credentials are the canonical source for both vault metadata and the historical parquet. `TS_PRIVATE_TOP_VAULTS_URL` and `TS_PRIVATE_VAULT_PRICES_PARQUET_URL` are fallback direct URLs when R2 is not configured. |
| 34 | + |
| 35 | +Restart the dev server after changing `.env.local`; Vite reads these values at process start. |
| 36 | + |
| 37 | +## Data symlink |
| 38 | + |
| 39 | +The historical vault parquet is large and is read from a path relative to the current worktree: |
| 40 | + |
| 41 | +```text |
| 42 | +data/cleaned-vault-prices-1h.parquet |
| 43 | +``` |
| 44 | + |
| 45 | +Use a symlink instead of duplicating the cache: |
| 46 | + |
| 47 | +```shell |
| 48 | +ln -s /home/mikko/code/frontend/data data |
| 49 | +``` |
| 50 | + |
| 51 | +This allows worktree-local endpoints such as `/trading-view/vaults/{id}/metrics` to find the same cached parquet as the main checkout. |
| 52 | + |
| 53 | +## Checks |
| 54 | + |
| 55 | +Confirm ignored local resources are present: |
| 56 | + |
| 57 | +```shell |
| 58 | +ls -l .env.local data/cleaned-vault-prices-1h.parquet |
| 59 | +git check-ignore -v .env.local data/cleaned-vault-prices-1h.parquet |
| 60 | +``` |
| 61 | + |
| 62 | +Confirm the running dev server inherited private environment variables: |
| 63 | + |
| 64 | +```shell |
| 65 | +ps -eo pid,cmd | rg 'vite|pnpm run dev' |
| 66 | +tr '\0' '\n' < /proc/<vite-pid>/environ | rg 'TS_PRIVATE_R2_|TS_PRIVATE_TOP_VAULTS_URL|TS_PRIVATE_VAULT_PRICES_PARQUET_URL' |
| 67 | +``` |
| 68 | + |
| 69 | +Confirm vault chart data works: |
| 70 | + |
| 71 | +```shell |
| 72 | +curl -s 'http://127.0.0.1:5173/trading-view/vaults/<vault-id>/metrics' |
| 73 | +``` |
0 commit comments