Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions apps/mobile/src/features/connection/CloudEnvironmentRows.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ConnectionTraceId } from "./ConnectionTraceId";
import { useAuth } from "@clerk/expo";
import { SymbolView } from "../../components/AppSymbol";
import {
Expand Down Expand Up @@ -405,23 +406,15 @@ function CloudEnvironmentRowShell(props: {
>
{statusText}
{errorTraceId ? (
<>
{" Trace ID: "}
<Text
accessibilityHint="Copies the trace ID"
accessibilityRole="button"
className={cn("text-xs underline decoration-dotted", statusClassName)}
onLongPress={(event) => {
event.stopPropagation();
copyTextWithHaptic(errorTraceId, { target: "connection-trace-id" });
}}
onPress={(event) => {
event.stopPropagation();
}}
>
{errorTraceId}
</Text>
</>
<ConnectionTraceId
traceId={errorTraceId}
tone={
props.connectionError && props.connectionState !== "unsupported"
? "danger"
: "muted"
}
activation="longPress"
/>
) : null}
</Text>
{errorCanExpand ? (
Expand Down
24 changes: 6 additions & 18 deletions apps/mobile/src/features/connection/ConnectionEnvironmentRow.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ConnectionTraceId } from "./ConnectionTraceId";
import { SymbolView } from "../../components/AppSymbol";
import { connectionStatusText } from "@t3tools/client-runtime/connection";
import type { AtomCommandResult } from "@t3tools/client-runtime/state/runtime";
Expand All @@ -15,7 +16,6 @@ import { MaterialButton } from "../../components/MaterialButton";
import { MaterialIconButton } from "../../components/MaterialIconButton";
import { ThemedSwitch } from "../../components/ThemedSwitch";
import { cn } from "../../lib/cn";
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types";
import { serverEnvironment } from "../../state/server";
import { ConnectionStatusDot } from "./ConnectionStatusDot";
Expand Down Expand Up @@ -114,23 +114,11 @@ export function ConnectionEnvironmentRow(props: {
>
{statusLabel}
{statusTraceId ? (
<>
{" Trace ID: "}
<Text
accessibilityHint="Copies the trace ID"
accessibilityRole="button"
className="underline decoration-dotted"
onLongPress={(event) => {
event.stopPropagation();
copyTextWithHaptic(statusTraceId, { target: "connection-trace-id" });
}}
onPress={(event) => {
event.stopPropagation();
}}
>
{statusTraceId}
</Text>
</>
<ConnectionTraceId
traceId={statusTraceId}
tone={hasConnectionFailure ? "danger" : "muted"}
activation="longPress"
/>
) : null}
</Text>
) : null}
Expand Down
51 changes: 51 additions & 0 deletions apps/mobile/src/features/connection/ConnectionTraceId.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { AppText as Text } from "../../components/AppText";
import { cn } from "../../lib/cn";
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";

/** Inline trace control; disclosure rows reserve ordinary taps for their own navigation. */
export function ConnectionTraceId({
traceId,
tone = "muted",
activation = "press",
}: {
readonly traceId: string;
readonly tone?: "muted" | "danger";
readonly activation?: "press" | "longPress";
}) {
const copy = () => copyTextWithHaptic(traceId, { target: "connection-trace-id" });
return (
<>
{" Trace ID: "}
<Text
accessibilityHint={
activation === "longPress" ? "Long press to copy the trace ID" : "Copies the trace ID"
}
accessibilityLabel={`Copy trace ID ${traceId}`}
accessibilityRole="button"
accessibilityActions={[{ name: "activate", label: "Copy trace ID" }]}
onAccessibilityAction={(event) => {
event.stopPropagation();
if (event.nativeEvent.actionName === "activate") copy();
}}
className={cn(
"underline decoration-dotted",
tone === "danger" ? "text-danger-foreground" : "text-foreground-muted",
)}
onLongPress={
activation === "longPress"
? (event) => {
event.stopPropagation();
copy();
}
: undefined
}
onPress={(event) => {
event.stopPropagation();
if (activation === "press") copy();
}}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
>
{traceId}
</Text>
</>
);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ConnectionTraceId } from "./ConnectionTraceId";
import {
type EnvironmentConnectionPhase,
type EnvironmentConnectionPresentation,
Expand All @@ -6,7 +7,6 @@ import { SymbolView } from "../../components/AppSymbol";
import { ActivityIndicator, Pressable, View } from "react-native";

import { AppText as Text } from "../../components/AppText";
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";

function noticeTitle(phase: EnvironmentConnectionPhase, environmentLabel: string): string {
switch (phase) {
Expand Down Expand Up @@ -81,21 +81,7 @@ export function EnvironmentConnectionNotice(props: {
<Text className="text-center text-sm leading-normal text-foreground-muted">
{noticeDetail(props.connection.phase, props.resourceName, props.connection.error)}
{props.connection.traceId ? (
<>
{" Trace ID: "}
<Text
accessibilityHint="Copies the trace ID"
accessibilityRole="button"
className="underline decoration-dotted"
onPress={() =>
copyTextWithHaptic(props.connection.traceId!, {
target: "connection-trace-id",
})
}
>
{props.connection.traceId}
</Text>
</>
<ConnectionTraceId traceId={props.connection.traceId} />
) : null}
</Text>

Expand Down
Loading