mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-29 19:56:01 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
097a0f3a7d | ||
|
|
47b4205098 | ||
|
|
d8e9a39953 |
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Open Pi settings from the Android model picker. Scroll the sheet body until
|
||||
# most of the Models list is visible. Use a host with several Pi models and
|
||||
# the default shown-models selection.
|
||||
session="${1:?Pass the agent-device session with the Pi provider sheet open}"
|
||||
artifacts="${2:-.artifacts/provider-model-scroll}"
|
||||
mkdir -p "$artifacts"
|
||||
|
||||
ad() {
|
||||
agent-device "$@" --session "$session"
|
||||
}
|
||||
|
||||
visible_rows() {
|
||||
jq -ce '
|
||||
.data.nodes as $nodes
|
||||
| ($nodes[] | select(.identifier == "provider-discovered-models")) as $list
|
||||
| [$nodes[]
|
||||
| select((.identifier // "") | startswith("provider-shown-model-"))
|
||||
| select(.rect.height > 0 and .rect.y < ($list.rect.y + $list.rect.height))
|
||||
| select(.rect.y + .rect.height > $list.rect.y)
|
||||
| .label]
|
||||
| select(length > 1)
|
||||
' "$1"
|
||||
}
|
||||
|
||||
ad snapshot --json > "$artifacts/before.json"
|
||||
read -r x y dy < <(jq -er '
|
||||
.data.nodes[]
|
||||
| select(.identifier == "provider-discovered-models" and .rect.height >= 350)
|
||||
| .rect
|
||||
| [(.x + .width / 2 | floor), (.y + .height * 0.7 | floor), (-.height * 0.5 | floor)]
|
||||
| @tsv
|
||||
' "$artifacts/before.json") || {
|
||||
printf 'Scroll the sheet body until the Models list is visible.\n' >&2
|
||||
exit 1
|
||||
}
|
||||
before=$(visible_rows "$artifacts/before.json")
|
||||
ad gesture pan "$x" "$y" 0 "$dy" 580
|
||||
ad snapshot --json > "$artifacts/after.json"
|
||||
after=$(visible_rows "$artifacts/after.json")
|
||||
|
||||
printf 'Before %s\nAfter %s\n' "$before" "$after"
|
||||
first=$(jq -r '.[0]' <<<"$before")
|
||||
if jq -e --arg first "$first" 'index($first) != null' <<<"$after" >/dev/null; then
|
||||
printf 'The first model stayed visible after the upward drag.\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
model=$(jq -r '.[1]' <<<"$after")
|
||||
ad press "role=checkbox label=\"$model\"" --settle
|
||||
ad snapshot --json > "$artifacts/checked.json"
|
||||
jq -e --arg model "$model" '
|
||||
any(.data.nodes[]; .kind == "checkbox" and .label == $model and .checked == true)
|
||||
' "$artifacts/checked.json" >/dev/null
|
||||
ad press 'id="provider-shown-models-reset"' --settle
|
||||
ad snapshot --json > "$artifacts/reset.json"
|
||||
jq -e --arg model "$model" '
|
||||
any(.data.nodes[]; .kind == "checkbox" and .label == $model and .checked == false)
|
||||
' "$artifacts/reset.json" >/dev/null
|
||||
@@ -4,8 +4,8 @@ import { FlatList, Text, View } from "react-native";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import { AlertTriangle, ChevronDown, Layers } from "lucide-react-native";
|
||||
import type { AgentProfilePickerRow } from "@/agent-profiles";
|
||||
import { IndependentScrollBoundary } from "@/components/ui/independent-scroll-boundary";
|
||||
import {
|
||||
IndependentScrollBoundary,
|
||||
MODEL_PICKER_ROW_HEIGHT,
|
||||
ModelBrowserLoadingState,
|
||||
ModelBrowserNoProviders,
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
FlatList,
|
||||
Platform,
|
||||
Pressable,
|
||||
ScrollView,
|
||||
Text,
|
||||
@@ -27,6 +26,10 @@ import {
|
||||
type StyleProp,
|
||||
type ViewStyle,
|
||||
} from "react-native";
|
||||
import {
|
||||
IndependentScrollBoundary,
|
||||
useIndependentScrollGesture,
|
||||
} from "@/components/ui/independent-scroll-boundary";
|
||||
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import {
|
||||
@@ -209,10 +212,6 @@ function AgentProfilesEditAction({ onPress }: { onPress: () => void }) {
|
||||
);
|
||||
}
|
||||
|
||||
const IndependentScrollGestureContext = createContext<ReturnType<typeof Gesture.Native> | null>(
|
||||
null,
|
||||
);
|
||||
|
||||
interface ModelBrowserNavContextValue {
|
||||
activeKey: string | null;
|
||||
onActivateKey: (key: string) => void;
|
||||
@@ -616,7 +615,7 @@ function ModelBrowserPressable({
|
||||
onLayout,
|
||||
testID,
|
||||
}: ModelBrowserPressableProps) {
|
||||
const independentScrollGesture = useContext(IndependentScrollGestureContext);
|
||||
const independentScrollGesture = useIndependentScrollGesture();
|
||||
const [pressed, setPressed] = useState(false);
|
||||
// Android's scroll handler must keep the pointer stream until release so a
|
||||
// fling survives leaving the short viewport. A simultaneous Tap keeps rows
|
||||
@@ -1381,29 +1380,6 @@ function GroupedProviderRows({
|
||||
);
|
||||
}
|
||||
|
||||
export function IndependentScrollBoundary({ children }: { children: React.ReactElement }) {
|
||||
// Prevent the parent sheet from cancelling Android's native scroll when the
|
||||
// finger crosses this viewport; receiving ACTION_UP is what preserves fling.
|
||||
const nativeScrollGesture = useMemo(
|
||||
() =>
|
||||
Gesture.Native()
|
||||
.shouldActivateOnStart(true)
|
||||
.shouldCancelWhenOutside(false)
|
||||
.disallowInterruption(true),
|
||||
[],
|
||||
);
|
||||
|
||||
if (Platform.OS !== "android") {
|
||||
return children;
|
||||
}
|
||||
|
||||
return (
|
||||
<IndependentScrollGestureContext.Provider value={nativeScrollGesture}>
|
||||
<GestureDetector gesture={nativeScrollGesture}>{children}</GestureDetector>
|
||||
</IndependentScrollGestureContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
function resolveModelListRevealTarget({
|
||||
shouldRevealActive,
|
||||
hasActiveHeaderItem,
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
import { Component, type ErrorInfo, type ReactNode } from "react";
|
||||
|
||||
interface RenderErrorBoundaryProps {
|
||||
children: ReactNode;
|
||||
/** A caught error is cleared when any of these values change, so new content renders. */
|
||||
resetKeys: readonly unknown[];
|
||||
/** The error state shown in place of the children. `retry` renders the children again. */
|
||||
renderError(error: string, retry: () => void): ReactNode;
|
||||
onError(error: unknown, componentStack: string | null | undefined): void;
|
||||
}
|
||||
|
||||
interface RenderErrorBoundaryState {
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps a render error inside one surface. Without it the error reaches the root boundary,
|
||||
* which replaces the whole app.
|
||||
*/
|
||||
export class RenderErrorBoundary extends Component<
|
||||
RenderErrorBoundaryProps,
|
||||
RenderErrorBoundaryState
|
||||
> {
|
||||
state: RenderErrorBoundaryState = { error: null };
|
||||
|
||||
static getDerivedStateFromError(error: unknown): RenderErrorBoundaryState {
|
||||
return { error: error instanceof Error ? error.message : String(error) };
|
||||
}
|
||||
|
||||
componentDidCatch(error: unknown, info: ErrorInfo): void {
|
||||
this.props.onError(error, info.componentStack);
|
||||
}
|
||||
|
||||
componentDidUpdate(previous: RenderErrorBoundaryProps): void {
|
||||
if (this.state.error !== null && resetKeysChanged(previous.resetKeys, this.props.resetKeys)) {
|
||||
this.retry();
|
||||
}
|
||||
}
|
||||
|
||||
retry = (): void => {
|
||||
this.setState({ error: null });
|
||||
};
|
||||
|
||||
render() {
|
||||
if (this.state.error !== null) return this.props.renderError(this.state.error, this.retry);
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function resetKeysChanged(previous: readonly unknown[], next: readonly unknown[]): boolean {
|
||||
return previous.length !== next.length || previous.some((key, index) => key !== next[index]);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { createContext, useContext, useMemo, type ReactElement } from "react";
|
||||
import { Platform } from "react-native";
|
||||
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
||||
|
||||
const IndependentScrollGestureContext = createContext<ReturnType<typeof Gesture.Native> | null>(
|
||||
null,
|
||||
);
|
||||
|
||||
/** The native scroll gesture of the enclosing boundary, for gestures that must not cancel it. */
|
||||
export function useIndependentScrollGesture(): ReturnType<typeof Gesture.Native> | null {
|
||||
return useContext(IndependentScrollGestureContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps a parent pan from interrupting an Android scroll and lets the list receive ACTION_UP
|
||||
* for the fling. With activation on start, child taps must join the native scroll gesture.
|
||||
* When activation waits for the scroll view to intercept a drag, ordinary pressables receive taps.
|
||||
*/
|
||||
export function IndependentScrollBoundary({
|
||||
children,
|
||||
activateOnStart = true,
|
||||
}: {
|
||||
children: ReactElement;
|
||||
activateOnStart?: boolean;
|
||||
}) {
|
||||
const nativeScrollGesture = useMemo(
|
||||
() =>
|
||||
Gesture.Native()
|
||||
.shouldActivateOnStart(activateOnStart)
|
||||
.shouldCancelWhenOutside(false)
|
||||
.disallowInterruption(true),
|
||||
[activateOnStart],
|
||||
);
|
||||
|
||||
if (Platform.OS !== "android") {
|
||||
return children;
|
||||
}
|
||||
|
||||
return (
|
||||
<IndependentScrollGestureContext.Provider value={nativeScrollGesture}>
|
||||
<GestureDetector gesture={nativeScrollGesture}>{children}</GestureDetector>
|
||||
</IndependentScrollGestureContext.Provider>
|
||||
);
|
||||
}
|
||||
@@ -2183,9 +2183,6 @@ export const ar: TranslationResources = {
|
||||
archiveFinishedRetry: "إعادة المحاولة ({{failed}}/{{total}})",
|
||||
},
|
||||
panels: {
|
||||
renderError: {
|
||||
title: "تعذّر عرض هذه اللوحة",
|
||||
},
|
||||
draft: {
|
||||
newAgent: "وكيل جديد",
|
||||
creatingAgent: "وكيل الخلق",
|
||||
|
||||
@@ -2213,9 +2213,6 @@ export const en = {
|
||||
archiveFinishedRetry: "Retry ({{failed}}/{{total}})",
|
||||
},
|
||||
panels: {
|
||||
renderError: {
|
||||
title: "Unable to show this panel",
|
||||
},
|
||||
draft: {
|
||||
newAgent: "New Agent",
|
||||
creatingAgent: "Creating agent",
|
||||
|
||||
@@ -2239,9 +2239,6 @@ export const es: TranslationResources = {
|
||||
archiveFinishedRetry: "Reintentar ({{failed}}/{{total}})",
|
||||
},
|
||||
panels: {
|
||||
renderError: {
|
||||
title: "No se puede mostrar este panel",
|
||||
},
|
||||
draft: {
|
||||
newAgent: "Nuevo agente",
|
||||
creatingAgent: "Agente creador",
|
||||
|
||||
@@ -2236,9 +2236,6 @@ export const fr: TranslationResources = {
|
||||
archiveFinishedRetry: "Réessayer ({{failed}}/{{total}})",
|
||||
},
|
||||
panels: {
|
||||
renderError: {
|
||||
title: "Impossible d'afficher ce panneau",
|
||||
},
|
||||
draft: {
|
||||
newAgent: "Nouvel agent",
|
||||
creatingAgent: "Création de l’agent",
|
||||
|
||||
@@ -2206,9 +2206,6 @@ export const ja: TranslationResources = {
|
||||
archiveFinishedRetry: "再試行 ({{failed}}/{{total}})",
|
||||
},
|
||||
panels: {
|
||||
renderError: {
|
||||
title: "このパネルを表示できません",
|
||||
},
|
||||
draft: {
|
||||
newAgent: "新しいエージェント",
|
||||
creatingAgent: "エージェントを作成中",
|
||||
|
||||
@@ -2195,9 +2195,6 @@ export const ko: TranslationResources = {
|
||||
archiveFinishedRetry: "다시 시도 ({{failed}}/{{total}})",
|
||||
},
|
||||
panels: {
|
||||
renderError: {
|
||||
title: "이 패널을 표시할 수 없습니다",
|
||||
},
|
||||
draft: {
|
||||
newAgent: "새 에이전트",
|
||||
creatingAgent: "에이전트 생성 중",
|
||||
|
||||
@@ -2223,9 +2223,6 @@ export const ptBR: TranslationResources = {
|
||||
archiveFinishedRetry: "Tentar novamente ({{failed}}/{{total}})",
|
||||
},
|
||||
panels: {
|
||||
renderError: {
|
||||
title: "Não foi possível exibir este painel",
|
||||
},
|
||||
draft: {
|
||||
newAgent: "Novo Agente",
|
||||
creatingAgent: "Criando agente",
|
||||
|
||||
@@ -2223,9 +2223,6 @@ export const ru: TranslationResources = {
|
||||
archiveFinishedRetry: "Повторить ({{failed}}/{{total}})",
|
||||
},
|
||||
panels: {
|
||||
renderError: {
|
||||
title: "Не удалось показать эту панель",
|
||||
},
|
||||
draft: {
|
||||
newAgent: "Новый агент",
|
||||
creatingAgent: "Создание агента",
|
||||
|
||||
@@ -2160,9 +2160,6 @@ export const zhCN: TranslationResources = {
|
||||
archiveFinishedRetry: "重试 ({{failed}}/{{total}})",
|
||||
},
|
||||
panels: {
|
||||
renderError: {
|
||||
title: "无法显示此面板",
|
||||
},
|
||||
draft: {
|
||||
newAgent: "新建 Agent",
|
||||
creatingAgent: "正在创建 Agent",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { ReactNode } from "react";
|
||||
import React, { Component, type ErrorInfo, type ReactNode } from "react";
|
||||
import { Text } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { RenderErrorBoundary } from "@/components/render-error-boundary";
|
||||
|
||||
interface SurfaceErrorBoundaryProps {
|
||||
children: ReactNode;
|
||||
@@ -11,30 +10,42 @@ interface SurfaceErrorBoundaryProps {
|
||||
renderError?(error: string): ReactNode;
|
||||
}
|
||||
|
||||
export function SurfaceErrorBoundary({
|
||||
children,
|
||||
installation,
|
||||
resetKey,
|
||||
Surface,
|
||||
renderError,
|
||||
}: SurfaceErrorBoundaryProps) {
|
||||
return (
|
||||
<RenderErrorBoundary
|
||||
resetKeys={[installation, resetKey, Surface]}
|
||||
onError={warnSurfaceRenderFailed}
|
||||
renderError={renderError ?? renderPluginFailed}
|
||||
>
|
||||
{children}
|
||||
</RenderErrorBoundary>
|
||||
);
|
||||
interface SurfaceErrorBoundaryState {
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
function renderPluginFailed(error: string) {
|
||||
return <Text style={styles.errorText}>Plugin failed: {error}</Text>;
|
||||
}
|
||||
export class SurfaceErrorBoundary extends Component<
|
||||
SurfaceErrorBoundaryProps,
|
||||
SurfaceErrorBoundaryState
|
||||
> {
|
||||
state: SurfaceErrorBoundaryState = { error: null };
|
||||
|
||||
function warnSurfaceRenderFailed(error: unknown, componentStack: string | null | undefined): void {
|
||||
console.warn("[Plugins] Surface render failed", error, componentStack);
|
||||
static getDerivedStateFromError(error: unknown): SurfaceErrorBoundaryState {
|
||||
return { error: error instanceof Error ? error.message : String(error) };
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error, info: ErrorInfo): void {
|
||||
console.warn("[Plugins] Surface render failed", error, info.componentStack);
|
||||
}
|
||||
|
||||
componentDidUpdate(previous: SurfaceErrorBoundaryProps): void {
|
||||
if (
|
||||
this.state.error &&
|
||||
(previous.installation !== this.props.installation ||
|
||||
previous.resetKey !== this.props.resetKey ||
|
||||
previous.Surface !== this.props.Surface)
|
||||
) {
|
||||
this.setState({ error: null });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
if (this.props.renderError) return this.props.renderError(this.state.error);
|
||||
return <Text style={styles.errorText}>Plugin failed: {this.state.error}</Text>;
|
||||
}
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
|
||||
@@ -15,6 +15,7 @@ import { SettingsRow, SettingsSection } from "@/components/settings";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CheckboxRow } from "@/components/ui/checkbox";
|
||||
import { bySizing, TOUCH_TARGET } from "@/components/ui/control-geometry";
|
||||
import { IndependentScrollBoundary } from "@/components/ui/independent-scroll-boundary";
|
||||
import { ToolbarButton, paneContentToolbarIconSize } from "@/components/ui/pane-content-toolbar";
|
||||
import { SearchField } from "@/components/ui/search-field";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
@@ -232,14 +233,16 @@ export function ProviderModels({
|
||||
/>
|
||||
) : null}
|
||||
{/* A provider can report hundreds of models; the rest of the page stays in reach. */}
|
||||
<ScrollView
|
||||
// Android scrolls a ScrollView nested in the page or the sheet only with this flag.
|
||||
nestedScrollEnabled
|
||||
style={[styles.discoveredList, curating && settingsStyles.rowBorder]}
|
||||
testID="provider-discovered-models"
|
||||
>
|
||||
{discoveredBody}
|
||||
</ScrollView>
|
||||
<IndependentScrollBoundary activateOnStart={false}>
|
||||
<ScrollView
|
||||
// Android scrolls a ScrollView nested in the page or the sheet only with this flag.
|
||||
nestedScrollEnabled
|
||||
style={[styles.discoveredList, curating && settingsStyles.rowBorder]}
|
||||
testID="provider-discovered-models"
|
||||
>
|
||||
{discoveredBody}
|
||||
</ScrollView>
|
||||
</IndependentScrollBoundary>
|
||||
</View>
|
||||
</SettingsSection>
|
||||
) : null}
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
/**
|
||||
* @vitest-environment jsdom
|
||||
*/
|
||||
import { act } from "@testing-library/react";
|
||||
import React from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { Text, View } from "react-native";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { definePanel, registerPanel } from "@/panels/panel-registry";
|
||||
import { buildWorkspacePaneContentModel } from "@/screens/workspace/workspace-pane-content";
|
||||
import { WorkspacePanelHost } from "@/screens/workspace/workspace-panel-host";
|
||||
import type { WorkspaceTabDescriptor } from "@/screens/workspace/workspace-tabs-types";
|
||||
|
||||
let panelFails = true;
|
||||
|
||||
function FailingPanel() {
|
||||
if (panelFails) throw new Error("Changes exploded");
|
||||
return <Text>Changes recovered</Text>;
|
||||
}
|
||||
|
||||
function HealthyPanel() {
|
||||
return <Text>Draft panel</Text>;
|
||||
}
|
||||
|
||||
// The workspace screen registers the real panels; these stand in for the two kinds the test opens.
|
||||
registerPanel(
|
||||
definePanel("agent", {
|
||||
component: FailingPanel,
|
||||
useDescriptor: () => {
|
||||
throw new Error("The test panel has no descriptor");
|
||||
},
|
||||
}),
|
||||
);
|
||||
registerPanel(
|
||||
definePanel("draft", {
|
||||
component: HealthyPanel,
|
||||
useDescriptor: () => {
|
||||
throw new Error("The test panel has no descriptor");
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const failingTab: WorkspaceTabDescriptor = {
|
||||
key: "agent_agent-a",
|
||||
tabId: "agent_agent-a",
|
||||
kind: "agent",
|
||||
target: { kind: "agent", agentId: "agent-a" },
|
||||
};
|
||||
const healthyTab: WorkspaceTabDescriptor = {
|
||||
key: "draft_draft-a",
|
||||
tabId: "draft_draft-a",
|
||||
kind: "draft",
|
||||
target: { kind: "draft", draftId: "draft-a" },
|
||||
};
|
||||
|
||||
function buildContent({ tab }: { paneId: string; tab: WorkspaceTabDescriptor }) {
|
||||
return buildWorkspacePaneContentModel({
|
||||
tab,
|
||||
normalizedServerId: "server-a",
|
||||
normalizedWorkspaceId: "workspace-a",
|
||||
host: "main",
|
||||
onOpenTab: vi.fn(),
|
||||
onOpenPreferredTarget: vi.fn(),
|
||||
onOpenTargetToSide: vi.fn(),
|
||||
onCloseCurrentTab: vi.fn(),
|
||||
onRetargetCurrentTab: vi.fn(),
|
||||
onSetCurrentTabState: vi.fn(),
|
||||
onOpenWorkspaceFile: vi.fn(),
|
||||
onOpenImportSheet: vi.fn(),
|
||||
});
|
||||
}
|
||||
|
||||
function Workspace({ activeTabId }: { activeTabId: string }) {
|
||||
return (
|
||||
<View>
|
||||
<Text>Sidebar</Text>
|
||||
<WorkspacePanelHost
|
||||
paneId="pane-a"
|
||||
tabs={[failingTab, healthyTab]}
|
||||
activeTabId={activeTabId}
|
||||
normalizedServerId="server-a"
|
||||
normalizedWorkspaceId="workspace-a"
|
||||
isWorkspaceFocused
|
||||
isPaneFocused
|
||||
buildPaneContentModel={buildContent}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function byTestId(container: HTMLElement, testID: string): HTMLElement | null {
|
||||
return container.querySelector(`[data-testid="${testID}"]`);
|
||||
}
|
||||
|
||||
describe("WorkspacePanelHost", () => {
|
||||
let root: Root | null = null;
|
||||
let container: HTMLElement | null = null;
|
||||
|
||||
afterEach(() => {
|
||||
if (root) act(() => root?.unmount());
|
||||
root = null;
|
||||
container?.remove();
|
||||
container = null;
|
||||
panelFails = true;
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("keeps a panel's render error inside that panel and retries it", () => {
|
||||
vi.spyOn(console, "error").mockImplementation(() => undefined);
|
||||
vi.spyOn(console, "warn").mockImplementation(() => undefined);
|
||||
container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
root = createRoot(container);
|
||||
|
||||
act(() => root?.render(<Workspace activeTabId={failingTab.tabId} />));
|
||||
expect(container.textContent).toContain("Sidebar");
|
||||
expect(byTestId(container, "panel-render-error")?.textContent).toContain("Changes exploded");
|
||||
|
||||
act(() => root?.render(<Workspace activeTabId={healthyTab.tabId} />));
|
||||
expect(container.textContent).toContain("Draft panel");
|
||||
|
||||
panelFails = false;
|
||||
act(() => root?.render(<Workspace activeTabId={failingTab.tabId} />));
|
||||
const retry = byTestId(container, "panel-render-error-retry");
|
||||
expect(retry).not.toBeNull();
|
||||
act(() => retry?.click());
|
||||
expect(byTestId(container, "panel-render-error")).toBeNull();
|
||||
expect(container.textContent).toContain("Changes recovered");
|
||||
expect(container.textContent).toContain("Sidebar");
|
||||
});
|
||||
});
|
||||
@@ -1,11 +1,5 @@
|
||||
import { memo, useCallback, useEffect, useMemo, useRef } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { View } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { RenderErrorBoundary } from "@/components/render-error-boundary";
|
||||
import { RetainedPanel } from "@/components/retained-panel";
|
||||
import { Alert } from "@/components/ui/alert";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useModifiedPanelTabIds } from "@/panels/panel-instance-attributes";
|
||||
import {
|
||||
WorkspacePaneContent,
|
||||
@@ -58,44 +52,17 @@ const MountedTab = memo(function MountedTab({
|
||||
return (
|
||||
<RenderProfile id={`DesktopMountedTab:${tab.kind}:${tab.tabId}`}>
|
||||
<RetainedPanel active={visible}>
|
||||
<RenderErrorBoundary
|
||||
resetKeys={[tab]}
|
||||
onError={logPanelRenderError}
|
||||
renderError={renderPanelError}
|
||||
>
|
||||
<WorkspacePaneContent
|
||||
content={content}
|
||||
isWorkspaceFocused={isWorkspaceFocused}
|
||||
isPaneFocused={interactive}
|
||||
onFocusPane={onFocusPane ? handleFocusPane : undefined}
|
||||
/>
|
||||
</RenderErrorBoundary>
|
||||
<WorkspacePaneContent
|
||||
content={content}
|
||||
isWorkspaceFocused={isWorkspaceFocused}
|
||||
isPaneFocused={interactive}
|
||||
onFocusPane={onFocusPane ? handleFocusPane : undefined}
|
||||
/>
|
||||
</RetainedPanel>
|
||||
</RenderProfile>
|
||||
);
|
||||
});
|
||||
|
||||
function logPanelRenderError(error: unknown, componentStack: string | null | undefined): void {
|
||||
console.error("[WorkspacePanel] Render failed", error, componentStack);
|
||||
}
|
||||
|
||||
function renderPanelError(error: string, retry: () => void) {
|
||||
return <PanelRenderError error={error} onRetry={retry} />;
|
||||
}
|
||||
|
||||
function PanelRenderError({ error, onRetry }: { error: string; onRetry: () => void }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<View style={styles.renderError} testID="panel-render-error">
|
||||
<Alert variant="error" title={t("panels.renderError.title")} description={error}>
|
||||
<Button variant="outline" size="sm" onPress={onRetry} testID="panel-render-error-retry">
|
||||
{t("common.actions.retry")}
|
||||
</Button>
|
||||
</Alert>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function useStableTabs(tabs: WorkspaceTabDescriptor[]) {
|
||||
const cacheRef = useRef(new Map<string, WorkspaceTabDescriptor>());
|
||||
const stableTabs = useMemo(() => {
|
||||
@@ -169,9 +136,3 @@ export function WorkspacePanelHost({
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
renderError: {
|
||||
padding: theme.spacing[4],
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -262,12 +262,16 @@ describe("daemon E2E (real codex) - send message during tool call", () => {
|
||||
cwd: cwd ?? process.cwd(),
|
||||
title: "codex-exact-turn-steer",
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
thinkingOptionId: "low",
|
||||
modeId: "full-access",
|
||||
}),
|
||||
);
|
||||
resources.collector = createMessageCollector(client);
|
||||
await within(
|
||||
"subscribe to steering agent timeline",
|
||||
15_000,
|
||||
client.observeTimeline([agent.id]).ready,
|
||||
);
|
||||
await within(
|
||||
"submit Codex foreground sleep turn",
|
||||
30_000,
|
||||
@@ -401,12 +405,12 @@ describe("daemon E2E (real codex) - send message during tool call", () => {
|
||||
cwd,
|
||||
title: "codex-tool-interrupt-repro",
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
thinkingOptionId: "low",
|
||||
modeId: "full-access",
|
||||
});
|
||||
|
||||
collector = createMessageCollector(client);
|
||||
await client.observeTimeline([agent.id]).ready;
|
||||
|
||||
await client.sendMessage(
|
||||
agent.id,
|
||||
@@ -480,12 +484,12 @@ describe("daemon E2E (real codex) - send message during tool call", () => {
|
||||
cwd,
|
||||
title: "codex-quick-follow-up-repro",
|
||||
provider: "codex",
|
||||
model: "gpt-5.4",
|
||||
thinkingOptionId: "low",
|
||||
modeId: "full-access",
|
||||
});
|
||||
|
||||
collector = createMessageCollector(client);
|
||||
await client.observeTimeline([agent.id]).ready;
|
||||
|
||||
await client.sendAgentMessage(
|
||||
agent.id,
|
||||
|
||||
@@ -364,10 +364,14 @@ test("the plugin demo shows its finished state when motion is reduced", async ({
|
||||
const builtPanelRow = page.getByText("Add Gruvbox theme", { exact: true });
|
||||
const panel = builtPanelRow.locator("xpath=ancestor::div[contains(@class, 'md:border-l')]");
|
||||
const heading = page.getByRole("heading", { name: "Ask Paseo to change Paseo" });
|
||||
const section = heading.locator("xpath=ancestor::section[1]");
|
||||
|
||||
// The section fades in when it scrolls into view. The demo inside must already be finished
|
||||
// when that fade ends; the staged demo would still be hiding the row for seconds.
|
||||
await expect(async () => {
|
||||
await heading.scrollIntoViewIfNeeded();
|
||||
expect(await renderedOpacity(builtPanelRow)).toBe(1);
|
||||
}).toPass({ timeout: 2_000 });
|
||||
expect(await renderedOpacity(section)).toBe(1);
|
||||
}).toPass();
|
||||
expect(await renderedOpacity(builtPanelRow)).toBe(1);
|
||||
expect(await panel.evaluate((element) => getComputedStyle(element).transform)).toBe("none");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user