diff --git a/apps/mobile/src/features/diffs/nativeReviewDiffSurface.ts b/apps/mobile/src/features/diffs/nativeReviewDiffSurface.ts index a4896dc401..9ac85b2715 100644 --- a/apps/mobile/src/features/diffs/nativeReviewDiffSurface.ts +++ b/apps/mobile/src/features/diffs/nativeReviewDiffSurface.ts @@ -12,6 +12,7 @@ import { requireNativeView } from "expo"; import { NativeViewResolutionError } from "../../native/nativeViewResolutionError"; const NATIVE_REVIEW_DIFF_MODULE_NAME = "T3ReviewDiffSurface"; +const NATIVE_REVIEW_DIFF_PAYLOAD_RETRY_FRAMES = 60; interface ExpoGlobalWithViewConfig { readonly expo?: { @@ -195,7 +196,7 @@ function useNativeReviewDiffPayload( const view = nativeRef.current; const command = view?.[method]; if (!view || !command) { - if (attempts < 4) { + if (attempts < NATIVE_REVIEW_DIFF_PAYLOAD_RETRY_FRAMES) { attempts += 1; frame = requestAnimationFrame(dispatch); } @@ -203,7 +204,11 @@ function useNativeReviewDiffPayload( } void command.call(view, payload).catch((error: unknown) => { - if (!cancelled && attempts < 4 && isPendingNativeViewRegistration(error)) { + if ( + !cancelled && + attempts < NATIVE_REVIEW_DIFF_PAYLOAD_RETRY_FRAMES && + isPendingNativeViewRegistration(error) + ) { attempts += 1; frame = requestAnimationFrame(dispatch); return; diff --git a/apps/mobile/src/features/home/workspace-connection-status.ts b/apps/mobile/src/features/home/workspace-connection-status.ts index c9116d060c..d523684f03 100644 --- a/apps/mobile/src/features/home/workspace-connection-status.ts +++ b/apps/mobile/src/features/home/workspace-connection-status.ts @@ -3,6 +3,7 @@ import type { WorkspaceState } from "../../state/workspaceModel"; export function shouldShowWorkspaceConnectionStatus(state: WorkspaceState): boolean { return ( state.networkStatus === "offline" || + state.connectionError !== null || state.hasConnectingEnvironment || (state.hasLoadedShellSnapshot && !state.hasReadyEnvironment) ); diff --git a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx index 88821ded48..4221e290b1 100644 --- a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx +++ b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx @@ -32,7 +32,10 @@ import { import { resolveThreadSelectionNavigationAction } from "../../lib/adaptive-navigation"; import { buildThreadRoutePath } from "../../lib/routes"; import { scopedThreadKey } from "../../lib/scopedEntities"; -import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands"; +import { + parseActiveThreadPath, + useHardwareKeyboardCommand, +} from "../keyboard/hardwareKeyboardCommands"; import { HomeListOptionsProvider } from "../home/home-list-options"; import { ThreadNavigationSidebar } from "../threads/ThreadNavigationSidebar"; @@ -113,8 +116,10 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) layout, viewportWidth: width, preferredWidth: fileInspectorPreferredWidth ?? undefined, + reservedLeadingWidth: + layout.usesSplitView && primarySidebarPreferredVisible ? (layout.listPaneWidth ?? 0) : 0, }), - [fileInspectorPreferredWidth, layout, width], + [fileInspectorPreferredWidth, layout, primarySidebarPreferredVisible, width], ); const auxiliaryPaneRole: WorkspaceAuxiliaryPaneRole = focusedAuxiliaryPaneRole ?? (/\/files(?:\/|$)/.test(pathname) ? "inspector" : "supplementary"); @@ -190,6 +195,14 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) } setSupplementaryPanePreferredVisible(true); }, []); + const handleOpenFilesCommand = useCallback(() => { + if (!layout.usesSplitView || !fileInspector.supported || !parseActiveThreadPath(pathname)) { + return false; + } + showAuxiliaryPane("inspector"); + return true; + }, [fileInspector.supported, layout.usesSplitView, pathname, showAuxiliaryPane]); + useHardwareKeyboardCommand("files", handleOpenFilesCommand); const toggleAuxiliaryPane = useCallback(() => { if (auxiliaryPaneRole === "inspector") { setFileInspectorPreferredVisible((current) => !current); diff --git a/apps/mobile/src/features/layout/workspace-pane-divider.tsx b/apps/mobile/src/features/layout/workspace-pane-divider.tsx index a892ab7365..c6fd1fca8e 100644 --- a/apps/mobile/src/features/layout/workspace-pane-divider.tsx +++ b/apps/mobile/src/features/layout/workspace-pane-divider.tsx @@ -59,9 +59,9 @@ export function WorkspacePaneDivider(props: WorkspacePaneDividerProps) { const handleAccessibilityAction = (event: AccessibilityActionEvent) => { props.onResizeStart?.(); if (event.nativeEvent.actionName === "increment") { - props.onResizeBy(ACCESSIBILITY_RESIZE_STEP); + props.onResizeBy(ACCESSIBILITY_RESIZE_STEP * props.resizeDirection); } else if (event.nativeEvent.actionName === "decrement") { - props.onResizeBy(-ACCESSIBILITY_RESIZE_STEP); + props.onResizeBy(-ACCESSIBILITY_RESIZE_STEP * props.resizeDirection); } props.onResizeEnd?.(); }; diff --git a/apps/mobile/src/lib/layout.test.ts b/apps/mobile/src/lib/layout.test.ts index a61a1ba40b..6dea0beafb 100644 --- a/apps/mobile/src/lib/layout.test.ts +++ b/apps/mobile/src/lib/layout.test.ts @@ -164,7 +164,7 @@ describe("deriveWorkspacePaneLayout", () => { contentPaneWidth: 1_024, supportsAuxiliaryPane: true, auxiliaryPaneVisible: true, - auxiliaryPaneWidth: 287, + auxiliaryPaneWidth: 260, }); }); @@ -185,7 +185,25 @@ describe("deriveWorkspacePaneLayout", () => { contentPaneWidth: 986, supportsAuxiliaryPane: true, auxiliaryPaneVisible: true, - auxiliaryPaneWidth: 320, + auxiliaryPaneWidth: 276, + }); + }); + + it("keeps an explicitly hidden thread sidebar hidden when the file inspector is visible", () => { + const layout = deriveLayout({ width: 1_024, height: 1_366 }); + + expect( + deriveWorkspacePaneLayout({ + layout, + viewportWidth: 1_024, + primarySidebarPreferredVisible: false, + auxiliaryPanePreferredVisible: true, + auxiliaryPaneRole: "inspector", + }), + ).toMatchObject({ + primarySidebarVisible: false, + primarySidebarSuppressedByAuxiliary: false, + auxiliaryPaneVisible: true, }); }); diff --git a/apps/mobile/src/lib/layout.ts b/apps/mobile/src/lib/layout.ts index 44d0470116..eb0c45e060 100644 --- a/apps/mobile/src/lib/layout.ts +++ b/apps/mobile/src/lib/layout.ts @@ -100,9 +100,11 @@ export function deriveWorkspacePaneLayout(input: { layout: input.layout, viewportWidth, preferredWidth: input.auxiliaryPanePreferredWidth, + reservedLeadingWidth: preferredPrimarySidebarWidth, }); const auxiliaryPaneVisible = fileInspector.supported && input.auxiliaryPanePreferredVisible; const primarySidebarSuppressedByAuxiliary = + preferredPrimarySidebarVisible && auxiliaryPaneVisible && fileInspector.width !== null && input.layout.listPaneWidth !== null && @@ -151,8 +153,13 @@ export function deriveFileInspectorPaneLayout(input: { readonly layout: Layout; readonly viewportWidth: number; readonly preferredWidth?: number; + readonly reservedLeadingWidth?: number; }): FileInspectorPaneLayout { const viewportWidth = Math.max(0, input.viewportWidth); + const reservedLeadingWidth = Number.isFinite(input.reservedLeadingWidth) + ? Math.max(0, input.reservedLeadingWidth ?? 0) + : 0; + const availableContentWidth = Math.max(0, viewportWidth - reservedLeadingWidth); const supported = input.layout.usesSplitView && viewportWidth >= FILE_INSPECTOR_MIN_VIEWPORT_WIDTH; @@ -163,11 +170,11 @@ export function deriveFileInspectorPaneLayout(input: { preferredWidth: input.preferredWidth ?? clamp( - Math.round(viewportWidth * 0.28), + Math.round(availableContentWidth * 0.28), AUXILIARY_PANE_MIN_WIDTH, AUXILIARY_PANE_DEFAULT_MAX_WIDTH, ), - availableWidth: viewportWidth, + availableWidth: availableContentWidth, }) : null, };