@devries-cameron20 / t3code Mirror · read-only / commits / 1535f3f32e
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 14:45 UTC

fix(desktop): theme changes no longer stop at windows without a title bar overlay (#28081)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Sam committed Nov 14, 2026 at 22:40 UTC 1535f3f32e77cebc46ec0937e17e039669512e32
4 files changed +106 -19
apps/desktop/src/electron/ElectronWindow.test.ts
+28
@@ -148,6 +148,34 @@ describe("ElectronWindow", () => {
148 }).pipe(Effect.provide(layerTestFor("win32"))),
149 );
150
151 + it.effect("reports which windows were created with a title bar overlay", () =>
152 + Effect.gen(function* () {
153 + const framed = { isDestroyed: () => false };
154 + const overlay = { isDestroyed: () => false };
155 + browserWindowMock
156 + .mockImplementationOnce(function FramedWindowMock() {
157 + return framed;
158 + })
159 + .mockImplementationOnce(function OverlayWindowMock() {
160 + return overlay;
161 + });
162 + const electronWindow = yield* ElectronWindow.ElectronWindow;
163 + yield* electronWindow.create({});
164 + yield* electronWindow.create({
165 + titleBarStyle: "hidden",
166 + titleBarOverlay: { color: "#01000000", height: 40 },
167 + });
168 + getAllWindowsMock.mockReturnValue([framed, overlay, { isDestroyed: () => false }]);
169 +
170 + const seen: Array<boolean> = [];
171 + yield* electronWindow.syncAllAppearance((_window, { titleBarOverlay }) =>
172 + Effect.sync(() => seen.push(titleBarOverlay)),
173 + );
174 +
175 + assert.deepEqual(seen, [false, true, false]);
176 + }).pipe(Effect.provide(layerTestFor("win32"))),
177 + );
178 +
179 it.effect("preserves destroy failures and continues with later windows", () =>
180 Effect.gen(function* () {
181 const cause = new Error("window destroy failed");
apps/desktop/src/electron/ElectronWindow.ts
+13 -3
@@ -125,7 +125,10 @@ export class ElectronWindow extends Context.Service<
125 readonly sendAll: (channel: string, ...args: readonly unknown[]) => Effect.Effect<void>;
126 readonly destroyAll: Effect.Effect<void>;
127 readonly syncAllAppearance: <E, R>(
128 - sync: (window: Electron.BrowserWindow) => Effect.Effect<void, E, R>,
128 + sync: (
129 + window: Electron.BrowserWindow,
130 + appearance: { readonly titleBarOverlay: boolean },
131 + ) => Effect.Effect<void, E, R>,
132 ) => Effect.Effect<void, E, R>;
133 }
134 >()("@t3tools/desktop/electron/ElectronWindow") {}
@@ -145,6 +148,7 @@ export const make = Effect.gen(function* () {
148 yield* Effect.addFinalizer(() => Effect.sync(() => windowsForegroundFocus?.close()));
149 const mainWindowRef = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
150 const auxiliaryWindows = new WeakSet<Electron.BrowserWindow>();
151 + const titleBarOverlayWindows = new WeakSet<Electron.BrowserWindow>();
152
153 const listWindows = Effect.try({
154 try: () => Electron.BrowserWindow.getAllWindows(),
@@ -241,6 +245,9 @@ export const make = Effect.gen(function* () {
245 try: () => {
246 const window = new Electron.BrowserWindow(options);
247 if (behavior?.auxiliary === true) auxiliaryWindows.add(window);
248 + if (options.titleBarOverlay !== undefined && options.titleBarOverlay !== false) {
249 + titleBarOverlayWindows.add(window);
250 + }
251 return window;
252 },
253 catch: (cause) => new ElectronWindowCreateError({ options: diagnosticOptions, cause }),
@@ -383,14 +390,17 @@ export const make = Effect.gen(function* () {
390 }
391 }),
392 syncAllAppearance: Effect.fn("desktop.electron.window.syncAllAppearance")(function* <E, R>(
386 - sync: (window: Electron.BrowserWindow) => Effect.Effect<void, E, R>,
393 + sync: (
394 + window: Electron.BrowserWindow,
395 + appearance: { readonly titleBarOverlay: boolean },
396 + ) => Effect.Effect<void, E, R>,
397 ) {
398 const windows = yield* listWindows;
399 for (const window of windows) {
400 if (yield* isWindowDestroyed(window)) {
401 continue;
402 }
393 - yield* sync(window);
403 + yield* sync(window, { titleBarOverlay: titleBarOverlayWindows.has(window) });
404 }
405 }),
406 });
apps/desktop/src/window/DesktopWindow.test.ts
+61 -13
@@ -207,17 +207,20 @@ const layerElectronTheme = Layer.succeed(ElectronTheme.ElectronTheme, {
207 onUpdated: () => Effect.void,
208 } satisfies ElectronTheme.ElectronTheme["Service"]);
209
210 -const layerDesktopEnvironment = DesktopEnvironment.layer(environmentInput).pipe(
211 - Layer.provide(
212 - Layer.mergeAll(
213 - NodeServices.layer,
214 - DesktopConfig.layerTest({
215 - T3CODE_PORT: "3773",
216 - VITE_DEV_SERVER_URL: "http://127.0.0.1:5733",
217 - }),
210 +const layerDesktopEnvironmentFor = (platform: NodeJS.Platform) =>
211 + DesktopEnvironment.layer({ ...environmentInput, platform }).pipe(
212 + Layer.provide(
213 + Layer.mergeAll(
214 + NodeServices.layer,
215 + DesktopConfig.layerTest({
216 + T3CODE_PORT: "3773",
217 + VITE_DEV_SERVER_URL: "http://127.0.0.1:5733",
218 + }),
219 + ),
220 ),
219 - ),
220 -);
221 + );
222 +
223 +const layerDesktopEnvironment = layerDesktopEnvironmentFor(environmentInput.platform);
224
225 const desktopWindowBoundsEquivalence = Schema.toEquivalence(
226 DesktopAppSettings.DesktopWindowBoundsSchema,
@@ -243,6 +246,11 @@ function layerTest(input: {
246 readonly previewZoomReapplies?: number[];
247 readonly onReveal?: (window: Electron.BrowserWindow) => void;
248 readonly focusedWindow?: Electron.BrowserWindow;
249 + readonly platform?: NodeJS.Platform;
250 + readonly appearanceWindows?: ReadonlyArray<{
251 + readonly window: Electron.BrowserWindow;
252 + readonly titleBarOverlay: boolean;
253 + }>;
254 readonly primaryPasteEnabled?: boolean;
255 readonly previewPasskeyBridgeEnabled?: boolean;
256 }) {
@@ -302,7 +310,14 @@ function layerTest(input: {
310 reveal: (window) => Effect.sync(() => input.onReveal?.(window)),
311 sendAll: () => Effect.void,
312 destroyAll: input.destroyAll ?? Effect.void,
305 - syncAllAppearance: (sync) => sync(input.window),
313 + syncAllAppearance: (sync) =>
314 + input.appearanceWindows === undefined
315 + ? sync(input.window, { titleBarOverlay: true })
316 + : Effect.forEach(
317 + input.appearanceWindows,
318 + ({ window, titleBarOverlay }) => sync(window, { titleBarOverlay }),
319 + { discard: true },
320 + ),
321 } satisfies ElectronWindow.ElectronWindow["Service"]);
322
323 return DesktopWindow.layer.pipe(
@@ -314,7 +329,9 @@ function layerTest(input: {
329 recordMetrics: () => Effect.void,
330 shutdown: Effect.void,
331 }),
317 - layerDesktopEnvironment,
332 + input.platform === undefined
333 + ? layerDesktopEnvironment
334 + : layerDesktopEnvironmentFor(input.platform),
335 layerDesktopAppSettings,
336 layerDesktopClientSettings,
337 layerDesktopServerExposure,
@@ -423,7 +440,8 @@ const makeSplashScenario = (createOutcomes: readonly (Electron.BrowserWindow | n
440 reveal: (window) => Ref.update(revealedWindows, (windows) => [...windows, window]),
441 sendAll: () => Effect.void,
442 destroyAll: Effect.void,
426 - syncAllAppearance: (sync) => (fallbackWindow ? sync(fallbackWindow) : Effect.void),
443 + syncAllAppearance: (sync) =>
444 + fallbackWindow ? sync(fallbackWindow, { titleBarOverlay: true }) : Effect.void,
445 } satisfies ElectronWindow.ElectronWindow["Service"];
446
447 const layer = DesktopWindow.layer.pipe(
@@ -1170,6 +1188,36 @@ describe("DesktopWindow", () => {
1188 }),
1189 );
1190
1191 + it.effect("updates title bar overlays only on windows created with one", () =>
1192 + Effect.gen(function* () {
1193 + const framed = makeFakeBrowserWindow();
1194 + vi.mocked(framed.window.setTitleBarOverlay).mockImplementation(() => {
1195 + throw new TypeError("Titlebar overlay is not enabled");
1196 + });
1197 + const overlay = makeFakeBrowserWindow();
1198 + const layer = layerTest({
1199 + window: overlay.window,
1200 + createCount: yield* Ref.make(0),
1201 + mainWindow: yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none()),
1202 + platform: "win32",
1203 + appearanceWindows: [
1204 + { window: framed.window, titleBarOverlay: false },
1205 + { window: overlay.window, titleBarOverlay: true },
1206 + ],
1207 + });
1208 +
1209 + yield* Effect.gen(function* () {
1210 + const desktopWindow = yield* DesktopWindow.DesktopWindow;
1211 + yield* desktopWindow.syncAppearance;
1212 + }).pipe(Effect.provide(layer));
1213 +
1214 + assert.deepEqual(vi.mocked(framed.window.setBackgroundColor).mock.calls, [["#ffffff"]]);
1215 + assert.lengthOf(vi.mocked(framed.window.setTitleBarOverlay).mock.calls, 0);
1216 + assert.deepEqual(vi.mocked(overlay.window.setBackgroundColor).mock.calls, [["#ffffff"]]);
1217 + assert.lengthOf(vi.mocked(overlay.window.setTitleBarOverlay).mock.calls, 1);
1218 + }),
1219 + );
1220 +
1221 it.effect.each([
1222 { window: "normal", write: "flush" },
1223 { window: "normal", write: "debounce" },
apps/desktop/src/window/DesktopWindow.ts
+4 -3
@@ -343,6 +343,7 @@ function getWindowTitleBarOptions(
343
344 function syncWindowAppearance(
345 window: Electron.BrowserWindow,
346 + hasTitleBarOverlay: boolean,
347 shouldUseDarkColors: boolean,
348 platform: NodeJS.Platform,
349 ): Effect.Effect<void> {
@@ -353,7 +354,7 @@ function syncWindowAppearance(
354
355 window.setBackgroundColor(getInitialWindowBackgroundColor(shouldUseDarkColors));
356 const { titleBarOverlay } = getWindowTitleBarOptions(shouldUseDarkColors, platform);
356 - if (typeof titleBarOverlay === "object") {
357 + if (hasTitleBarOverlay && typeof titleBarOverlay === "object") {
358 window.setTitleBarOverlay(titleBarOverlay);
359 }
360 });
@@ -1202,8 +1203,8 @@ export const make = Effect.gen(function* () {
1203 }),
1204 syncAppearance: Effect.gen(function* () {
1205 const shouldUseDarkColors = yield* electronTheme.shouldUseDarkColors;
1205 - yield* electronWindow.syncAllAppearance((window) =>
1206 - syncWindowAppearance(window, shouldUseDarkColors, environment.platform),
1206 + yield* electronWindow.syncAllAppearance((window, { titleBarOverlay }) =>
1207 + syncWindowAppearance(window, titleBarOverlay, shouldUseDarkColors, environment.platform),
1208 );
1209 }).pipe(Effect.withSpan("desktop.window.syncAppearance")),
1210 });