Skip to content

Commit 8c711e7

Browse files
Merge main into fix/issue-13138
2 parents 2298129 + 5ffe045 commit 8c711e7

63 files changed

Lines changed: 1291 additions & 1031 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.pnpmfile.cjs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
// Release scripts stage their own installs with explicit architectures.
66
module.exports = {
77
hooks: {
8+
// `typescript` is @tsc-rs/typescript (the catalog entry). Its npm version (0.8.x) is outside
9+
// vite-plus-core's typescript peer range, so pnpm gave the vite-plus that @effect/vitest
10+
// imports apps/marketing's [email protected] instead, and tests loaded a second vitest.
11+
readPackage(pkg) {
12+
if (pkg.name === "@voidzero-dev/vite-plus-core" && pkg.peerDependencies?.typescript) {
13+
pkg.peerDependencies.typescript = "*";
14+
}
15+
return pkg;
16+
},
817
updateConfig(config) {
918
// oxlint-disable-next-line t3code/no-global-process-runtime -- pnpm loads this file before any Effect runtime exists.
1019
if (process.platform !== "win32") return config;

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ An empty database is a bad test. Seed your worktree's `.t3` with a copy of real
100100

101101
- Before you push, run `vp run check:changed`. It runs CI's fast checks for changed files: format, lint, knip, typecheck of affected packages and dependents, and tests beside changes. CI still runs the full test suites.
102102
- While you iterate, run `vp test run <files>`. For big files, add `-t "<name>"`.
103-
- Do not use `npx tsc`. Use `vp run typecheck`; it uses tsc-rs, which is 3x faster.
103+
- Use `vp run typecheck`, not `npx tsc`; it caches per package. Both run tsc-rs (`typescript` is the `@tsc-rs/typescript` drop-in).
104104
- Run `node -e` snippets from `apps/server` or the owning package. `effect` does not resolve from the repo root.
105105
- Test meaningful logic or observable behavior. Do not render components to static markup to assert props or attributes, or add tests that merely assert callback wiring or mirror the implementation.
106106
- **Do not run repo-wide checks.** No `vp check`, no `vp run -r test`, no `vp run -r typecheck` unless I ask. CI owns the full suite.

‎apps/desktop/vite.config.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export default defineConfig({
4343
dependsOn: ["t3#build"],
4444
cache: false,
4545
},
46-
// tsc-rs rewrites the tsbuildinfo it reads, which keeps a task out of the cache.
46+
// tsc (tsc-rs) rewrites the tsbuildinfo it reads, which keeps a task out of the cache.
4747
typecheck: {
48-
command: "tsc-rs --noEmit",
48+
command: "tsc --noEmit",
4949
cache: { input: [{ auto: true }, "!*.tsbuildinfo"] },
5050
},
5151
},

‎apps/mobile/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"measure-renders": "node scripts/measure-renders.mts",
4646
"generate": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON scripts/generate-uniwind-themes.mts",
4747
"test": "vp test run --project unit --project react",
48-
"typecheck": "tsc-rs --noEmit"
48+
"typecheck": "tsc --noEmit"
4949
},
5050
"dependencies": {
5151
"@clerk/expo": "catalog:",

‎apps/mobile/src/widgets/AgentActivity.tsx‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import { HStack, Image, Spacer, Text, VStack, ZStack } from "@expo/ui/swift-ui";
1+
import { Circle, HStack, Image, Spacer, Text, VStack, ZStack } from "@expo/ui/swift-ui";
22
import type { ComponentProps } from "react";
33
import {
4+
accessibilityElement,
5+
accessibilityLabel,
46
activityBackgroundTint,
57
font,
68
foregroundStyle,
79
frame,
810
layoutPriority,
911
lineLimit,
12+
minimumScaleFactor,
1013
padding,
1114
resizable,
1215
widgetURL,
@@ -149,6 +152,8 @@ export function AgentActivity(
149152
: environment.isStale
150153
? "Out of date"
151154
: `${props.activeCount} active`;
155+
const showCompactCount = !attentionRow && !allDone && !environment.isStale;
156+
const compactCountLabel = props.activeCount > 99 ? "99+" : `${props.activeCount}`;
152157
const summary = attentionSuffix || activeLabel;
153158

154159
// Any registered scheme variant routes back to this app; taps are delivered
@@ -326,11 +331,35 @@ export function AgentActivity(
326331
</VStack>
327332
),
328333
compactLeading: renderLogo(14, tint, linkModifiers),
329-
compactTrailing: (
334+
compactTrailing: showCompactCount ? (
335+
<ZStack
336+
modifiers={[
337+
frame({ width: 28, height: 28 }),
338+
accessibilityElement("ignore"),
339+
accessibilityLabel(agentsLabel),
340+
...linkModifiers,
341+
]}
342+
>
343+
<Circle modifiers={[foregroundStyle(tint)]} />
344+
<Text
345+
modifiers={[
346+
font({ weight: "bold", size: 14 }),
347+
foregroundStyle("#000000"),
348+
lineLimit(1),
349+
minimumScaleFactor(0.75),
350+
frame({ width: 24, height: 28 }),
351+
]}
352+
>
353+
{compactCountLabel}
354+
</Text>
355+
</ZStack>
356+
) : (
330357
<Text
331358
modifiers={[
332359
font({ weight: "semibold", size: 11 }),
333360
foregroundStyle(tint),
361+
lineLimit(1),
362+
minimumScaleFactor(0.5),
334363
...linkModifiers,
335364
]}
336365
>

‎apps/server/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"build:bundle": "vp pack",
2121
"build:exe": "node scripts/cli.ts build-exe",
2222
"start": "node dist/bin.mjs",
23-
"typecheck": "tsc-rs --noEmit",
23+
"typecheck": "tsc --noEmit",
2424
"test": "vp test run",
2525
"record:codex-replay": "bun scripts/record-codex-app-server-replay-fixture.ts",
2626
"record:claude-replay": "bun scripts/record-claude-agent-sdk-replay-fixture.ts",

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -314,26 +314,41 @@ const WORKFLOW_MEMBER_TRANSCRIPT_FLUSH_MS = 500;
314314
// subagents to move to the background before it is sent.
315315
const BACKGROUND_MOVE_TIMEOUT_MS = 5_000;
316316

317+
const CLAUDE_GROUP_WATCH_SCRIPT = [
318+
"{ trap '' TERM; read -r _ <&3; kill -TERM 0; sleep 5; kill -KILL 0; } </dev/null >/dev/null 2>&1 &",
319+
'exec "$@" 3<&-',
320+
].join("\n");
321+
317322
/**
318323
* When the CLI exits it stops the MCP servers it started, but not their children: a plugin's
319324
* `bun run start` wrapper dies and its `bun server.ts` keeps running, writing to a pipe nobody
320325
* reads (#3089). Those stay in the CLI's group, so the rest of the group gets SIGKILL once the
321326
* CLI exits for any reason.
327+
*
328+
* That cleanup needs this server alive, and the CLI finishes its turn after its pipes close. A
329+
* server that crashes or is killed would leave the CLI working next to the session it resumes
330+
* (#23370), so a watcher in the group reads a pipe only this server holds and stops the group at
331+
* its end-of-file.
322332
*/
323-
function spawnClaudeProcessGroup(options: ClaudeSpawnOptions): ClaudeSpawnedProcess {
324-
const child = NodeChildProcess.spawn(options.command, options.args, {
325-
cwd: options.cwd,
326-
env: options.env,
327-
signal: options.signal,
328-
stdio: ["pipe", "pipe", "ignore"],
329-
detached: true,
330-
});
333+
export function spawnClaudeProcessGroup(options: ClaudeSpawnOptions): ClaudeSpawnedProcess {
334+
const child = NodeChildProcess.spawn(
335+
"/bin/sh",
336+
["-c", CLAUDE_GROUP_WATCH_SCRIPT, "t3-claude", options.command, ...options.args],
337+
{
338+
cwd: options.cwd,
339+
env: options.env,
340+
signal: options.signal,
341+
stdio: ["pipe", "pipe", "ignore", "pipe"],
342+
detached: true,
343+
},
344+
);
331345
child.once("exit", () => {
332346
try {
333347
signalProcessGroup(child.pid ?? 0, "SIGKILL");
334348
} catch {}
335349
});
336-
return child;
350+
// Node's typings make stdin and stdout nullable once stdio has a fourth entry; both are pipes.
351+
return child as ClaudeSpawnedProcess;
337352
}
338353

339354
export const ClaudeProviderCapabilitiesV2 = {

‎apps/server/src/orchestration-v2/Adapters/ClaudeAgentSdkQueryRunner.test.ts‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ import { vi } from "vite-plus/test";
1515

1616
import * as HostProcess from "@t3tools/shared/HostProcess";
1717
import { ProviderEventLoggers } from "@t3tools/provider-core/server/ProviderEventLoggers";
18-
import { ClaudeAgentSdkQueryRunner, layerQueryRunner } from "./ClaudeAdapterV2.ts";
18+
import { signalProcessGroup } from "@t3tools/provider-core/server/processGroup";
19+
import {
20+
ClaudeAgentSdkQueryRunner,
21+
layerQueryRunner,
22+
spawnClaudeProcessGroup,
23+
} from "./ClaudeAdapterV2.ts";
1924

2025
vi.mock("@anthropic-ai/claude-agent-sdk", { spy: true });
2126

@@ -163,4 +168,38 @@ describe.skipIf(HostProcess.Platform.defaultValue() === "win32")("Claude CLI pro
163168
yield* Effect.promise(() => leftoverStopped);
164169
}).pipe(Effect.provide(realQueryRunner)),
165170
);
171+
172+
// The CLI keeps running its turn after its pipes close, so a server that
173+
// crashed would leave it working next to the session it resumes (#23370).
174+
it.effect("stops the CLI when the server that started it goes away", () =>
175+
Effect.gen(function* () {
176+
const cli = fakeClaudeCli(['dir=$(dirname "$0")', 'sleep 600 > "$dir/alive"'].join("\n"));
177+
const dir = NodePath.dirname(cli);
178+
NodeChildProcess.execFileSync("mkfifo", [NodePath.join(dir, "alive")]);
179+
const child = spawnClaudeProcessGroup({
180+
command: cli,
181+
args: [],
182+
cwd: dir,
183+
env: process.env,
184+
signal: new AbortController().signal,
185+
}) as NodeChildProcess.ChildProcess;
186+
yield* Effect.addFinalizer(() =>
187+
Effect.sync(() => {
188+
try {
189+
signalProcessGroup(child.pid ?? 0, "SIGKILL");
190+
} catch {}
191+
NodeFS.rmSync(dir, { recursive: true, force: true });
192+
}),
193+
);
194+
const alive = NodeFS.createReadStream(NodePath.join(dir, "alive"));
195+
const turnStarted = new Promise<void>((resolve) => alive.once("open", () => resolve()));
196+
const turnStopped = new Promise<void>((resolve) => alive.once("close", () => resolve()));
197+
alive.resume();
198+
yield* Effect.promise(() => turnStarted);
199+
200+
// A dying server's descriptors close; the kernel would do this for it.
201+
for (const pipe of child.stdio) pipe?.destroy();
202+
yield* Effect.promise(() => turnStopped);
203+
}),
204+
);
166205
});

‎apps/web/src/components/ChatView.logic.ts‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { getProviderModelCapabilities } from "../providerModels";
1515
import { sanitizeThreadErrorMessage } from "~/rpc/transportError";
1616
import type {
1717
EnvironmentThread,
18+
ThreadStructure,
1819
EnvironmentThreadShell,
1920
} from "@t3tools/client-runtime/state/shell";
2021
import {
@@ -30,7 +31,6 @@ import {
3031
type MessageId,
3132
type ModelSelection,
3233
type OrchestrationMessageContext,
33-
type OrchestrationV2ProjectedTurnItem,
3434
type PreviewAnnotationPayload,
3535
type ProviderInteractionMode,
3636
ProviderDriverKind,
@@ -106,6 +106,7 @@ import {
106106
} from "../providerInstances";
107107

108108
type ThreadProjection = EnvironmentThread["projection"];
109+
type ThreadStructureRow = ThreadStructure["visibleTurnItems"][number];
109110

110111
export const LAST_INVOKED_SCRIPT_BY_PROJECT_KEY = "t3code:last-invoked-script-by-project";
111112
export const MAX_HIDDEN_MOUNTED_TERMINAL_THREADS = 10;
@@ -1198,7 +1199,7 @@ export function createLocalDispatchSnapshot(
11981199
* turn items avoids dropping steer rows in that gap.
11991200
*/
12001201
export function deriveCommittedServerUserMessageIds(
1201-
visibleTurnItems: ReadonlyArray<OrchestrationV2ProjectedTurnItem>,
1202+
visibleTurnItems: ReadonlyArray<ThreadStructureRow>,
12021203
): ReadonlySet<ChatMessage["id"]> {
12031204
return new Set(
12041205
visibleTurnItems.flatMap((row) =>
@@ -1626,20 +1627,29 @@ export function sendTitleFallbackLabels(snapshot: ComposerSendSnapshot) {
16261627
];
16271628
}
16281629

1629-
/** A thread shell built from its loaded detail, for direct links that hydrate the detail first. */
1630+
/**
1631+
* A thread shell built from its loaded detail, for direct links that hydrate the detail first.
1632+
* `updatedAt` and `lastVisitedAt` are passed live: the thread structure leaves them out.
1633+
*/
16301634
export function presentThreadShellFromProjection(
16311635
environmentId: EnvironmentId,
16321636
threadId: ThreadId,
1633-
projection: ThreadProjection,
1637+
projection: ThreadStructure,
1638+
live: {
1639+
readonly updatedAt: ThreadProjection["updatedAt"];
1640+
readonly lastVisitedAt: ThreadProjection["thread"]["lastVisitedAt"];
1641+
},
16341642
) {
1643+
const { updatedAt, lastVisitedAt } = live;
16351644
const latestRun = deriveLatestThreadRun(projection);
1636-
const runtime = deriveThreadRuntime(projection);
1645+
const runtime = deriveThreadRuntime({ ...projection, updatedAt });
16371646
const pendingRuntimeRequest =
16381647
projection.runtimeRequests.findLast((request) => request.status === "pending") ?? null;
16391648
// Direct links can hydrate detail before the thread enters the shell index.
16401649
return {
16411650
...presentThreadShell(environmentId, {
16421651
...projection.thread,
1652+
lastVisitedAt,
16431653
latestRunId: latestRun?.runId ?? null,
16441654
activeRunId: runtime?.activeRunId ?? null,
16451655
status: runtime?.status ?? "idle",
@@ -1663,15 +1673,15 @@ export function presentThreadShellFromProjection(
16631673
)?.goal ?? null,
16641674
itemCount: projection.turnItems.length,
16651675
visibleItemCount: projection.visibleTurnItems.length,
1666-
updatedAt: projection.updatedAt,
1676+
updatedAt,
16671677
}),
16681678
latestRun,
16691679
runtime,
16701680
};
16711681
}
16721682

16731683
/** Background work the provider still runs after the latest run ended. */
1674-
export function deriveThreadPendingBackgroundTasks(projection: ThreadProjection | null) {
1684+
export function deriveThreadPendingBackgroundTasks(projection: ThreadStructure | null) {
16751685
if (projection === null) return [];
16761686
const sessionError =
16771687
projection.providerSessions.findLast(
@@ -1697,7 +1707,7 @@ export function deriveThreadPendingBackgroundTasks(projection: ThreadProjection
16971707
* active provider thread, plus 0 for the thread start. Empty without a live provider session
16981708
* on the thread's selected instance.
16991709
*/
1700-
export function deriveAvailableRevertTurnCounts(projection: ThreadProjection | null) {
1710+
export function deriveAvailableRevertTurnCounts(projection: ThreadStructure | null) {
17011711
const available = new Set<number>();
17021712
const providerThread = projection?.providerThreads.find(
17031713
(candidate) => candidate.id === projection.thread.activeProviderThreadId,
@@ -1740,7 +1750,7 @@ export function deriveAvailableRevertTurnCounts(projection: ThreadProjection | n
17401750
* without reporting the paths it touched.
17411751
*/
17421752
export function deriveWorkspaceMutationId(
1743-
visibleTurnItems: ReadonlyArray<OrchestrationV2ProjectedTurnItem>,
1753+
visibleTurnItems: ReadonlyArray<ThreadStructureRow>,
17441754
latestCheckpointCompletedAt: string | null,
17451755
) {
17461756
let itemId: string | null = null;

0 commit comments

Comments
 (0)