Skip to content

Commit 57eaf5e

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/mobile-unify-chat-chips
# Conflicts: # apps/mobile/src/features/threads/ThreadFeed.tsx
2 parents d28eb04 + d3415f3 commit 57eaf5e

183 files changed

Lines changed: 23430 additions & 1469 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.

‎.gitattributes‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Batch files need CRLF for cmd.exe to parse them reliably.
44
*.cmd text eol=crlf
55
*.bat text eol=crlf
6-
# GitHub's GraphQL schema and the operations graphqlgen writes from it.
6+
# GitHub's and Expo's GraphQL schemas and the operations graphqlgen writes from them.
77
packages/source-control-github/schema/** linguist-generated
8+
apps/server/schema/** linguist-generated
89
**/*.graphql.ts linguist-generated

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ jobs:
9393
- name: Check generated GitHub GraphQL operations
9494
run: vp run --filter @t3tools/source-control-github generate --check
9595

96+
- name: Check generated Expo GraphQL operations
97+
run: vp run --filter t3 generate --check
98+
9699
- name: Check
97100
run: vp check
98101

‎apps/mobile/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
"shiki": "4.2.0",
145145
"tailwind-merge": "^3.5.0",
146146
"unified": "catalog:",
147-
"uniwind": "1.12.1"
147+
"uniwind": "1.13.0"
148148
},
149149
"devDependencies": {
150150
"@babel/core": "^7.29.7",

‎apps/mobile/src/connection/platform.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ const layerCapabilities = Layer.effectContext(
196196
bearerToken: Effect.succeed(Option.none()),
197197
}),
198198
),
199+
// The relay device id already persists in secure storage; analytics only sends its hash.
200+
Context.add(ClientCapabilities.AnalyticsDevice, {
201+
id: storage.loadOrCreateAgentAwarenessDeviceId.pipe(Effect.option),
202+
}),
199203
Context.add(
200204
ClientCapabilities.RelayDeviceIdentity,
201205
ClientCapabilities.RelayDeviceIdentity.of({

‎apps/mobile/src/features/connection/CloudEnvironmentRows.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { environmentPresentations } from "../../state/presentation";
2828
import { availableCloudEnvironmentPresentation } from "../cloud/cloudEnvironmentPresentation";
2929
import { hasCloudPublicConfig } from "../cloud/publicConfig";
3030
import { ConnectionStatusDot } from "./ConnectionStatusDot";
31+
import { useConnectionDiagnosis } from "./ConnectionDiagnosisDetails";
3132
import { environmentStatusText } from "./environmentStatusText";
3233
import { type RelayEnvironmentView, useConnectionController } from "./useConnectionController";
3334

@@ -193,6 +194,7 @@ function ConnectedCloudEnvironmentRow(props: {
193194
);
194195
const canRetry = presentation !== null && hasSavedBearerRoute(presentation.entry);
195196
const enabled = props.environment.isEnabled && !unsupported;
197+
const { diagnosis } = useConnectionDiagnosis(props.environment.environmentId, presentation);
196198
const [lastDescriptor, setLastDescriptor] = useState(props.descriptor);
197199
if (props.descriptor !== undefined && props.descriptor !== lastDescriptor) {
198200
setLastDescriptor(props.descriptor);
@@ -213,7 +215,11 @@ function ConnectedCloudEnvironmentRow(props: {
213215
onValueChange={props.onSetEnabled}
214216
onToggleError={props.onToggleError}
215217
disabled={unsupported && !canRetry}
216-
{...(enabled || unsupported ? {} : { statusText: "Off" })}
218+
{...(enabled || unsupported
219+
? diagnosis
220+
? { statusText: diagnosis.headline }
221+
: {}
222+
: { statusText: "Off" })}
217223
value={enabled}
218224
/>
219225
);
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { useAtomValue } from "@effect/atom-react";
2+
import {
3+
AVAILABLE_CONNECTION_STATE,
4+
type ConnectionDiagnosis,
5+
connectionDiagnosisText,
6+
connectionRoutes,
7+
hasRelayRoute,
8+
presentConnectionDiagnosis,
9+
type EnvironmentPresentation,
10+
} from "@t3tools/client-runtime/connection";
11+
import type { EnvironmentId } from "@t3tools/contracts";
12+
import Constants from "expo-constants";
13+
import * as Option from "effect/Option";
14+
import { AsyncResult } from "effect/reactivity";
15+
import { View } from "react-native";
16+
17+
import { AppText as Text } from "../../components/ui/AppText";
18+
import { Button } from "../../components/ui/Button";
19+
import { environmentCatalog } from "../../connection/catalog";
20+
import { cn } from "../../lib/cn";
21+
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
22+
23+
const HOP_MARK = { ok: "✓", failed: "✕", unchecked: "–" } as const;
24+
const HOP_NOTE = { ok: "", failed: " · Failed", unchecked: " · Not checked" } as const;
25+
26+
/** Same model as the web Settings row; null while connected, off, or not failed. */
27+
export function useConnectionDiagnosis(
28+
environmentId: EnvironmentId,
29+
presentation: EnvironmentPresentation | null,
30+
) {
31+
const state = Option.getOrElse(
32+
AsyncResult.value(useAtomValue(environmentCatalog.stateAtom(environmentId))),
33+
() => AVAILABLE_CONNECTION_STATE,
34+
);
35+
if (presentation === null || !presentation.entry.enabled) return { diagnosis: null, state };
36+
const phase = presentation.connection.phase;
37+
if (phase === "connected" || phase === "unsupported") return { diagnosis: null, state };
38+
const relayOnly =
39+
connectionRoutes(presentation.entry).length === 1 && hasRelayRoute(presentation.entry);
40+
const diagnosis = presentConnectionDiagnosis({
41+
hostLabel: presentation.entry.target.label,
42+
state,
43+
via: relayOnly ? "relay" : "direct",
44+
clientVersion: Constants.expoConfig?.version,
45+
serverVersion: presentation.serverConfig?.environment.serverVersion,
46+
});
47+
return { diagnosis, state };
48+
}
49+
50+
export function ConnectionDiagnosisDetails(props: {
51+
readonly hostLabel: string;
52+
readonly diagnosis: ConnectionDiagnosis;
53+
}) {
54+
const { diagnosis } = props;
55+
return (
56+
<View className="gap-3">
57+
<View className="gap-0.5">
58+
{diagnosis.hops.map((hop) => (
59+
<Text
60+
key={hop.hop}
61+
className={cn(
62+
"text-sm",
63+
hop.result === "failed" ? "text-danger-foreground" : "text-foreground-muted",
64+
)}
65+
>
66+
{`${HOP_MARK[hop.result]} ${hop.label}${HOP_NOTE[hop.result]}`}
67+
</Text>
68+
))}
69+
</View>
70+
<View className="gap-0.5">
71+
<Text className="text-sm font-t3-bold text-foreground">What to try</Text>
72+
{diagnosis.steps.map((step, index) => (
73+
<Text key={step} className="text-sm text-foreground-muted">
74+
{`${index + 1}. ${step}`}
75+
</Text>
76+
))}
77+
</View>
78+
<Text selectable className="font-mono text-xs text-foreground-muted">
79+
{diagnosis.facts.map(([label, value]) => `${label}: ${value}`).join("\n")}
80+
</Text>
81+
<Button
82+
label="Copy diagnostics"
83+
icon="doc.on.doc"
84+
onPress={() => {
85+
copyTextWithHaptic(connectionDiagnosisText(props.hostLabel, diagnosis), {
86+
target: "connection-diagnostics",
87+
});
88+
}}
89+
/>
90+
</View>
91+
);
92+
}

‎apps/mobile/src/features/connection/ConnectionEnvironmentRow.tsx‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { cn } from "../../lib/cn";
2020
import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types";
2121
import { serverEnvironment } from "../../state/server";
2222
import { environmentPresentations } from "../../state/presentation";
23+
import { ConnectionDiagnosisDetails, useConnectionDiagnosis } from "./ConnectionDiagnosisDetails";
2324
import { ConnectionFormField } from "./ConnectionFormField";
2425
import { ConnectionStatusDot } from "./ConnectionStatusDot";
2526
import { environmentStatusText } from "./environmentStatusText";
@@ -58,6 +59,10 @@ export function ConnectionEnvironmentRow(props: {
5859
environmentPresentations.presentationAtom(props.environment.environmentId),
5960
);
6061
const canRetry = presentation !== null && hasSavedBearerRoute(presentation.entry);
62+
const { diagnosis, state: connectionState } = useConnectionDiagnosis(
63+
props.environment.environmentId,
64+
presentation,
65+
);
6166
const enabled = props.environment.isEnabled && !unsupported;
6267
const statusLabel = connectionStatusLabel(props.environment);
6368
const statusTraceId = enabled ? props.environment.connectionErrorTraceId : null;
@@ -118,7 +123,16 @@ export function ConnectionEnvironmentRow(props: {
118123
{props.environment.displayUrl}
119124
</Text>
120125
) : null}
121-
{statusLabel ? (
126+
{diagnosis ? (
127+
<>
128+
<Text className="text-xs text-danger-foreground">{diagnosis.headline}</Text>
129+
{connectionState.attempt > 0 ? (
130+
<Text className="text-xs text-foreground-muted">
131+
{`Retrying · attempt ${connectionState.attempt}`}
132+
</Text>
133+
) : null}
134+
</>
135+
) : statusLabel ? (
122136
<Text
123137
className={cn(
124138
"text-xs",
@@ -177,6 +191,12 @@ export function ConnectionEnvironmentRow(props: {
177191
exiting={FadeOut.duration(150)}
178192
className="gap-3 px-4 pb-4"
179193
>
194+
{diagnosis ? (
195+
<ConnectionDiagnosisDetails
196+
hostLabel={props.environment.environmentLabel}
197+
diagnosis={diagnosis}
198+
/>
199+
) : null}
180200
{props.environment.isRelayManaged ? (
181201
<Text className="text-sm text-foreground-muted">
182202
Managed by T3 Connect. Tunnel details update automatically.

‎apps/mobile/src/features/devices/device-stream.browser.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ export function start(configuration: DeviceStreamConfiguration) {
140140
canvas.style.display = "none";
141141
image.style.display = "block";
142142
},
143+
onCanvasVideo: () => {
144+
image.style.display = "none";
145+
canvas.style.display = "";
146+
},
143147
onUnauthorized: unauthorized,
144148
onInputConnected: (connected) => {
145149
inputConnected = connected;

‎apps/mobile/src/features/pull-requests/PullRequestFiles.tsx‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { PullRequestChangeBreakdown } from "@t3tools/contracts";
12
import { PullRequestSectionHeading } from "./PullRequestSectionHeading";
23
import { AnimatedLegendList } from "@legendapp/list/reanimated";
34
import Animated from "react-native-reanimated";
@@ -23,6 +24,33 @@ import {
2324
import { usePullRequestFilesViewed } from "./usePullRequestFilesViewed";
2425
import { usePullRequestFileFilter } from "./usePullRequestFileFilter";
2526

27+
const BREAKDOWN_LABELS = {
28+
code: "Code",
29+
tests: "Tests",
30+
mocks: "Mocks",
31+
generated: "Generated",
32+
} satisfies Record<keyof NonNullable<PullRequestChangeBreakdown>, string>;
33+
34+
function PullRequestChangeBreakdownLine(props: {
35+
readonly breakdown: NonNullable<PullRequestChangeBreakdown>;
36+
}) {
37+
const parts = (Object.keys(BREAKDOWN_LABELS) as Array<keyof typeof BREAKDOWN_LABELS>).flatMap(
38+
(kind) => {
39+
const { additions, deletions } = props.breakdown[kind];
40+
return additions === 0 && deletions === 0
41+
? []
42+
: [
43+
`${BREAKDOWN_LABELS[kind]} +${additions.toLocaleString()} −${deletions.toLocaleString()}`,
44+
];
45+
},
46+
);
47+
return (
48+
<Text className="text-2xs tabular-nums text-foreground-muted" numberOfLines={2}>
49+
{parts.join(" · ")}
50+
</Text>
51+
);
52+
}
53+
2654
function fileDirectory(path: string) {
2755
const separator = path.lastIndexOf("/");
2856
return separator < 0 ? "" : path.slice(0, separator);
@@ -37,6 +65,9 @@ export function usePullRequestFilesContent(props: {
3765
const result = usePullRequestDiff(props.params);
3866
const detail = useEnvironmentQuery(composerPullRequests.detail(requestTarget(props.params)));
3967
const viewed = usePullRequestFilesViewed(props.params, props.params.commit ? null : detail.data);
68+
const breakdown = useEnvironmentQuery(
69+
props.params.commit ? null : composerPullRequests.changeBreakdown(requestTarget(props.params)),
70+
).data;
4071
const filter = usePullRequestFileFilter(result.parsed);
4172
const parsed = filter.parsed;
4273
const loading = result.isPending && parsed.kind === "empty" && !result.error;
@@ -209,6 +240,7 @@ export function usePullRequestFilesContent(props: {
209240
? `${filter.hiddenCount} test ${filter.hiddenCount === 1 ? "file" : "files"} hidden`
210241
: "Test files included"}
211242
</Text>
243+
{breakdown ? <PullRequestChangeBreakdownLine breakdown={breakdown} /> : null}
212244
</View>
213245
<PullRequestDiffStats
214246
additions={parsed.additions}

‎apps/mobile/src/features/pull-requests/pullRequestFileFilters.ts‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1+
import { classifyChangedFile } from "@t3tools/shared/changedFileKind";
12
import type { ReviewParsedDiff } from "../review/reviewModel";
23

4+
/** Test support such as fixtures and snapshots is hidden along with the tests. */
35
export function isPullRequestTestFile(path: string): boolean {
4-
const segments = path.replaceAll("\\", "/").split("/");
5-
const name = segments.at(-1) ?? "";
6-
return (
7-
segments
8-
.slice(0, -1)
9-
.some((segment) => /^(?:__tests__|__snapshots__|tests?|spec|e2e)$/i.test(segment)) ||
10-
/\.(?:test|spec)\./i.test(name) ||
11-
/\.snap$/i.test(name) ||
12-
/^(?:test_.+|.+_test)\.py$/i.test(name) ||
13-
/_test\.(?:go|rs|rb|c|cc|cpp|h|hpp)$/i.test(name) ||
14-
/(?:Test|Tests|Spec)\.(?:java|kt|kts|swift|cs)$/.test(name) ||
15-
/_spec\.rb$/i.test(name)
16-
);
6+
const kind = classifyChangedFile(path);
7+
return kind === "tests" || kind === "mocks";
178
}
189

1910
export function filterPullRequestTestFiles(

0 commit comments

Comments
 (0)