Skip to content

Commit 34cfc48

Browse files
authored
feat(ui): show selected theme in footer (#396)
1 parent b65e6db commit 34cfc48

3 files changed

Lines changed: 44 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ All notable user-visible changes to Hunk are documented in this file.
66

77
### Added
88

9+
- Show the newly selected theme in the footer status bar when switching themes.
10+
911
### Changed
1012

1113
### Fixed

src/ui/App.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,16 @@ export function App({
373373
setWrapLines((current) => !current);
374374
};
375375

376+
/** Switch the active theme and surface the result in the shared footer notice area. */
377+
const selectTheme = useCallback(
378+
(nextThemeId: string) => {
379+
const nextTheme = themeOptions.find((theme) => theme.id === nextThemeId);
380+
setThemeId(nextThemeId);
381+
showTransientNotice(`Theme: ${nextTheme?.label ?? nextThemeId}`);
382+
},
383+
[showTransientNotice, themeOptions],
384+
);
385+
376386
/** Toggle the sidebar, forcing it open on narrower layouts when the app can still fit both panes. */
377387
const toggleSidebar = () => {
378388
if (sidebarVisible && (responsiveLayout.showSidebar || forceSidebarOpen)) {
@@ -596,12 +606,12 @@ export function App({
596606
setFocusArea("files");
597607
}, [review.cancelDraftNote]);
598608

599-
/** Cycle through the available built-in themes. */
609+
/** Cycle through the themes exposed by the current app configuration. */
600610
const cycleTheme = useCallback(() => {
601611
const currentIndex = themeOptions.findIndex((theme) => theme.id === activeTheme.id);
602612
const nextIndex = (currentIndex + 1) % themeOptions.length;
603-
setThemeId(themeOptions[nextIndex]!.id);
604-
}, [activeTheme.id, themeOptions]);
613+
selectTheme(themeOptions[nextIndex]!.id);
614+
}, [activeTheme.id, selectTheme, themeOptions]);
605615

606616
const menus = useMemo(
607617
() =>
@@ -617,7 +627,7 @@ export function App({
617627
refreshCurrentInput: triggerRefreshCurrentInput,
618628
requestQuit,
619629
selectLayoutMode,
620-
selectThemeId: setThemeId,
630+
selectThemeId: selectTheme,
621631
copyDecorations,
622632
showAgentNotes,
623633
showHelp,
@@ -647,6 +657,7 @@ export function App({
647657
requestQuit,
648658
review.moveToHunk,
649659
selectLayoutMode,
660+
selectTheme,
650661
triggerRefreshCurrentInput,
651662
toggleCopyDecorations,
652663
showAgentNotes,

src/ui/AppHost.interactions.test.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,33 @@ describe("App interactions", () => {
685685
}
686686
});
687687

688+
test("theme shortcut shows the selected theme in the status bar", async () => {
689+
const setup = await testRender(<AppHost bootstrap={createSingleFileBootstrap()} />, {
690+
width: 240,
691+
height: 24,
692+
});
693+
694+
try {
695+
await flush(setup);
696+
697+
await act(async () => {
698+
await setup.mockInput.typeText("t");
699+
});
700+
let frame = await waitForFrame(setup, (nextFrame) => nextFrame.includes("Theme: Paper"));
701+
expect(frame).toContain("Theme: Paper");
702+
703+
await act(async () => {
704+
await setup.mockInput.typeText("t");
705+
});
706+
frame = await waitForFrame(setup, (nextFrame) => nextFrame.includes("Theme: Ember"));
707+
expect(frame).toContain("Theme: Ember");
708+
} finally {
709+
await act(async () => {
710+
setup.renderer.destroy();
711+
});
712+
}
713+
});
714+
688715
test("keyboard shortcut can wrap long lines in the app", async () => {
689716
const setup = await testRender(<AppHost bootstrap={createWrapBootstrap()} />, {
690717
width: 140,

0 commit comments

Comments
 (0)