lint using oxlint (#106)

This commit is contained in:
Will Chen
2025-05-08 17:21:35 -07:00
committed by GitHub
parent 0e8cc26fb5
commit 2537fbb342
63 changed files with 251 additions and 292 deletions

View File

@@ -99,8 +99,8 @@ console.log("TodoItem");
expect(result).toEqual([
{
path: "src/components/TodoItem.tsx",
content: `import React from \"react\";
console.log(\"TodoItem\");`,
content: `import React from "react";
console.log("TodoItem");`,
},
]);
});
@@ -117,8 +117,8 @@ console.log("TodoItem");
expect(result).toEqual([
{
path: "src/components/TodoItem.tsx",
content: `import React from \"react\";
console.log(\"TodoItem\");`,
content: `import React from "react";
console.log("TodoItem");`,
},
]);
});

View File

@@ -1,4 +1,4 @@
import { atom } from "jotai";
import type { CodeProposal, ProposalResult } from "@/lib/schemas";
import type { ProposalResult } from "@/lib/schemas";
export const proposalResultAtom = atom<ProposalResult | null>(null);

View File

@@ -1,6 +1,6 @@
import { useEffect } from "react";
import { useNavigate, useRouterState } from "@tanstack/react-router";
import type { ChatSummary } from "@/lib/schemas";
import { formatDistanceToNow } from "date-fns";
import { PlusCircle, MoreVertical, Trash2 } from "lucide-react";
import { useAtom } from "jotai";
@@ -29,7 +29,7 @@ export function ChatList({ show }: { show?: boolean }) {
const navigate = useNavigate();
const [selectedChatId, setSelectedChatId] = useAtom(selectedChatIdAtom);
const [selectedAppId, setSelectedAppId] = useAtom(selectedAppIdAtom);
const [isDropdownOpen, setIsDropdownOpen] = useAtom(dropdownOpenAtom);
const [, setIsDropdownOpen] = useAtom(dropdownOpenAtom);
const { chats, loading, refreshChats } = useChats(selectedAppId);
const routerState = useRouterState();
const isChatRoute = routerState.location.pathname === "/chat";

View File

@@ -2,7 +2,7 @@ import { useState, useRef, useEffect, useCallback } from "react";
import { useAtom, useAtomValue } from "jotai";
import { chatMessagesAtom, chatStreamCountAtom } from "../atoms/chatAtoms";
import { IpcClient } from "@/ipc/ipc_client";
import { selectedAppIdAtom } from "@/atoms/appAtoms";
import { ChatHeader } from "./chat/ChatHeader";
import { MessagesList } from "./chat/MessagesList";
import { ChatInput } from "./chat/ChatInput";
@@ -20,14 +20,11 @@ export function ChatPanel({
isPreviewOpen,
onTogglePreview,
}: ChatPanelProps) {
const appId = useAtomValue(selectedAppIdAtom);
const [messages, setMessages] = useAtom(chatMessagesAtom);
const [appName, setAppName] = useState<string>("Chat");
const [isVersionPaneOpen, setIsVersionPaneOpen] = useState(false);
const [error, setError] = useState<string | null>(null);
const streamCount = useAtomValue(chatStreamCountAtom);
// Reference to store the processed prompt so we don't submit it twice
const processedPromptRef = useRef<string | null>(null);
const messagesEndRef = useRef<HTMLDivElement | null>(null);
const messagesContainerRef = useRef<HTMLDivElement | null>(null);
@@ -83,23 +80,6 @@ export function ChatPanel({
};
}, []);
useEffect(() => {
const fetchAppName = async () => {
if (!appId) return;
try {
const app = await IpcClient.getInstance().getApp(appId);
if (app?.name) {
setAppName(app.name);
}
} catch (error) {
console.error("Failed to fetch app name:", error);
}
};
fetchAppName();
}, [appId]);
const fetchChatMessages = useCallback(async () => {
if (!chatId) {
setMessages([]);

View File

@@ -1,10 +1,4 @@
import React, {
Component,
ErrorInfo,
ReactNode,
useState,
useEffect,
} from "react";
import React, { useState, useEffect } from "react";
import { Button } from "@/components/ui/button";
import { LightbulbIcon } from "lucide-react";
import { ErrorComponentProps } from "@tanstack/react-router";

View File

@@ -292,7 +292,7 @@ Session ID: ${sessionId}
<div className="border rounded-md p-3">
<h3 className="font-medium mb-2">Chat Messages</h3>
<div className="text-sm bg-slate-50 dark:bg-slate-900 rounded p-2 max-h-40 overflow-y-auto">
{chatLogsData.chat.messages.map((msg, index) => (
{chatLogsData.chat.messages.map((msg) => (
<div key={msg.id} className="mb-2">
<span className="font-semibold">
{msg.role === "user" ? "You" : "Assistant"}:{" "}

View File

@@ -10,13 +10,8 @@ import { providerSettingsRoute } from "@/routes/settings/providers/$provider";
import type { ModelProvider } from "@/lib/schemas";
import { useSettings } from "@/hooks/useSettings";
import { GiftIcon } from "lucide-react";
interface ProviderSettingsProps {
configuredProviders?: ModelProvider[];
}
export function ProviderSettingsGrid({
configuredProviders = [],
}: ProviderSettingsProps) {
export function ProviderSettingsGrid() {
const navigate = useNavigate();
const handleProviderClick = (provider: ModelProvider) => {
@@ -33,10 +28,6 @@ export function ProviderSettingsGrid({
<h2 className="text-2xl font-bold mb-6">AI Providers</h2>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
{Object.entries(PROVIDERS).map(([key, provider]) => {
const isConfigured = configuredProviders.includes(
key as ModelProvider,
);
return (
<Card
key={key}

View File

@@ -1,8 +1,8 @@
import { useState, useEffect } from "react";
import { useEffect } from "react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { SupabaseSchema } from "@/lib/schemas";
import { IpcClient } from "@/ipc/ipc_client";
import { toast } from "sonner";
import { useSettings } from "@/hooks/useSettings";
@@ -24,7 +24,7 @@ import {
import { Skeleton } from "@/components/ui/skeleton";
import { useLoadApp } from "@/hooks/useLoadApp";
import { useDeepLink } from "@/contexts/DeepLinkContext";
const OAUTH_CLIENT_ID = "bf747de7-60bb-48a2-9015-6494e0b04983";
// @ts-ignore
import supabaseLogoLight from "../../assets/supabase/supabase-logo-wordmark--light.svg";
// @ts-ignore
@@ -74,7 +74,7 @@ export function SupabaseConnector({ appId }: { appId: number }) {
toast.success("Project connected to app successfully");
await refreshApp();
} catch (error) {
toast.error("Failed to connect project to app");
toast.error("Failed to connect project to app: " + error);
}
};

View File

@@ -1,5 +1,5 @@
import { IpcClient } from "@/ipc/ipc_client";
import React, { useState } from "react";
import React from "react";
import { Button } from "./ui/button";
import { atom, useAtom } from "jotai";
import { useSettings } from "@/hooks/useSettings";

View File

@@ -1,7 +1,6 @@
import { useSettings } from "@/hooks/useSettings";
import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch";
import { showInfo } from "@/lib/toast";
export function TelemetrySwitch() {
const { settings, updateSettings } = useSettings();

View File

@@ -1,5 +1,4 @@
import { FileText, X } from "lucide-react";
import { useEffect } from "react";
interface AttachmentsListProps {
attachments: File[];

View File

@@ -3,11 +3,10 @@ import {
History,
PlusCircle,
GitBranch,
AlertCircle,
Info,
} from "lucide-react";
import { PanelRightClose } from "lucide-react";
import { useAtom, useAtomValue, useSetAtom } from "jotai";
import { useAtom, useAtomValue } from "jotai";
import { selectedAppIdAtom } from "@/atoms/appAtoms";
import { useVersions } from "@/hooks/useVersions";
import { Button } from "../ui/button";

View File

@@ -58,17 +58,14 @@ import { useVersions } from "@/hooks/useVersions";
import { useAttachments } from "@/hooks/useAttachments";
import { AttachmentsList } from "./AttachmentsList";
import { DragDropOverlay } from "./DragDropOverlay";
import {
showError as showErrorToast,
showUncommittedFilesWarning,
} from "@/lib/toast";
import { showUncommittedFilesWarning } from "@/lib/toast";
const showTokenBarAtom = atom(false);
export function ChatInput({ chatId }: { chatId?: number }) {
const posthog = usePostHog();
const [inputValue, setInputValue] = useAtom(chatInputValueAtom);
const textareaRef = useRef<HTMLTextAreaElement>(null);
const { settings, updateSettings, isAnyProviderSetup } = useSettings();
const { settings, updateSettings } = useSettings();
const appId = useAtomValue(selectedAppIdAtom);
const { refreshVersions } = useVersions(appId);
const { streamMessage, isStreaming, setIsStreaming, error, setError } =
@@ -76,7 +73,7 @@ export function ChatInput({ chatId }: { chatId?: number }) {
const [showError, setShowError] = useState(true);
const [isApproving, setIsApproving] = useState(false); // State for approving
const [isRejecting, setIsRejecting] = useState(false); // State for rejecting
const [messages, setMessages] = useAtom<Message[]>(chatMessagesAtom);
const [, setMessages] = useAtom<Message[]>(chatMessagesAtom);
const setIsPreviewOpen = useSetAtom(isPreviewOpenAtom);
const [showTokenBar, setShowTokenBar] = useAtom(showTokenBarAtom);
@@ -101,7 +98,7 @@ export function ChatInput({ chatId }: { chatId?: number }) {
error: proposalError,
refreshProposal,
} = useProposal(chatId);
const { proposal, chatId: proposalChatId, messageId } = proposalResult ?? {};
const { proposal, messageId } = proposalResult ?? {};
const adjustHeight = () => {
const textarea = textareaRef.current;
@@ -620,7 +617,6 @@ function ChatInputActions({
isApproving,
isRejecting,
}: ChatInputActionsProps) {
const [autoApprove, setAutoApprove] = useState(false);
const [isDetailsVisible, setIsDetailsVisible] = useState(false);
if (proposal.type === "tip-proposal") {

View File

@@ -1,4 +1,3 @@
import { memo } from "react";
import type { Message } from "@/ipc/ipc_types";
import {
DyadMarkdownParser,

View File

@@ -1,19 +1,10 @@
import type React from "react";
import type { ReactNode } from "react";
import { useState } from "react";
import { Button } from "../ui/button";
import { IpcClient } from "../../ipc/ipc_client";
import { useAtom, useAtomValue } from "jotai";
import { chatMessagesAtom, selectedChatIdAtom } from "../../atoms/chatAtoms";
import { useStreamChat } from "@/hooks/useStreamChat";
import {
Package,
ChevronsUpDown,
ChevronsDownUp,
Loader,
ExternalLink,
Download,
} from "lucide-react";
import { Package, ChevronsUpDown, ChevronsDownUp } from "lucide-react";
import { CodeHighlight } from "./CodeHighlight";
interface DyadAddDependencyProps {
@@ -28,15 +19,14 @@ export const DyadAddDependency: React.FC<DyadAddDependencyProps> = ({
}) => {
// Extract package attribute from the node if available
const packages = node?.properties?.packages?.split(" ") || "";
const [isInstalling, setIsInstalling] = useState(false);
const [isContentVisible, setIsContentVisible] = useState(false);
const hasChildren = !!children;
return (
<div
className={`bg-(--background-lightest) dark:bg-gray-900 hover:bg-(--background-lighter) rounded-lg px-4 py-3 border my-2 ${
className={`bg-(--background-lightest) dark:bg-gray-900 hover:bg-(--background-lighter) rounded-lg px-4 py-3 border my-2 border-border ${
hasChildren ? "cursor-pointer" : ""
} ${isInstalling ? "border-amber-500" : "border-border"}`}
}`}
onClick={
hasChildren ? () => setIsContentVisible(!isContentVisible) : undefined
}
@@ -66,12 +56,6 @@ export const DyadAddDependency: React.FC<DyadAddDependencyProps> = ({
</div>
</div>
)}
{isInstalling && (
<div className="flex items-center text-amber-600 text-xs ml-2">
<Loader size={14} className="mr-1 animate-spin" />
<span>Installing...</span>
</div>
)}
</div>
{hasChildren && (
<div className="flex items-center">

View File

@@ -30,7 +30,13 @@ type ContentPiece =
| { type: "markdown"; content: string }
| { type: "custom-tag"; tagInfo: CustomTagInfo };
const customLink = ({ node, ...props }: { node?: any; [key: string]: any }) => (
const customLink = ({
node: _node,
...props
}: {
node?: any;
[key: string]: any;
}) => (
<a
{...props}
onClick={(e) => {
@@ -358,11 +364,3 @@ function renderCustomTag(
return null;
}
}
/**
* Extract attribute values from className string
*/
function extractAttribute(className: string, attrName: string): string {
const match = new RegExp(`${attrName}="([^"]*)"`, "g").exec(className);
return match ? match[1] : "";
}

View File

@@ -6,8 +6,8 @@ import {
XCircle,
Sparkles,
} from "lucide-react";
import { useAtom, useSetAtom } from "jotai";
import { chatInputValueAtom, selectedChatIdAtom } from "@/atoms/chatAtoms";
import { useAtomValue } from "jotai";
import { selectedChatIdAtom } from "@/atoms/chatAtoms";
import { useStreamChat } from "@/hooks/useStreamChat";
interface DyadOutputProps {
type: "error" | "warning";
@@ -21,7 +21,7 @@ export const DyadOutput: React.FC<DyadOutputProps> = ({
children,
}) => {
const [isContentVisible, setIsContentVisible] = useState(false);
const [selectedChatId, setSelectedChatId] = useAtom(selectedChatIdAtom);
const selectedChatId = useAtomValue(selectedChatIdAtom);
const { streamMessage } = useStreamChat();
// If the type is not warning, it is an error (in case LLM gives a weird "type")

View File

@@ -1,6 +1,6 @@
import { SendIcon, StopCircleIcon, X, Paperclip, Loader2 } from "lucide-react";
import { SendIcon, StopCircleIcon, Paperclip } from "lucide-react";
import type React from "react";
import { useEffect, useRef, useState } from "react";
import { useEffect, useRef } from "react";
import { ModelPicker } from "@/components/ModelPicker";
import { useSettings } from "@/hooks/useSettings";
import { homeChatInputValueAtom } from "@/atoms/chatAtoms"; // Use a different atom for home input
@@ -21,7 +21,7 @@ export function HomeChatInput({
const [inputValue, setInputValue] = useAtom(homeChatInputValueAtom);
const textareaRef = useRef<HTMLTextAreaElement>(null);
const { settings, updateSettings, isAnyProviderSetup } = useSettings();
const { streamMessage, isStreaming, setIsStreaming } = useStreamChat({
const { isStreaming } = useStreamChat({
hasChatId: false,
}); // eslint-disable-line @typescript-eslint/no-unused-vars

View File

@@ -6,12 +6,12 @@ import { SetupBanner } from "../SetupBanner";
import { useSettings } from "@/hooks/useSettings";
import { useStreamChat } from "@/hooks/useStreamChat";
import { selectedChatIdAtom } from "@/atoms/chatAtoms";
import { useAtom, useAtomValue, useSetAtom } from "jotai";
import { useAtomValue, useSetAtom } from "jotai";
import { Loader2, RefreshCw, Undo } from "lucide-react";
import { Button } from "@/components/ui/button";
import { useVersions } from "@/hooks/useVersions";
import { selectedAppIdAtom } from "@/atoms/appAtoms";
import { showError, showSuccess, showWarning } from "@/lib/toast";
import { showError, showWarning } from "@/lib/toast";
import { IpcClient } from "@/ipc/ipc_client";
import { chatMessagesAtom } from "@/atoms/chatAtoms";
@@ -24,13 +24,13 @@ export const MessagesList = forwardRef<HTMLDivElement, MessagesListProps>(
function MessagesList({ messages, messagesEndRef }, ref) {
const appId = useAtomValue(selectedAppIdAtom);
const { versions, revertVersion } = useVersions(appId);
const { streamMessage, isStreaming, error, setError } = useStreamChat();
const { streamMessage, isStreaming } = useStreamChat();
const { isAnyProviderSetup } = useSettings();
const setMessages = useSetAtom(chatMessagesAtom);
const [isUndoLoading, setIsUndoLoading] = useState(false);
const [isRetryLoading, setIsRetryLoading] = useState(false);
const [selectedChatId, setSelectedChatId] = useAtom(selectedChatIdAtom);
const selectedChatId = useAtomValue(selectedChatIdAtom);
return (
<div className="flex-1 overflow-y-auto p-4" ref={ref}>

View File

@@ -1,4 +1,3 @@
import { useState } from "react";
import { FileEditor } from "./FileEditor";
import { FileTree } from "./FileTree";
import { RefreshCw } from "lucide-react";

View File

@@ -90,7 +90,7 @@ export const FileEditor = ({ appId, filePath }: FileEditorProps) => {
const editorTheme = isDarkMode ? "dyad-dark" : "dyad-light";
// Handle editor mount
const handleEditorDidMount: OnMount = (editor, monaco) => {
const handleEditorDidMount: OnMount = (editor) => {
editorRef.current = editor;
// Listen for model content change events

View File

@@ -20,7 +20,7 @@ import {
} from "lucide-react";
import { selectedChatIdAtom } from "@/atoms/chatAtoms";
import { IpcClient } from "@/ipc/ipc_client";
import { useLoadApp } from "@/hooks/useLoadApp";
import { useLoadAppFile } from "@/hooks/useLoadAppFile";
import {
DropdownMenu,
@@ -28,8 +28,6 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { useSettings } from "@/hooks/useSettings";
import { useRunApp } from "@/hooks/useRunApp";
import { useStreamChat } from "@/hooks/useStreamChat";
interface ErrorBannerProps {
@@ -113,7 +111,7 @@ export const PreviewIframe = ({ loading }: { loading: boolean }) => {
// State to trigger iframe reload
const [reloadKey, setReloadKey] = useState(0);
const [errorMessage, setErrorMessage] = useAtom(previewErrorMessageAtom);
const [selectedChatId, setSelectedChatId] = useAtom(selectedChatIdAtom);
const selectedChatId = useAtomValue(selectedChatIdAtom);
const { streamMessage } = useStreamChat();
const [availableRoutes, setAvailableRoutes] = useState<
Array<{ path: string; label: string }>
@@ -168,7 +166,6 @@ export const PreviewIframe = ({ loading }: { loading: boolean }) => {
const [navigationHistory, setNavigationHistory] = useState<string[]>([]);
const [currentHistoryPosition, setCurrentHistoryPosition] = useState(0);
const iframeRef = useRef<HTMLIFrameElement>(null);
const { settings } = useSettings();
// Add message listener for iframe errors and navigation events
useEffect(() => {

View File

@@ -5,7 +5,7 @@ import {
previewPanelKeyAtom,
selectedAppIdAtom,
} from "../../atoms/appAtoms";
import { useLoadApp } from "@/hooks/useLoadApp";
import { CodeView } from "./CodeView";
import { PreviewIframe } from "./PreviewIframe";
import {
@@ -14,11 +14,8 @@ import {
ChevronDown,
ChevronUp,
Logs,
RefreshCw,
MoreVertical,
Trash2,
Cog,
CirclePower,
Power,
} from "lucide-react";
import { motion } from "framer-motion";

View File

@@ -104,7 +104,7 @@ export function ProviderSettingsPage({ provider }: ProviderSettingsPageProps) {
providerSettings: {
...settings?.providerSettings,
[provider]: {
...(settings?.providerSettings?.[provider] || {}),
...settings?.providerSettings?.[provider],
apiKey: {
value: apiKeyInput,
},
@@ -134,7 +134,7 @@ export function ProviderSettingsPage({ provider }: ProviderSettingsPageProps) {
providerSettings: {
...settings?.providerSettings,
[provider]: {
...(settings?.providerSettings?.[provider] || {}),
...settings?.providerSettings?.[provider],
apiKey: undefined,
},
},

View File

@@ -1,7 +1,7 @@
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { type VariantProps, cva } from "class-variance-authority";
import { Menu, PanelLeftIcon } from "lucide-react";
import { Menu } from "lucide-react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -224,7 +224,6 @@ function Sidebar({
}
function SidebarTrigger({
className,
onClick,
...props
}: React.ComponentProps<typeof Button>) {

View File

@@ -9,7 +9,7 @@ export function useAppVersion() {
try {
const version = await IpcClient.getInstance().getAppVersion();
setAppVersion(version);
} catch (error) {
} catch {
setAppVersion(null);
}
};

View File

@@ -1,7 +1,7 @@
import { useState, useEffect } from "react";
import { IpcClient } from "@/ipc/ipc_client";
import type { App } from "@/ipc/ipc_types";
import { atom, useAtom } from "jotai";
import { useAtom } from "jotai";
import { currentAppAtom } from "@/atoms/appAtoms";
export function useLoadApp(appId: number | null) {

View File

@@ -5,7 +5,7 @@ import { IpcClient } from "@/ipc/ipc_client";
export function useLoadApps() {
const [apps, setApps] = useAtom(appsListAtom);
const [appBasePath, setAppBasePath] = useAtom(appBasePathAtom);
const [, setAppBasePath] = useAtom(appBasePathAtom);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<Error | null>(null);

View File

@@ -1,6 +1,6 @@
import { useState, useEffect, useCallback } from "react";
import { IpcClient } from "@/ipc/ipc_client";
import type { CodeProposal, ProposalResult } from "@/lib/schemas"; // Import Proposal type
import type { ProposalResult } from "@/lib/schemas"; // Import Proposal type
import { proposalResultAtom } from "@/atoms/proposalAtoms";
import { useAtom } from "jotai";
export function useProposal(chatId?: number | undefined) {

View File

@@ -9,7 +9,6 @@ import {
selectedAppIdAtom,
} from "@/atoms/appAtoms";
import { useAtom, useAtomValue, useSetAtom } from "jotai";
import { App } from "@/ipc/ipc_types";
export function useRunApp() {
const [loading, setLoading] = useState(false);

View File

@@ -1,5 +1,5 @@
import { useState, useEffect, useCallback } from "react";
import { atom, useAtom } from "jotai";
import { useAtom } from "jotai";
import { userSettingsAtom, envVarsAtom } from "@/atoms/appAtoms";
import { IpcClient } from "@/ipc/ipc_client";
import { cloudProviders, type UserSettings } from "@/lib/schemas";
@@ -11,9 +11,6 @@ const PROVIDER_TO_ENV_VAR: Record<string, string> = {
google: "GEMINI_API_KEY",
};
// Define a type for the environment variables we expect
type EnvVars = Record<string, string | undefined>;
const TELEMETRY_CONSENT_KEY = "dyadTelemetryConsent";
const TELEMETRY_USER_ID_KEY = "dyadTelemetryUserId";

View File

@@ -1,4 +1,4 @@
import { useCallback, useState } from "react";
import { useCallback } from "react";
import type { Message } from "@/ipc/ipc_types";
import { useAtom, useSetAtom } from "jotai";
import {
@@ -14,7 +14,7 @@ import { useChats } from "./useChats";
import { useLoadApp } from "./useLoadApp";
import { selectedAppIdAtom } from "@/atoms/appAtoms";
import { useVersions } from "./useVersions";
import { showError, showUncommittedFilesWarning } from "@/lib/toast";
import { showUncommittedFilesWarning } from "@/lib/toast";
import { useProposal } from "./useProposal";
import { useSearch } from "@tanstack/react-router";
import { useRunApp } from "./useRunApp";
@@ -27,7 +27,7 @@ export function getRandomNumberId() {
export function useStreamChat({
hasChatId = true,
}: { hasChatId?: boolean } = {}) {
const [messages, setMessages] = useAtom(chatMessagesAtom);
const [, setMessages] = useAtom(chatMessagesAtom);
const [isStreaming, setIsStreaming] = useAtom(isStreamingAtom);
const [error, setError] = useAtom(chatErrorAtom);
const setIsPreviewOpen = useSetAtom(isPreviewOpenAtom);

View File

@@ -10,7 +10,7 @@ export function useVersions(appId: number | null) {
const [loading, setLoading] = useState(true);
const [error, setError] = useState<Error | null>(null);
const selectedChatId = useAtomValue(selectedChatIdAtom);
const [messages, setMessages] = useAtom(chatMessagesAtom);
const [, setMessages] = useAtom(chatMessagesAtom);
useEffect(() => {
const loadVersions = async () => {
// If no app is selected, clear versions and return

View File

@@ -1,20 +1,15 @@
import { ipcMain } from "electron";
import { db, getDatabasePath } from "../../db";
import { apps, chats, messages } from "../../db/schema";
import { desc, eq, and, gte, sql, gt } from "drizzle-orm";
import type {
App,
CreateAppParams,
SandboxConfig,
Version,
} from "../ipc_types";
import { apps, chats } from "../../db/schema";
import { desc, eq } from "drizzle-orm";
import type { App, CreateAppParams } from "../ipc_types";
import fs from "node:fs";
import path from "node:path";
import { getDyadAppPath, getUserDataPath } from "../../paths/paths";
import { spawn } from "node:child_process";
import git from "isomorphic-git";
import { promises as fsPromises } from "node:fs";
import { extractCodebase } from "../../utils/codebase";
// Import our utility modules
import { withLock } from "../utils/lock_utils";
import {
@@ -26,19 +21,17 @@ import {
processCounter,
killProcess,
removeAppIfCurrentProcess,
RunningAppInfo,
} from "../utils/process_manager";
import { ALLOWED_ENV_VARS } from "../../constants/models";
import { getEnvVar } from "../utils/read_env";
import { readSettings } from "../../main/settings";
import { Worker } from "worker_threads";
import fixPath from "fix-path";
import { getGitAuthor } from "../utils/git_author";
import killPort from "kill-port";
import util from "util";
import log from "electron-log";
import { getSupabaseProjectName } from "../../supabase_admin/supabase_management_client";
import { settings } from "happy-dom/lib/PropertySymbol.js";
const logger = log.scope("app_handlers");
@@ -138,7 +131,7 @@ async function executeAppLocalNode({
async function killProcessOnPort(port: number): Promise<void> {
try {
await killPort(port, "tcp");
} catch (err) {
} catch {
// Ignore if nothing was running on that port
}
}

View File

@@ -5,7 +5,7 @@ import { desc, eq } from "drizzle-orm";
import type { ChatSummary } from "../../lib/schemas";
import * as git from "isomorphic-git";
import * as fs from "fs";
import * as path from "path";
import log from "electron-log";
import { getDyadAppPath } from "../../paths/paths";

View File

@@ -26,7 +26,7 @@ import * as fs from "fs";
import * as path from "path";
import * as os from "os";
import * as crypto from "crypto";
import { stat, readFile, writeFile, mkdir, unlink } from "fs/promises";
import { readFile, writeFile, unlink } from "fs/promises";
const logger = log.scope("chat_stream_handlers");
@@ -61,19 +61,6 @@ if (!fs.existsSync(TEMP_DIR)) {
fs.mkdirSync(TEMP_DIR, { recursive: true });
}
// First, define the proper content types to match ai SDK
type TextContent = {
type: "text";
text: string;
};
type ImageContent = {
type: "image";
image: Buffer;
};
type MessageContent = TextContent | ImageContent;
export function registerChatStreamHandlers() {
ipcMain.handle("chat:stream", async (event, req: ChatStreamParams) => {
try {

View File

@@ -1,8 +1,8 @@
import { ipcMain, app } from "electron";
import { ipcMain } from "electron";
import { platform, arch } from "os";
import { SystemDebugInfo, ChatLogsData } from "../ipc_types";
import { readSettings } from "../../main/settings";
import { execSync } from "child_process";
import log from "electron-log";
import path from "path";
import fs from "fs";

View File

@@ -1,15 +1,10 @@
import {
ipcMain,
IpcMainEvent,
BrowserWindow,
IpcMainInvokeEvent,
} from "electron";
import { ipcMain, BrowserWindow, IpcMainInvokeEvent } from "electron";
import fetch from "node-fetch"; // Use node-fetch for making HTTP requests in main process
import { writeSettings, readSettings } from "../../main/settings";
import { updateAppGithubRepo } from "../../db/index";
import git from "isomorphic-git";
import http from "isomorphic-git/http/node";
import path from "node:path";
import fs from "node:fs";
import { getDyadAppPath } from "../../paths/paths";
import { db } from "../../db";

View File

@@ -37,7 +37,7 @@ export async function fetchLMStudioModels(): Promise<LocalModelListResponse> {
logger.info(`Successfully fetched ${models.length} models from LM Studio`);
return { models, error: null };
} catch (error) {
} catch {
return { models: [], error: "Failed to fetch models from LM Studio" };
}
}

View File

@@ -1,5 +1,5 @@
import { ipcMain, app } from "electron";
import { exec, execSync } from "child_process";
import { ipcMain } from "electron";
import { execSync } from "child_process";
import { platform, arch } from "os";
import { NodeSystemInfo } from "../ipc_types";
import fixPath from "fix-path";

View File

@@ -1,14 +1,12 @@
import { ipcMain, type IpcMainInvokeEvent } from "electron";
import type {
CodeProposal,
FileChange,
ProposalResult,
SqlQuery,
ActionProposal,
} from "../../lib/schemas";
import { db } from "../../db";
import { messages, chats } from "../../db/schema";
import { desc, eq, and, Update } from "drizzle-orm";
import { desc, eq, and } from "drizzle-orm";
import path from "node:path"; // Import path for basename
// Import tag parsers
import {
@@ -31,26 +29,9 @@ import {
import { extractCodebase } from "../../utils/codebase";
import { getDyadAppPath } from "../../paths/paths";
import { withLock } from "../utils/lock_utils";
const logger = log.scope("proposal_handlers");
// Placeholder Proposal data (can be removed or kept for reference)
// const placeholderProposal: Proposal = { ... };
// Type guard for the parsed proposal structure
interface ParsedProposal {
title: string;
files: string[];
}
function isParsedProposal(obj: any): obj is ParsedProposal {
return (
obj &&
typeof obj === "object" &&
typeof obj.title === "string" &&
Array.isArray(obj.files) &&
obj.files.every((file: any) => typeof file === "string")
);
}
// Cache for codebase token counts
interface CodebaseTokenCache {
chatId: number;

View File

@@ -5,28 +5,7 @@ import { readSettings } from "../../main/settings";
export function registerSettingsHandlers() {
ipcMain.handle("get-user-settings", async () => {
const settings = await readSettings();
// Mask API keys before sending to renderer
if (settings?.providerSettings) {
// Use optional chaining
for (const providerKey in settings.providerSettings) {
// Ensure the key is own property and providerSetting exists
if (
Object.prototype.hasOwnProperty.call(
settings.providerSettings,
providerKey,
)
) {
const providerSetting = settings.providerSettings[providerKey];
// Check if apiKey exists and is a non-empty string before masking
if (providerSetting?.apiKey?.value) {
providerSetting.apiKey = providerSetting.apiKey;
}
}
}
}
const settings = readSettings();
return settings;
});

View File

@@ -1,6 +1,6 @@
import { ipcMain } from "electron";
import { db } from "../../db";
import { chats, messages } from "../../db/schema";
import { chats } from "../../db/schema";
import { eq } from "drizzle-orm";
import { SYSTEM_PROMPT } from "../../prompts/system_prompt";
import {
@@ -11,8 +11,7 @@ import { getDyadAppPath } from "../../paths/paths";
import log from "electron-log";
import { extractCodebase } from "../../utils/codebase";
import { getSupabaseContext } from "../../supabase_admin/supabase_context";
import { readSettings } from "../../main/settings";
import { MODEL_OPTIONS } from "../../constants/models";
import { TokenCountParams } from "../ipc_types";
import { TokenCountResult } from "../ipc_types";
import { estimateTokens, getContextWindow } from "../utils/token_utils";

View File

@@ -133,12 +133,7 @@ export function registerVersionHandlers() {
});
// Process each file to revert to the state in previousVersionId
for (const [
filepath,
headStatus,
workdirStatus,
stageStatus,
] of matrix) {
for (const [filepath, headStatus, workdirStatus] of matrix) {
const fullPath = path.join(appPath, filepath);
// If file exists in HEAD (previous version)

View File

@@ -9,7 +9,6 @@ import type {
AppOutput,
Chat,
ChatResponseEnd,
ChatStreamParams,
CreateAppParams,
CreateAppResult,
ListAppsResponse,
@@ -18,13 +17,12 @@ import type {
Version,
SystemDebugInfo,
LocalModel,
LocalModelListResponse,
TokenCountParams,
TokenCountResult,
ChatLogsData,
BranchResult,
} from "./ipc_types";
import type { CodeProposal, ProposalResult } from "@/lib/schemas";
import type { ProposalResult } from "@/lib/schemas";
import { showError } from "@/lib/toast";
export interface ChatStreamCallbacks {

View File

@@ -5,7 +5,7 @@ import fs from "node:fs";
import { getDyadAppPath } from "../../paths/paths";
import path from "node:path";
import git from "isomorphic-git";
import { getGithubUser } from "../handlers/github_handlers";
import { getGitAuthor } from "../utils/git_author";
import log from "electron-log";
import { executeAddDependency } from "./executeAddDependency";
@@ -229,7 +229,7 @@ export async function processFullResponseActions(
if (dyadExecuteSqlQueries.length > 0) {
for (const query of dyadExecuteSqlQueries) {
try {
const result = await executeSupabaseSql({
await executeSupabaseSql({
supabaseProjectId: chatWithApp.app.supabaseProjectId!,
query: query.content,
});

View File

@@ -1,4 +1,4 @@
import { createOpenAI, OpenAIProvider } from "@ai-sdk/openai";
import { createOpenAI } from "@ai-sdk/openai";
import { createGoogleGenerativeAI as createGoogle } from "@ai-sdk/google";
import { createAnthropic } from "@ai-sdk/anthropic";
import { createOpenRouter } from "@openrouter/ai-sdk-provider";

View File

@@ -39,7 +39,7 @@ export async function withLock<T>(
}
// Acquire a new lock
const { release, promise } = acquireLock(lockId);
const { release } = acquireLock(lockId);
try {
const result = await fn();

View File

@@ -1,4 +1,3 @@
import type { Message } from "ai";
import { IpcClient } from "../ipc/ipc_client";
import type { ChatSummary } from "./schemas";
import type { CreateAppParams, CreateAppResult } from "../ipc/ipc_types";

View File

@@ -53,7 +53,7 @@ export const showLoading = <T>(
) => {
return toast.promise(promise, {
loading: loadingMessage,
success: (data) => successMessage || "Operation completed successfully",
success: () => successMessage || "Operation completed successfully",
error: (err) => errorMessage || `Error: ${err.message || "Unknown error"}`,
});
};

View File

@@ -129,7 +129,7 @@ const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit();
} else {
app.on("second-instance", (event, commandLine, workingDirectory) => {
app.on("second-instance", (_event, commandLine, _workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();

View File

@@ -3,15 +3,13 @@ import { useAtom, useAtomValue } from "jotai";
import { appBasePathAtom, appsListAtom } from "@/atoms/appAtoms";
import { IpcClient } from "@/ipc/ipc_client";
import { useLoadApps } from "@/hooks/useLoadApps";
import { useState, useEffect } from "react";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import {
ArrowLeft,
MoreVertical,
ArrowRight,
MessageCircle,
Pencil,
Github,
Folder,
} from "lucide-react";
import {
@@ -30,7 +28,6 @@ import {
} from "@/components/ui/dialog";
import { GitHubConnector } from "@/components/GitHubConnector";
import { SupabaseConnector } from "@/components/SupabaseConnector";
import { useSettings } from "@/hooks/useSettings";
export default function AppDetailsPage() {
const navigate = useNavigate();
@@ -50,7 +47,7 @@ export default function AppDetailsPage() {
const [newFolderName, setNewFolderName] = useState("");
const [isRenamingFolder, setIsRenamingFolder] = useState(false);
const appBasePath = useAtomValue(appBasePathAtom);
const { settings } = useSettings();
// Get the appId from search params and find the corresponding app
const appId = search.appId ? Number(search.appId) : null;
const selectedApp = appId ? appsList.find((app) => app.id === appId) : null;

View File

@@ -1,4 +1,4 @@
import { useState, useEffect } from "react";
import { useState } from "react";
import { useTheme } from "../contexts/ThemeContext";
import { ProviderSettingsGrid } from "@/components/ProviderSettings";
import ConfirmationDialog from "@/components/ConfirmationDialog";
@@ -113,7 +113,7 @@ export default function SettingsPage() {
</div>
<div className="bg-white dark:bg-gray-800 rounded-xl shadow-sm">
<ProviderSettingsGrid configuredProviders={[]} />
<ProviderSettingsGrid />
</div>
<div className="space-y-6">

View File

@@ -33,7 +33,7 @@ export function getElectron(): typeof import("electron") | undefined {
if (process.versions.electron) {
electron = require("electron");
}
} catch (e) {
} catch {
// Not in Electron environment
}
return electron;

View File

@@ -226,7 +226,7 @@ async function safeParseErrorResponseBody(
) {
return { message: body.message };
}
} catch (error) {
} catch {
return;
}
}

View File

@@ -70,7 +70,7 @@ async function isGitIgnored(
gitIgnoreMtimes.set(rootGitIgnorePath, stats.mtimeMs);
shouldClearCache = true;
}
} catch (error) {
} catch {
// Root .gitignore might not exist, which is fine
}
@@ -86,7 +86,7 @@ async function isGitIgnored(
gitIgnoreMtimes.set(gitIgnorePath, stats.mtimeMs);
shouldClearCache = true;
}
} catch (error) {
} catch {
// This directory might not have a .gitignore, which is fine
}
}
@@ -324,41 +324,3 @@ async function sortFilesByModificationTime(files: string[]): Promise<string[]> {
// Sort by modification time (oldest first)
return fileStats.sort((a, b) => a.mtime - b.mtime).map((item) => item.file);
}
/**
* Sort files by their importance for context
*/
function sortFilesByImportance(files: string[], baseDir: string): string[] {
// Define patterns for important files
const highPriorityPatterns = [
new RegExp(`(^|/)${ALWAYS_INCLUDE_FILES[0]}$`),
/tsconfig\.json$/,
/README\.md$/,
/index\.(ts|js)x?$/,
/main\.(ts|js)x?$/,
/app\.(ts|js)x?$/,
];
// Custom sorting function
return [...files].sort((a, b) => {
const relativeA = path.relative(baseDir, a);
const relativeB = path.relative(baseDir, b);
// Check if file A matches any high priority pattern
const aIsHighPriority = highPriorityPatterns.some((pattern) =>
pattern.test(relativeA),
);
// Check if file B matches any high priority pattern
const bIsHighPriority = highPriorityPatterns.some((pattern) =>
pattern.test(relativeB),
);
// Sort by priority first
if (aIsHighPriority && !bIsHighPriority) return -1;
if (!aIsHighPriority && bIsHighPriority) return 1;
// If both are same priority, sort alphabetically
return relativeA.localeCompare(relativeB);
});
}