From 69c920982b055170d403965c72e8906f4084c6f7 Mon Sep 17 00:00:00 2001 From: Steven Enamakel <31011319+senamakel@users.noreply.github.com> Date: Fri, 26 Jun 2026 10:16:57 -0700 Subject: [PATCH] fix(context): super-context bundle injection + dedup robustness (#4173) --- .../layout/shell/RootShellLayout.tsx | 9 +- .../layout/shell/WindowDragBar.test.tsx | 41 +++++ .../components/layout/shell/WindowDragBar.tsx | 49 ++++++ .../agent/harness/session/turn/core.rs | 8 + .../tools/agent_prepare_context.rs | 160 +++++++++++------- tests/agent_harness_e2e.rs | 75 ++++++++ 6 files changed, 281 insertions(+), 61 deletions(-) create mode 100644 app/src/components/layout/shell/WindowDragBar.test.tsx create mode 100644 app/src/components/layout/shell/WindowDragBar.tsx diff --git a/app/src/components/layout/shell/RootShellLayout.tsx b/app/src/components/layout/shell/RootShellLayout.tsx index 871e0bcf2..00cda6c96 100644 --- a/app/src/components/layout/shell/RootShellLayout.tsx +++ b/app/src/components/layout/shell/RootShellLayout.tsx @@ -11,6 +11,7 @@ import { } from '../../../store/layoutSlice'; import { Tooltip } from '../../ui'; import CollapsedNavRail from './CollapsedNavRail'; +import WindowDragBar from './WindowDragBar'; // `app-shell` (not the older `root-shell`) so the persisted geometry seeds // fresh with the sidebar visible by default. Exported so the global command @@ -212,8 +213,14 @@ export default function RootShellLayout({ sidebar, children }: RootShellLayoutPr )} -
+
{children} + {/* macOS overlay-title-bar drag strip — a transparent overlay pinned on + TOP of the routed view (last child) so full-bleed surfaces (Tiny + Place world, Chat backdrop) stay edge-to-edge while the top of the + window still drags. The sidebar is excluded — its header already + drags in place. No-op off macOS / outside Tauri. */} +
); diff --git a/app/src/components/layout/shell/WindowDragBar.test.tsx b/app/src/components/layout/shell/WindowDragBar.test.tsx new file mode 100644 index 000000000..b779c1b2a --- /dev/null +++ b/app/src/components/layout/shell/WindowDragBar.test.tsx @@ -0,0 +1,41 @@ +import { cleanup, render } from '@testing-library/react'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; + +import WindowDragBar, { WINDOW_DRAG_BAR_HEIGHT } from './WindowDragBar'; + +// Both gates are mocked so we can drive every platform combination. +const isMac = vi.fn(); +const isTauri = vi.fn(); +vi.mock('../../../lib/commands/shortcut', () => ({ isMac: () => isMac() })); +vi.mock('../../../utils/tauriCommands/common', () => ({ isTauri: () => isTauri() })); + +describe('WindowDragBar', () => { + beforeEach(() => { + isMac.mockReset(); + isTauri.mockReset(); + }); + afterEach(cleanup); + + it('renders a draggable strip on macOS inside Tauri', () => { + isMac.mockReturnValue(true); + isTauri.mockReturnValue(true); + const { container } = render(); + const bar = container.querySelector('[data-tauri-drag-region]'); + expect(bar).not.toBeNull(); + expect((bar as HTMLElement).style.height).toBe(`${WINDOW_DRAG_BAR_HEIGHT}px`); + }); + + it('renders nothing on macOS outside Tauri (plain browser)', () => { + isMac.mockReturnValue(true); + isTauri.mockReturnValue(false); + const { container } = render(); + expect(container.querySelector('[data-tauri-drag-region]')).toBeNull(); + }); + + it('renders nothing inside Tauri on non-macOS (native title bar handles drag)', () => { + isMac.mockReturnValue(false); + isTauri.mockReturnValue(true); + const { container } = render(); + expect(container.querySelector('[data-tauri-drag-region]')).toBeNull(); + }); +}); diff --git a/app/src/components/layout/shell/WindowDragBar.tsx b/app/src/components/layout/shell/WindowDragBar.tsx new file mode 100644 index 000000000..808412b99 --- /dev/null +++ b/app/src/components/layout/shell/WindowDragBar.tsx @@ -0,0 +1,49 @@ +import { isMac } from '../../../lib/commands/shortcut'; +import { isTauri } from '../../../utils/tauriCommands/common'; + +/** + * Height (px) of the drag strip. Matches the macOS traffic-light zone so the + * native window controls sit within the band. + */ +export const WINDOW_DRAG_BAR_HEIGHT = 28; + +/** + * Transparent macOS window-drag strip for the overlay title bar. + * + * The main window runs with `titleBarStyle: "Overlay"` + `hiddenTitle` (see + * `app/src-tauri/tauri.conf.json`), so macOS draws transparent traffic lights + * over the web content but does NOT make the top draggable on its own — the + * webview captures the pointer events. We opt back in with a `data-tauri-drag- + * region` strip. + * + * Rendered as an absolutely-positioned overlay pinned to the top of the main + * content pane ({@link RootShellLayout}), as the LAST child so it paints ON TOP + * of the routed view. That keeps full-bleed HTML surfaces (the Tiny Place world + * canvas, the Chat backdrop) edge-to-edge — the strip floats over them and + * drags the window — instead of a reserved inset that would push them down and + * reveal the app background above them. It occupies no layout space and is + * transparent. + * + * A drag region must be the top-most element under the pointer, so the band + * does sit over the top ~28px of the pane: page chrome with controls in that + * band keeps the bulk of each control clickable below the strip, and the + * traffic lights (native, composited above the webview) are always clickable. + * The sidebar is intentionally excluded — its header already drags in place. + * Native CEF provider webviews composite above all HTML and so can't be dragged + * through; that's a platform limit, not this strip. + * + * macOS-only: Windows/Linux keep their native decorated title bar (the + * `Overlay` style is a no-op there). Outside the Tauri runtime (browser/iOS) + * there is no window to drag, so it renders nothing. + */ +export default function WindowDragBar() { + if (!isTauri() || !isMac()) return null; + return ( +