fix(router): skip git fetch/checkout when /workspace has uncommitted changes#65
Merged
Merged
Conversation
…changes
Session pods crashloop in Init:0/1 when the PVC at /workspace carries
uncommitted edits from a prior session — `git checkout` aborts with
"local changes would be overwritten" and the user is locked out of their
session.
Detect a dirty workspace (any tracked diff or non-ignored untracked
file) and skip the git fetch + checkout phase entirely when present. The
workspace was initialized on an earlier pod start so the pod can come up
against the existing state. To get back onto the session branch the
user commits or discards the changes from inside the pod and restarts.
This preserves the user's mental model ("my work is where I left it")
with no surprising stash entries piling up and no risk of pop-time
conflicts. A fresh-clone workspace is never dirty so the first-start
path is unchanged.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
45dc68d to
b34f8e0
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Init:0/1when the PVC at/workspacecarries uncommitted edits from a prior session —git checkoutaborts witherror: Your local changes to the following files would be overwritten by checkout.Why this approach (vs. auto-stash)
Considered stashing the uncommitted work and either popping it or leaving it in the stash list. Rejected because:
git stash liston every restart and makes it non-obvious to the user where their edits went.Trade-off: if the session annotation says branch X but the workspace was left on branch Y, the pod silently starts on Y. In practice this is unlikely because each session pod is hash-scoped to a single branch — but worth knowing.
Repro
Init container logs from a pod hitting this in production:
Test plan
bun test src/pod-manager.test.ts— 67 pass (1 new test added asserting the dirty-workspace guard wraps fetch and both checkout branches)bun run typecheck— cleanopencode-init: uncommitted changes detected in /workspace; skipping git fetch/checkout to preserve work🤖 Generated with Claude Code