Skip to content

Commit 80dd2d2

Browse files
fix(server): retain Grok notification consumer for session (#291)
Co-authored-by: T3 Code PR Stack <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 497e1d2 commit 80dd2d2

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

apps/server/src/provider/Layers/GrokAdapter.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,30 @@ it.layer(grokAdapterTestLayer)("GrokAdapterLive", (it) => {
13721372
}),
13731373
);
13741374

1375+
it.effect("keeps the notification consumer alive after the session starter fiber exits", () =>
1376+
Effect.gen(function* () {
1377+
const threadId = ThreadId.make("grok-session-notification-scope");
1378+
const wrapperPath = yield* Effect.promise(() => makeMockGrokWrapper());
1379+
const adapter = yield* makeTestAdapter(wrapperPath);
1380+
1381+
const starter = yield* adapter
1382+
.startSession({
1383+
threadId,
1384+
provider: ProviderDriverKind.make("grok"),
1385+
cwd: process.cwd(),
1386+
runtimeMode: "full-access",
1387+
})
1388+
.pipe(Effect.forkChild);
1389+
yield* Fiber.join(starter);
1390+
1391+
yield* adapter
1392+
.sendTurn({ threadId, input: "survive the starter fiber", attachments: [] })
1393+
.pipe(Effect.timeout("5 seconds"));
1394+
1395+
yield* adapter.stopSession(threadId);
1396+
}),
1397+
);
1398+
13751399
it.effect("continues streaming events when native notification logging fails", () =>
13761400
Effect.gen(function* () {
13771401
const threadId = ThreadId.make("grok-native-log-failure");

apps/server/src/provider/Layers/GrokAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ export function makeGrokAdapter(grokSettings: GrokSettings, options?: GrokAdapte
12201220
Effect.catch((cause) =>
12211221
Effect.logError("Failed to process Grok runtime notification.", { cause }),
12221222
),
1223-
Effect.forkChild,
1223+
Effect.forkIn(sessionScope),
12241224
);
12251225

12261226
ctx.notificationFiber = nf;

0 commit comments

Comments
 (0)