Skip to content

refactor(session): effectify Session service - #19449

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

refactor(session): effectify Session service#19449
kitlangton merged 3 commits into
devfrom
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
Co-authored-by: ian-morgan99 <106852423+ian-morgan99@users.noreply.github.com>
loocor pushed a commit to loocor/opencode that referenced this pull request Mar 30, 2026
balcsida pushed a commit to balcsida/opencode that referenced this pull request Apr 8, 2026
xywsxp pushed a commit to xywsxp/opencode that referenced this pull request Apr 24, 2026
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request May 5, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
avion23 pushed a commit to avion23/opencode that referenced this pull request Jun 10, 2026
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment