Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(preflight): never repin the shared editable install from a linked worktree

rubenluetke10-beepd577fcde8552
diff --git a/docs/BUGS.md b/docs/BUGS.md
index 6f0a863220..d9850fb564 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -15445,3 +15445,31 @@ nothing; only `sudo mdutil -E /` repairs it. The installer now proves the stall
finishing silently on an app search cannot find. Launchpad listed the app all
along. Guards: `tests/unit/setup/test_macos_dock.py`,
`tests/unit/install/test_installer_flow.py`.
+
+## BUG-219: after a restart the desktop app booted an agent's stale branch — onboarding again, settings and IDE panes "gone" (HIGH, FIXED 2026-09-28)
+
+**Symptom.** The app was closed and restarted and came back on day-old code,
+walking the user through onboarding as if nothing had ever been configured.
+Every Agentic IDE workspace was closed.
+
+**Cause.** A coding agent ran `scripts/preflight.ps1` inside its own linked
+git worktree. Check 2 ran `pip install -e .` there, which repins the ONE
+editable install in the user's site-packages — the same pin the installed
+desktop app imports `jarvis` through. Nothing changed while the app kept
+running (its code was already in memory); the next launch, a day later,
+imported the worktree's branch and pinned the working directory to that
+worktree, so it read the worktree's empty `data/` folder: no setup state
+(onboarding), default settings, and the autostart shortcut rewritten to the
+worktree. The user's real `data/` was never touched.
+
+**Fix.** `preflight.ps1` detects a linked worktree (`--git-dir` differs from
+`--git-common-dir`) and leaves the shared pin alone there; its import check
+runs with the worktree root on `PYTHONPATH`, the way pytest
+(`pythonpath = ["."]`) sees it. The primary checkout still self-heals the pin.
+The rulebook's restore-trap bullet now forbids `pip install -e` from a linked
+worktree.
+
+**Recovery.** `pip install -e . --no-deps` from the primary checkout, restart
+the app; the IDE workspaces come back from `last_session.json` via
+`POST /api/agentic-ide/workspaces/{id}/restore`, each pane resuming its CLI
+session.
diff --git a/scripts/preflight.ps1 b/scripts/preflight.ps1
index c6f0a2b275..699f472f7a 100644
--- a/scripts/preflight.ps1
+++ b/scripts/preflight.ps1
@@ -13,7 +13,8 @@
Five sequential checks, each printing a [GREEN] or [RED] label:
1. Git worktree assertion
- 2. Editable install repins to the current worktree
+ 2. Editable install repins to the current checkout -- primary
+ checkout ONLY; a linked worktree leaves the shared pin alone
3. import jarvis resolves from under the current worktree
4. Stale __editable__*.pth scan (user site-packages)
5. Summary line + exit code
@@ -92,16 +93,48 @@ try {
Pop-Location
}
+# ---------------------------------------------------------------------------
+# Linked-worktree detection.
+#
+# In a linked worktree `--git-dir` (.git/worktrees/<name>) differs from
+# `--git-common-dir` (the primary checkout's .git). In the primary
+# checkout both are the same directory.
+# ---------------------------------------------------------------------------
+$IsLinkedWorktree = $false
+Push-Location $WorktreeRoot
+try {
+ $gd = (git rev-parse --path-format=absolute --git-dir 2>$null)
+ $gc = (git rev-parse --path-format=absolute --git-common-dir 2>$null)
+ if ($LASTEXITCODE -eq 0 -and $gd -and $gc) {
+ $gdAbs = [System.IO.Path]::GetFullPath((($gd -join "") -as [string]).Trim())
+ $gcAbs = [System.IO.Path]::GetFullPath((($gc -join "") -as [string]).Trim())
+ $IsLinkedWorktree = ($gdAbs.TrimEnd([char[]]'\/').ToLowerInvariant() -ne $gcAbs.TrimEnd([char[]]'\/').ToLowerInvariant())
+ }
+} finally {
+ Pop-Location
+}
+
# ---------------------------------------------------------------------------
# Check 2: Editable install.
#
-# Running `pip install -e . --no-deps -q` at the worktree root re-pins
+# Running `pip install -e . --no-deps -q` at the checkout root re-pins
# the editable-install entry in the active interpreter's site-packages
-# to THIS worktree. If the pin was stale, this fixes it as a side
+# to THIS checkout. If the pin was stale, this fixes it as a side
# effect; if it was already correct, the call is a fast no-op.
# A non-zero exit means setup.py / pyproject.toml is broken or the
# interpreter is wrong -- both are wave-blockers.
+#
+# NEVER from a linked worktree (BUG-219). That pin is shared by the whole
+# machine: the installed desktop app imports jarvis through it. An agent
+# worktree that repinned it silently turned the user's next app restart
+# into a boot of the agent's stale branch, with that worktree's empty
+# data/ folder -- onboarding again, settings "gone", panes gone. Tests
+# in a worktree do not need the pin: pytest puts the rootdir on sys.path
+# (pyproject `pythonpath = ["."]`), and Check 3 proves the import below.
# ---------------------------------------------------------------------------
+if ($IsLinkedWorktree) {
+ Write-Check "GREEN" "Linked worktree -- shared editable install left alone (BUG-219)"
+} else {
Push-Location $WorktreeRoot
try {
$pipOut = pip install -e . --no-deps -q 2>&1
@@ -118,6 +151,7 @@ try {
} finally {
Pop-Location
}
+}
# ---------------------------------------------------------------------------
# Check 3: Import path assertion.
@@ -129,9 +163,21 @@ try {
#
# Comparison is case-insensitive (Windows filesystem) and runs on
# canonical absolute paths (GetFullPath).
+#
+# A linked worktree checks with its root on PYTHONPATH -- the way pytest
+# and `python -m` from the root see it -- because the shared pin
+# deliberately still points at the primary checkout.
# ---------------------------------------------------------------------------
-$pyOut = python -c "import jarvis; print(jarvis.__file__)" 2>$null
-$pyExit = $LASTEXITCODE
+$savedPythonPath = $env:PYTHONPATH
+Push-Location $WorktreeRoot
+try {
+ if ($IsLinkedWorktree) { $env:PYTHONPATH = $WorktreeRoot }
+ $pyOut = python -c "import jarvis; print(jarvis.__file__)" 2>$null
+ $pyExit = $LASTEXITCODE
+} finally {
+ $env:PYTHONPATH = $savedPythonPath
+ Pop-Location
+}
if ($pyExit -ne 0 -or [string]::IsNullOrWhiteSpace($pyOut)) {
Write-Check "RED" "Cannot import jarvis package (python exit $pyExit)"
} else {