diff --git a/desktop/src-tauri/capabilities/default.json b/desktop/src-tauri/capabilities/default.json index ff9c8375..25089f0d 100644 --- a/desktop/src-tauri/capabilities/default.json +++ b/desktop/src-tauri/capabilities/default.json @@ -5,6 +5,7 @@ "windows": ["main"], "permissions": [ "core:default", + "core:window:allow-start-dragging", "shell:allow-open", { "identifier": "shell:allow-execute", diff --git a/desktop/src-tauri/tauri.conf.json b/desktop/src-tauri/tauri.conf.json index b53987a5..743d2571 100644 --- a/desktop/src-tauri/tauri.conf.json +++ b/desktop/src-tauri/tauri.conf.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/nicegui/nicegui/main/nicegui/static/tauri-schema-v2.json", - "productName": "Claude Code", + "productName": "Claude Code Haha", "version": "0.1.0", "identifier": "com.claude-code.desktop", "build": { @@ -12,7 +12,7 @@ "app": { "windows": [ { - "title": "Claude Code", + "title": "Claude Code Haha", "width": 1280, "height": 800, "minWidth": 900, @@ -20,7 +20,8 @@ "decorations": true, "titleBarStyle": "Overlay", "hiddenTitle": true, - "transparent": false + "transparent": false, + "acceptFirstMouse": true } ], "security": { diff --git a/desktop/src/components/layout/AppShell.tsx b/desktop/src/components/layout/AppShell.tsx index ea20b1fa..5a071e2c 100644 --- a/desktop/src/components/layout/AppShell.tsx +++ b/desktop/src/components/layout/AppShell.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react' +import { useEffect, useState, useCallback, useRef } from 'react' import { Sidebar } from './Sidebar' import { ContentRouter } from './ContentRouter' import { ToastContainer } from '../shared/Toast' @@ -12,6 +12,7 @@ export function AppShell() { const fetchSettings = useSettingsStore((s) => s.fetchAll) const [ready, setReady] = useState(false) const [startupError, setStartupError] = useState(null) + const startDraggingRef = useRef<(() => Promise) | null>(null) useEffect(() => { let cancelled = false @@ -38,6 +39,22 @@ export function AppShell() { } }, [fetchSettings]) + // Pre-cache Tauri window drag function + useEffect(() => { + if (!isTauri) return + import(/* @vite-ignore */ '@tauri-apps/api/window') + .then(({ getCurrentWindow }) => { + const win = getCurrentWindow() + startDraggingRef.current = () => win.startDragging() + }) + .catch(() => {}) + }, []) + + const handleDragMouseDown = useCallback((e: React.MouseEvent) => { + if ((e.target as HTMLElement).closest('button, input, textarea, select, a, [role="button"]')) return + startDraggingRef.current?.() + }, []) + useKeyboardShortcuts() if (startupError) { @@ -65,12 +82,12 @@ export function AppShell() { return (
- {/* Drag region for macOS Overlay title bar — only relevant in Tauri */} + {/* Drag region for macOS Overlay title bar — full width strip at the top */} {isTauri && (
)} diff --git a/desktop/src/components/layout/Sidebar.tsx b/desktop/src/components/layout/Sidebar.tsx index 7a4009ae..603f7c62 100644 --- a/desktop/src/components/layout/Sidebar.tsx +++ b/desktop/src/components/layout/Sidebar.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState, useCallback, useMemo } from 'react' +import { useEffect, useState, useCallback, useMemo, useRef } from 'react' import { useSessionStore } from '../../stores/sessionStore' import { useUIStore } from '../../stores/uiStore' import { useTranslation } from '../../i18n' @@ -80,6 +80,23 @@ export function Sidebar() { setRenameValue('') }, [renamingId, renameValue, renameSession]) + const startDraggingRef = useRef<(() => Promise) | null>(null) + + useEffect(() => { + if (!isTauri) return + import(/* @vite-ignore */ '@tauri-apps/api/window') + .then(({ getCurrentWindow }) => { + const win = getCurrentWindow() + startDraggingRef.current = () => win.startDragging() + }) + .catch(() => {}) + }, []) + + const handleSidebarDrag = useCallback((e: React.MouseEvent) => { + if ((e.target as HTMLElement).closest('button, input, textarea, select, a, [role="button"]')) return + startDraggingRef.current?.() + }, []) + const t = useTranslation() const TIME_GROUP_LABELS: Record = { @@ -91,7 +108,7 @@ export function Sidebar() { } return ( -