Files
moreminimore-vibe/src/pages/settings.tsx
SlayTheDragons cbf247a4ef feat (frontend): Text size accessibility settings (As requested in issue #1482) (#1624)
<img width="496" height="470" alt="Screenshot 2025-10-24 200100"
src="https://github.com/user-attachments/assets/e64ee081-dc08-4b54-94a6-9ed41453cfcf"
/>

This PR adds settings for text size, small, medium (default), large and
extra large.

This should help more people use Dyad more productively.

Closes #1482 
    






<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Adds adjustable workspace zoom levels (90%, 100%, 110%, 125%, 150%) to
improve readability and accessibility. Changes apply instantly and
persist per user, addressing issue #1482.

- **New Features**
  - Zoom selector in Settings → General.
  - Persists zoomLevel in user settings and schema.
  - Applies zoom via Electron webFrame for consistent app scaling.

- **Refactors**
  - Removed deprecated workspaceTextSize setting.
  - Removed root font-size from globals.css.

<sup>Written for commit 54bad25f016a83e9f414025a07e80fdbad859366.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->








<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds adjustable app zoom levels (90–150%) with a Settings selector,
persisted in user settings, and applied via Electron webFrame.
> 
> - **UI/Settings**:
> - Add `ZoomSelector` component and surface it in `Settings → General`
(`src/components/ZoomSelector.tsx`, `src/pages/settings.tsx`).
> - **Schema/Persistence**:
> - Introduce `ZoomLevelSchema` and optional `zoomLevel` in
`UserSettingsSchema` (`src/lib/schemas.ts`).
> - **Electron Integration**:
> - Expose `webFrame.setZoomFactor/getZoomFactor` in `window.electron`
(`src/preload.ts`).
> - **App Behavior**:
> - Apply zoom factor on load and when settings change with default
`100%` (`src/app/layout.tsx`).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
54bad25f016a83e9f414025a07e80fdbad859366. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Devforschool <138079274+Devforschool@users.noreply.github.com>
Co-authored-by: Will Chen <willchen90@gmail.com>
2025-11-10 15:49:25 -08:00

348 lines
12 KiB
TypeScript

import { useEffect, useState } from "react";
import { useTheme } from "../contexts/ThemeContext";
import { ProviderSettingsGrid } from "@/components/ProviderSettings";
import ConfirmationDialog from "@/components/ConfirmationDialog";
import { IpcClient } from "@/ipc/ipc_client";
import { showSuccess, showError } from "@/lib/toast";
import { AutoApproveSwitch } from "@/components/AutoApproveSwitch";
import { TelemetrySwitch } from "@/components/TelemetrySwitch";
import { MaxChatTurnsSelector } from "@/components/MaxChatTurnsSelector";
import { ThinkingBudgetSelector } from "@/components/ThinkingBudgetSelector";
import { useSettings } from "@/hooks/useSettings";
import { useAppVersion } from "@/hooks/useAppVersion";
import { Button } from "@/components/ui/button";
import { ArrowLeft } from "lucide-react";
import { useRouter } from "@tanstack/react-router";
import { GitHubIntegration } from "@/components/GitHubIntegration";
import { VercelIntegration } from "@/components/VercelIntegration";
import { SupabaseIntegration } from "@/components/SupabaseIntegration";
import { Switch } from "@/components/ui/switch";
import { Label } from "@/components/ui/label";
import { AutoFixProblemsSwitch } from "@/components/AutoFixProblemsSwitch";
import { AutoUpdateSwitch } from "@/components/AutoUpdateSwitch";
import { ReleaseChannelSelector } from "@/components/ReleaseChannelSelector";
import { NeonIntegration } from "@/components/NeonIntegration";
import { RuntimeModeSelector } from "@/components/RuntimeModeSelector";
import { NodePathSelector } from "@/components/NodePathSelector";
import { ToolsMcpSettings } from "@/components/settings/ToolsMcpSettings";
import { ZoomSelector } from "@/components/ZoomSelector";
import { useSetAtom } from "jotai";
import { activeSettingsSectionAtom } from "@/atoms/viewAtoms";
export default function SettingsPage() {
const [isResetDialogOpen, setIsResetDialogOpen] = useState(false);
const [isResetting, setIsResetting] = useState(false);
const appVersion = useAppVersion();
const { settings, updateSettings } = useSettings();
const router = useRouter();
const setActiveSettingsSection = useSetAtom(activeSettingsSectionAtom);
useEffect(() => {
setActiveSettingsSection("general-settings");
}, [setActiveSettingsSection]);
const handleResetEverything = async () => {
setIsResetting(true);
try {
const ipcClient = IpcClient.getInstance();
await ipcClient.resetAll();
showSuccess("Successfully reset everything. Restart the application.");
} catch (error) {
console.error("Error resetting:", error);
showError(
error instanceof Error ? error.message : "An unknown error occurred",
);
} finally {
setIsResetting(false);
setIsResetDialogOpen(false);
}
};
return (
<div className="min-h-screen px-8 py-4">
<div className="max-w-5xl mx-auto">
<Button
onClick={() => router.history.back()}
variant="outline"
size="sm"
className="flex items-center gap-2 mb-4 bg-(--background-lightest) py-5"
>
<ArrowLeft className="h-4 w-4" />
Go Back
</Button>
<div className="flex justify-between mb-4">
<h1 className="text-3xl font-bold text-gray-900 dark:text-white">
Settings
</h1>
</div>
<div className="space-y-6">
<GeneralSettings appVersion={appVersion} />
<WorkflowSettings />
<AISettings />
<div
id="provider-settings"
className="bg-white dark:bg-gray-800 rounded-xl shadow-sm"
>
<ProviderSettingsGrid />
</div>
<div className="space-y-6">
<div
id="telemetry"
className="bg-white dark:bg-gray-800 rounded-xl shadow-sm p-6"
>
<h2 className="text-lg font-medium text-gray-900 dark:text-white mb-4">
Telemetry
</h2>
<div className="space-y-2">
<TelemetrySwitch />
<div className="text-sm text-gray-500 dark:text-gray-400">
This records anonymous usage data to improve the product.
</div>
</div>
<div className="mt-2 flex items-center text-sm text-gray-500 dark:text-gray-400">
<span className="mr-2 font-medium">Telemetry ID:</span>
<span className="bg-gray-100 dark:bg-gray-700 px-2 py-0.5 rounded text-gray-800 dark:text-gray-200 font-mono">
{settings ? settings.telemetryUserId : "n/a"}
</span>
</div>
</div>
</div>
{/* Integrations Section */}
<div
id="integrations"
className="bg-white dark:bg-gray-800 rounded-xl shadow-sm p-6"
>
<h2 className="text-lg font-medium text-gray-900 dark:text-white mb-4">
Integrations
</h2>
<div className="space-y-4">
<GitHubIntegration />
<VercelIntegration />
<SupabaseIntegration />
<NeonIntegration />
</div>
</div>
{/* Tools (MCP) */}
<div
id="tools-mcp"
className="bg-white dark:bg-gray-800 rounded-xl shadow-sm p-6"
>
<h2 className="text-lg font-medium text-gray-900 dark:text-white mb-4">
Tools (MCP)
</h2>
<ToolsMcpSettings />
</div>
{/* Experiments Section */}
<div
id="experiments"
className="bg-white dark:bg-gray-800 rounded-xl shadow-sm p-6"
>
<h2 className="text-lg font-medium text-gray-900 dark:text-white mb-4">
Experiments
</h2>
<div className="space-y-4">
<div className="space-y-1 mt-4">
<div className="flex items-center space-x-2">
<Switch
id="enable-native-git"
checked={!!settings?.enableNativeGit}
onCheckedChange={(checked) => {
updateSettings({
enableNativeGit: checked,
});
}}
/>
<Label htmlFor="enable-native-git">Enable Native Git</Label>
</div>
<div className="text-sm text-gray-500 dark:text-gray-400">
Native Git offers faster performance but requires{" "}
<a
onClick={() => {
IpcClient.getInstance().openExternalUrl(
"https://git-scm.com/downloads",
);
}}
className="text-blue-600 hover:underline dark:text-blue-400"
>
installing Git
</a>
.
</div>
</div>
</div>
</div>
{/* Danger Zone */}
<div
id="danger-zone"
className="bg-white dark:bg-gray-800 rounded-xl shadow-sm p-6 border border-red-200 dark:border-red-800"
>
<h2 className="text-lg font-medium text-red-600 dark:text-red-400 mb-4">
Danger Zone
</h2>
<div className="space-y-4">
<div className="flex items-start justify-between flex-col sm:flex-row sm:items-center gap-4">
<div>
<h3 className="text-sm font-medium text-gray-900 dark:text-white">
Reset Everything
</h3>
<p className="text-xs text-gray-500 dark:text-gray-400 mt-1">
This will delete all your apps, chats, and settings. This
action cannot be undone.
</p>
</div>
<button
onClick={() => setIsResetDialogOpen(true)}
disabled={isResetting}
className="rounded-md border border-transparent bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed"
>
{isResetting ? "Resetting..." : "Reset Everything"}
</button>
</div>
</div>
</div>
</div>
</div>
<ConfirmationDialog
isOpen={isResetDialogOpen}
title="Reset Everything"
message="Are you sure you want to reset everything? This will delete all your apps, chats, and settings. This action cannot be undone."
confirmText="Reset Everything"
cancelText="Cancel"
onConfirm={handleResetEverything}
onCancel={() => setIsResetDialogOpen(false)}
/>
</div>
);
}
export function GeneralSettings({ appVersion }: { appVersion: string | null }) {
const { theme, setTheme } = useTheme();
return (
<div
id="general-settings"
className="bg-white dark:bg-gray-800 rounded-xl shadow-sm p-6"
>
<h2 className="text-lg font-medium text-gray-900 dark:text-white mb-4">
General Settings
</h2>
<div className="space-y-4 mb-4">
<div className="flex items-center gap-4">
<label className="text-sm font-medium text-gray-700 dark:text-gray-300">
Theme
</label>
<div className="relative bg-gray-100 dark:bg-gray-700 rounded-lg p-1 flex">
{(["system", "light", "dark"] as const).map((option) => (
<button
key={option}
onClick={() => setTheme(option)}
className={`
px-4 py-1.5 text-sm font-medium rounded-md
transition-all duration-200
${
theme === option
? "bg-white dark:bg-gray-600 text-gray-900 dark:text-white shadow-sm"
: "text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"
}
`}
>
{option.charAt(0).toUpperCase() + option.slice(1)}
</button>
))}
</div>
</div>
</div>
<div className="mt-4">
<ZoomSelector />
</div>
<div className="space-y-1 mt-4">
<AutoUpdateSwitch />
<div className="text-sm text-gray-500 dark:text-gray-400">
This will automatically update the app when new versions are
available.
</div>
</div>
<div className="mt-4">
<ReleaseChannelSelector />
</div>
<div className="mt-4">
<RuntimeModeSelector />
</div>
<div className="mt-4">
<NodePathSelector />
</div>
<div className="flex items-center text-sm text-gray-500 dark:text-gray-400 mt-4">
<span className="mr-2 font-medium">App Version:</span>
<span className="bg-gray-100 dark:bg-gray-700 px-2 py-0.5 rounded text-gray-800 dark:text-gray-200 font-mono">
{appVersion ? appVersion : "-"}
</span>
</div>
</div>
);
}
export function WorkflowSettings() {
return (
<div
id="workflow-settings"
className="bg-white dark:bg-gray-800 rounded-xl shadow-sm p-6"
>
<h2 className="text-lg font-medium text-gray-900 dark:text-white mb-4">
Workflow Settings
</h2>
<div className="space-y-1">
<AutoApproveSwitch showToast={false} />
<div className="text-sm text-gray-500 dark:text-gray-400">
This will automatically approve code changes and run them.
</div>
</div>
<div className="space-y-1 mt-4">
<AutoFixProblemsSwitch />
<div className="text-sm text-gray-500 dark:text-gray-400">
This will automatically fix TypeScript errors.
</div>
</div>
</div>
);
}
export function AISettings() {
return (
<div
id="ai-settings"
className="bg-white dark:bg-gray-800 rounded-xl shadow-sm p-6"
>
<h2 className="text-lg font-medium text-gray-900 dark:text-white mb-4">
AI Settings
</h2>
<div className="mt-4">
<ThinkingBudgetSelector />
</div>
<div className="mt-4">
<MaxChatTurnsSelector />
</div>
</div>
);
}