Skip to content

fix(handoff): set mode and repositoryId together on cloud hand off#1958

Merged
jonathanlab merged 2 commits intomainfrom
fix/handoff-atomic-fix
Apr 30, 2026
Merged

fix(handoff): set mode and repositoryId together on cloud hand off#1958
jonathanlab merged 2 commits intomainfrom
fix/handoff-atomic-fix

Conversation

@jonathanlab
Copy link
Copy Markdown
Contributor

The cloud to local handoff saga only set workspace.mode to "local" but left repositoryId null, which broke everything.


Created with PostHog Code

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/code/src/main/services/handoff/service.test.ts:89-90
**`workspaceRepo` mock incomplete for new execute path**

`attachWorkspaceToFolder` calls `this.workspaceRepo.findByTaskId(taskId)` and `this.workspaceRepo.setModeAndRepository(...)`, but the mock here only provides `updateMode`. Any test that exercises `service.execute()` will throw `"workspaceRepo.findByTaskId is not a function"` rather than a clear test failure. Worth extending the mock now so future execute-path tests don't silently regress.

### Issue 2 of 2
apps/code/src/main/services/handoff/handoff-saga.ts:127-137
**Mutable closure variable for revert leaks state across async boundary**

`attachmentRevert` is captured in a mutable outer variable and assigned inside the `execute` callback. The saga framework guarantees `execute` runs before `rollback`, so this is safe today, but it's a fragile pattern — if the step API ever changes or a parallel step is introduced, the rollback could silently call `null?.()` instead of the real revert. Returning the revert through the saga step's output type, if the framework supports it, would be cleaner.

Reviews (1): Last reviewed commit: "fix(handoff): set mode and repositoryId ..." | Re-trigger Greptile

Comment thread apps/code/src/main/services/handoff/service.test.ts Outdated
Comment thread apps/code/src/main/services/handoff/handoff-saga.ts Outdated
Generated-By: PostHog Code
Task-Id: e2a44dd9-f5de-433e-8d8c-dce9920f20ba
@jonathanlab jonathanlab added the Create release This will trigger a new release label Apr 30, 2026
@jonathanlab jonathanlab merged commit 8941040 into main Apr 30, 2026
15 checks passed
@jonathanlab jonathanlab deleted the fix/handoff-atomic-fix branch April 30, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Create release This will trigger a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants