Skip to content

refactor(session): effectify Session service#19449

Merged
kitlangton merged 3 commits intodevfrom
kit/effectify-session
Mar 27, 2026
Merged

refactor(session): effectify Session service#19449
kitlangton merged 3 commits intodevfrom
kit/effectify-session

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

  • Migrate Session to Effect service pattern (Service, Interface, layer, defaultLayer)
  • Bus.publish and Config.get go through Effect services (yield* bus.publish, yield* config.get)
  • Auto-share uses Effect.forkIn(scope) for fire-and-forget
  • Extracted patch() helper for SyncEvent.Updated boilerplate
  • Internal layer methods call each other directly, not through facades
  • Pure functions (getUsage, plan, isDefaultTitle) stay outside the layer
  • Facades use existing fn() wrapper for .schema compatibility with server routes

Known inherited weaknesses (not introduced by this PR)

  • remove() swallows all errors via try/catch (catches defects from throw)
  • updatePart/updatePartDelta called without await in prompt.ts stream handlers — timing was already fragile

Verified

  • runPromise preserves thrown error types (instanceof NotFoundError still works in middleware)
  • session_diff storage key is correct
  • All 1617 unit tests pass
  • Full monorepo typecheck passes (13/13 packages)

Test plan

  • bun run typecheck from packages/opencode
  • bun run test from packages/opencode (1617 pass)
  • CI (unit + e2e)

Migrate Session to Effect service pattern with Bus.Service and
Config.Service as layer dependencies. All methods defined as Effect.fn
inside the layer, exposed through fn() facades with runPromise.

- Added Session.Service, Interface, layer, defaultLayer
- Bus.publish and Config.get now go through Effect services
- Auto-share uses Effect.forkIn(scope) for true fire-and-forget
- Extracted patch() helper for SyncEvent.Updated boilerplate
- Internal methods call each other directly (not through facades)
- Pure functions (getUsage, plan, isDefaultTitle) stay outside the layer
@kitlangton kitlangton marked this pull request as ready for review March 27, 2026 19:06
@kitlangton kitlangton merged commit e5f0e81 into dev Mar 27, 2026
8 checks passed
@kitlangton kitlangton deleted the kit/effectify-session branch March 27, 2026 20:25
Copilot AI pushed a commit to ian-morgan99/opencode that referenced this pull request Mar 28, 2026
loocor pushed a commit to loocor/opencode that referenced this pull request Mar 30, 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