app: make draft screen unhandled areas draggable in Tauri
This commit is contained in:
@@ -49,6 +49,7 @@ import type {
|
|||||||
} from '@server/server/agent/agent-sdk-types'
|
} from '@server/server/agent/agent-sdk-types'
|
||||||
import { AGENT_PROVIDER_DEFINITIONS } from '@server/server/agent/provider-manifest'
|
import { AGENT_PROVIDER_DEFINITIONS } from '@server/server/agent/provider-manifest'
|
||||||
import { buildHostAgentDetailRoute } from '@/utils/host-routes'
|
import { buildHostAgentDetailRoute } from '@/utils/host-routes'
|
||||||
|
import { useTauriDragHandlers } from '@/utils/tauri-window'
|
||||||
|
|
||||||
const DRAFT_AGENT_ID = '__new_agent__'
|
const DRAFT_AGENT_ID = '__new_agent__'
|
||||||
const EMPTY_PENDING_PERMISSIONS = new Map()
|
const EMPTY_PENDING_PERMISSIONS = new Map()
|
||||||
@@ -237,6 +238,7 @@ function DraftAgentScreenContent({
|
|||||||
const activateExplorerTabForCheckout = usePanelStore(
|
const activateExplorerTabForCheckout = usePanelStore(
|
||||||
(state) => state.activateExplorerTabForCheckout
|
(state) => state.activateExplorerTabForCheckout
|
||||||
)
|
)
|
||||||
|
const tauriDragHandlers = useTauriDragHandlers()
|
||||||
const isExplorerOpen = isMobile ? mobileView === 'file-explorer' : desktopFileExplorerOpen
|
const isExplorerOpen = isMobile ? mobileView === 'file-explorer' : desktopFileExplorerOpen
|
||||||
|
|
||||||
const [worktreeMode, setWorktreeMode] = useState<'none' | 'create' | 'attach'>('none')
|
const [worktreeMode, setWorktreeMode] = useState<'none' | 'create' | 'attach'>('none')
|
||||||
@@ -1112,7 +1114,7 @@ function DraftAgentScreenContent({
|
|||||||
const explorerServerId = draftExplorerCheckout?.serverId ?? null
|
const explorerServerId = draftExplorerCheckout?.serverId ?? null
|
||||||
const explorerIsGit = draftExplorerCheckout?.isGit ?? false
|
const explorerIsGit = draftExplorerCheckout?.isGit ?? false
|
||||||
const mainContent = (
|
const mainContent = (
|
||||||
<View style={styles.container}>
|
<View style={styles.container} {...tauriDragHandlers}>
|
||||||
<View style={styles.outerContainer}>
|
<View style={styles.outerContainer}>
|
||||||
<View style={styles.agentPanel}>
|
<View style={styles.agentPanel}>
|
||||||
<View
|
<View
|
||||||
|
|||||||
@@ -4,6 +4,18 @@ import { getIsTauriMac, TAURI_TRAFFIC_LIGHT_WIDTH, TAURI_TRAFFIC_LIGHT_HEIGHT }
|
|||||||
import { getCurrentTauriWindow, getTauri, isTauriEnvironment } from "@/utils/tauri";
|
import { getCurrentTauriWindow, getTauri, isTauriEnvironment } from "@/utils/tauri";
|
||||||
|
|
||||||
let tauriWindow: any = null;
|
let tauriWindow: any = null;
|
||||||
|
const NON_DRAGGABLE_SELECTOR = [
|
||||||
|
"button",
|
||||||
|
"a",
|
||||||
|
"input",
|
||||||
|
"textarea",
|
||||||
|
"select",
|
||||||
|
"[role='button']",
|
||||||
|
"[role='link']",
|
||||||
|
"[role='textbox']",
|
||||||
|
"[role='combobox']",
|
||||||
|
"[contenteditable='true']",
|
||||||
|
].join(", ");
|
||||||
|
|
||||||
async function getTauriWindow() {
|
async function getTauriWindow() {
|
||||||
if (tauriWindow) return tauriWindow;
|
if (tauriWindow) return tauriWindow;
|
||||||
@@ -82,9 +94,10 @@ export function useTauriDragHandlers() {
|
|||||||
onMouseDown: (e: React.MouseEvent) => {
|
onMouseDown: (e: React.MouseEvent) => {
|
||||||
// Only handle primary button, ignore if clicking on interactive elements.
|
// Only handle primary button, ignore if clicking on interactive elements.
|
||||||
// Tauri docs recommend using `e.detail` on mousedown for double-click maximize.
|
// Tauri docs recommend using `e.detail` on mousedown for double-click maximize.
|
||||||
|
if (e.defaultPrevented) return;
|
||||||
if (typeof e.buttons === "number" ? e.buttons !== 1 : e.button !== 0) return;
|
if (typeof e.buttons === "number" ? e.buttons !== 1 : e.button !== 0) return;
|
||||||
const target = e.target as HTMLElement;
|
const target = e.target instanceof Element ? e.target : null;
|
||||||
if (target.closest("button, a, input, [role='button']")) return;
|
if (target?.closest(NON_DRAGGABLE_SELECTOR)) return;
|
||||||
|
|
||||||
// Prevent text selection when dragging
|
// Prevent text selection when dragging
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user