diff --git a/docs/design.md b/docs/design.md index 58b914107..ba9c6b41c 100644 --- a/docs/design.md +++ b/docs/design.md @@ -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. `` 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 `` (`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. `` 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 `` (`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 `` wrapping a `` is a sixth variant. It is wrong. ` + + @@ -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", () => { diff --git a/packages/app/src/components/settings/row-density.tsx b/packages/app/src/components/settings/row-density.tsx index 8e6b05a3e..25c360591 100644 --- a/packages/app/src/components/settings/row-density.tsx +++ b/packages/app/src/components/settings/row-density.tsx @@ -27,11 +27,6 @@ export function MenuSettingsRows({ children }: { children: ReactNode }) { export interface SettingsRowLayout { row: StyleProp; - /** - * 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; title: StyleProp; hint: StyleProp; /** 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: { diff --git a/packages/app/src/components/settings/row-header.tsx b/packages/app/src/components/settings/row-header.tsx index 0b3730b93..617a30980 100644 --- a/packages/app/src/components/settings/row-header.tsx +++ b/packages/app/src/components/settings/row-header.tsx @@ -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], diff --git a/packages/app/src/components/ui/control-geometry.test.ts b/packages/app/src/components/ui/control-geometry.test.ts index ad439d19c..773789df8 100644 --- a/packages/app/src/components/ui/control-geometry.test.ts +++ b/packages/app/src/components/ui/control-geometry.test.ts @@ -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, }); }); diff --git a/packages/app/src/components/ui/control-geometry.ts b/packages/app/src/components/ui/control-geometry.ts index bec7819b7..db29007f5 100644 --- a/packages/app/src/components/ui/control-geometry.ts +++ b/packages/app/src/components/ui/control-geometry.ts @@ -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 { diff --git a/packages/app/src/components/ui/search-field.tsx b/packages/app/src/components/ui/search-field.tsx index 77daed289..792149b33 100644 --- a/packages/app/src/components/ui/search-field.tsx +++ b/packages/app/src/components/ui/search-field.tsx @@ -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 ( - + ({ borderWidth: theme.borderWidth[1], borderColor: theme.colors.border, }, + fieldFullWidth: { + maxWidth: "100%", + }, fieldFocused: { borderColor: theme.colors.borderAccent, backgroundColor: theme.colors.surface2, diff --git a/packages/app/src/components/ui/switch.tsx b/packages/app/src/components/ui/switch.tsx index 618eae8c1..df10ba394 100644 --- a/packages/app/src/components/ui/switch.tsx +++ b/packages/app/src/components/ui/switch.tsx @@ -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 ( diff --git a/packages/app/src/i18n/resources/ar.ts b/packages/app/src/i18n/resources/ar.ts index 1826f63ba..4a69fb552 100644 --- a/packages/app/src/i18n/resources/ar.ts +++ b/packages/app/src/i18n/resources/ar.ts @@ -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}}", }, diff --git a/packages/app/src/i18n/resources/en.ts b/packages/app/src/i18n/resources/en.ts index 951e36271..ffe12ce3c 100644 --- a/packages/app/src/i18n/resources/en.ts +++ b/packages/app/src/i18n/resources/en.ts @@ -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}}", }, diff --git a/packages/app/src/i18n/resources/es.ts b/packages/app/src/i18n/resources/es.ts index e99bdfb17..776caccc7 100644 --- a/packages/app/src/i18n/resources/es.ts +++ b/packages/app/src/i18n/resources/es.ts @@ -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", }, diff --git a/packages/app/src/i18n/resources/fr.ts b/packages/app/src/i18n/resources/fr.ts index 981cfa72e..1f64d24ba 100644 --- a/packages/app/src/i18n/resources/fr.ts +++ b/packages/app/src/i18n/resources/fr.ts @@ -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}}", }, diff --git a/packages/app/src/i18n/resources/ja.ts b/packages/app/src/i18n/resources/ja.ts index 76d95f094..0954e01e6 100644 --- a/packages/app/src/i18n/resources/ja.ts +++ b/packages/app/src/i18n/resources/ja.ts @@ -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}}に更新", }, diff --git a/packages/app/src/i18n/resources/ko.ts b/packages/app/src/i18n/resources/ko.ts index b7bad0f67..238a174fc 100644 --- a/packages/app/src/i18n/resources/ko.ts +++ b/packages/app/src/i18n/resources/ko.ts @@ -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}} 업데이트됨", }, diff --git a/packages/app/src/i18n/resources/pt-BR.ts b/packages/app/src/i18n/resources/pt-BR.ts index 62d408baf..10cd5b0ba 100644 --- a/packages/app/src/i18n/resources/pt-BR.ts +++ b/packages/app/src/i18n/resources/pt-BR.ts @@ -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}}", }, diff --git a/packages/app/src/i18n/resources/ru.ts b/packages/app/src/i18n/resources/ru.ts index 4185c2d48..7c964d486 100644 --- a/packages/app/src/i18n/resources/ru.ts +++ b/packages/app/src/i18n/resources/ru.ts @@ -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}}", }, diff --git a/packages/app/src/i18n/resources/zh-CN.ts b/packages/app/src/i18n/resources/zh-CN.ts index e1ba06b09..463ecc110 100644 --- a/packages/app/src/i18n/resources/zh-CN.ts +++ b/packages/app/src/i18n/resources/zh-CN.ts @@ -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}}", }, diff --git a/packages/app/src/provider-settings/internal/provider-detail-page.tsx b/packages/app/src/provider-settings/internal/provider-detail-page.tsx index f5ae12f28..c5cde3313 100644 --- a/packages/app/src/provider-settings/internal/provider-detail-page.tsx +++ b/packages/app/src/provider-settings/internal/provider-detail-page.tsx @@ -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( - () => , - [provider, serverId], + () => ( + + ), + [isCompact, provider, serverId], ); return ( ); } + +// 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 }); diff --git a/packages/app/src/provider-settings/internal/provider-detail.tsx b/packages/app/src/provider-settings/internal/provider-detail.tsx index d5c641b7e..d4b583d7e 100644 --- a/packages/app/src/provider-settings/internal/provider-detail.tsx +++ b/packages/app/src/provider-settings/internal/provider-detail.tsx @@ -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 ( @@ -117,13 +128,16 @@ export function ProviderDetail({ action={installation.action} /> {sections.models ? ( - + ) : null} {/* 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 ( - - - + {refresh ? : null} + {docsUrl ? ( + + ) : null} + + + ); +} + function DangerZone({ removing, onRemove }: { removing: boolean; onRemove: () => void }) { const { t } = useTranslation(); return ( diff --git a/packages/app/src/provider-settings/internal/provider-glyph.tsx b/packages/app/src/provider-settings/internal/provider-glyph.tsx index af298e29a..92bfe99eb 100644 --- a/packages/app/src/provider-settings/internal/provider-glyph.tsx +++ b/packages/app/src/provider-settings/internal/provider-glyph.tsx @@ -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 ; + return ; } const styles = StyleSheet.create((theme) => ({ diff --git a/packages/app/src/provider-settings/internal/provider-models.tsx b/packages/app/src/provider-settings/internal/provider-models.tsx index 51acc71e5..641d8220e 100644 --- a/packages/app/src/provider-settings/internal/provider-models.tsx +++ b/packages/app/src/provider-settings/internal/provider-models.tsx @@ -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(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 ? ( - {discoveredModels.length} - ) : null, - [discoveredModels.length], + refresh ? : null, + [discoveredModels.length, refresh], ); let discoveredBody: React.ReactNode; @@ -173,23 +176,29 @@ export function ProviderModels({ return ( {discovered ? ( - <> - + + - - {discoveredBody} - - + + {/* A provider can report hundreds of models; the rest of the page stays in reach. */} + + {discoveredBody} + + + ) : null} {customBody} @@ -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 ( + + {facts ? ( + + {facts} + + ) : null} + + + ); +} + function MutedRow({ children }: { children: string }) { return ( @@ -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", diff --git a/packages/app/src/provider-settings/internal/provider-refresh.tsx b/packages/app/src/provider-settings/internal/provider-refresh.tsx new file mode 100644 index 000000000..44dfc6981 --- /dev/null +++ b/packages/app/src/provider-settings/internal/provider-refresh.tsx @@ -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 ( + + ); +} diff --git a/packages/app/src/screens/project-settings-screen.tsx b/packages/app/src/screens/project-settings-screen.tsx index d278a21bc..762f2f7a4 100644 --- a/packages/app/src/screens/project-settings-screen.tsx +++ b/packages/app/src/screens/project-settings-screen.tsx @@ -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 ( - - ); + return ; } 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 ( + <> + + + + ); +} + +function NoEditableTarget({ onBackToProjects }: { onBackToProjects: () => void }) { const { t } = useTranslation(); + // The compact back header already goes back to Projects. + const isCompact = useIsCompactFormFactor(); return ( - {showBackToProjects ? : null} {t("settings.project.noEditableTarget")} - {showBackToProjects ? ( + {isCompact ? null : ( - ) : null} + )} ); } -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 ( - + 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( () => ( + ); @@ -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 ( - - ); + return ; } 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], }, diff --git a/packages/app/src/screens/settings-screen.tsx b/packages/app/src/screens/settings-screen.tsx index b1966dc04..0288d8270 100644 --- a/packages/app/src/screens/settings-screen.tsx +++ b/packages/app/src/screens/settings-screen.tsx @@ -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) { ({ 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, diff --git a/packages/plugin/src/server/provider.ts b/packages/plugin/src/server/provider.ts index c40c982e0..47a710c3c 100644 --- a/packages/plugin/src/server/provider.ts +++ b/packages/plugin/src/server/provider.ts @@ -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; diff --git a/packages/protocol/src/agent-types.ts b/packages/protocol/src/agent-types.ts index efbd119c3..a30066562 100644 --- a/packages/protocol/src/agent-types.ts +++ b/packages/protocol/src/agent-types.ts @@ -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; } diff --git a/packages/protocol/src/messages.ts b/packages/protocol/src/messages.ts index e8b9142c4..af8c18a47 100644 --- a/packages/protocol/src/messages.ts +++ b/packages/protocol/src/messages.ts @@ -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(), }); diff --git a/packages/protocol/src/provider-manifest.ts b/packages/protocol/src/provider-manifest.ts index 82d097836..0d7076f0b 100644 --- a/packages/protocol/src/provider-manifest.ts +++ b/packages/protocol/src/provider-manifest.ts @@ -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, diff --git a/packages/server/src/server/agent/agent-sdk-types.ts b/packages/server/src/server/agent/agent-sdk-types.ts index f950b4317..0f7c32c01 100644 --- a/packages/server/src/server/agent/agent-sdk-types.ts +++ b/packages/server/src/server/agent/agent-sdk-types.ts @@ -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; +} + 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; - 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`. diff --git a/packages/server/src/server/agent/plugin-provider.test.ts b/packages/server/src/server/agent/plugin-provider.test.ts index 4b2b35231..c7f7e2b58 100644 --- a/packages/server/src/server/agent/plugin-provider.test.ts +++ b/packages/server/src/server/agent/plugin-provider.test.ts @@ -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(); diff --git a/packages/server/src/server/agent/plugin-provider.ts b/packages/server/src/server/agent/plugin-provider.ts index c09e4d149..71d2e2dd4 100644 --- a/packages/server/src/server/agent/plugin-provider.ts +++ b/packages/server/src/server/agent/plugin-provider.ts @@ -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 { + /** 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 { + 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 { + 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 { 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(); 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( diff --git a/packages/server/src/server/agent/provider-snapshot-manager.test.ts b/packages/server/src/server/agent/provider-snapshot-manager.test.ts index f1bbbc796..73da100d4 100644 --- a/packages/server/src/server/agent/provider-snapshot-manager.test.ts +++ b/packages/server/src/server/agent/provider-snapshot-manager.test.ts @@ -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 = ''; + 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" }, diff --git a/packages/server/src/server/agent/provider-snapshot-manager.ts b/packages/server/src/server/agent/provider-snapshot-manager.ts index bc9600ab6..ed895f882 100644 --- a/packages/server/src/server/agent/provider-snapshot-manager.ts +++ b/packages/server/src/server/agent/provider-snapshot-manager.ts @@ -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, }), }); diff --git a/packages/server/src/server/plugins/index.posix.test.ts b/packages/server/src/server/plugins/index.posix.test.ts index 86f3aa12d..1d92d3eec 100644 --- a/packages/server/src/server/plugins/index.posix.test.ts +++ b/packages/server/src/server/plugins/index.posix.test.ts @@ -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); diff --git a/packages/server/src/server/plugins/index.ts b/packages/server/src/server/plugins/index.ts index 373e0c29e..cddc57ebd 100644 --- a/packages/server/src/server/plugins/index.ts +++ b/packages/server/src/server/plugins/index.ts @@ -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 diff --git a/packages/server/src/server/plugins/plugin-process-protocol.ts b/packages/server/src/server/plugins/plugin-process-protocol.ts index ccbdf5d1c..419fc4820 100644 --- a/packages/server/src/server/plugins/plugin-process-protocol.ts +++ b/packages/server/src/server/plugins/plugin-process-protocol.ts @@ -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(), diff --git a/packages/server/src/server/plugins/plugin-process.ts b/packages/server/src/server/plugins/plugin-process.ts index 17d7ff40b..738a7644d 100644 --- a/packages/server/src/server/plugins/plugin-process.ts +++ b/packages/server/src/server/plugins/plugin-process.ts @@ -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, diff --git a/plugins/antigravity-provider/server/provider.test.ts b/plugins/antigravity-provider/server/provider.test.ts index 7483600ec..6e3a5e967 100644 --- a/plugins/antigravity-provider/server/provider.test.ts +++ b/plugins/antigravity-provider/server/provider.test.ts @@ -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], diff --git a/plugins/antigravity-provider/server/provider.ts b/plugins/antigravity-provider/server/provider.ts index 2726a5521..b32fdd0e4 100644 --- a/plugins/antigravity-provider/server/provider.ts +++ b/plugins/antigravity-provider/server/provider.ts @@ -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>): 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}`, }; } }, diff --git a/plugins/fx-provider/server/provider.ts b/plugins/fx-provider/server/provider.ts index f7cc53526..d9e764404 100644 --- a/plugins/fx-provider/server/provider.ts +++ b/plugins/fx-provider/server/provider.ts @@ -13,5 +13,6 @@ export function createFxProvider(): ProviderRegistration { command: ["fx", "acp"], transformers: [fileToolTransformer], }), + docsUrl: "https://paseo.sh/docs/supported-providers/fx", }; } diff --git a/plugins/hoplite-provider/server/provider.ts b/plugins/hoplite-provider/server/provider.ts index 74828eab7..e65d7a186 100644 --- a/plugins/hoplite-provider/server/provider.ts +++ b/plugins/hoplite-provider/server/provider.ts @@ -15,6 +15,7 @@ export function createHopliteProvider(): ProviderRegistration { acpOptions: { workspaceOnlyCatalog: true }, transformers: [runPhaseTransformer], }), + docsUrl: "https://paseo.sh/docs/supported-providers/hoplite", installation: createHopliteInstallation(), }; } diff --git a/plugins/muse-provider/server/provider.ts b/plugins/muse-provider/server/provider.ts index 525d9b51e..00732f274 100644 --- a/plugins/muse-provider/server/provider.ts +++ b/plugins/muse-provider/server/provider.ts @@ -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 }) { diff --git a/public-docs/plugins/providers.md b/public-docs/plugins/providers.md index fca9d224a..d3a75f4a3 100644 --- a/public-docs/plugins/providers.md +++ b/public-docs/plugins/providers.md @@ -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: diff --git a/public-docs/plugins/providers.zh-CN.md b/public-docs/plugins/providers.zh-CN.md index ef8ca4443..835d7fb86 100644 --- a/public-docs/plugins/providers.zh-CN.md +++ b/public-docs/plugins/providers.zh-CN.md @@ -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 适配层: diff --git a/public-docs/plugins/reference.md b/public-docs/plugins/reference.md index 747f3a021..6d684a36f 100644 --- a/public-docs/plugins/reference.md +++ b/public-docs/plugins/reference.md @@ -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 diff --git a/public-docs/plugins/reference.zh-CN.md b/public-docs/plugins/reference.zh-CN.md index 5f2b2d355..1c909d7fb 100644 --- a/public-docs/plugins/reference.zh-CN.md +++ b/public-docs/plugins/reference.zh-CN.md @@ -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` 导入它的契约和辅助函数。 diff --git a/public-docs/supported-providers/antigravity.md b/public-docs/supported-providers/antigravity.md index 489df0471..19c0f01f6 100644 --- a/public-docs/supported-providers/antigravity.md +++ b/public-docs/supported-providers/antigravity.md @@ -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)`. diff --git a/public-docs/supported-providers/antigravity.zh-CN.md b/public-docs/supported-providers/antigravity.zh-CN.md index 2f9854235..5f7e46195 100644 --- a/public-docs/supported-providers/antigravity.zh-CN.md +++ b/public-docs/supported-providers/antigravity.zh-CN.md @@ -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)`。