Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions wework/scripts/dev-windows-app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,10 @@ async function main() {

log(`Sidecar source: ${sidecarSource}`)

log('Preparing DWS sidecar...')
process.env.WEWORK_DWS_TARGET = target
await run('pnpm', ['run', 'prepare:dws'], { cwd: WEWORK_DIR })

if (useDevReload) {
process.env.WEGENT_EXECUTOR_TARGET_DIR = executorTargetDir
}
Expand Down
30 changes: 22 additions & 8 deletions wework/scripts/prepare-dws-binary.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ const packageJson = require.resolve('dingtalk-workspace-cli/package.json')
const packageRoot = dirname(packageJson)
const target =
process.env.WEWORK_DWS_TARGET?.trim() ||
({
{
'darwin-arm64': 'aarch64-apple-darwin',
'darwin-x64': 'x86_64-apple-darwin',
'linux-x64': 'x86_64-unknown-linux-gnu',
'linux-arm64': 'aarch64-unknown-linux-gnu',
'win32-x64': 'x86_64-pc-windows-msvc',
}[`${platform}-${arch}`])
}[`${platform}-${arch}`]

if (!target) throw new Error(`Unsupported DWS build platform: ${platform}-${arch}`)

Expand Down Expand Up @@ -49,14 +49,28 @@ async function findBinary(directory) {
return null
}

try {
const archive = join(packageRoot, 'assets', archiveName)
const command = archiveName.endsWith('.zip') ? 'unzip' : 'tar'
const args = archiveName.endsWith('.zip')
? ['-q', archive, '-d', temporaryDirectory]
: ['-xzf', archive, '-C', temporaryDirectory]
function extractArchive(archive, destination) {
const isZip = archive.endsWith('.zip')
if (process.platform === 'win32') {
if (isZip) {
const result = spawnSync('tar', ['-xf', archive, '-C', destination], { stdio: 'inherit' })
if (result.status !== 0) throw new Error(`Failed to extract ${archiveName}`)
return
}
const result = spawnSync('tar', ['-xzf', archive, '-C', destination], { stdio: 'inherit' })
if (result.status !== 0) throw new Error(`Failed to extract ${archiveName}`)
return
}

const command = isZip ? 'unzip' : 'tar'
const args = isZip ? ['-q', archive, '-d', destination] : ['-xzf', archive, '-C', destination]
const result = spawnSync(command, args, { stdio: 'inherit' })
if (result.status !== 0) throw new Error(`Failed to extract ${archiveName}`)
}

try {
const archive = join(packageRoot, 'assets', archiveName)
extractArchive(archive, temporaryDirectory)
const source = await findBinary(temporaryDirectory)
if (!source) throw new Error(`DWS binary is missing from ${archiveName}`)
const destination = resolve(
Expand Down
15 changes: 15 additions & 0 deletions wework/src/components/layout/DesktopTopBar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,19 @@ describe('DesktopTopBar', () => {
)
).toHaveAttribute('data-tauri-drag-region')
})

test('hides the drag region on Windows to avoid conflicting with the custom titlebar', () => {
Object.defineProperty(navigator, 'userAgent', {
configurable: true,
value: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)',
})
render(
<DesktopTopBar
left={<button type="button">Left</button>}
right={<button type="button">Right</button>}
/>
)

expect(screen.getByTestId('desktop-topbar-drag-region')).toHaveClass('hidden')
Comment on lines +28 to +40

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Restore navigator.userAgent after the test.

This mutates shared test-environment state and can cause later tests to run as Windows, unexpectedly hiding the drag region. Capture the original value and restore it with afterEach or try/finally.

As per coding guidelines, run the focused Wework tests and required formatting/lint checks before committing.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@wework/src/components/layout/DesktopTopBar.test.tsx` around lines 28 - 40,
Restore the shared navigator.userAgent after the Windows-specific test in
DesktopTopBar.test.tsx. Capture its original value before mutation and ensure
cleanup via afterEach or try/finally, while preserving the existing assertion;
then run the focused Wework tests and required formatting/lint checks.

Source: Coding guidelines

})
})
10 changes: 9 additions & 1 deletion wework/src/components/layout/DesktopTopBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { CSSProperties, ReactNode } from 'react'
import { cn } from '@/lib/utils'
import { getPlatform } from '@/lib/platform'
import { MacOSTitleBarDragRegion } from './MacOSTitleBarDragRegion'

export const DESKTOP_TOP_BAR_BUTTON_CLASS =
Expand All @@ -26,6 +27,9 @@ export function DesktopTopBar({
testId = 'desktop-topbar',
style,
}: DesktopTopBarProps) {
const platform = getPlatform()
const dragRegionHidden = platform === 'win'

return (
<header
data-testid={testId}
Expand All @@ -42,7 +46,11 @@ export function DesktopTopBar({
)}
<div
data-testid={`${testId}-drag-region`}
className={cn('min-w-4 flex-1 self-stretch', dragRegionClassName)}
className={cn(
'min-w-4 flex-1 self-stretch',
dragRegionHidden && 'hidden',
dragRegionClassName
)}
>
<MacOSTitleBarDragRegion className="h-full w-full" />
</div>
Expand Down
11 changes: 7 additions & 4 deletions wework/src/components/layout/DesktopWindowsTitlebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ export function DesktopWindowsTitlebar({
<div
data-testid="desktop-windows-titlebar"
data-window-focused={windowFocused}
data-tauri-drag-region
className={cn(
'relative z-chrome flex h-[38px] w-full shrink-0 items-center bg-[rgb(var(--color-sidebar))] backdrop-blur-xl backdrop-saturate-150',
'relative z-chrome h-[38px] w-full shrink-0 bg-[rgb(var(--color-sidebar))] backdrop-blur-xl backdrop-saturate-150',
!windowFocused && 'bg-[rgb(var(--color-sidebar-unfocused))]',
className
)}
>
<div
className="pointer-events-auto flex h-full items-center gap-1 px-1"
className="pointer-events-auto absolute left-0 top-0 z-chrome flex h-full items-center gap-1 px-1"
data-tauri-drag-region={false}
>
<DesktopWindowControls
Expand All @@ -48,8 +49,10 @@ export function DesktopWindowsTitlebar({
/>
<DesktopAppSwitcher activeApp={activeApp} onNavigate={onNavigate} />
</div>
<div data-tauri-drag-region className="min-w-4 flex-1 self-stretch" />
<div className="pointer-events-auto h-full w-[138px]" data-tauri-drag-region={false}>
<div
className="pointer-events-auto absolute right-0 top-0 z-chrome h-full w-[138px]"
data-tauri-drag-region={false}
>
<WindowFrameControls className="h-full justify-end" />
</div>
</div>
Expand Down
Loading