mirror of
https://github.com/getpaseo/paseo.git
synced 2026-12-01 04:36:26 +00:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07d167ab82 | ||
|
|
2e83ac3225 | ||
|
|
e47c44b166 | ||
|
|
2209155b6f | ||
|
|
5037f7daf2 | ||
|
|
4293292d00 | ||
|
|
c94c3c47fe | ||
|
|
158032ac40 | ||
|
|
437fb8af0b | ||
|
|
2ef65f7691 | ||
|
|
79620eeea4 |
@@ -126,8 +126,12 @@ keeps Explorer underneath and closing the sheet uncovers it. Semantic navigation
|
|||||||
actual destination before revealing it, including deduplicated targets.
|
actual destination before revealing it, including deduplicated targets.
|
||||||
|
|
||||||
Compact overlay selection and saved dock visibility are independent. Folding changes geometry,
|
Compact overlay selection and saved dock visibility are independent. Folding changes geometry,
|
||||||
not either mode’s visibility intent. Native workspace retention remains one workspace; web retains
|
not either mode’s visibility intent. Native retains up to three recent workspaces; web retains
|
||||||
up to ten with its existing inactive TTL.
|
up to ten. Both use the existing inactive TTL. A native workspace with an open file sheet still
|
||||||
|
unmounts on navigation because its sheet stack uses the app-wide host. Other sheets close when
|
||||||
|
their retained owner becomes inactive, unless the owner already hides them on focus loss.
|
||||||
|
Import-session and tab-rename forms retain their open state on return. Review drafts survive
|
||||||
|
presentation unmounts.
|
||||||
|
|
||||||
PR discovery belongs to the active workspace: split layouts discover while active, and other
|
PR discovery belongs to the active workspace: split layouts discover while active, and other
|
||||||
layouts discover while Explorer is active. The rail requests summary status; selected visible PR
|
layouts discover while Explorer is active. The rail requests summary status; selected visible PR
|
||||||
|
|||||||
@@ -58,7 +58,9 @@ cannot deliver them.
|
|||||||
Register keyboard handling with `useOverlayRegistration` from `@/keyboard`.
|
Register keyboard handling with `useOverlayRegistration` from `@/keyboard`.
|
||||||
Pass the surface's open state, layer, handled keys and `onKeyDown`. The highest
|
Pass the surface's open state, layer, handled keys and `onKeyDown`. The highest
|
||||||
layer gets first refusal; the latest registration wins a tie. Native registration
|
layer gets first refusal; the latest registration wins a tie. Native registration
|
||||||
does not need a DOM ref. Web adds focus trapping and restoration through its adapter.
|
does not need a DOM ref. The native adapter releases overlay keyboard ownership when a retained
|
||||||
|
panel hides, even if the owner keeps its open state. Web releases ownership when the scope
|
||||||
|
detaches, preserving the original focus-return target across a hide.
|
||||||
Declaring Tab takes it from the web focus trap and hands it to `onKeyDown`; the command
|
Declaring Tab takes it from the web focus trap and hands it to `onKeyDown`; the command
|
||||||
center rotates its tabs with it. Native sources drop Tab from the declarations.
|
center rotates its tabs with it. Native sources drop Tab from the declarations.
|
||||||
|
|
||||||
|
|||||||
@@ -148,3 +148,51 @@ test.describe("mobile bottom sheet reopen", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function switchToNextWorkspace(page: Page, workspaceId: string) {
|
||||||
|
await page.keyboard.press("Alt+]");
|
||||||
|
await page.waitForURL((url) => url.pathname.endsWith(`/workspace/${workspaceId}`));
|
||||||
|
}
|
||||||
|
|
||||||
|
test("leaving a retained workspace dismisses its model sheet", async ({ page }) => {
|
||||||
|
const first = await openMockAgentAtMobileBreakpoint(page);
|
||||||
|
const second = await seedMockAgentWorkspace({
|
||||||
|
repoPrefix: "sheet-other-workspace-",
|
||||||
|
title: "Other workspace",
|
||||||
|
initialPrompt: "Prepare another workspace.",
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await openModelSelector(page);
|
||||||
|
await switchToNextWorkspace(page, second.workspaceId);
|
||||||
|
await expect(page.getByTestId("agent-controls-model-sheet")).not.toBeInViewport();
|
||||||
|
await expectComposerVisible(page);
|
||||||
|
await switchToNextWorkspace(page, first.workspaceId);
|
||||||
|
await expect(page.getByTestId("agent-controls-model-sheet")).not.toBeInViewport();
|
||||||
|
await expectComposerVisible(page);
|
||||||
|
} finally {
|
||||||
|
await second.cleanup();
|
||||||
|
await first.cleanup();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("leaving a retained workspace closes its context window sheet", async ({ page }) => {
|
||||||
|
const first = await openMockAgentAtMobileBreakpoint(page);
|
||||||
|
const second = await seedMockAgentWorkspace({
|
||||||
|
repoPrefix: "context-sheet-other-",
|
||||||
|
title: "Other workspace",
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await page.getByRole("button", { name: /Context window.*used/ }).click();
|
||||||
|
const sheet = page.getByRole("dialog", { name: "Context window", exact: true });
|
||||||
|
await expect(sheet).toBeInViewport();
|
||||||
|
await switchToNextWorkspace(page, second.workspaceId);
|
||||||
|
await expect(sheet).not.toBeInViewport();
|
||||||
|
await expectComposerVisible(page);
|
||||||
|
await switchToNextWorkspace(page, first.workspaceId);
|
||||||
|
await expect(sheet).not.toBeInViewport();
|
||||||
|
await expectComposerVisible(page);
|
||||||
|
} finally {
|
||||||
|
await second.cleanup();
|
||||||
|
await first.cleanup();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent";
|
||||||
import { expect, test } from "../support/fixtures";
|
import { expect, test } from "../support/fixtures";
|
||||||
import { clickNewChat } from "../support/helpers/launcher";
|
import { clickNewChat } from "../support/helpers/launcher";
|
||||||
import { expectComposerVisible } from "../support/helpers/composer";
|
import { expectComposerVisible } from "../support/helpers/composer";
|
||||||
@@ -310,3 +311,32 @@ test.describe("Composer attachments", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("image lightbox hides when its retained workspace becomes inactive", async ({ page }) => {
|
||||||
|
const first = await seedMockAgentWorkspace({
|
||||||
|
repoPrefix: "image-owner-",
|
||||||
|
title: "Image workspace",
|
||||||
|
});
|
||||||
|
const second = await seedMockAgentWorkspace({
|
||||||
|
repoPrefix: "image-other-",
|
||||||
|
title: "Other workspace",
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await openAgentRoute(page, first);
|
||||||
|
await expectComposerVisible(page);
|
||||||
|
await attachImageFromMenu(page, TEST_IMAGE);
|
||||||
|
await openImageLightbox(page);
|
||||||
|
await page.keyboard.press("Alt+]");
|
||||||
|
await page.waitForURL((url) => url.pathname.endsWith(`/workspace/${second.workspaceId}`));
|
||||||
|
await expect(page.getByTestId("attachment-lightbox-close")).not.toBeVisible();
|
||||||
|
await expectComposerVisible(page);
|
||||||
|
await page.keyboard.press("Alt+]");
|
||||||
|
await page.waitForURL((url) => url.pathname.endsWith(`/workspace/${first.workspaceId}`));
|
||||||
|
await expect(page.getByTestId("attachment-lightbox-close")).toBeVisible();
|
||||||
|
await closeImageLightbox(page);
|
||||||
|
await expect(page.getByRole("button", { name: "Open image attachment" }).first()).toBeFocused();
|
||||||
|
} finally {
|
||||||
|
await second.cleanup();
|
||||||
|
await first.cleanup();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
@@ -248,6 +248,33 @@ test.describe("review comments", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("compact review draft survives a workspace switch", async ({ page }) => {
|
||||||
|
const workspace = await seedChangedAgent("retained-review-draft-");
|
||||||
|
const other = await seedMockAgentWorkspace({
|
||||||
|
repoPrefix: "review-other-",
|
||||||
|
title: "Other workspace",
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await openReviewDiff(page, workspace);
|
||||||
|
await showCompactLayout(page);
|
||||||
|
await tapFirstAddedDiffLine(page);
|
||||||
|
await expectCompactCommentSheet(page);
|
||||||
|
await fillReviewComment(page, "Keep this unsaved review");
|
||||||
|
await page.keyboard.press("Alt+]");
|
||||||
|
await page.waitForURL((url) => url.pathname.endsWith(`/workspace/${other.workspaceId}`));
|
||||||
|
await expect(page.getByTestId("review-comment-sheet")).not.toBeInViewport();
|
||||||
|
await page.keyboard.press("Alt+]");
|
||||||
|
await page.waitForURL((url) => url.pathname.endsWith(`/workspace/${workspace.workspaceId}`));
|
||||||
|
await expect(page.getByRole("textbox", { name: "Review comment" })).toHaveValue(
|
||||||
|
"Keep this unsaved review",
|
||||||
|
);
|
||||||
|
await cancelReviewComment(page);
|
||||||
|
} finally {
|
||||||
|
await other.cleanup();
|
||||||
|
await workspace.cleanup();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test("wide review comments retain inline editing", async ({ page }) => {
|
test("wide review comments retain inline editing", async ({ page }) => {
|
||||||
const workspace = await seedChangedAgent("wide-review-comment-");
|
const workspace = await seedChangedAgent("wide-review-comment-");
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ function enableDictationCapability(message: WebSocketMessage): WebSocketMessage
|
|||||||
async function installSyntheticMicrophone(page: Page): Promise<void> {
|
async function installSyntheticMicrophone(page: Page): Promise<void> {
|
||||||
await page.addInitScript(() => {
|
await page.addInitScript(() => {
|
||||||
const mediaDevices = navigator.mediaDevices;
|
const mediaDevices = navigator.mediaDevices;
|
||||||
|
const tracks: MediaStreamTrack[] = [];
|
||||||
|
Object.defineProperty(window, "dictationTestTracks", { value: tracks });
|
||||||
Object.defineProperty(mediaDevices, "getUserMedia", {
|
Object.defineProperty(mediaDevices, "getUserMedia", {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
value: async () => {
|
value: async () => {
|
||||||
@@ -78,13 +80,15 @@ async function installSyntheticMicrophone(page: Page): Promise<void> {
|
|||||||
const destination = context.createMediaStreamDestination();
|
const destination = context.createMediaStreamDestination();
|
||||||
oscillator.connect(destination);
|
oscillator.connect(destination);
|
||||||
oscillator.start();
|
oscillator.start();
|
||||||
|
tracks.push(...destination.stream.getTracks());
|
||||||
return destination.stream;
|
return destination.stream;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function installDictationFailureHarness(page: Page) {
|
async function installDictationFailureHarness(page: Page, holdTranscript = false) {
|
||||||
|
let deliverTranscript: (() => void) | null = null;
|
||||||
let resolveAudioChunk!: () => void;
|
let resolveAudioChunk!: () => void;
|
||||||
let resolveCreateRequest!: () => void;
|
let resolveCreateRequest!: () => void;
|
||||||
const audioChunk = new Promise<void>((resolve) => {
|
const audioChunk = new Promise<void>((resolve) => {
|
||||||
@@ -122,12 +126,14 @@ async function installDictationFailureHarness(page: Page) {
|
|||||||
if (type === "dictation_stream_finish" && dictationId) {
|
if (type === "dictation_stream_finish" && dictationId) {
|
||||||
sendSessionMessage(ws, {
|
sendSessionMessage(ws, {
|
||||||
type: "dictation_stream_finish_accepted",
|
type: "dictation_stream_finish_accepted",
|
||||||
payload: { dictationId, timeoutMs: 5_000 },
|
payload: { dictationId, timeoutMs: holdTranscript ? 60_000 : 5_000 },
|
||||||
});
|
|
||||||
sendSessionMessage(ws, {
|
|
||||||
type: "dictation_stream_final",
|
|
||||||
payload: { dictationId, text: TRANSCRIPT },
|
|
||||||
});
|
});
|
||||||
|
deliverTranscript = () =>
|
||||||
|
sendSessionMessage(ws, {
|
||||||
|
type: "dictation_stream_final",
|
||||||
|
payload: { dictationId, text: TRANSCRIPT },
|
||||||
|
});
|
||||||
|
if (!holdTranscript) deliverTranscript();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (request && type === "workspace.create.request" && typeof request.requestId === "string") {
|
if (request && type === "workspace.create.request" && typeof request.requestId === "string") {
|
||||||
@@ -155,6 +161,11 @@ async function installDictationFailureHarness(page: Page) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
waitForAudio: () => audioChunk,
|
waitForAudio: () => audioChunk,
|
||||||
|
hasPendingTranscript: () => deliverTranscript !== null,
|
||||||
|
deliverTranscript: () => {
|
||||||
|
if (!deliverTranscript) throw new Error("No pending transcript");
|
||||||
|
deliverTranscript();
|
||||||
|
},
|
||||||
waitForCreateRequest: () => createRequest,
|
waitForCreateRequest: () => createRequest,
|
||||||
failWorkspaceCreation: () => {
|
failWorkspaceCreation: () => {
|
||||||
if (!failCreate) {
|
if (!failCreate) {
|
||||||
@@ -254,3 +265,75 @@ test("dictation shortcut leaves retained fullscreen and exposes recording contro
|
|||||||
await agent.cleanup();
|
await agent.cleanup();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("leaving a retained workspace stops dictation and preserves its draft", async ({ page }) => {
|
||||||
|
const first = await seedMockAgentWorkspace({
|
||||||
|
repoPrefix: "dictation-owner-",
|
||||||
|
title: "Recording workspace",
|
||||||
|
});
|
||||||
|
const second = await seedMockAgentWorkspace({
|
||||||
|
repoPrefix: "dictation-other-",
|
||||||
|
title: "Other workspace",
|
||||||
|
});
|
||||||
|
await installSyntheticMicrophone(page);
|
||||||
|
const harness = await installDictationFailureHarness(page);
|
||||||
|
try {
|
||||||
|
await openAgentRoute(page, first);
|
||||||
|
await expectComposerVisible(page);
|
||||||
|
await fillComposerDraft(page, "Keep this draft");
|
||||||
|
await page.getByRole("button", { name: "Start dictation", exact: true }).click();
|
||||||
|
await harness.waitForAudio();
|
||||||
|
await page.keyboard.press("Alt+]");
|
||||||
|
await page.waitForURL((url) => url.pathname.endsWith(`/workspace/${second.workspaceId}`));
|
||||||
|
await expect.poll(() => microphoneTracksEnded(page)).toBe(true);
|
||||||
|
await page.keyboard.press("Alt+]");
|
||||||
|
await page.waitForURL((url) => url.pathname.endsWith(`/workspace/${first.workspaceId}`));
|
||||||
|
await expect(composerLocator(page)).toHaveValue("Keep this draft");
|
||||||
|
await expect(page.getByRole("button", { name: "Cancel dictation", exact: true })).toHaveCount(
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
await second.cleanup();
|
||||||
|
await first.cleanup();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function microphoneTracksEnded(page: Page): Promise<boolean> {
|
||||||
|
return page.evaluate(() => {
|
||||||
|
const tracks = (window as unknown as { dictationTestTracks: MediaStreamTrack[] })
|
||||||
|
.dictationTestTracks;
|
||||||
|
return tracks.length > 0 && tracks.every((track) => track.readyState === "ended");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
test("confirmed dictation survives leaving and returning while pending", async ({ page }) => {
|
||||||
|
const first = await seedMockAgentWorkspace({
|
||||||
|
repoPrefix: "dictation-processing-",
|
||||||
|
title: "Processing workspace",
|
||||||
|
});
|
||||||
|
const second = await seedMockAgentWorkspace({
|
||||||
|
repoPrefix: "dictation-other-",
|
||||||
|
title: "Other workspace",
|
||||||
|
});
|
||||||
|
await installSyntheticMicrophone(page);
|
||||||
|
const harness = await installDictationFailureHarness(page, true);
|
||||||
|
try {
|
||||||
|
await openAgentRoute(page, first);
|
||||||
|
await expectComposerVisible(page);
|
||||||
|
await page.getByRole("button", { name: "Start dictation", exact: true }).click();
|
||||||
|
await harness.waitForAudio();
|
||||||
|
await page.getByRole("button", { name: "Insert transcription", exact: true }).click();
|
||||||
|
await expect.poll(harness.hasPendingTranscript).toBe(true);
|
||||||
|
await page.keyboard.press("Alt+]");
|
||||||
|
await page.waitForURL((url) => url.pathname.endsWith(`/workspace/${second.workspaceId}`));
|
||||||
|
await expect.poll(() => microphoneTracksEnded(page)).toBe(true);
|
||||||
|
await page.keyboard.press("Alt+]");
|
||||||
|
await page.waitForURL((url) => url.pathname.endsWith(`/workspace/${first.workspaceId}`));
|
||||||
|
await expect(page.getByRole("button", { name: "Cancel dictation", exact: true })).toBeVisible();
|
||||||
|
harness.deliverTranscript();
|
||||||
|
await expect(composerLocator(page)).toHaveValue(TRANSCRIPT);
|
||||||
|
} finally {
|
||||||
|
await second.cleanup();
|
||||||
|
await first.cleanup();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
@@ -237,7 +237,12 @@ function WorkspaceDeckEntry({
|
|||||||
}) {
|
}) {
|
||||||
const hasHydratedWorkspaces = useHasHydratedWorkspaces(selection.serverId);
|
const hasHydratedWorkspaces = useHasHydratedWorkspaces(selection.serverId);
|
||||||
const workspaceExists = useWorkspaceExists(selection.serverId, selection.workspaceId);
|
const workspaceExists = useWorkspaceExists(selection.serverId, selection.workspaceId);
|
||||||
|
const hasOpenNativeSheets = useWorkspaceLayoutStore(
|
||||||
|
(state) =>
|
||||||
|
isNative && (state.sheetsByWorkspace[getWorkspaceSelectionKey(selection)]?.length ?? 0) > 0,
|
||||||
|
);
|
||||||
const shouldKeepMounted = shouldKeepWorkspaceDeckEntryMounted({
|
const shouldKeepMounted = shouldKeepWorkspaceDeckEntryMounted({
|
||||||
|
hasOpenNativeSheets,
|
||||||
isActive: active,
|
isActive: active,
|
||||||
hasHydratedWorkspaces,
|
hasHydratedWorkspaces,
|
||||||
workspaceExists,
|
workspaceExists,
|
||||||
|
|||||||
@@ -662,7 +662,7 @@ function CompactSheetBody({
|
|||||||
|
|
||||||
export function AdaptiveModalSheet({
|
export function AdaptiveModalSheet({
|
||||||
header,
|
header,
|
||||||
visible,
|
visible: requestedVisible,
|
||||||
onClose,
|
onClose,
|
||||||
onDismiss,
|
onDismiss,
|
||||||
children,
|
children,
|
||||||
@@ -680,9 +680,15 @@ export function AdaptiveModalSheet({
|
|||||||
}: AdaptiveModalSheetProps) {
|
}: AdaptiveModalSheetProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const isMobile = useIsCompactFormFactor();
|
const isMobile = useIsCompactFormFactor();
|
||||||
const isKeyboardVisible = useKeyboardVisibility(visible);
|
|
||||||
const resolvedSnapPoints = useMemo(() => snapPoints ?? ["65%", "90%"], [snapPoints]);
|
const resolvedSnapPoints = useMemo(() => snapPoints ?? ["65%", "90%"], [snapPoints]);
|
||||||
const isSheet = isMobile || !isWeb;
|
const isSheet = isMobile || !isWeb;
|
||||||
|
const { visible, sheetRef, handleSheetChange, handleSheetDismiss } =
|
||||||
|
useIsolatedBottomSheetVisibility({
|
||||||
|
visible: requestedVisible,
|
||||||
|
isEnabled: isSheet,
|
||||||
|
onClose,
|
||||||
|
});
|
||||||
|
const isKeyboardVisible = useKeyboardVisibility(visible);
|
||||||
// The sheet registers itself; the desktop dialog does not use it.
|
// The sheet registers itself; the desktop dialog does not use it.
|
||||||
useDismissibleOverlay(visible && !isSheet, onClose);
|
useDismissibleOverlay(visible && !isSheet, onClose);
|
||||||
const footerView = useMemo(
|
const footerView = useMemo(
|
||||||
@@ -697,11 +703,6 @@ export function AdaptiveModalSheet({
|
|||||||
}
|
}
|
||||||
}, [visible]);
|
}, [visible]);
|
||||||
|
|
||||||
const { sheetRef, handleSheetChange, handleSheetDismiss } = useIsolatedBottomSheetVisibility({
|
|
||||||
visible,
|
|
||||||
isEnabled: isSheet,
|
|
||||||
onClose,
|
|
||||||
});
|
|
||||||
const [shouldRenderWeb, setShouldRenderWeb] = useState(visible);
|
const [shouldRenderWeb, setShouldRenderWeb] = useState(visible);
|
||||||
const [isWebClosing, setIsWebClosing] = useState(false);
|
const [isWebClosing, setIsWebClosing] = useState(false);
|
||||||
const modalLayer = useGlobalOverlayLayer("modal", visible || shouldRenderWeb);
|
const modalLayer = useGlobalOverlayLayer("modal", visible || shouldRenderWeb);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useRetainedPanelActive } from "@/components/retained-panel";
|
||||||
import {
|
import {
|
||||||
BottomSheetModal as GorhomBottomSheetModal,
|
BottomSheetModal as GorhomBottomSheetModal,
|
||||||
type BottomSheetModalProps,
|
type BottomSheetModalProps,
|
||||||
@@ -160,7 +161,7 @@ export const IsolatedBottomSheetModal = forwardRef<
|
|||||||
});
|
});
|
||||||
|
|
||||||
export function useIsolatedBottomSheetVisibility({
|
export function useIsolatedBottomSheetVisibility({
|
||||||
visible,
|
visible: requestedVisible,
|
||||||
isEnabled,
|
isEnabled,
|
||||||
onClose,
|
onClose,
|
||||||
onBack,
|
onBack,
|
||||||
@@ -171,6 +172,8 @@ export function useIsolatedBottomSheetVisibility({
|
|||||||
/** Offered Android Back before it closes the sheet; returns true when it handled the press. */
|
/** Offered Android Back before it closes the sheet; returns true when it handled the press. */
|
||||||
onBack?: () => boolean;
|
onBack?: () => boolean;
|
||||||
}) {
|
}) {
|
||||||
|
const active = useRetainedPanelActive();
|
||||||
|
const visible = requestedVisible && active;
|
||||||
const onCloseRef = useRef(onClose);
|
const onCloseRef = useRef(onClose);
|
||||||
onCloseRef.current = onClose;
|
onCloseRef.current = onClose;
|
||||||
const onBackRef = useRef(onBack);
|
const onBackRef = useRef(onBack);
|
||||||
@@ -201,11 +204,12 @@ export function useIsolatedBottomSheetVisibility({
|
|||||||
const handleSheetDismiss = useCallback(() => tracker.handleSheetDismiss(), [tracker]);
|
const handleSheetDismiss = useCallback(() => tracker.handleSheetDismiss(), [tracker]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
tracker.syncDesired({ visible, isEnabled });
|
tracker.syncDesired({ visible: requestedVisible, active, isEnabled });
|
||||||
}, [isEnabled, tracker, visible]);
|
}, [active, isEnabled, tracker, requestedVisible]);
|
||||||
useDismissibleOverlay(visible && isEnabled !== false, onClose);
|
useDismissibleOverlay(visible && isEnabled !== false, onClose);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
visible,
|
||||||
sheetRef: setSheetRef,
|
sheetRef: setSheetRef,
|
||||||
handleSheetChange,
|
handleSheetChange,
|
||||||
handleSheetDismiss,
|
handleSheetDismiss,
|
||||||
|
|||||||
@@ -291,3 +291,46 @@ it("does not cancel the owner's editor when the compact sheet leaves the tree on
|
|||||||
expect(context.closeCount()).toBe(0);
|
expect(context.closeCount()).toBe(0);
|
||||||
expect(context.backPress.press()).toBe(false);
|
expect(context.backPress.press()).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("closes a retained owner's sheet and releases Back when the owner becomes inactive", () => {
|
||||||
|
const { sheet, tracker, backPress, closeCount } = setup();
|
||||||
|
tracker.attachController(sheet);
|
||||||
|
tracker.syncDesired({ visible: true, active: true });
|
||||||
|
tracker.handleSheetIndexChange(0);
|
||||||
|
tracker.syncDesired({ visible: true, active: false });
|
||||||
|
expect(sheet.events).toEqual([{ type: "present" }, { type: "dismiss" }]);
|
||||||
|
expect(closeCount()).toBe(1);
|
||||||
|
expect(backPress.press()).toBe(false);
|
||||||
|
tracker.syncDesired({ visible: false, active: false });
|
||||||
|
tracker.handleSheetDismiss();
|
||||||
|
tracker.syncDesired({ visible: false, active: true });
|
||||||
|
expect(sheet.events).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("dismisses a late opening after the inactive owner acknowledges closure", () => {
|
||||||
|
const { sheet, tracker, backPress, closeCount } = setup();
|
||||||
|
tracker.attachController(sheet);
|
||||||
|
tracker.syncDesired({ visible: true, active: true });
|
||||||
|
tracker.syncDesired({ visible: true, active: false });
|
||||||
|
expect(closeCount()).toBe(1);
|
||||||
|
tracker.syncDesired({ visible: false, active: false });
|
||||||
|
// Gorhom can drop an early dismiss before its first layout measurement.
|
||||||
|
tracker.handleSheetIndexChange(0);
|
||||||
|
expect(sheet.events).toEqual([{ type: "present" }, { type: "dismiss" }, { type: "dismiss" }]);
|
||||||
|
expect(backPress.press()).toBe(false);
|
||||||
|
tracker.handleSheetDismiss();
|
||||||
|
tracker.syncDesired({ visible: false, active: true });
|
||||||
|
expect(sheet.events).toHaveLength(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("closes a disabled presentation on every departure after owner acknowledgement", () => {
|
||||||
|
const { tracker, closeCount } = setup();
|
||||||
|
for (let departure = 1; departure <= 2; departure++) {
|
||||||
|
tracker.syncDesired({ visible: true, active: true, isEnabled: false });
|
||||||
|
tracker.syncDesired({ visible: true, active: false, isEnabled: false });
|
||||||
|
tracker.syncDesired({ visible: true, active: false, isEnabled: false });
|
||||||
|
expect(closeCount()).toBe(departure);
|
||||||
|
tracker.syncDesired({ visible: false, active: false, isEnabled: false });
|
||||||
|
tracker.syncDesired({ visible: false, active: true, isEnabled: false });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export interface BottomSheetController {
|
|||||||
|
|
||||||
export interface BottomSheetVisibilityInput {
|
export interface BottomSheetVisibilityInput {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
|
active?: boolean;
|
||||||
isEnabled?: boolean;
|
isEnabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,8 +102,16 @@ export function createBottomSheetVisibilityTracker(opts: {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
syncDesired(next) {
|
syncDesired(next) {
|
||||||
visible = next.visible;
|
visible = next.visible && next.active !== false;
|
||||||
isEnabled = next.isEnabled;
|
isEnabled = next.isEnabled;
|
||||||
|
if (!next.visible) hasNotifiedClose = false;
|
||||||
|
// Leaving a retained owner is a close, not a temporary presentation pause.
|
||||||
|
// Clear its desired state so returning does not reopen the old sheet.
|
||||||
|
if (next.visible && next.active === false) {
|
||||||
|
dismiss();
|
||||||
|
notifyClose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isEnabled === false) return;
|
if (isEnabled === false) return;
|
||||||
if (visible) {
|
if (visible) {
|
||||||
present();
|
present();
|
||||||
@@ -117,9 +126,7 @@ export function createBottomSheetVisibilityTracker(opts: {
|
|||||||
},
|
},
|
||||||
handleSheetIndexChange(index) {
|
handleSheetIndexChange(index) {
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
if (phase === "presenting" || phase === "dismissing") {
|
setPhase("presented");
|
||||||
setPhase("presented");
|
|
||||||
}
|
|
||||||
// A dismiss sent before the sheet measured its layout is dropped, and the sheet still
|
// A dismiss sent before the sheet measured its layout is dropped, and the sheet still
|
||||||
// finishes opening. The owner wants it hidden, so it goes again.
|
// finishes opening. The owner wants it hidden, so it goes again.
|
||||||
if (!visible && isEnabled !== false) {
|
if (!visible && isEnabled !== false) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useRetainedPanelActive } from "@/components/retained-panel";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import {
|
import {
|
||||||
Modal as NativeModal,
|
Modal as NativeModal,
|
||||||
@@ -23,11 +24,23 @@ type ModalProps = Omit<NativeModalProps, "onRequestClose"> & {
|
|||||||
function noClose() {}
|
function noClose() {}
|
||||||
|
|
||||||
export function Modal(props: ModalProps) {
|
export function Modal(props: ModalProps) {
|
||||||
const { visible = true, onRequestClose, style } = props;
|
const { visible: requestedVisible = true, onRequestClose, style } = props;
|
||||||
|
const active = useRetainedPanelActive();
|
||||||
|
const visible = requestedVisible && active;
|
||||||
useDismissibleOverlay(visible && onRequestClose !== undefined, onRequestClose ?? noClose);
|
useDismissibleOverlay(visible && onRequestClose !== undefined, onRequestClose ?? noClose);
|
||||||
const windowFrame = useAndroidWindowFrame();
|
const windowFrame = useAndroidWindowFrame();
|
||||||
const containerStyle = useMemo(() => [windowFrame, style], [windowFrame, style]);
|
const containerStyle = useMemo(() => [windowFrame, style], [windowFrame, style]);
|
||||||
return <NativeModal supportedOrientations={orientations} {...props} style={containerStyle} />;
|
// Hidden web chats freeze before a modal exit animation can finish.
|
||||||
|
// Remove the portal while its owner is inactive.
|
||||||
|
if (!active) return null;
|
||||||
|
return (
|
||||||
|
<NativeModal
|
||||||
|
supportedOrientations={orientations}
|
||||||
|
{...props}
|
||||||
|
visible={visible}
|
||||||
|
style={containerStyle}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useRetainedPanelActive } from "@/components/retained-panel";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ import {
|
|||||||
|
|
||||||
export function useDictation(options: UseDictationOptions): UseDictationResult {
|
export function useDictation(options: UseDictationOptions): UseDictationResult {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const active = useRetainedPanelActive();
|
||||||
const {
|
const {
|
||||||
client,
|
client,
|
||||||
onTranscript,
|
onTranscript,
|
||||||
@@ -336,6 +338,10 @@ export function useDictation(options: UseDictationOptions): UseDictationResult {
|
|||||||
}
|
}
|
||||||
}, [audio, clearStreamingState, reportError, stopDurationTracking]);
|
}, [audio, clearStreamingState, reportError, stopDurationTracking]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!active && isRecording && !isProcessing) void cancelDictation();
|
||||||
|
}, [active, cancelDictation, isRecording, isProcessing]);
|
||||||
|
|
||||||
const confirmDictation = useCallback(async () => {
|
const confirmDictation = useCallback(async () => {
|
||||||
if (actionGateRef.current.confirming) {
|
if (actionGateRef.current.confirming) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
|
import { useRetainedPanelActive } from "@/components/retained-panel";
|
||||||
import type { OverlayRegistration } from "./overlay-contract";
|
import type { OverlayRegistration } from "./overlay-contract";
|
||||||
import { useLayoutEffect, useRef } from "react";
|
import { useLayoutEffect, useRef } from "react";
|
||||||
import { overlays } from "./overlays";
|
import { overlays } from "./overlays";
|
||||||
|
|
||||||
const setScope = (_node: unknown) => {};
|
const setScope = (_node: unknown) => {};
|
||||||
export function useOverlayRegistration(input: OverlayRegistration) {
|
export function useOverlayRegistration(input: OverlayRegistration) {
|
||||||
|
const ownerActive = useRetainedPanelActive();
|
||||||
|
const active = input.active && ownerActive;
|
||||||
const current = useRef(input);
|
const current = useRef(input);
|
||||||
current.current = input;
|
current.current = input;
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!input.active) return;
|
if (!active) return;
|
||||||
return overlays.register({
|
return overlays.register({
|
||||||
getLayer: () => current.current.layer,
|
getLayer: () => current.current.layer,
|
||||||
getKeys: () => current.current.keys,
|
getKeys: () => current.current.keys,
|
||||||
onKeyDown: (event) => current.current.onKeyDown(event),
|
onKeyDown: (event) => current.current.onKeyDown(event),
|
||||||
});
|
});
|
||||||
}, [input.active]);
|
}, [active]);
|
||||||
return setScope;
|
return setScope;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
|
||||||
import { buildEffectiveBindings } from "./keyboard-shortcuts";
|
|
||||||
import { createKeyboardPipeline } from "./internal/pipeline";
|
|
||||||
import { createOverlayRegistry } from "./internal/overlays";
|
|
||||||
describe("DOM source adapter", () => {
|
|
||||||
it("runs DOM input through the same resolver, preserving cancellation and cleanup", async () => {
|
|
||||||
const { attachDomKeyboardSource } = await import("./internal/sources/dom.web");
|
|
||||||
const actions: string[] = [];
|
|
||||||
const input = document.createElement("textarea");
|
|
||||||
input.dataset.testid = "message-input";
|
|
||||||
document.body.append(input);
|
|
||||||
input.focus();
|
|
||||||
const pipeline = createKeyboardPipeline({
|
|
||||||
getContext: () => ({ isMac: true, usesDesktopBindings: false, commandCenterOpen: false }),
|
|
||||||
getBindings: () => buildEffectiveBindings({ "command-center-toggle-cmd-k-mac": "Cmd+J" }),
|
|
||||||
isCapturing: () => false,
|
|
||||||
dispatch: (match) => {
|
|
||||||
actions.push(match.action);
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
overlays: createOverlayRegistry(),
|
|
||||||
});
|
|
||||||
const detach = attachDomKeyboardSource({
|
|
||||||
keyDown: pipeline.keyDown,
|
|
||||||
keyUp() {},
|
|
||||||
blur() {},
|
|
||||||
commandCenterOpen: () => false,
|
|
||||||
subscribeCommandCenter: () => () => {},
|
|
||||||
});
|
|
||||||
const event = new KeyboardEvent("keydown", {
|
|
||||||
key: "j",
|
|
||||||
code: "KeyJ",
|
|
||||||
metaKey: true,
|
|
||||||
bubbles: true,
|
|
||||||
cancelable: true,
|
|
||||||
});
|
|
||||||
input.dispatchEvent(event);
|
|
||||||
expect(actions).toEqual(["command-center.toggle"]);
|
|
||||||
expect(event.defaultPrevented).toBe(true);
|
|
||||||
detach();
|
|
||||||
input.dispatchEvent(
|
|
||||||
new KeyboardEvent("keydown", { key: "j", code: "KeyJ", metaKey: true, bubbles: true }),
|
|
||||||
);
|
|
||||||
expect(actions).toHaveLength(1);
|
|
||||||
input.remove();
|
|
||||||
pipeline.dispose();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { buildEffectiveBindings } from "./keyboard-shortcuts";
|
||||||
|
import { createKeyboardPipeline } from "./internal/pipeline";
|
||||||
|
import { createOverlayRegistry } from "./internal/overlays";
|
||||||
|
describe("DOM source adapter", () => {
|
||||||
|
it("runs DOM input through the same resolver, preserving cancellation and cleanup", async () => {
|
||||||
|
const { attachDomKeyboardSource } = await import("./internal/sources/dom.web");
|
||||||
|
const actions: string[] = [];
|
||||||
|
const input = document.createElement("textarea");
|
||||||
|
input.dataset.testid = "message-input";
|
||||||
|
document.body.append(input);
|
||||||
|
input.focus();
|
||||||
|
const pipeline = createKeyboardPipeline({
|
||||||
|
getContext: () => ({ isMac: true, usesDesktopBindings: false, commandCenterOpen: false }),
|
||||||
|
getBindings: () => buildEffectiveBindings({ "command-center-toggle-cmd-k-mac": "Cmd+J" }),
|
||||||
|
isCapturing: () => false,
|
||||||
|
dispatch: (match) => {
|
||||||
|
actions.push(match.action);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
overlays: createOverlayRegistry(),
|
||||||
|
});
|
||||||
|
const detach = attachDomKeyboardSource({
|
||||||
|
keyDown: pipeline.keyDown,
|
||||||
|
keyUp() {},
|
||||||
|
blur() {},
|
||||||
|
commandCenterOpen: () => false,
|
||||||
|
subscribeCommandCenter: () => () => {},
|
||||||
|
});
|
||||||
|
const event = new KeyboardEvent("keydown", {
|
||||||
|
key: "j",
|
||||||
|
code: "KeyJ",
|
||||||
|
metaKey: true,
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
});
|
||||||
|
input.dispatchEvent(event);
|
||||||
|
expect(actions).toEqual(["command-center.toggle"]);
|
||||||
|
expect(event.defaultPrevented).toBe(true);
|
||||||
|
detach();
|
||||||
|
input.dispatchEvent(
|
||||||
|
new KeyboardEvent("keydown", { key: "j", code: "KeyJ", metaKey: true, bubbles: true }),
|
||||||
|
);
|
||||||
|
expect(actions).toHaveLength(1);
|
||||||
|
input.remove();
|
||||||
|
pipeline.dispose();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("releases a hidden retained owner's overlay keys while its scope stays mounted", async () => {
|
||||||
|
const { createElement, act } = await import("react");
|
||||||
|
const { createRoot } = await import("react-dom/client");
|
||||||
|
const { RetainedPanelActivity } = await import("@/components/retained-panel");
|
||||||
|
const { getTopOverlayKeys, hasActiveOverlay } = await import("./index");
|
||||||
|
// Exercise the native adapter itself in a real React renderer, bypassing Vite's .web resolution.
|
||||||
|
const nativeAdapterPath = "./internal/overlay-registration.ts";
|
||||||
|
const { useOverlayRegistration } = (await import(
|
||||||
|
/* @vite-ignore */ nativeAdapterPath
|
||||||
|
)) as typeof import("./internal/overlay-registration");
|
||||||
|
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
||||||
|
const container = document.createElement("div");
|
||||||
|
document.body.append(container);
|
||||||
|
const root = createRoot(container);
|
||||||
|
function Viewer() {
|
||||||
|
const scope = useOverlayRegistration({
|
||||||
|
active: true,
|
||||||
|
layer: 100,
|
||||||
|
keys: ["Escape"],
|
||||||
|
manageFocus: false,
|
||||||
|
onKeyDown: () => true,
|
||||||
|
});
|
||||||
|
return createElement("button", { ref: scope, type: "button" }, "Viewer");
|
||||||
|
}
|
||||||
|
async function render(active: boolean) {
|
||||||
|
await act(async () =>
|
||||||
|
root.render(
|
||||||
|
<RetainedPanelActivity active={active}>
|
||||||
|
<Viewer />
|
||||||
|
</RetainedPanelActivity>,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await render(true);
|
||||||
|
expect(getTopOverlayKeys()).toEqual(["Escape"]);
|
||||||
|
await render(false);
|
||||||
|
expect(container.querySelector("button")).not.toBeNull();
|
||||||
|
expect(hasActiveOverlay()).toBe(false);
|
||||||
|
expect(getTopOverlayKeys()).toEqual([]);
|
||||||
|
await render(true);
|
||||||
|
expect(getTopOverlayKeys()).toEqual(["Escape"]);
|
||||||
|
} finally {
|
||||||
|
await act(async () => root.unmount());
|
||||||
|
container.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -4,6 +4,7 @@ import { useKeyboardAnimation } from "react-native-keyboard-controller";
|
|||||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||||
import { KeyboardTranslationContext } from "./context";
|
import { KeyboardTranslationContext } from "./context";
|
||||||
import { useKeyboardTranslationScope } from "./measure";
|
import { useKeyboardTranslationScope } from "./measure";
|
||||||
|
import { useRetainedPanelActive } from "@/components/retained-panel";
|
||||||
|
|
||||||
interface KeyboardTranslateViewProps extends ViewProps {
|
interface KeyboardTranslateViewProps extends ViewProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
@@ -19,12 +20,14 @@ interface KeyboardTranslateViewProps extends ViewProps {
|
|||||||
|
|
||||||
export function KeyboardTranslateView({
|
export function KeyboardTranslateView({
|
||||||
children,
|
children,
|
||||||
enabled = true,
|
enabled: requestedEnabled = true,
|
||||||
bottomClearance = 0,
|
bottomClearance = 0,
|
||||||
keyboardGap = 0,
|
keyboardGap = 0,
|
||||||
style,
|
style,
|
||||||
...props
|
...props
|
||||||
}: KeyboardTranslateViewProps) {
|
}: KeyboardTranslateViewProps) {
|
||||||
|
const active = useRetainedPanelActive();
|
||||||
|
const enabled = requestedEnabled && active;
|
||||||
const insets = useSafeAreaInsets();
|
const insets = useSafeAreaInsets();
|
||||||
const { height, progress } = useKeyboardAnimation();
|
const { height, progress } = useKeyboardAnimation();
|
||||||
// Mirrors resolveKeyboardLift on the native driver: `overlap` is the negated shift.
|
// Mirrors resolveKeyboardLift on the native driver: `overlap` is the negated shift.
|
||||||
@@ -50,7 +53,8 @@ export function KeyboardTranslateView({
|
|||||||
// setValue during the React commit gets overwritten by the resize. A rebuilt
|
// setValue during the React commit gets overwritten by the resize. A rebuilt
|
||||||
// graph (a new bottomClearance after rotation) starts from JS-side keyboard
|
// graph (a new bottomClearance after rotation) starts from JS-side keyboard
|
||||||
// values, so run it on the native frame too or it stays stale until the
|
// values, so run it on the native frame too or it stays stale until the
|
||||||
// keyboard next moves.
|
// keyboard next moves. An inactive panel must not retain another workspace's
|
||||||
|
// keyboard offset for Fabric to restore when it becomes visible again.
|
||||||
const enabledValue = useAnimatedValue(enabled ? 1 : 0);
|
const enabledValue = useAnimatedValue(enabled ? 1 : 0);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const animation = Animated.timing(enabledValue, {
|
const animation = Animated.timing(enabledValue, {
|
||||||
|
|||||||
@@ -30,15 +30,24 @@ function retainedWorkspaceIds(
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("reconcileRetainedWorkspaceSelections", () => {
|
describe("reconcileRetainedWorkspaceSelections", () => {
|
||||||
it("retains only the active workspace on native", () => {
|
it("keeps recent native workspaces warm and evicts the least recently used workspace", () => {
|
||||||
const entries = reconcileRetainedWorkspaceSelections({
|
let entries = [retained("A", null)];
|
||||||
currentEntries: [retained("A", null)],
|
const visit = (workspaceId: string, now: number) => {
|
||||||
activeSelection: workspace("B"),
|
entries = reconcileRetainedWorkspaceSelections({
|
||||||
now: 2,
|
currentEntries: entries,
|
||||||
maxMountedWorkspaces: resolveWorkspaceDeckRetentionLimit({ isNative: true }),
|
activeSelection: workspace(workspaceId),
|
||||||
});
|
now,
|
||||||
|
maxMountedWorkspaces: resolveWorkspaceDeckRetentionLimit({ isNative: true }),
|
||||||
|
});
|
||||||
|
return retainedWorkspaceIds(entries);
|
||||||
|
};
|
||||||
|
|
||||||
expect(retainedWorkspaceIds(entries)).toEqual(["B"]);
|
expect(visit("B", 1)).toEqual(["B", "A"]);
|
||||||
|
expect(visit("C", 2)).toEqual(["C", "B", "A"]);
|
||||||
|
expect(visit("A", 3)).toEqual(["A", "C", "B"]);
|
||||||
|
expect(visit("D", 4)).toEqual(["D", "A", "C"]);
|
||||||
|
expect(visit("A", 5)).toEqual(["A", "D", "C"]);
|
||||||
|
expect(visit("E", 6)).toEqual(["E", "A", "D"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("retains the desktop deck limit on web", () => {
|
it("retains the desktop deck limit on web", () => {
|
||||||
@@ -179,9 +188,23 @@ describe("resolveWorkspaceDeckEntries", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("shouldKeepWorkspaceDeckEntryMounted", () => {
|
describe("shouldKeepWorkspaceDeckEntryMounted", () => {
|
||||||
|
it("tears down native sheet owners when leaving, while keeping the active sheet mounted", () => {
|
||||||
|
for (const isActive of [true, false]) {
|
||||||
|
expect(
|
||||||
|
shouldKeepWorkspaceDeckEntryMounted({
|
||||||
|
isActive,
|
||||||
|
hasOpenNativeSheets: true,
|
||||||
|
hasHydratedWorkspaces: true,
|
||||||
|
workspaceExists: true,
|
||||||
|
}),
|
||||||
|
).toBe(isActive);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it("keeps the active workspace mounted even when it is missing from hydrated workspaces", () => {
|
it("keeps the active workspace mounted even when it is missing from hydrated workspaces", () => {
|
||||||
expect(
|
expect(
|
||||||
shouldKeepWorkspaceDeckEntryMounted({
|
shouldKeepWorkspaceDeckEntryMounted({
|
||||||
|
hasOpenNativeSheets: false,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
hasHydratedWorkspaces: true,
|
hasHydratedWorkspaces: true,
|
||||||
workspaceExists: false,
|
workspaceExists: false,
|
||||||
@@ -192,6 +215,7 @@ describe("shouldKeepWorkspaceDeckEntryMounted", () => {
|
|||||||
it("keeps inactive workspaces mounted until workspace hydration finishes", () => {
|
it("keeps inactive workspaces mounted until workspace hydration finishes", () => {
|
||||||
expect(
|
expect(
|
||||||
shouldKeepWorkspaceDeckEntryMounted({
|
shouldKeepWorkspaceDeckEntryMounted({
|
||||||
|
hasOpenNativeSheets: false,
|
||||||
isActive: false,
|
isActive: false,
|
||||||
hasHydratedWorkspaces: false,
|
hasHydratedWorkspaces: false,
|
||||||
workspaceExists: false,
|
workspaceExists: false,
|
||||||
@@ -202,6 +226,7 @@ describe("shouldKeepWorkspaceDeckEntryMounted", () => {
|
|||||||
it("unmounts inactive workspaces that are gone after hydration", () => {
|
it("unmounts inactive workspaces that are gone after hydration", () => {
|
||||||
expect(
|
expect(
|
||||||
shouldKeepWorkspaceDeckEntryMounted({
|
shouldKeepWorkspaceDeckEntryMounted({
|
||||||
|
hasOpenNativeSheets: false,
|
||||||
isActive: false,
|
isActive: false,
|
||||||
hasHydratedWorkspaces: true,
|
hasHydratedWorkspaces: true,
|
||||||
workspaceExists: false,
|
workspaceExists: false,
|
||||||
@@ -212,6 +237,7 @@ describe("shouldKeepWorkspaceDeckEntryMounted", () => {
|
|||||||
it("keeps inactive workspaces that still exist after hydration", () => {
|
it("keeps inactive workspaces that still exist after hydration", () => {
|
||||||
expect(
|
expect(
|
||||||
shouldKeepWorkspaceDeckEntryMounted({
|
shouldKeepWorkspaceDeckEntryMounted({
|
||||||
|
hasOpenNativeSheets: false,
|
||||||
isActive: false,
|
isActive: false,
|
||||||
hasHydratedWorkspaces: true,
|
hasHydratedWorkspaces: true,
|
||||||
workspaceExists: true,
|
workspaceExists: true,
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ export interface RetainedWorkspaceSelection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function resolveWorkspaceDeckRetentionLimit(input: { isNative: boolean }): number {
|
export function resolveWorkspaceDeckRetentionLimit(input: { isNative: boolean }): number {
|
||||||
return input.isNative ? 1 : WORKSPACE_DECK_MAX_MOUNTED_WORKSPACES;
|
// Keep recent switches warm without retaining the desktop-sized set of
|
||||||
|
// native chat trees. Reconciliation evicts the least recently used entry.
|
||||||
|
return input.isNative ? 3 : WORKSPACE_DECK_MAX_MOUNTED_WORKSPACES;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ReconcileRetainedWorkspaceSelectionsInput {
|
interface ReconcileRetainedWorkspaceSelectionsInput {
|
||||||
@@ -28,6 +30,7 @@ interface GetNextWorkspaceDeckExpirationDelayInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface WorkspaceDeckEntryMountInput {
|
interface WorkspaceDeckEntryMountInput {
|
||||||
|
hasOpenNativeSheets: boolean;
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
hasHydratedWorkspaces: boolean;
|
hasHydratedWorkspaces: boolean;
|
||||||
workspaceExists: boolean;
|
workspaceExists: boolean;
|
||||||
@@ -159,6 +162,7 @@ export function resolveWorkspaceDeckEntries({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function shouldKeepWorkspaceDeckEntryMounted({
|
export function shouldKeepWorkspaceDeckEntryMounted({
|
||||||
|
hasOpenNativeSheets,
|
||||||
isActive,
|
isActive,
|
||||||
hasHydratedWorkspaces,
|
hasHydratedWorkspaces,
|
||||||
workspaceExists,
|
workspaceExists,
|
||||||
@@ -166,6 +170,9 @@ export function shouldKeepWorkspaceDeckEntryMounted({
|
|||||||
if (isActive) {
|
if (isActive) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// Native sheets can present on the app-wide host. Preserve their existing
|
||||||
|
// teardown on navigation until the sheet stack supports inactive owners.
|
||||||
|
if (hasOpenNativeSheets) return false;
|
||||||
if (!hasHydratedWorkspaces) {
|
if (!hasHydratedWorkspaces) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
diff --git a/node_modules/react-native-keyboard-controller/src/animated.tsx b/node_modules/react-native-keyboard-controller/src/animated.tsx
|
||||||
|
--- a/node_modules/react-native-keyboard-controller/src/animated.tsx
|
||||||
|
+++ b/node_modules/react-native-keyboard-controller/src/animated.tsx
|
||||||
|
@@ -226,7 +226,7 @@
|
||||||
|
onKeyboardMoveStart={OS === "ios" ? onKeyboardMove : undefined}
|
||||||
|
onKeyboardMove={OS === "android" ? onKeyboardMove : undefined}
|
||||||
|
onKeyboardMoveInteractive={onKeyboardMove}
|
||||||
|
- onKeyboardMoveEnd={OS === "android" ? onKeyboardMove : undefined}
|
||||||
|
+ onKeyboardMoveEnd={OS === "web" ? undefined : onKeyboardMove}
|
||||||
|
onFocusedInputLayoutChangedReanimated={inputLayoutHandler}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
diff --git a/node_modules/react-native-keyboard-controller/lib/module/animated.js b/node_modules/react-native-keyboard-controller/lib/module/animated.js
|
||||||
|
--- a/node_modules/react-native-keyboard-controller/lib/module/animated.js
|
||||||
|
+++ b/node_modules/react-native-keyboard-controller/lib/module/animated.js
|
||||||
|
@@ -173,7 +173,7 @@
|
||||||
|
onKeyboardMoveStart: OS === "ios" ? onKeyboardMove : undefined,
|
||||||
|
onKeyboardMove: OS === "android" ? onKeyboardMove : undefined,
|
||||||
|
onKeyboardMoveInteractive: onKeyboardMove,
|
||||||
|
- onKeyboardMoveEnd: OS === "android" ? onKeyboardMove : undefined,
|
||||||
|
+ onKeyboardMoveEnd: OS === "web" ? undefined : onKeyboardMove,
|
||||||
|
onFocusedInputLayoutChangedReanimated: inputLayoutHandler
|
||||||
|
}, children), /*#__PURE__*/React.createElement(Animated.View, {
|
||||||
|
// we are using this small hack, because if the component (where
|
||||||
|
diff --git a/node_modules/react-native-keyboard-controller/lib/commonjs/animated.js b/node_modules/react-native-keyboard-controller/lib/commonjs/animated.js
|
||||||
|
--- a/node_modules/react-native-keyboard-controller/lib/commonjs/animated.js
|
||||||
|
+++ b/node_modules/react-native-keyboard-controller/lib/commonjs/animated.js
|
||||||
|
@@ -181,7 +181,7 @@
|
||||||
|
onKeyboardMoveStart: OS === "ios" ? onKeyboardMove : undefined,
|
||||||
|
onKeyboardMove: OS === "android" ? onKeyboardMove : undefined,
|
||||||
|
onKeyboardMoveInteractive: onKeyboardMove,
|
||||||
|
- onKeyboardMoveEnd: OS === "android" ? onKeyboardMove : undefined,
|
||||||
|
+ onKeyboardMoveEnd: OS === "web" ? undefined : onKeyboardMove,
|
||||||
|
onFocusedInputLayoutChangedReanimated: inputLayoutHandler
|
||||||
|
}, children), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
|
||||||
|
// we are using this small hack, because if the component (where
|
||||||
@@ -8,6 +8,13 @@ import { join, relative } from "node:path";
|
|||||||
// workspace root live in their workspace's own node_modules, and patch-package resolves
|
// workspace root live in their workspace's own node_modules, and patch-package resolves
|
||||||
// the patch's node_modules/... paths relative to its working directory.
|
// the patch's node_modules/... paths relative to its working directory.
|
||||||
const patchedPackages = [
|
const patchedPackages = [
|
||||||
|
// iOS retained views need the final keyboard event to settle the native animation graph.
|
||||||
|
// Remove when upstream binds onKeyboardMoveEnd to Animated.event on iOS too.
|
||||||
|
{
|
||||||
|
nodeModulesPath: "packages/app/node_modules/react-native-keyboard-controller",
|
||||||
|
patchPrefix: "react-native-keyboard-controller+",
|
||||||
|
cwd: "packages/app",
|
||||||
|
},
|
||||||
// Backport for expo-modules-core 57.0.23: https://github.com/expo/expo/pull/49634.
|
// Backport for expo-modules-core 57.0.23: https://github.com/expo/expo/pull/49634.
|
||||||
// Remove when the installed Expo SDK includes the Activity recreation fix.
|
// Remove when the installed Expo SDK includes the Activity recreation fix.
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { test } from "node:test";
|
|||||||
const script = path.resolve("scripts", "postinstall-patches.mjs");
|
const script = path.resolve("scripts", "postinstall-patches.mjs");
|
||||||
const bin = path.resolve("node_modules", ".bin");
|
const bin = path.resolve("node_modules", ".bin");
|
||||||
const packageName = "react-native-draggable-flatlist";
|
const packageName = "react-native-draggable-flatlist";
|
||||||
const patchFile = `${packageName}+4.0.3.patch`;
|
|
||||||
|
|
||||||
for (const platform of ["ios", "android"]) {
|
for (const platform of ["ios", "android"]) {
|
||||||
test(`patched Markdown ships ${platform} props generated from its native specs`, () => {
|
test(`patched Markdown ships ${platform} props generated from its native specs`, () => {
|
||||||
@@ -47,24 +46,24 @@ for (const platform of ["ios", "android"]) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createCheckout() {
|
function createCheckout({ name = packageName, version = "4.0.3", workspace = "" } = {}) {
|
||||||
const root = mkdtempSync(path.join(tmpdir(), "postinstall-patches-"));
|
const root = mkdtempSync(path.join(tmpdir(), "postinstall-patches-"));
|
||||||
writeFileSync(path.join(root, "package.json"), JSON.stringify({ name: "checkout" }));
|
writeFileSync(path.join(root, "package.json"), JSON.stringify({ name: "checkout" }));
|
||||||
const packageDir = path.join(root, "node_modules", packageName);
|
const packageDir = path.join(root, workspace, "node_modules", name);
|
||||||
mkdirSync(packageDir, { recursive: true });
|
mkdirSync(packageDir, { recursive: true });
|
||||||
writeFileSync(
|
if (workspace) {
|
||||||
path.join(packageDir, "package.json"),
|
writeFileSync(path.join(root, workspace, "package.json"), JSON.stringify({ name: "app" }));
|
||||||
JSON.stringify({ name: packageName, version: "4.0.3" }),
|
}
|
||||||
);
|
writeFileSync(path.join(packageDir, "package.json"), JSON.stringify({ name, version }));
|
||||||
writeFileSync(path.join(packageDir, "index.js"), "export const value = 1;\n");
|
writeFileSync(path.join(packageDir, "index.js"), "export const value = 1;\n");
|
||||||
mkdirSync(path.join(root, "patches"));
|
mkdirSync(path.join(root, "patches"));
|
||||||
return { root, packageDir };
|
return { root, packageDir };
|
||||||
}
|
}
|
||||||
|
|
||||||
function writePatch(root, from, to) {
|
function writePatch(root, from, to, name = packageName, version = "4.0.3") {
|
||||||
const file = `node_modules/${packageName}/index.js`;
|
const file = `node_modules/${name}/index.js`;
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
path.join(root, "patches", patchFile),
|
path.join(root, "patches", `${name}+${version}.patch`),
|
||||||
[
|
[
|
||||||
`diff --git a/${file} b/${file}`,
|
`diff --git a/${file} b/${file}`,
|
||||||
`--- a/${file}`,
|
`--- a/${file}`,
|
||||||
@@ -85,6 +84,23 @@ function install(root, PATH = `${bin}${path.delimiter}${process.env.PATH}`) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("patches the app-local keyboard controller during install", () => {
|
||||||
|
const name = "react-native-keyboard-controller";
|
||||||
|
const version = "1.21.12";
|
||||||
|
const { root, packageDir } = createCheckout({ name, version, workspace: "packages/app" });
|
||||||
|
try {
|
||||||
|
writePatch(root, 1, 2, name, version);
|
||||||
|
const result = install(root);
|
||||||
|
assert.equal(result.status, 0, result.stdout + result.stderr);
|
||||||
|
assert.equal(
|
||||||
|
readFileSync(path.join(packageDir, "index.js"), "utf8"),
|
||||||
|
"export const value = 2;\n",
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
rmSync(root, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test("a patch that changed since it was applied removes the package for a clean reinstall", () => {
|
test("a patch that changed since it was applied removes the package for a clean reinstall", () => {
|
||||||
const { root, packageDir } = createCheckout();
|
const { root, packageDir } = createCheckout();
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user