Skip to content

Commit f39f784

Browse files
authored
fix(theme): make graphite the explicit default across startup modes (#200)
1 parent d2626fb commit f39f784

4 files changed

Lines changed: 33 additions & 10 deletions

File tree

src/core/config.test.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe("config resolution", () => {
8686
});
8787
});
8888

89-
test("falls back to the global config path outside a repo", () => {
89+
test("defaults unspecified themes to graphite, including piped pager-style patch input", () => {
9090
const home = createTempDir("hunk-config-home-");
9191
const cwd = createTempDir("hunk-config-cwd-");
9292

@@ -96,6 +96,7 @@ describe("config resolution", () => {
9696
});
9797

9898
expect(resolved.repoConfigPath).toBeUndefined();
99+
expect(resolved.input.options.theme).toBe("graphite");
99100
});
100101

101102
test("command-specific config sections also apply to show mode", () => {
@@ -196,4 +197,28 @@ describe("config resolution", () => {
196197
expect(bootstrap.initialShowHunkHeaders).toBe(false);
197198
expect(bootstrap.initialShowAgentNotes).toBe(true);
198199
});
200+
201+
test("loadAppBootstrap exposes graphite when no theme is configured", async () => {
202+
const home = createTempDir("hunk-config-home-");
203+
const repo = createTempDir("hunk-config-repo-");
204+
createRepo(repo);
205+
206+
const before = join(repo, "before.ts");
207+
const after = join(repo, "after.ts");
208+
writeFileSync(before, "export const alpha = 1;\n");
209+
writeFileSync(after, "export const alpha = 2;\n");
210+
211+
const resolved = resolveConfiguredCliInput(
212+
{
213+
kind: "diff",
214+
left: before,
215+
right: after,
216+
options: {},
217+
},
218+
{ cwd: repo, env: { HOME: home } },
219+
);
220+
const bootstrap = await loadAppBootstrap(resolved.input);
221+
222+
expect(bootstrap.initialTheme).toBe("graphite");
223+
});
199224
});

src/core/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ export function resolveConfiguredCliInput(
131131

132132
let resolvedOptions: CommonOptions = {
133133
mode: DEFAULT_VIEW_PREFERENCES.mode,
134-
theme: undefined,
134+
// Keep the built-in theme default explicit so stdin-backed startup paths do not depend on
135+
// renderer theme-mode detection for their initial palette.
136+
theme: "graphite",
135137
agentContext: input.options.agentContext,
136138
pager: input.options.pager ?? false,
137139
watch: input.options.watch ?? false,

src/ui/lib/ui-lib.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,13 @@ describe("ui helpers", () => {
359359
).toBe(16);
360360
});
361361

362-
test("resolveTheme falls back by requested id and renderer mode while lazily exposing syntax styles", () => {
362+
test("resolveTheme falls back by requested id to graphite while lazily exposing syntax styles", () => {
363363
const midnight = resolveTheme("midnight", null);
364364
const missingLight = resolveTheme("missing", "light");
365365
const missingDark = resolveTheme("missing", "dark");
366366

367367
expect(midnight.id).toBe("midnight");
368-
expect(missingLight.id).toBe("paper");
368+
expect(missingLight.id).toBe("graphite");
369369
expect(missingDark.id).toBe("graphite");
370370
expect(resolveTheme("ember", null).syntaxStyle).toBeDefined();
371371
});

src/ui/themes.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,16 +286,12 @@ export const THEMES: AppTheme[] = [
286286
),
287287
];
288288

289-
/** Resolve a named theme or fall back to a theme that matches the renderer mode. */
290-
export function resolveTheme(requested: string | undefined, themeMode: ThemeMode | null) {
289+
/** Resolve a named theme or fall back to Hunk's explicit built-in default. */
290+
export function resolveTheme(requested: string | undefined, _themeMode: ThemeMode | null) {
291291
const exact = THEMES.find((theme) => theme.id === requested);
292292
if (exact) {
293293
return exact;
294294
}
295295

296-
if (themeMode === "light") {
297-
return THEMES.find((theme) => theme.id === "paper") ?? THEMES[0]!;
298-
}
299-
300296
return THEMES.find((theme) => theme.id === "graphite") ?? THEMES[0]!;
301297
}

0 commit comments

Comments
 (0)