Skip to content

feat: tauri custom titlebar#198

Merged
flick9000 merged 15 commits into
mainfrom
feat-titlebar
Jun 8, 2026
Merged

feat: tauri custom titlebar#198
flick9000 merged 15 commits into
mainfrom
feat-titlebar

Conversation

@flick9000
Copy link
Copy Markdown
Owner

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Refactoring
  • Style
  • Localization
  • Other

Description

Replaced native titlebar with custom one

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a custom window titlebar for the application. It disables default OS window decorations in tauri.conf.json, configures the necessary Tauri window permissions, and introduces a new Titlebar.astro component with custom controls (minimize, close, bug, and donate buttons). Additionally, layout and style adjustments are made across several components to accommodate the new titlebar. Feedback highlights include renaming the shadowed global window variable and replacing unsafe non-null assertions (!) with optional chaining (?.) in Titlebar.astro, as well as removing a commented-out debug border in Sidebar.astro.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread app/src/components/Titlebar.astro Outdated
Comment on lines +105 to +139
const window = getCurrentWindow();
const title = document.getElementById("title");

function updateTitle(isFocused) {
if (isFocused) {
title!.style.color = "var(--text)";
} else {
title!.style.color = "var(--muted)";
}
}

window.isFocused().then((focused) => {
updateTitle(focused);
});

window.listen("tauri://focus", () => {
updateTitle(true);
});

window.listen("tauri://blur", () => {
updateTitle(false);
});

document.querySelector(".bug")!.addEventListener("click", () => {
open("https://github.com/flick9000/winscript/issues");
});
document.querySelector(".donate")!.addEventListener("click", () => {
open("https://ko-fi.com/flick9000");
});
document.querySelector(".minimize")!.addEventListener("click", () => {
window.minimize();
});
document.querySelector(".close")!.addEventListener("click", () => {
window.close();
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Shadowing the global window object by declaring const window = getCurrentWindow() can lead to unexpected bugs and confusion, as other scripts or browser APIs might rely on the global window object. Additionally, using the non-null assertion operator (!) on DOM queries (e.g., title!, document.querySelector(...)!) can cause runtime crashes if the elements are not yet available in the DOM.

It is highly recommended to rename window to appWindow and use optional chaining (?.) or explicit null checks instead of non-null assertions.

    const appWindow = getCurrentWindow();
    const title = document.getElementById("title");

    function updateTitle(isFocused) {
      if (title) {
        title.style.color = isFocused ? "var(--text)" : "var(--muted)";
      }
    }

    appWindow.isFocused().then((focused) => {
      updateTitle(focused);
    });

    appWindow.listen("tauri://focus", () => {
      updateTitle(true);
    });

    appWindow.listen("tauri://blur", () => {
      updateTitle(false);
    });

    document.querySelector(".bug")?.addEventListener("click", () => {
      open("https://github.com/flick9000/winscript/issues");
    });
    document.querySelector(".donate")?.addEventListener("click", () => {
      open("https://ko-fi.com/flick9000");
    });
    document.querySelector(".minimize")?.addEventListener("click", () => {
      appWindow.minimize();
    });
    document.querySelector(".close")?.addEventListener("click", () => {
      appWindow.close();
    });

Comment on lines 103 to +104
margin-left: 1rem;
/* border: 1px solid red; */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Remove the commented-out debug border style to keep the codebase clean and maintainable.

    margin-left: 1rem;

@flick9000 flick9000 merged commit 306b752 into main Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant