Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/app/e2e/app/shell-frame.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ test("@smoke shell frame exposes stable desktop hooks", async ({ page, gotoSessi
await expect(page.locator(desktopShellFrameSelector)).toBeVisible()
await expect(page.locator(titlebarShellSelector)).toBeVisible()
await expect(page.locator(desktopShellMainSelector)).toBeVisible()
await expect(page.locator(desktopShellSelector)).toHaveAttribute("data-platform", "web")
await expect(page.locator(desktopShellSelector)).toHaveAttribute("data-shell", "desktop")
await expect(page.locator(titlebarShellSelector)).toHaveAttribute("data-shell", "desktop")
await expect(page.locator(titlebarShellSelector)).toHaveAttribute("data-os", "macos")
await expect(page.locator(titlebarLeftSelector)).toHaveCount(1)
await expect(page.locator(titlebarLeftSelector)).toContainText(/new session/i)
await expect(page.locator(`${titlebarRightSelector} button`).first()).toBeVisible()
await expect(page.getByRole("button", { name: /toggle sidebar/i }).first()).toBeVisible()

const titlebarBox = await page.locator(titlebarShellSelector).boundingBox()
expect(Math.round(titlebarBox?.height ?? 0)).toBe(44)

const settings = await openSettings(page)
await expect(settings.getByRole("heading", { level: 2 })).toBeVisible()
await closeSettingsPanel(page, settings)
Expand Down
1 change: 1 addition & 0 deletions packages/app/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default defineConfig({
reuseExistingServer: reuse,
timeout: 120_000,
env: {
VITE_PAWWORK_SHELL_OS: "macos",
Comment thread
Astro-Han marked this conversation as resolved.
Resolved
VITE_OPENCODE_SERVER_HOST: serverHost,
VITE_OPENCODE_SERVER_PORT: serverPort,
},
Expand Down
16 changes: 9 additions & 7 deletions packages/app/src/components/titlebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Button } from "@opencode-ai/ui/button"
import { TooltipKeybind } from "@opencode-ai/ui/tooltip"

import { useLayout } from "@/context/layout"
import { usePlatform } from "@/context/platform"
import { isDesktopShell, isMacShell, isWindowsShell, usePlatform } from "@/context/platform"
Comment thread
Astro-Han marked this conversation as resolved.
Resolved
import { useCommand } from "@/context/command"
import { useLanguage } from "@/context/language"
import { applyPath, backPath, forwardPath } from "./titlebar-history"
Expand All @@ -20,9 +20,10 @@ export function Titlebar() {
const location = useLocation()
const params = useParams()

const mac = createMemo(() => platform.platform === "desktop" && platform.os === "macos")
const windows = createMemo(() => platform.platform === "desktop" && platform.os === "windows")
const web = createMemo(() => platform.platform === "web")
const shellKind = () => platform.shell?.kind ?? (platform.platform === "desktop" ? "desktop" : "web")
const shellOs = () => platform.shell?.os ?? platform.os
Comment thread
Astro-Han marked this conversation as resolved.
Resolved
const mac = createMemo(() => isMacShell(platform))
const windows = createMemo(() => isWindowsShell(platform))
const zoom = () => platform.webviewZoom?.() ?? 1
const currentTitlebarHeight = () =>
mac() ? "var(--shell-titlebar-current-height, var(--shell-titlebar-height, 40px))" : undefined
Expand Down Expand Up @@ -84,9 +85,10 @@ export function Titlebar() {
<header
data-component="titlebar-shell"
data-platform={platform.platform}
data-os={platform.os}
data-shell={shellKind()}
data-os={shellOs()}
class="shrink-0 relative grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center"
classList={{ "h-11": platform.platform === "desktop" && !mac() }}
classList={{ "h-11": isDesktopShell(platform) && !mac() }}
style={{ height: currentTitlebarHeight(), "min-height": currentTitlebarHeight() }}
data-shell-drag-region={!windows() || undefined}
>
Expand All @@ -101,7 +103,7 @@ export function Titlebar() {
</Show>
<div class="flex items-center gap-1 shrink-0">
<TooltipKeybind
class={web() ? "flex shrink-0 ml-14" : "flex shrink-0 ml-2"}
class="flex shrink-0 ml-2"
placement="bottom"
title={language.t("command.sidebar.toggle")}
keybind={command.keybind("sidebar.toggle")}
Expand Down
21 changes: 21 additions & 0 deletions packages/app/src/context/platform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export type Platform = {
/** Platform discriminator */
platform: "web" | "desktop"

/** Visual shell contract. Runtime identity stays separate from appearance. */
shell?: PlatformShell

/** Desktop OS (desktop only) */
os?: "macos" | "windows" | "linux"

Expand Down Expand Up @@ -175,6 +178,24 @@ export type Platform = {

export type DisplayBackend = "auto" | "wayland"

export type PlatformShell = {
kind: "desktop" | "web"
os?: "macos" | "windows" | "linux"
}

export function isDesktopShell(platform: Pick<Platform, "platform" | "shell">) {
const kind = platform.shell?.kind ?? (platform.platform === "desktop" ? "desktop" : "web")
return kind === "desktop"
}

export function isMacShell(platform: Pick<Platform, "platform" | "shell" | "os">) {
return isDesktopShell(platform) && (platform.shell?.os ?? platform.os) === "macos"
}

export function isWindowsShell(platform: Pick<Platform, "platform" | "shell" | "os">) {
return isDesktopShell(platform) && (platform.shell?.os ?? platform.os) === "windows"
}
Comment thread
Astro-Han marked this conversation as resolved.
Resolved

export const { use: usePlatform, provider: PlatformProvider } = createSimpleContext({
name: "Platform",
init: (props: { value: Platform }) => {
Expand Down
11 changes: 11 additions & 0 deletions packages/app/src/entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ const restart: Platform["restart"] = async () => {
window.location.reload()
}

const getShellOs = (): NonNullable<Platform["shell"]>["os"] => {
const override = import.meta.env.VITE_PAWWORK_SHELL_OS
if (override === "macos" || override === "windows" || override === "linux") return override
if (typeof navigator !== "object") return "macos"
const ua = navigator.userAgent
if (ua.includes("Windows")) return "windows"
if (ua.includes("Linux")) return "linux"
return "macos"
}

const root = document.getElementById("root")
if (!(root instanceof HTMLElement) && import.meta.env.DEV) {
throw new Error(getRootNotFoundError())
Expand All @@ -121,6 +131,7 @@ const getDefaultUrl = () => {

const platform: Platform = {
platform: "web",
shell: { kind: "desktop", os: getShellOs() },
version: pkg.version,
openLink,
back,
Expand Down
16 changes: 8 additions & 8 deletions packages/app/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
}

[data-component="desktop-shell"][data-platform="desktop"] {
[data-component="desktop-shell"][data-shell="desktop"] {
--shell-titlebar-height: 44px;
--shell-frame-margin: 12px;
--shell-frame-radius: 12px;
Expand All @@ -58,7 +58,7 @@
linear-gradient(180deg, var(--shell-background-base), var(--shell-background-weak));
}

:root[data-color-scheme="dark"] [data-component="desktop-shell"][data-platform="desktop"] {
:root[data-color-scheme="dark"] [data-component="desktop-shell"][data-shell="desktop"] {
--shell-background-base: #212121;
--shell-background-weak: #181818;
--shell-surface-base: #181818;
Expand Down Expand Up @@ -114,7 +114,7 @@
bg. Right-panel boundary is intentionally NOT drawn into the titlebar
(Mail / Finder / Notes do not split their toolbar) so it never overlaps
with breadcrumb or center-portal content when the panel is wide. */
[data-component="titlebar-shell"][data-platform="desktop"][data-os="macos"] {
[data-component="titlebar-shell"][data-shell="desktop"][data-os="macos"] {
padding-inline: 8px;
background: linear-gradient(
to right,
Expand All @@ -125,25 +125,25 @@
);
}

[data-component="titlebar-shell"][data-platform="desktop"][data-os="macos"] [data-shell-slot="left-portal"] {
[data-component="titlebar-shell"][data-shell="desktop"][data-os="macos"] [data-shell-slot="left-portal"] {
padding-inline: 12px;
}

[data-component="titlebar-shell"] [data-shell-slot="left-portal"] > * {
pointer-events: auto;
}

[data-component="titlebar-shell"][data-platform="desktop"][data-os="macos"]
[data-component="titlebar-shell"][data-shell="desktop"][data-os="macos"]
:is([data-component="button"], [data-component="icon-button"]).titlebar-icon[data-variant="ghost"] {
border-radius: 10px;
}

[data-component="titlebar-shell"][data-platform="desktop"][data-os="macos"]
[data-component="titlebar-shell"][data-shell="desktop"][data-os="macos"]
:is([data-component="button"], [data-component="icon-button"]).titlebar-icon[data-variant="ghost"]:hover:not(:disabled) {
background-color: var(--surface-base-hover);
}

[data-component="desktop-shell-main"][data-platform="desktop"][data-os="macos"] {
[data-component="desktop-shell-main"][data-shell="desktop"][data-os="macos"] {
border-top-width: 0;
}

Expand All @@ -153,7 +153,7 @@
}

@media (min-width: 1280px) {
[data-component="desktop-shell-frame"][data-platform="desktop"][data-os="linux"] {
[data-component="desktop-shell-frame"][data-shell="desktop"][data-os="linux"] {
margin: var(--shell-frame-margin);
border: 1px solid var(--shell-frame-border);
border-radius: var(--shell-frame-radius);
Expand Down
15 changes: 10 additions & 5 deletions packages/app/src/pages/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Button } from "@opencode-ai/ui/button"
import { Dialog } from "@opencode-ai/ui/dialog"
import { getFilename } from "@opencode-ai/util/path"
import { Session, type GlobalSession, type Message } from "@opencode-ai/sdk/v2/client"
import { usePlatform } from "@/context/platform"
import { isMacShell, usePlatform } from "@/context/platform"
Comment thread
Astro-Han marked this conversation as resolved.
Resolved
import { useSettings } from "@/context/settings"
import { createStore, produce, reconcile } from "solid-js/store"
import type { DragEvent } from "@thisbeyond/solid-dnd"
Expand Down Expand Up @@ -2097,6 +2097,8 @@ export default function Layout(props: ParentProps) {
)
const sidebarContent = () =>
renderPawworkPanel(pawworkSessions, { directory: currentProject()?.worktree, scope: "main" })
const shellKind = () => platform.shell?.kind ?? (platform.platform === "desktop" ? "desktop" : "web")
const shellOs = () => platform.shell?.os ?? platform.os
Comment thread
Astro-Han marked this conversation as resolved.
Resolved

return (
<LayoutPageContext.Provider
Expand All @@ -2112,15 +2114,16 @@ export default function Layout(props: ParentProps) {
<div
data-component="desktop-shell"
data-platform={platform.platform}
data-os={platform.os}
data-shell={shellKind()}
data-os={shellOs()}
class="relative bg-background-base flex-1 min-h-0 min-w-0 flex flex-col select-none [&_input]:select-text [&_textarea]:select-text [&_[contenteditable]]:select-text"
classList={{
"[transition:--sidebar-width_200ms_cubic-bezier(0.22,1,0.36,1),--right-panel-width_240ms_cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none":
!state.sizing,
}}
style={{
"--shell-titlebar-current-height":
platform.platform === "desktop" && platform.os === "macos"
isMacShell(platform)
? `calc(var(--shell-titlebar-height, 40px) / ${platform.webviewZoom?.() ?? 1})`
: "var(--shell-titlebar-height, 40px)",
"--sidebar-width": layout.sidebar.opened() ? `${side()}px` : "0px",
Expand All @@ -2131,7 +2134,8 @@ export default function Layout(props: ParentProps) {
<div
data-component="desktop-shell-frame"
data-platform={platform.platform}
data-os={platform.os}
data-shell={shellKind()}
data-os={shellOs()}
class="flex flex-1 min-h-0 min-w-0 flex-col"
>
<Titlebar />
Expand Down Expand Up @@ -2191,7 +2195,8 @@ export default function Layout(props: ParentProps) {
<main
data-component="desktop-shell-main"
data-platform={platform.platform}
data-os={platform.os}
data-shell={shellKind()}
data-os={shellOs()}
classList={{
"size-full overflow-x-hidden flex flex-col items-start contain-strict bg-background-base": true,
}}
Expand Down
37 changes: 28 additions & 9 deletions packages/app/src/shell-frame-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ test("desktop shell shares titlebar height across titlebar and narrow sidebar ge
const sessionHeader = read("./components/session/session-header.tsx")
const pawworkTitlebar = read("./pages/layout/pawwork-titlebar.tsx")
const wideDesktopQuery = css.indexOf("@media (min-width: 1280px)")
const macMainSeamRule = css.indexOf(
'[data-component="desktop-shell-main"][data-platform="desktop"][data-os="macos"] {',
)
const wideFrameRule = css.indexOf(
'[data-component="desktop-shell-frame"][data-platform="desktop"][data-os="linux"] {',
)
const macMainSeamRule = css.indexOf('[data-component="desktop-shell-main"][data-shell="desktop"][data-os="macos"] {')
const wideFrameRule = css.indexOf('[data-component="desktop-shell-frame"][data-shell="desktop"][data-os="linux"] {')

expect(css).toContain('[data-component="desktop-shell"][data-platform="desktop"] {')
expect(css).toContain('[data-component="desktop-shell"][data-shell="desktop"] {')
expect(css).toContain("--shell-titlebar-height: 44px;")
expect(css).not.toContain("--shell-titlebar-height: 40px;")
expect(css).not.toContain("--shell-titlebar-height: 48px;")
Expand All @@ -31,9 +27,9 @@ test("desktop shell shares titlebar height across titlebar and narrow sidebar ge
expect(macMainSeamRule).toBeGreaterThan(-1)
expect(macMainSeamRule).toBeLessThan(wideDesktopQuery)
expect(layout).toContain('"--shell-titlebar-current-height"')
expect(layout).toContain('platform.os === "macos"')
expect(layout).toContain("isMacShell(platform)")
expect(layout).not.toContain("top-10")
expect(titlebar).toContain('"h-11": platform.platform === "desktop" && !mac()')
expect(titlebar).toContain('"h-11": isDesktopShell(platform) && !mac()')
expect(titlebar).toContain('style={{ height: currentTitlebarHeight(), "min-height": currentTitlebarHeight() }}')
expect(titlebar).toContain("--sidebar-width")
expect(titlebar).toContain("--right-panel-width")
Expand All @@ -45,6 +41,29 @@ test("desktop shell shares titlebar height across titlebar and narrow sidebar ge
expect(pawworkTitlebar).toMatch(/document\.getElementById\(["']pawwork-titlebar-center["']\)/)
})

test("web runtime uses the desktop shell without claiming Electron platform identity", () => {
const entry = read("./entry.tsx")
const platform = read("./context/platform.tsx")

expect(entry).toContain('platform: "web"')
expect(entry).toContain('shell: { kind: "desktop"')
expect(entry).toContain("getShellOs")
expect(platform).toContain('shell?: PlatformShell')
expect(platform).toContain("export function isDesktopShell")
expect(platform).toContain("export function isMacShell")
expect(platform).toContain("export function isWindowsShell")
})

test("web favicon uses PawWork branding instead of the inherited OpenCode mark", () => {
const html = read("../index.html")
const favicon = read("../../ui/src/assets/favicon/favicon-v3.svg")

expect(html).toContain("/favicon-v3.svg")
expect(favicon).toContain("#FF6B2B")
expect(favicon).toContain("#FFF8F0")
expect(favicon).not.toContain("#131010")
})

test("session composer is docked outside the scroll-clipped timeline region", () => {
const session = read("./pages/session.tsx")
const sessionMainView = read("./pages/session/session-main-view.tsx")
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-electron/src/main/window-chrome.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test("macOS traffic lights stay centered when shell titlebar height increases",
const wideDesktopQuery = css.indexOf("@media (min-width: 1280px)")

expect(wideDesktopQuery).toBeGreaterThan(-1)
expect(css).toContain('[data-component="desktop-shell"][data-platform="desktop"] {')
expect(css).toContain('[data-component="desktop-shell"][data-shell="desktop"] {')
expect(css).toContain("--shell-titlebar-height: 44px;")
expect(css).not.toContain("--shell-titlebar-height: 40px;")
expect(css).not.toContain("--shell-titlebar-height: 48px;")
Expand Down
1 change: 1 addition & 0 deletions packages/desktop-electron/src/renderer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const createPlatform = (): Platform => {

return {
platform: "desktop",
shell: { kind: "desktop", os },
os,
version: pkg.version,

Expand Down
23 changes: 16 additions & 7 deletions packages/ui/src/assets/favicon/favicon-v3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 16 additions & 7 deletions packages/ui/src/assets/favicon/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading