Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
li-boxuan committed Jan 21, 2025
1 parent 71d146a commit 5d4b927
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
15 changes: 8 additions & 7 deletions frontend/src/components/features/chat/chat-interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useDispatch, useSelector } from "react-redux";
import toast from "react-hot-toast";
import React from "react";
import posthog from "posthog-js";
import { useParams } from "react-router";
import { convertImageToBase64 } from "#/utils/convert-image-to-base-64";
import { FeedbackActions } from "../feedback/feedback-actions";
import { ExportActions } from "../export/export-actions";
Expand All @@ -22,7 +23,6 @@ import { ContinueButton } from "#/components/shared/buttons/continue-button";
import { ScrollToBottomButton } from "#/components/shared/buttons/scroll-to-bottom-button";
import { LoadingSpinner } from "#/components/shared/loading-spinner";
import { useGetTrajectory } from "#/hooks/mutation/use-get-trajectory";
import { useParams } from "react-router";
import { downloadTrajectory } from "#/utils/download-files";

function getEntryPoint(
Expand Down Expand Up @@ -105,11 +105,14 @@ export function ChatInterface() {

getTrajectory(params.conversationId, {
onSuccess: async (data) => {
await downloadTrajectory(params.conversationId ?? 'unknown', data.trajectory);
await downloadTrajectory(
params.conversationId ?? "unknown",
data.trajectory,
);
},
onError: (error) => {
toast.error(error.message);
}
},
});
};

Expand Down Expand Up @@ -161,10 +164,8 @@ export function ChatInterface() {
}
/>
<ExportActions
onExportTrajectory={() =>
onClickExportTrajectoryButton()
}>
</ExportActions>
onExportTrajectory={() => onClickExportTrajectoryButton()}
/>

<div className="absolute left-1/2 transform -translate-x-1/2 bottom-0">
{messages.length > 2 &&
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/components/features/export/export-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ interface ExportActionsProps {
onExportTrajectory: () => void;
}

export function ExportActions({
onExportTrajectory,
}: ExportActionsProps) {
export function ExportActions({ onExportTrajectory }: ExportActionsProps) {
return (
<div data-testid="export-actions" className="flex gap-1">
<ExportActionButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ interface ExportActionButtonProps {
icon: React.ReactNode;
}

export function ExportActionButton({
onClick,
icon,
}: ExportActionButtonProps) {
export function ExportActionButton({ onClick, icon }: ExportActionButtonProps) {
return (
<button
type="button"
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/types/file-system.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ interface SaveFilePickerOptions {

interface Window {
showDirectoryPicker(): Promise<FileSystemDirectoryHandle>;
showSaveFilePicker(options?: SaveFilePickerOptions): Promise<FileSystemFileHandle>;
showSaveFilePicker(
options?: SaveFilePickerOptions,
): Promise<FileSystemFileHandle>;
}
19 changes: 12 additions & 7 deletions frontend/src/utils/download-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function isFileSystemAccessSupported(): boolean {
* Checks if the Save File Picker API is supported
*/
function isSaveFilePickerSupported(): boolean {
return 'showSaveFilePicker' in window;
return "showSaveFilePicker" in window;
}

/**
Expand Down Expand Up @@ -169,7 +169,10 @@ async function processBatch(
};
}

export async function downloadTrajectory(conversationId: string, data: unknown[] | null): Promise<void> {
export async function downloadTrajectory(
conversationId: string,
data: unknown[] | null,
): Promise<void> {
try {
if (!isSaveFilePickerSupported()) {
throw new Error(
Expand All @@ -178,12 +181,14 @@ export async function downloadTrajectory(conversationId: string, data: unknown[]
}
const options = {
suggestedName: `trajectory-${conversationId}.json`,
types: [{
description: 'JSON File',
accept: {
'application/json': ['.json'],
types: [
{
description: "JSON File",
accept: {
"application/json": [".json"],
},
},
}],
],
};

const handle = await window.showSaveFilePicker(options);
Expand Down

0 comments on commit 5d4b927

Please sign in to comment.