diff --git a/packages/core/src/location-activity.ts b/packages/core/src/location-activity.ts index c98319027a20..7aa3ed68dc9a 100644 --- a/packages/core/src/location-activity.ts +++ b/packages/core/src/location-activity.ts @@ -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)), ) diff --git a/packages/core/test/location-activity.test.ts b/packages/core/test/location-activity.test.ts index e7a10ed15179..7f20d05704ce 100644 --- a/packages/core/test/location-activity.test.ts +++ b/packages/core/test/location-activity.test.ts @@ -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([]) + }), + ) })