Skip to content

Commit b1e71c6

Browse files
committed
Merge main into fix/new-provider-models-visible
2 parents 7bbcf9a + 0fcd5f9 commit b1e71c6

29 files changed

Lines changed: 355 additions & 58 deletions

‎.coderabbit.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
reviews:
2+
high_level_summary: false
23
review_status: false
34
auto_review:
45
enabled: true

‎apps/desktop/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@t3tools/desktop",
3-
"version": "0.0.43",
3+
"version": "0.0.44",
44
"private": true,
55
"type": "module",
66
"main": "dist-electron/boot.cjs",

‎apps/server/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "t3",
3-
"version": "0.0.43",
3+
"version": "0.0.44",
44
"license": "MIT",
55
"repository": {
66
"type": "git",

‎apps/server/scripts/acp-mock-agent.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,12 @@ const program = Effect.gen(function* () {
621621
Effect.gen(function* () {
622622
const requestedSessionId = String(request.sessionId ?? sessionId);
623623
promptCount += 1;
624+
if (
625+
process.env.T3_ACP_CRASH_PROMPT === "1" &&
626+
request.prompt.some((part) => part.type === "text" && part.text === "crash now")
627+
) {
628+
return yield* Effect.sync(() => process.exit(23));
629+
}
624630

625631
if (completeFirstPromptOnCancel && promptCount === 1) {
626632
yield* agent.client.sessionUpdate({

‎apps/server/src/provider/CodexInstallation.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ it.effect("requires an update before running an older activated managed installa
281281
'{"version":"0.155.1"}',
282282
);
283283
const restarted = yield* makeHarness({ baseDir: first.baseDir });
284-
expect((yield* Effect.flip(restarted.installation.resolve())).detail).toMatch(
285-
/Use >=\d+\.\d+\.\d+/,
284+
expect((yield* Effect.flip(restarted.installation.resolve())).detail).toContain(
285+
"outside the supported range",
286286
);
287287
yield* restarted.installation.start;
288288
expect((yield* terminalState(restarted.installation)).phase).toBe("succeeded");

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,66 @@ it.layer(grokAdapterTestLayer)("GrokAdapterLive", (it) => {
363363
}),
364364
);
365365

366+
it.effect("retires a crashed process so a deliberate retry can resume", () =>
367+
Effect.gen(function* () {
368+
const threadId = ThreadId.make("grok-crash-recovery");
369+
const tempDir = yield* Effect.promise(() =>
370+
NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "grok-crash-recovery-")),
371+
);
372+
const requestLogPath = NodePath.join(tempDir, "requests.ndjson");
373+
const wrapper = yield* Effect.promise(() =>
374+
makeMockGrokWrapper({
375+
T3_ACP_CRASH_PROMPT: "1",
376+
T3_ACP_REQUEST_LOG_PATH: requestLogPath,
377+
}),
378+
);
379+
const adapter = yield* makeTestAdapter(wrapper);
380+
const exited =
381+
yield* Deferred.make<Extract<ProviderRuntimeEvent, { type: "session.exited" }>>();
382+
const events = yield* Stream.runForEach(adapter.streamEvents, (event) =>
383+
event.type === "session.exited"
384+
? Deferred.succeed(exited, event).pipe(Effect.asVoid)
385+
: Effect.void,
386+
).pipe(Effect.forkChild);
387+
const input = {
388+
threadId,
389+
provider: ProviderDriverKind.make("grok"),
390+
cwd: process.cwd(),
391+
runtimeMode: "full-access" as const,
392+
};
393+
const session = yield* adapter.startSession(input);
394+
const failure = yield* Effect.flip(
395+
adapter.sendTurn({ threadId, input: "crash now", attachments: [] }),
396+
);
397+
assert.isDefined(failure);
398+
assert.isFalse(yield* adapter.hasSession(threadId));
399+
const retryDuringTeardown = yield* Effect.flip(
400+
adapter.sendTurn({ threadId, input: "retry during teardown", attachments: [] }),
401+
);
402+
assert.equal(retryDuringTeardown._tag, "ProviderAdapterSessionNotFoundError");
403+
assert.equal((yield* Deferred.await(exited)).payload.exitKind, "error");
404+
assert.deepStrictEqual(yield* adapter.listSessions(), []);
405+
yield* Fiber.interrupt(events);
406+
yield* adapter.startSession({ ...input, resumeCursor: session.resumeCursor });
407+
const turn = yield* adapter.sendTurn({ threadId, input: "retry now", attachments: [] });
408+
assert.equal(turn.threadId, threadId);
409+
yield* adapter.stopSession(threadId);
410+
const requests = yield* Effect.promise(() => readJsonLines(requestLogPath));
411+
assert.equal(requests.filter((request) => request.method === "session/new").length, 1);
412+
assert.deepStrictEqual(session.resumeCursor, {
413+
schemaVersion: 1,
414+
sessionId: "mock-session-1",
415+
});
416+
const resumes = requests.filter((request) => request.method === "session/load");
417+
assert.equal(resumes.length, 1);
418+
assert.deepStrictEqual(resumes[0]?.params, {
419+
sessionId: "mock-session-1",
420+
cwd: process.cwd(),
421+
mcpServers: [],
422+
});
423+
}),
424+
);
425+
366426
it.effect("starts a session and maps mock ACP prompt flow to runtime events", () =>
367427
Effect.gen(function* () {
368428
const threadId = ThreadId.make("grok-mock-thread");

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

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ interface GrokSessionContext {
175175
currentModelId: string | undefined;
176176
currentReasoningEffort: string | undefined;
177177
stopped: boolean;
178+
terminated: boolean;
178179
/** Live monitor/shell identities and their originating turns. */
179180
readonly backgroundTasks: Map<string, GrokBackgroundTaskRecord>;
180181
}
@@ -345,6 +346,7 @@ export function grokPromptSettlementBelongsToContext(input: {
345346

346347
export function makeGrokAdapter(grokSettings: GrokSettings, options?: GrokAdapterLiveOptions) {
347348
return Effect.gen(function* () {
349+
const ownerScope = yield* Effect.scope;
348350
const boundInstanceId = options?.instanceId ?? ProviderInstanceId.make("grok");
349351
const fileSystem = yield* FileSystem.FileSystem;
350352
const path = yield* Path.Path;
@@ -922,7 +924,7 @@ export function makeGrokAdapter(grokSettings: GrokSettings, options?: GrokAdapte
922924
threadId: ThreadId,
923925
): Effect.Effect<GrokSessionContext, ProviderAdapterSessionNotFoundError> => {
924926
const ctx = sessions.get(threadId);
925-
if (!ctx || ctx.stopped) {
927+
if (!ctx || ctx.stopped || ctx.terminated) {
926928
return Effect.fail(
927929
new ProviderAdapterSessionNotFoundError({ provider: PROVIDER, threadId }),
928930
);
@@ -946,7 +948,7 @@ export function makeGrokAdapter(grokSettings: GrokSettings, options?: GrokAdapte
946948
...(yield* makeEventStamp()),
947949
provider: PROVIDER,
948950
threadId: ctx.threadId,
949-
payload: { exitKind: "graceful" },
951+
payload: { exitKind: ctx.terminated ? "error" : "graceful" },
950952
});
951953
});
952954

@@ -1316,12 +1318,35 @@ export function makeGrokAdapter(grokSettings: GrokSettings, options?: GrokAdapte
13161318
? normalizeGrokReasoningEffort(requestedStartReasoningEffort)
13171319
: currentStartReasoningEffort,
13181320
stopped: false,
1321+
terminated: false,
13191322
backgroundTasks: new Map(),
13201323
};
13211324

13221325
const nf = yield* Stream.runDrain(
13231326
Stream.mapEffect(acp.getEvents(), (event) =>
13241327
Effect.gen(function* () {
1328+
if (event._tag === "ConnectionTerminated") {
1329+
ctx.terminated = true;
1330+
yield* withThreadLock(
1331+
ctx.threadId,
1332+
Effect.gen(function* () {
1333+
if (sessions.get(ctx.threadId) !== ctx) return;
1334+
if (ctx.activeTurnId) {
1335+
yield* settlePromptInFlight(
1336+
ctx.threadId,
1337+
ctx.activeTurnId,
1338+
ctx.acpSessionId,
1339+
{
1340+
errorMessage: "Grok connection terminated.",
1341+
settleAllPrompts: true,
1342+
},
1343+
);
1344+
}
1345+
yield* stopSessionInternal(ctx);
1346+
}),
1347+
).pipe(Effect.forkIn(ownerScope));
1348+
return;
1349+
}
13251350
if (event._tag === "EventStreamBarrier") {
13261351
yield* Deferred.succeed(event.acknowledge, undefined);
13271352
return;
@@ -2165,12 +2190,16 @@ export function makeGrokAdapter(grokSettings: GrokSettings, options?: GrokAdapte
21652190
);
21662191

21672192
const listSessions: GrokAdapterShape["listSessions"] = () =>
2168-
Effect.sync(() => Array.from(sessions.values(), (c) => ({ ...c.session })));
2193+
Effect.sync(() =>
2194+
Array.from(sessions.values())
2195+
.filter((c) => !c.terminated)
2196+
.map((c) => ({ ...c.session })),
2197+
);
21692198

21702199
const hasSession: GrokAdapterShape["hasSession"] = (threadId) =>
21712200
Effect.sync(() => {
21722201
const c = sessions.get(threadId);
2173-
return c !== undefined && !c.stopped;
2202+
return c !== undefined && !c.stopped && !c.terminated;
21742203
});
21752204

21762205
const stopAll: GrokAdapterShape["stopAll"] = () =>

‎apps/web/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@t3tools/web",
3-
"version": "0.0.43",
3+
"version": "0.0.44",
44
"private": true,
55
"type": "module",
66
"scripts": {

‎apps/web/src/components/BranchToolbarBranchSelector.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ export function BranchToolbarBranchSelector({
793793
number={prNumber}
794794
url={prUrl}
795795
status={displayedPrStatus}
796-
onOpenStack={() => useRightPanelStore.getState().open(threadRef, "pull-requests")}
796+
onOpenList={() => useRightPanelStore.getState().open(threadRef, "pull-requests")}
797797
onOpenPullRequest={(event) => {
798798
if (prUrl) openPrLink(event, prUrl);
799799
}}

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,11 +1515,12 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
15151515
const accessibleTitle = isRenaming ? null : <span className="sr-only">{thread.title}</span>;
15161516

15171517
// Stacks show their layer count; multiple unrelated links show their total count.
1518-
// Plain clicks open T3; individual PR links also support opening the host in a new tab.
1518+
// Either opens the thread's pull requests tab; a single PR link opens that PR and still
1519+
// supports opening the host in a new tab.
15191520
const prBadgeShape = supportsMultiplePullRequests
15201521
? resolveThreadPullRequestBadge(thread.pullRequests)
15211522
: null;
1522-
const handlePrStackClick = useCallback(() => {
1523+
const handlePrListClick = useCallback(() => {
15231524
useRightPanelStore.getState().open(threadRef, "pull-requests");
15241525
if (!props.isActive) onThreadActivate(threadRef);
15251526
}, [onThreadActivate, props.isActive, threadRef]);
@@ -1531,7 +1532,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
15311532
number={pr?.number ?? currentLinkedPr?.number}
15321533
url={pr?.url ?? currentLinkedPr?.url}
15331534
status={prStatus}
1534-
onOpenStack={handlePrStackClick}
1535+
onOpenList={handlePrListClick}
15351536
onOpenPullRequest={handlePrClick}
15361537
/>
15371538
) : null;

0 commit comments

Comments
 (0)