mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-13 19:46:16 +03:00
fix(core): canonicalize location in activity tracking (#56259)
This commit is contained in:
committed by
GitHub
Unverified
parent
3fb3e52ac7
commit
9a7d4ed0f4
@@ -31,9 +31,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)),
|
||||
)
|
||||
|
||||
@@ -204,7 +204,11 @@ describe("LocationActivity eviction", () => {
|
||||
yield* Location.Service.pipe(Effect.provide(map.get(later)), Effect.scoped)
|
||||
yield* TestClock.adjust("30 minutes")
|
||||
// Keep fresh work active while a different graph reaches its own deadline.
|
||||
yield* bus.publish(SessionEvent.Execution.Started, { sessionID: newcomer }, { location: ref })
|
||||
yield* bus.publish(
|
||||
SessionEvent.Execution.Started,
|
||||
{ sessionID: newcomer },
|
||||
{ location: Location.Ref.make({ directory: ref.directory }) },
|
||||
)
|
||||
yield* TestClock.adjust("32 minutes")
|
||||
expect(Array.from(yield* execution.active)).toEqual([newcomer])
|
||||
expect(Array.from(yield* RcMap.keys(map.rcMap))).toEqual([ref])
|
||||
@@ -219,4 +223,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([])
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user