Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
reviews:
high_level_summary: false
review_status: false
auto_review:
enabled: true
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@t3tools/desktop",
"version": "0.0.43",
"version": "0.0.44",
"private": true,
"type": "module",
"main": "dist-electron/boot.cjs",
Expand Down
2 changes: 1 addition & 1 deletion apps/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "t3",
"version": "0.0.43",
"version": "0.0.44",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions apps/server/scripts/acp-mock-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,12 @@ const program = Effect.gen(function* () {
Effect.gen(function* () {
const requestedSessionId = String(request.sessionId ?? sessionId);
promptCount += 1;
if (
process.env.T3_ACP_CRASH_PROMPT === "1" &&
request.prompt.some((part) => part.type === "text" && part.text === "crash now")
) {
return yield* Effect.sync(() => process.exit(23));
}

if (completeFirstPromptOnCancel && promptCount === 1) {
yield* agent.client.sessionUpdate({
Expand Down
4 changes: 3 additions & 1 deletion apps/server/src/provider/CodexInstallation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ it.effect("requires an update before running an older activated managed installa
'{"version":"0.155.1"}',
);
const restarted = yield* makeHarness({ baseDir: first.baseDir });
expect((yield* Effect.flip(restarted.installation.resolve())).detail).toContain("0.156.0");
expect((yield* Effect.flip(restarted.installation.resolve())).detail).toContain(
"outside the supported range",
);
yield* restarted.installation.start;
expect((yield* terminalState(restarted.installation)).phase).toBe("succeeded");
expect((yield* restarted.installation.resolve()).version).toBe("0.156.1");
Expand Down
10 changes: 10 additions & 0 deletions apps/server/src/provider/Layers/CodexProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ it("uses standard routing when the catalog has no default service tier", () => {
name: "Fast",
description: "1.5x speed, increased usage",
},
{
id: "ultrafast",
name: "Ultrafast",
description: "The fastest available responses for latency-sensitive work.",
},
],
supportedReasoningEfforts: [],
});
Expand All @@ -97,6 +102,11 @@ it("uses standard routing when the catalog has no default service tier", () => {
label: "Fast",
description: "1.5x speed, increased usage",
},
{
id: "ultrafast",
label: "Ultrafast",
description: "Even faster, more expensive",
},
],
currentValue: "default",
},
Expand Down
22 changes: 16 additions & 6 deletions apps/server/src/provider/Layers/CodexProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ const REASONING_EFFORT_LABELS: Readonly<Record<string, string>> = {

const DEFAULT_SERVICE_TIER_ID = "default";

/** Shorter copy for tiers whose catalog description wraps in the traits menu. */
const SERVICE_TIER_DESCRIPTIONS: Readonly<Record<string, string>> = {
ultrafast: "Even faster, more expensive",
};

function reasoningEffortLabel(reasoningEffort: string): string {
return REASONING_EFFORT_LABELS[reasoningEffort] ?? reasoningEffort;
}
Expand All @@ -115,6 +120,8 @@ export function codexPlanLabel(planType: string | null | undefined): string | un
return "ChatGPT Pro 20x Subscription";
case "prolite":
return "ChatGPT Pro 5x Subscription";
case "promax":
return "ChatGPT Pro Max Subscription";
case "team":
return "ChatGPT Team Subscription";
case "self_serve_business_prolite":
Expand Down Expand Up @@ -195,12 +202,15 @@ export function mapCodexModelCapabilities(
label: "Standard",
...(defaultServiceTier === DEFAULT_SERVICE_TIER_ID ? { isDefault: true } : {}),
},
...serviceTiers.map((tier) => ({
id: tier.id,
label: tier.name,
...(tier.description ? { description: tier.description } : {}),
...(defaultServiceTier === tier.id ? { isDefault: true } : {}),
})),
...serviceTiers.map((tier) => {
const description = SERVICE_TIER_DESCRIPTIONS[tier.id] ?? tier.description;
return {
id: tier.id,
label: tier.name,
...(description ? { description } : {}),
...(defaultServiceTier === tier.id ? { isDefault: true } : {}),
};
}),
],
currentValue: defaultServiceTier,
});
Expand Down
60 changes: 60 additions & 0 deletions apps/server/src/provider/Layers/GrokAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,66 @@ it.layer(grokAdapterTestLayer)("GrokAdapterLive", (it) => {
}),
);

it.effect("retires a crashed process so a deliberate retry can resume", () =>
Effect.gen(function* () {
const threadId = ThreadId.make("grok-crash-recovery");
const tempDir = yield* Effect.promise(() =>
NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "grok-crash-recovery-")),
);
const requestLogPath = NodePath.join(tempDir, "requests.ndjson");
const wrapper = yield* Effect.promise(() =>
makeMockGrokWrapper({
T3_ACP_CRASH_PROMPT: "1",
T3_ACP_REQUEST_LOG_PATH: requestLogPath,
}),
);
const adapter = yield* makeTestAdapter(wrapper);
const exited =
yield* Deferred.make<Extract<ProviderRuntimeEvent, { type: "session.exited" }>>();
const events = yield* Stream.runForEach(adapter.streamEvents, (event) =>
event.type === "session.exited"
? Deferred.succeed(exited, event).pipe(Effect.asVoid)
: Effect.void,
).pipe(Effect.forkChild);
const input = {
threadId,
provider: ProviderDriverKind.make("grok"),
cwd: process.cwd(),
runtimeMode: "full-access" as const,
};
const session = yield* adapter.startSession(input);
const failure = yield* Effect.flip(
adapter.sendTurn({ threadId, input: "crash now", attachments: [] }),
);
assert.isDefined(failure);
assert.isFalse(yield* adapter.hasSession(threadId));
const retryDuringTeardown = yield* Effect.flip(
adapter.sendTurn({ threadId, input: "retry during teardown", attachments: [] }),
);
assert.equal(retryDuringTeardown._tag, "ProviderAdapterSessionNotFoundError");
assert.equal((yield* Deferred.await(exited)).payload.exitKind, "error");
assert.deepStrictEqual(yield* adapter.listSessions(), []);
yield* Fiber.interrupt(events);
yield* adapter.startSession({ ...input, resumeCursor: session.resumeCursor });
const turn = yield* adapter.sendTurn({ threadId, input: "retry now", attachments: [] });
assert.equal(turn.threadId, threadId);
yield* adapter.stopSession(threadId);
const requests = yield* Effect.promise(() => readJsonLines(requestLogPath));
assert.equal(requests.filter((request) => request.method === "session/new").length, 1);
assert.deepStrictEqual(session.resumeCursor, {
schemaVersion: 1,
sessionId: "mock-session-1",
});
const resumes = requests.filter((request) => request.method === "session/load");
assert.equal(resumes.length, 1);
assert.deepStrictEqual(resumes[0]?.params, {
sessionId: "mock-session-1",
cwd: process.cwd(),
mcpServers: [],
});
}),
);

it.effect("starts a session and maps mock ACP prompt flow to runtime events", () =>
Effect.gen(function* () {
const threadId = ThreadId.make("grok-mock-thread");
Expand Down
37 changes: 33 additions & 4 deletions apps/server/src/provider/Layers/GrokAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ interface GrokSessionContext {
currentModelId: string | undefined;
currentReasoningEffort: string | undefined;
stopped: boolean;
terminated: boolean;
/** Live monitor/shell identities and their originating turns. */
readonly backgroundTasks: Map<string, GrokBackgroundTaskRecord>;
}
Expand Down Expand Up @@ -345,6 +346,7 @@ export function grokPromptSettlementBelongsToContext(input: {

export function makeGrokAdapter(grokSettings: GrokSettings, options?: GrokAdapterLiveOptions) {
return Effect.gen(function* () {
const ownerScope = yield* Effect.scope;
const boundInstanceId = options?.instanceId ?? ProviderInstanceId.make("grok");
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
Expand Down Expand Up @@ -922,7 +924,7 @@ export function makeGrokAdapter(grokSettings: GrokSettings, options?: GrokAdapte
threadId: ThreadId,
): Effect.Effect<GrokSessionContext, ProviderAdapterSessionNotFoundError> => {
const ctx = sessions.get(threadId);
if (!ctx || ctx.stopped) {
if (!ctx || ctx.stopped || ctx.terminated) {
return Effect.fail(
new ProviderAdapterSessionNotFoundError({ provider: PROVIDER, threadId }),
);
Expand All @@ -946,7 +948,7 @@ export function makeGrokAdapter(grokSettings: GrokSettings, options?: GrokAdapte
...(yield* makeEventStamp()),
provider: PROVIDER,
threadId: ctx.threadId,
payload: { exitKind: "graceful" },
payload: { exitKind: ctx.terminated ? "error" : "graceful" },
});
});

Expand Down Expand Up @@ -1316,12 +1318,35 @@ export function makeGrokAdapter(grokSettings: GrokSettings, options?: GrokAdapte
? normalizeGrokReasoningEffort(requestedStartReasoningEffort)
: currentStartReasoningEffort,
stopped: false,
terminated: false,
backgroundTasks: new Map(),
};

const nf = yield* Stream.runDrain(
Stream.mapEffect(acp.getEvents(), (event) =>
Effect.gen(function* () {
if (event._tag === "ConnectionTerminated") {
ctx.terminated = true;
yield* withThreadLock(
ctx.threadId,
Effect.gen(function* () {
if (sessions.get(ctx.threadId) !== ctx) return;
if (ctx.activeTurnId) {
yield* settlePromptInFlight(
ctx.threadId,
ctx.activeTurnId,
ctx.acpSessionId,
{
errorMessage: "Grok connection terminated.",
settleAllPrompts: true,
},
);
}
yield* stopSessionInternal(ctx);
}),
).pipe(Effect.forkIn(ownerScope));
return;
}
if (event._tag === "EventStreamBarrier") {
yield* Deferred.succeed(event.acknowledge, undefined);
return;
Expand Down Expand Up @@ -2165,12 +2190,16 @@ export function makeGrokAdapter(grokSettings: GrokSettings, options?: GrokAdapte
);

const listSessions: GrokAdapterShape["listSessions"] = () =>
Effect.sync(() => Array.from(sessions.values(), (c) => ({ ...c.session })));
Effect.sync(() =>
Array.from(sessions.values())
.filter((c) => !c.terminated)
.map((c) => ({ ...c.session })),
);

const hasSession: GrokAdapterShape["hasSession"] = (threadId) =>
Effect.sync(() => {
const c = sessions.get(threadId);
return c !== undefined && !c.stopped;
return c !== undefined && !c.stopped && !c.terminated;
});

const stopAll: GrokAdapterShape["stopAll"] = () =>
Expand Down
6 changes: 6 additions & 0 deletions apps/server/src/provider/Layers/OpenCodeProvider.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as NodeAssert from "node:assert/strict";
import * as NodeCrypto from "node:crypto";

import * as NodeServices from "@effect/platform-node/NodeServices";
import { it } from "@effect/vitest";
Expand Down Expand Up @@ -71,6 +72,10 @@ it.effect("reads Go limits with the instance's XDG credentials and preserves res
Effect.provide(NodeServices.layer),
);
NodeAssert.equal(limits.unavailable, undefined);
NodeAssert.equal(
limits.credentialFingerprint,
NodeCrypto.createHash("sha256").update("opencode-go\0instance-key").digest("hex"),
);
NodeAssert.deepEqual(
limits.windows.map(({ kind, usedPercent, resetsAt: reset }) => ({
kind,
Expand Down Expand Up @@ -139,6 +144,7 @@ it.effect("keeps Go entitlement absence distinct from failed or malformed usage
Effect.provide(NodeServices.layer),
);
NodeAssert.equal(limits.unavailable?.reason, reason);
NodeAssert.equal(limits.credentialFingerprint, undefined);
NodeAssert.deepEqual(limits.windows, []);
}
}),
Expand Down
12 changes: 11 additions & 1 deletion apps/server/src/provider/Layers/openCodeUsageLimits.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as NodeOS from "node:os";
import * as NodeCrypto from "node:crypto";

import type { ServerProviderUsageWindow } from "@t3tools/contracts";
import * as DateTime from "effect/DateTime";
Expand Down Expand Up @@ -95,7 +96,16 @@ export const readOpenCodeGoUsageLimits = Effect.fn("readOpenCodeGoUsageLimits")(
resetsAt: DateTime.formatIso(body.usage.monthly.resetsAt),
},
];
return makeUsageLimits({ checkedAt, windows });
return {
...makeUsageLimits({ checkedAt, windows }),
// Go's usage response has no account ID. An unkeyed hash matches across
// environments without a shared secret. It permits offline guesses, but
// Go keys are randomly generated.
credentialFingerprint: NodeCrypto.createHash("sha256")
.update("opencode-go\0")
.update(apiKey)
.digest("hex"),
};
}).pipe(
Effect.timeout("5 seconds"),
Effect.orElseSucceed(() =>
Expand Down
14 changes: 12 additions & 2 deletions apps/server/src/provider/model-manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
{
"version": 1,
"updatedAt": "2026-09-29T01:03:44Z",
"updatedAt": "2026-09-29T20:20:00Z",
"compatibility": [
{
"driver": "codex",
"t3CodeRange": ">=0.0.42",
"t3CodeRange": ">=0.0.44",
"recommendedRange": ">=0.159.0",
"ranges": [
{ "range": ">=0.156.0", "status": "supported" },
{ "range": ">=0.149.0 <0.156.0", "status": "unsupported" },
{ "range": "<0.149.0", "status": "broken" }
]
},
{
"driver": "codex",
"t3CodeRange": ">=0.0.42 <0.0.44",
"recommendedRange": ">=0.156.0",
"ranges": [
{ "range": ">=0.156.0", "status": "supported" },
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@t3tools/web",
"version": "0.0.43",
"version": "0.0.44",
"private": true,
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/BranchToolbarBranchSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ export function BranchToolbarBranchSelector({
number={prNumber}
url={prUrl}
status={displayedPrStatus}
onOpenStack={() => useRightPanelStore.getState().open(threadRef, "pull-requests")}
onOpenList={() => useRightPanelStore.getState().open(threadRef, "pull-requests")}
onOpenPullRequest={(event) => {
if (prUrl) openPrLink(event, prUrl);
}}
Expand Down
7 changes: 4 additions & 3 deletions apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1515,11 +1515,12 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
const accessibleTitle = isRenaming ? null : <span className="sr-only">{thread.title}</span>;

// Stacks show their layer count; multiple unrelated links show their total count.
// Plain clicks open T3; individual PR links also support opening the host in a new tab.
// Either opens the thread's pull requests tab; a single PR link opens that PR and still
// supports opening the host in a new tab.
const prBadgeShape = supportsMultiplePullRequests
? resolveThreadPullRequestBadge(thread.pullRequests)
: null;
const handlePrStackClick = useCallback(() => {
const handlePrListClick = useCallback(() => {
useRightPanelStore.getState().open(threadRef, "pull-requests");
if (!props.isActive) onThreadActivate(threadRef);
}, [onThreadActivate, props.isActive, threadRef]);
Expand All @@ -1531,7 +1532,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
number={pr?.number ?? currentLinkedPr?.number}
url={pr?.url ?? currentLinkedPr?.url}
status={prStatus}
onOpenStack={handlePrStackClick}
onOpenList={handlePrListClick}
onOpenPullRequest={handlePrClick}
/>
) : null;
Expand Down
Loading
Loading