From cff21a7839de8b7cc392cc44526f27f7ad5ae28c Mon Sep 17 00:00:00 2001 From: ubuntudroid Date: Wed, 8 Apr 2026 17:11:27 +0200 Subject: [PATCH 1/6] feat: add expandCommitDetail to InterfaceSettings --- src/main/settings.ts | 5 +++++ src/test/main/settings.test.ts | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/main/settings.ts b/src/main/settings.ts index 82cd0cc3d..8f24c92cf 100644 --- a/src/main/settings.ts +++ b/src/main/settings.ts @@ -70,6 +70,7 @@ export interface InterfaceSettings { showResourceMonitor?: boolean; theme?: 'light' | 'dark' | 'dark-black' | 'system'; taskHoverAction?: 'delete' | 'archive'; + expandCommitDetail?: boolean; } /** @@ -205,6 +206,7 @@ const DEFAULT_SETTINGS: AppSettings = { showResourceMonitor: false, theme: 'system', taskHoverAction: 'delete', + expandCommitDetail: false, }, providerConfigs: {}, terminal: { @@ -549,6 +551,9 @@ export function normalizeSettings(input: AppSettings): AppSettings { ? iface.theme : DEFAULT_SETTINGS.interface!.theme, taskHoverAction: iface?.taskHoverAction === 'archive' ? 'archive' : 'delete', + expandCommitDetail: Boolean( + iface?.expandCommitDetail ?? DEFAULT_SETTINGS.interface!.expandCommitDetail + ), }; // Provider custom configs diff --git a/src/test/main/settings.test.ts b/src/test/main/settings.test.ts index 5456eeab2..16574974f 100644 --- a/src/test/main/settings.test.ts +++ b/src/test/main/settings.test.ts @@ -283,3 +283,20 @@ describe('normalizeSettings – terminal settings', () => { expect(result.terminal?.macOptionIsMeta).toBe(true); }); }); + +describe('normalizeSettings – expandCommitDetail', () => { + it('defaults expandCommitDetail to false when not set', () => { + const result = normalizeSettings(makeSettings()); + expect(result.interface?.expandCommitDetail).toBe(false); + }); + + it('preserves expandCommitDetail: true', () => { + const result = normalizeSettings(makeSettings({ interface: { expandCommitDetail: true } })); + expect(result.interface?.expandCommitDetail).toBe(true); + }); + + it('preserves expandCommitDetail: false', () => { + const result = normalizeSettings(makeSettings({ interface: { expandCommitDetail: false } })); + expect(result.interface?.expandCommitDetail).toBe(false); + }); +}); From 792b51e0be8078b6e695bf6382df628bcdaaf8b3 Mon Sep 17 00:00:00 2001 From: ubuntudroid Date: Wed, 8 Apr 2026 17:12:00 +0200 Subject: [PATCH 2/6] feat: add CommitDetailSettingsCard toggle --- .../components/CommitDetailSettingsCard.tsx | 33 ++++++++++++ ...ommitDetailSettingsCard.component.test.tsx | 52 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 src/renderer/components/CommitDetailSettingsCard.tsx create mode 100644 src/test/renderer/CommitDetailSettingsCard.component.test.tsx diff --git a/src/renderer/components/CommitDetailSettingsCard.tsx b/src/renderer/components/CommitDetailSettingsCard.tsx new file mode 100644 index 000000000..ddf82cf6f --- /dev/null +++ b/src/renderer/components/CommitDetailSettingsCard.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import { Switch } from './ui/switch'; +import { useAppSettings } from '@/contexts/AppSettingsProvider'; + +const CommitDetailSettingsCard: React.FC = () => { + const { settings, updateSettings, isLoading: loading } = useAppSettings(); + + const expandCommitDetail = settings?.interface?.expandCommitDetail ?? false; + + return ( +
+
+ + Expand commit details by default + + + Automatically show the full commit message and author when selecting a commit in the + History tab + +
+ + updateSettings({ interface: { expandCommitDetail: checked } }) + } + /> +
+ ); +}; + +export default CommitDetailSettingsCard; diff --git a/src/test/renderer/CommitDetailSettingsCard.component.test.tsx b/src/test/renderer/CommitDetailSettingsCard.component.test.tsx new file mode 100644 index 000000000..d127230df --- /dev/null +++ b/src/test/renderer/CommitDetailSettingsCard.component.test.tsx @@ -0,0 +1,52 @@ +import { render, screen, fireEvent } from '@testing-library/react'; +import { describe, expect, it, vi } from 'vitest'; +import { useAppSettings } from '@/contexts/AppSettingsProvider'; +import CommitDetailSettingsCard from '../../renderer/components/CommitDetailSettingsCard'; +import type { AppSettings } from '../../main/settings'; + +vi.mock('@/contexts/AppSettingsProvider', () => ({ + useAppSettings: vi.fn(), +})); + +function setup(expandCommitDetail = false) { + const updateSettings = vi.fn(); + vi.mocked(useAppSettings).mockReturnValue({ + settings: { + interface: { expandCommitDetail }, + } as unknown as ReturnType['settings'], + isLoading: false, + isSaving: false, + updateSettings, + }); + render(); + return { updateSettings }; +} + +describe('CommitDetailSettingsCard', () => { + it('renders the toggle label', () => { + setup(); + expect(screen.getByText('Expand commit details by default')).toBeInTheDocument(); + }); + + it('is unchecked when expandCommitDetail is false', () => { + setup(false); + expect(screen.getByRole('switch')).toHaveAttribute('data-state', 'unchecked'); + }); + + it('is checked when expandCommitDetail is true', () => { + setup(true); + expect(screen.getByRole('switch')).toHaveAttribute('data-state', 'checked'); + }); + + it('calls updateSettings with true when toggled on', () => { + const { updateSettings } = setup(false); + fireEvent.click(screen.getByRole('switch')); + expect(updateSettings).toHaveBeenCalledWith({ interface: { expandCommitDetail: true } }); + }); + + it('calls updateSettings with false when toggled off', () => { + const { updateSettings } = setup(true); + fireEvent.click(screen.getByRole('switch')); + expect(updateSettings).toHaveBeenCalledWith({ interface: { expandCommitDetail: false } }); + }); +}); From 0a2fffa0372a7b8760201b4dfa4555a50e2f9947 Mon Sep 17 00:00:00 2001 From: ubuntudroid Date: Wed, 8 Apr 2026 17:12:30 +0200 Subject: [PATCH 3/6] feat: register CommitDetailSettingsCard in Interface settings --- src/renderer/components/SettingsPage.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/renderer/components/SettingsPage.tsx b/src/renderer/components/SettingsPage.tsx index 293cb280d..8fd3e142b 100644 --- a/src/renderer/components/SettingsPage.tsx +++ b/src/renderer/components/SettingsPage.tsx @@ -28,6 +28,7 @@ import TerminalSettingsCard from './TerminalSettingsCard'; import HiddenToolsSettingsCard from './HiddenToolsSettingsCard'; import ReviewAgentSettingsCard from './ReviewAgentSettingsCard'; import ResourceMonitorSettingsCard from './ResourceMonitorSettingsCard'; +import CommitDetailSettingsCard from './CommitDetailSettingsCard'; import { AccountTab } from './settings/AccountTab'; import { WorkspaceProviderInfoCard } from './WorkspaceProviderInfoCard'; import { useTaskSettings } from '../hooks/useTaskSettings'; @@ -268,6 +269,7 @@ export const SettingsPage: React.FC = ({ initialTab, onClose + ), }, From 283756dd7c6646366cdbdf3e299e34059ee767bb Mon Sep 17 00:00:00 2001 From: ubuntudroid Date: Wed, 8 Apr 2026 17:14:28 +0200 Subject: [PATCH 4/6] feat: auto-expand commit detail based on settings --- src/renderer/components/diff-viewer/HistoryTab.tsx | 5 ++++- .../renderer/CommitDetailSettingsCard.component.test.tsx | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/diff-viewer/HistoryTab.tsx b/src/renderer/components/diff-viewer/HistoryTab.tsx index d6c65a634..5f107c65e 100644 --- a/src/renderer/components/diff-viewer/HistoryTab.tsx +++ b/src/renderer/components/diff-viewer/HistoryTab.tsx @@ -6,6 +6,7 @@ import { CommitFileList } from './CommitFileList'; import { CommitFileDiffView } from './CommitFileDiffView'; import { DiffToolbar } from './DiffToolbar'; import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '../ui/resizable'; +import { useAppSettings } from '@/contexts/AppSettingsProvider'; interface HistoryTabProps { taskPath?: string; @@ -27,6 +28,8 @@ export const HistoryTab: React.FC = ({ const [diffStyle, setDiffStyle] = useState<'unified' | 'split'>( () => (localStorage.getItem('diffViewer:diffStyle') as 'unified' | 'split') || 'unified' ); + const { settings } = useAppSettings(); + const expandByDefault = settings?.interface?.expandCommitDetail ?? false; const [detailExpanded, setDetailExpanded] = useState(false); const [copied, setCopied] = useState(false); @@ -39,7 +42,7 @@ export const HistoryTab: React.FC = ({ if (commit.hash === selectedCommit?.hash) return; setSelectedCommit(commit); setSelectedFile(null); - setDetailExpanded(false); + setDetailExpanded(expandByDefault); setCopied(false); }; diff --git a/src/test/renderer/CommitDetailSettingsCard.component.test.tsx b/src/test/renderer/CommitDetailSettingsCard.component.test.tsx index d127230df..b620ce7dc 100644 --- a/src/test/renderer/CommitDetailSettingsCard.component.test.tsx +++ b/src/test/renderer/CommitDetailSettingsCard.component.test.tsx @@ -2,7 +2,6 @@ import { render, screen, fireEvent } from '@testing-library/react'; import { describe, expect, it, vi } from 'vitest'; import { useAppSettings } from '@/contexts/AppSettingsProvider'; import CommitDetailSettingsCard from '../../renderer/components/CommitDetailSettingsCard'; -import type { AppSettings } from '../../main/settings'; vi.mock('@/contexts/AppSettingsProvider', () => ({ useAppSettings: vi.fn(), From 05c7edf115b5e0efc8c8ba206b642c835188b2fc Mon Sep 17 00:00:00 2001 From: ubuntudroid Date: Wed, 8 Apr 2026 17:37:34 +0200 Subject: [PATCH 5/6] fix: don't truncate commit subject when detail is expanded --- src/renderer/components/diff-viewer/HistoryTab.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/diff-viewer/HistoryTab.tsx b/src/renderer/components/diff-viewer/HistoryTab.tsx index 5f107c65e..271ee1116 100644 --- a/src/renderer/components/diff-viewer/HistoryTab.tsx +++ b/src/renderer/components/diff-viewer/HistoryTab.tsx @@ -7,6 +7,7 @@ import { CommitFileDiffView } from './CommitFileDiffView'; import { DiffToolbar } from './DiffToolbar'; import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '../ui/resizable'; import { useAppSettings } from '@/contexts/AppSettingsProvider'; +import { cn } from '@/lib/utils'; interface HistoryTabProps { taskPath?: string; @@ -102,7 +103,12 @@ export const HistoryTab: React.FC = ({ {/* Commit message detail */}
-
+
{selectedCommit.subject}
{hasExpandableContent && ( From 9d7da44381a157d4abf6377d0e36519052aff6be Mon Sep 17 00:00:00 2001 From: ubuntudroid Date: Wed, 8 Apr 2026 18:27:20 +0200 Subject: [PATCH 6/6] fix: remove redundant defaultChecked and add edge case test per code review --- src/renderer/components/CommitDetailSettingsCard.tsx | 1 - src/test/main/settings.test.ts | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/CommitDetailSettingsCard.tsx b/src/renderer/components/CommitDetailSettingsCard.tsx index ddf82cf6f..8a051e9bc 100644 --- a/src/renderer/components/CommitDetailSettingsCard.tsx +++ b/src/renderer/components/CommitDetailSettingsCard.tsx @@ -20,7 +20,6 @@ const CommitDetailSettingsCard: React.FC = () => {
updateSettings({ interface: { expandCommitDetail: checked } }) diff --git a/src/test/main/settings.test.ts b/src/test/main/settings.test.ts index 16574974f..0463f7c33 100644 --- a/src/test/main/settings.test.ts +++ b/src/test/main/settings.test.ts @@ -299,4 +299,9 @@ describe('normalizeSettings – expandCommitDetail', () => { const result = normalizeSettings(makeSettings({ interface: { expandCommitDetail: false } })); expect(result.interface?.expandCommitDetail).toBe(false); }); + + it('coerces missing value inside interface to false', () => { + const result = normalizeSettings(makeSettings({ interface: {} })); + expect(result.interface?.expandCommitDetail).toBe(false); + }); });