Skip to content

Commit b313b4d

Browse files
committed
address my own pr comments
1 parent 00e999e commit b313b4d

File tree

9 files changed

+23
-18
lines changed

9 files changed

+23
-18
lines changed

apps/array/src/api/posthogClient.ts renamed to apps/array/src/renderer/api/posthogClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { buildApiFetcher } from "@api/fetcher";
2+
import { createApiClient, type Schemas } from "@api/generated";
13
import type { AgentEvent } from "@posthog/agent";
24
import { logger } from "@renderer/lib/logger";
35
import type { Task, TaskRun } from "@shared/types";
46
import type { StoredLogEntry } from "@shared/types/session-events";
5-
import { buildApiFetcher } from "./fetcher";
6-
import { createApiClient, type Schemas } from "./generated";
77

88
const log = logger.scope("posthog-client");
99

apps/array/src/renderer/components/ErrorBoundary.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Button, Card, Flex, Text } from "@radix-ui/themes";
22
import { logger } from "@renderer/lib/logger";
3-
import { toast } from "@utils/toast";
43
import type { ReactNode } from "react";
54
import { ErrorBoundary as ReactErrorBoundary } from "react-error-boundary";
65

@@ -9,7 +8,13 @@ interface Props {
98
fallback?: ReactNode;
109
}
1110

12-
function DefaultFallback({ onReset }: { onReset: () => void }) {
11+
function DefaultFallback({
12+
error,
13+
onReset,
14+
}: {
15+
error: Error;
16+
onReset: () => void;
17+
}) {
1318
return (
1419
<Flex align="center" justify="center" minHeight="100vh" p="4">
1520
<Card size="3" style={{ maxWidth: 400 }}>
@@ -18,7 +23,7 @@ function DefaultFallback({ onReset }: { onReset: () => void }) {
1823
Something went wrong
1924
</Text>
2025
<Text size="2" color="gray" align="center">
21-
An unexpected error occurred. Please try again.
26+
{error.message}
2227
</Text>
2328
<Button onClick={onReset} variant="soft">
2429
Try again
@@ -32,16 +37,17 @@ function DefaultFallback({ onReset }: { onReset: () => void }) {
3237
export function ErrorBoundary({ children, fallback }: Props) {
3338
return (
3439
<ReactErrorBoundary
35-
fallbackRender={({ resetErrorBoundary }) =>
36-
fallback ?? <DefaultFallback onReset={resetErrorBoundary} />
40+
fallbackRender={({ error, resetErrorBoundary }) =>
41+
fallback ?? (
42+
<DefaultFallback error={error} onReset={resetErrorBoundary} />
43+
)
3744
}
3845
onError={(error, info) => {
3946
logger.error("React error boundary caught error", {
4047
error: error.message,
4148
stack: error.stack,
4249
componentStack: info.componentStack,
4350
});
44-
toast.error("Something went wrong", { description: error.message });
4551
}}
4652
>
4753
{children}

apps/array/src/renderer/features/auth/stores/authStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PostHogAPIClient } from "@api/posthogClient";
1+
import { PostHogAPIClient } from "@renderer/api/posthogClient";
22
import { identifyUser, resetUser, track } from "@renderer/lib/analytics";
33
import { electronStorage } from "@renderer/lib/electronStorage";
44
import { logger } from "@renderer/lib/logger";

apps/array/src/renderer/hooks/useAuthenticatedMutation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { PostHogAPIClient } from "@api/posthogClient";
21
import { useAuthStore } from "@features/auth/stores/authStore";
2+
import type { PostHogAPIClient } from "@renderer/api/posthogClient";
33
import type {
44
UseMutationOptions,
55
UseMutationResult,

apps/array/src/renderer/hooks/useAuthenticatedQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { PostHogAPIClient } from "@api/posthogClient";
21
import { useAuthStore } from "@features/auth/stores/authStore";
2+
import type { PostHogAPIClient } from "@renderer/api/posthogClient";
33
import type {
44
QueryKey,
55
UseQueryOptions,

apps/array/src/renderer/lib/error-handling.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { formatArgsToString } from "@shared/utils/format";
22
import { toast } from "@utils/toast";
3+
import { IS_DEV } from "@/constants/environment";
34
import { logger } from "./logger";
45

5-
const isDev = import.meta.env.DEV;
66
const devErrorToastsEnabled =
7-
isDev && import.meta.env.VITE_DEV_ERROR_TOASTS !== "false";
7+
IS_DEV && import.meta.env.VITE_DEV_ERROR_TOASTS !== "false";
88

99
export function initializeRendererErrorHandling(): void {
1010
if (devErrorToastsEnabled) {

apps/array/src/renderer/lib/logger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import type { Logger, ScopedLogger } from "@shared/lib/create-logger";
22
import { createLogger } from "@shared/lib/create-logger";
33
import { toast } from "@utils/toast";
44
import log from "electron-log/renderer";
5+
import { IS_DEV } from "@/constants/environment";
56

67
log.transports.console.level = "debug";
78

8-
const isDev = import.meta.env.DEV;
99
const devErrorToastsEnabled =
10-
isDev && import.meta.env.VITE_DEV_ERROR_TOASTS !== "false";
10+
IS_DEV && import.meta.env.VITE_DEV_ERROR_TOASTS !== "false";
1111

1212
const emitToast = devErrorToastsEnabled
1313
? (title: string, description?: string) => toast.error(title, { description })

apps/array/src/renderer/sagas/task/task-creation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { PostHogAPIClient } from "@api/posthogClient";
21
import { buildPromptBlocks } from "@features/editor/utils/prompt-builder";
32
import { getSessionActions } from "@features/sessions/stores/sessionStore";
43
import { useWorkspaceStore } from "@features/workspace/stores/workspaceStore";
4+
import type { PostHogAPIClient } from "@renderer/api/posthogClient";
55
import { logger } from "@renderer/lib/logger";
66
import { useTaskDirectoryStore } from "@renderer/stores/taskDirectoryStore";
77
import { trpcVanilla } from "@renderer/trpc";

apps/array/tsconfig.node.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
},
1313
"exclude": [
1414
"src/renderer/**/*",
15-
"src/main/preload.ts",
16-
"src/api/posthogClient.ts"
15+
"src/main/preload.ts"
1716
],
1817
"extends": "./tsconfig.json",
1918
"include": ["src/main/**/*", "src/shared/**/*", "src/api/**/*"]

0 commit comments

Comments
 (0)