fix(orchestration): thread visits no longer create activity loops (#5038)
This commit is contained in:
1 parent
6978955a43
commit
f076636c21
3 files changed
+77
No files matched your search
@@ -84,6 +84,75 @@ it("includes imported runless history when selecting fork context through a run"
|
||||
});
|
||||
|
||||
it.layer(TestLayer)("ProjectionStoreV2", (it) => {
|
||||
it.effect("does not treat visited or marked-unread state as thread activity", () =>
|
||||
Effect.gen(function* () {
|
||||
const projectionStore = yield* ProjectionStoreV2;
|
||||
const createdAt = yield* DateTime.now;
|
||||
const visitedOccurredAt = DateTime.add(createdAt, { seconds: 1 });
|
||||
const markedUnreadOccurredAt = DateTime.add(createdAt, { seconds: 2 });
|
||||
const threadId = ThreadId.make("thread:projection-read-state");
|
||||
const projectId = ProjectId.make("project:projection-read-state");
|
||||
const thread = {
|
||||
createdBy: "user" as const,
|
||||
creationSource: "web" as const,
|
||||
id: threadId,
|
||||
projectId,
|
||||
title: "Projection read state",
|
||||
providerInstanceId,
|
||||
modelSelection,
|
||||
runtimeMode: "full-access" as const,
|
||||
interactionMode: "default" as const,
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
activeProviderThreadId: null,
|
||||
lineage: {
|
||||
parentThreadId: null,
|
||||
relationshipToParent: null,
|
||||
rootThreadId: threadId,
|
||||
},
|
||||
forkedFrom: null,
|
||||
createdAt,
|
||||
updatedAt: createdAt,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
lastVisitedAt: null,
|
||||
deletedAt: null,
|
||||
};
|
||||
|
||||
yield* projectionStore.apply({
|
||||
id: EventId.make("event:projection-read-state:created"),
|
||||
type: "thread.created",
|
||||
threadId,
|
||||
occurredAt: createdAt,
|
||||
payload: thread,
|
||||
});
|
||||
yield* projectionStore.apply({
|
||||
id: EventId.make("event:projection-read-state:visited"),
|
||||
type: "thread.visited",
|
||||
threadId,
|
||||
occurredAt: visitedOccurredAt,
|
||||
payload: { ...thread, lastVisitedAt: createdAt },
|
||||
});
|
||||
|
||||
const visited = yield* projectionStore.getThreadProjection(threadId);
|
||||
assert.deepEqual(visited.thread.lastVisitedAt, createdAt);
|
||||
assert.deepEqual(visited.thread.updatedAt, createdAt);
|
||||
|
||||
yield* projectionStore.apply({
|
||||
id: EventId.make("event:projection-read-state:marked-unread"),
|
||||
type: "thread.marked-unread",
|
||||
threadId,
|
||||
occurredAt: markedUnreadOccurredAt,
|
||||
payload: thread,
|
||||
});
|
||||
|
||||
const markedUnread = yield* projectionStore.getThreadProjection(threadId);
|
||||
assert.isNull(markedUnread.thread.lastVisitedAt);
|
||||
assert.deepEqual(markedUnread.thread.updatedAt, createdAt);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("only exposes interruptible runs through the shell activeRunId", () =>
|
||||
Effect.gen(function* () {
|
||||
const projectionStore = yield* ProjectionStoreV2;
|
||||
|
||||
@@ -1804,6 +1804,12 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
|
||||
event.type !== "thread.archived" &&
|
||||
event.type !== "thread.unarchived" &&
|
||||
event.type !== "thread.deleted" &&
|
||||
event.type !== "thread.settled" &&
|
||||
event.type !== "thread.unsettled" &&
|
||||
event.type !== "thread.snoozed" &&
|
||||
event.type !== "thread.unsnoozed" &&
|
||||
event.type !== "thread.visited" &&
|
||||
event.type !== "thread.marked-unread" &&
|
||||
event.type !== "thread.metadata-updated" &&
|
||||
event.type !== "thread.runtime-mode-updated" &&
|
||||
event.type !== "thread.interaction-mode-updated" &&
|
||||
|
||||
@@ -18,6 +18,7 @@ import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Queue from "effect/Queue";
|
||||
import * as Stream from "effect/Stream";
|
||||
import * as TestClock from "effect/testing/TestClock";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
|
||||
import * as CheckpointStore from "../checkpointing/CheckpointStore.ts";
|
||||
@@ -1312,6 +1313,7 @@ it.layer(SharedApplicationDataPlaneTestLayer)("visited projection", (it) => {
|
||||
assert.isNull(created.thread.lastVisitedAt);
|
||||
const createdUpdatedAt = created.thread.updatedAt;
|
||||
|
||||
yield* TestClock.adjust("1 second");
|
||||
yield* orchestrator.dispatch({
|
||||
type: "thread.visit",
|
||||
commandId: CommandId.make("runtime-layer-visited-thread-visit"),
|
||||
|
||||
Reference in new issue
Block a user