fix(context-restore): name another branch as a cause when the saved commit is not in history

Cross-branch resume (Conductor handoff) is a supported restore path, and there
the checkpoint's commit is usually not an ancestor of HEAD. The diverged line
said only 'rebased, reset, or not fetched'. It now names 'saved on another
branch' first; the new test case covers a save on a feature branch restored
from main.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-10-24 22:55:59 +00:00
1 parent d540b102ac
commit 0ddbc5b04d
3 files changed
+16 -4

No files matched your search

+2 -2
View File
@@ -560,8 +560,8 @@ fi
under **Verify first**: the saving session could not know about those commits,
so any step may already be done.
- `HEAD_DIVERGED` or `HEAD_UNKNOWN`: print `This checkpoint was saved at {first 7
characters of head}, which is not in this checkout's history (rebased, reset, or
not fetched).` and list every item under Verify first.
characters of head}, which is not in this checkout's history (saved on another
branch, rebased, reset, or not fetched).` and list every item under Verify first.
- `HEAD_UNTRACKED`: print `This checkpoint predates commit tracking; restore cannot tell whether work landed after it.`
and sort as usual.
+2 -2
View File
@@ -236,8 +236,8 @@ fi
under **Verify first**: the saving session could not know about those commits,
so any step may already be done.
- `HEAD_DIVERGED` or `HEAD_UNKNOWN`: print `This checkpoint was saved at {first 7
characters of head}, which is not in this checkout's history (rebased, reset, or
not fetched).` and list every item under Verify first.
characters of head}, which is not in this checkout's history (saved on another
branch, rebased, reset, or not fetched).` and list every item under Verify first.
- `HEAD_UNTRACKED`: print `This checkpoint predates commit tracking; restore cannot tell whether work landed after it.`
and sort as usual.
+12
View File
@@ -144,6 +144,18 @@ describe('context-restore compares the checkpoint with HEAD', () => {
expect(headCheck(app, file)).toStartWith('HEAD_DIVERGED ');
});
test('a checkpoint resumed from another branch is reported, and the prompt names that cause', () => {
const app = repo();
git(app, 'checkout', '-q', '-b', 'feature');
commit(app, 'feature work');
const file = save(app);
git(app, 'checkout', '-q', 'main');
commit(app, 'unrelated main work');
expect(headCheck(app, file)).toStartWith('HEAD_DIVERGED ');
const restore = fs.readFileSync(path.join(ROOT, 'context-restore/SKILL.md'), 'utf-8');
expect(restore).toContain('(saved on another\n branch, rebased, reset, or not fetched)');
});
test('checkpoints saved before head tracking, or with a malformed head, are never treated as current', () => {
const app = repo();
const legacy = path.join(tmp, 'legacy.md');