Skip to content

Commit 21b8dce

Browse files
committed
fix: correct Home actions and memoize shortcut groups
1 parent 02fe50f commit 21b8dce

4 files changed

Lines changed: 148 additions & 145 deletions

File tree

src/features/home/components/Home.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { describe, expect, it, vi } from "vitest";
44
import { Home } from "./Home";
55

66
const baseProps = {
7-
onOpenProject: vi.fn(),
7+
onOpenSettings: vi.fn(),
88
onAddWorkspace: vi.fn(),
99
latestAgentRuns: [],
1010
isLoadingLatestAgents: false,

src/features/home/components/Home.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import FolderOpen from "lucide-react/dist/esm/icons/folder-open";
1+
import Settings from "lucide-react/dist/esm/icons/settings";
22
import RefreshCw from "lucide-react/dist/esm/icons/refresh-cw";
33
import type { LocalUsageSnapshot } from "../../../types";
44
import { formatRelativeTime } from "../../../utils/time";
@@ -21,7 +21,7 @@ type UsageWorkspaceOption = {
2121
};
2222

2323
type HomeProps = {
24-
onOpenProject: () => void;
24+
onOpenSettings: () => void;
2525
onAddWorkspace: () => void;
2626
latestAgentRuns: LatestAgentRun[];
2727
isLoadingLatestAgents: boolean;
@@ -38,7 +38,7 @@ type HomeProps = {
3838
};
3939

4040
export function Home({
41-
onOpenProject,
41+
onOpenSettings,
4242
onAddWorkspace,
4343
latestAgentRuns,
4444
isLoadingLatestAgents,
@@ -240,23 +240,23 @@ export function Home({
240240
<div className="home-actions">
241241
<button
242242
className="home-button primary"
243-
onClick={onOpenProject}
243+
onClick={onAddWorkspace}
244244
data-tauri-drag-region="false"
245245
>
246246
<span className="home-icon" aria-hidden>
247-
<FolderOpen size={18} />
247+
+
248248
</span>
249-
Open Project
249+
Add Workspaces
250250
</button>
251251
<button
252252
className="home-button secondary"
253-
onClick={onAddWorkspace}
253+
onClick={onOpenSettings}
254254
data-tauri-drag-region="false"
255255
>
256256
<span className="home-icon" aria-hidden>
257-
+
257+
<Settings size={18} />
258258
</span>
259-
Add Workspaces
259+
Settings
260260
</button>
261261
</div>
262262
<div className="home-usage">

src/features/layout/hooks/layoutNodes/buildPrimaryNodes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ export function buildPrimaryNodes(options: LayoutNodesOptions): PrimaryLayoutNod
223223

224224
const homeNode = (
225225
<Home
226-
onOpenProject={options.onAddWorkspace}
226+
onOpenSettings={options.onOpenSettings}
227227
onAddWorkspace={options.onAddWorkspace}
228228
latestAgentRuns={options.latestAgentRuns}
229229
isLoadingLatestAgents={options.isLoadingLatestAgents}

src/features/settings/components/sections/SettingsShortcutsSection.tsx

Lines changed: 137 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -75,140 +75,143 @@ export function SettingsShortcutsSection({
7575
const isMac = isMacPlatform();
7676
const [searchQuery, setSearchQuery] = useState("");
7777

78-
const groups: ShortcutGroup[] = [
79-
{
80-
title: "File",
81-
subtitle: "Create agents and worktrees from the keyboard.",
82-
items: [
83-
{
84-
label: "New Agent",
85-
draftKey: "newAgent",
86-
settingKey: "newAgentShortcut",
87-
help: `Default: ${formatShortcut("cmd+n")}`,
88-
},
89-
{
90-
label: "New Worktree Agent",
91-
draftKey: "newWorktreeAgent",
92-
settingKey: "newWorktreeAgentShortcut",
93-
help: `Default: ${formatShortcut("cmd+shift+n")}`,
94-
},
95-
{
96-
label: "New Clone Agent",
97-
draftKey: "newCloneAgent",
98-
settingKey: "newCloneAgentShortcut",
99-
help: `Default: ${formatShortcut("cmd+alt+n")}`,
100-
},
101-
{
102-
label: "Archive active thread",
103-
draftKey: "archiveThread",
104-
settingKey: "archiveThreadShortcut",
105-
help: `Default: ${formatShortcut(isMac ? "cmd+ctrl+a" : "ctrl+alt+a")}`,
106-
},
107-
],
108-
},
109-
{
110-
title: "Composer",
111-
subtitle: "Cycle between model, access, reasoning, and collaboration modes.",
112-
items: [
113-
{
114-
label: "Cycle model",
115-
draftKey: "model",
116-
settingKey: "composerModelShortcut",
117-
help: `Press a new shortcut while focused. Default: ${formatShortcut("cmd+shift+m")}`,
118-
},
119-
{
120-
label: "Cycle access mode",
121-
draftKey: "access",
122-
settingKey: "composerAccessShortcut",
123-
help: `Default: ${formatShortcut("cmd+shift+a")}`,
124-
},
125-
{
126-
label: "Cycle reasoning mode",
127-
draftKey: "reasoning",
128-
settingKey: "composerReasoningShortcut",
129-
help: `Default: ${formatShortcut("cmd+shift+r")}`,
130-
},
131-
{
132-
label: "Cycle collaboration mode",
133-
draftKey: "collaboration",
134-
settingKey: "composerCollaborationShortcut",
135-
help: `Default: ${formatShortcut("shift+tab")}`,
136-
},
137-
{
138-
label: "Stop active run",
139-
draftKey: "interrupt",
140-
settingKey: "interruptShortcut",
141-
help: `Default: ${formatShortcut(getDefaultInterruptShortcut())}`,
142-
},
143-
],
144-
},
145-
{
146-
title: "Panels",
147-
subtitle: "Toggle sidebars and panels.",
148-
items: [
149-
{
150-
label: "Toggle projects sidebar",
151-
draftKey: "projectsSidebar",
152-
settingKey: "toggleProjectsSidebarShortcut",
153-
help: `Default: ${formatShortcut("cmd+shift+p")}`,
154-
},
155-
{
156-
label: "Toggle git sidebar",
157-
draftKey: "gitSidebar",
158-
settingKey: "toggleGitSidebarShortcut",
159-
help: `Default: ${formatShortcut("cmd+shift+g")}`,
160-
},
161-
{
162-
label: "Branch switcher",
163-
draftKey: "branchSwitcher",
164-
settingKey: "branchSwitcherShortcut",
165-
help: `Default: ${formatShortcut("cmd+b")}`,
166-
},
167-
{
168-
label: "Toggle debug panel",
169-
draftKey: "debugPanel",
170-
settingKey: "toggleDebugPanelShortcut",
171-
help: `Default: ${formatShortcut("cmd+shift+d")}`,
172-
},
173-
{
174-
label: "Toggle terminal panel",
175-
draftKey: "terminal",
176-
settingKey: "toggleTerminalShortcut",
177-
help: `Default: ${formatShortcut("cmd+shift+t")}`,
178-
},
179-
],
180-
},
181-
{
182-
title: "Navigation",
183-
subtitle: "Cycle between agents and workspaces.",
184-
items: [
185-
{
186-
label: "Next agent",
187-
draftKey: "cycleAgentNext",
188-
settingKey: "cycleAgentNextShortcut",
189-
help: `Default: ${formatShortcut(isMac ? "cmd+ctrl+down" : "ctrl+alt+down")}`,
190-
},
191-
{
192-
label: "Previous agent",
193-
draftKey: "cycleAgentPrev",
194-
settingKey: "cycleAgentPrevShortcut",
195-
help: `Default: ${formatShortcut(isMac ? "cmd+ctrl+up" : "ctrl+alt+up")}`,
196-
},
197-
{
198-
label: "Next workspace",
199-
draftKey: "cycleWorkspaceNext",
200-
settingKey: "cycleWorkspaceNextShortcut",
201-
help: `Default: ${formatShortcut(isMac ? "cmd+shift+down" : "ctrl+alt+shift+down")}`,
202-
},
203-
{
204-
label: "Previous workspace",
205-
draftKey: "cycleWorkspacePrev",
206-
settingKey: "cycleWorkspacePrevShortcut",
207-
help: `Default: ${formatShortcut(isMac ? "cmd+shift+up" : "ctrl+alt+shift+up")}`,
208-
},
209-
],
210-
},
211-
];
78+
const groups = useMemo<ShortcutGroup[]>(
79+
() => [
80+
{
81+
title: "File",
82+
subtitle: "Create agents and worktrees from the keyboard.",
83+
items: [
84+
{
85+
label: "New Agent",
86+
draftKey: "newAgent",
87+
settingKey: "newAgentShortcut",
88+
help: `Default: ${formatShortcut("cmd+n")}`,
89+
},
90+
{
91+
label: "New Worktree Agent",
92+
draftKey: "newWorktreeAgent",
93+
settingKey: "newWorktreeAgentShortcut",
94+
help: `Default: ${formatShortcut("cmd+shift+n")}`,
95+
},
96+
{
97+
label: "New Clone Agent",
98+
draftKey: "newCloneAgent",
99+
settingKey: "newCloneAgentShortcut",
100+
help: `Default: ${formatShortcut("cmd+alt+n")}`,
101+
},
102+
{
103+
label: "Archive active thread",
104+
draftKey: "archiveThread",
105+
settingKey: "archiveThreadShortcut",
106+
help: `Default: ${formatShortcut(isMac ? "cmd+ctrl+a" : "ctrl+alt+a")}`,
107+
},
108+
],
109+
},
110+
{
111+
title: "Composer",
112+
subtitle: "Cycle between model, access, reasoning, and collaboration modes.",
113+
items: [
114+
{
115+
label: "Cycle model",
116+
draftKey: "model",
117+
settingKey: "composerModelShortcut",
118+
help: `Press a new shortcut while focused. Default: ${formatShortcut("cmd+shift+m")}`,
119+
},
120+
{
121+
label: "Cycle access mode",
122+
draftKey: "access",
123+
settingKey: "composerAccessShortcut",
124+
help: `Default: ${formatShortcut("cmd+shift+a")}`,
125+
},
126+
{
127+
label: "Cycle reasoning mode",
128+
draftKey: "reasoning",
129+
settingKey: "composerReasoningShortcut",
130+
help: `Default: ${formatShortcut("cmd+shift+r")}`,
131+
},
132+
{
133+
label: "Cycle collaboration mode",
134+
draftKey: "collaboration",
135+
settingKey: "composerCollaborationShortcut",
136+
help: `Default: ${formatShortcut("shift+tab")}`,
137+
},
138+
{
139+
label: "Stop active run",
140+
draftKey: "interrupt",
141+
settingKey: "interruptShortcut",
142+
help: `Default: ${formatShortcut(getDefaultInterruptShortcut())}`,
143+
},
144+
],
145+
},
146+
{
147+
title: "Panels",
148+
subtitle: "Toggle sidebars and panels.",
149+
items: [
150+
{
151+
label: "Toggle projects sidebar",
152+
draftKey: "projectsSidebar",
153+
settingKey: "toggleProjectsSidebarShortcut",
154+
help: `Default: ${formatShortcut("cmd+shift+p")}`,
155+
},
156+
{
157+
label: "Toggle git sidebar",
158+
draftKey: "gitSidebar",
159+
settingKey: "toggleGitSidebarShortcut",
160+
help: `Default: ${formatShortcut("cmd+shift+g")}`,
161+
},
162+
{
163+
label: "Branch switcher",
164+
draftKey: "branchSwitcher",
165+
settingKey: "branchSwitcherShortcut",
166+
help: `Default: ${formatShortcut("cmd+b")}`,
167+
},
168+
{
169+
label: "Toggle debug panel",
170+
draftKey: "debugPanel",
171+
settingKey: "toggleDebugPanelShortcut",
172+
help: `Default: ${formatShortcut("cmd+shift+d")}`,
173+
},
174+
{
175+
label: "Toggle terminal panel",
176+
draftKey: "terminal",
177+
settingKey: "toggleTerminalShortcut",
178+
help: `Default: ${formatShortcut("cmd+shift+t")}`,
179+
},
180+
],
181+
},
182+
{
183+
title: "Navigation",
184+
subtitle: "Cycle between agents and workspaces.",
185+
items: [
186+
{
187+
label: "Next agent",
188+
draftKey: "cycleAgentNext",
189+
settingKey: "cycleAgentNextShortcut",
190+
help: `Default: ${formatShortcut(isMac ? "cmd+ctrl+down" : "ctrl+alt+down")}`,
191+
},
192+
{
193+
label: "Previous agent",
194+
draftKey: "cycleAgentPrev",
195+
settingKey: "cycleAgentPrevShortcut",
196+
help: `Default: ${formatShortcut(isMac ? "cmd+ctrl+up" : "ctrl+alt+up")}`,
197+
},
198+
{
199+
label: "Next workspace",
200+
draftKey: "cycleWorkspaceNext",
201+
settingKey: "cycleWorkspaceNextShortcut",
202+
help: `Default: ${formatShortcut(isMac ? "cmd+shift+down" : "ctrl+alt+shift+down")}`,
203+
},
204+
{
205+
label: "Previous workspace",
206+
draftKey: "cycleWorkspacePrev",
207+
settingKey: "cycleWorkspacePrevShortcut",
208+
help: `Default: ${formatShortcut(isMac ? "cmd+shift+up" : "ctrl+alt+shift+up")}`,
209+
},
210+
],
211+
},
212+
],
213+
[isMac],
214+
);
212215

213216
const normalizedSearchQuery = searchQuery.trim().toLowerCase();
214217
const filteredGroups = useMemo(() => {

0 commit comments

Comments
 (0)