Skip to content

Commit 46b76ac

Browse files
authored
Merge branch 'main' into fix/grok-turn-stuck-background-tasks
2 parents 2b1adb6 + a4c9494 commit 46b76ac

114 files changed

Lines changed: 11039 additions & 771 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/components/ProviderIcon.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ export function ProviderIcon(props: ProviderIconProps) {
119119
);
120120
}
121121

122+
if (props.provider === "muse") {
123+
return (
124+
<Svg width={size} height={size} viewBox="0 0 150.4828 100" fill="none">
125+
<Path
126+
fill={mono}
127+
fillRule="evenodd"
128+
d="M107.9999847,0.0000013c-12.3391113,0-21.984787,9.2935991-30.7164001,21.0993118 C65.2847366,5.821527,55.2499847,0,43.2413788,0C18.7586193,0,0,31.8620682,0,65.5862122 C0,86.6896515,10.2095623,100,27.3103466,100c12.3080502,0,21.1600361-5.8025894,36.8965454-33.3103409 c0,0,6.5597382-11.5841255,11.0725021-19.563858c1.5813522,2.5531845,3.2431107,5.3001404,4.9964676,8.2535095 l7.379303,12.4137955C102.0298843,91.8478851,110.039032,100,124.5517273,100 c16.6595764,0,25.9310303-13.4923325,25.9310303-35.0344849 C150.4827576,29.6551723,131.301178,0.0000013,107.9999847,0.0000013z M52.2068977,59.2413788 c-12.7586212,20-17.1724167,24.4827576-24.2758656,24.4827576c-7.3103428,0-11.6551704-6.4178314-11.6551704-17.8620682 c0-24.4827576,12.2068977-49.5172424,26.7586231-49.5172424c7.880127,0,14.4653816,4.5510426,24.5522308,18.9913158 C58.0087967,50.0272293,52.2068977,59.2413788,52.2068977,59.2413788z M100.3597336,56.7235756L91.5367355,42.00877 c-2.3876724-3.8832092-4.6757278-7.451458-6.8838348-10.7230263 c7.951973-12.273531,14.5113449-18.3891907,22.3126144-18.3891907c16.2069016,0,29.1724243,23.8620682,29.1724243,53.1724091 c0,11.1724167-3.6593475,17.6551743-11.2413864,17.6551743 C117.6294937,83.7241364,114.1578674,78.924736,100.3597336,56.7235756z"
129+
/>
130+
</Svg>
131+
);
132+
}
133+
122134
if (props.provider === "pi") {
123135
const foreground = isDarkMode ? "#F5F5F5" : "#0F0F0F";
124136
return (

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,13 @@ function renderFeedEntry(
19391939
})}
19401940
{showAssistantMeta ? (
19411941
<View className="mt-1 flex-row items-center gap-1">
1942+
<CopyTextButton
1943+
accessibilityLabel="Copy message"
1944+
text={renderedText}
1945+
tintColor={iconSubtleColor}
1946+
buttonSize={28}
1947+
iconSize={13}
1948+
/>
19421949
{message.projectedItem ? (
19431950
<AssistantForkButton
19441951
environmentId={props.environmentId}
@@ -1947,13 +1954,6 @@ function renderFeedEntry(
19471954
sourceTitle={props.threadTitle}
19481955
/>
19491956
) : null}
1950-
<CopyTextButton
1951-
accessibilityLabel="Copy message"
1952-
text={renderedText}
1953-
tintColor={iconSubtleColor}
1954-
buttonSize={28}
1955-
iconSize={13}
1956-
/>
19571957
<Text className="font-t3-medium text-xs tabular-nums text-foreground-secondary">
19581958
{timestampLabel}
19591959
</Text>

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

Lines changed: 101 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { ChatGptUsageSummary } from "./ChatGptUsageSummary";
22
import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
3-
import { EnvironmentId, USAGE_CONTRACT_VERSION } from "@t3tools/contracts";
3+
import { EnvironmentId, USAGE_CONTRACT_VERSION, type UsageProviderKind } from "@t3tools/contracts";
44
import { type RouteProp, useIsFocused, useNavigation, useRoute } from "@react-navigation/native";
55
import { cursorKeychainAccessEnvironments } from "@t3tools/client-runtime/state/usage";
6+
import {
7+
updatingProvidersLabel,
8+
usageEnvironmentProgress,
9+
usageProgress,
10+
} from "@t3tools/client-runtime/state/usage-progress";
611
import {
712
isCompatibleUsageContractVersion,
813
isModelCostUnknown,
@@ -21,9 +26,16 @@ import {
2126
formatUsd,
2227
makeWindow,
2328
} from "@t3tools/shared/usageFormat";
24-
import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
25-
import { Platform, Pressable, RefreshControl, View } from "react-native";
26-
import Animated, { FadeIn, ReduceMotion } from "react-native-reanimated";
29+
import { useCallback, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
30+
import { ActivityIndicator, Platform, Pressable, RefreshControl, View } from "react-native";
31+
import Animated, {
32+
FadeIn,
33+
ReduceMotion,
34+
useAnimatedStyle,
35+
useSharedValue,
36+
withDelay,
37+
withTiming,
38+
} from "react-native-reanimated";
2739
import { useSafeAreaInsets } from "react-native-safe-area-context";
2840

2941
import { SegmentedControl } from "../../components/SegmentedControl";
@@ -65,6 +77,7 @@ const METRIC_OPTIONS = [
6577
] as const satisfies readonly { value: UsageChartMetric; label: string }[];
6678

6779
const CHART_HEIGHT = 180;
80+
const providerLabel = (provider: UsageProviderKind) => PROVIDER_LABEL[provider];
6881
const CURSOR_KEYCHAIN_COPY = "Requires access to your Cursor login in macOS Keychain.";
6982

7083
/**
@@ -156,6 +169,10 @@ export function UsageRouteScreen() {
156169
const [refreshingUsage, setRefreshingUsage] = useState(false);
157170
const refreshingRef = useRef(false);
158171
const showingLimits = tab === "limits";
172+
const progress = usageProgress(selectedEnvironments, {
173+
refreshing: refreshingUsage,
174+
providerLabel,
175+
});
159176
const selectWindow = (days: number) => {
160177
setWindowSelection({
161178
days,
@@ -182,10 +199,6 @@ export function UsageRouteScreen() {
182199
};
183200

184201
const showEnvironmentFilter = environments.length > 0 || selectedEnvironmentIds !== null;
185-
const hasLoadingEnvironments = selectedEnvironments.some(isUsageLoading);
186-
const filterAccessibilityLabel = hasLoadingEnvironments
187-
? "Filter usage environments, some environments are loading"
188-
: "Filter usage environments";
189202
const filterIcon =
190203
selectedEnvironmentIds === null
191204
? "line.3.horizontal.decrease"
@@ -201,14 +214,14 @@ export function UsageRouteScreen() {
201214
...environments.map((environment) => ({
202215
id: environment.environmentId,
203216
title: environment.label,
204-
subtitle: usageEnvironmentStatus(environment),
217+
subtitle: usageEnvironmentStatus(environment, refreshingUsage),
205218
state:
206219
selectedEnvironmentIds === null || selectedEnvironmentIds.has(environment.environmentId)
207220
? ("on" as const)
208221
: ("off" as const),
209222
})),
210223
],
211-
[environments, selectedEnvironmentIds],
224+
[environments, refreshingUsage, selectedEnvironmentIds],
212225
);
213226
const selectEnvironment = useCallback(
214227
(value: string) => {
@@ -227,37 +240,24 @@ export function UsageRouteScreen() {
227240
<ControlPillMenu
228241
accessible
229242
accessibilityRole="button"
230-
accessibilityLabel={filterAccessibilityLabel}
243+
accessibilityLabel="Filter usage environments"
231244
title="Environments"
232245
actions={environmentActions}
233246
onPressAction={({ nativeEvent }) => selectEnvironment(nativeEvent.event)}
234247
>
235248
<Pressable
236249
accessibilityRole="button"
237-
accessibilityLabel={filterAccessibilityLabel}
250+
accessibilityLabel="Filter usage environments"
238251
className={cn(
239252
"items-center justify-center rounded-full",
240253
Platform.OS === "ios" ? "size-[28px]" : "size-[44px]",
241254
)}
242255
>
243256
<SymbolView name={filterIcon} size={22} tintColorClassName="accent-icon" />
244-
{hasLoadingEnvironments ? (
245-
<View
246-
pointerEvents="none"
247-
className="absolute -right-[2px] -top-[2px] size-[9px] rounded-full bg-amber-500"
248-
/>
249-
) : null}
250257
</Pressable>
251258
</ControlPillMenu>
252259
) : null,
253-
[
254-
showEnvironmentFilter,
255-
environmentActions,
256-
selectEnvironment,
257-
filterAccessibilityLabel,
258-
filterIcon,
259-
hasLoadingEnvironments,
260-
],
260+
[showEnvironmentFilter, environmentActions, selectEnvironment, filterIcon],
261261
);
262262

263263
useLayoutEffect(() => {
@@ -361,26 +361,28 @@ export function UsageRouteScreen() {
361361
{message}
362362
</Text>
363363
))}
364-
<ChartCard
365-
merged={merged}
366-
days={chartDays}
367-
daily={chartTotals}
368-
metric={metric}
369-
sinceDay={window.sinceDay}
370-
untilDay={window.untilDay}
371-
isPast24Hours={isPast24Hours}
372-
timeZone={window.timeZone}
373-
/>
374-
<ProviderSection
375-
merged={merged}
376-
metric={metric}
377-
cursorAccessEnvironments={cursorAccessEnvironments}
378-
showCursorEnvironment={selectedEnvironments.length > 1}
379-
onCursorEnabled={refreshAfterCursorEnable}
380-
/>
381-
<TotalsSection merged={merged} isPast24Hours={isPast24Hours} />
382-
<CostSection merged={merged} />
383-
<ModelsSection merged={merged} metric={metric} />
364+
<UsageUpdating dimmed={progress.dimmed} label={progress.label}>
365+
<ChartCard
366+
merged={merged}
367+
days={chartDays}
368+
daily={chartTotals}
369+
metric={metric}
370+
sinceDay={window.sinceDay}
371+
untilDay={window.untilDay}
372+
isPast24Hours={isPast24Hours}
373+
timeZone={window.timeZone}
374+
/>
375+
<ProviderSection
376+
merged={merged}
377+
metric={metric}
378+
cursorAccessEnvironments={cursorAccessEnvironments}
379+
showCursorEnvironment={selectedEnvironments.length > 1}
380+
onCursorEnabled={refreshAfterCursorEnable}
381+
/>
382+
<TotalsSection merged={merged} isPast24Hours={isPast24Hours} />
383+
<CostSection merged={merged} />
384+
<ModelsSection merged={merged} metric={metric} />
385+
</UsageUpdating>
384386
</>
385387
)}
386388
</>
@@ -391,6 +393,53 @@ export function UsageRouteScreen() {
391393
);
392394
}
393395

396+
/**
397+
* Dims totals that are about to change and says what is still updating. The
398+
* status overlays the first child's top-right corner, the chart card's label
399+
* row, so appearing never moves anything.
400+
*/
401+
function UsageUpdating({
402+
dimmed,
403+
label,
404+
children,
405+
}: {
406+
readonly dimmed: boolean;
407+
readonly label: string | null;
408+
readonly children: ReactNode;
409+
}) {
410+
const opacity = useSharedValue(1);
411+
useLayoutEffect(() => {
412+
// The delay keeps a quick cached answer from flashing the dim.
413+
opacity.set(
414+
dimmed
415+
? withDelay(150, withTiming(0.5, { duration: 150, reduceMotion: ReduceMotion.System }))
416+
: withTiming(1, { duration: 150, reduceMotion: ReduceMotion.System }),
417+
);
418+
}, [opacity, dimmed]);
419+
const dimStyle = useAnimatedStyle(() => ({ opacity: opacity.get() }));
420+
421+
return (
422+
<View>
423+
<Animated.View style={dimStyle} className="gap-6" accessibilityState={{ busy: dimmed }}>
424+
{children}
425+
</Animated.View>
426+
{label !== null ? (
427+
<Animated.View
428+
entering={FadeIn.delay(150).duration(150).reduceMotion(ReduceMotion.System)}
429+
accessibilityLiveRegion="polite"
430+
pointerEvents="none"
431+
className="absolute right-4 top-4 h-5 max-w-[55%] flex-row items-center gap-1.5"
432+
>
433+
<ActivityIndicator size="small" colorClassName="accent-adaptive-sky-600-400" />
434+
<Text className="shrink text-sm text-adaptive-sky-600-400" numberOfLines={1}>
435+
{label}
436+
</Text>
437+
</Animated.View>
438+
) : null}
439+
</View>
440+
);
441+
}
442+
394443
function CursorEnableAction({
395444
environmentId,
396445
label,
@@ -860,11 +909,7 @@ function ModelsSection(props: { readonly merged: MergedUsage; readonly metric: U
860909
* one that failed, or one whose transcripts another environment already
861910
* reported.
862911
*/
863-
function isUsageLoading(environment: EnvironmentUsageStatus) {
864-
return environment.isPending || (environment.summary === null && environment.error === null);
865-
}
866-
867-
function usageEnvironmentStatus(environment: EnvironmentUsageStatus): string {
912+
function usageEnvironmentStatus(environment: EnvironmentUsageStatus, refreshing: boolean): string {
868913
if (
869914
environment.summary &&
870915
!isCompatibleUsageContractVersion(environment.summary.contractVersion, USAGE_CONTRACT_VERSION)
@@ -881,7 +926,10 @@ function usageEnvironmentStatus(environment: EnvironmentUsageStatus): string {
881926
return environment.summary ? `${environment.error} Showing saved totals.` : environment.error;
882927
if (!environment.isConnected)
883928
return environment.summary ? "Disconnected · showing saved usage" : "Waiting for connection…";
884-
if (isUsageLoading(environment))
885-
return environment.summary ? "Updating usage…" : "Loading usage…";
929+
const progress = usageEnvironmentProgress(environment, refreshing);
930+
if (progress.phase === "loading") return "Loading usage…";
931+
if (progress.phase === "stale") return "Updating usage…";
932+
if (progress.phase === "partway")
933+
return updatingProvidersLabel(progress.providers, providerLabel);
886934
return "Usage up to date";
887935
}

‎apps/server/integration/transferBudgetV2.integration.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ const layerManagement = Layer.unwrap(
8888
projections.getThreadSnapshotWindow(id, options).pipe(Effect.orDie),
8989
getThreadShell: (id) => projections.getThreadShell(id).pipe(Effect.orDie),
9090
getShellSnapshot: (options) => projections.getShellSnapshot(options).pipe(Effect.orDie),
91+
readShellSnapshot: (options) =>
92+
projections.readShellSnapshot(options).pipe(Effect.map(Effect.orDie), Effect.orDie),
9193
streamStoredEventsFrom: (input) =>
9294
sink.stream({ ...input, bounded: true }).pipe(Stream.orDie),
9395
});

‎apps/server/package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@
2525
"record:claude-replay": "bun scripts/record-claude-agent-sdk-replay-fixture.ts",
2626
"record:cursor-replay": "node --env-file-if-exists=../../.env --experimental-strip-types scripts/record-cursor-agent-sdk-replay-fixture.ts",
2727
"record:pi-replay": "node scripts/record-pi-rpc-replay-fixture.ts",
28-
"record:grok-replay": "node scripts/record-grok-acp-replay-fixture.ts"
28+
"record:grok-replay": "node scripts/record-grok-acp-replay-fixture.ts",
29+
"record:muse-replay": "node scripts/record-muse-msp-replay-fixture.ts"
2930
},
3031
"dependencies": {
3132
"@anthropic-ai/claude-agent-sdk": "^0.3.276",
3233
"@cursor/sdk": "1.0.35",
3334
"@effect/platform-node": "catalog:",
3435
"@effect/platform-node-shared": "catalog:",
3536
"@ff-labs/fff-node": "0.9.4",
37+
"@muse-code/sdk": "1.4.2",
3638
"@napi-rs/keyring": "^1.3.0",
3739
"@noble/hashes": "catalog:",
3840
"@opencode-ai/sdk": "^1.3.15",

0 commit comments

Comments
 (0)