Skip to content

Commit e3dcfcc

Browse files
ntindleclaude
andcommitted
Merge origin/main into t3/muse-usage-limits
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 parents fdd7ad4 + 716357c commit e3dcfcc

68 files changed

Lines changed: 2625 additions & 285 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/review/ReviewSheet.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
2+
import { formatDiffCount } from "@t3tools/client-runtime/diff-count";
23
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
34
import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
45
import { ScreenHeader } from "../../components/ScreenHeader";
@@ -282,9 +283,11 @@ const ReviewFileNavigatorRow = memo(function ReviewFileNavigatorRow(props: {
282283
</Text>
283284
<View className="mt-1 flex-row gap-2">
284285
<Text className="text-2xs font-t3-bold text-adaptive-emerald-700-300">
285-
+{file.additions}
286+
+{formatDiffCount(file.additions)}
287+
</Text>
288+
<Text className="text-2xs font-t3-bold text-adaptive-rose-700-300">
289+
-{formatDiffCount(file.deletions)}
286290
</Text>
287-
<Text className="text-2xs font-t3-bold text-adaptive-rose-700-300">-{file.deletions}</Text>
288291
</View>
289292
</Pressable>
290293
);

‎apps/mobile/src/features/review/useReviewDiffData.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
2+
import { formatDiffCount } from "@t3tools/client-runtime/diff-count";
23

34
import { countReviewCommentContexts, parseReviewInlineComments } from "./reviewCommentSelection";
45
import { getCachedNativeReviewDiffData } from "./nativeReviewDiffAdapter";
@@ -109,12 +110,15 @@ export function formatHeaderDiffSummary(
109110
} {
110111
if (files) {
111112
return {
112-
additions: `+${files.reduce((total, file) => total + file.additions, 0)}`,
113-
deletions: `-${files.reduce((total, file) => total + file.deletions, 0)}`,
113+
additions: `+${formatDiffCount(files.reduce((total, file) => total + file.additions, 0))}`,
114+
deletions: `-${formatDiffCount(files.reduce((total, file) => total + file.deletions, 0))}`,
114115
};
115116
}
116117
if (parsedDiff.kind !== "files") return { additions: null, deletions: null };
117-
return { additions: `+${parsedDiff.additions}`, deletions: `-${parsedDiff.deletions}` };
118+
return {
119+
additions: `+${formatDiffCount(parsedDiff.additions)}`,
120+
deletions: `-${formatDiffCount(parsedDiff.deletions)}`,
121+
};
118122
}
119123

120124
export function useReviewDiffData(input: {

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,15 @@ export interface ThreadDetailScreenProps {
173173
* The server has not created this thread yet. "preparing" runs while the
174174
* queued creation is delivered (a worktree may be checking out); "failed"
175175
* is a rejected creation whose content went back to the project draft.
176+
* `serverOwned` marks a thread the server already created that is still
177+
* setting up its worktree; follow-ups queue on the server behind that setup.
176178
*/
177179
readonly creationState:
178-
| { readonly kind: "preparing"; readonly preparingWorktree: boolean }
180+
| {
181+
readonly kind: "preparing";
182+
readonly preparingWorktree: boolean;
183+
readonly serverOwned: boolean;
184+
}
179185
| { readonly kind: "failed"; readonly reason: string; readonly onEditTask: () => void }
180186
| null;
181187
readonly activePendingApproval: PendingApproval | null;
@@ -1439,11 +1445,14 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
14391445
canStopThread={props.canStopThread}
14401446
environmentId={props.environmentId}
14411447
projectCwd={props.threadCwd ?? props.projectWorkspaceRoot}
1442-
// Follow-ups typed during setup wait in the draft: queueing
1443-
// them against a thread id the server may still reject
1444-
// would strand them in the outbox.
1448+
// Follow-ups typed before the server creates the thread wait in
1449+
// the draft: queueing them against a thread id the server may
1450+
// still reject would strand them in the outbox.
14451451
sendBlockedReason={
1446-
props.creationState?.kind === "preparing" ? "Starting the task…" : null
1452+
props.creationState?.kind === "preparing" &&
1453+
!props.creationState.serverOwned
1454+
? "Starting the task…"
1455+
: null
14471456
}
14481457
draftKey={props.composerDraftKey ?? undefined}
14491458
followUpBehavior={props.followUpBehavior}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,9 @@ function ThreadRouteContent(
889889
]);
890890
const creationState = ((): ThreadDetailScreenProps["creationState"] => {
891891
if (selectedThreadCreation === null) {
892-
return awaitingBootstrapTurn ? { kind: "preparing", preparingWorktree: true } : null;
892+
return awaitingBootstrapTurn
893+
? { kind: "preparing", preparingWorktree: true, serverOwned: true }
894+
: null;
893895
}
894896
if (selectedThreadCreation.outcome?.kind === "failed") {
895897
return {
@@ -901,6 +903,7 @@ function ThreadRouteContent(
901903
return {
902904
kind: "preparing",
903905
preparingWorktree: selectedThreadCreation.message.creation?.workspaceMode === "worktree",
906+
serverOwned: false,
904907
};
905908
})();
906909
if (!environmentId || !threadId) {

‎apps/mobile/src/features/threads/git/GitCommitSheet.tsx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
22
import { useCallback, useState } from "react";
33
import { Platform, Pressable, ScrollView, useWindowDimensions, View } from "react-native";
4+
import { formatDiffCount } from "@t3tools/client-runtime/diff-count";
45
import { useSafeAreaInsets } from "react-native-safe-area-context";
56

67
import { AndroidSheetHeader } from "../../../components/AndroidScreenHeader";
@@ -134,7 +135,8 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {
134135
Files
135136
</Text>
136137
<Text className="text-foreground-muted text-xs leading-normal">
137-
{selectedFiles.length} selected · +{selectedInsertions} / -{selectedDeletions}
138+
{selectedFiles.length} selected · +{formatDiffCount(selectedInsertions)} / -
139+
{formatDiffCount(selectedDeletions)}
138140
</Text>
139141
</View>
140142
<View className="flex-row items-center gap-2">
@@ -171,10 +173,10 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {
171173
{file.path}
172174
</Text>
173175
<Text className="text-xs font-t3-bold text-adaptive-emerald-700-300">
174-
+{file.insertions}
176+
+{formatDiffCount(file.insertions)}
175177
</Text>
176178
<Text className="text-xs font-t3-bold text-adaptive-rose-700-300">
177-
-{file.deletions}
179+
-{formatDiffCount(file.deletions)}
178180
</Text>
179181
</View>
180182
))}
@@ -250,10 +252,10 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {
250252
</View>
251253
<View className="items-end gap-1">
252254
<Text className="text-xs font-t3-bold text-adaptive-emerald-700-300">
253-
+{file.insertions}
255+
+{formatDiffCount(file.insertions)}
254256
</Text>
255257
<Text className="text-xs font-t3-bold text-adaptive-rose-700-300">
256-
-{file.deletions}
258+
-{formatDiffCount(file.deletions)}
257259
</Text>
258260
</View>
259261
</View>

‎apps/mobile/src/features/threads/new-task-flow-provider.tsx‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
ThreadId,
2525
} from "@t3tools/contracts";
2626
import { sanitizeNewRefName } from "@t3tools/shared/git";
27-
import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
27+
import { resolveNewThreadEnvMode, resolveProjectSettings } from "@t3tools/shared/projectSettings";
2828
import { parseT3ProjectFile } from "@t3tools/shared/t3ProjectFile";
2929
import * as Arr from "effect/Array";
3030
import { pipe } from "effect/Function";
@@ -487,7 +487,8 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
487487
const attachments = selectedProjectDraft.attachments;
488488
// Default mode until the user picks one explicitly — same resolution web
489489
// uses for new draft threads: per-project setting, then the repo's
490-
// checked-in t3.json, then the server's configured default.
490+
// checked-in t3.json, then the server's configured default (which a new
491+
// project with no threads yet replaces with its checkout).
491492
const fileAccessSession = useEnvironmentQuery(
492493
selectedProject !== null && selectedProject.workspaceRoot !== ""
493494
? environmentSession.sessionStateAtom(selectedProject.environmentId)
@@ -535,8 +536,20 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
535536
// A thread without a project runs in a plain folder, so worktree mode
536537
// would leave it unsendable: it is always local and offers no choice.
537538
const canChooseWorkspace = !isScratchDraft;
539+
const selectedProjectHasThreads =
540+
selectedProject !== null &&
541+
threads.some(
542+
(thread) =>
543+
thread.environmentId === selectedProject.environmentId &&
544+
thread.projectId === selectedProject.id,
545+
);
538546
const defaultWorkspaceMode: WorkspaceMode = canChooseWorkspace
539-
? projectSettings.settings.defaultThreadEnvMode
547+
? resolveNewThreadEnvMode({
548+
projectSettings,
549+
workspaceRoot: selectedProject?.workspaceRoot ?? null,
550+
newProjectsRoot: selectedEnvironmentServerConfig?.newProjectsRoot,
551+
projectHasThreads: selectedProjectHasThreads,
552+
})
540553
: "local";
541554
// While the file read is pending and nothing above it decided, the
542555
// resolved default is provisional. Nothing may write it into the draft

‎apps/mobile/src/features/usage/UsageLimitsPooled.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { useProviderColors } from "./usageProviders";
3030
const DRIVER_LABEL: Partial<Record<string, string>> = {
3131
codex: "Codex",
3232
claudeAgent: "Claude",
33+
antigravity: "Antigravity",
3334
muse: "Muse Code",
3435
};
3536
const PACE_LABEL = { ahead: "Ahead of pace", on: "On pace", under: "Under pace" } as const;
@@ -268,7 +269,13 @@ export function UsageLimitsSection({
268269
<PoolWindowCard
269270
key={`${window.kind}:${window.id}`}
270271
pool={window}
271-
color={pool.driver === "claudeAgent" ? colors.claude : colors.codex}
272+
color={
273+
pool.driver === "claudeAgent"
274+
? colors.claude
275+
: pool.driver === "antigravity"
276+
? colors.antigravity
277+
: colors.codex
278+
}
272279
now={now}
273280
environmentIds={
274281
selectedEnvironmentIds === null ? null : [...selectedEnvironmentIds]

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { V2ItemSupport } from "@t3tools/client-runtime/state/item-support";
22
import { toolItemForDisplay } from "@t3tools/client-runtime/work-log/presentation";
3+
import { formatDiffCount } from "@t3tools/client-runtime/diff-count";
34
import type { ThreadId } from "@t3tools/contracts";
45
import { formatDuration } from "@t3tools/shared/orchestrationTiming";
56
import * as DateTime from "effect/DateTime";
@@ -160,7 +161,7 @@ export function buildThreadActivityInspector(
160161
if (item.additions !== undefined || item.deletions !== undefined) {
161162
fields.push({
162163
label: "Changes",
163-
value: `+${item.additions ?? 0} −${item.deletions ?? 0}`,
164+
value: `+${formatDiffCount(item.additions ?? 0)} −${formatDiffCount(item.deletions ?? 0)}`,
164165
});
165166
}
166167
break;
@@ -206,7 +207,10 @@ export function buildThreadActivityInspector(
206207
blocks,
207208
"Files",
208209
item.files
209-
.map((file) => `${file.path} +${file.additions} −${file.deletions} ${file.kind}`)
210+
.map(
211+
(file) =>
212+
`${file.path} +${formatDiffCount(file.additions)} −${formatDiffCount(file.deletions)} ${file.kind}`,
213+
)
210214
.join("\n"),
211215
);
212216
break;

‎apps/mobile/src/state/use-thread-composer-state.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,20 @@ export function useThreadComposerState() {
677677
alternateModifier: followUpOverride !== undefined && followUpOverride !== followUpBehavior,
678678
activeTurnDefault: followUpBehavior,
679679
});
680-
const followUpDispatchMode =
681-
followUpAction === "auto" ? null : followUpAction === "queue" ? "queue" : "auto";
680+
// A send while the worktree is still being set up waits behind that setup,
681+
// so the server can hold it if the setup ends without a worktree.
682+
// Before detail loads, the shell's latest run can be a queued follow-up
683+
// while its runtime still reports the setup.
684+
const setupRunning = [selectedThreadActivityRun?.status, selectedThreadRuntime?.status].some(
685+
(status) => status === "preparing" || status === "starting",
686+
);
687+
const followUpDispatchMode = setupRunning
688+
? "queue"
689+
: followUpAction === "auto"
690+
? null
691+
: followUpAction === "queue"
692+
? "queue"
693+
: "auto";
682694

683695
const metadata = makeQueuedMessageMetadata();
684696
const messageId = MessageId.make(metadata.messageId);
@@ -735,7 +747,9 @@ export function useThreadComposerState() {
735747
saveQueuedRunEdit,
736748
selectedEnvironmentRuntime?.connectionState,
737749
selectedEnvironmentRuntime?.serverConfig,
750+
selectedThreadActivityRun?.status,
738751
selectedThreadCreation,
752+
selectedThreadRuntime?.status,
739753
selectedThreadShell,
740754
uploadThreadFeedback,
741755
],

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,31 @@ describe("ClaudeAdapterV2 context usage", () => {
900900
updatedAt: "2026-08-29T00:00:00.000Z",
901901
});
902902
});
903+
904+
it("reports the prompt cache TTL the response wrote", () => {
905+
const ttlFor = (cache_creation: {
906+
ephemeral_1h_input_tokens: number;
907+
ephemeral_5m_input_tokens: number;
908+
}) =>
909+
ClaudeAdapterV2.claudeProviderTurnTokenUsage(
910+
{ input_tokens: 1, output_tokens: 1, cache_creation },
911+
CLAUDE_TEST_MODEL_SELECTION,
912+
"2026-08-29T00:00:00.000Z",
913+
).promptCacheTtlMs;
914+
915+
assert.strictEqual(
916+
ttlFor({ ephemeral_1h_input_tokens: 2_000, ephemeral_5m_input_tokens: 300 }),
917+
60 * 60_000,
918+
);
919+
assert.strictEqual(
920+
ttlFor({ ephemeral_1h_input_tokens: 0, ephemeral_5m_input_tokens: 300 }),
921+
5 * 60_000,
922+
);
923+
assert.strictEqual(
924+
ttlFor({ ephemeral_1h_input_tokens: 0, ephemeral_5m_input_tokens: 0 }),
925+
undefined,
926+
);
927+
});
903928
});
904929

905930
describe("ClaudeAdapterV2 session permissions", () => {

0 commit comments

Comments
 (0)