Skip to content

Commit 483ea47

Browse files
authored
fix(theme): restore GitHub Dark Default as the default theme (#1195)
1 parent 3958042 commit 483ea47

23 files changed

Lines changed: 130 additions & 48 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"hunkdiff": patch
3+
---
4+
5+
Restore `github-dark-default` as the default theme. The `terminal` theme remains available explicitly through config, `--theme terminal`, or the theme picker.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ and falling back to it if migration fails. Global extension paths are unchanged.
177177
For example:
178178

179179
```toml
180-
theme = "terminal"
180+
theme = "github-dark-default"
181181
mode = "auto" # auto, split, unified
182182
auto_split_min_width = 160 # minimum available diff columns for split in auto mode
183183
line_numbers = true

‎docs/themes.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Themes
22

3-
Hunk follows your terminal's own colors by default. You can instead choose a
4-
built-in theme, let Hunk select one from your terminal background, or create a
3+
Hunk uses `github-dark-default` by default. You can instead follow your terminal's
4+
own colors, choose another built-in theme, select one from your terminal background, or create a
55
custom theme in `~/.config/hunk/config.toml` or `.hunk/config.toml`.
66

77
```toml
@@ -13,7 +13,7 @@ You can also change themes while reviewing: press `t` or choose
1313

1414
## Terminal theme
1515

16-
`theme = "terminal"` is the default. At startup Hunk asks the terminal for its
16+
Set `theme = "terminal"` to follow your terminal's colors. At startup Hunk asks the terminal for its
1717
foreground, background, and 16-color ANSI palette, then draws diffs, chrome,
1818
and syntax highlighting from those colors: green for additions and strings, red
1919
for removals, blue for functions and accents, magenta for keywords, and so on.

‎packages/hunk/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ and falling back to it if migration fails. Global extension paths are unchanged.
177177
For example:
178178

179179
```toml
180-
theme = "terminal"
180+
theme = "github-dark-default"
181181
mode = "auto" # auto, split, unified
182182
auto_split_min_width = 160 # minimum available diff columns for split in auto mode
183183
line_numbers = true

‎packages/hunk/src/core/run/config.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ describe("config resolution", () => {
920920
expect(configured.input.options.transparentBackground).toBe(true);
921921
});
922922

923-
test("defaults unspecified themes to terminal, including piped pager-style patch input", () => {
923+
test("defaults unspecified themes to GitHub Dark Default, including piped pager-style patch input", () => {
924924
const home = createTempDir("hunk-config-home-");
925925
const cwd = createTempDir("hunk-config-cwd-");
926926

@@ -931,7 +931,7 @@ describe("config resolution", () => {
931931

932932
expect(resolved.repoConfigPath).toBeUndefined();
933933
expect(resolved.viewPreferencesConfigPath).toBe(join(home, ".config", "hunk", "config.toml"));
934-
expect(resolved.input.options.theme).toBe("terminal");
934+
expect(resolved.input.options.theme).toBe("github-dark-default");
935935
});
936936

937937
test("command-specific config sections also apply to show mode", () => {
@@ -1288,7 +1288,7 @@ describe("config resolution", () => {
12881288
]);
12891289
});
12901290

1291-
test("loadAppBootstrap exposes terminal when no theme is configured", async () => {
1291+
test("loadAppBootstrap exposes GitHub Dark Default when no theme is configured", async () => {
12921292
const home = createTempDir("hunk-config-home-");
12931293
const repo = createTempDir("hunk-config-repo-");
12941294
createRepo(repo);
@@ -1309,7 +1309,7 @@ describe("config resolution", () => {
13091309
);
13101310
const bootstrap = await loadAppBootstrap(resolved.input);
13111311

1312-
expect(bootstrap.initialTheme).toBe("terminal");
1312+
expect(bootstrap.initialTheme).toBe("github-dark-default");
13131313
});
13141314
});
13151315

‎packages/hunk/src/core/run/config.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import fs from "node:fs";
22
import { dirname, join } from "node:path";
33
import { sanitizeTerminalLine } from "../../lib/terminalText";
44
import { BUNDLED_SHIKI_THEME_IDS, LEGACY_THEME_ID_ALIASES } from "../theme/catalog";
5-
import { TERMINAL_THEME_ID } from "../theme/terminalColors";
65
import {
76
createInvalidThemeIdNotice,
87
createThemeCollisionNotice,
@@ -101,7 +100,7 @@ export interface PersistedViewPreferences {
101100
export const BUILT_IN_THEME_IDS = BUNDLED_SHIKI_THEME_IDS;
102101
// Widen the large literal tuple before formatting it, avoiding TypeScript's deep tuple inference.
103102
const BUILT_IN_THEME_IDS_FOR_MESSAGES: readonly string[] = BUILT_IN_THEME_IDS;
104-
const DEFAULT_THEME_ID = TERMINAL_THEME_ID;
103+
const DEFAULT_THEME_ID = "github-dark-default";
105104
const DEFAULT_CUSTOM_THEME_BASE_ID = "github-dark-default";
106105
const DEFAULT_VIEW_PREFERENCES: PersistedViewPreferences = {
107106
mode: "auto",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { expect, test } from "bun:test";
2+
import { themeFollowsTerminal } from "./terminalColors";
3+
4+
test("only explicit terminal and auto themes need terminal color detection", () => {
5+
expect(themeFollowsTerminal(undefined)).toBe(false);
6+
expect(themeFollowsTerminal("github-dark-default")).toBe(false);
7+
expect(themeFollowsTerminal("github-light-default")).toBe(false);
8+
expect(themeFollowsTerminal("terminal")).toBe(true);
9+
expect(themeFollowsTerminal("auto")).toBe(true);
10+
});

‎packages/hunk/src/core/theme/terminalColors.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/** Id of the built-in theme drawn from the terminal's own colors, and Hunk's default theme. */
1+
/** Id of the opt-in built-in theme drawn from the terminal's own colors. */
22
export const TERMINAL_THEME_ID = "terminal";
33

44
/**
5-
* Return whether a requested theme id depends on what the terminal looks like: the default
6-
* (no id), the terminal-colors theme itself, and `auto` light/dark selection.
5+
* Return whether a requested theme id depends on what the terminal looks like:
6+
* the terminal-colors theme itself and `auto` light/dark selection.
77
*/
88
export function themeFollowsTerminal(themeId: string | undefined) {
9-
return themeId === undefined || themeId === TERMINAL_THEME_ID || themeId === "auto";
9+
return themeId === TERMINAL_THEME_ID || themeId === "auto";
1010
}
1111

1212
/**

‎packages/hunk/src/lib/shikiWasm.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { tmpdir } from "node:os";
44
import { join } from "node:path";
55
import { pathToFileURL } from "node:url";
66
import { REPO_ROOT } from "../../../../scripts/build/package-paths";
7+
import { removeTestDirectory } from "../../../../test/helpers/filesystem";
78

89
// Install the main-thread counter before Pierre evaluates its static imports.
910
const highlightDecodeTestPreload = `
@@ -94,7 +95,7 @@ function runHighlightTestProcess(args: string[], cwd = REPO_ROOT) {
9495
return JSON.parse(result.stdout.toString());
9596
}
9697

97-
test("Pierre avoids base64 decoding in source, workers, bundles, and binaries with identical tokens", () => {
98+
test("Pierre avoids base64 decoding in source, workers, bundles, and binaries with identical tokens", async () => {
9899
const temporary = mkdtempSync(join(tmpdir(), "hunk-shiki-test-"));
99100
// Keep the compile entry under the repository so its package imports resolve normally.
100101
const sourceDir = mkdtempSync(join(REPO_ROOT, ".shiki-test-"));
@@ -177,7 +178,7 @@ test("Pierre avoids base64 decoding in source, workers, bundles, and binaries wi
177178
expect(compiled.assets).toContain(466_610);
178179
} finally {
179180
rmSync(sourceDir, { recursive: true, force: true });
180-
// Windows can briefly retain the compiled executable's file lock after the child exits.
181-
rmSync(temporary, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
181+
// Yield between retries so Windows can release the compiled child's executable handles.
182+
await removeTestDirectory(temporary);
182183
}
183184
}, 60_000);

‎packages/hunk/src/ui/AppHost.keybindings.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,13 @@ describe("user keybindings", () => {
239239
setup.mockInput.pressKey("n", { ctrl: true });
240240
});
241241
await flush(setup);
242-
expect(setup.captureCharFrame()).toContain("› andromeeda");
242+
expect(setup.captureCharFrame()).toContain("› github-dark-dimmed");
243243

244244
await act(async () => {
245245
setup.mockInput.pressKey("p", { ctrl: true });
246246
});
247247
await flush(setup);
248-
expect(setup.captureCharFrame()).toContain("› terminal");
248+
expect(setup.captureCharFrame()).toContain("› github-dark-default");
249249
});
250250
});
251251

0 commit comments

Comments
 (0)