Skip to content

Commit eaa12a9

Browse files
test(web): preserve path-copy regressions in the new logic suite
2 parents bcc52f8 + da7c4f2 commit eaa12a9

77 files changed

Lines changed: 5817 additions & 7401 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/settings/SettingsProviderAccountsRouteScreen.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import {
55
type AtomCommandResult,
66
} from "@t3tools/client-runtime/state/runtime";
77
import type { ProviderAuthResponse, ServerProvider } from "@t3tools/contracts";
8+
import { useAtomValue } from "@effect/atom-react";
89
import { useRef, useState } from "react";
910
import { Linking, Pressable, ScrollView, TextInput, View } from "react-native";
1011
import { useSafeAreaInsets } from "react-native-safe-area-context";
1112

1213
import { AppText as Text } from "../../components/ui/AppText";
1314
import { ScreenScrollView } from "../../components/ui/ScreenScrollView";
15+
import { environmentPresentations } from "../../state/presentation";
1416
import { useEnvironmentQuery } from "../../state/query";
1517
import { serverEnvironment } from "../../state/server";
1618
import { useAtomCommand } from "../../state/use-atom-command";
@@ -25,6 +27,7 @@ import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-en
2527

2628
export function SettingsProviderAccountsRouteScreen() {
2729
const { selectedTargets } = useSettingsEnvironmentFilter();
30+
const providersByEnvironment = useAtomValue(environmentPresentations.providersByEnvironmentAtom);
2831
const insets = useSafeAreaInsets();
2932
return (
3033
<>
@@ -41,7 +44,7 @@ export function SettingsProviderAccountsRouteScreen() {
4144
) : (
4245
selectedTargets.map((environment) => (
4346
<SettingsSection key={environment.environmentId} title={environment.label}>
44-
{environment.serverConfig.providers
47+
{(providersByEnvironment.get(environment.environmentId) ?? [])
4548
.filter(
4649
(provider) =>
4750
provider.setup?.canAuthenticate ||
@@ -54,7 +57,7 @@ export function SettingsProviderAccountsRouteScreen() {
5457
provider={provider}
5558
/>
5659
))}
57-
{!environment.serverConfig.providers.some(
60+
{!(providersByEnvironment.get(environment.environmentId) ?? []).some(
5861
(provider) =>
5962
provider.setup?.canAuthenticate ||
6063
(provider.driver === "acpRegistry" && provider.installed),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function ChatGptUsageSummary({
1111
}: {
1212
selectedEnvironmentIds: ReadonlySet<EnvironmentId> | null;
1313
}) {
14-
const presentations = useAtomValue(environmentPresentations.presentationsAtom);
14+
const presentations = useAtomValue(environmentPresentations.presentationsWithProvidersAtom);
1515
const selected =
1616
selectedEnvironmentIds === null
1717
? presentations

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export function UsageLimitsSection({
222222
readonly selectedEnvironmentIds: ReadonlySet<EnvironmentId> | null;
223223
readonly cursorPrompt?: ReactNode;
224224
}) {
225-
const presentations = useAtomValue(environmentPresentations.presentationsAtom);
225+
const presentations = useAtomValue(environmentPresentations.presentationsWithProvidersAtom);
226226
const selected =
227227
selectedEnvironmentIds === null
228228
? presentations
@@ -345,7 +345,7 @@ type AccountScreenProps = StaticScreenProps<{
345345

346346
export function UsageLimitAccountScreen({ route }: AccountScreenProps) {
347347
const insets = useSafeAreaInsets();
348-
const presentations = useAtomValue(environmentPresentations.presentationsAtom);
348+
const presentations = useAtomValue(environmentPresentations.presentationsWithProvidersAtom);
349349
const { accountKey, windowId, windowKind, environmentIds, now } = route.params;
350350
const selectedIds =
351351
environmentIds === null ? null : new Set(environmentIds.map((id) => EnvironmentId.make(id)));

‎apps/mobile/src/widgets/SubscriptionUsageCoordinator.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { buildSubscriptionUsageSnapshot } from "./subscriptionUsageSnapshot";
1212
// Isolate quota changes from the much busier thread/config presentation stream.
1313
const snapshotAtom = Atom.make((get) =>
1414
buildSubscriptionUsageSnapshot(
15-
get(environmentPresentations.presentationsAtom),
15+
get(environmentPresentations.presentationsWithProvidersAtom),
1616
Linking.createURL("settings/usage", { queryParams: { tab: "limits" } }),
1717
Platform.OS === "android" ? Infinity : 6,
1818
),
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
2+
import { AsyncResult } from "effect/reactivity";
3+
import { act } from "react";
4+
import { createRoot, type Root } from "react-dom/client";
5+
import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
6+
7+
const mint = vi.hoisted(() => vi.fn());
8+
// Atoms derived from the server config run in the real registry over a missing config.
9+
vi.mock(import("../state/server"), async (original) => {
10+
const actual = await original();
11+
const { Atom } = await import("effect/reactivity");
12+
const noConfig = Atom.make(null);
13+
return {
14+
...actual,
15+
serverEnvironment: { ...actual.serverEnvironment, configValueAtom: (() => noConfig) as never },
16+
};
17+
});
18+
vi.mock(import("../state/use-atom-query-runner"), async (original) => ({
19+
...(await original()),
20+
useAtomQueryRunner: (() => mint) as never,
21+
}));
22+
vi.mock(import("../state/session"), async (original) => ({
23+
...(await original()),
24+
readEnvironmentScope: () => false,
25+
useEnvironmentScope: () => false,
26+
readPreparedConnection: (() => ({ httpBaseUrl: "https://host.test" })) as never,
27+
}));
28+
29+
import ChatMarkdown from "./ChatMarkdown";
30+
31+
const roots: Root[] = [];
32+
beforeEach(() => vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true));
33+
afterEach(async () => {
34+
for (const root of roots.splice(0)) await act(async () => root.unmount());
35+
document.body.replaceChildren();
36+
vi.unstubAllGlobals();
37+
});
38+
39+
it("opens host media through server authorization before the client grant loads", async () => {
40+
mint.mockResolvedValue(
41+
AsyncResult.success({ relativeUrl: "/api/assets/image.png", expiresAt: 1 }),
42+
);
43+
const onImageExpand = vi.fn();
44+
const container = document.body.appendChild(document.createElement("div"));
45+
const root = createRoot(container);
46+
roots.push(root);
47+
await act(async () =>
48+
root.render(
49+
<ChatMarkdown
50+
cwd="/repo"
51+
threadRef={{
52+
environmentId: EnvironmentId.make("media-environment"),
53+
threadId: ThreadId.make("media-thread"),
54+
}}
55+
text="[Open image](/tmp/image.png)"
56+
onImageExpand={onImageExpand}
57+
/>,
58+
),
59+
);
60+
const link = container.querySelector<HTMLAnchorElement>('a[href="/tmp/image.png"]');
61+
expect(link).not.toBeNull();
62+
await act(async () => link!.click());
63+
await vi.waitFor(() =>
64+
expect(onImageExpand).toHaveBeenCalledWith(
65+
expect.objectContaining({
66+
images: [expect.objectContaining({ src: "https://host.test/api/assets/image.png" })],
67+
}),
68+
),
69+
);
70+
});

‎apps/web/src/components/ChatMarkdown.assets.test.tsx‎

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)