mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-22 08:15:05 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3914893aa1 |
+2
-2
@@ -78,7 +78,7 @@ In the composer, the first glyph's ink starts on the text column's edge, and the
|
||||
|
||||
One gate, `resolveControlSizing`, picks touch or pointer sizing: touch when the layout is compact or touch is the primary input. An iPad with the sidebar docked is wide and touch-sized; a desktop is pointer-sized; a phone is both compact and touch. The primary input comes from `(pointer: coarse)` (`hasTouchPrimaryPointer` in `hooks/pointer-capabilities.ts`), not from whether a touch screen exists: WebKit keeps touch primary on an iPad with a trackpad attached, and Chromium reports a fine primary pointer for a laptop with a touch screen that its trackpad drives. The fact is read once at startup: attaching a pointer to a tablet does not shrink its controls, and a 2-in-1 launched with a pointer keeps pointer sizes after it switches to tablet mode until the app reloads. Stylesheets take sizes from `bySizing({ touch, pointer })`, which resolves to a breakpoint value, so a caller never sees which sizing it got. Rows, icon buttons and icon slots take theirs from `styles/density.ts`, which uses the same gate. An `{ xs, md }` literal for a hit target or glyph is wrong: on an iPad it yields the pointer size.
|
||||
|
||||
Buttons are pills (`borderRadius.full`) with medium-weight labels; an icon-only button is a circle. `<Switch>` follows the same two sizes: a 34×20 track by default and in `sm`, 44×26 where controls are touch-sized, and it reserves its size's control height so a row holding one lines up with a row holding a button. Buttons, text fields, dropdown triggers, and `<SegmentedControl>` (`packages/app/src/components/ui/segmented-control.tsx`) share the size contract — the same size name means the same height and label size on every control kind, so controls in one row line up. Segments run tighter than a button, because the gap between segments already reads as padding. The selected segment is a `surface3` fill with `foreground` text, not an inverted one — inverting it inside thin chrome puts a white slab in the toolbar. A settings row sizes the controls in its trailing slot itself, default in a card and `sm` when nested (`packages/app/src/components/ui/control-size.tsx`), so don't pass a size to a button, dropdown or field placed in a row. Code that computes with a control's height outside a stylesheet uses `controlHeightForLayout`. Never shrink a control's font or padding locally to fit a context — if the context needs a smaller control, the size tier is missing or the wrong one is in use.
|
||||
Buttons are pills (`borderRadius.full`) with medium-weight labels; an icon-only button is a circle. `<Switch>` follows the same two sizes: a 34×20 track by default and in `sm`, 44×26 where controls are touch-sized, and it takes presses over its size's control height without adding that height to its row. Buttons, text fields, dropdown triggers, and `<SegmentedControl>` (`packages/app/src/components/ui/segmented-control.tsx`) share the size contract — the same size name means the same height and label size on every control kind, so controls in one row line up. Segments run tighter than a button, because the gap between segments already reads as padding. The selected segment is a `surface3` fill with `foreground` text, not an inverted one — inverting it inside thin chrome puts a white slab in the toolbar. A settings row sizes the controls in its trailing slot itself, default in a card and `sm` when nested (`packages/app/src/components/ui/control-size.tsx`), so don't pass a size to a button, dropdown or field placed in a row. Code that computes with a control's height outside a stylesheet uses `controlHeightForLayout`. Never shrink a control's font or padding locally to fit a context — if the context needs a smaller control, the size tier is missing or the wrong one is in use.
|
||||
|
||||
A `<Pressable>` wrapping a `<Text>` is a sixth variant. It is wrong. `<Button>` accepts `style`, `textStyle`, `leftIcon`, `disabled`, `size`, and `variant`.
|
||||
|
||||
@@ -134,7 +134,7 @@ A section or group explains itself through the `info` prop on `<SettingsSection>
|
||||
|
||||
Cards inside a section sit closer than sections. Rows inside a card touch — only the divider separates them. The rhythm is page → spacious; section → spacious; card → tight.
|
||||
|
||||
Rows have generous vertical padding: roughly 16px of content plus 16px of vertical padding for settings rows, 8–12px for sidebar list items where many rows must fit. A row that opens something (`<SettingsDetailRow>`, a collapsible row's header) is at least as tall as one holding a default control, so a list where only some of those rows carry a switch keeps one row height. Other rows take their content's height. Compressing rows below the established density to fit more on the screen is wrong. Too many rows means more cards or more sections, not smaller rows.
|
||||
Rows have generous vertical padding: roughly 16px of content plus 16px of vertical padding for settings rows, 8–12px for sidebar list items where many rows must fit. Every row is at least as tall as one holding a switch, so text rows, switch rows and rows that open something (`<SettingsDetailRow>`, a collapsible row's header) line up. A row holding a button or a select is taller. Compressing rows below the established density to fit more on the screen is wrong. Too many rows means more cards or more sections, not smaller rows.
|
||||
|
||||
Rows revealed under a `<SettingsCollapsibleRow>` are nested rows, one step smaller than card rows: 8px of vertical padding, `fontSize.sm` text, `sm` controls, and one fixed height so rows with and without a trailing button line up. The collapsible row sets this for everything under it (`packages/app/src/components/settings/row-density.tsx`). Never pass a density to a row, and never pad or resize a nested row by hand. Settings rows that share a menu surface with menu rows, such as Usage's options, go inside `<MenuSettingsRows>`, which puts their labels on the menu rows' label rail (`menuRowContentInset`).
|
||||
|
||||
|
||||
@@ -118,7 +118,8 @@ async function exerciseProviderSettingsStack(page: Page) {
|
||||
|
||||
await page.getByRole("button", { name: "Refresh", exact: true }).click();
|
||||
await expectProviderSettingsVisible(page);
|
||||
await expect(page.getByText("Checked just now", { exact: true })).toBeVisible({
|
||||
// The Models header puts the model count before it: "12 · Checked just now".
|
||||
await expect(page.getByText(/Checked just now$/)).toBeVisible({
|
||||
timeout: 30_000,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -567,7 +567,9 @@ export async function expectProviderPageLoaded(page: Page, providerName: string)
|
||||
await expect(page.getByTestId("provider-detail-title")).toHaveText(providerName, {
|
||||
timeout: 30_000,
|
||||
});
|
||||
await expect(page.getByText("Provider status")).toBeVisible({ timeout: 30_000 });
|
||||
await expect(page.getByRole("button", { name: "Diagnostic report" })).toBeVisible({
|
||||
timeout: 30_000,
|
||||
});
|
||||
}
|
||||
|
||||
export async function expectProviderNotOnHost(page: Page): Promise<void> {
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { AppearanceText as Text } from "@/appearance/text";
|
||||
import { ChevronRight } from "lucide-react-native";
|
||||
import { useMemo, type ReactNode } from "react";
|
||||
import { Platform, ScrollView, View } from "react-native";
|
||||
import { Platform, ScrollView, View, type PressableStateCallbackType } from "react-native";
|
||||
import { KeyboardAwareScrollView } from "react-native-keyboard-controller";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import { BackHeader } from "@/components/headers/back-header";
|
||||
import { MenuHeader } from "@/components/headers/menu-header";
|
||||
import { PressHighlight } from "@/components/ui/press-highlight";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { SPACING } from "@/styles/theme";
|
||||
import { ICON_SIZE, SPACING, type Theme } from "@/styles/theme";
|
||||
|
||||
const PageScrollView = Platform.OS === "android" ? KeyboardAwareScrollView : ScrollView;
|
||||
|
||||
@@ -58,14 +60,7 @@ export function PageLayout({
|
||||
testID={testID}
|
||||
>
|
||||
<View style={width === "wide" ? styles.contentWide : styles.content}>
|
||||
{showTitle ? (
|
||||
<View style={styles.titleRow} testID={titleTestID}>
|
||||
<Text style={styles.title} testID="page-title">
|
||||
{title}
|
||||
</Text>
|
||||
{actions}
|
||||
</View>
|
||||
) : null}
|
||||
{showTitle ? <PageTitle title={title} actions={actions} testID={titleTestID} /> : null}
|
||||
{children}
|
||||
</View>
|
||||
</PageScrollView>
|
||||
@@ -73,6 +68,77 @@ export function PageLayout({
|
||||
);
|
||||
}
|
||||
|
||||
/** The page that holds this one. Its name is the first part of the title and goes back to it. */
|
||||
export interface PageTitleParent {
|
||||
label: string;
|
||||
/** What the press does, such as "Back to providers". */
|
||||
accessibilityLabel: string;
|
||||
onPress: () => void;
|
||||
testID?: string;
|
||||
}
|
||||
|
||||
interface PageTitleProps {
|
||||
parent?: PageTitleParent;
|
||||
/** Drawn before the title, such as the icon of the thing the page is about. */
|
||||
icon?: ReactNode;
|
||||
title?: string;
|
||||
/** A control that belongs to the title, drawn right after it. */
|
||||
adornment?: ReactNode;
|
||||
/** Controls for the whole page, drawn at the trailing edge. */
|
||||
actions?: ReactNode;
|
||||
testID?: string;
|
||||
titleTestID?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The heading of a desktop page. A page that opens from another page, such as one provider from
|
||||
* Providers, names that page first: "Providers > Antigravity".
|
||||
*/
|
||||
export function PageTitle({
|
||||
parent,
|
||||
icon,
|
||||
title,
|
||||
adornment,
|
||||
actions,
|
||||
testID,
|
||||
titleTestID = "page-title",
|
||||
}: PageTitleProps) {
|
||||
return (
|
||||
<View style={styles.titleRow} testID={testID}>
|
||||
<View style={styles.titleParts}>
|
||||
{parent ? (
|
||||
<PressHighlight
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={parent.accessibilityLabel}
|
||||
onPress={parent.onPress}
|
||||
testID={parent.testID}
|
||||
>
|
||||
{({ hovered }: PressableStateCallbackType & { hovered?: boolean }) => (
|
||||
<Text style={[styles.title, styles.parent, hovered && styles.parentHovered]}>
|
||||
{parent.label}
|
||||
</Text>
|
||||
)}
|
||||
</PressHighlight>
|
||||
) : null}
|
||||
{parent && title !== undefined ? (
|
||||
<ThemedChevronRight size={ICON_SIZE.lg} uniProps={separatorColor} />
|
||||
) : null}
|
||||
{icon}
|
||||
{title !== undefined ? (
|
||||
<Text style={[styles.title, styles.titleLeaf]} numberOfLines={1} testID={titleTestID}>
|
||||
{title}
|
||||
</Text>
|
||||
) : null}
|
||||
{adornment}
|
||||
</View>
|
||||
{actions}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const ThemedChevronRight = withUnistyles(ChevronRight);
|
||||
const separatorColor = (theme: Theme) => ({ color: theme.colors.foregroundMuted });
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
container: {
|
||||
flex: 1,
|
||||
@@ -102,11 +168,27 @@ const styles = StyleSheet.create((theme) => ({
|
||||
gap: theme.spacing[4],
|
||||
marginBottom: theme.spacing[6],
|
||||
},
|
||||
title: {
|
||||
titleParts: {
|
||||
// Line up with the section titles, which sit inset from their cards.
|
||||
marginLeft: theme.spacing[1],
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
flexShrink: 1,
|
||||
minWidth: 0,
|
||||
},
|
||||
title: {
|
||||
fontSize: theme.fontSize["4xl"],
|
||||
fontWeight: theme.fontWeight.medium,
|
||||
color: theme.colors.foreground,
|
||||
},
|
||||
titleLeaf: {
|
||||
flexShrink: 1,
|
||||
},
|
||||
parent: {
|
||||
color: theme.colors.foregroundMuted,
|
||||
},
|
||||
parentHovered: {
|
||||
color: theme.colors.foreground,
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -2,7 +2,9 @@ import { ArrowLeft } from "lucide-react-native";
|
||||
import type { ReactNode } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { PageTitle, type PageTitleParent } from "@/components/page-layout";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
|
||||
/**
|
||||
* "Back to …" above a settings detail page on wide layouts, where the page has no header of its
|
||||
@@ -32,32 +34,43 @@ export function SettingsBackLink({
|
||||
}
|
||||
|
||||
/**
|
||||
* The top of a settings detail page: "Back to …" when the page has no header of its own, then the
|
||||
* icon and name the page is about, with an optional action after the name.
|
||||
* The top of a settings detail page: the icon and name of the thing the page is about, with an
|
||||
* optional action after the name. On wide layouts it is the page's title and names the parent page
|
||||
* first, which goes back to it. On compact layouts the back header already names the parent.
|
||||
*/
|
||||
export function SettingsDetailHeader({
|
||||
back,
|
||||
parent,
|
||||
icon,
|
||||
title,
|
||||
trailing,
|
||||
titleTestID,
|
||||
}: {
|
||||
back?: { label: string; onPress: () => void; testID?: string };
|
||||
icon: ReactNode;
|
||||
title: string;
|
||||
parent: PageTitleParent;
|
||||
icon?: ReactNode;
|
||||
/** Absent while the page has nothing to name, such as a project that no longer exists. */
|
||||
title?: string;
|
||||
trailing?: ReactNode;
|
||||
titleTestID?: string;
|
||||
}) {
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
if (!isCompact)
|
||||
return (
|
||||
<PageTitle
|
||||
parent={parent}
|
||||
icon={icon}
|
||||
title={title}
|
||||
adornment={trailing}
|
||||
titleTestID={titleTestID}
|
||||
/>
|
||||
);
|
||||
if (title === undefined) return null;
|
||||
return (
|
||||
<View style={styles.header}>
|
||||
{back ? <SettingsBackLink {...back} /> : null}
|
||||
<View style={styles.titleRow}>
|
||||
{icon}
|
||||
<Text style={styles.title} numberOfLines={1} testID={titleTestID}>
|
||||
{title}
|
||||
</Text>
|
||||
{trailing}
|
||||
</View>
|
||||
<View style={styles.titleRow}>
|
||||
{icon}
|
||||
<Text style={styles.title} numberOfLines={1} testID={titleTestID}>
|
||||
{title}
|
||||
</Text>
|
||||
{trailing}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -67,15 +80,13 @@ const styles = StyleSheet.create((theme) => ({
|
||||
alignSelf: "flex-start",
|
||||
paddingHorizontal: 0,
|
||||
},
|
||||
header: {
|
||||
gap: theme.spacing[2],
|
||||
marginBottom: theme.spacing[4],
|
||||
},
|
||||
titleRow: {
|
||||
marginTop: theme.spacing[2],
|
||||
// Line up with the section titles, which sit inset from their cards.
|
||||
marginLeft: theme.spacing[1],
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[3],
|
||||
marginBottom: theme.spacing[4],
|
||||
},
|
||||
title: {
|
||||
color: theme.colors.foreground,
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { View } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
|
||||
/**
|
||||
* The action at a heading's end. It adds no height, so a heading with a button is as tall as one
|
||||
* without and both sit the same distance from their cards. The button stays centered on the title
|
||||
* and its hit area grows past the heading.
|
||||
*/
|
||||
export function HeadingTrailing({ children }: { children: ReactNode }) {
|
||||
if (children === null || children === undefined || children === false) return null;
|
||||
return <View style={styles.trailing}>{children}</View>;
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
trailing: {
|
||||
height: 0,
|
||||
justifyContent: "center",
|
||||
// A long trailing gives way to the title.
|
||||
flexShrink: 1,
|
||||
},
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useMemo, type ReactNode } from "react";
|
||||
import { Text, View, type StyleProp, type ViewStyle } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { HeadingTrailing } from "./heading-trailing";
|
||||
import { SettingsInfoTip } from "./settings-info-tip";
|
||||
|
||||
interface SettingsGroupProps {
|
||||
@@ -40,7 +41,7 @@ export function SettingsGroup({
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
{trailing}
|
||||
<HeadingTrailing>{trailing}</HeadingTrailing>
|
||||
</View>
|
||||
{children}
|
||||
</View>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useMemo, type ReactNode } from "react";
|
||||
import { View, type StyleProp, type ViewStyle } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { ExternalLink, type ExternalLinkProps } from "@/components/ui/external-link";
|
||||
import { HeadingTrailing } from "./heading-trailing";
|
||||
import { SettingsInfoTip } from "./settings-info-tip";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
|
||||
@@ -67,7 +68,7 @@ export function SettingsSection({
|
||||
<ExternalLink {...link} />
|
||||
</View>
|
||||
) : null}
|
||||
{trailing}
|
||||
<HeadingTrailing>{trailing}</HeadingTrailing>
|
||||
</View>
|
||||
<View style={styles.content}>{children}</View>
|
||||
</View>
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
SettingsCollapsibleRow,
|
||||
SettingsDetailRow,
|
||||
SettingsRow,
|
||||
SettingsSwitch,
|
||||
} from "@/components/settings";
|
||||
|
||||
let root: Root | null = null;
|
||||
@@ -20,6 +21,7 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
function openNothing() {}
|
||||
function toggleNothing() {}
|
||||
|
||||
function mountRows() {
|
||||
container = document.createElement("div");
|
||||
@@ -33,6 +35,13 @@ function mountRows() {
|
||||
Download
|
||||
</Button>
|
||||
</SettingsRow>
|
||||
<SettingsRow label="Text only" testID="text-row" />
|
||||
<SettingsSwitch
|
||||
label="Toggles"
|
||||
value={false}
|
||||
onValueChange={toggleNothing}
|
||||
testID="switch-row"
|
||||
/>
|
||||
<SettingsDetailRow label="Opens a page" onPress={openNothing} testID="detail-row" />
|
||||
<SettingsCollapsibleRow label="Group" defaultExpanded testID="group">
|
||||
<SettingsRow label="Nested with a button" testID="nested-with-button">
|
||||
@@ -74,11 +83,13 @@ describe("settings row density", () => {
|
||||
expect(heightOf("group-toggle")).toBeGreaterThan(heightOf("nested-without-button"));
|
||||
});
|
||||
|
||||
it("keeps a row that opens something as tall as a row holding a control", () => {
|
||||
it("lines up text, switch, and opening rows below a row holding a button", () => {
|
||||
mountRows();
|
||||
|
||||
expect(heightOf("detail-row")).toBe(heightOf("card-row"));
|
||||
expect(heightOf("group-toggle")).toBe(heightOf("card-row"));
|
||||
expect(heightOf("switch-row")).toBe(heightOf("text-row"));
|
||||
expect(heightOf("detail-row")).toBe(heightOf("text-row"));
|
||||
expect(heightOf("group-toggle")).toBe(heightOf("text-row"));
|
||||
expect(heightOf("card-row")).toBeGreaterThan(heightOf("text-row"));
|
||||
});
|
||||
|
||||
it("sizes nested text and controls one step below card rows", () => {
|
||||
|
||||
@@ -27,11 +27,6 @@ export function MenuSettingsRows({ children }: { children: ReactNode }) {
|
||||
|
||||
export interface SettingsRowLayout {
|
||||
row: StyleProp<ViewStyle>;
|
||||
/**
|
||||
* A row as tall as one holding a control of `controlSize`, whether or not it holds one. In a menu
|
||||
* it keeps the menu's row height.
|
||||
*/
|
||||
controlRow: StyleProp<ViewStyle>;
|
||||
title: StyleProp<TextStyle>;
|
||||
hint: StyleProp<TextStyle>;
|
||||
/** The size of the controls in the row's trailing slot. */
|
||||
@@ -43,7 +38,6 @@ function layoutFor(placement: RowPlacement): SettingsRowLayout {
|
||||
case "nested":
|
||||
return {
|
||||
row: [settingsStyles.row, styles.nestedRow],
|
||||
controlRow: [settingsStyles.row, styles.nestedRow],
|
||||
title: [settingsStyles.rowTitle, styles.nestedText],
|
||||
hint: [settingsStyles.rowHint, styles.nestedText],
|
||||
controlSize: "sm",
|
||||
@@ -51,7 +45,6 @@ function layoutFor(placement: RowPlacement): SettingsRowLayout {
|
||||
case "menu":
|
||||
return {
|
||||
row: [settingsStyles.row, styles.menuRow],
|
||||
controlRow: [settingsStyles.row, styles.menuRow],
|
||||
title: settingsStyles.rowTitle,
|
||||
hint: settingsStyles.rowHint,
|
||||
controlSize: "md",
|
||||
@@ -59,7 +52,6 @@ function layoutFor(placement: RowPlacement): SettingsRowLayout {
|
||||
case "card":
|
||||
return {
|
||||
row: settingsStyles.row,
|
||||
controlRow: [settingsStyles.row, styles.cardControlRow],
|
||||
title: settingsStyles.rowTitle,
|
||||
hint: settingsStyles.rowHint,
|
||||
controlSize: "md",
|
||||
@@ -74,9 +66,6 @@ export function useSettingsRowLayout(): SettingsRowLayout {
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
cardControlRow: {
|
||||
minHeight: mapLayout(CONTROL_HEIGHTS.md, (height) => height + theme.spacing[4] * 2),
|
||||
},
|
||||
// Every nested row is as tall as one holding an `sm` control, so rows with and without a
|
||||
// trailing button line up.
|
||||
nestedRow: {
|
||||
|
||||
@@ -86,7 +86,7 @@ export function SettingsRowHeader({
|
||||
const handlePointerEnter = useCallback(() => setPointerOver(true), []);
|
||||
const handlePointerLeave = useCallback(() => setPointerOver(false), []);
|
||||
const hovered = pointerOver && !disabled;
|
||||
const rowStyle = useMemo(() => [layout.controlRow, hovered && styles.hovered], [hovered, layout]);
|
||||
const rowStyle = useMemo(() => [layout.row, hovered && styles.hovered], [hovered, layout]);
|
||||
const chevronStyle = useMemo(
|
||||
() => [styles.chevron, expanded && styles.chevronExpanded],
|
||||
[expanded],
|
||||
|
||||
@@ -302,23 +302,23 @@ describe("control geometry", () => {
|
||||
trackHeight: 20,
|
||||
thumbSize: 16,
|
||||
thumbTravel: 14,
|
||||
reservedHeight: 32,
|
||||
hitHeight: 32,
|
||||
});
|
||||
expect(switchGeometryForLayout("md", true)).toEqual({
|
||||
trackWidth: 44,
|
||||
trackHeight: 26,
|
||||
thumbSize: 22,
|
||||
thumbTravel: 18,
|
||||
reservedHeight: 44,
|
||||
hitHeight: 44,
|
||||
});
|
||||
// Tight chrome keeps the pointer-sized track on every layout and reserves its row's height.
|
||||
// Tight chrome keeps the pointer-sized track on every layout and takes presses over its row's control height.
|
||||
expect(switchGeometryForLayout("sm", true)).toMatchObject({
|
||||
trackWidth: 34,
|
||||
reservedHeight: 32,
|
||||
hitHeight: 32,
|
||||
});
|
||||
expect(switchGeometryForLayout("sm", false)).toMatchObject({
|
||||
trackWidth: 34,
|
||||
reservedHeight: 28,
|
||||
hitHeight: 28,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -223,8 +223,11 @@ export interface SwitchGeometry {
|
||||
thumbSize: number;
|
||||
/** How far the thumb slides between off and on. */
|
||||
thumbTravel: number;
|
||||
/** The control height the switch reserves, so its row lines up with one holding a button. */
|
||||
reservedHeight: number;
|
||||
/**
|
||||
* The height of the area that takes the press: the control height of the switch's size. The
|
||||
* switch itself is only as tall as its track, so it never makes a row taller.
|
||||
*/
|
||||
hitHeight: number;
|
||||
}
|
||||
|
||||
function switchSize(trackWidth: number, trackHeight: number, thumbSize: number) {
|
||||
@@ -235,6 +238,15 @@ function switchSize(trackWidth: number, trackHeight: number, thumbSize: number)
|
||||
const SWITCH_POINTER = switchSize(34, 20, 16);
|
||||
const SWITCH_TOUCH = switchSize(44, 26, 22);
|
||||
|
||||
/**
|
||||
* The height of a default switch. Exported so a row can be as tall as one holding a switch whether
|
||||
* or not it holds one. A breakpoint value, so it only works inside a Unistyles stylesheet.
|
||||
*/
|
||||
export const SWITCH_HEIGHT = bySizing({
|
||||
touch: SWITCH_TOUCH.trackHeight,
|
||||
pointer: SWITCH_POINTER.trackHeight,
|
||||
});
|
||||
|
||||
/**
|
||||
* A switch follows the same two sizes as every other control. Its thumb travel feeds an
|
||||
* animation, so the size is resolved to plain numbers here instead of a stylesheet breakpoint.
|
||||
@@ -242,7 +254,7 @@ const SWITCH_TOUCH = switchSize(44, 26, 22);
|
||||
export function switchGeometryForLayout(size: ControlSize, isCompact: boolean): SwitchGeometry {
|
||||
const touchSized = controlSizingForLayout(isCompact) === "touch";
|
||||
const track = size === "md" && touchSized ? SWITCH_TOUCH : SWITCH_POINTER;
|
||||
return { ...track, reservedHeight: controlHeightForLayout(size, isCompact) };
|
||||
return { ...track, hitHeight: controlHeightForLayout(size, isCompact) };
|
||||
}
|
||||
|
||||
function fieldLineHeight(fontSize: number): number {
|
||||
|
||||
@@ -25,6 +25,8 @@ export interface SearchFieldProps {
|
||||
/** Falls back to `placeholder`, which already names the field. */
|
||||
accessibilityLabel?: string;
|
||||
clearAccessibilityLabel: string;
|
||||
/** Fill the container, for a search that heads one list. Defaults to the filter rail's width. */
|
||||
fullWidth?: boolean;
|
||||
testID?: string;
|
||||
clearTestID?: string;
|
||||
}
|
||||
@@ -42,6 +44,7 @@ export function SearchField({
|
||||
placeholder,
|
||||
accessibilityLabel,
|
||||
clearAccessibilityLabel,
|
||||
fullWidth = false,
|
||||
testID,
|
||||
clearTestID,
|
||||
}: SearchFieldProps): ReactElement {
|
||||
@@ -55,7 +58,9 @@ export function SearchField({
|
||||
}, [onChangeText]);
|
||||
|
||||
return (
|
||||
<View style={[styles.field, isFocused && styles.fieldFocused]}>
|
||||
<View
|
||||
style={[styles.field, fullWidth && styles.fieldFullWidth, isFocused && styles.fieldFocused]}
|
||||
>
|
||||
<ThemedSearch size={14} uniProps={mutedColorMapping} />
|
||||
<ThemedTextInput
|
||||
testID={testID}
|
||||
@@ -103,6 +108,9 @@ const styles = StyleSheet.create((theme) => ({
|
||||
borderWidth: theme.borderWidth[1],
|
||||
borderColor: theme.colors.border,
|
||||
},
|
||||
fieldFullWidth: {
|
||||
maxWidth: "100%",
|
||||
},
|
||||
fieldFocused: {
|
||||
borderColor: theme.colors.borderAccent,
|
||||
backgroundColor: theme.colors.surface2,
|
||||
|
||||
@@ -123,11 +123,16 @@ export function Switch({
|
||||
const pressableStyle = useMemo(
|
||||
() => [
|
||||
styles.switchControl,
|
||||
{ minHeight: geometry.reservedHeight },
|
||||
// The press area is a full control tall and grows out of the track; the layout only sees
|
||||
// the track.
|
||||
{
|
||||
minHeight: geometry.hitHeight,
|
||||
marginVertical: (geometry.trackHeight - geometry.hitHeight) / 2,
|
||||
},
|
||||
disabled ? styles.disabled : null,
|
||||
style,
|
||||
],
|
||||
[disabled, geometry.reservedHeight, style],
|
||||
[disabled, geometry.hitHeight, geometry.trackHeight, style],
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -3113,6 +3113,7 @@ export const ar: TranslationResources = {
|
||||
status: "حالة المزود",
|
||||
checked: "تم الفحص {{time}}",
|
||||
diagnosticReport: "تقرير التشخيص",
|
||||
docs: "الوثائق",
|
||||
dangerZone: "منطقة الخطر",
|
||||
removeHint: "يحذف هذا المزود من config.json",
|
||||
},
|
||||
@@ -3158,7 +3159,7 @@ export const ar: TranslationResources = {
|
||||
noSearchMatches: "لا توجد نماذج تطابق بحثك",
|
||||
noneDetected: "لم يتم اكتشاف أي نماذج",
|
||||
noCustom: "لا توجد نماذج مخصصة",
|
||||
discovered: "اكتشف",
|
||||
title: "النماذج",
|
||||
custom: "نماذج مخصصة",
|
||||
updated: "تم تحديث{{time}}",
|
||||
},
|
||||
|
||||
@@ -3211,6 +3211,7 @@ export const en = {
|
||||
status: "Provider status",
|
||||
checked: "Checked {{time}}",
|
||||
diagnosticReport: "Diagnostic report",
|
||||
docs: "Docs",
|
||||
dangerZone: "Danger zone",
|
||||
removeHint: "Deletes this provider from config.json",
|
||||
},
|
||||
@@ -3256,7 +3257,7 @@ export const en = {
|
||||
noSearchMatches: "No models match your search",
|
||||
noneDetected: "No models detected",
|
||||
noCustom: "No custom models",
|
||||
discovered: "Discovered",
|
||||
title: "Models",
|
||||
custom: "Custom models",
|
||||
updated: "Updated {{time}}",
|
||||
},
|
||||
|
||||
@@ -3141,6 +3141,7 @@ export const es: TranslationResources = {
|
||||
status: "Estado del proveedor",
|
||||
checked: "Comprobado {{time}}",
|
||||
diagnosticReport: "Informe de diagnóstico",
|
||||
docs: "Documentación",
|
||||
dangerZone: "Zona de peligro",
|
||||
removeHint: "Elimina este proveedor de config.json",
|
||||
},
|
||||
@@ -3186,7 +3187,7 @@ export const es: TranslationResources = {
|
||||
noSearchMatches: "Ningún modelo coincide con tu búsqueda",
|
||||
noneDetected: "No se detectaron modelos",
|
||||
noCustom: "No hay modelos personalizados",
|
||||
discovered: "descubierto",
|
||||
title: "Modelos",
|
||||
custom: "Modelos personalizados",
|
||||
updated: "{{time}}actualizado",
|
||||
},
|
||||
|
||||
@@ -3147,6 +3147,7 @@ export const fr: TranslationResources = {
|
||||
status: "État du fournisseur",
|
||||
checked: "Vérifié {{time}}",
|
||||
diagnosticReport: "Rapport de diagnostic",
|
||||
docs: "Documentation",
|
||||
dangerZone: "Zone de danger",
|
||||
removeHint: "Supprime ce fournisseur de config.json",
|
||||
},
|
||||
@@ -3193,7 +3194,7 @@ export const fr: TranslationResources = {
|
||||
noSearchMatches: "Aucun modèle ne correspond à votre recherche",
|
||||
noneDetected: "Aucun modèle détecté",
|
||||
noCustom: "Aucun modèle personnalisé",
|
||||
discovered: "Détectés",
|
||||
title: "Modèles",
|
||||
custom: "Modèles personnalisés",
|
||||
updated: "Mis à jour {{time}}",
|
||||
},
|
||||
|
||||
@@ -3109,6 +3109,7 @@ export const ja: TranslationResources = {
|
||||
status: "プロバイダーの状態",
|
||||
checked: "{{time}}に確認",
|
||||
diagnosticReport: "診断レポート",
|
||||
docs: "ドキュメント",
|
||||
dangerZone: "危険な操作",
|
||||
removeHint: "このプロバイダーを config.json から削除します",
|
||||
},
|
||||
@@ -3154,7 +3155,7 @@ export const ja: TranslationResources = {
|
||||
noSearchMatches: "検索に一致するモデルがありません",
|
||||
noneDetected: "モデルが検出されませんでした",
|
||||
noCustom: "カスタムモデルはありません",
|
||||
discovered: "検出済み",
|
||||
title: "モデル",
|
||||
custom: "カスタムモデル",
|
||||
updated: "{{time}}に更新",
|
||||
},
|
||||
|
||||
@@ -3094,6 +3094,7 @@ export const ko: TranslationResources = {
|
||||
status: "프로바이더 상태",
|
||||
checked: "{{time}} 확인됨",
|
||||
diagnosticReport: "진단 보고서",
|
||||
docs: "문서",
|
||||
dangerZone: "위험 구역",
|
||||
removeHint: "config.json에서 이 프로바이더를 삭제합니다",
|
||||
},
|
||||
@@ -3140,7 +3141,7 @@ export const ko: TranslationResources = {
|
||||
noSearchMatches: "검색과 일치하는 모델이 없습니다",
|
||||
noneDetected: "감지된 모델이 없습니다",
|
||||
noCustom: "사용자 지정 모델 없음",
|
||||
discovered: "발견됨",
|
||||
title: "모델",
|
||||
custom: "사용자 지정 모델",
|
||||
updated: "{{time}} 업데이트됨",
|
||||
},
|
||||
|
||||
@@ -3122,6 +3122,7 @@ export const ptBR: TranslationResources = {
|
||||
status: "Status do provedor",
|
||||
checked: "Verificado {{time}}",
|
||||
diagnosticReport: "Relatório de diagnóstico",
|
||||
docs: "Documentação",
|
||||
dangerZone: "Zona de perigo",
|
||||
removeHint: "Exclui este provedor do config.json",
|
||||
},
|
||||
@@ -3167,7 +3168,7 @@ export const ptBR: TranslationResources = {
|
||||
noSearchMatches: "Nenhum modelo corresponde à sua busca",
|
||||
noneDetected: "Nenhum modelo detectado",
|
||||
noCustom: "Nenhum modelo personalizado",
|
||||
discovered: "Descobertos",
|
||||
title: "Modelos",
|
||||
custom: "Modelos personalizados",
|
||||
updated: "Atualizado {{time}}",
|
||||
},
|
||||
|
||||
@@ -3133,6 +3133,7 @@ export const ru: TranslationResources = {
|
||||
status: "Состояние провайдера",
|
||||
checked: "Проверено {{time}}",
|
||||
diagnosticReport: "Диагностический отчёт",
|
||||
docs: "Документация",
|
||||
dangerZone: "Опасная зона",
|
||||
removeHint: "Удаляет этого провайдера из config.json",
|
||||
},
|
||||
@@ -3179,7 +3180,7 @@ export const ru: TranslationResources = {
|
||||
noSearchMatches: "Ни одна модель не соответствует вашему запросу",
|
||||
noneDetected: "Модели не обнаружены",
|
||||
noCustom: "Нет пользовательских моделей",
|
||||
discovered: "Обнаруженные модели",
|
||||
title: "Модели",
|
||||
custom: "Пользовательские модели",
|
||||
updated: "Обновлено {{time}}",
|
||||
},
|
||||
|
||||
@@ -3042,6 +3042,7 @@ export const zhCN: TranslationResources = {
|
||||
status: "Provider 状态",
|
||||
checked: "{{time}}检查",
|
||||
diagnosticReport: "诊断报告",
|
||||
docs: "文档",
|
||||
dangerZone: "危险操作",
|
||||
removeHint: "从 config.json 中删除此 Provider",
|
||||
},
|
||||
@@ -3087,7 +3088,7 @@ export const zhCN: TranslationResources = {
|
||||
noSearchMatches: "没有匹配搜索的 Model",
|
||||
noneDetected: "未检测到 Model",
|
||||
noCustom: "没有自定义模型",
|
||||
discovered: "已发现",
|
||||
title: "Models",
|
||||
custom: "自定义 Models",
|
||||
updated: "已更新 {{time}}",
|
||||
},
|
||||
|
||||
@@ -1,44 +1,53 @@
|
||||
import { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { View } from "react-native";
|
||||
import { withUnistyles } from "react-native-unistyles";
|
||||
import { SettingsDetailHeader } from "@/components/settings";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { ICON_SIZE, type Theme } from "@/styles/theme";
|
||||
import { ProviderDetail, useProviderDetail } from "./provider-detail";
|
||||
import { ProviderGlyph } from "./provider-glyph";
|
||||
|
||||
/**
|
||||
* A provider's detail as a Settings page, shaped like a project's: the screen titles it
|
||||
* "Providers", the page names the provider. On wide layouts the page has no back button of its
|
||||
* own, so it draws "Back to providers".
|
||||
* A provider's detail as a Settings page, shaped like a project's. On wide layouts the page is
|
||||
* titled "Providers > name" and "Providers" goes back. On compact layouts the screen titles it
|
||||
* "Providers" and the page names the provider.
|
||||
*/
|
||||
export function ProviderDetailPage({
|
||||
serverId,
|
||||
provider,
|
||||
onBack,
|
||||
showBack,
|
||||
}: {
|
||||
serverId: string;
|
||||
provider: string;
|
||||
onBack: () => void;
|
||||
showBack: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const detail = useProviderDetail({ serverId, provider, onRemoved: onBack });
|
||||
const back = useMemo(
|
||||
const parent = useMemo(
|
||||
() => ({
|
||||
label: t("settings.providers.detail.backToProviders"),
|
||||
label: t("settings.hostSections.providers"),
|
||||
accessibilityLabel: t("settings.providers.detail.backToProviders"),
|
||||
onPress: onBack,
|
||||
testID: "provider-detail-back",
|
||||
}),
|
||||
[onBack, t],
|
||||
);
|
||||
const icon = useMemo(
|
||||
() => <ProviderGlyph serverId={serverId} provider={provider} />,
|
||||
[provider, serverId],
|
||||
() => (
|
||||
<ThemedProviderGlyph
|
||||
serverId={serverId}
|
||||
provider={provider}
|
||||
uniProps={isCompact ? rowTitleSize : pageTitleSize}
|
||||
/>
|
||||
),
|
||||
[isCompact, provider, serverId],
|
||||
);
|
||||
return (
|
||||
<View testID="provider-detail-page">
|
||||
<SettingsDetailHeader
|
||||
back={showBack ? back : undefined}
|
||||
parent={parent}
|
||||
icon={icon}
|
||||
title={detail.label}
|
||||
titleTestID="provider-detail-title"
|
||||
@@ -47,3 +56,8 @@ export function ProviderDetailPage({
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
// The glyph is as large as the name beside it. The page title scales with the interface size.
|
||||
const ThemedProviderGlyph = withUnistyles(ProviderGlyph);
|
||||
const pageTitleSize = (theme: Theme) => ({ size: theme.fontSize["4xl"] });
|
||||
const rowTitleSize = () => ({ size: ICON_SIZE.md });
|
||||
|
||||
@@ -14,9 +14,9 @@ import { Alert } from "@/components/ui/alert";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { readAcpProviderInstallGuide } from "@/hooks/use-acp-provider-catalog";
|
||||
import { useProvidersSnapshot } from "@/hooks/use-providers-snapshot";
|
||||
import { useTimeAgo } from "@/hooks/use-time-ago";
|
||||
import { useHostRuntimeIsConnected } from "@/runtime/host-runtime";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import { openExternalUrl } from "@/utils/open-external-url";
|
||||
import {
|
||||
readDetailPresence,
|
||||
readDetailSections,
|
||||
@@ -27,6 +27,7 @@ import { DiagnosticSheet } from "./diagnostic-sheet";
|
||||
import { useProviderConfigActions, type ProviderEntry } from "./provider-config";
|
||||
import { ProviderModels } from "./provider-models";
|
||||
import { ProviderNotice } from "./provider-notice";
|
||||
import { ProviderRefreshButton, useCheckedLabel, type ProviderRefresh } from "./provider-refresh";
|
||||
|
||||
export interface ProviderDetailState {
|
||||
provider: string;
|
||||
@@ -81,6 +82,9 @@ export function useProviderDetail({
|
||||
/**
|
||||
* Everything about one provider, top to bottom: what is wrong, whether it runs, its installation,
|
||||
* its models, then the rare actions. The page and the sheet frame the same body.
|
||||
*
|
||||
* Refresh sits with the model list, which is what it is most often pressed for. A provider that
|
||||
* lists no models of its own keeps it under Troubleshooting.
|
||||
*/
|
||||
export function ProviderDetail({
|
||||
serverId,
|
||||
@@ -106,6 +110,13 @@ export function ProviderDetail({
|
||||
installGuide: readAcpProviderInstallGuide(provider),
|
||||
});
|
||||
const sections = readDetailSections(entry, shownInstallation);
|
||||
const listsModels = sections.models === "all";
|
||||
const providerRefresh: ProviderRefresh = {
|
||||
checkedAt: entry.fetchedAt,
|
||||
// The probe running again is a refresh too, whoever asked for it.
|
||||
busy: isRefreshing || installation.refreshing || entry.status === "loading",
|
||||
run: handleRefresh,
|
||||
};
|
||||
|
||||
return (
|
||||
<View testID="provider-detail">
|
||||
@@ -117,13 +128,16 @@ export function ProviderDetail({
|
||||
action={installation.action}
|
||||
/>
|
||||
{sections.models ? (
|
||||
<ProviderModels serverId={serverId} entry={entry} discovered={sections.models === "all"} />
|
||||
<ProviderModels
|
||||
serverId={serverId}
|
||||
entry={entry}
|
||||
refresh={listsModels ? providerRefresh : null}
|
||||
/>
|
||||
) : null}
|
||||
<Troubleshooting
|
||||
serverId={serverId}
|
||||
entry={entry}
|
||||
refreshing={isRefreshing || installation.refreshing}
|
||||
onRefresh={handleRefresh}
|
||||
refresh={listsModels ? null : providerRefresh}
|
||||
/>
|
||||
{/* Config no longer owns a provider whose removal has succeeded. */}
|
||||
{detail.removing || detail.canRemove(entry) ? (
|
||||
@@ -182,42 +196,39 @@ function EnabledCard({ serverId, entry }: { serverId: string; entry: ProviderEnt
|
||||
function Troubleshooting({
|
||||
serverId,
|
||||
entry,
|
||||
refreshing,
|
||||
onRefresh,
|
||||
refresh,
|
||||
}: {
|
||||
serverId: string;
|
||||
entry: ProviderEntry;
|
||||
refreshing: boolean;
|
||||
onRefresh: () => void;
|
||||
/** Null when the model list carries Refresh. */
|
||||
refresh: ProviderRefresh | null;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [diagnosticOpen, setDiagnosticOpen] = useState(false);
|
||||
const openDiagnostic = useCallback(() => setDiagnosticOpen(true), []);
|
||||
const closeDiagnostic = useCallback(() => setDiagnosticOpen(false), []);
|
||||
const checked = useTimeAgo(entry.fetchedAt ? new Date(entry.fetchedAt) : null);
|
||||
// The probe running again is a refresh too, whoever asked for it.
|
||||
const busy = refreshing || entry.status === "loading";
|
||||
const docsUrl = entry.docsUrl;
|
||||
const openDocs = useCallback(() => {
|
||||
if (docsUrl) void openExternalUrl(docsUrl);
|
||||
}, [docsUrl]);
|
||||
|
||||
return (
|
||||
<SettingsSection title={t("settings.providers.detail.troubleshooting")}>
|
||||
<SettingsCard>
|
||||
<SettingsRow
|
||||
label={t("settings.providers.detail.status")}
|
||||
hint={
|
||||
entry.fetchedAt ? t("settings.providers.detail.checked", { time: checked }) : undefined
|
||||
}
|
||||
>
|
||||
<Button variant="outline" onPress={onRefresh} loading={busy} testID="provider-refresh">
|
||||
{busy
|
||||
? t("settings.providers.diagnostic.refreshing")
|
||||
: t("settings.providers.diagnostic.refresh")}
|
||||
</Button>
|
||||
</SettingsRow>
|
||||
{refresh ? <ProviderStatusRow refresh={refresh} /> : null}
|
||||
<SettingsDetailRow
|
||||
label={t("settings.providers.detail.diagnosticReport")}
|
||||
onPress={openDiagnostic}
|
||||
testID="provider-diagnostic-report"
|
||||
/>
|
||||
{docsUrl ? (
|
||||
<SettingsDetailRow
|
||||
label={t("settings.providers.detail.docs")}
|
||||
onPress={openDocs}
|
||||
external
|
||||
testID="provider-docs"
|
||||
/>
|
||||
) : null}
|
||||
</SettingsCard>
|
||||
<DiagnosticSheet
|
||||
serverId={serverId}
|
||||
@@ -229,6 +240,16 @@ function Troubleshooting({
|
||||
);
|
||||
}
|
||||
|
||||
function ProviderStatusRow({ refresh }: { refresh: ProviderRefresh }) {
|
||||
const { t } = useTranslation();
|
||||
const checked = useCheckedLabel(refresh);
|
||||
return (
|
||||
<SettingsRow label={t("settings.providers.detail.status")} hint={checked}>
|
||||
<ProviderRefreshButton refresh={refresh} form="labelled" />
|
||||
</SettingsRow>
|
||||
);
|
||||
}
|
||||
|
||||
function DangerZone({ removing, onRemove }: { removing: boolean; onRemove: () => void }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
|
||||
@@ -2,10 +2,18 @@ import { StyleSheet } from "react-native-unistyles";
|
||||
import { useProviderIcon } from "@/components/provider-icons";
|
||||
import { ICON_SIZE } from "@/styles/theme";
|
||||
|
||||
/** A provider's icon at row size, drawn in the foreground colour. */
|
||||
export function ProviderGlyph({ serverId, provider }: { serverId: string; provider: string }) {
|
||||
/** A provider's icon in the foreground colour, at row size unless the caller names another. */
|
||||
export function ProviderGlyph({
|
||||
serverId,
|
||||
provider,
|
||||
size = ICON_SIZE.md,
|
||||
}: {
|
||||
serverId: string;
|
||||
provider: string;
|
||||
size?: number;
|
||||
}) {
|
||||
const Icon = useProviderIcon(provider, serverId);
|
||||
return <Icon size={ICON_SIZE.md} color={styles.glyph.color} />;
|
||||
return <Icon size={size} color={styles.glyph.color} />;
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Plus, Trash2 } from "lucide-react-native";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Text, View } from "react-native";
|
||||
import { ScrollView, Text, View } from "react-native";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import type { AgentModelDefinition } from "@getpaseo/protocol/agent-types";
|
||||
import type { ProviderProfileModel } from "@getpaseo/protocol/provider-config";
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
type ProviderDiscoveredModelsCache,
|
||||
} from "./discovered-models";
|
||||
import type { ProviderEntry } from "./provider-config";
|
||||
import { ProviderRefreshButton, useCheckedLabel, type ProviderRefresh } from "./provider-refresh";
|
||||
|
||||
const ThemedTrash = withUnistyles(Trash2);
|
||||
const destructiveColorMapping = (theme: Theme) => ({ color: theme.colors.destructive });
|
||||
@@ -51,15 +52,19 @@ function rankModels<T>(items: T[], query: string, fields: (item: T) => string[])
|
||||
export function ProviderModels({
|
||||
serverId,
|
||||
entry,
|
||||
discovered,
|
||||
refresh,
|
||||
}: {
|
||||
serverId: string;
|
||||
entry: ProviderEntry;
|
||||
/** List the models the provider reports, with search. Only a running provider reports them. */
|
||||
discovered: boolean;
|
||||
/**
|
||||
* Lists the models the provider reports, with search and the way to ask for them again. Null for
|
||||
* a provider that is not running, which reports none.
|
||||
*/
|
||||
refresh: ProviderRefresh | null;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const provider = entry.provider;
|
||||
const discovered = refresh !== null;
|
||||
const { config, patchConfig } = useDaemonConfig(serverId);
|
||||
const [query, setQuery] = useState("");
|
||||
const [addSheetOpen, setAddSheetOpen] = useState(false);
|
||||
@@ -130,10 +135,8 @@ export function ProviderModels({
|
||||
|
||||
const discoveredTrailing = useMemo(
|
||||
() =>
|
||||
discoveredModels.length > 0 ? (
|
||||
<Text style={settingsStyles.sectionHeaderTitle}>{discoveredModels.length}</Text>
|
||||
) : null,
|
||||
[discoveredModels.length],
|
||||
refresh ? <DiscoveredTrailing count={discoveredModels.length} refresh={refresh} /> : null,
|
||||
[discoveredModels.length, refresh],
|
||||
);
|
||||
|
||||
let discoveredBody: React.ReactNode;
|
||||
@@ -173,23 +176,29 @@ export function ProviderModels({
|
||||
return (
|
||||
<View testID="provider-models">
|
||||
{discovered ? (
|
||||
<>
|
||||
<View style={styles.searchRail}>
|
||||
<SettingsSection title={t("settings.providers.models.title")} trailing={discoveredTrailing}>
|
||||
<View style={styles.searchRow}>
|
||||
<SearchField
|
||||
value={query}
|
||||
onChangeText={setQuery}
|
||||
placeholder={t("settings.providers.models.searchPlaceholder")}
|
||||
clearAccessibilityLabel={t("sessions.actions.clearSearch")}
|
||||
fullWidth
|
||||
testID="provider-settings-search"
|
||||
/>
|
||||
</View>
|
||||
<SettingsSection
|
||||
title={t("settings.providers.models.discovered")}
|
||||
trailing={discoveredTrailing}
|
||||
>
|
||||
<View style={settingsStyles.card}>{discoveredBody}</View>
|
||||
</SettingsSection>
|
||||
</>
|
||||
<View style={settingsStyles.card}>
|
||||
{/* A provider can report hundreds of models; the rest of the page stays in reach. */}
|
||||
<ScrollView
|
||||
style={styles.discoveredList}
|
||||
// Android scrolls a ScrollView nested in the page or the sheet only with this flag.
|
||||
nestedScrollEnabled
|
||||
testID="provider-discovered-models"
|
||||
>
|
||||
{discoveredBody}
|
||||
</ScrollView>
|
||||
</View>
|
||||
</SettingsSection>
|
||||
) : null}
|
||||
<SettingsSection title={t("settings.providers.models.custom")} trailing={customTrailing}>
|
||||
<View style={settingsStyles.card}>{customBody}</View>
|
||||
@@ -205,6 +214,22 @@ export function ProviderModels({
|
||||
);
|
||||
}
|
||||
|
||||
/** How many models the provider reports, when it last reported them, and the way to ask again. */
|
||||
function DiscoveredTrailing({ count, refresh }: { count: number; refresh: ProviderRefresh }) {
|
||||
const checked = useCheckedLabel(refresh);
|
||||
const facts = [count > 0 ? String(count) : null, checked].filter(Boolean).join(" · ");
|
||||
return (
|
||||
<View style={styles.headerTrailing}>
|
||||
{facts ? (
|
||||
<Text style={[settingsStyles.sectionHeaderTitle, styles.headerFacts]} numberOfLines={1}>
|
||||
{facts}
|
||||
</Text>
|
||||
) : null}
|
||||
<ProviderRefreshButton refresh={refresh} form="icon" />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function MutedRow({ children }: { children: string }) {
|
||||
return (
|
||||
<View style={styles.modelRow}>
|
||||
@@ -367,15 +392,23 @@ function AddCustomModelSheet({
|
||||
const ADD_SNAP_POINTS = ["40%"];
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
searchRail: {
|
||||
// The search field sizes itself along a row.
|
||||
searchRow: {
|
||||
flexDirection: "row",
|
||||
marginBottom: theme.spacing[3],
|
||||
},
|
||||
// Nine rows and part of a tenth, so a longer list visibly continues.
|
||||
discoveredList: {
|
||||
maxHeight: 320,
|
||||
},
|
||||
headerTrailing: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[1],
|
||||
},
|
||||
// The facts give way before the button does.
|
||||
headerFacts: {
|
||||
flexShrink: 1,
|
||||
},
|
||||
modelRow: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import { RotateCw } from "lucide-react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useTimeAgo } from "@/hooks/use-time-ago";
|
||||
|
||||
/** Asking the provider again for its status, version and models. */
|
||||
export interface ProviderRefresh {
|
||||
/** When the provider last answered. Absent before its first answer. */
|
||||
checkedAt: string | undefined;
|
||||
/** A check is running, whoever asked for it. */
|
||||
busy: boolean;
|
||||
run: () => void;
|
||||
}
|
||||
|
||||
/** "Checked 5m ago", kept current, or nothing before the provider's first answer. */
|
||||
export function useCheckedLabel(refresh: ProviderRefresh): string | undefined {
|
||||
const { t } = useTranslation();
|
||||
const time = useTimeAgo(refresh.checkedAt ? new Date(refresh.checkedAt) : null);
|
||||
return refresh.checkedAt ? t("settings.providers.detail.checked", { time }) : undefined;
|
||||
}
|
||||
|
||||
export function ProviderRefreshButton({
|
||||
refresh,
|
||||
form,
|
||||
}: {
|
||||
refresh: ProviderRefresh;
|
||||
/** `icon` in a section header, `labelled` in a row. */
|
||||
form: "icon" | "labelled";
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const label = refresh.busy
|
||||
? t("settings.providers.diagnostic.refreshing")
|
||||
: t("settings.providers.diagnostic.refresh");
|
||||
if (form === "icon")
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
leftIcon={RotateCw}
|
||||
onPress={refresh.run}
|
||||
loading={refresh.busy}
|
||||
accessibilityLabel={label}
|
||||
testID="provider-refresh"
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<Button
|
||||
variant="outline"
|
||||
onPress={refresh.run}
|
||||
loading={refresh.busy}
|
||||
testID="provider-refresh"
|
||||
>
|
||||
{label}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -29,7 +29,9 @@ import { EditingTextInput as TextInput } from "@/components/ui/text-input";
|
||||
import { SettingsTextAreaCard } from "@/components/settings-textarea";
|
||||
import { SettingsGroup } from "@/components/settings/headings/settings-group";
|
||||
import { SettingsSection } from "@/components/settings/headings/settings-section";
|
||||
import { SettingsBackLink, SettingsDetailHeader } from "@/components/settings";
|
||||
import type { PageTitleParent } from "@/components/page-layout";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { SettingsDetailHeader } from "@/components/settings";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import { useProjects } from "@/hooks/use-projects";
|
||||
import type { ProjectEditFormSnapshot } from "@/projects/edit-form";
|
||||
@@ -95,14 +97,12 @@ export interface ProjectSettingsScreenProps {
|
||||
serverId: string;
|
||||
projectId: string;
|
||||
onBackToProjects: () => void;
|
||||
showBackToProjects: boolean;
|
||||
}
|
||||
|
||||
export default function ProjectSettingsScreen({
|
||||
serverId,
|
||||
projectId,
|
||||
onBackToProjects,
|
||||
showBackToProjects,
|
||||
}: ProjectSettingsScreenProps) {
|
||||
const { projects } = useProjects();
|
||||
const project = useMemo(
|
||||
@@ -123,12 +123,7 @@ export default function ProjectSettingsScreen({
|
||||
selectedHost.repoRoot.trim().length > 0;
|
||||
|
||||
if (!project || !selectedHost || !client || !canEdit) {
|
||||
return (
|
||||
<NoEditableTarget
|
||||
onBackToProjects={onBackToProjects}
|
||||
showBackToProjects={showBackToProjects}
|
||||
/>
|
||||
);
|
||||
return <NoProject onBackToProjects={onBackToProjects} />;
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -138,24 +133,29 @@ export default function ProjectSettingsScreen({
|
||||
client={client}
|
||||
isHostGone={isHostGone}
|
||||
onBackToProjects={onBackToProjects}
|
||||
showBackToProjects={showBackToProjects}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function NoEditableTarget({
|
||||
onBackToProjects,
|
||||
showBackToProjects,
|
||||
}: {
|
||||
onBackToProjects: () => void;
|
||||
showBackToProjects: boolean;
|
||||
}) {
|
||||
/** A project page with no project to name: the title is the way back to Projects. */
|
||||
function NoProject({ onBackToProjects }: { onBackToProjects: () => void }) {
|
||||
const parent = useProjectsParent(onBackToProjects);
|
||||
return (
|
||||
<>
|
||||
<SettingsDetailHeader parent={parent} />
|
||||
<NoEditableTarget onBackToProjects={onBackToProjects} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function NoEditableTarget({ onBackToProjects }: { onBackToProjects: () => void }) {
|
||||
const { t } = useTranslation();
|
||||
// The compact back header already goes back to Projects.
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
return (
|
||||
<View style={styles.noTargetContainer}>
|
||||
{showBackToProjects ? <BackToProjectsButton onPress={onBackToProjects} /> : null}
|
||||
<Text style={styles.noTargetText}>{t("settings.project.noEditableTarget")}</Text>
|
||||
{showBackToProjects ? (
|
||||
{isCompact ? null : (
|
||||
<Button
|
||||
testID="project-settings-back-button"
|
||||
onPress={onBackToProjects}
|
||||
@@ -163,19 +163,22 @@ function NoEditableTarget({
|
||||
>
|
||||
{t("settings.project.backToProjects")}
|
||||
</Button>
|
||||
) : null}
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function BackToProjectsButton({ onPress }: { onPress: () => void }) {
|
||||
/** Projects as the first part of a project page's title, which goes back to the list. */
|
||||
function useProjectsParent(onPress: () => void): PageTitleParent {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<SettingsBackLink
|
||||
label={t("settings.project.backToProjects")}
|
||||
onPress={onPress}
|
||||
testID="project-settings-back-link"
|
||||
/>
|
||||
return useMemo(
|
||||
() => ({
|
||||
label: t("settings.projects"),
|
||||
accessibilityLabel: t("settings.project.backToProjects"),
|
||||
onPress,
|
||||
testID: "project-settings-back-link",
|
||||
}),
|
||||
[onPress, t],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -185,7 +188,6 @@ interface ProjectSettingsBodyProps {
|
||||
client: DaemonClient;
|
||||
isHostGone: boolean;
|
||||
onBackToProjects: () => void;
|
||||
showBackToProjects: boolean;
|
||||
}
|
||||
|
||||
function ProjectSettingsBody({
|
||||
@@ -194,7 +196,6 @@ function ProjectSettingsBody({
|
||||
client,
|
||||
isHostGone,
|
||||
onBackToProjects,
|
||||
showBackToProjects,
|
||||
}: ProjectSettingsBodyProps) {
|
||||
const { t } = useTranslation();
|
||||
const [isEditSheetOpen, setIsEditSheetOpen] = useState(false);
|
||||
@@ -256,17 +257,7 @@ function ProjectSettingsBody({
|
||||
const handleReload = useCallback(() => {
|
||||
void readQuery.refetch();
|
||||
}, [readQuery]);
|
||||
const backLink = useMemo(
|
||||
() =>
|
||||
showBackToProjects
|
||||
? {
|
||||
label: t("settings.project.backToProjects"),
|
||||
onPress: onBackToProjects,
|
||||
testID: "project-settings-back-link",
|
||||
}
|
||||
: undefined,
|
||||
[onBackToProjects, showBackToProjects, t],
|
||||
);
|
||||
const parent = useProjectsParent(onBackToProjects);
|
||||
const titleIcon = useMemo(
|
||||
() => (
|
||||
<ProjectTitleIcon
|
||||
@@ -294,9 +285,9 @@ function ProjectSettingsBody({
|
||||
);
|
||||
|
||||
return (
|
||||
<View role="main" style={styles.body}>
|
||||
<View role="main">
|
||||
<SettingsDetailHeader
|
||||
back={backLink}
|
||||
parent={parent}
|
||||
icon={titleIcon}
|
||||
title={selectedHost.projectName}
|
||||
trailing={editButton}
|
||||
@@ -327,7 +318,6 @@ function ProjectSettingsBody({
|
||||
onReload: handleReload,
|
||||
isHostGone,
|
||||
onBackToProjects,
|
||||
showBackToProjects,
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
@@ -345,7 +335,6 @@ interface RenderContentInput {
|
||||
onReload: () => void;
|
||||
isHostGone: boolean;
|
||||
onBackToProjects: () => void;
|
||||
showBackToProjects: boolean;
|
||||
}
|
||||
|
||||
function renderContent({
|
||||
@@ -360,7 +349,6 @@ function renderContent({
|
||||
onReload,
|
||||
isHostGone,
|
||||
onBackToProjects,
|
||||
showBackToProjects,
|
||||
}: RenderContentInput) {
|
||||
if (readQuery.isLoading) {
|
||||
return (
|
||||
@@ -379,12 +367,7 @@ function renderContent({
|
||||
}
|
||||
|
||||
if (isHostGone) {
|
||||
return (
|
||||
<NoEditableTarget
|
||||
onBackToProjects={onBackToProjects}
|
||||
showBackToProjects={showBackToProjects}
|
||||
/>
|
||||
);
|
||||
return <NoEditableTarget onBackToProjects={onBackToProjects} />;
|
||||
}
|
||||
|
||||
if (!loadedConfig) {
|
||||
@@ -1118,10 +1101,6 @@ const styles = StyleSheet.create((theme) => ({
|
||||
color: theme.colors.foregroundMuted,
|
||||
fontSize: theme.fontSize.base,
|
||||
},
|
||||
body: {
|
||||
padding: theme.spacing[4],
|
||||
gap: theme.spacing[2],
|
||||
},
|
||||
editButton: {
|
||||
padding: theme.spacing[1],
|
||||
},
|
||||
|
||||
@@ -1335,7 +1335,6 @@ export default function SettingsScreen({ view }: SettingsScreenProps) {
|
||||
serverId={view.serverId}
|
||||
projectId={view.projectId}
|
||||
onBackToProjects={handleBackFromDetail}
|
||||
showBackToProjects={!isCompactLayout}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1345,7 +1344,6 @@ export default function SettingsScreen({ view }: SettingsScreenProps) {
|
||||
serverId={view.serverId}
|
||||
provider={view.providerId}
|
||||
onBack={handleBackFromDetail}
|
||||
showBack={!isCompactLayout}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1450,7 +1448,8 @@ export default function SettingsScreen({ view }: SettingsScreenProps) {
|
||||
<WindowChromeRegion corners="top-right">
|
||||
<View style={desktopStyles.contentPane} testID="settings-detail-pane">
|
||||
<PageLayout
|
||||
title={detailTitle}
|
||||
// A project or provider page draws its own title, which names the list it came from.
|
||||
title={view.kind === "project" || view.kind === "provider" ? undefined : detailTitle}
|
||||
actions={detailActions}
|
||||
width={detailWidth}
|
||||
titleTestID="settings-detail-header-title"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { mapLayout, SWITCH_HEIGHT } from "@/components/ui/control-geometry";
|
||||
|
||||
export const settingsStyles = StyleSheet.create((theme) => ({
|
||||
section: {
|
||||
@@ -34,6 +35,8 @@ export const settingsStyles = StyleSheet.create((theme) => ({
|
||||
justifyContent: "space-between",
|
||||
paddingVertical: theme.spacing[4],
|
||||
paddingHorizontal: theme.spacing[4],
|
||||
// As tall as a row holding a switch, so rows with and without one line up.
|
||||
minHeight: mapLayout(SWITCH_HEIGHT, (height) => height + theme.spacing[4] * 2),
|
||||
},
|
||||
rowBorder: {
|
||||
borderTopWidth: 1,
|
||||
|
||||
@@ -39,6 +39,8 @@ export interface ProviderRegistration {
|
||||
description?: string;
|
||||
/** Plugin-directory-relative path to a self-contained SVG file. */
|
||||
icon?: string;
|
||||
/** http(s) page that helps users set up and troubleshoot the provider. Paseo opens it. */
|
||||
docsUrl?: string;
|
||||
/** How users install the provider's CLI and which version they run. Every member is optional. */
|
||||
installation?: ProviderInstallation;
|
||||
connect(request: ProviderConnectRequest): Promise<ProviderConnection>;
|
||||
|
||||
@@ -133,6 +133,8 @@ export interface ProviderSnapshotEntry {
|
||||
label?: string;
|
||||
description?: string;
|
||||
iconSvg?: string;
|
||||
/** The page that helps users set up and troubleshoot this provider. */
|
||||
docsUrl?: string;
|
||||
defaultModeId?: string | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -429,6 +429,7 @@ export const ProviderSnapshotEntrySchema = z.object({
|
||||
label: z.string().optional(),
|
||||
description: z.string().optional(),
|
||||
iconSvg: z.string().optional(),
|
||||
docsUrl: z.string().optional(),
|
||||
defaultModeId: z.string().nullable().optional(),
|
||||
});
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ export interface AgentProviderDefinition {
|
||||
id: string;
|
||||
label: string;
|
||||
description: string;
|
||||
/** The page that helps users set up and troubleshoot this provider. */
|
||||
docsUrl?: string;
|
||||
enabledByDefault?: boolean;
|
||||
defaultModeId: string | null;
|
||||
modes: AgentProviderModeDefinition[];
|
||||
@@ -199,6 +201,7 @@ export const AGENT_PROVIDER_DEFINITIONS: AgentProviderDefinition[] = [
|
||||
id: "claude",
|
||||
label: "Claude",
|
||||
description: "Anthropic's multi-tool assistant with MCP support, streaming, and deep reasoning",
|
||||
docsUrl: "https://paseo.sh/docs/supported-providers/claude-code",
|
||||
defaultModeId: "auto",
|
||||
modes: CLAUDE_MODES,
|
||||
voice: {
|
||||
@@ -211,6 +214,7 @@ export const AGENT_PROVIDER_DEFINITIONS: AgentProviderDefinition[] = [
|
||||
id: "codex",
|
||||
label: "Codex",
|
||||
description: "OpenAI's Codex workspace agent with sandbox controls and optional network access",
|
||||
docsUrl: "https://paseo.sh/docs/supported-providers/codex",
|
||||
defaultModeId: "auto-review",
|
||||
modes: CODEX_MODES,
|
||||
voice: {
|
||||
@@ -223,6 +227,7 @@ export const AGENT_PROVIDER_DEFINITIONS: AgentProviderDefinition[] = [
|
||||
id: "copilot",
|
||||
label: "Copilot",
|
||||
description: "GitHub Copilot via Agent Client Protocol with dynamic modes and session support",
|
||||
docsUrl: "https://paseo.sh/docs/supported-providers/github-copilot",
|
||||
defaultModeId: "https://agentclientprotocol.com/protocol/session-modes#agent",
|
||||
modes: COPILOT_MODES,
|
||||
},
|
||||
@@ -230,6 +235,7 @@ export const AGENT_PROVIDER_DEFINITIONS: AgentProviderDefinition[] = [
|
||||
id: "opencode",
|
||||
label: "OpenCode",
|
||||
description: "Open-source coding assistant with multi-provider model support",
|
||||
docsUrl: "https://paseo.sh/docs/supported-providers/opencode",
|
||||
// No static default: OpenCode users can rename or delete any agent,
|
||||
// including "build". Leaving this unset means the daemon and OpenCode
|
||||
// itself decide (see normalizeOpenCodeModeId in opencode-agent.ts).
|
||||
@@ -244,6 +250,7 @@ export const AGENT_PROVIDER_DEFINITIONS: AgentProviderDefinition[] = [
|
||||
id: "pi",
|
||||
label: "Pi",
|
||||
description: "Minimal terminal-based coding agent with multi-provider LLM support",
|
||||
docsUrl: "https://paseo.sh/docs/supported-providers/pi",
|
||||
defaultModeId: null,
|
||||
modes: [],
|
||||
},
|
||||
@@ -251,6 +258,7 @@ export const AGENT_PROVIDER_DEFINITIONS: AgentProviderDefinition[] = [
|
||||
id: "omp",
|
||||
label: "Oh My Pi",
|
||||
description: "Multi-provider coding agent with native approvals, host tools, and subagents",
|
||||
docsUrl: "https://paseo.sh/docs/supported-providers/omp",
|
||||
enabledByDefault: false,
|
||||
defaultModeId: "full",
|
||||
modes: OMP_MODES,
|
||||
|
||||
@@ -9,7 +9,7 @@ import type {
|
||||
ToolPolicy,
|
||||
} from "@getpaseo/protocol/agent-types";
|
||||
import type { AgentMessage } from "@getpaseo/protocol/agent-message";
|
||||
import type { AgentAttachment } from "@getpaseo/protocol/messages";
|
||||
import type { AgentAttachment, ProviderInstallationInspection } from "@getpaseo/protocol/messages";
|
||||
import type {
|
||||
ProviderInspection,
|
||||
ProviderUpdateCheck,
|
||||
@@ -142,6 +142,8 @@ export interface ProviderSnapshotEntry {
|
||||
label?: string;
|
||||
description?: string;
|
||||
iconSvg?: string;
|
||||
/** The page that helps users set up and troubleshoot this provider. */
|
||||
docsUrl?: string;
|
||||
defaultModeId?: string | null;
|
||||
}
|
||||
|
||||
@@ -851,6 +853,15 @@ export interface AgentClientUpdateContext extends AgentClientInstallationContext
|
||||
report(event: ProviderUpdateReport): void;
|
||||
}
|
||||
|
||||
/** What the daemon gives a provider's diagnostic report. */
|
||||
export interface AgentClientDiagnosticContext {
|
||||
/**
|
||||
* The installation as the provider's Installation row shows it, under the same deadline and
|
||||
* cache. Undefined when the provider does not report its installation.
|
||||
*/
|
||||
inspectInstallation(): Promise<ProviderInstallationInspection | undefined>;
|
||||
}
|
||||
|
||||
export interface AgentClient {
|
||||
resolveUsageLaunch?(): Promise<
|
||||
import("@getpaseo/plugin/server/provider").ProviderLaunch | undefined
|
||||
@@ -916,7 +927,7 @@ export interface AgentClient {
|
||||
* Returns true if available, false otherwise.
|
||||
*/
|
||||
isAvailable(signal?: AbortSignal, options?: FetchCatalogOptions): Promise<boolean>;
|
||||
getDiagnostic?(): Promise<{ diagnostic: string }>;
|
||||
getDiagnostic?(context: AgentClientDiagnosticContext): Promise<{ diagnostic: string }>;
|
||||
/**
|
||||
* Installation links and the installed version. The same contract as plugin providers'
|
||||
* `ProviderRegistration.installation`; built-ins resolve their own launch inside `inspect`.
|
||||
|
||||
@@ -2498,6 +2498,9 @@ describe("pending provider responses", () => {
|
||||
);
|
||||
});
|
||||
|
||||
/** A diagnostic context for a provider that does not report its installation. */
|
||||
const NO_INSTALLATION = { inspectInstallation: async () => undefined };
|
||||
|
||||
describe("plugin provider launch and status", () => {
|
||||
test("resolves the executable against the provider's PATH override", async () => {
|
||||
const harness = createProviderHarness();
|
||||
@@ -2509,7 +2512,13 @@ describe("plugin provider launch and status", () => {
|
||||
const definition = registry.definitions()[registration.id]!;
|
||||
const client = definition.createClient(logger, { env: { PATH: "/paseo-nonexistent-bin" } });
|
||||
expect(await client.isAvailable()).toBe(false);
|
||||
expect(await client.getDiagnostic!()).toEqual({ diagnostic: "node not found on PATH" });
|
||||
const report = (await client.getDiagnostic!(NO_INSTALLATION)).diagnostic.split("\n");
|
||||
expect(report[0]).toBe("Plugin direct");
|
||||
expect(report).toContain(" Daemon PATH: /paseo-nonexistent-bin");
|
||||
expect(report.slice(-2)).toEqual([
|
||||
" Resolved path: not found",
|
||||
" Error: node not found on PATH",
|
||||
]);
|
||||
} finally {
|
||||
await registry.shutdown();
|
||||
}
|
||||
@@ -2589,6 +2598,51 @@ describe("plugin provider launch and status", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("the diagnostic reports the launch, the version and the provider's own rows", async () => {
|
||||
const harness = createProviderHarness();
|
||||
const registration: ProviderRegistration = {
|
||||
...harness.registration,
|
||||
command: [process.execPath, "agent"],
|
||||
async status() {
|
||||
return { available: true, diagnostic: "Sign-in: work account\nPlan: Pro" };
|
||||
},
|
||||
};
|
||||
const registry = new PluginAgentClientRegistry(createTestLogger());
|
||||
registry.replace([registration]);
|
||||
try {
|
||||
const client = registry.clients()[registration.id]!;
|
||||
const { diagnostic } = await client.getDiagnostic!({
|
||||
inspectInstallation: async () => ({ status: "installed", version: "1.2.3" }),
|
||||
});
|
||||
// The daemon's PATH and shell rows depend on the host; the formatter's own tests cover them.
|
||||
const hostRows = /^ {2}Daemon (PATH|shell): /;
|
||||
expect(diagnostic.split("\n").filter((row) => !hostRows.test(row))).toEqual([
|
||||
"Plugin direct",
|
||||
" Command source: default",
|
||||
` Configured command: ${process.execPath} agent`,
|
||||
" PATH matches: not checked",
|
||||
` Resolved path: ${process.execPath}`,
|
||||
" Version: 1.2.3",
|
||||
" Sign-in: work account",
|
||||
" Plan: Pro",
|
||||
]);
|
||||
} finally {
|
||||
await registry.shutdown();
|
||||
}
|
||||
});
|
||||
|
||||
test("a provider without a command reports only its own rows", async () => {
|
||||
const harness = createProviderHarness();
|
||||
const registry = new PluginAgentClientRegistry(createTestLogger());
|
||||
registry.replace([harness.registration]);
|
||||
try {
|
||||
const client = registry.clients()[harness.registration.id]!;
|
||||
expect(await client.getDiagnostic!(NO_INSTALLATION)).toEqual({ diagnostic: "Plugin direct" });
|
||||
} finally {
|
||||
await registry.shutdown();
|
||||
}
|
||||
});
|
||||
|
||||
test("a missing executable is unavailable with a diagnostic without connecting", async () => {
|
||||
const harness = createProviderHarness();
|
||||
const registration: ProviderRegistration = {
|
||||
@@ -2600,9 +2654,13 @@ describe("plugin provider launch and status", () => {
|
||||
try {
|
||||
const client = registry.clients()[registration.id]!;
|
||||
expect(await client.isAvailable()).toBe(false);
|
||||
expect(await client.getDiagnostic!()).toEqual({
|
||||
diagnostic: "paseo-nonexistent-provider-executable not found on PATH",
|
||||
});
|
||||
const report = (await client.getDiagnostic!(NO_INSTALLATION)).diagnostic.split("\n");
|
||||
expect(report).toContain(" Configured command: paseo-nonexistent-provider-executable");
|
||||
expect(report).toContain(" PATH matches: none");
|
||||
expect(report.slice(-2)).toEqual([
|
||||
" Resolved path: not found",
|
||||
" Error: paseo-nonexistent-provider-executable not found on PATH",
|
||||
]);
|
||||
expect(harness.inputs).toEqual([]);
|
||||
} finally {
|
||||
await registry.shutdown();
|
||||
|
||||
@@ -4,6 +4,7 @@ import { PluginSessionHistory } from "./plugin-session-history.js";
|
||||
import { resolve as resolvePath } from "node:path";
|
||||
import type { Logger } from "pino";
|
||||
import type { JsonValue, ProviderOptions } from "@getpaseo/protocol/agent-types";
|
||||
import type { ProviderInstallationInspection } from "@getpaseo/protocol/messages";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
PROVIDER_CAPABILITIES,
|
||||
@@ -65,6 +66,7 @@ import type {
|
||||
ProviderRefreshContext,
|
||||
SteerActiveTurnOptions,
|
||||
SteerResult,
|
||||
AgentClientDiagnosticContext,
|
||||
} from "./agent-sdk-types.js";
|
||||
import {
|
||||
resolveProviderLaunch,
|
||||
@@ -73,6 +75,11 @@ import {
|
||||
type ProviderRuntimeSettings,
|
||||
} from "./provider-launch-config.js";
|
||||
import { readPluginOptionState } from "./plugin-provider-options.js";
|
||||
import {
|
||||
buildCommandResolutionDiagnosticRows,
|
||||
formatProviderDiagnostic,
|
||||
type DiagnosticEntry,
|
||||
} from "./providers/diagnostic-utils.js";
|
||||
import type { RegisteredProviderDefinition } from "./provider-registry.js";
|
||||
import { runProviderTurn } from "./providers/provider-runner.js";
|
||||
import { StaleProviderSessionError } from "./stale-provider-session-error.js";
|
||||
@@ -136,6 +143,12 @@ function isProviderRequestReply(
|
||||
);
|
||||
}
|
||||
|
||||
function describeVersion(inspection: ProviderInstallationInspection): string {
|
||||
if (inspection.status === "not_installed") return "not installed";
|
||||
if (inspection.status === "error") return `error: ${inspection.message}`;
|
||||
return inspection.version?.trim() || "unknown";
|
||||
}
|
||||
|
||||
class ProviderRuntime {
|
||||
private connection: ProviderConnection | null = null;
|
||||
connectedLaunch: ProviderLaunch | undefined;
|
||||
@@ -165,8 +178,8 @@ class ProviderRuntime {
|
||||
private readonly runtimeSettings?: ProviderRuntimeSettings,
|
||||
) {}
|
||||
|
||||
/** The effective launch, including when its executable does not resolve. */
|
||||
private async resolveEffectiveLaunch(): Promise<ProviderInstallationLaunch | undefined> {
|
||||
/** The launch after overrides, and where its executable resolves. */
|
||||
private async resolveConfiguredLaunch() {
|
||||
const command = this.registration.command;
|
||||
if (!command) return undefined;
|
||||
const launch = await resolveProviderLaunch({
|
||||
@@ -176,7 +189,14 @@ class ProviderRuntime {
|
||||
if (launch.source !== "override") launch.args.unshift(...command.slice(1));
|
||||
const env = createProviderEnv({ runtimeSettings: this.runtimeSettings });
|
||||
launch.env = env;
|
||||
const availability = await checkProviderLaunchAvailable(launch);
|
||||
return { launch, env, availability: await checkProviderLaunchAvailable(launch) };
|
||||
}
|
||||
|
||||
/** The effective launch, including when its executable does not resolve. */
|
||||
private async resolveEffectiveLaunch(): Promise<ProviderInstallationLaunch | undefined> {
|
||||
const configured = await this.resolveConfiguredLaunch();
|
||||
if (!configured) return undefined;
|
||||
const { launch, env, availability } = configured;
|
||||
if (!availability.resolvedPath)
|
||||
return { command: launch.command, args: launch.args, env, resolved: false };
|
||||
return {
|
||||
@@ -224,6 +244,24 @@ class ProviderRuntime {
|
||||
return await update.call(this.registration.installation, { ...context, launch });
|
||||
}
|
||||
|
||||
/** What the daemon launches, where it found the executable and which version it runs. */
|
||||
async launchDiagnosticRows(context: AgentClientDiagnosticContext): Promise<DiagnosticEntry[]> {
|
||||
const configured = await this.resolveConfiguredLaunch();
|
||||
if (!configured) return [];
|
||||
const { launch, env, availability } = configured;
|
||||
const rows = [
|
||||
...(await buildCommandResolutionDiagnosticRows(launch, {
|
||||
knownBinaryNames: [launch.command],
|
||||
pathValue: env.PATH,
|
||||
})),
|
||||
{ label: "Resolved path", value: availability.resolvedPath ?? "not found" },
|
||||
];
|
||||
if (!availability.resolvedPath) return rows;
|
||||
const inspection = await context.inspectInstallation();
|
||||
if (inspection) rows.push({ label: "Version", value: describeVersion(inspection) });
|
||||
return rows;
|
||||
}
|
||||
|
||||
async status(): Promise<ProviderStatus> {
|
||||
try {
|
||||
const launch = await this.resolveLaunch();
|
||||
@@ -1000,6 +1038,7 @@ function createPluginProviderDefinition(
|
||||
label: registration.label,
|
||||
description: registration.description ?? `Plugin provider ${registration.label}`,
|
||||
iconSvg: registration.icon,
|
||||
docsUrl: registration.docsUrl,
|
||||
requiresConfiguration: registration.requiresConfiguration,
|
||||
defaultModeId: null,
|
||||
modes: [],
|
||||
@@ -1015,6 +1054,7 @@ interface PendingChild {
|
||||
|
||||
class PluginAgentClient implements AgentClient {
|
||||
readonly provider: string;
|
||||
private readonly label: string;
|
||||
private readonly runtime: ProviderRuntime;
|
||||
private readonly rootsBySession = new Map<string, PluginAgentSession>();
|
||||
private readonly pendingChildren: PendingChild[] = [];
|
||||
@@ -1024,6 +1064,7 @@ class PluginAgentClient implements AgentClient {
|
||||
|
||||
constructor(registration: ProviderRegistration, runtimeSettings?: ProviderRuntimeSettings) {
|
||||
this.provider = registration.id;
|
||||
this.label = registration.label;
|
||||
this.runtime = new ProviderRuntime(registration, runtimeSettings);
|
||||
if (registration.getCatalogCacheKey)
|
||||
this.getCatalogCacheKey = (options) => this.runtime.catalogCacheKey(options);
|
||||
@@ -1109,9 +1150,20 @@ class PluginAgentClient implements AgentClient {
|
||||
return await this.runtime.isAvailable();
|
||||
}
|
||||
|
||||
async getDiagnostic(): Promise<{ diagnostic: string }> {
|
||||
const status = await this.runtime.status();
|
||||
return { diagnostic: status.diagnostic ?? "Provider is available" };
|
||||
async getDiagnostic(context: AgentClientDiagnosticContext): Promise<{ diagnostic: string }> {
|
||||
const [rows, status] = await Promise.all([
|
||||
this.runtime.launchDiagnosticRows(context),
|
||||
this.runtime.status(),
|
||||
]);
|
||||
const report = [formatProviderDiagnostic(this.label, rows)];
|
||||
if (!status.available) report.push(` Error: ${status.diagnostic}`);
|
||||
// An available provider adds its own rows, one per line.
|
||||
else if (status.diagnostic) {
|
||||
for (const line of status.diagnostic.split("\n")) {
|
||||
if (line.trim()) report.push(` ${line.trim()}`);
|
||||
}
|
||||
}
|
||||
return { diagnostic: report.join("\n") };
|
||||
}
|
||||
|
||||
async listImportableSessions(
|
||||
|
||||
@@ -217,12 +217,14 @@ describe("ProviderSnapshotManager public surface", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("carries a plugin provider icon in snapshot metadata", () => {
|
||||
test("carries a plugin provider icon and docs link in snapshot metadata", () => {
|
||||
const iconSvg = '<svg viewBox="0 0 24 24"><path d="M4 4h16v16H4z" /></svg>';
|
||||
const docsUrl = "https://example.com/docs";
|
||||
const registration: ProviderRegistration = {
|
||||
id: "icon-provider",
|
||||
label: "Icon Provider",
|
||||
icon: iconSvg,
|
||||
docsUrl,
|
||||
async connect() {
|
||||
throw new Error("not opened by this test");
|
||||
},
|
||||
@@ -233,7 +235,13 @@ describe("ProviderSnapshotManager public surface", () => {
|
||||
manager.replacePluginProviders([registration]);
|
||||
|
||||
expect(manager.getSnapshot("/tmp/project").records.map(({ entry }) => entry)).toContainEqual(
|
||||
expect.objectContaining({ provider: "icon-provider", iconSvg }),
|
||||
expect.objectContaining({ provider: "icon-provider", iconSvg, docsUrl }),
|
||||
);
|
||||
expect(manager.getSnapshot("/tmp/project").records.map(({ entry }) => entry)).toContainEqual(
|
||||
expect.objectContaining({
|
||||
provider: "claude",
|
||||
docsUrl: "https://paseo.sh/docs/supported-providers/claude-code",
|
||||
}),
|
||||
);
|
||||
} finally {
|
||||
manager.destroy();
|
||||
@@ -1038,6 +1046,40 @@ describe("ProviderSnapshotManager public surface", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("getProviderDiagnostic gives the client the installation that the Installation row shows", async () => {
|
||||
let inspections = 0;
|
||||
const client = createExtraClient("codex", {
|
||||
installation: {
|
||||
async inspect() {
|
||||
inspections += 1;
|
||||
return { status: "installed", version: `1.0.${inspections}` };
|
||||
},
|
||||
},
|
||||
async getDiagnostic(context) {
|
||||
const inspection = await context.inspectInstallation();
|
||||
return {
|
||||
diagnostic: `codex ${inspection?.status === "installed" ? inspection.version : "?"}`,
|
||||
};
|
||||
},
|
||||
});
|
||||
const manager = new ProviderSnapshotManager({
|
||||
logger: createTestLogger(),
|
||||
extraClients: { codex: client },
|
||||
});
|
||||
try {
|
||||
const { diagnostic } = await manager.getProviderDiagnostic("codex");
|
||||
expect(diagnostic).toContain("codex 1.0.1");
|
||||
// The report refreshed the installation, so the Installation row reads the same answer.
|
||||
expect((await manager.installations.inspect("codex"))?.inspection).toEqual({
|
||||
status: "installed",
|
||||
version: "1.0.1",
|
||||
});
|
||||
expect(inspections).toBe(1);
|
||||
} finally {
|
||||
manager.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
test("getProviderDiagnostic force-refreshes the snapshot and appends models/status", async () => {
|
||||
const catalogModels: AgentModelDefinition[] = [
|
||||
{ provider: "codex", id: "gpt-5.4-mini", label: "GPT 5.4 Mini" },
|
||||
|
||||
@@ -907,7 +907,11 @@ export class ProviderSnapshotManager {
|
||||
if (client.getDiagnostic) {
|
||||
return (
|
||||
await withTimeout(
|
||||
client.getDiagnostic(),
|
||||
client.getDiagnostic({
|
||||
// The report and the Installation row show one answer for the version.
|
||||
inspectInstallation: async () =>
|
||||
(await this.installations.inspect(provider, { refresh: true }))?.inspection,
|
||||
}),
|
||||
this.diagnosticTimeoutMs,
|
||||
`Timed out collecting ${definition.label ?? provider} diagnostic after ${
|
||||
this.diagnosticTimeoutMs
|
||||
@@ -952,6 +956,7 @@ export class ProviderSnapshotManager {
|
||||
label: definition.label,
|
||||
description: definition.description,
|
||||
iconSvg: definition.iconSvg,
|
||||
docsUrl: definition.docsUrl,
|
||||
defaultModeId: definition.defaultModeId ?? null,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -434,6 +434,7 @@ describe("PluginService", () => {
|
||||
"provider-installation",
|
||||
`export default function contribute(server) {
|
||||
server.registerProvider({ id: "plugin-agent", label: "Plugin agent", command: ["agent"],
|
||||
docsUrl: "https://example.com/docs",
|
||||
installation: {
|
||||
installUrl: "https://example.com/install",
|
||||
updateUrl: "https://example.com/update",
|
||||
@@ -472,6 +473,7 @@ describe("PluginService", () => {
|
||||
try {
|
||||
if (runtime === "subprocess") await service.installDirectory({ path: directory });
|
||||
const [registration] = service.getProviderRegistrations();
|
||||
expect(registration!.docsUrl).toBe("https://example.com/docs");
|
||||
const installation = registration!.installation!;
|
||||
expect(installation).toMatchObject({
|
||||
installUrl: "https://example.com/install",
|
||||
@@ -554,6 +556,33 @@ describe("PluginService", () => {
|
||||
expect(await provider.getCatalogCacheKey!({ scope: "global" })).toBeUndefined();
|
||||
});
|
||||
|
||||
it("fails a plugin whose provider docs link is not an http(s) page", async () => {
|
||||
const home = await mkdtemp(path.join(tmpdir(), "paseo-plugin-home-"));
|
||||
roots.push(home);
|
||||
const directory = await createPlugin(
|
||||
"provider-docs-link",
|
||||
`export default function contribute(server) {
|
||||
server.registerProvider({
|
||||
id: "plugin-agent",
|
||||
label: "Plugin agent",
|
||||
docsUrl: "file:///etc/passwd",
|
||||
async connect() { throw new Error("not opened by this test"); },
|
||||
});
|
||||
return () => {};
|
||||
}`,
|
||||
);
|
||||
const service = createService(home);
|
||||
|
||||
await service.start();
|
||||
await service.installDirectory({ path: directory }).catch(() => undefined);
|
||||
|
||||
expect(service.getProviderRegistrations()).toEqual([]);
|
||||
expect(await service.listPlugins()).toMatchObject([
|
||||
{ status: "failed", error: "Plugin provider plugin-agent docsUrl must be an http(s) URL" },
|
||||
]);
|
||||
await service.stopAllPlugins();
|
||||
});
|
||||
|
||||
it("publishes provider registrations only while their plugin is running", async () => {
|
||||
const home = await mkdtemp(path.join(tmpdir(), "paseo-plugin-home-"));
|
||||
roots.push(home);
|
||||
|
||||
@@ -773,6 +773,7 @@ export class PluginService {
|
||||
id: provider.id,
|
||||
label: provider.label,
|
||||
description: provider.description,
|
||||
docsUrl: provider.docsUrl,
|
||||
command: provider.command,
|
||||
requiresConfiguration: provider.requiresConfiguration,
|
||||
status: provider.hasStatus
|
||||
|
||||
@@ -28,6 +28,7 @@ export interface PluginProviderMetadata {
|
||||
label: string;
|
||||
description?: string;
|
||||
iconPath?: string;
|
||||
docsUrl?: string;
|
||||
}
|
||||
|
||||
export interface PluginProviderInstallationMetadata {
|
||||
@@ -176,6 +177,7 @@ const providerMetadataSchema = z
|
||||
label: z.string().min(1),
|
||||
description: z.string().optional(),
|
||||
iconPath: z.string().optional(),
|
||||
docsUrl: z.string().optional(),
|
||||
requiresConfiguration: z.boolean().optional(),
|
||||
hasCatalogCacheKey: z.boolean().optional(),
|
||||
hasStatus: z.boolean().optional(),
|
||||
|
||||
@@ -207,6 +207,11 @@ export function createPluginWorker(options: {
|
||||
}
|
||||
if (provider.status !== undefined && typeof provider.status !== "function")
|
||||
throw new Error(`Invalid status callback for plugin provider ${id}`);
|
||||
if (
|
||||
provider.docsUrl !== undefined &&
|
||||
(typeof provider.docsUrl !== "string" || !isHttpUrl(provider.docsUrl))
|
||||
)
|
||||
throw new Error(`Plugin provider ${id} docsUrl must be an http(s) URL`);
|
||||
validateProviderInstallation(id, provider.installation);
|
||||
if (
|
||||
provider.command !== undefined &&
|
||||
@@ -270,6 +275,7 @@ export function createPluginWorker(options: {
|
||||
label: provider.label,
|
||||
description: provider.description,
|
||||
iconPath: provider.icon,
|
||||
docsUrl: provider.docsUrl,
|
||||
requiresConfiguration: provider.requiresConfiguration,
|
||||
hasCatalogCacheKey: provider.getCatalogCacheKey !== undefined,
|
||||
hasStatus: provider.status !== undefined,
|
||||
|
||||
@@ -39,6 +39,50 @@ it("reports a CLI without the acp subcommand as unavailable", async () => {
|
||||
});
|
||||
});
|
||||
|
||||
const minimalAcpAgent = `
|
||||
const { createInterface } = require("node:readline");
|
||||
createInterface({ input: process.stdin }).on("line", (line) => {
|
||||
const { id, method } = JSON.parse(line);
|
||||
if (method === "initialize")
|
||||
process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id, result: { protocolVersion: 1, agentCapabilities: {} } }) + "\\n");
|
||||
});
|
||||
`;
|
||||
|
||||
describe("diagnostic", () => {
|
||||
it("says agy runs outside an SSH session when the daemon has no SSH variables", async () => {
|
||||
const { launch } = await launchAgent(minimalAcpAgent);
|
||||
expect(await createAntigravityProvider().status!({ launch })).toEqual({
|
||||
available: true,
|
||||
diagnostic: "SSH session: no\nSign-in: can differ from agy over SSH",
|
||||
});
|
||||
});
|
||||
|
||||
it.each(["SSH_CONNECTION", "SSH_CLIENT", "SSH_TTY"])(
|
||||
"says agy runs in an SSH session when the daemon has %s",
|
||||
async (variable) => {
|
||||
const { launch } = await launchAgent(minimalAcpAgent);
|
||||
const env = { ...launch.env, [variable]: "set" };
|
||||
expect(await createAntigravityProvider().status!({ launch: { ...launch, env } })).toEqual({
|
||||
available: true,
|
||||
diagnostic: `SSH session: yes (${variable})\nSign-in: can differ from agy outside SSH`,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it("says whether agy runs in an SSH session when ACP does not start", async () => {
|
||||
const { launch } = await launchAgent(`process.exit(1);`);
|
||||
const env = { ...launch.env, SSH_CONNECTION: "set" };
|
||||
expect(await createAntigravityProvider().status!({ launch: { ...launch, env } })).toEqual({
|
||||
available: false,
|
||||
diagnostic: [
|
||||
"Antigravity ACP did not start. Install Antigravity 1.5.0 or later. If you override the command, include the acp subcommand.",
|
||||
"SSH session: yes (SSH_CONNECTION)",
|
||||
"Sign-in: can differ from agy outside SSH",
|
||||
].join("\n"),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("publishes Antigravity skills separately from built-in commands", async () => {
|
||||
const { directory, launch } = await launchAgent(`
|
||||
const { createInterface } = require("node:readline");
|
||||
@@ -154,7 +198,7 @@ it.each([true, false])(
|
||||
});
|
||||
`);
|
||||
const provider = createAntigravityProvider();
|
||||
expect(await provider.status!({ launch })).toEqual({ available: true });
|
||||
expect(await provider.status!({ launch })).toMatchObject({ available: true });
|
||||
const connection = await provider.connect({
|
||||
launch,
|
||||
versions: [1],
|
||||
|
||||
@@ -86,6 +86,21 @@ async function readAgyVersion(
|
||||
return /\b\d+\.\d+\.\d+\S*/.exec(stdout)?.[0] ?? (firstLine || undefined);
|
||||
}
|
||||
|
||||
// agy 1.5.14 reads its sign-in from a token file when any of these is set, and from the OS keyring
|
||||
// otherwise. https://github.com/google-antigravity/antigravity-cli/issues/1336
|
||||
const sshSessionVariables = ["SSH_CONNECTION", "SSH_CLIENT", "SSH_TTY"];
|
||||
|
||||
/**
|
||||
* Report rows that say whether agy runs in an SSH session, because that decides which sign-in it
|
||||
* uses. The report does not wrap, so each row stays short enough to read without scrolling.
|
||||
*/
|
||||
function describeSignIn(env: Readonly<Record<string, string>>): string {
|
||||
const variable = sshSessionVariables.find((name) => env[name]);
|
||||
return variable
|
||||
? `SSH session: yes (${variable})\nSign-in: can differ from agy outside SSH`
|
||||
: "SSH session: no\nSign-in: can differ from agy over SSH";
|
||||
}
|
||||
|
||||
export function createAntigravityProvider(): ProviderRegistration {
|
||||
const provider = runAcpProvider({
|
||||
id: "antigravity",
|
||||
@@ -127,6 +142,7 @@ export function createAntigravityProvider(): ProviderRegistration {
|
||||
});
|
||||
return {
|
||||
...provider,
|
||||
docsUrl: "https://paseo.sh/docs/supported-providers/antigravity#troubleshooting",
|
||||
// agy documents no update command and no release source, so there is nothing to check or run.
|
||||
installation: {
|
||||
installUrl: "https://antigravity.google/docs/getting-started?tab=cli",
|
||||
@@ -138,6 +154,8 @@ export function createAntigravityProvider(): ProviderRegistration {
|
||||
},
|
||||
async status({ launch }) {
|
||||
if (!launch) return { available: false, diagnostic: "Install Antigravity 1.5.0 or later." };
|
||||
// A sign-in problem can stop ACP from starting, so the report says which sign-in either way.
|
||||
const signIn = describeSignIn(launch.env);
|
||||
try {
|
||||
const connection = await provider.connect({
|
||||
launch,
|
||||
@@ -145,12 +163,11 @@ export function createAntigravityProvider(): ProviderRegistration {
|
||||
capabilities: [],
|
||||
});
|
||||
await connection.close();
|
||||
return { available: true };
|
||||
return { available: true, diagnostic: signIn };
|
||||
} catch {
|
||||
return {
|
||||
available: false,
|
||||
diagnostic:
|
||||
"Antigravity ACP did not start. Install Antigravity 1.5.0 or later. If you override the command, include the acp subcommand.",
|
||||
diagnostic: `Antigravity ACP did not start. Install Antigravity 1.5.0 or later. If you override the command, include the acp subcommand.\n${signIn}`,
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
@@ -13,5 +13,6 @@ export function createFxProvider(): ProviderRegistration {
|
||||
command: ["fx", "acp"],
|
||||
transformers: [fileToolTransformer],
|
||||
}),
|
||||
docsUrl: "https://paseo.sh/docs/supported-providers/fx",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ export function createHopliteProvider(): ProviderRegistration {
|
||||
acpOptions: { workspaceOnlyCatalog: true },
|
||||
transformers: [runPhaseTransformer],
|
||||
}),
|
||||
docsUrl: "https://paseo.sh/docs/supported-providers/hoplite",
|
||||
installation: createHopliteInstallation(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ export function createMuseProvider(
|
||||
label: "Muse Code",
|
||||
icon: "icon.svg",
|
||||
command: ["muse"],
|
||||
docsUrl: "https://paseo.sh/docs/supported-providers/muse-code",
|
||||
installation: {
|
||||
installUrl: "https://paseo.sh/docs/muse-code",
|
||||
async inspect({ launch, signal }) {
|
||||
|
||||
@@ -548,6 +548,37 @@ version, so a CLI updated outside Paseo is checked again once the inspection exp
|
||||
`update` has no deadline. `signal` aborts when Paseo stops waiting or the daemon stops.
|
||||
See the [`installation` reference](/docs/plugins/reference#provider-installation) for every field.
|
||||
|
||||
## Help users fix problems
|
||||
|
||||
A user who gets a wrong result opens the provider's settings before they ask for help. Give that
|
||||
page what they need: declare `docsUrl`, and return the facts that explain a wrong result from
|
||||
`status`.
|
||||
|
||||
```ts
|
||||
export function createProvider(): ProviderRegistration {
|
||||
return {
|
||||
id: "example-agent",
|
||||
label: "Example Agent",
|
||||
command: ["example-agent"],
|
||||
docsUrl: "https://example.com/docs/paseo#troubleshooting",
|
||||
async status({ launch }) {
|
||||
if (!launch) return { available: false, diagnostic: "example-agent has no command" };
|
||||
return { available: true, diagnostic: `Profile: ${launch.env.EXAMPLE_PROFILE ?? "default"}` };
|
||||
},
|
||||
async connect(request) {
|
||||
// ...
|
||||
},
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
**Docs** opens `docsUrl`. **Diagnostic report** shows the command, the path of the executable and
|
||||
the version that Paseo found, then your `Profile` row. Report what the CLI reads from its
|
||||
environment, such as the account, the profile, or the configuration file in use. Those differ
|
||||
between the daemon and the user's terminal, and the user cannot see them from the app.
|
||||
See the [troubleshooting reference](/docs/plugins/reference#provider-troubleshooting) for the rows
|
||||
that Paseo writes and for the rules of `status`.
|
||||
|
||||
## Adapt an ACP agent
|
||||
|
||||
Use the ACP shim when the agent already speaks ACP:
|
||||
|
||||
@@ -449,6 +449,30 @@ Paseo 把版本当作文本。它按原样显示 `version` 和 `versions`,从
|
||||
|
||||
Paseo 在设置打开时调用 `inspect`,并把结果保留 30 秒。只要 `inspect` 报告的版本不变,它就把 `checkForUpdates` 的 `current` 或 `available` 结果保留一小时,所以在 Paseo 之外更新的 CLI 会在 `inspect` 的结果过期后重新检查。`inspect` 必须在 20 秒内回答,`checkForUpdates` 必须在 25 秒内回答。`update` 没有期限。当 Paseo 停止等待或 daemon 停止时,`signal` 会中止。每个字段见 [`installation` 参考](/docs/plugins/reference#provider-installation)。
|
||||
|
||||
## 帮助用户解决问题 {#help-users-fix-problems}
|
||||
|
||||
用户得到错误结果时,会先打开 Provider 的设置,然后才去寻求帮助。请在这个页面提供他们需要的内容:声明 `docsUrl`,并从 `status` 返回能解释错误结果的事实。
|
||||
|
||||
```ts
|
||||
export function createProvider(): ProviderRegistration {
|
||||
return {
|
||||
id: "example-agent",
|
||||
label: "Example Agent",
|
||||
command: ["example-agent"],
|
||||
docsUrl: "https://example.com/docs/paseo#troubleshooting",
|
||||
async status({ launch }) {
|
||||
if (!launch) return { available: false, diagnostic: "example-agent has no command" };
|
||||
return { available: true, diagnostic: `Profile: ${launch.env.EXAMPLE_PROFILE ?? "default"}` };
|
||||
},
|
||||
async connect(request) {
|
||||
// ...
|
||||
},
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
**文档** 会打开 `docsUrl`。**诊断报告** 会显示命令、可执行文件的路径和 Paseo 找到的版本,然后是你的 `Profile` 行。请报告 CLI 从环境中读取的内容,例如账号、profile 或正在使用的配置文件。这些内容在 daemon 和用户的终端之间可能不同,用户在应用中也看不到。Paseo 写入的各行以及 `status` 的规则见[故障排查参考](/docs/plugins/reference#provider-troubleshooting)。
|
||||
|
||||
## 适配 ACP Agent {#adapt-an-acp-agent}
|
||||
|
||||
当 Agent 已经支持 ACP 时,使用 ACP 适配层:
|
||||
|
||||
@@ -518,6 +518,44 @@ shapes is an error. **Update** appears once `inspect` reports the CLI installed
|
||||
`update`, whatever `checkForUpdates` answers and whether you declare it; without `update`, Paseo
|
||||
offers `updateUrl` on the same terms.
|
||||
|
||||
#### Provider troubleshooting
|
||||
|
||||
**Requires Paseo 0.18.** Older versions ignore `docsUrl` and show only the `diagnostic` text.
|
||||
The provider's settings have a **Troubleshooting** section with a **Diagnostic report** and
|
||||
**Docs**. Users copy the report into a bug report, so put the facts
|
||||
that explain a wrong result into it.
|
||||
|
||||
`ProviderRegistration.docsUrl` is the `http` or `https` page that **Docs** opens. Point it at the
|
||||
page that says how to set up the provider and how to fix its common problems. The plugin fails to
|
||||
start when it is another kind of URL. Paseo hides **Docs** when you declare none.
|
||||
|
||||
The report is your provider's `label` and one `Label: value` row per line. Paseo writes these rows:
|
||||
|
||||
| Row | Shown |
|
||||
| -------------------------------------------------------------- | ---------------------------------------------------------------------- |
|
||||
| `Command source`, `Configured command` | When you declare `command` |
|
||||
| `Daemon PATH`, `Daemon shell`, `PATH matches`, `Resolved path` | When you declare `command` |
|
||||
| `Version` | When Paseo found the executable and you declare `installation.inspect` |
|
||||
| `Models`, `Status` | Always |
|
||||
|
||||
`status(request)` adds your rows after them. `request.launch` is the launch a session would use.
|
||||
|
||||
```ts
|
||||
async status({ launch }) {
|
||||
if (!launch) return { available: false, diagnostic: "example-agent has no command" };
|
||||
const profile = launch.env.EXAMPLE_PROFILE ?? "default";
|
||||
return { available: true, diagnostic: `Profile: ${profile}\nSign-in: ${signInSource(launch.env)}` };
|
||||
}
|
||||
```
|
||||
|
||||
| Answer | Result |
|
||||
| ---------------------------------- | ------------------------------------------------------------------------------ |
|
||||
| `{ available: true, diagnostic? }` | Each line of `diagnostic` is one row. Write each line as `Label: value`. |
|
||||
| `{ available: false, diagnostic }` | The provider is unavailable. The report shows `diagnostic` in the `Error` row. |
|
||||
|
||||
Paseo calls `status` each time it checks whether the provider is available, not only for the
|
||||
report. The report does not wrap lines, so write short rows.
|
||||
|
||||
### Usage sources
|
||||
|
||||
**Requires Paseo 0.11.** Register a source from your server entry with
|
||||
|
||||
@@ -422,6 +422,38 @@ Provider 设置中的 **刷新** 会跳过保留的结果,并清除失败的
|
||||
|
||||
Paseo 按原样显示 `version`、`versions` 和 `message`,不解析或排序它们。只要 `inspect` 报告的 `version` 不变,Paseo 会在最长一小时内复用 `current` 或 `available` 的结果。它保留 `report` 输出的最后 65,536 个字符。不符合这些结构的结果是错误。只要 `inspect` 报告 CLI 已安装且你声明了 `update`,就会出现 **更新**,与 `checkForUpdates` 的回答以及是否声明它无关;没有 `update` 时,Paseo 在同样条件下提供 `updateUrl`。
|
||||
|
||||
#### Provider 故障排查 {#provider-troubleshooting}
|
||||
|
||||
**需要 Paseo 0.18**。较旧的版本会忽略 `docsUrl`,并且只显示 `diagnostic` 文本。Provider 设置中有一个 **故障排查** 部分,其中包含 **诊断报告** 和 **文档**。用户会把报告复制到问题反馈中,所以请把能解释错误结果的事实写进报告。
|
||||
|
||||
`ProviderRegistration.docsUrl` 是 **文档** 打开的 `http` 或 `https` 页面。请让它指向说明如何设置该 Provider 以及如何解决常见问题的页面。它是其他类型的 URL 时,插件会启动失败。没有声明时,Paseo 会隐藏 **文档**。
|
||||
|
||||
报告由 Provider 的 `label` 和若干行组成,每行是一个 `Label: value`。Paseo 会写入以下各行:
|
||||
|
||||
| 行 | 显示条件 |
|
||||
| -------------------------------------------------------------- | --------------------------------------------------------- |
|
||||
| `Command source`、`Configured command` | 声明了 `command` |
|
||||
| `Daemon PATH`、`Daemon shell`、`PATH matches`、`Resolved path` | 声明了 `command` |
|
||||
| `Version` | Paseo 找到了可执行文件,且你声明了 `installation.inspect` |
|
||||
| `Models`、`Status` | 始终显示 |
|
||||
|
||||
`status(request)` 会在这些行之后添加你的行。`request.launch` 是会话将使用的启动配置。
|
||||
|
||||
```ts
|
||||
async status({ launch }) {
|
||||
if (!launch) return { available: false, diagnostic: "example-agent has no command" };
|
||||
const profile = launch.env.EXAMPLE_PROFILE ?? "default";
|
||||
return { available: true, diagnostic: `Profile: ${profile}\nSign-in: ${signInSource(launch.env)}` };
|
||||
}
|
||||
```
|
||||
|
||||
| 结果 | 效果 |
|
||||
| ---------------------------------- | ---------------------------------------------------------------- |
|
||||
| `{ available: true, diagnostic? }` | `diagnostic` 的每一行是报告中的一行。每行请写成 `Label: value`。 |
|
||||
| `{ available: false, diagnostic }` | Provider 不可用。报告在 `Error` 行中显示 `diagnostic`。 |
|
||||
|
||||
Paseo 每次检查 Provider 是否可用时都会调用 `status`,不只是在生成报告时。报告不会自动换行,所以每一行请写得简短。
|
||||
|
||||
### 用量来源 {#usage-sources}
|
||||
|
||||
**需要 Paseo 0.11**。在服务端入口中用 `server.registerUsageSource()` 注册一个来源。从 `@getpaseo/plugin/server/usage` 导入它的契约和辅助函数。
|
||||
|
||||
@@ -46,3 +46,52 @@ Finish or stop the current turn before you switch to or from **Full access**.
|
||||
Paseo can import CLI sessions and restore conversation history when it reopens a chat. Antigravity publishes slash commands and accepts image attachments through ACP. It also receives the MCP servers configured for the agent.
|
||||
|
||||
Send a follow-up after the current turn finishes, or interrupt the turn to change direction.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
In Paseo, open **Settings → Providers → Antigravity** and select **Diagnostic report**. The report shows the command that Paseo runs, where the daemon found `agy`, the `agy` version, the number of models, and whether `agy` runs in an SSH session.
|
||||
|
||||
### New models are missing
|
||||
|
||||
Paseo reads the model list from `agy` when the daemon starts and when you select **Refresh**. If your account gets new models after that, open **Settings → Providers → Antigravity** and select **Refresh**.
|
||||
|
||||
### Paseo shows different models than `agy models`
|
||||
|
||||
`agy` keeps two sign-ins on one machine. In an SSH session, `agy` reads its sign-in from a token file. Outside an SSH session, `agy` reads its sign-in from the keyring of the operating system. If the two sign-ins use different Google accounts, your terminal and Paseo show different models. [Antigravity CLI issue 1336](https://github.com/google-antigravity/antigravity-cli/issues/1336) tracks this behavior.
|
||||
|
||||
Paseo runs `agy` with the environment of the daemon. A daemon that you started from an SSH session runs `agy` in an SSH session. A daemon that a desktop session or a service manager started runs `agy` outside one. The `SSH session` row of the diagnostic report shows which one applies.
|
||||
|
||||
If the row shows `SSH session: no`, do these steps in a terminal on the daemon host:
|
||||
|
||||
1. List the models of the sign-in that Paseo uses:
|
||||
|
||||
```bash
|
||||
env -u SSH_CONNECTION -u SSH_CLIENT -u SSH_TTY agy models
|
||||
```
|
||||
|
||||
2. If the list is not the one you expect, start `agy` with the same sign-in:
|
||||
|
||||
```bash
|
||||
env -u SSH_CONNECTION -u SSH_CLIENT -u SSH_TTY agy
|
||||
```
|
||||
|
||||
3. Run `/logout`, then sign in with the account that has your plan.
|
||||
4. In Paseo, open **Settings → Providers → Antigravity** and select **Refresh**.
|
||||
|
||||
If the row shows `SSH session: yes`, do the same steps in a terminal that is not an SSH session. Use `SSH_CONNECTION=1 agy models` in step 1 and `SSH_CONNECTION=1 agy` in step 2.
|
||||
|
||||
To keep both sign-ins and make Paseo use the one from your SSH terminal, set an SSH variable for the provider in `~/.paseo/config.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"agents": {
|
||||
"providers": {
|
||||
"antigravity": {
|
||||
"env": { "SSH_CONNECTION": "paseo" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Run `paseo reload`, then select **Refresh**. The row then shows `SSH session: yes (SSH_CONNECTION)`.
|
||||
|
||||
@@ -44,3 +44,52 @@ Paseo 连接到 `agy acp`,并显示 CLI 提供的权限模式。在 **Default*
|
||||
Paseo 可以导入 CLI 会话,并在重新打开聊天时恢复对话历史。Antigravity 通过 ACP 提供斜杠命令、接收图片附件,也会使用为 Agent 配置的 MCP 服务器。
|
||||
|
||||
你可以在当前轮次结束后发送后续消息,也可以中断当前轮次来改变方向。
|
||||
|
||||
## 故障排查 {#troubleshooting}
|
||||
|
||||
在 Paseo 中打开 **设置 → Providers → Antigravity** 并选择 **诊断报告**。报告会显示 Paseo 运行的命令、daemon 找到 `agy` 的位置、`agy` 的版本、模型数量,以及 `agy` 是否在 SSH 会话中运行。
|
||||
|
||||
### 缺少新模型 {#new-models-are-missing}
|
||||
|
||||
Paseo 在 daemon 启动时和你选择 **刷新** 时从 `agy` 读取模型列表。如果你的账号在此之后获得了新模型,请打开 **设置 → Providers → Antigravity** 并选择 **刷新**。
|
||||
|
||||
### Paseo 显示的模型与 `agy models` 不同 {#paseo-shows-different-models-than-agy-models}
|
||||
|
||||
`agy` 在同一台机器上保存两份登录状态。在 SSH 会话中,`agy` 从 token 文件读取登录状态。在 SSH 会话之外,`agy` 从操作系统的密钥环读取登录状态。如果两份登录状态使用不同的 Google 账号,你的终端和 Paseo 会显示不同的模型。[Antigravity CLI issue 1336](https://github.com/google-antigravity/antigravity-cli/issues/1336) 跟踪此行为。
|
||||
|
||||
Paseo 使用 daemon 的环境运行 `agy`。从 SSH 会话启动的 daemon 会在 SSH 会话中运行 `agy`。由桌面会话或服务管理器启动的 daemon 会在 SSH 会话之外运行 `agy`。诊断报告中的 `SSH session` 行会显示当前属于哪种情况。
|
||||
|
||||
如果该行显示 `SSH session: no`,请在 daemon 主机的终端中执行以下步骤:
|
||||
|
||||
1. 列出 Paseo 所用登录状态下的模型:
|
||||
|
||||
```bash
|
||||
env -u SSH_CONNECTION -u SSH_CLIENT -u SSH_TTY agy models
|
||||
```
|
||||
|
||||
2. 如果列表与预期不符,请用同一份登录状态启动 `agy`:
|
||||
|
||||
```bash
|
||||
env -u SSH_CONNECTION -u SSH_CLIENT -u SSH_TTY agy
|
||||
```
|
||||
|
||||
3. 运行 `/logout`,然后用拥有你的订阅计划的账号登录。
|
||||
4. 在 Paseo 中打开 **设置 → Providers → Antigravity** 并选择 **刷新**。
|
||||
|
||||
如果该行显示 `SSH session: yes`,请在非 SSH 会话的终端中执行相同步骤。第 1 步使用 `SSH_CONNECTION=1 agy models`,第 2 步使用 `SSH_CONNECTION=1 agy`。
|
||||
|
||||
如果想保留两份登录状态,并让 Paseo 使用 SSH 终端的那一份,请在 `~/.paseo/config.json` 中为该 Provider 设置一个 SSH 变量:
|
||||
|
||||
```json
|
||||
{
|
||||
"agents": {
|
||||
"providers": {
|
||||
"antigravity": {
|
||||
"env": { "SSH_CONNECTION": "paseo" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
运行 `paseo reload`,然后选择 **刷新**。之后该行会显示 `SSH session: yes (SSH_CONNECTION)`。
|
||||
|
||||
Reference in New Issue
Block a user