-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add custom title bar for Windows #1800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lintowe
wants to merge
6
commits into
pingdotgg:main
Choose a base branch
from
lintowe:feat/windows-titlebar-context-cleanup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4cc5bbf
feat(desktop): add windows custom title bar and window controls bridge
lintowe 5b33d8f
Refine Windows custom title bar context and remove chat badge
lintowe 5ee101f
Merge branch 'main' into feat/windows-titlebar-context-cleanup
lintowe 2be07d2
Merge branch 'main' into feat/windows-titlebar-context-cleanup
lintowe 55567f3
Merge branch 'main' into feat/windows-titlebar-context-cleanup
lintowe 8865c0e
Merge branch 'main' into feat/windows-titlebar-context-cleanup
lintowe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import type { ReactNode } from "react"; | ||
|
|
||
| import { cn } from "~/lib/utils"; | ||
|
|
||
| import { DesktopWindowControls } from "./DesktopWindowControls"; | ||
|
|
||
| interface DesktopTitleBarProps { | ||
| title: string; | ||
| subtitle?: string; | ||
| contextLabel?: string; | ||
| contextValue?: string; | ||
| showContextChip?: boolean; | ||
| trailing?: ReactNode; | ||
| className?: string; | ||
| showWindowControls?: boolean; | ||
| } | ||
|
|
||
| export function DesktopTitleBar(props: DesktopTitleBarProps) { | ||
| const showContextChip = props.showContextChip ?? true; | ||
| const contextLabel = props.contextLabel ?? "Workspace"; | ||
| const contextValue = props.contextValue; | ||
|
|
||
| return ( | ||
| <div | ||
| className={cn( | ||
| "drag-region relative flex h-[44px] shrink-0 items-center border-b border-border/70 bg-[linear-gradient(90deg,color-mix(in_srgb,var(--background)_95%,var(--color-black)_5%)_0%,var(--background)_65%,color-mix(in_srgb,var(--background)_94%,var(--color-black)_6%)_100%)] px-3", | ||
| props.className, | ||
| )} | ||
| > | ||
| {showContextChip ? ( | ||
| <div className="min-w-0 max-w-[40%] truncate"> | ||
| <div className="inline-flex items-center gap-2 rounded-md border border-border/60 bg-card/70 px-2 py-1 text-[11px] leading-none"> | ||
| <span className="inline-flex size-4 items-center justify-center rounded-sm bg-foreground text-[9px] font-semibold text-background"> | ||
| T3 | ||
| </span> | ||
| <span className="truncate font-medium tracking-tight text-foreground/85"> | ||
| {contextLabel} | ||
| </span> | ||
| {contextValue ? ( | ||
| <span className="rounded-full bg-muted px-1.5 py-0.5 text-[9px] font-semibold tracking-[0.14em] uppercase text-muted-foreground"> | ||
| {contextValue} | ||
| </span> | ||
| ) : null} | ||
| </div> | ||
| </div> | ||
| ) : null} | ||
|
|
||
| <div className="pointer-events-none absolute inset-0 flex min-w-0 items-center justify-center px-[8.5rem]"> | ||
| <div className="min-w-0 text-center"> | ||
| <div className="truncate text-[12px] font-medium text-foreground/90">{props.title}</div> | ||
| {props.subtitle ? ( | ||
| <div className="truncate text-[10px] text-muted-foreground/85">{props.subtitle}</div> | ||
| ) : null} | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="ms-auto flex shrink-0 items-center gap-1.5 [-webkit-app-region:no-drag]"> | ||
| {props.trailing} | ||
| {props.showWindowControls === false ? null : <DesktopWindowControls />} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { renderToStaticMarkup } from "react-dom/server"; | ||
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import { DesktopWindowControls } from "./DesktopWindowControls"; | ||
|
|
||
| function setDesktopBridge(value: unknown) { | ||
| vi.stubGlobal("window", { | ||
| desktopBridge: value, | ||
| }); | ||
| } | ||
|
|
||
| describe("DesktopWindowControls", () => { | ||
| afterEach(() => { | ||
| vi.unstubAllGlobals(); | ||
| }); | ||
|
|
||
| it("does not render controls when desktop bridge APIs are unavailable", () => { | ||
| setDesktopBridge(undefined); | ||
| const html = renderToStaticMarkup(<DesktopWindowControls />); | ||
|
|
||
| expect(html).toBe(""); | ||
| }); | ||
|
|
||
| it("renders controls when desktop bridge APIs are available", () => { | ||
| setDesktopBridge({ | ||
| minimizeWindow: async () => undefined, | ||
| toggleMaximizeWindow: async () => ({ maximized: false }), | ||
| closeWindow: async () => undefined, | ||
| getWindowState: async () => ({ maximized: false }), | ||
| onWindowState: () => () => undefined, | ||
| }); | ||
| const html = renderToStaticMarkup(<DesktopWindowControls />); | ||
|
|
||
| expect(html).toContain("Minimize window"); | ||
| expect(html).toContain("Maximize window"); | ||
| expect(html).toContain("Close window"); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Close handler fallback may close wrong window
Medium Severity
The
resolveEventWindowhelper, used by window IPC handlers, includes a fallback tomainWindowor any other active window if the event sender's window cannot be resolved. For theCLOSE_WINDOW_CHANNELhandler, this fallback can cause an unrelated window to close, risking unexpected data loss.Reviewed by Cursor Bugbot for commit 2be07d2. Configure here.