Skip to content

refactor(snapshot): effectify SnapshotService#17878

Merged
kitlangton merged 2 commits intodevfrom
refactor/effectify-snapshot
Mar 18, 2026
Merged

refactor(snapshot): effectify SnapshotService#17878
kitlangton merged 2 commits intodevfrom
refactor/effectify-snapshot

Conversation

@kitlangton
Copy link
Contributor

Summary

  • Converts Snapshot from a promise-based namespace with Instance ALS reads to an Effect service (SnapshotService) on the Instances LayerMap
  • Uses ChildProcessSpawner for git subprocess execution and Effect FileSystem for file operations (replaces Process.run and raw fs calls)
  • Replaces Scheduler.register with Effect.forkScoped + Schedule.spaced for hourly cleanup
  • Adds worktree to InstanceContext.Shape and Instance.current getter

Details

  • Nothrow git helper that always returns { code, text, stderr }, preserving spawn failure details
  • Parallelized before/after git show in diffFull via Effect.all({ concurrency: 2 })
  • Promise facade preserved — zero changes needed at call sites
  • Platform layers (NodeChildProcessSpawner, NodeFileSystem, NodePath) provided directly on the service layer
  • Extracted repeated git config flags into GIT_CORE / GIT_CFG / GIT_CFG_QUOTE constants

Test plan

  • All 43 existing snapshot tests pass (track, patch, revert, restore, diff, diffFull, worktrees, unicode, binary, symlinks, edge cases)
  • Typecheck clean
  • Verify extendEnv: true doesn't break git PATH resolution (behavioral difference from old Process.run env handling)
  • Verify exists + mkdir in track() doesn't cause issues vs old atomic fs.mkdir return value check

Convert Snapshot from a promise-based namespace with Instance ALS reads
to an Effect service on the Instances LayerMap.

- SnapshotService with ChildProcessSpawner for git subprocess execution
  and Effect FileSystem for file operations (replaces Process.run and
  raw fs calls)
- Nothrow git helper that always returns { code, text, stderr }, with
  spawn failure details preserved in stderr
- Hourly cleanup via Effect.forkScoped + Schedule.spaced (replaces
  Scheduler.register)
- Promise facade preserved for all existing callers
- Parallelized before/after git show in diffFull
- Add worktree to InstanceContext.Shape (needed for --work-tree flag)
- Add Instance.current getter for single ALS read
- Extract repeated git config flags into GIT_CORE/GIT_CFG/GIT_CFG_QUOTE
  constants
- Platform layers (NodeChildProcessSpawner, NodeFileSystem, NodePath)
  provided directly on the service layer
@kitlangton kitlangton merged commit 9e7c136 into dev Mar 18, 2026
8 checks passed
@kitlangton kitlangton deleted the refactor/effectify-snapshot branch March 18, 2026 01:04
AbhishekChorotiya pushed a commit to AbhishekChorotiya/opencode that referenced this pull request Mar 19, 2026
AvatarGanymede pushed a commit to AvatarGanymede/opencode-dev that referenced this pull request Mar 19, 2026
demostanis pushed a commit to demostanis/opencode that referenced this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant