Skip to content

Commit 83b005e

Browse files
juliusmarmingecodex
andcommitted
Make archive session lookup best-effort
Co-authored-by: codex <[email protected]>
1 parent c811373 commit 83b005e

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎apps/server/src/ws.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,17 @@ const makeWsRpcLayer = (currentSessionId: AuthSessionId) =>
552552
const normalizedCommand = yield* normalizeDispatchCommand(command);
553553
const result = yield* dispatchNormalizedCommand(normalizedCommand);
554554
if (normalizedCommand.type === "thread.archive") {
555-
const thread = Option.getOrNull(
556-
yield* projectionSnapshotQuery.getThreadShellById(normalizedCommand.threadId),
557-
);
555+
const existingSessionStatus = yield* projectionSnapshotQuery
556+
.getThreadShellById(normalizedCommand.threadId)
557+
.pipe(
558+
Effect.map(Option.flatMapNullishOr((thread) => thread.session?.status)),
559+
Effect.catch(() => Effect.succeedNone),
560+
);
558561

559-
if (thread?.session && thread.session.status !== "stopped") {
562+
if (
563+
Option.isSome(existingSessionStatus) &&
564+
existingSessionStatus.value !== "stopped"
565+
) {
560566
yield* Effect.gen(function* () {
561567
const stopCommand = yield* normalizeDispatchCommand({
562568
type: "thread.session.stop",

0 commit comments

Comments
 (0)