Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix(native): unify safe area and fold keyboard layout (#1146)
Gener25634f8b6c31
diff --git a/scripts/ci/e2e-shards.mjs b/scripts/ci/e2e-shards.mjsindex 23d7b5e71..22db756ee 100644--- a/scripts/ci/e2e-shards.mjs+++ b/scripts/ci/e2e-shards.mjs@@ -92,6 +92,7 @@ export const SPEC_SECONDS = {"68-bot-memberships.spec.ts": DEFAULT_SPEC_SECONDS,"69-table-fullscreen-scroll.spec.ts": DEFAULT_SPEC_SECONDS,"70-renderer-action-themes.spec.ts": DEFAULT_SPEC_SECONDS,+ "native-keyboard-viewport-projection.spec.ts": DEFAULT_SPEC_SECONDS,}function walk(directory) {diff --git a/scripts/ci/e2e-shards.test.ts b/scripts/ci/e2e-shards.test.tsindex 763cefccd..02792f168 100644--- a/scripts/ci/e2e-shards.test.ts+++ b/scripts/ci/e2e-shards.test.ts@@ -75,7 +75,7 @@ describe("planE2eShards", () => {expect(first).toEqual(second)expect(Object.keys(SPEC_SECONDS).sort()).toEqual(specs)- expect(first).toHaveLength(22)+ expect(first).toHaveLength(23)expect([...assigned].sort()).toEqual(specs)expect(new Set(assigned).size).toBe(specs.length)expect(SPEC_SECONDS["18-new-divider-scroll.spec.ts"]).toBe(DEFAULT_SPEC_SECONDS)@@ -85,6 +85,9 @@ describe("planE2eShards", () => {expect(SPEC_SECONDS["67-text-sidebar-threads.spec.ts"]).toBe(DEFAULT_SPEC_SECONDS)expect(SPEC_SECONDS["68-bot-memberships.spec.ts"]).toBe(DEFAULT_SPEC_SECONDS)expect(SPEC_SECONDS["70-renderer-action-themes.spec.ts"]).toBe(DEFAULT_SPEC_SECONDS)+ expect(SPEC_SECONDS["native-keyboard-viewport-projection.spec.ts"]).toBe(DEFAULT_SPEC_SECONDS)+ expect(first.find((shard) => shard.files.includes("native-keyboard-viewport-projection.spec.ts"))?.files)+ .toEqual(["native-keyboard-viewport-projection.spec.ts"])expect(first.find((shard) => shard.files.includes("70-renderer-action-themes.spec.ts"))?.files).toEqual(["70-renderer-action-themes.spec.ts"])expect(SPEC_SECONDS["69-table-fullscreen-scroll.spec.ts"]).toBe(DEFAULT_SPEC_SECONDS)@@ -100,11 +103,11 @@ describe("planE2eShards", () => {expect(first.find((shard) => shard.files.includes("67-text-sidebar-threads.spec.ts"))?.files).toEqual(["67-text-sidebar-threads.spec.ts"])expect(specSeconds).toEqual([- 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 155.638, 154.234, 155.283,+ 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 155.638, 154.234, 155.283,156.095, 155.905, 156.323, 155.711, 153.963, 154.488, 156.138,])expect(predictedSeconds).toEqual([- 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 230.638, 229.234, 230.283,+ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 230.638, 229.234, 230.283,231.095, 230.905, 231.323, 230.711, 228.963, 229.488, 231.138,])expect(first.every((shard) => (diff --git a/scripts/ci/ios-native-insets.test.ts b/scripts/ci/ios-native-insets.test.tsnew file mode 100644index 000000000..108df8220--- /dev/null+++ b/scripts/ci/ios-native-insets.test.ts@@ -0,0 +1,119 @@+import { execFileSync } from "node:child_process"+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"+import { tmpdir } from "node:os"+import { resolve } from "node:path"+import { runInNewContext } from "node:vm"+import { expect, it } from "vitest"++const root = resolve(import.meta.dirname, "../..")+const runtime = readFileSync(resolve(root, "src/desktop/src-tauri/gen/apple/Sources/alook-desktop/main.mm"), "utf8")+const read = (path: string) => readFileSync(resolve(root, path), "utf8")++it.runIf(process.platform === "darwin")("executes the real native frame and keyboard helpers across system inset shapes", () => {+ const frame = runtime.match(/static CGRect alookNativeContentFrame\([\s\S]*?\n\}/)?.[0]+ const keyboard = runtime.match(/static CGFloat alookKeyboardBottomInset\([\s\S]*?\n\}/)?.[0]+ expect(frame).toBeDefined()+ expect(keyboard).toBeDefined()+ const directory = mkdtempSync(resolve(tmpdir(), "alook-native-insets-"))+ try {+ const source = resolve(directory, "insets.mm")+ const binary = resolve(directory, "insets")+ writeFileSync(source, `+#import <Foundation/Foundation.h>+#import <CoreGraphics/CoreGraphics.h>+#include <cassert>+#include <cstdio>+#include <initializer_list>+typedef struct { CGFloat top, left, bottom, right; } UIEdgeInsets;+${frame}+${keyboard}+int main() {+ const CGRect host = CGRectMake(0, 0, 1200, 900);+ for (CGFloat top : {0.0, 6.0, 10.0, 24.0, 59.0, 62.0}) {+ for (CGFloat bottom : {0.0, 20.0, 21.0, 34.0}) {+ UIEdgeInsets original = {top, 12, bottom, 17};+ CGRect app = alookNativeContentFrame(host, original, YES);+ assert(app.origin.x == 12 && app.origin.y == MAX(top, 10.0));+ assert(app.size.width == 1171 && CGRectGetMaxY(app) == 880);+ assert(original.top == top && original.bottom == bottom);+ CGRect other = alookNativeContentFrame(host, original, NO);+ assert(other.origin.y == top && CGRectGetMaxY(other) == 900 - bottom);+ CGRect bounds = CGRectMake(0, 0, app.size.width, app.size.height);+ CGRect safe = CGRectMake(12, top, 1171, 900 - top - bottom);+ CGRect hiddenGuide = CGRectMake(0, 900 - bottom, 1200, bottom);+ CGRect hiddenInWeb = CGRectOffset(hiddenGuide, -app.origin.x, -app.origin.y);+ assert(alookKeyboardBottomInset(bounds, hiddenInWeb, hiddenGuide, safe) == 0);+ CGRect shownGuide = CGRectMake(0, 600, 1200, 300);+ CGRect shownInWeb = CGRectOffset(shownGuide, -app.origin.x, -app.origin.y);+ CGFloat overlap = alookKeyboardBottomInset(bounds, shownInWeb, shownGuide, safe);+ assert(overlap == 280 && overlap + 20 == 300);+ CGRect outside = CGRectOffset(shownInWeb, 2000, 0);+ assert(alookKeyboardBottomInset(bounds, outside, shownGuide, safe) == 0);+ CGRect covering = CGRectMake(0, -100, bounds.size.width, bounds.size.height + 100);+ assert(alookKeyboardBottomInset(bounds, covering, shownGuide, safe) == bounds.size.height);+ }+ }+ UIEdgeInsets inset = {0, 12, 34, 17};+ CGRect tiny = alookNativeContentFrame(CGRectMake(0, 0, 5, 5), inset, YES);+ assert(tiny.size.width == 0 && tiny.size.height == 0);+ std::puts("PASS original insets, trial frame, hidden guide, docked overlap and bounds");+}+`)+ execFileSync("xcrun", ["--sdk", "macosx", "clang++", "-fobjc-arc", "-std=c++17",+ "-framework", "Foundation", "-framework", "CoreGraphics", source, "-o", binary],+ { timeout: 30_000, stdio: "pipe" })+ expect(execFileSync(binary, [], { timeout: 5000, encoding: "utf8" }))+ .toContain("PASS original insets, trial frame, hidden guide, docked overlap and bounds")+ } finally {+ rmSync(directory, { recursive: true, force: true })+ }+}, 40_000)++it("executes the actual native safe-area script without copying system values into Web layout", () => {+ const declaration = runtime.match(/static NSString \*const kAlookConsumedSafeAreaScript =\n([\s\S]*?);\n\nstatic CGRect/)?.[1]+ expect(declaration).toBeDefined()+ const script = [...declaration!.matchAll(/@?"((?:\\.|[^"\\])*)"/g)]+ .map(match => JSON.parse(`"${match[1]}"`) as string).join("")+ expect(script).not.toBe("")+ for (const initial of [0, 20, 34]) {+ const values = new Map<string, string>([["color-scheme", "dark"]])+ for (const edge of ["top", "right", "bottom", "left"]) values.set(`--app-safe-area-${edge}`, `${initial}px`)+ const context = { document: { documentElement: { style: { setProperty: (name: string, value: string) => values.set(name, value) } } } }+ runInNewContext(script, context)+ runInNewContext(script, context)+ expect([...values]).toEqual([+ ["color-scheme", "dark"], ["--app-safe-area-top", "0px"], ["--app-safe-area-right", "0px"],+ ["--app-safe-area-bottom", "0px"], ["--app-safe-area-left", "0px"],+ ])+ }+ expect(runtime).toContain("injectionTime:WKUserScriptInjectionTimeAtDocumentStart")+ expect(runtime).toContain("[webView evaluateJavaScript:kAlookConsumedSafeAreaScript completionHandler:nil]")+ const handler = runtime.split("@implementation AlookSafeAreaHandler")[1]?.split("@end")[0] ?? ""+ expect(handler).toContain("@(controller.view.safeAreaInsets.top)")+ expect(handler).not.toContain("MAX(")+ expect(runtime).toContain("kAlookSafeAreaTopKey, @(insets.top)")+})++it("keeps browser env defaults while native UI consumers share the existing app variables", () => {+ const globals = read("src/web/src/app/globals.css")+ for (const edge of ["top", "right", "bottom", "left"]) {+ expect(globals).toContain(`--app-safe-area-${edge}: env(safe-area-inset-${edge}, 0px)`)+ }+ const consumers = [+ "src/web/src/app/(auth)/sign-in/sign-in-client.tsx",+ "src/web/src/components/toaster-provider.tsx",+ "src/web/src/components/ui/toast.tsx",+ "src/web/src/components/community/channels/post-tag-dialog.tsx",+ "src/web/src/components/avatar/bot-avatar-picker-dialog.tsx",+ "src/web/src/components/community/messages/message-reactions.tsx",+ "src/web/src/components/community/messages/image-lightbox.tsx",+ ]+ for (const path of consumers) {+ expect(read(path), path).not.toContain("env(safe-area-inset-")+ expect(read(path), path).toMatch(/(?:var\(|-\()--app-safe-area-/)+ }+ const recovery = read("src/desktop/src-tauri/src/webview_recovery.rs")+ for (const edge of ["top", "right", "bottom", "left"]) {+ expect(recovery).toContain(`var(--app-safe-area-${edge},env(safe-area-inset-${edge}))`)+ }+})diff --git a/scripts/ci/native-shell-theme-colors.test.ts b/scripts/ci/native-shell-theme-colors.test.tsindex 34d5b6519..be51f3fbc 100644--- a/scripts/ci/native-shell-theme-colors.test.ts+++ b/scripts/ci/native-shell-theme-colors.test.ts@@ -119,7 +119,8 @@ describe("native shell theme color contract", () => {const handler = iosRuntime.split("@implementation AlookKeyboardHandler")[1]?.split("@end")[0] ?? ""const publish = iosRuntime.split("static void alookPublishKeyboardSnapshots(")[1]?.split("\n}\n")[0] ?? ""expect(measure).toContain("convertRect:host.keyboardLayoutGuide.layoutFrame fromView:host")- expect(measure).toContain("CGRectIntersectsRect(bounds, keyboardFrame)")+ expect(measure).toContain("alookKeyboardBottomInset(bounds, keyboardFrame,")+ expect(measure).toContain("host.keyboardLayoutGuide.layoutFrame, host.safeAreaLayoutGuide.layoutFrame")expect(measure).toContain("@\"bottomInset\"")expect(measure).toContain("@\"viewportWidth\"")expect(observer).toContain("[super layoutSubviews]")@@ -179,7 +180,7 @@ describe("native shell theme color contract", () => {)expect(iosRuntime).toContain("objc_setAssociatedObject(")expect(iosRuntime).toContain("objc_getAssociatedObject(")- expect(iosRuntime).toContain("bounds.size.height - insets.top - insets.bottom")+ expect(iosRuntime).toContain("alookNativeContentFrame(bounds, insets, isTauriRoot)")expect(iosRuntime).not.toContain("prefersHomeIndicatorAutoHidden")})diff --git a/src/desktop/src-tauri/gen/apple/Sources/alook-desktop/main.mm b/src/desktop/src-tauri/gen/apple/Sources/alook-desktop/main.mmindex 542d05026..97ee81e02 100644--- a/src/desktop/src-tauri/gen/apple/Sources/alook-desktop/main.mm+++ b/src/desktop/src-tauri/gen/apple/Sources/alook-desktop/main.mm@@ -26,6 +26,29 @@ static UIView *gAlookStartupOverlay = nil;static BOOL gAlookStartupCompleted = NO;static BOOL gAlookStartupFailed = NO;+static NSString *const kAlookConsumedSafeAreaScript =+ @"for (const edge of ['top', 'right', 'bottom', 'left']) {"+ "document.documentElement.style.setProperty('--app-safe-area-' + edge, '0px');"+ "}";++static CGRect alookNativeContentFrame(CGRect bounds, UIEdgeInsets systemInsets, BOOL isTauriRoot) {+ CGFloat top = isTauriRoot ? MAX(systemInsets.top, 10.0) : systemInsets.top;+ CGFloat bottom = isTauriRoot ? 20.0 : systemInsets.bottom;+ CGFloat width = bounds.size.width - systemInsets.left - systemInsets.right;+ CGFloat height = bounds.size.height - top - bottom;+ return CGRectMake(systemInsets.left, top,+ isTauriRoot ? MAX(0.0, width) : width,+ isTauriRoot ? MAX(0.0, height) : height);+}++static CGFloat alookKeyboardBottomInset(CGRect bounds, CGRect keyboardFrame,+ CGRect keyboardGuideFrame, CGRect safeAreaFrame) {+ if (CGRectGetMinY(keyboardGuideFrame) >= CGRectGetMaxY(safeAreaFrame)) return 0;+ return CGRectIntersectsRect(bounds, keyboardFrame)+ ? MIN(bounds.size.height, MAX(0, CGRectGetMaxY(bounds) - CGRectGetMinY(keyboardFrame)))+ : 0;+}+static BOOL alookIsTauriRootController(UIViewController *viewController) {Class taoViewController = NSClassFromString(@"TaoUIViewController");return taoViewController != Nil && [viewController isKindOfClass:taoViewController];@@ -148,9 +171,8 @@ static NSDictionary *alookMeasureKeyboardSnapshot(UIViewController *controller,UIView *host = controller.view;CGRect keyboardFrame = [webView convertRect:host.keyboardLayoutGuide.layoutFrame fromView:host];CGRect bounds = webView.bounds;- CGFloat bottomInset = CGRectIntersectsRect(bounds, keyboardFrame)- ? MIN(bounds.size.height, MAX(0, CGRectGetMaxY(bounds) - CGRectGetMinY(keyboardFrame)))- : 0;+ CGFloat bottomInset = alookKeyboardBottomInset(bounds, keyboardFrame,+ host.keyboardLayoutGuide.layoutFrame, host.safeAreaLayoutGuide.layoutFrame);return @{@"bottomInset": @(bottomInset),@"viewportWidth": @(bounds.size.width)@@ -509,18 +531,19 @@ static NSString *const kThemeObserverScript =for (UIView *subview in self.view.subviews) {if ([subview isKindOfClass:[WKWebView class]]) {CGRect bounds = self.view.bounds;- CGRect contentFrame = CGRectMake(- insets.left,- insets.top,- bounds.size.width - insets.left - insets.right,- bounds.size.height - insets.top - insets.bottom- );+ CGRect contentFrame = alookNativeContentFrame(bounds, insets, isTauriRoot);WKWebView *webView = (WKWebView *)subview;if (isTauriRoot) {alookInstallCommunityRootScrollLock(self.view, webView);NSNumber *previousTop = objc_getAssociatedObject(webView, kAlookSafeAreaTopKey);if (previousTop == nil) {+ WKUserScript *safeAreaScript = [[WKUserScript alloc]+ initWithSource:kAlookConsumedSafeAreaScript+ injectionTime:WKUserScriptInjectionTimeAtDocumentStart+ forMainFrameOnly:YES];+ [webView.configuration.userContentController addUserScript:safeAreaScript];+ [webView evaluateJavaScript:kAlookConsumedSafeAreaScript completionHandler:nil];AlookSafeAreaHandler *handler = [[AlookSafeAreaHandler alloc] init];handler.viewController = self;[webView.configuration.userContentControllerdiff --git a/src/desktop/src-tauri/src/webview_recovery.rs b/src/desktop/src-tauri/src/webview_recovery.rsindex b0a171163..085e4ece5 100644--- a/src/desktop/src-tauri/src/webview_recovery.rs+++ b/src/desktop/src-tauri/src/webview_recovery.rs@@ -955,7 +955,7 @@ fn recovery_html() -> &'static str {:root{color-scheme:light dark;--background:oklch(1 0 0);--foreground:oklch(0.18 0.03 230);--muted-foreground:oklch(0.44 0.03 230);--ring:oklch(0.55 0.03 230);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:var(--background);color:var(--foreground)}*{box-sizing:border-box}body{min-height:100vh;margin:0;background:var(--background)}- main{width:100%;min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;padding:max(24px,env(safe-area-inset-top)) max(24px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left));text-align:center;cursor:pointer;outline:none;-webkit-user-select:none;user-select:none}+ main{width:100%;min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;padding:max(24px,var(--app-safe-area-top,env(safe-area-inset-top))) max(24px,var(--app-safe-area-right,env(safe-area-inset-right))) max(24px,var(--app-safe-area-bottom,env(safe-area-inset-bottom))) max(24px,var(--app-safe-area-left,env(safe-area-inset-left)));text-align:center;cursor:pointer;outline:none;-webkit-user-select:none;user-select:none}main:focus-visible svg{outline:3px solid var(--ring);outline-offset:4px;border-radius:50%}svg{width:48px;height:48px;color:var(--foreground)}p{margin:0;color:var(--muted-foreground);font-size:16px;line-height:1.55}diff --git a/src/web/src/app/(auth)/sign-in/sign-in-client.tsx b/src/web/src/app/(auth)/sign-in/sign-in-client.tsxindex 6f1368d24..c65f02d07 100644--- a/src/web/src/app/(auth)/sign-in/sign-in-client.tsx+++ b/src/web/src/app/(auth)/sign-in/sign-in-client.tsx@@ -371,7 +371,7 @@ function SignInForm({)}>{showMethodsPane ? (- <div aria-hidden={isTransitioning || undefined} inert={isTransitioning || undefined} className="flex min-h-svh w-full shrink-0 flex-col justify-center gap-4 pt-[max(0.5rem,env(safe-area-inset-top))] pb-[max(1rem,env(safe-area-inset-bottom))] sm:min-h-0 sm:p-8">+ <div aria-hidden={isTransitioning || undefined} inert={isTransitioning || undefined} className="flex min-h-svh w-full shrink-0 flex-col justify-center gap-4 pt-[max(0.5rem,var(--app-safe-area-top))] pb-[max(1rem,var(--app-safe-area-bottom))] sm:min-h-0 sm:p-8"><SignInMobileTypewriter collapsed={false} /><div className="mx-auto w-full max-w-88 px-4 sm:px-0"><FieldGroup className="gap-4">@@ -445,7 +445,7 @@ function SignInForm({data-testid="sign-in-email-pane"aria-hidden={isExitingEmail || undefined}inert={isTransitioning || undefined}- className="flex min-h-svh w-full shrink-0 flex-col px-4 pt-[max(3rem,env(safe-area-inset-top))] pb-[max(1.5rem,env(safe-area-inset-bottom))] sm:min-h-0 sm:justify-center sm:p-8"+ className="flex min-h-svh w-full shrink-0 flex-col px-4 pt-[max(3rem,var(--app-safe-area-top))] pb-[max(1.5rem,var(--app-safe-area-bottom))] sm:min-h-0 sm:justify-center sm:p-8"><div className="mx-auto w-full max-w-80 sm:max-w-88"><FieldGroup className="gap-4">@@ -491,7 +491,7 @@ function SignInForm({data-testid="sign-in-code-pane"aria-hidden={isExitingCode || undefined}inert={isTransitioning || undefined}- className="flex min-h-svh w-full shrink-0 flex-col px-4 pt-[max(3rem,env(safe-area-inset-top))] pb-[max(1.5rem,env(safe-area-inset-bottom))] sm:min-h-0 sm:justify-center sm:p-8"+ className="flex min-h-svh w-full shrink-0 flex-col px-4 pt-[max(3rem,var(--app-safe-area-top))] pb-[max(1.5rem,var(--app-safe-area-bottom))] sm:min-h-0 sm:justify-center sm:p-8"><div className="mx-auto w-full max-w-80 sm:max-w-88"><FieldGroup className="gap-4">diff --git a/src/web/src/components/avatar/bot-avatar-picker-dialog.tsx b/src/web/src/components/avatar/bot-avatar-picker-dialog.tsxindex 57234492a..1002d607d 100644--- a/src/web/src/components/avatar/bot-avatar-picker-dialog.tsx+++ b/src/web/src/components/avatar/bot-avatar-picker-dialog.tsx@@ -76,7 +76,7 @@ export function BotAvatarPickerDialog({ image, onChange }: BotAvatarPickerDialog<DialogContent className={isMobile- ? "top-auto left-0 translate-x-0 translate-y-0 bottom-0 max-w-full sm:max-w-full w-full rounded-b-none rounded-t-xl max-h-[85dvh] overflow-y-auto thin-scrollbar pb-[env(safe-area-inset-bottom)]"+ ? "top-auto left-0 translate-x-0 translate-y-0 bottom-0 max-w-full sm:max-w-full w-full rounded-b-none rounded-t-xl max-h-[85dvh] overflow-y-auto thin-scrollbar pb-(--app-safe-area-bottom)": "sm:max-w-120"}><DialogHeader>diff --git a/src/web/src/components/community/channels/post-tag-dialog.tsx b/src/web/src/components/community/channels/post-tag-dialog.tsxindex d10a1b849..af8c0466a 100644--- a/src/web/src/components/community/channels/post-tag-dialog.tsx+++ b/src/web/src/components/community/channels/post-tag-dialog.tsx@@ -333,7 +333,7 @@ export function PostTagDialog({showCloseButton={false}data-testid={tid.forumTagDialog}aria-label={`Edit tags for ${postName}`}- className="flex max-h-[calc(100dvh-2rem-env(safe-area-inset-top)-env(safe-area-inset-bottom))] w-[calc(100%-2rem)] max-w-sm flex-col gap-0 rounded-2xl p-0"+ className="flex max-h-[calc(100dvh-2rem-var(--app-safe-area-top)-var(--app-safe-area-bottom))] w-[calc(100%-2rem)] max-w-sm flex-col gap-0 rounded-2xl p-0"onClick={(event) => event.stopPropagation()}><div className="flex min-w-0 shrink-0 items-center gap-1 px-2 py-2">diff --git a/src/web/src/components/community/community-dnd.dom.test.tsx b/src/web/src/components/community/community-dnd.dom.test.tsxindex 4712001f4..63435537a 100644--- a/src/web/src/components/community/community-dnd.dom.test.tsx+++ b/src/web/src/components/community/community-dnd.dom.test.tsx@@ -1,5 +1,6 @@-import { useLayoutEffect, useRef, useState, type ReactNode } from "react"-import { DndProvider } from "react-dnd"+import { StrictMode, useLayoutEffect, useRef, useState, type ReactNode } from "react"+import { DndProvider, useDrag, useDragDropManager } from "react-dnd"+import { MultiBackend } from "dnd-multi-backend"import { TestBackend, type TestBackendImpl } from "react-dnd-test-backend"import { act, fireEvent, render } from "@/test/react-dom-harness"import { describe, expect, it, vi } from "vitest"@@ -82,6 +83,40 @@ function ActualSidebarFixture({ onReorder }: { onReorder: (ids: string[]) => voi}describe("React DnD community scopes", () => {+ it("keeps sibling provider managers live through StrictMode replay and a provider rerender", () => {+ const managers = new Map<string, ReturnType<typeof useDragDropManager>>()+ function Source({ label }: { label: string }) {+ const manager = useDragDropManager()+ useLayoutEffect(() => { managers.set(label, manager) }, [label, manager])+ const [, drag] = useDrag(() => ({ type: "community/provider-lifecycle", item: { label } }), [label])+ return <div ref={node => { drag(node) }}>{label}</div>+ }+ function Scope({ id }: { id: string }) {+ const [revision, setRevision] = useState(0)+ return <>+ <button type="button" onClick={() => setRevision(value => value + 1)}>update {id}</button>+ <CommunityDndProvider><Source label={`${id}:${revision}`} /></CommunityDndProvider>+ </>+ }+ const view = render(<StrictMode><Scope id="rail" /><Scope id="sidebar" /></StrictMode>)+ const manager = managers.get("rail:0")+ expect(manager).toBeDefined()+ expect(managers.get("sidebar:0")).toBe(manager)+ fireEvent.click(view.getByRole("button", { name: "update rail" }))+ expect(view.getByText("rail:1")).toBeInTheDocument()+ expect(view.getByText("sidebar:0")).toBeInTheDocument()+ expect(managers.get("rail:1")).toBe(manager)+ view.unmount()+ const isolated = render(<DndProvider backend={MultiBackend} options={communityDndOptions} context={{}}>+ <Source label="isolated" />+ </DndProvider>)+ expect(managers.get("isolated")).not.toBe(manager)+ isolated.unmount()+ const reopened = render(<CommunityDndProvider><Source label="reopened" /></CommunityDndProvider>)+ expect(managers.get("reopened")).toBe(manager)+ reopened.unmount()+ })+it("renders a same-kind drag preview only in its owning scope", () => {const ui = setup(<><div data-scope="first"><TreeFixture onDrop={vi.fn()} /></div><div data-scope="second"><TreeFixture onDrop={vi.fn()} /></div></>)const source = ui.container.querySelector<HTMLElement>('[data-scope="second"] [data-testid="text"]')!diff --git a/src/web/src/components/community/community-dnd.tsx b/src/web/src/components/community/community-dnd.tsxindex a6436cd53..0bab57fa2 100644--- a/src/web/src/components/community/community-dnd.tsx+++ b/src/web/src/components/community/community-dnd.tsx@@ -22,7 +22,7 @@ export const communityDndOptions = {export function CommunityDndProvider({ children }: { children: ReactNode }) {const { dragDropManager } = useContext(DndContext)if (dragDropManager) return children- return <DndProvider backend={MultiBackend} options={communityDndOptions}>{children}</DndProvider>+ return <DndProvider backend={MultiBackend} options={communityDndOptions} context={typeof window === "undefined" ? undefined : window}>{children}</DndProvider>}export function useDndCancellation(onCancel: () => void) {diff --git a/src/web/src/components/community/messages/conversation-footer-shell.dom.test.tsx b/src/web/src/components/community/messages/conversation-footer-shell.dom.test.tsxindex ce7e25664..c86bb4902 100644--- a/src/web/src/components/community/messages/conversation-footer-shell.dom.test.tsx+++ b/src/web/src/components/community/messages/conversation-footer-shell.dom.test.tsx@@ -19,6 +19,37 @@ afterEach(() => {})describe("ConversationFooterShell", () => {+ it("keeps one retained footer and draft while native keyboard geometry changes from cover to expanded", async () => {+ const originalWidth = Object.getOwnPropertyDescriptor(window, "innerWidth")+ Object.defineProperty(window, "__TAURI__", { configurable: true, value: {} })+ Object.defineProperty(window, "innerWidth", { configurable: true, value: 382 })+ let native = { bottomInset: 285, viewportWidth: 382 }+ Object.defineProperty(window, "webkit", { configurable: true, value: { messageHandlers: {+ alookKeyboard: { postMessage: async () => native },+ } } })+ const view = render(<ConversationFooterShell data-testid="fold-footer" style={{ marginBottom: 6 }}>+ <input aria-label="Fold draft" defaultValue="Keep this unsent" />+ </ConversationFooterShell>)+ try {+ const footer = view.getByTestId("fold-footer")+ const draft = view.getByRole("textbox", { name: "Fold draft" })+ await waitFor(() => expect(footer).toHaveStyle({ marginBottom: `${100 * 285 / 382}vw` }))+ native = { bottomInset: 244, viewportWidth: 867 }+ Object.defineProperty(window, "innerWidth", { configurable: true, value: 867 })+ act(() => window.dispatchEvent(new Event("resize")))+ await waitFor(() => expect(footer).toHaveStyle({ marginBottom: `${100 * 244 / 867}vw` }))+ expect(view.getByTestId("fold-footer")).toBe(footer)+ expect(view.getByRole("textbox", { name: "Fold draft" })).toBe(draft)+ expect(draft).toHaveValue("Keep this unsent")+ native = { bottomInset: 0, viewportWidth: 867 }+ act(() => window.dispatchEvent(new Event("alook:keyboard-change")))+ await waitFor(() => expect(footer).toHaveStyle({ marginBottom: "6px" }))+ } finally {+ view.unmount()+ if (originalWidth) Object.defineProperty(window, "innerWidth", originalWidth)+ }+ })+it("reserves native occlusion only in the conversation footer and restores the existing style and draft", async () => {Object.defineProperty(window, "__TAURI__", { configurable: true, value: {} })let bottomInset = 0@@ -42,7 +73,7 @@ describe("ConversationFooterShell", () => {.map(id => ({ node: renderer.getByTestId(id), style: renderer.getByTestId(id).getAttribute("style") }))bottomInset = 300act(() => window.dispatchEvent(new Event("alook:keyboard-change")))- await waitFor(() => expect(footer).toHaveStyle({ marginBottom: "300px", borderRadius: "8px" }))+ await waitFor(() => expect(footer).toHaveStyle({ marginBottom: `${100 * 300 / window.innerWidth}vw`, borderRadius: "8px" }))for (const entry of stable) expect(entry.node.getAttribute("style")).toBe(entry.style)expect(renderer.getByRole("textbox", { name: "Native draft" })).toBe(draft)expect(draft).toHaveValue("Unsent draft")@@ -67,7 +98,7 @@ describe("ConversationFooterShell", () => {await act(async () => {})expect(renderer.getByTestId("footer").style.marginBottom).toBe("")renderer.rerender(<Page presented />)- await waitFor(() => expect(renderer.getByTestId("footer")).toHaveStyle({ marginBottom: "200px" }))+ await waitFor(() => expect(renderer.getByTestId("footer")).toHaveStyle({ marginBottom: `${100 * 200 / window.innerWidth}vw` }))renderer.rerender(<Page presented={false} />)expect(renderer.getByTestId("footer").style.marginBottom).toBe("")expect(renderer.getByRole("textbox", { name: "Retained draft" })).toBe(draft)diff --git a/src/web/src/components/community/messages/conversation-footer-shell.tsx b/src/web/src/components/community/messages/conversation-footer-shell.tsxindex d2b1898c7..956c478dd 100644--- a/src/web/src/components/community/messages/conversation-footer-shell.tsx+++ b/src/web/src/components/community/messages/conversation-footer-shell.tsx@@ -76,7 +76,9 @@ export function ConversationFooterShell({data-slot="community-conversation-footer"data-selection-active={selectionActive ? "true" : "false"}className={`relative shrink-0${className ? ` ${className}` : ""}`}- style={presented && keyboard.bottomInset > 0 ? { ...style, marginBottom: keyboard.bottomInset } : style}+ style={presented && keyboard && keyboard.bottomInset > 0+ ? { ...style, marginBottom: `${100 * keyboard.bottomInset / keyboard.viewportWidth}vw` }+ : style}><divref={bindAccessoryTarget}diff --git a/src/web/src/components/community/messages/image-lightbox.tsx b/src/web/src/components/community/messages/image-lightbox.tsxindex 592e1e765..bd4fe8d8e 100644--- a/src/web/src/components/community/messages/image-lightbox.tsx+++ b/src/web/src/components/community/messages/image-lightbox.tsx@@ -229,7 +229,7 @@ export function ImageLightbox({ image, onClose }: { image: ImagePreview | null;onOpenChangeComplete={(open) => { if (!open) setRetained(null) }}><DialogContentaria-label={displayed.name}- className="top-[max(1rem,env(safe-area-inset-top))] right-[max(1rem,env(safe-area-inset-right))] left-[max(1rem,env(safe-area-inset-left))] flex h-[calc(100dvh-max(1rem,env(safe-area-inset-top))-max(1rem,env(safe-area-inset-bottom)))] w-auto max-w-none translate-x-0 translate-y-0 overflow-visible border-none bg-transparent p-0 shadow-none ring-0 sm:max-w-none"+ className="top-[max(1rem,var(--app-safe-area-top))] right-[max(1rem,var(--app-safe-area-right))] left-[max(1rem,var(--app-safe-area-left))] flex h-[calc(100dvh-max(1rem,var(--app-safe-area-top))-max(1rem,var(--app-safe-area-bottom)))] w-auto max-w-none translate-x-0 translate-y-0 overflow-visible border-none bg-transparent p-0 shadow-none ring-0 sm:max-w-none"showCloseButton={false}><PreviewFramediff --git a/src/web/src/components/community/messages/message-reactions.tsx b/src/web/src/components/community/messages/message-reactions.tsxindex a33d98744..e19780d01 100644--- a/src/web/src/components/community/messages/message-reactions.tsx+++ b/src/web/src/components/community/messages/message-reactions.tsx@@ -222,7 +222,7 @@ function ReactionDetailsDialog({<DialogContentdata-testid={tid.reactionDialog(messageId)}finalFocus={false}- className="flex max-h-[calc(100dvh-2rem-env(safe-area-inset-top)-env(safe-area-inset-bottom))] flex-col gap-3 overflow-hidden transition-none sm:max-w-sm **:data-[slot=dialog-close]:size-11 **:data-[slot=dialog-close]:transition-none sm:**:data-[slot=dialog-close]:size-7"+ className="flex max-h-[calc(100dvh-2rem-var(--app-safe-area-top)-var(--app-safe-area-bottom))] flex-col gap-3 overflow-hidden transition-none sm:max-w-sm **:data-[slot=dialog-close]:size-11 **:data-[slot=dialog-close]:transition-none sm:**:data-[slot=dialog-close]:size-7"><DialogHeader className="min-w-0 shrink-0"><DialogTitle className="truncate pr-8">{authorName}</DialogTitle>diff --git a/src/web/src/components/toaster-provider.tsx b/src/web/src/components/toaster-provider.tsxindex b92461b22..1a6c5cd62 100644--- a/src/web/src/components/toaster-provider.tsx+++ b/src/web/src/components/toaster-provider.tsx@@ -14,8 +14,8 @@ export function ToasterProvider() {richColorscloseButtonposition={isMobile ? "top-center" : "bottom-right"}- offset={isMobile ? { top: "calc(env(safe-area-inset-top) + 16px)" } : undefined}- mobileOffset={{ top: "calc(env(safe-area-inset-top) + 16px)" }}+ offset={isMobile ? { top: "calc(var(--app-safe-area-top) + 16px)" } : undefined}+ mobileOffset={{ top: "calc(var(--app-safe-area-top) + 16px)" }}/>);}diff --git a/src/web/src/components/ui/toast.tsx b/src/web/src/components/ui/toast.tsxindex b00b82854..96cb4db23 100644--- a/src/web/src/components/ui/toast.tsx+++ b/src/web/src/components/ui/toast.tsx@@ -36,7 +36,7 @@ function ToastViewport({ className, ...props }: ToastPrimitive.Viewport.Props) {aria-label="Notifications"data-slot="message-notification-viewport"className={cn(- "pointer-events-none fixed inset-x-4 top-[calc(env(safe-area-inset-top)+1rem)] z-100 mx-auto w-auto max-w-lg outline-none sm:w-full",+ "pointer-events-none fixed inset-x-4 top-[calc(var(--app-safe-area-top)+1rem)] z-100 mx-auto w-auto max-w-lg outline-none sm:w-full",className,)}{...props}diff --git a/src/web/src/hooks/use-native-keyboard.dom.test.tsx b/src/web/src/hooks/use-native-keyboard.dom.test.tsxindex d482b8529..f01a7c83f 100644--- a/src/web/src/hooks/use-native-keyboard.dom.test.tsx+++ b/src/web/src/hooks/use-native-keyboard.dom.test.tsx@@ -23,9 +23,9 @@ function install(postMessage: (command: "snapshot") => Promise<unknown>) {it("keeps ordinary Web and Android without a native keyboard capability unchanged", () => {Reflect.deleteProperty(window, "webkit")const view = renderHook(useNativeKeyboard)- expect(view.result.current.bottomInset).toBe(0)+ expect(view.result.current).toBeNull()act(() => window.dispatchEvent(new Event("alook:keyboard-change")))- expect(view.result.current.bottomInset).toBe(0)+ expect(view.result.current).toBeNull()})it("does not enable native layout in a browser with a WebKit-shaped object", async () => {@@ -34,7 +34,7 @@ it("does not enable native layout in a browser with a WebKit-shaped object", asyReflect.deleteProperty(window, "__TAURI__")const view = renderHook(useNativeKeyboard)await act(async () => {})- expect(view.result.current.bottomInset).toBe(0)+ expect(view.result.current).toBeNull()expect(post).not.toHaveBeenCalled()})@@ -43,13 +43,13 @@ it("updates overlap for closed and reopened keyboard snapshots", async () => {const post = vi.fn(async () => snapshot(bottomInset))install(post)const view = renderHook(useNativeKeyboard)- await waitFor(() => expect(view.result.current.bottomInset).toBe(300))+ await waitFor(() => expect(view.result.current).toEqual(snapshot(300)))bottomInset = 0act(() => window.dispatchEvent(new Event("alook:keyboard-change")))- await waitFor(() => expect(view.result.current.bottomInset).toBe(0))+ await waitFor(() => expect(view.result.current).toEqual(snapshot()))bottomInset = 320act(() => window.dispatchEvent(new Event("alook:keyboard-change")))- await waitFor(() => expect(view.result.current.bottomInset).toBe(320))+ await waitFor(() => expect(view.result.current).toEqual(snapshot(320)))expect(post).toHaveBeenLastCalledWith("snapshot")expect(post).toHaveBeenCalledTimes(3)})@@ -62,7 +62,7 @@ it("does not let an older native snapshot revive a later closed state", async ()const view = renderHook(useNativeKeyboard)act(() => window.dispatchEvent(new Event("alook:keyboard-change")))await act(async () => release(snapshot(300)))- expect(view.result.current.bottomInset).toBe(0)+ expect(view.result.current).toEqual(snapshot())expect(post).toHaveBeenCalledTimes(2)})@@ -78,14 +78,14 @@ it("retires pending snapshots and callbacks when a component leaves", async () =await act(async () => release(snapshot(300)))expect(oldPost).toHaveBeenCalledTimes(1)expect(nextPost).toHaveBeenCalledExactlyOnceWith("snapshot")- expect(next.result.current.bottomInset).toBe(0)+ expect(next.result.current).toEqual(snapshot())})it("retires on pagehide and resumes only the preserved document on BFCache return", async () => {const post = vi.fn(async () => snapshot(300))install(post)const view = renderHook(useNativeKeyboard)- await waitFor(() => expect(view.result.current.bottomInset).toBe(300))+ await waitFor(() => expect(view.result.current).toEqual(snapshot(300)))act(() => window.dispatchEvent(new PageTransitionEvent("pagehide")))const calls = post.mock.calls.lengthact(() => {@@ -93,9 +93,9 @@ it("retires on pagehide and resumes only the preserved document on BFCache returwindow.dispatchEvent(new PageTransitionEvent("pageshow", { persisted: false }))})expect(post).toHaveBeenCalledTimes(calls)- expect(view.result.current.bottomInset).toBe(0)+ expect(view.result.current).toBeNull()act(() => window.dispatchEvent(new PageTransitionEvent("pageshow", { persisted: true })))- await waitFor(() => expect(view.result.current.bottomInset).toBe(300))+ await waitFor(() => expect(view.result.current).toEqual(snapshot(300)))})it("keeps failed capability reads closed and accepts a later native state change", async () => {@@ -103,23 +103,23 @@ it("keeps failed capability reads closed and accepts a later native state changeinstall(post)const view = renderHook(useNativeKeyboard)await act(async () => {})- expect(view.result.current.bottomInset).toBe(0)+ expect(view.result.current).toBeNull()act(() => window.dispatchEvent(new Event("alook:keyboard-change")))- await waitFor(() => expect(view.result.current.bottomInset).toBe(300))+ await waitFor(() => expect(view.result.current).toEqual(snapshot(300)))})-it("converts native overlap points to the current CSS width and resamples on resize", async () => {+it("keeps native geometry intact and resamples on the existing resize event", async () => {const originalWidth = Object.getOwnPropertyDescriptor(window, "innerWidth")Object.defineProperty(window, "innerWidth", { configurable: true, value: 900 })const post = vi.fn(async () => snapshot(150, 450))install(post)const view = renderHook(useNativeKeyboard)try {- await waitFor(() => expect(view.result.current.bottomInset).toBe(300))+ await waitFor(() => expect(view.result.current).toEqual(snapshot(150, 450)))Object.defineProperty(window, "innerWidth", { configurable: true, value: 450 })act(() => window.dispatchEvent(new Event("resize")))- await waitFor(() => expect(view.result.current.bottomInset).toBe(150))+ await waitFor(() => expect(view.result.current).toEqual(snapshot(150, 450)))expect(post).toHaveBeenCalledTimes(2)} finally {view.unmount()@@ -127,12 +127,30 @@ it("converts native overlap points to the current CSS width and resamples on res}})+it("keeps native geometry independent of CSS width without a manual rerender", async () => {+ const originalWidth = Object.getOwnPropertyDescriptor(window, "innerWidth")+ Object.defineProperty(window, "innerWidth", { configurable: true, value: 382 })+ const post = vi.fn(async () => snapshot(244, 867))+ install(post)+ const view = renderHook(useNativeKeyboard)+ try {+ await waitFor(() => expect(view.result.current).toEqual(snapshot(244, 867)))+ const native = view.result.current+ Object.defineProperty(window, "innerWidth", { configurable: true, value: 867 })+ expect(view.result.current).toBe(native)+ expect(post).toHaveBeenCalledTimes(1)+ } finally {+ view.unmount()+ if (originalWidth) Object.defineProperty(window, "innerWidth", originalWidth)+ }+})+it.each([true, false, { bottomInset: -10, viewportWidth: 390 }, { bottomInset: 100, viewportWidth: 0 },{ bottomInset: Number.NaN, viewportWidth: 390 }, { bottomInset: 100, viewportWidth: Number.POSITIVE_INFINITY }])("does not use malformed or retired-format native geometry: %j", async (value) => {install(async () => value)const view = renderHook(useNativeKeyboard)await act(async () => {})- expect(view.result.current.bottomInset).toBe(0)+ expect(view.result.current).toBeNull()},)diff --git a/src/web/src/hooks/use-native-keyboard.ts b/src/web/src/hooks/use-native-keyboard.tsindex 92812716f..8f2f964cd 100644--- a/src/web/src/hooks/use-native-keyboard.ts+++ b/src/web/src/hooks/use-native-keyboard.ts@@ -16,8 +16,8 @@ function keyboardBridge() {return (window as KeyboardWindow).webkit?.messageHandlers?.alookKeyboard}-export function useNativeKeyboard() {- const [bottomInset, setBottomInset] = useState(0)+export function useNativeKeyboard(): KeyboardSnapshot | null {+ const [snapshot, setSnapshot] = useState<KeyboardSnapshot | null>(null)useEffect(() => {const bridge = keyboardBridge()if (!bridge) return@@ -31,13 +31,13 @@ export function useNativeKeyboard() {if (owner.active && request === revision) {const valid = next && Number.isFinite(next.bottomInset) && next.bottomInset >= 0&& Number.isFinite(next.viewportWidth) && next.viewportWidth > 0- setBottomInset(valid ? next.bottomInset * window.innerWidth / next.viewportWidth : 0)+ setSnapshot(valid ? { bottomInset: next.bottomInset, viewportWidth: next.viewportWidth } : null)}} catch {- if (owner.active && request === revision) setBottomInset(0)+ if (owner.active && request === revision) setSnapshot(null)}}- const hide = () => { owner.active = false; revision++; setBottomInset(0) }+ const hide = () => { owner.active = false; revision++; setSnapshot(null) }const show = (event: PageTransitionEvent) => {if (!event.persisted) returnowner.active = true@@ -57,5 +57,5 @@ export function useNativeKeyboard() {window.removeEventListener("pageshow", show)}}, [])- return { bottomInset }+ return snapshot}diff --git a/src/web/src/test/e2e-ui/native-keyboard-viewport-projection.spec.ts b/src/web/src/test/e2e-ui/native-keyboard-viewport-projection.spec.tsnew file mode 100644index 000000000..3f8b64c43--- /dev/null+++ b/src/web/src/test/e2e-ui/native-keyboard-viewport-projection.spec.ts@@ -0,0 +1,79 @@+import { test, expect } from "@playwright/test"+import { buildSync } from "esbuild"+import { resolve } from "node:path"+import { tid } from "../../lib/community/testids"++const webRoot = resolve(__dirname, "../../..")+const fixture = buildSync({+ stdin: {+ contents: `+ import React, { Profiler } from "react";+ import { createRoot } from "react-dom/client";+ import { ConversationFooterShell } from ${JSON.stringify(resolve(webRoot, "src/components/community/messages/conversation-footer-shell.tsx"))};+ import { tid } from ${JSON.stringify(resolve(webRoot, "src/lib/community/testids.ts"))};+ window.__TAURI__ = {};+ window.keyboardFixture = { calls: 0, commits: 0, hold: false };+ window.webkit = { messageHandlers: { alookKeyboard: { postMessage() {+ window.keyboardFixture.calls++;+ if (window.keyboardFixture.hold) return new Promise(() => {});+ return Promise.resolve({ bottomInset: 244, viewportWidth: 867 });+ } } } };+ createRoot(document.getElementById("root")).render(+ <Profiler id="keyboard" onRender={() => window.keyboardFixture.commits++}>+ <div style={{ height: "100vh", display: "flex", flexDirection: "column" }}>+ <div style={{ flex: 1, minHeight: 0 }}>Messages</div>+ <ConversationFooterShell {...{ "data-testid": tid.channelComposerShell }} style={{ height: 52, flexShrink: 0, position: "relative" }}>+ <input aria-label="Retained draft" defaultValue="QA295 fold keep" />+ </ConversationFooterShell>+ </div>+ </Profiler>+ );+ `,+ loader: "tsx",+ resolveDir: webRoot,+ sourcefile: "native-keyboard-component-fixture.tsx",+ },+ bundle: true,+ write: false,+ platform: "browser",+ format: "iife",+ tsconfig: resolve(webRoot, "tsconfig.json"),+ alias: { "@alook/shared": resolve(webRoot, "../shared/src/mode.ts") },+ define: {+ "process.env.NODE_ENV": JSON.stringify("development"),+ "process.env": JSON.stringify({ NODE_ENV: "development" }),+ },+}).outputFiles[0].text++test("native keyboard margin follows viewport changes without another reply or React commit", async ({ page }, testInfo) => {+ await page.setViewportSize({ width: 382, height: 639 })+ await page.setContent(`<style>+ body { margin: 0 }+ [data-slot="community-composer-accessory-slot"] { position: absolute }+ [data-slot="community-selection-footer-slot"] { display: none }+ </style><div id="root"></div>`)+ await page.addScriptTag({ content: fixture })+ const footer = page.getByTestId(tid.channelComposerShell)+ await expect.poll(() => footer.evaluate(node => Number.parseFloat(getComputedStyle(node).marginBottom)))+ .toBeCloseTo(244 * 382 / 867, 1)+ const before = await page.evaluate(() => {+ const fixture = (window as unknown as { keyboardFixture: { calls: number; commits: number; hold: boolean } }).keyboardFixture+ fixture.hold = true+ return { calls: fixture.calls, commits: fixture.commits }+ })+ await page.setViewportSize({ width: 867, height: 639 })+ const after = await footer.evaluate(node => {+ const fixture = (window as unknown as { keyboardFixture: { calls: number; commits: number } }).keyboardFixture+ return { width: innerWidth, margin: Number.parseFloat(getComputedStyle(node).marginBottom),+ bottom: node.getBoundingClientRect().bottom, calls: fixture.calls, commits: fixture.commits }+ })+ await testInfo.attach("viewport-projection", { body: JSON.stringify({ before, after }), contentType: "application/json" })+ expect(after.width).toBe(867)+ expect(after.margin).toBeCloseTo(244, 1)+ expect(after.bottom).toBeCloseTo(395, 1)+ expect(after.commits).toBe(before.commits)+ await expect(page.getByRole("textbox", { name: "Retained draft" })).toHaveValue("QA295 fold keep")+ await page.setViewportSize({ width: 382, height: 639 })+ expect(await footer.evaluate(node => Number.parseFloat(getComputedStyle(node).marginBottom)))+ .toBeCloseTo(244 * 382 / 867, 1)+})