Skip to content

Commit a9ad3a9

Browse files
authored
Merge branch 'main' into fix/PWA-crash-on-clear-terminal
2 parents 65ec22a + 4f5834b commit a9ad3a9

75 files changed

Lines changed: 8156 additions & 462 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.

‎apps/mobile/src/features/threads/PendingApprovalCard.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ export interface PendingApprovalCardProps {
1414
}
1515

1616
export function PendingApprovalCard(props: PendingApprovalCardProps) {
17+
// Opaque for the same reason as PendingUserInputCard: nothing blurs the feed
18+
// behind this card, so a translucent surface bleeds messages through it.
1719
return (
18-
<View className="gap-2.5 rounded-[20px] border border-neutral-200 bg-neutral-100/80 p-4 dark:border-white/6 dark:bg-neutral-900/80">
20+
<View className="gap-2.5 rounded-[20px] border border-neutral-200 bg-neutral-100 p-4 dark:border-white/6 dark:bg-neutral-900">
1921
<Text className="font-t3-bold text-2xs uppercase tracking-[1.1px] text-sky-700 dark:text-sky-300">
2022
Approval needed
2123
</Text>

‎apps/mobile/src/features/threads/PendingUserInputCard.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ export interface PendingUserInputCardProps {
2424
}
2525

2626
export function PendingUserInputCard(props: PendingUserInputCardProps) {
27+
// The surface is opaque on purpose: the card floats over the thread feed
28+
// with no blur behind it, so a translucent background renders the questions
29+
// on top of whatever message happens to sit underneath.
2730
return (
28-
<View className="gap-2.5 rounded-[20px] border border-neutral-200 bg-neutral-100/80 p-4 dark:border-white/6 dark:bg-neutral-900/80">
31+
<View className="gap-2.5 rounded-[20px] border border-neutral-200 bg-neutral-100 p-4 dark:border-white/6 dark:bg-neutral-900">
2932
<Text className="font-t3-bold text-2xs uppercase tracking-[1.1px] text-sky-700 dark:text-sky-300">
3033
User input needed
3134
</Text>

‎apps/mobile/src/lib/threadActivity.test.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,3 +532,39 @@ describe("buildThreadFeed", () => {
532532
});
533533
});
534534
});
535+
536+
describe("quiet timeline: nested agents", () => {
537+
it("keeps a nested agent's terminal row but hides its background work", () => {
538+
const thread = makeThread({
539+
id: ThreadId.make("thread-nested"),
540+
projectId: ProjectId.make("project-1"),
541+
title: "Nested agents",
542+
activities: [
543+
// A subagent's own shell: internal, covered by the owner's liveness.
544+
makeActivity({
545+
id: EventId.make("shell-done"),
546+
kind: "task.completed",
547+
summary: "Task completed",
548+
createdAt: "2026-04-01T00:00:02.000Z",
549+
payload: { taskId: "sh-1", agentId: "owner", agentKind: "background" },
550+
}),
551+
// A nested AGENT's completion: mobile has no Agents sheet, so this
552+
// terminal row is the only signal it ever finished.
553+
makeActivity({
554+
id: EventId.make("nested-done"),
555+
kind: "task.completed",
556+
summary: "Task completed",
557+
createdAt: "2026-04-01T00:00:03.000Z",
558+
payload: { taskId: "n-1", agentId: "owner", agentKind: "agent" },
559+
}),
560+
],
561+
});
562+
563+
const feed = buildThreadFeed(thread);
564+
const ids = feed.flatMap((entry) =>
565+
entry.type === "activity-group" ? entry.activities.map((row) => row.id) : [],
566+
);
567+
expect(ids).toContain("nested-done");
568+
expect(ids).not.toContain("shell-done");
569+
});
570+
});

‎apps/mobile/src/lib/threadActivity.ts‎

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ interface WorkLogEntry {
8080
interface DerivedWorkLogEntry extends WorkLogEntry {
8181
activityKind: OrchestrationThreadActivity["kind"];
8282
collapseKey?: string;
83+
/** Grouping key for subagent lifecycle rows (one row per agent). */
84+
taskId?: string;
8385
}
8486

8587
type RawThreadFeedEntry =
@@ -235,6 +237,63 @@ function resolvePendingUserInputAnswer(
235237
return normalizeDraftAnswer(draft?.selectedOptionLabel);
236238
}
237239

240+
/** Codex children settle via task.updated (idle/failed/interrupted), never
241+
* task.completed — these rows are mobile's only terminal signal for them. */
242+
const MOBILE_TERMINAL_UPDATE_STATUSES: ReadonlySet<string> = new Set([
243+
"idle",
244+
"completed",
245+
"failed",
246+
"cancelled",
247+
"interrupted",
248+
]);
249+
250+
function isTerminalBypassUpdate(activity: OrchestrationThreadActivity): boolean {
251+
if (activity.kind !== "task.updated") {
252+
return false;
253+
}
254+
const payload =
255+
activity.payload && typeof activity.payload === "object"
256+
? (activity.payload as Record<string, unknown>)
257+
: null;
258+
return (
259+
payload?.timelineBypass === true &&
260+
typeof payload.status === "string" &&
261+
MOBILE_TERMINAL_UPDATE_STATUSES.has(payload.status)
262+
);
263+
}
264+
265+
/**
266+
* Quiet-timeline guarantee (mirrors web's session-logic): agent-internal
267+
* activity lives in the Agents sheet, not the work log. Terminal rows are
268+
* kept — with no Agents surface on mobile they are the terminal signal
269+
* (a surface that hides rows must keep its own terminal signal). That means
270+
* task.completed (Claude) AND terminal bypassed task.updated (Codex, whose
271+
* children never emit task.completed — review finding).
272+
*/
273+
function isAgentInternalActivity(activity: OrchestrationThreadActivity): boolean {
274+
const payload =
275+
activity.payload && typeof activity.payload === "object"
276+
? (activity.payload as Record<string, unknown>)
277+
: null;
278+
if (!payload) {
279+
return false;
280+
}
281+
const isTerminalTaskRow = activity.kind === "task.completed" || isTerminalBypassUpdate(activity);
282+
if (payload.timelineBypass === true && !isTerminalTaskRow) {
283+
return true;
284+
}
285+
// agentId marks ownership, not "hide me": a NESTED AGENT's terminal row is
286+
// the only signal mobile gets (no Agents sheet), so it stays. Only an
287+
// agent's own background work (stamped "background") is internal — same
288+
// rule as web (review finding: hiding on agentId alone dropped nested
289+
// completions with no replacement UI).
290+
const ownedByAgent = typeof payload.agentId === "string" && payload.agentId.trim().length > 0;
291+
if (!ownedByAgent) {
292+
return false;
293+
}
294+
return !(isTerminalTaskRow && payload.agentKind === "agent");
295+
}
296+
238297
function deriveWorkLogEntries(
239298
activities: ReadonlyArray<OrchestrationThreadActivity>,
240299
): DerivedWorkLogEntry[] {
@@ -243,9 +302,13 @@ function deriveWorkLogEntries(
243302
for (const activity of ordered) {
244303
if (activity.kind === "tool.started") continue;
245304
if (activity.kind === "task.started") continue;
305+
// Terminal bypassed updates pass: Codex children's only terminal signal.
306+
if (activity.kind === "task.updated" && !isTerminalBypassUpdate(activity)) continue;
307+
if (activity.kind === "tool.progress") continue;
246308
if (activity.kind === "context-window.updated") continue;
247309
if (activity.summary === "Checkpoint captured") continue;
248310
if (isPlanBoundaryToolActivity(activity)) continue;
311+
if (isAgentInternalActivity(activity)) continue;
249312
entries.push(toDerivedWorkLogEntry(activity));
250313
}
251314
return collapseDerivedWorkLogEntries(entries);
@@ -271,7 +334,13 @@ function toDerivedWorkLogEntry(activity: OrchestrationThreadActivity): DerivedWo
271334
const commandPreview = extractToolCommand(payload);
272335
const changedFiles = extractChangedFiles(payload);
273336
const title = extractToolTitle(payload);
274-
const isTaskActivity = activity.kind === "task.progress" || activity.kind === "task.completed";
337+
// task.updated included: terminal bypassed updates (Codex children's only
338+
// terminal signal) must carry task identity so they collapse per child
339+
// instead of stacking anonymous "Task idle" rows.
340+
const isTaskActivity =
341+
activity.kind === "task.progress" ||
342+
activity.kind === "task.completed" ||
343+
activity.kind === "task.updated";
275344
const taskSummary =
276345
isTaskActivity && typeof payload?.summary === "string" && payload.summary.length > 0
277346
? payload.summary
@@ -284,10 +353,15 @@ function toDerivedWorkLogEntry(activity: OrchestrationThreadActivity): DerivedWo
284353
? payload.detail
285354
: null;
286355
const taskLabel = taskSummary || taskDetailAsLabel;
356+
const taskId =
357+
isTaskActivity && typeof payload?.taskId === "string" && payload.taskId.length > 0
358+
? payload.taskId
359+
: undefined;
287360
const entry: DerivedWorkLogEntry = {
288361
id: activity.id,
289362
createdAt: activity.createdAt,
290363
turnId: activity.turnId,
364+
...(taskId ? { taskId } : {}),
291365
label: taskLabel || activity.summary,
292366
tone:
293367
activity.kind === "task.progress"
@@ -352,7 +426,25 @@ function collapseDerivedWorkLogEntries(
352426
entries: ReadonlyArray<DerivedWorkLogEntry>,
353427
): DerivedWorkLogEntry[] {
354428
const collapsed: DerivedWorkLogEntry[] = [];
429+
// Subagent rows collapse by identity, not adjacency (quiet-timeline
430+
// guarantee; mirrors web's session-logic).
431+
const taskRowIndex = new Map<string, number>();
355432
for (const entry of entries) {
433+
const isTaskRow =
434+
entry.taskId !== undefined &&
435+
(entry.activityKind === "task.progress" ||
436+
entry.activityKind === "task.completed" ||
437+
entry.activityKind === "task.updated");
438+
if (isTaskRow && entry.taskId !== undefined) {
439+
const existingIndex = taskRowIndex.get(entry.taskId);
440+
if (existingIndex !== undefined) {
441+
collapsed[existingIndex] = mergeDerivedWorkLogEntries(collapsed[existingIndex]!, entry);
442+
continue;
443+
}
444+
taskRowIndex.set(entry.taskId, collapsed.length);
445+
collapsed.push(entry);
446+
continue;
447+
}
356448
const previous = collapsed.at(-1);
357449
if (previous && shouldCollapseToolLifecycleEntries(previous, entry)) {
358450
collapsed[collapsed.length - 1] = mergeDerivedWorkLogEntries(previous, entry);

‎apps/server/integration/OrchestrationEngineHarness.integration.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import * as RepositoryIdentityResolver from "../src/project/RepositoryIdentityRe
5050
import { OrchestrationEngineLive } from "../src/orchestration/Layers/OrchestrationEngine.ts";
5151
import { OrchestrationProjectionPipelineLive } from "../src/orchestration/Layers/ProjectionPipeline.ts";
5252
import { OrchestrationProjectionSnapshotQueryLive } from "../src/orchestration/Layers/ProjectionSnapshotQuery.ts";
53+
import * as ThreadBackgroundLiveness from "../src/orchestration/ThreadBackgroundLiveness.ts";
5354
import { RuntimeReceiptBusTest } from "../src/orchestration/Layers/RuntimeReceiptBus.ts";
5455
import { OrchestrationReactorLive } from "../src/orchestration/Layers/OrchestrationReactor.ts";
5556
import { ProviderCommandReactorLive } from "../src/orchestration/Layers/ProviderCommandReactor.ts";
@@ -305,7 +306,7 @@ export const makeOrchestrationIntegrationHarness = (
305306
checkpointStoreLayer,
306307
providerLayer,
307308
RuntimeReceiptBusTest,
308-
);
309+
).pipe(Layer.provideMerge(ThreadBackgroundLiveness.layer));
309310
const serverSettingsLayer = ServerSettingsService.layerTest();
310311
const runtimeIngestionLayer = ProviderRuntimeIngestionLive.pipe(
311312
Layer.provideMerge(runtimeServicesLayer),

‎apps/server/src/auth/RpcAuthorization.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type WsRpcMethod = RpcGroup.Rpcs<typeof WsRpcGroup>["_tag"];
2222
*/
2323
export const RPC_REQUIRED_SCOPES = {
2424
[ORCHESTRATION_WS_METHODS.dispatchCommand]: AuthOrchestrationOperateScope,
25+
[ORCHESTRATION_WS_METHODS.getWorkflowScript]: AuthOrchestrationReadScope,
2526
[ORCHESTRATION_WS_METHODS.getTurnDiff]: AuthOrchestrationReadScope,
2627
[ORCHESTRATION_WS_METHODS.getFullThreadDiff]: AuthOrchestrationReadScope,
2728
[ORCHESTRATION_WS_METHODS.searchThreads]: AuthOrchestrationReadScope,

‎apps/server/src/cloud/bootService.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ it("keeps systemd pinned to the stable launcher rather than a versioned server",
3131
});
3232

3333
expect(unit).toContain("ExecStart=/usr/bin/node /home/theo/.t3/runtime/service-launcher.mjs");
34-
expect(unit).toContain("KillMode=control-group");
34+
expect(unit).toContain("KillMode=mixed");
3535
expect(unit).not.toContain("versions/1.2.3");
3636
});
3737

‎apps/server/src/cloud/bootService.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ export function renderBootServiceUnit(plan: BootServicePlan): string {
6464
`Environment=T3CODE_HOME=${quoteSystemdValue(plan.baseDir)}`,
6565
`Environment=${BOOT_SERVICE_UNIT_ENV}=${BOOT_SERVICE_UNIT_FILE}`,
6666
`ExecStart=${quoteSystemdValue(plan.nodePath)} ${quoteSystemdValue(plan.launcherPath)}`,
67-
"KillMode=control-group",
67+
// Let the launcher mark an explicit stop before it signals the server.
68+
// systemd still SIGKILLs the whole cgroup if graceful shutdown times out.
69+
"KillMode=mixed",
6870
"Restart=always",
6971
"RestartSec=5",
7072
`StandardOutput=append:${escapeSystemdSpecifiers(plan.logPath)}`,

0 commit comments

Comments
 (0)