Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): 修复 Duo 文件预览顶栏与状态栏、系统竖栏的布局

Dashef1eecaffaa5
diff --git a/apps/mobile/app/(auth)/login.tsx b/apps/mobile/app/(auth)/login.tsx
index c8b8412371..4b8bb65d4c 100644
--- a/apps/mobile/app/(auth)/login.tsx
+++ b/apps/mobile/app/(auth)/login.tsx
@@ -1376,7 +1376,7 @@ export function LoginScreen({
) : null}
{additionalAccount && onClose ? (
- <View style={{ position: 'absolute', right: spacing.lg, top: insets.top + spacing.sm, zIndex: 20 }}>
+ <View style={{ position: 'absolute', right: insets.right + spacing.lg, top: insets.top + spacing.sm, zIndex: 20 }}>
<HomeHeaderGlassButton accessibilityLabel={t('shared.closePanel')}
disabled={auth.isBusy} onPress={onClose} testID="login.closeButton">
<X color={colors.textPrimary} size={iconSize.action} strokeWidth={iconStroke.regular} />
diff --git a/apps/mobile/app/files/preview/[sessionId].tsx b/apps/mobile/app/files/preview/[sessionId].tsx
index c380b7c1a5..fb6e4e1ef6 100644
--- a/apps/mobile/app/files/preview/[sessionId].tsx
+++ b/apps/mobile/app/files/preview/[sessionId].tsx
@@ -66,6 +66,7 @@ import { HtmlBrowserChrome } from '@/session/HtmlBrowserChrome';
import { HtmlWebsiteBrowser, type WebsiteVisit } from '@/session/HtmlWebsiteBrowser';
import { normalizeBrowserAddress } from '@/session/browserAddress';
import { HTML_BROWSER_CONTROL_SIZE, type HtmlBrowserChromeProps } from '@/session/HtmlBrowserChrome.types';
+import { usePreviewChromeFrame } from '@/session/usePreviewChromeFrame';
import type { MobileHtmlPreview } from '@/session/mobileHtmlPreview';
import { prepareMobileHtmlPreview, type PrepareMobileHtmlPreview } from '@/session/mobileHtmlPreview';
import { useHtmlSnapshot } from '@/session/useHtmlSnapshot';
@@ -197,7 +198,7 @@ function RemoteFilePreviewContent() {
const targetLine = Number.isInteger(targetLineRaw) && targetLineRaw > 0 ? targetLineRaw : null;
const router = useRouter();
const previewWindow = useAdaptiveWindow();
- const pageInsets = useSafeAreaInsets();
+ const chromeFrame = usePreviewChromeFrame();
const [measuredPageWidth, setMeasuredPageWidth] = useState<number | null>(null);
const pageWidth = measuredPageWidth ?? Math.max(1, previewWindow.width - previewWindow.insets.left - previewWindow.insets.right);
const { openLink } = useDeviceLink();
@@ -633,10 +634,10 @@ function RemoteFilePreviewContent() {
path={absolutePathOf(pendingPath)}
address={absolutePathOf(pendingPath)}
onNavigate={() => true}
- top={pageInsets.top}
- bottom={pageInsets.bottom}
- left={pageInsets.left + spacing.md}
- right={pageInsets.right + spacing.md}
+ top={chromeFrame.top}
+ bottom={chromeFrame.bottom}
+ left={chromeFrame.left}
+ right={chromeFrame.right}
canGoBack={false}
canGoForward={false}
source={false}
@@ -670,10 +671,10 @@ function RemoteFilePreviewContent() {
document
title={pathDisplayName(pendingPath)}
path={absolutePathOf(pendingPath)}
- top={pageInsets.top}
- bottom={pageInsets.bottom}
- left={pageInsets.left + spacing.md}
- right={pageInsets.right + spacing.md}
+ top={chromeFrame.top}
+ bottom={chromeFrame.bottom}
+ left={chromeFrame.left}
+ right={chromeFrame.right}
busy
pending
onClose={() => goBackGuarded(router)}
@@ -835,8 +836,9 @@ function FilePreviewPage({
const { t } = useTranslation();
const styles = useThemedStyles(makeStyles);
const insets = useSafeAreaInsets();
+ const chromeFrame = usePreviewChromeFrame();
const contentPadding = {
- paddingTop: insets.top + HTML_BROWSER_CONTROL_SIZE + spacing.xs,
+ paddingTop: chromeFrame.contentTop,
paddingBottom: insets.bottom + spacing.xs,
paddingLeft: insets.left,
paddingRight: insets.right,
@@ -891,10 +893,10 @@ function FilePreviewPage({
{...htmlBrowserActions}
title={item.name}
path={absolutePathOf(item.relPath)}
- top={insets.top}
- bottom={insets.bottom}
- left={insets.left + spacing.md}
- right={insets.right + spacing.md}
+ top={chromeFrame.top}
+ bottom={chromeFrame.bottom}
+ left={chromeFrame.left}
+ right={chromeFrame.right}
/> : null}
</View>
);
@@ -1042,8 +1044,9 @@ function PdfPreviewPage({
workdir: string;
}) {
const insets = useSafeAreaInsets();
+ const chromeFrame = usePreviewChromeFrame();
const { viewRef, measure, viewportStyle, obscuredContentInsets } = useHtmlBrowserViewport({
- top: insets.top + HTML_BROWSER_CONTROL_SIZE + spacing.xs,
+ top: chromeFrame.contentTop,
bottom: insets.bottom + spacing.xs,
left: insets.left,
right: insets.right,
@@ -1172,9 +1175,10 @@ function TextPreviewPage({
const richKind = richTextKindOf(item.relPath);
const insets = useSafeAreaInsets();
// Sit directly against the safe-area edges; only a small gap separates page content.
- const browserTop = insets.top;
- const browserBottom = insets.bottom;
- const browserContentInset = { top: browserTop + HTML_BROWSER_CONTROL_SIZE + spacing.xs, bottom: browserBottom + (richKind === 'html' ? HTML_BROWSER_CONTROL_SIZE : 0) + spacing.xs };
+ const chromeFrame = usePreviewChromeFrame();
+ const browserTop = chromeFrame.top;
+ const browserBottom = chromeFrame.bottom;
+ const browserContentInset = { top: chromeFrame.contentTop, bottom: browserBottom + (richKind === 'html' ? HTML_BROWSER_CONTROL_SIZE : 0) + spacing.xs };
const browserRef = useRef<WebView>(null);
const [website, setWebsite] = useState<WebsiteVisit | null>(null);
const [browserNavigation, setBrowserNavigation] = useState<{
@@ -1297,7 +1301,7 @@ function TextPreviewPage({
if (website) return visible ? <HtmlWebsiteBrowser
visit={website}
insets={{ ...browserContentInset, left: insets.left, right: insets.right }}
- chrome={{ top: browserTop, bottom: browserBottom, left: insets.left + spacing.md, right: insets.right + spacing.md, onClose: htmlBrowserActions.onClose }}
+ chrome={{ top: browserTop, bottom: browserBottom, left: chromeFrame.left, right: chromeFrame.right, onClose: htmlBrowserActions.onClose }}
onReturn={() => { setBrowserNavigation(null); setWebsite(null); }}
/> : <View style={styles.textPage} />;
@@ -1412,8 +1416,8 @@ function TextPreviewPage({
path={absolutePathOf(item.relPath)}
top={browserTop}
bottom={browserBottom}
- left={insets.left + spacing.md}
- right={insets.right + spacing.md}
+ left={chromeFrame.left}
+ right={chromeFrame.right}
source={richView === 'source'}
onToggleSource={canRenderRich ? () => setRichView(value => value === 'rendered' ? 'source' : 'rendered') : undefined}
/> : null}
@@ -1435,8 +1439,8 @@ function TextPreviewPage({
}}
top={browserTop}
bottom={browserBottom}
- left={insets.left + spacing.md}
- right={insets.right + spacing.md}
+ left={chromeFrame.left}
+ right={chromeFrame.right}
source={richView === 'source'}
loading={richView === 'rendered' && !htmlError && (!htmlSnapshot.preview || navigation?.loading === true)}
canGoBack={richView === 'source' || navigation?.canGoBack === true}
diff --git a/apps/mobile/src/__tests__/filePreviewCacheRendering.test.tsx b/apps/mobile/src/__tests__/filePreviewCacheRendering.test.tsx
index 679652e102..bdf4725fa9 100644
--- a/apps/mobile/src/__tests__/filePreviewCacheRendering.test.tsx
+++ b/apps/mobile/src/__tests__/filePreviewCacheRendering.test.tsx
@@ -39,6 +39,7 @@ vi.mock('expo-router', () => {
});
vi.mock('@/platform/chrome/SystemNavigationBack', () => ({ SystemNavigationBack: () => null, useSystemNavigationBack: () => false }));
vi.mock('@/platform/AdaptiveWindowContext', () => ({ useAdaptiveWindow: () => ({ width: 390, insets: { left: 0, right: 0 } }) }));
+vi.mock('@/session/usePreviewChromeFrame', () => ({ usePreviewChromeFrame: () => ({ top: 0, bottom: 0, left: 12, right: 12, contentTop: 48, sharedStatusRow: false }) }));
vi.mock('@/auth/AuthContext', () => { const auth = {}; return { useAuth: () => auth }; });
vi.mock('@/device-link/DeviceLinkContext', () => { const link = { openLink: async () => {} }; return { useDeviceLink: () => link }; });
vi.mock('@/device-link/unresponsiveDevicesStore', () => { const devices = new Set(); return { useUnresponsiveDevices: () => devices }; });
diff --git a/apps/mobile/src/__tests__/windowGeometry.test.ts b/apps/mobile/src/__tests__/windowGeometry.test.ts
index be4d0b6580..02e2288309 100644
--- a/apps/mobile/src/__tests__/windowGeometry.test.ts
+++ b/apps/mobile/src/__tests__/windowGeometry.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
-import { keyboardControlRegion, controlRegion, sharedStatusRowDrawerTop, windowDivision, type WindowGeometry } from '@/platform/windowGeometry';
+import { keyboardControlRegion, controlRegion, floatingTopRow, sharedStatusRowDrawerTop, windowDivision, type WindowGeometry } from '@/platform/windowGeometry';
import { foldDesktopLayout } from '@/remote-desktop/foldDesktopLayout';
import { sessionPaneLayout } from '@/session/sessionPaneLayout';
@@ -114,3 +114,24 @@ describe('task-list drawer top when the system bar shares the status row', () =>
expect(sharedStatusRowDrawerTop(0, 82)).toBeUndefined();
});
});
+
+// Regression: Duo file preview (2026-10-29). Its floating close/title/menu row sat under the whole
+// status area in portrait, and against the top screen edge (clipped) beside the landscape rail.
+describe('floating top row beside the Duo status area', () => {
+ const portrait = (patch: Partial<WindowGeometry> = {}) => window({ width: 662, height: 942, barEdge: 'none',
+ insets: { top: 82, left: 0, right: 0, bottom: 20 },
+ regions: [{ kind: 'occlusion', x: 520, y: 0, width: 142, height: 82 }], ...patch });
+ it('shares the status row in portrait, ending before the status area', () => {
+ expect(floatingTopRow(portrait(), 44)).toEqual({ top: 26, left: 12, right: 150, sharedStatusRow: true });
+ });
+ it('keeps the row below the status area for ordinary bars, other reservations and narrow rows', () => {
+ const below = { top: 82, left: 12, right: 12, sharedStatusRow: false };
+ expect(floatingTopRow(portrait({ regions: [] }), 44)).toEqual(below);
+ expect(floatingTopRow(portrait({ reservedRegionsSupported: false }), 44)).toEqual(below);
+ expect(floatingTopRow(portrait({ regions: [...portrait().regions, { kind: 'occlusion', x: 280, y: 20, width: 100, height: 40 }] }), 44)).toEqual(below);
+ expect(floatingTopRow(portrait({ width: 300, regularWidth: false, regions: [{ kind: 'occlusion', x: 160, y: 0, width: 140, height: 82 }] }), 44)).toMatchObject({ sharedStatusRow: false });
+ });
+ it('keeps a margin from the top edge beside a vertical system bar', () => {
+ expect(floatingTopRow(window(), 44)).toEqual({ top: 12, left: 12, right: 72, sharedStatusRow: false });
+ });
+});
diff --git a/apps/mobile/src/platform/windowGeometry.ts b/apps/mobile/src/platform/windowGeometry.ts
index eb4c81ac8c..baf448bfb8 100644
--- a/apps/mobile/src/platform/windowGeometry.ts
+++ b/apps/mobile/src/platform/windowGeometry.ts
@@ -75,6 +75,29 @@ export function keyboardControlRegion(g: WindowGeometry, keyboardBottom: number)
return alternative.height > controls.height ? alternative : controls;
}
+/**
+ * Edges of a page's own floating top row (close, title, menu) where no native bar hosts it.
+ * Duo portrait reports its status area as a trailing-corner reservation; like the native bar,
+ * the row then shares that status row, its controls `spacing.md` above the row's bottom and
+ * ending before the reservation. A vertical system bar (Duo landscape) leaves no top inset,
+ * so the row keeps its own margin from the screen edge.
+ */
+export function floatingTopRow(g: WindowGeometry, rowHeight: number): {
+ top: number; left: number; right: number; sharedStatusRow: boolean;
+} {
+ const left = g.insets.left + spacing.md, right = g.insets.right + spacing.md;
+ if (g.barEdge !== 'none') return { top: Math.max(g.insets.top, spacing.md), left, right, sharedStatusRow: false };
+ const ordinary = { top: g.insets.top, left, right, sharedStatusRow: false };
+ const status = g.regions.filter(r => r.kind === 'occlusion' && r.y === 0 && r.x + r.width >= g.width);
+ const top = g.insets.top - rowHeight - spacing.md;
+ if (!g.reservedRegionsSupported || !g.regularWidth || !status.length || top < spacing.md) return ordinary;
+ const sharedRight = Math.max(right, g.width - Math.min(...status.map(r => r.x)) + spacing.sm);
+ const row = { x: left, y: top, width: g.width - left - sharedRight, height: rowHeight };
+ // Close, title and menu must all fit beside the status area, clear of any other reservation.
+ if (row.width < rowHeight * 5 || avoidReservedRegions(row, g.regions.filter(r => !status.includes(r))) !== row) return ordinary;
+ return { top, left, right: sharedRight, sharedStatusRow: true };
+}
+
/**
* Top padding for the temporary task-list drawer when the native top bar shares the status row
* (Duo portrait), so the drawer header lands where the hidden bar's buttons were. Duo (iOS 27.1)
diff --git a/apps/mobile/src/plugins/PluginNativeIntent.tsx b/apps/mobile/src/plugins/PluginNativeIntent.tsx
index e3447a3534..3bb5002a5e 100644
--- a/apps/mobile/src/plugins/PluginNativeIntent.tsx
+++ b/apps/mobile/src/plugins/PluginNativeIntent.tsx
@@ -151,7 +151,7 @@ export function PluginNativeIntent({
<HtmlWebsiteBrowser
visit={{ url: intent.url, snapshotClosed: closed }}
insets={{ top: 0, bottom: 44, left: 0, right: 0 }}
- chrome={{ top: 0, bottom: 0, left: 0, right: 0, onClose }}
+ chrome={{ top: 0, bottom: 0, left: 0, right: 0, standalone: true, onClose }}
onReturn={onClose}
/>
)}
diff --git a/apps/mobile/src/session/BotGroupTextAttachmentPreview.tsx b/apps/mobile/src/session/BotGroupTextAttachmentPreview.tsx
index d205101d8f..0889c4c746 100644
--- a/apps/mobile/src/session/BotGroupTextAttachmentPreview.tsx
+++ b/apps/mobile/src/session/BotGroupTextAttachmentPreview.tsx
@@ -129,7 +129,7 @@ export function BotGroupTextAttachmentPreview({ attachmentId, fileName, kind, re
return (
<Modal visible animationType="slide" presentationStyle="fullScreen" onRequestClose={onClose}>
<SafeAreaProvider>
- <SafeAreaView edges={['top', 'bottom']} style={[styles.fill, { backgroundColor: colors.surface }]}>
+ <SafeAreaView edges={['top', 'bottom', 'left', 'right']} style={[styles.fill, { backgroundColor: colors.surface }]}>
<View style={[styles.header, { borderBottomColor: colors.border }]}>
<Pressable
accessibilityRole="button"
diff --git a/apps/mobile/src/session/HtmlBrowserChrome.ios.tsx b/apps/mobile/src/session/HtmlBrowserChrome.ios.tsx
index 92e22a4e39..a10ca0477f 100644
--- a/apps/mobile/src/session/HtmlBrowserChrome.ios.tsx
+++ b/apps/mobile/src/session/HtmlBrowserChrome.ios.tsx
@@ -33,6 +33,7 @@ import {
shapes,
} from "@expo/ui/swift-ui/modifiers";
import { ActivityIndicator, Alert, StyleSheet, View } from "react-native";
+import { Stack } from "expo-router";
import { useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { Text } from "@/components/AppText";
@@ -40,6 +41,7 @@ import { MainWindowActionButton } from "@/components/MobilePrimitives";
import { SystemNavigationBack, useSystemNavigationBack } from "@/platform/chrome/SystemNavigationBack";
import { iconSize, lineHeight, navigationChrome, radius, spacing, typeScale, useTheme } from "@/theme";
import { useLiquidGlassAvailable } from "./useLiquidGlassAvailable";
+import { usePreviewChromeFrame } from "./usePreviewChromeFrame";
import {
HTML_BROWSER_CONTROL_SIZE as size,
type HtmlBrowserChromeProps,
@@ -51,7 +53,11 @@ export function HtmlBrowserChrome(p: HtmlBrowserChromeProps | DocumentPreviewChr
const { colors, mode } = useTheme();
const { t } = useTranslation();
const glass = useLiquidGlassAvailable();
- const systemBack = useSystemNavigationBack();
+ // A vertical system bar (Duo landscape) hosts close and the document menu as native items.
+ const systemBack = useSystemNavigationBack() && !p.standalone;
+ const sharedStatusRow = usePreviewChromeFrame().sharedStatusRow && !p.standalone;
+ // Center the document title on screen, except beside a status area sharing its row.
+ const centeredTitle = p.document && !sharedStatusRow;
const [editing, setEditing] = useState(false);
const addressText = useNativeState(p.document ? '' : p.address);
const addressRef = useRef<TextFieldRef>(null);
@@ -150,27 +156,48 @@ export function HtmlBrowserChrome(p: HtmlBrowserChromeProps | DocumentPreviewChr
);
return (
<View pointerEvents="box-none" style={StyleSheet.absoluteFill}>
- <SystemNavigationBack
+ {p.standalone ? null : <SystemNavigationBack
close
- available={p.document === true}
label={t("files.preview.done")}
onPress={p.onClose}
- />
+ />}
+ {systemBack && p.document ? <Stack.Toolbar placement="right">
+ <Stack.Toolbar.Menu icon="ellipsis" disabled={p.pending === true}
+ accessibilityLabel={t("files.preview.browserMore")}>
+ <Stack.Toolbar.MenuAction icon="square.and.arrow.up" disabled={p.busy} onPress={p.onShare}>
+ {t("files.preview.a11yShare")}
+ </Stack.Toolbar.MenuAction>
+ <Stack.Toolbar.Menu inline title={p.title}>
+ <Stack.Toolbar.MenuAction icon="doc" onPress={showFileInfo}>
+ {t("files.preview.browserFileInfo")}
+ </Stack.Toolbar.MenuAction>
+ </Stack.Toolbar.Menu>
+ {p.onToggleSource ? <Stack.Toolbar.MenuAction icon="chevron.left.forwardslash.chevron.right"
+ onPress={p.onToggleSource}>
+ {t(p.source ? "files.preview.browserShowDocument" : "files.preview.browserShowSource")}
+ </Stack.Toolbar.MenuAction> : null}
+ <Stack.Toolbar.Menu inline>
+ <Stack.Toolbar.MenuAction icon="doc.on.doc" disabled={p.busy} onPress={p.onCopyPath}>
+ {t("files.preview.copyPath")}
+ </Stack.Toolbar.MenuAction>
+ <Stack.Toolbar.MenuAction icon="text.bubble" disabled={p.busy} onPress={p.onAddToTask}>
+ {t("files.preview.browserAddToTask")}
+ </Stack.Toolbar.MenuAction>
+ </Stack.Toolbar.Menu>
+ </Stack.Toolbar.Menu>
+ </Stack.Toolbar> : null}
<View
pointerEvents="box-none"
style={{
position: "absolute",
top: p.top,
- left: p.document ? Math.max(p.left, p.right) : p.left,
- right: p.document ? Math.max(p.left, p.right) : p.right,
+ left: centeredTitle ? Math.max(p.left, p.right) : p.left,
+ right: centeredTitle ? Math.max(p.left, p.right) : p.right,
flexDirection: "row",
gap: spacing.sm,
}}
>
- {p.document && systemBack ? (
- // Duo owns close in its native toolbar; keep equal side widths for the title.
- <View pointerEvents="none" style={{ width: size, height: size }} />
- ) : <Host {...host} style={{ width: size, height: size }}>
+ {systemBack ? null : <Host {...host} style={{ width: size, height: size }}>
<Button
onPress={p.onClose}
testID="filePreview.done"
@@ -276,7 +303,7 @@ export function HtmlBrowserChrome(p: HtmlBrowserChromeProps | DocumentPreviewChr
)}
</HStack>
</Host>
- {p.document ? moreMenu : null}
+ {p.document && !systemBack ? moreMenu : null}
</View>
{p.notice ? (
<View
diff --git a/apps/mobile/src/session/HtmlBrowserChrome.types.ts b/apps/mobile/src/session/HtmlBrowserChrome.types.ts
index 3ddbc9780d..daf9a4d367 100644
--- a/apps/mobile/src/session/HtmlBrowserChrome.types.ts
+++ b/apps/mobile/src/session/HtmlBrowserChrome.types.ts
@@ -8,6 +8,8 @@ export interface FilePreviewChromeProps {
bottom: number;
left: number;
right: number;
+ /** Shown outside a navigation route (Modal): every control stays in the page, never in the host route's bar. */
+ standalone?: boolean;
source?: boolean;
busy: boolean;
/** The file has not opened yet: address editing and the more menu stay disabled. */
diff --git a/apps/mobile/src/session/HtmlWebsiteBrowser.tsx b/apps/mobile/src/session/HtmlWebsiteBrowser.tsx
index 8e3c7dccbc..96888b86ce 100644
--- a/apps/mobile/src/session/HtmlWebsiteBrowser.tsx
+++ b/apps/mobile/src/session/HtmlWebsiteBrowser.tsx
@@ -21,7 +21,7 @@ const COPY_NOTICE_DISMISS_MS = 2500;
export function HtmlWebsiteBrowser({ visit, insets, chrome, onReturn }: {
visit: WebsiteVisit;
insets: BrowserInsets;
- chrome: Pick<HtmlBrowserChromeProps, 'top' | 'bottom' | 'left' | 'right' | 'onClose'>;
+ chrome: Pick<HtmlBrowserChromeProps, 'top' | 'bottom' | 'left' | 'right' | 'standalone' | 'onClose'>;
onReturn(): void;
}) {
const { t } = useTranslation();
diff --git a/apps/mobile/src/session/MessageRenderer.tsx b/apps/mobile/src/session/MessageRenderer.tsx
index 43ba60eb16..2dd37111df 100644
--- a/apps/mobile/src/session/MessageRenderer.tsx
+++ b/apps/mobile/src/session/MessageRenderer.tsx
@@ -7469,7 +7469,7 @@ function MessagePayloadModal({
testID="message.payloadMermaidDiagram"
zoomable
/>
- <View style={[styles.payloadFloatingActions, { top: modalSafeArea.paddingTop }]}>
+ <View style={[styles.payloadFloatingActions, { top: modalSafeArea.paddingTop, right: safeAreaInsets.right + spacing.lg }]}>
{imageAnnotation ? (
<PayloadHeaderActionButton
accessibilityLabel={t('message.renderer.annotateSendToChat')}
@@ -7523,6 +7523,9 @@ function MessagePayloadModal({
styles.payloadModal,
{
paddingBottom: modalSafeArea.paddingBottom,
+ // Landscape side insets hold the notch or a vertical system bar (Duo).
+ paddingLeft: safeAreaInsets.left,
+ paddingRight: safeAreaInsets.right,
paddingTop: modalSafeArea.paddingTop,
},
]}
@@ -9753,7 +9756,6 @@ const makeStyles = (colors: ThemeColors) => StyleSheet.create({
flexDirection: 'row',
gap: spacing.sm,
position: 'absolute',
- right: spacing.lg,
},
// 浮动按钮需要实底色,否则悬在图表线条上看不清。
payloadFloatingButton: {
diff --git a/apps/mobile/src/session/usePreviewChromeFrame.ts b/apps/mobile/src/session/usePreviewChromeFrame.ts
new file mode 100644
index 0000000000..cc792c20b1
--- /dev/null
+++ b/apps/mobile/src/session/usePreviewChromeFrame.ts
@@ -0,0 +1,19 @@
+import { Platform } from 'react-native';
+import { useSafeAreaInsets } from 'react-native-safe-area-context';
+import { useAdaptiveWindow } from '@/platform/AdaptiveWindowContext';
+import { floatingTopRow } from '@/platform/windowGeometry';
+import { spacing } from '@/theme/tokens';
+import { HTML_BROWSER_CONTROL_SIZE } from './HtmlBrowserChrome.types';
+
+/**
+ * Edges of the floating preview chrome and the content top that clears its first row.
+ * iOS follows the window's status/bar geometry (Duo); other platforms keep the safe area.
+ */
+export function usePreviewChromeFrame() {
+ const window = useAdaptiveWindow();
+ const insets = useSafeAreaInsets();
+ const row = Platform.OS === 'ios'
+ ? floatingTopRow({ ...window, insets }, HTML_BROWSER_CONTROL_SIZE)
+ : { top: insets.top, left: insets.left + spacing.md, right: insets.right + spacing.md, sharedStatusRow: false };
+ return { ...row, bottom: insets.bottom, contentTop: row.top + HTML_BROWSER_CONTROL_SIZE + spacing.xs };
+}
diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.md
index 3e78e0d411..bb1f9c5f67 100644
--- a/docs/design-rules/DESIGN.md
+++ b/docs/design-rules/DESIGN.md
@@ -796,6 +796,7 @@ There is one mobile home, as on Desktop (owner decision, 2026-10-24): no separat
- The home main menu remains a left-edge drawer on every platform and window shape, using `HomeChromeDrawer.tsx` (iOS uses FullWindowOverlay above the native header; Android uses a transparent Modal window, because wide layouts mount the resident home list and connection notices in root layers that an in-route overlay cannot cover). Preserve backdrop dismissal, swipe-left dismissal and the drawer's close lifecycle. Native glass button unification must not replace this navigation drawer with a bottom sheet. Device-scope/display pull-downs keep their existing system UIMenu path and native toolbar menus; their custom panels are fallback code, not a reason to replace working native menus. System navigation/toolbars remain native container-owned.
- Standalone custom navigation controls use a 44pt visible circle and 44pt hit frame (`navigationChrome.target`), with 20pt artwork (`iconSize.action`) centered inside. Apply the native interactive glass effect after the explicit frame on a borderless SwiftUI Button; do not add `controlSize(large)` or another glass/padding layer. System toolbar items retain native sizing and positioning: never replace them with `Toolbar.View` to enforce this custom-control rule, because that breaks Duo's vertical adaptation.
- Prefer the native navigation container for page back/close and toolbar actions. On Duo, let the system adapt navigation to the shared status/toolbar region; only the detail column gets the vertical bar in a split view. Sidebar-local menus stay in the sidebar.
+- Floating page chrome that a native bar cannot host (file preview's close, title capsule and menu) takes its edges from `floatingTopRow`: in Duo portrait it shares the status row and ends before the status area, the same way the native bar does; beside a vertical bar its close and menu become native toolbar items and the title keeps a top margin instead of touching the screen edge. Chrome inside a Modal stays fully in the Modal and never writes the host route's bar. Full-screen Modal controls add the side safe insets, which hold the landscape notch or Duo's vertical bar (2026-10-29).
- Full-screen custom overlays (remote desktop) keep back and tools on the right in both Duo landscape rotations, centered on one rail below the system status area. Back comes before tools. Respect safe areas and reserved folds; do not mirror the rail from a video orientation event.
- Portrait tabletop remote desktop on iPhone Duo defaults to the Macintosh II-inspired case and functional keyboard (owner request, 2026-10-24). The lower-pane appearance rail accepts left/right swipes and an accessible tap to cycle directionally through classic, slim classic, full-screen retro, Macintosh II, PowerBook 170, ThinkPad 701C and modern (wrapping at either end), retaining the choice for this viewer. Slim and full-screen variants maximize the viewport and use a nearly full-width keyboard and invisible palmrest pointer surface; retain the original classic as a comparison. Switching between any two appearances releases held input. Pointer gestures cover the entire palmrest below the keys, independently of the much smaller visible touchpad, trackball or buttons; never extend this region over the keyboard or appearance rail. Use photorealistic classic Macintosh-inspired hardware artwork: textured ivory plastic, a deep CRT recess, a floppy slot and beveled keycaps (owner refinement, 2026-10-24). Hardware artwork keeps each model’s material in Light/Dark mode, with Light text tokens on ivory keycaps and Dark text tokens on graphite keycaps. Macintosh II and PowerBook retain their rainbow Apple badge; ThinkPad retains its black material and red TrackPoint. These are space-adapted homages, not mechanically exact replicas; surrounding app chrome follows the active theme. Fit the live viewer within the screen opening. Do not substitute flat CSS/vector panels for the physical material. Keep the live viewer and lease mounted across switches. Unfolded/landscape layouts and system keyboard panels retain their ordinary appearance. Implementation: `apps/mobile/src/remote-desktop/FoldDesktopSkin.tsx` and `RemoteDesktopScreen.tsx`.
- Duo retro hardware draws the upper display case and lower keyboard deck edge-to-edge across their respective physical halves, meeting at the fold center. Scale the original artwork itself; never fill unsafe strips with a separate texture, tiled background or substitute image. Only the live screen, keyboard and interactive controls respect safe regions and toolbar clearance (owner correction, 2026-10-24).