The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 06:15 UTC
fix: show restore defaults only on General settings (#1710)
Utkarsh Patil committed
Apr 18, 2026 at 02:19 UTC
60387f67e99d68eba414d2c2e00c8ccdb145b0c3
1 file changed
+31
-27
apps/web/src/routes/settings.tsx
+31
-27
@@ -1,5 +1,5 @@
1
import { RotateCcwIcon } from "lucide-react";
2
-import { Outlet, createFileRoute, redirect } from "@tanstack/react-router";
2
+import { Outlet, createFileRoute, redirect, useLocation } from "@tanstack/react-router";
3
import { useEffect, useState } from "react";
4
5
import { useSettingsRestore } from "../components/settings/SettingsPanels";
@@ -7,11 +7,27 @@ import { Button } from "../components/ui/button";
7
import { SidebarInset, SidebarTrigger } from "../components/ui/sidebar";
8
import { isElectron } from "../env";
9
10
+function RestoreDefaultsButton({ onRestored }: { onRestored: () => void }) {
11
+ const { changedSettingLabels, restoreDefaults } = useSettingsRestore(onRestored);
12
+
13
+ return (
14
+ <Button
15
+ size="xs"
16
+ variant="outline"
17
+ disabled={changedSettingLabels.length === 0}
18
+ onClick={() => void restoreDefaults()}
19
+ >
20
+ <RotateCcwIcon className="size-3.5" />
21
+ Restore defaults
22
+ </Button>
23
+ );
24
+}
25
+
26
function SettingsContentLayout() {
27
+ const location = useLocation();
28
const [restoreSignal, setRestoreSignal] = useState(0);
12
- const { changedSettingLabels, restoreDefaults } = useSettingsRestore(() =>
13
- setRestoreSignal((value) => value + 1),
14
- );
29
+ const showRestoreDefaults = location.pathname === "/settings/general";
30
+ const handleRestored = () => setRestoreSignal((value) => value + 1);
31
32
useEffect(() => {
33
const onKeyDown = (event: KeyboardEvent) => {
@@ -33,20 +49,14 @@ function SettingsContentLayout() {
49
<div className="flex min-h-0 min-w-0 flex-1 flex-col bg-background text-foreground">
50
{!isElectron && (
51
<header className="border-b border-border px-3 py-2 sm:px-5">
36
- <div className="flex items-center gap-2">
52
+ <div className="flex min-h-7 items-center gap-2 sm:min-h-6">
53
<SidebarTrigger className="size-7 shrink-0 md:hidden" />
54
<span className="text-sm font-medium text-foreground">Settings</span>
39
- <div className="ms-auto flex items-center gap-2">
40
- <Button
41
- size="xs"
42
- variant="outline"
43
- disabled={changedSettingLabels.length === 0}
44
- onClick={() => void restoreDefaults()}
45
- >
46
- <RotateCcwIcon className="size-3.5" />
47
- Restore defaults
48
- </Button>
49
- </div>
55
+ {showRestoreDefaults ? (
56
+ <div className="ms-auto flex items-center gap-2">
57
+ <RestoreDefaultsButton onRestored={handleRestored} />
58
+ </div>
59
+ ) : null}
60
</div>
61
</header>
62
)}
@@ -56,17 +66,11 @@ function SettingsContentLayout() {
66
<span className="text-xs font-medium tracking-wide text-muted-foreground/70">
67
Settings
68
</span>
59
- <div className="ms-auto flex items-center gap-2">
60
- <Button
61
- size="xs"
62
- variant="outline"
63
- disabled={changedSettingLabels.length === 0}
64
- onClick={() => void restoreDefaults()}
65
- >
66
- <RotateCcwIcon className="size-3.5" />
67
- Restore defaults
68
- </Button>
69
- </div>
69
+ {showRestoreDefaults ? (
70
+ <div className="ms-auto flex items-center gap-2">
71
+ <RestoreDefaultsButton onRestored={handleRestored} />
72
+ </div>
73
+ ) : null}
74
</div>
75
)}
76