Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/core/src/location-activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ export function layer(options: { readonly timeToLive?: Duration.Input; readonly
)

const unsubscribe = yield* bus.listen((event) => {
if (!isSessionEvent(event)) return Effect.void
const location = event.location
if (!location) return Effect.void
if (!isSessionEvent(event) || !event.location) return Effect.void
const location = LocationServiceMap.canonical(event.location)
return RcMap.has(locations.rcMap, location).pipe(
Effect.flatMap((active) => (active ? touch(location) : Effect.void)),
)
Expand Down
26 changes: 26 additions & 0 deletions packages/core/test/location-activity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,30 @@ describe("LocationActivity eviction", () => {
)
}),
)

it.effect("refreshes inactivity deadline for session events with non-canonical location refs", () =>
Effect.gen(function* () {
const bus = yield* Bus.Service
const map = yield* LocationServiceMap.Service
const raw = Location.Ref.make({ directory: AbsolutePath.make("/project") })
const ref = LocationServiceMap.canonical(raw)

yield* Location.Service.pipe(Effect.provide(map.get(raw)), Effect.scoped)
expect(yield* RcMap.has(map.rcMap, raw)).toBe(false)
expect(yield* RcMap.has(map.rcMap, ref)).toBe(true)

yield* TestClock.adjust("31 minutes")
yield* bus.publish(
SessionEvent.Execution.Started,
{ sessionID: Session.ID.make("ses_activity") },
{ location: raw },
)

yield* TestClock.adjust("32 minutes")
expect(Array.from(yield* RcMap.keys(map.rcMap))).toEqual([ref])

yield* TestClock.adjust("30 minutes")
expect(Array.from(yield* RcMap.keys(map.rcMap))).toEqual([])
}),
)
})
Loading