Skip to content
Open
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
16 changes: 7 additions & 9 deletions apps/app/src/components/ai.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,14 @@ const renderToolPart = (
part: ChatMessagePart,
index: number,
): React.ReactNode => {
if (!part.type?.startsWith("tool-")) return null;

return <Tool key={`${part.type}-${index}`} toolPart={part as ToolPart} />;
};

export function MessageComponent({
message,
isLastMessage,
}: MessageComponentProps) {
const isAssistant = message?.role === "assistant";
const isAssistant = message.role === "assistant";

return (
<Message
Expand All @@ -64,17 +62,17 @@ export function MessageComponent({
{isAssistant ? (
<div className="group flex w-full flex-col gap-0 space-y-2">
<div className="w-full">
{message?.parts
.filter((part) => part.type?.startsWith("tool-"))
{message.parts
.filter((part) => part.type.startsWith("tool-"))
.map((part, index) => renderToolPart(part, index))}
</div>
<MessageContent
className="prose w-full min-w-0 flex-1 rounded-lg bg-transparent p-0 text-foreground"
markdown
>
{message?.parts
{message.parts
.filter((part) => part.type === "text")
.map((part) => (part.type === "text" ? part.text : ""))
.map((part) => part.text)
.join("")}
</MessageContent>

Expand Down Expand Up @@ -104,7 +102,7 @@ export function MessageComponent({
) : (
<div className="group flex w-full flex-col items-end gap-1">
<MessageContent className="max-w-[85%] rounded-3xl bg-muted px-5 py-2.5 whitespace-pre-wrap text-primary sm:max-w-[75%]">
{message?.parts
{message.parts
.map((part) => (part.type === "text" ? part.text : ""))
.join("")}
</MessageContent>
Expand Down Expand Up @@ -193,7 +191,7 @@ function ThreadChatbot() {
</div>
)}

{messages?.map((message, index) => {
{messages.map((message, index) => {
const isLastMessage = index === messages.length - 1;

return (
Expand Down
6 changes: 2 additions & 4 deletions apps/app/src/components/prompt-kit/response-stream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ function useTextStream({
if (modeRef.current === "typewriter") {
if (normalizedSpeed < 25) return 1;
return Math.max(1, Math.round((normalizedSpeed - 25) / 10));
} else if (modeRef.current === "fade") {
return 1;
}

return 1;
Expand Down Expand Up @@ -234,7 +232,7 @@ function useTextStream({

if (typeof textStream === "string") {
processStringTypewriter(textStream);
} else if (textStream) {
} else {
processAsyncIterable(textStream);
}
}, [textStream, reset, processStringTypewriter, processAsyncIterable]);
Expand Down Expand Up @@ -388,7 +386,7 @@ function ResponseStream({
}
};

const Container = as as keyof React.JSX.IntrinsicElements;
const Container = as;

return <Container className={className}>{renderContent()}</Container>;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/components/sign-in-with-google-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function SignInWithGoogleButton() {
return data;
},
onError: (error) => {
toast.error(error.message ?? "An unknown error occurred");
toast.error(error.message);
},
});

Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/components/ui/field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function FieldError({
...new Map(errors.map((error) => [error?.message, error])).values(),
];

if (uniqueErrors?.length == 1) {
if (uniqueErrors.length === 1) {
return uniqueErrors[0]?.message;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/lib/trpc/query-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function makeQueryClient() {
},
queryCache: new QueryCache({
onError: (error) => {
console.error(error.message ?? "Something went wrong");
console.error(error.message);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Removing the ?? "Something went wrong" fallback means that when an error has no message (e.g. a thrown non-Error value), the console now logs undefined instead of the earlier friendly message. Consider keeping a fallback for robustness.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/app/src/lib/trpc/query-client.ts, line 32:

<comment>Removing the `?? "Something went wrong"` fallback means that when an error has no message (e.g. a thrown non-Error value), the console now logs `undefined` instead of the earlier friendly message. Consider keeping a fallback for robustness.</comment>

<file context>
@@ -29,7 +29,7 @@ export function makeQueryClient() {
     queryCache: new QueryCache({
       onError: (error) => {
-        console.error(error.message ?? "Something went wrong");
+        console.error(error.message);
       },
     }),
</file context>

},
}),
});
Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/routes/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function Login() {
toast.success("Magic link printed to the server logs");
},
onError: (error) => {
toast.error(error.message ?? "An unknown error occurred");
toast.error(error.message);
},
});

Expand Down
4 changes: 2 additions & 2 deletions apps/web/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/types/routes.d.ts";
import "./.next/types/root-params.d.ts";
import "./.next/dev/types/routes.d.ts";
import "./.next/dev/types/root-params.d.ts";

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
5 changes: 2 additions & 3 deletions apps/web/src/app/api/[...trpc]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { createOpenApiFetchHandler } from "trpc-to-openapi";

import { appRouter, createContext } from "@repo/api";

const handler = (req: Request) => {
return createOpenApiFetchHandler({
const handler = (req: Request) =>
createOpenApiFetchHandler({
endpoint: "/api/v1",
req,
router: appRouter,
createContext: () => createContext({ headers: req.headers }),
});
};

export {
handler as GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ export function CreateQueueProvider({ children }: CreateQueueProviderProps) {
[createMutation, removeOptimisticAction],
);

const logic = React.useMemo(() => {
return createCreateQueueMachine({
createEvent,
removeOptimisticAction,
});
}, [createEvent, removeOptimisticAction]);
const logic = React.useMemo(
() =>
createCreateQueueMachine({
createEvent,
removeOptimisticAction,
}),
[createEvent, removeOptimisticAction],
);

return (
<CreateQueueContext.Provider logic={logic}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface CreateQueueItem {
}

export function hasAttendees(event: CalendarEvent) {
return !!event.attendees && event.attendees.length > 0;
return (event.attendees?.length ?? 0) > 0;
}

export type CreateEvent = (item: CreateQueueItem) => Promise<unknown>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ export function DeleteQueueProvider({ children }: DeleteQueueProviderProps) {
[deleteMutation, removeOptimisticAction],
);

const logic = React.useMemo(() => {
return createDeleteQueueMachine({
deleteEvent,
removeOptimisticAction,
});
}, [deleteEvent, removeOptimisticAction]);
const logic = React.useMemo(
() =>
createDeleteQueueMachine({
deleteEvent,
removeOptimisticAction,
}),
[deleteEvent, removeOptimisticAction],
);

return (
<DeleteQueueContext.Provider logic={logic}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export interface DeleteQueueItem {
}

export function isRecurring(event: CalendarEvent) {
return !!event.recurringEventId;
return Boolean(event.recurringEventId);
}

export function hasAttendees(event: CalendarEvent) {
return !!event.attendees && event.attendees.length > 0;
return (event.attendees?.length ?? 0) > 0;
}

export type DeleteEvent = (item: DeleteQueueItem) => Promise<unknown>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ export function EventFormStateProvider({
return item;
}, []);

const logic = React.useMemo(() => {
return createEventFormMachine({
updateEvent,
});
}, [updateEvent]);
const logic = React.useMemo(
() =>
createEventFormMachine({
updateEvent,
}),
[updateEvent],
);

return (
<EventFormStateContext.Provider logic={logic}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ export function UpdateQueueProvider({ children }: UpdateQueueProviderProps) {
[updateMutation, removeOptimisticAction],
);

const logic = React.useMemo(() => {
return createUpdateQueueMachine({
updateEvent,
removeOptimisticAction,
});
}, [updateEvent, removeOptimisticAction]);
const logic = React.useMemo(
() =>
createUpdateQueueMachine({
updateEvent,
removeOptimisticAction,
}),
[updateEvent, removeOptimisticAction],
);

return (
<UpdateQueueContext.Provider logic={logic}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ export interface UpdateQueueItem {
}

export function isRecurring(event: CalendarEvent) {
return !!event.recurringEventId;
return Boolean(event.recurringEventId);
}

export function hasAttendees(event: CalendarEvent) {
return !!event.attendees && event.attendees.length > 0;
return (event.attendees?.length ?? 0) > 0;
}

export type UpdateEvent = (item: UpdateQueueItem) => Promise<unknown>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,20 @@ function CalendarPickerContent() {
const calendarPreferences = useCalendarStore((s) => s.calendarPreferences);
const { isActionMenuOpen } = useCalendarPickerContext();

const visibleCalendars = React.useMemo(() => {
return data?.accounts
.flatMap((account) => account.calendars)
.filter((calendar) => {
const preference = getCalendarPreference(
calendarPreferences,
calendar.provider.accountId,
calendar.id,
);
return !preference?.hidden;
});
}, [data, calendarPreferences]);
const visibleCalendars = React.useMemo(
() =>
data?.accounts
.flatMap((account) => account.calendars)
.filter((calendar) => {
const preference = getCalendarPreference(
calendarPreferences,
calendar.provider.accountId,
calendar.id,
);
return !preference?.hidden;
}),
[data, calendarPreferences],
);

if (!data) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function SolarTerminatorMap({
if (terminator.length > 0) {
// Go to right edge at same latitude
dayCoords.push([180, terminator[terminator.length - 1]?.[1] || 0]);
if ((sunDeclination ?? 0) >= 0) {
if (sunDeclination >= 0) {
// Close across the northern boundary when the sun is over the northern hemisphere
dayCoords.push([180, 90]);
dayCoords.push([-180, 90]);
Expand Down Expand Up @@ -156,7 +156,7 @@ export function SolarTerminatorMap({
);
});

return lineGenerator(dayCoords) + "Z" || "";
return lineGenerator(dayCoords) + "Z";
}, [terminator, projection, sunDeclination]);

return (
Expand Down
7 changes: 4 additions & 3 deletions apps/web/src/components/calendar/timeline/header/timezone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ function TimeDisplay({ className, timeZoneId }: TimeDisplayProps) {
const use12Hour = useCalendarStore((s) => s.calendarSettings.use12Hour);
const locale = useCalendarStore((s) => s.calendarSettings.locale);

const time = React.useMemo(() => {
return currentTime.withTimeZone(timeZoneId);
}, [currentTime, timeZoneId]);
const time = React.useMemo(
() => currentTime.withTimeZone(timeZoneId),
[currentTime, timeZoneId],
);

return (
<div className={cn("flex flex-col items-end gap-0.5", className)}>
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/calendar/timeline/timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ function useHours(timeZone: string) {

const start = startOfDay(date, { timeZone: defaultTimeZone });

const hours = HOURS.map((time) => {
return start.add({ hours: time.hour }).withTimeZone(timeZone);
});
const hours = HOURS.map((time) =>
start.add({ hours: time.hour }).withTimeZone(timeZone),
);

return hours.map((hour) => ({
label: formatTime({
Expand Down
7 changes: 4 additions & 3 deletions apps/web/src/components/command-bar/window-stack-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ export function WindowStackProvider({ children }: WindowStackProviderProps) {
];
}, [selectedEvents]);

const windows = React.useMemo<StackWindowEntry[]>(() => {
return [...eventWindows, ...stack];
}, [eventWindows, stack]);
const windows = React.useMemo<StackWindowEntry[]>(
() => [...eventWindows, ...stack],
[eventWindows, stack],
);

const [activeWindowId, setActiveWindowId] = React.useState<string | null>(
() => windows[0]?.id ?? null,
Expand Down
14 changes: 8 additions & 6 deletions apps/web/src/components/date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ export function DatePicker() {

const displayedDays = useDisplayedDays();

const displayedMonth = React.useMemo(() => {
return Temporal.PlainYearMonth.from({
year: currentDate.year,
month: currentDate.month,
});
}, [currentDate.year, currentDate.month]);
const displayedMonth = React.useMemo(
() =>
Temporal.PlainYearMonth.from({
year: currentDate.year,
month: currentDate.month,
}),
[currentDate.year, currentDate.month],
);

const calendarRef = React.useRef<HTMLDivElement>(null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export const useExpandingInput = (value: string) => {
const placeCursorAtEnd = useCallback(() => {
if (!textareaRef.current) return;
textareaRef.current.focus();
textareaRef.current.selectionStart = textareaRef.current.value.length ?? 0;
textareaRef.current.selectionEnd = textareaRef.current.value.length ?? 0;
textareaRef.current.selectionStart = textareaRef.current.value.length;
textareaRef.current.selectionEnd = textareaRef.current.value.length;
}, []);

useUpdateEffect(() => {
Expand Down
Loading
Loading