mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-29 11:46:12 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97628dfd13 | ||
|
|
25441b1845 | ||
|
|
e1bb1f8ff1 | ||
|
|
20354c13b9 | ||
|
|
f3e59c1c86 |
+1
-1
@@ -1 +1 @@
|
||||
sha256-aal9eR571blWuL7CZt1LR+KfA4QPJ0ivVl/GSTWy93o=
|
||||
sha256-34bUBmRmjekbUSp93597GLTmSWKt23TCHaK3ViXG+iU=
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import {
|
||||
expectBuiltinPluginSettings,
|
||||
openBuiltinPluginSettings,
|
||||
test,
|
||||
} from "../support/helpers/builtin-plugin-settings";
|
||||
|
||||
test("a built-in plugin's settings link opens its screen", async ({
|
||||
page,
|
||||
builtinSettingsHost,
|
||||
}) => {
|
||||
await openBuiltinPluginSettings(page, builtinSettingsHost);
|
||||
await expectBuiltinPluginSettings(page);
|
||||
});
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
} from "../support/helpers/composer";
|
||||
import { openGlobalNewWorkspaceComposer } from "../support/helpers/new-workspace";
|
||||
import { clickNewChat, clickNewTerminal, gotoWorkspace } from "../support/helpers/launcher";
|
||||
import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
|
||||
const MOCK_PROVIDER_LABEL = "Mock Load Test";
|
||||
@@ -344,6 +345,18 @@ test.describe("Cross-provider model search", () => {
|
||||
expect(Math.abs(expandedBox!.y - collapsedBox!.y)).toBeLessThanOrEqual(1);
|
||||
expect(Math.abs(expandedBox!.height - collapsedBox!.height)).toBeLessThanOrEqual(1);
|
||||
|
||||
// Search dock matches the collapsed provider card's outer rails, height, and text rail.
|
||||
const searchContainer = page.getByTestId("model-search-all-input-container");
|
||||
const searchInput = page.getByTestId("model-search-all-input");
|
||||
const searchBox = await searchContainer.boundingBox();
|
||||
const searchInputBox = await searchInput.boundingBox();
|
||||
const collapsedCardBox = await readCollapsedCardGeometry(collapsedHeader);
|
||||
expect(searchBox && searchInputBox && collapsedCardBox).toBeTruthy();
|
||||
expect(Math.abs(searchBox!.x - collapsedCardBox!.cardX)).toBeLessThanOrEqual(1);
|
||||
expect(Math.abs(searchBox!.width - collapsedCardBox!.cardWidth)).toBeLessThanOrEqual(1);
|
||||
expect(Math.abs(searchBox!.height - collapsedCardBox!.cardHeight)).toBeLessThanOrEqual(1);
|
||||
expect(Math.abs(searchInputBox!.x - collapsedCardBox!.labelX)).toBeLessThanOrEqual(2);
|
||||
|
||||
// Return Home, expand Profiles in place, and apply the profile.
|
||||
await page.getByTestId("sheet-header-back").click();
|
||||
await profilesToggle.click();
|
||||
@@ -451,8 +464,97 @@ test.describe("Cross-provider model search", () => {
|
||||
await provider.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test("compact single-provider picker keeps its header fixed and scrolls to the last model row", async ({
|
||||
page,
|
||||
}) => {
|
||||
const extraModels = Array.from({ length: 24 }, (_, index) => ({
|
||||
id: `extra-scroll-${String(index).padStart(2, "0")}`,
|
||||
label: `Extra scroll model ${String(index).padStart(2, "0")}`,
|
||||
description: `Extra row ${index}`,
|
||||
}));
|
||||
const client = await connectDaemonClient<DaemonClient>({
|
||||
clientIdPrefix: "single-provider-scroll",
|
||||
});
|
||||
const workspace = await seedMockAgentWorkspace({
|
||||
repoPrefix: "single-provider-scroll-",
|
||||
title: "Single provider scroll",
|
||||
model: "ten-second-stream",
|
||||
modeId: "load-test",
|
||||
});
|
||||
|
||||
try {
|
||||
await client.patchDaemonConfig({
|
||||
providers: {
|
||||
mock: {
|
||||
additionalModels: extraModels,
|
||||
},
|
||||
},
|
||||
});
|
||||
await page.setViewportSize({ width: 390, height: 800 });
|
||||
await openAgentRoute(page, workspace);
|
||||
await expectComposerVisible(page);
|
||||
await page.getByTestId("combined-model-selector").filter({ visible: true }).first().click();
|
||||
await expect(page.getByTestId("agent-controls-model")).toBeVisible();
|
||||
await page.getByTestId("agent-controls-model").click();
|
||||
|
||||
const list = page.getByTestId("compact-model-list");
|
||||
await expect(list).toBeVisible();
|
||||
const header = page.getByTestId("model-provider-section-mock");
|
||||
await expect(header).toBeVisible();
|
||||
const headerBox = await header.boundingBox();
|
||||
expect(headerBox).toBeTruthy();
|
||||
expect(headerBox!.height).toBeGreaterThanOrEqual(16);
|
||||
|
||||
// Scroll to the bottom of the lone provider's list and confirm the final row is fully in view.
|
||||
await list.evaluate((node) => {
|
||||
node.scrollTop = node.scrollHeight;
|
||||
});
|
||||
const lastRow = page.getByTestId("model-row-mock-extra-scroll-23");
|
||||
await expect(lastRow).toBeVisible();
|
||||
const listBox = await list.boundingBox();
|
||||
const lastRowBox = await lastRow.boundingBox();
|
||||
expect(listBox && lastRowBox).toBeTruthy();
|
||||
expect(lastRowBox!.y + lastRowBox!.height).toBeLessThanOrEqual(
|
||||
listBox!.y + listBox!.height + 1,
|
||||
);
|
||||
await lastRow.click();
|
||||
await expect(page.getByTestId("agent-controls-model")).toContainText("Extra scroll model 23");
|
||||
} finally {
|
||||
await client
|
||||
.patchDaemonConfig({
|
||||
providers: {
|
||||
mock: {
|
||||
additionalModels: [],
|
||||
},
|
||||
},
|
||||
})
|
||||
.catch(() => undefined);
|
||||
await client.close().catch(() => undefined);
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
async function readCollapsedCardGeometry(collapsedHeader: ReturnType<Page["getByTestId"]>) {
|
||||
return collapsedHeader.evaluate((node) => {
|
||||
// Walk up from the press overlay to the SettingsCard container (2px taller for borders).
|
||||
const header = node.parentElement;
|
||||
const card = header?.parentElement?.parentElement;
|
||||
const rect = card?.getBoundingClientRect();
|
||||
const label = header?.querySelector('[dir="auto"]');
|
||||
const labelRect = label?.getBoundingClientRect();
|
||||
return rect && labelRect
|
||||
? {
|
||||
cardX: rect.x,
|
||||
cardWidth: rect.width,
|
||||
cardHeight: rect.height,
|
||||
labelX: labelRect.x,
|
||||
}
|
||||
: null;
|
||||
});
|
||||
}
|
||||
|
||||
async function startScrollSampling(page: Page, listTestId: string): Promise<void> {
|
||||
await page.evaluate((testId) => {
|
||||
const samples: number[] = [];
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { BuiltinPluginLoader } from "../../../../server/src/server/plugins/builtin/index.js";
|
||||
import { createTestPaseoDaemon } from "../../../../server/src/server/test-utils/paseo-daemon.js";
|
||||
import { DaemonClient } from "../../../../server/src/server/test-utils/daemon-client.js";
|
||||
import assert from "node:assert/strict";
|
||||
import pino from "pino";
|
||||
|
||||
const [, , root, origin, paseoHomeRoot, daemonVersion] = process.argv;
|
||||
|
||||
const daemon = await createTestPaseoDaemon({
|
||||
corsAllowedOrigins: [origin!],
|
||||
paseoHomeRoot,
|
||||
daemonVersion,
|
||||
logger: pino({ level: "error" }),
|
||||
builtinPlugins: new BuiltinPluginLoader(root, ["builtin-settings"]),
|
||||
});
|
||||
const client = new DaemonClient({
|
||||
appVersion: daemonVersion,
|
||||
url: `ws://127.0.0.1:${daemon.port}/ws`,
|
||||
});
|
||||
|
||||
try {
|
||||
await client.connect();
|
||||
const plugin = (await client.getPluginCatalog()).find(({ id }) => id === "builtin-settings");
|
||||
assert.ok(plugin?.clientBundle, JSON.stringify(await client.getPluginLogs("builtin-settings")));
|
||||
assert.deepEqual(await client.listPlugins(), []);
|
||||
process.send!({ serverId: client.getLastServerInfoMessage()!.serverId, port: daemon.port });
|
||||
await new Promise<void>((resolve) => {
|
||||
process.once("disconnect", resolve);
|
||||
process.once("SIGTERM", resolve);
|
||||
});
|
||||
} finally {
|
||||
await client.close();
|
||||
await daemon.close();
|
||||
}
|
||||
@@ -627,7 +627,8 @@ export async function expectProfilesEditLink(page: Page): Promise<void> {
|
||||
exact: true,
|
||||
});
|
||||
await expect(edit).toBeVisible();
|
||||
await expect(edit).toHaveText("Edit");
|
||||
await expect(edit).toHaveText("");
|
||||
await expect(edit.locator("svg")).toBeVisible();
|
||||
}
|
||||
|
||||
/** With no profiles, the Profiles entry offers to create one instead of listing any. */
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { once } from "node:events";
|
||||
import { spawnTsx, killProcessTree } from "./spawn-node";
|
||||
import appPackage from "../../../package.json";
|
||||
import { expect, test as base, type Page } from "../fixtures";
|
||||
import { gotoAppShell } from "./app";
|
||||
import { addConnectedHostAndReload } from "./hosts";
|
||||
import { pluginRequirements } from "./plugin-fixture";
|
||||
|
||||
const pluginId = "builtin-settings";
|
||||
const screenId = "general";
|
||||
const settingsText = "Built-in settings body";
|
||||
|
||||
export const test = base.extend<{ builtinSettingsHost: { serverId: string; port: number } }>({
|
||||
builtinSettingsHost: async ({ baseURL }, provide, testInfo) => {
|
||||
const root = testInfo.outputPath("builtin-plugins");
|
||||
const directory = path.join(root, pluginId);
|
||||
await mkdir(directory, { recursive: true });
|
||||
await writeFile(
|
||||
path.join(directory, "paseo-plugin.json"),
|
||||
JSON.stringify({ id: pluginId, requirements: pluginRequirements }),
|
||||
);
|
||||
await writeFile(
|
||||
path.join(directory, "index.client.tsx"),
|
||||
`import React from "react";
|
||||
import { Text } from "react-native";
|
||||
|
||||
export default function contribute(client) {
|
||||
client.addSettingsScreen({
|
||||
id: "${screenId}",
|
||||
title: "General",
|
||||
icon: "SlidersHorizontal",
|
||||
Component: () => <Text>${settingsText}</Text>,
|
||||
});
|
||||
return () => {};
|
||||
}`,
|
||||
);
|
||||
await writeFile(
|
||||
path.join(directory, "index.server.ts"),
|
||||
"export default function contribute() { return () => {}; }",
|
||||
);
|
||||
const daemon = spawnTsx(
|
||||
path.resolve(__dirname, "../../fixtures/builtin-settings/daemon.mts"),
|
||||
[root, new URL(baseURL!).origin, testInfo.outputPath("daemon"), appPackage.version],
|
||||
{ stdio: ["ignore", "inherit", "inherit", "ipc"] },
|
||||
);
|
||||
try {
|
||||
const [host] = await Promise.race([
|
||||
once(daemon, "message") as Promise<[{ serverId: string; port: number }]>,
|
||||
once(daemon, "exit").then(([code]) => {
|
||||
throw new Error(`Built-in settings daemon exited with code ${code}`);
|
||||
}),
|
||||
]);
|
||||
await provide(host);
|
||||
} finally {
|
||||
await killProcessTree(daemon);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export async function openBuiltinPluginSettings(
|
||||
page: Page,
|
||||
host: { serverId: string; port: number },
|
||||
) {
|
||||
await gotoAppShell(page);
|
||||
await addConnectedHostAndReload(page, {
|
||||
...host,
|
||||
label: "Built-in settings host",
|
||||
destination: `/settings/hosts/${host.serverId}/plugins/${pluginId}/${screenId}`,
|
||||
});
|
||||
}
|
||||
|
||||
export async function expectBuiltinPluginSettings(page: Page) {
|
||||
await expect(page.getByText(settingsText, { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("switch", { name: /: Disable$/ })).toHaveCount(0);
|
||||
}
|
||||
@@ -76,15 +76,24 @@ export async function addOfflineHostsAndReload(
|
||||
|
||||
export async function addConnectedHostAndReload(
|
||||
page: Page,
|
||||
input: { serverId: string; label: string; port: number; primaryLabel?: string },
|
||||
input: {
|
||||
serverId: string;
|
||||
label: string;
|
||||
port: number;
|
||||
primaryLabel?: string;
|
||||
destination?: string;
|
||||
},
|
||||
): Promise<void> {
|
||||
await addConnectedHostsAndReload(page, [input], { primaryLabel: input.primaryLabel });
|
||||
await addConnectedHostsAndReload(page, [input], {
|
||||
primaryLabel: input.primaryLabel,
|
||||
destination: input.destination,
|
||||
});
|
||||
}
|
||||
|
||||
export async function addConnectedHostsAndReload(
|
||||
page: Page,
|
||||
inputs: Array<{ serverId: string; label: string; port: number }>,
|
||||
options?: { primaryLabel?: string },
|
||||
options?: { primaryLabel?: string; destination?: string },
|
||||
): Promise<void> {
|
||||
const connectedHosts = inputs.map((input) =>
|
||||
buildSeededHost({
|
||||
@@ -123,7 +132,8 @@ export async function addConnectedHostsAndReload(
|
||||
},
|
||||
);
|
||||
|
||||
await page.reload();
|
||||
if (options?.destination) await page.goto(options.destination);
|
||||
else await page.reload();
|
||||
}
|
||||
|
||||
export async function waitForConnectedHost(
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import { ModelProviderGlyph, useSelectedModelLabels } from "@/components/model-browser";
|
||||
import { DesktopModelPicker, type ModelPickerActions } from "@/components/model-browser-panes";
|
||||
import {
|
||||
getSheetSearchFooterStyle,
|
||||
MobileModelPageView,
|
||||
SheetSearchDock,
|
||||
useMobileModelPage,
|
||||
@@ -313,6 +314,7 @@ function CompactCombinedModelSelector({
|
||||
snapPoints={SHEET_SNAP_POINTS}
|
||||
scrollable={false}
|
||||
footer={footer}
|
||||
footerContainerStyle={getSheetSearchFooterStyle()}
|
||||
keyboard={keyboard}
|
||||
contentStyle={styles.sheetBody}
|
||||
testID="model-selector-sheet"
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useCallback, useMemo, useRef, useState, type ReactElement, type ReactNo
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FlatList, Text, View } from "react-native";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import { AlertTriangle, ChevronDown, Layers, Pencil } from "lucide-react-native";
|
||||
import { AlertTriangle, ChevronDown, Layers } from "lucide-react-native";
|
||||
import type { AgentProfilePickerRow } from "@/agent-profiles";
|
||||
import {
|
||||
IndependentScrollBoundary,
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
} from "@/components/model-browser";
|
||||
import {
|
||||
CustomizeProviderButton,
|
||||
EditProfilesButton,
|
||||
ModelPickerItemRow,
|
||||
type ModelPickerActions,
|
||||
} from "@/components/model-browser-panes";
|
||||
@@ -34,7 +35,6 @@ import {
|
||||
type MobileProviderSection,
|
||||
} from "@/components/mobile-model-page-view";
|
||||
import { SettingsCard } from "@/components/settings";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||
import { PressHighlight } from "@/components/ui/press-highlight";
|
||||
import {
|
||||
@@ -46,6 +46,7 @@ import { SearchField } from "@/components/ui/search-field";
|
||||
import { isNative, isWeb } from "@/constants/platform";
|
||||
import type { ProviderSelectorProvider } from "@/provider-selection/provider-selection";
|
||||
import { ICON_SIZE, type Theme } from "@/styles/theme";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import { inlineUnistylesStyle } from "@/styles/unistyles-inline-style";
|
||||
|
||||
/**
|
||||
@@ -158,6 +159,7 @@ export function SheetSearchDock({
|
||||
placeholder={placeholder}
|
||||
clearAccessibilityLabel={t("providerCatalog.clearSearch")}
|
||||
fullWidth
|
||||
variant="card"
|
||||
testID={testID}
|
||||
clearTestID={testID ? `${testID}-clear` : undefined}
|
||||
/>
|
||||
@@ -263,6 +265,21 @@ export function MobileModelPageView({
|
||||
),
|
||||
[renderItem],
|
||||
);
|
||||
const singleProviderSection =
|
||||
projection.kind === "browse" && !projection.showSectionHeaders
|
||||
? projection.sections[0]
|
||||
: undefined;
|
||||
const singleProviderHeader = useMemo(
|
||||
() =>
|
||||
singleProviderSection?.kind === "provider" ? (
|
||||
<ProviderSectionHeader
|
||||
section={singleProviderSection}
|
||||
serverId={serverId}
|
||||
collapsible={false}
|
||||
/>
|
||||
) : undefined,
|
||||
[serverId, singleProviderSection],
|
||||
);
|
||||
|
||||
if (projection.kind === "noProviders") {
|
||||
return (
|
||||
@@ -296,12 +313,8 @@ export function MobileModelPageView({
|
||||
);
|
||||
}
|
||||
if (!projection.showSectionHeaders) {
|
||||
const section = projection.sections[0];
|
||||
return (
|
||||
<SheetListCard testID="mobile-model-page">
|
||||
{section?.kind === "provider" ? (
|
||||
<ProviderSectionHeader section={section} serverId={serverId} collapsible={false} />
|
||||
) : null}
|
||||
<SheetListCard header={singleProviderHeader} testID="mobile-model-page">
|
||||
{projection.body ? (
|
||||
<SectionBody
|
||||
body={projection.body}
|
||||
@@ -397,18 +410,8 @@ export function CollapsibleProfilesCard({
|
||||
[],
|
||||
);
|
||||
const trailingAction = useMemo(
|
||||
() =>
|
||||
expanded && onEditProfiles ? (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
leftIcon={Pencil}
|
||||
onPress={onEditProfiles}
|
||||
accessibilityLabel={t("modelSelector.editProfilesLabel")}
|
||||
testID="model-profiles-edit"
|
||||
/>
|
||||
) : null,
|
||||
[expanded, onEditProfiles, t],
|
||||
() => (expanded && onEditProfiles ? <EditProfilesButton onPress={onEditProfiles} /> : null),
|
||||
[expanded, onEditProfiles],
|
||||
);
|
||||
const viewportHeight = computeBoundedListHeight(items.length);
|
||||
|
||||
@@ -491,12 +494,25 @@ function AccordionSectionCard({
|
||||
|
||||
/**
|
||||
* An inset card holding one sheet list, on the same rail as the browse sections' cards. It grows
|
||||
* with the list, then the list scrolls inside it.
|
||||
* with the list, then the list scrolls inside it while its optional header stays fixed.
|
||||
*/
|
||||
function SheetListCard({ children, testID }: { children: ReactNode; testID?: string }) {
|
||||
function SheetListCard({
|
||||
header,
|
||||
children,
|
||||
testID,
|
||||
}: {
|
||||
header?: ReactNode;
|
||||
children: ReactNode;
|
||||
testID?: string;
|
||||
}) {
|
||||
return (
|
||||
<View style={styles.listCardPage} testID={testID}>
|
||||
<SettingsCard shrink>{children}</SettingsCard>
|
||||
<View style={[settingsStyles.card, styles.listCard]}>
|
||||
{header ? <View style={styles.listCardHeader}>{header}</View> : null}
|
||||
<View style={[header ? settingsStyles.rowBorder : undefined, styles.listCardBody]}>
|
||||
{children}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -591,18 +607,8 @@ function ProfilesSectionHeader({
|
||||
[],
|
||||
);
|
||||
const trailing = useMemo(
|
||||
() =>
|
||||
expanded && onEditProfiles ? (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
leftIcon={Pencil}
|
||||
onPress={onEditProfiles}
|
||||
accessibilityLabel={t("modelSelector.editProfilesLabel")}
|
||||
testID="model-profiles-edit"
|
||||
/>
|
||||
) : null,
|
||||
[expanded, onEditProfiles, t],
|
||||
() => (expanded && onEditProfiles ? <EditProfilesButton onPress={onEditProfiles} /> : null),
|
||||
[expanded, onEditProfiles],
|
||||
);
|
||||
return (
|
||||
<CollapsibleSectionHeader
|
||||
@@ -698,7 +704,7 @@ function SectionBody({
|
||||
onRetryProvider: ModelPickerActions["onRetryProvider"];
|
||||
isRetryingProvider: boolean;
|
||||
}) {
|
||||
const frameStyle = fill ? styles.page : styles.fixedViewport;
|
||||
const frameStyle = fill ? styles.fillState : styles.fixedViewport;
|
||||
if (body.kind === "providerLoading") {
|
||||
return (
|
||||
<View style={[frameStyle, styles.centered]}>
|
||||
@@ -784,8 +790,12 @@ function SectionItemList({
|
||||
return [styles.boundedViewport, inlineUnistylesStyle({ height: viewportHeight })];
|
||||
}, [fill, viewportHeight]);
|
||||
|
||||
// A lone provider's list is the sheet's own scroller, so it must integrate with the bottom sheet
|
||||
// gesture handler (SheetFlatList); an accordion list scrolls independently inside SheetScrollView.
|
||||
const ListComponent = fill ? SheetFlatList : FlatList;
|
||||
|
||||
return (
|
||||
<FlatList
|
||||
<ListComponent
|
||||
ref={listRef}
|
||||
data={items}
|
||||
renderItem={renderItem}
|
||||
@@ -798,7 +808,7 @@ function SectionItemList({
|
||||
keyboardShouldPersistTaps="handled"
|
||||
keyboardDismissMode={KEYBOARD_DISMISS_MODE}
|
||||
showsVerticalScrollIndicator
|
||||
nestedScrollEnabled
|
||||
nestedScrollEnabled={!fill}
|
||||
testID={testID}
|
||||
/>
|
||||
);
|
||||
@@ -816,6 +826,20 @@ const styles = StyleSheet.create((theme) => ({
|
||||
paddingTop: theme.spacing[2],
|
||||
paddingBottom: theme.spacing[2],
|
||||
},
|
||||
listCard: {
|
||||
flexShrink: 1,
|
||||
minHeight: 0,
|
||||
},
|
||||
listCardHeader: {
|
||||
flexShrink: 0,
|
||||
},
|
||||
listCardBody: {
|
||||
flexShrink: 1,
|
||||
minHeight: 0,
|
||||
},
|
||||
fillState: {
|
||||
minHeight: MOBILE_EXPANDED_PROVIDER_HEIGHT,
|
||||
},
|
||||
sections: {
|
||||
paddingHorizontal: theme.spacing[4],
|
||||
paddingTop: theme.spacing[2],
|
||||
@@ -891,4 +915,14 @@ const styles = StyleSheet.create((theme) => ({
|
||||
flex: 1,
|
||||
flexDirection: "row",
|
||||
},
|
||||
searchFooter: {
|
||||
// Matches the card inset (`styles.sections` / `styles.listCardPage`) so the search box shares
|
||||
// its outer left and right rails with the provider cards above it.
|
||||
paddingHorizontal: theme.spacing[4],
|
||||
},
|
||||
}));
|
||||
|
||||
/** Read at render time rather than module scope (docs/unistyles.md). */
|
||||
export function getSheetSearchFooterStyle() {
|
||||
return styles.searchFooter;
|
||||
}
|
||||
|
||||
@@ -603,7 +603,6 @@ function ListPane({
|
||||
onActivate: (key: string) => void;
|
||||
actions: ModelPickerActions;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const { pane, activeKey } = projection;
|
||||
const entries = useListEntries(pane);
|
||||
const profiledLookup = useMemo(
|
||||
@@ -629,17 +628,7 @@ function ListPane({
|
||||
if (entry.kind === "heading") {
|
||||
let headingAction: ReactNode = null;
|
||||
if (entry.action?.kind === "editProfiles" && actions.onEditProfiles) {
|
||||
headingAction = (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onPress={actions.onEditProfiles}
|
||||
accessibilityLabel={t("modelSelector.editProfilesLabel")}
|
||||
testID="model-profiles-edit"
|
||||
>
|
||||
{t("modelSelector.editProfiles")}
|
||||
</Button>
|
||||
);
|
||||
headingAction = <EditProfilesButton onPress={actions.onEditProfiles} />;
|
||||
} else if (entry.action?.kind === "customizeProvider" && serverId) {
|
||||
headingAction = (
|
||||
<CustomizeProviderButton
|
||||
@@ -680,7 +669,6 @@ function ListPane({
|
||||
selectedModel,
|
||||
selectedProvider,
|
||||
serverId,
|
||||
t,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -797,17 +785,7 @@ function ListPaneHeader({
|
||||
<Text style={styles.paneTitle} numberOfLines={1}>
|
||||
{t("modelSelector.profiles")}
|
||||
</Text>
|
||||
{onEditProfiles ? (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onPress={onEditProfiles}
|
||||
accessibilityLabel={t("modelSelector.editProfilesLabel")}
|
||||
testID="model-profiles-edit"
|
||||
>
|
||||
{t("modelSelector.editProfiles")}
|
||||
</Button>
|
||||
) : null}
|
||||
{onEditProfiles ? <EditProfilesButton onPress={onEditProfiles} /> : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -828,6 +806,20 @@ function ListPaneHeader({
|
||||
);
|
||||
}
|
||||
|
||||
export function EditProfilesButton({ onPress }: { onPress: () => void }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
leftIcon={Pencil}
|
||||
onPress={onPress}
|
||||
accessibilityLabel={t("modelSelector.editProfilesLabel")}
|
||||
testID="model-profiles-edit"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function CustomizeProviderButton({
|
||||
serverId,
|
||||
providerId,
|
||||
|
||||
@@ -56,25 +56,13 @@ interface AppSettingsRowProps extends Omit<SettingsRowProps, "hint">, AppRowExtr
|
||||
hint?: ReactNode;
|
||||
}
|
||||
|
||||
/** Lets a card and its rows shrink below their content, so a list inside can scroll. */
|
||||
const SHRINK = { flexShrink: 1, minHeight: 0 } as const;
|
||||
|
||||
export function SettingsCard({
|
||||
children,
|
||||
testID,
|
||||
shrink = false,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
testID?: string;
|
||||
/** The card shrinks to fit a parent with a bounded height, and a list inside it scrolls. */
|
||||
shrink?: boolean;
|
||||
}) {
|
||||
export function SettingsCard({ children, testID }: { children: ReactNode; testID?: string }) {
|
||||
return (
|
||||
<View style={[settingsStyles.card, shrink && SHRINK]} testID={testID}>
|
||||
<View style={settingsStyles.card} testID={testID}>
|
||||
{Children.toArray(children).map((child, index) => (
|
||||
<View
|
||||
key={isValidElement(child) ? child.key : index}
|
||||
style={[index ? settingsStyles.rowBorder : undefined, shrink && SHRINK]}
|
||||
style={index ? settingsStyles.rowBorder : undefined}
|
||||
>
|
||||
{child}
|
||||
</View>
|
||||
|
||||
@@ -89,9 +89,7 @@ const styles = StyleSheet.create((theme: Theme) => ({
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
width: INDENT_GUIDE_WIDTH,
|
||||
// Translucent ink, not `border`: a solid line that colour disappears into a hovered row's fill.
|
||||
backgroundColor: theme.colors.foregroundExtraMuted,
|
||||
opacity: theme.opacity[50],
|
||||
backgroundColor: theme.colors.treeGuide,
|
||||
},
|
||||
chevron: {
|
||||
width: WORKSPACE_TREE_ICON_SIZE,
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from "react-native";
|
||||
import { Search, X } from "lucide-react-native";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import type { Theme } from "@/styles/theme";
|
||||
import { ICON_SIZE, type Theme } from "@/styles/theme";
|
||||
import {
|
||||
EditingTextInput as TextInput,
|
||||
type EditingTextInputHandle,
|
||||
@@ -35,6 +35,11 @@ export interface SearchFieldProps {
|
||||
fullWidth?: boolean;
|
||||
/** `sm` heads a list in tight chrome such as a sidebar pane. */
|
||||
size?: "sm" | "md";
|
||||
/**
|
||||
* `card` matches a compact `SettingsCard` row's height, corner radius, horizontal inset, and
|
||||
* leading glyph rail so a docked sheet search aligns with the cards above it.
|
||||
*/
|
||||
variant?: "default" | "card";
|
||||
/** Escape empties the field. Off where Escape already closes the surface around it. */
|
||||
clearOnEscape?: boolean;
|
||||
testID?: string;
|
||||
@@ -56,6 +61,7 @@ export function SearchField({
|
||||
clearAccessibilityLabel,
|
||||
fullWidth = false,
|
||||
size = "md",
|
||||
variant = "default",
|
||||
clearOnEscape = false,
|
||||
testID,
|
||||
clearTestID,
|
||||
@@ -79,17 +85,21 @@ export function SearchField({
|
||||
if (value === "" && inputRef.current?.getText()) inputRef.current.replaceText("");
|
||||
}, [value]);
|
||||
const small = size === "sm";
|
||||
const card = variant === "card";
|
||||
const leadingIcon = <ThemedSearch size={ICON_SIZE.sm} uniProps={mutedColorMapping} />;
|
||||
|
||||
return (
|
||||
<View
|
||||
testID={testID ? `${testID}-container` : undefined}
|
||||
style={[
|
||||
styles.field,
|
||||
small && styles.fieldSmall,
|
||||
card && styles.fieldCard,
|
||||
fullWidth && styles.fieldFullWidth,
|
||||
isFocused && styles.fieldFocused,
|
||||
]}
|
||||
>
|
||||
<ThemedSearch size={14} uniProps={mutedColorMapping} />
|
||||
{card ? <View style={styles.leadingSlot}>{leadingIcon}</View> : leadingIcon}
|
||||
<ThemedTextInput
|
||||
testID={testID}
|
||||
ref={inputRef}
|
||||
@@ -112,8 +122,9 @@ export function SearchField({
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={clearAccessibilityLabel}
|
||||
hitSlop={8}
|
||||
style={card ? styles.clearSlot : undefined}
|
||||
>
|
||||
<ThemedX size={14} uniProps={mutedColorMapping} />
|
||||
<ThemedX size={ICON_SIZE.sm} uniProps={mutedColorMapping} />
|
||||
</Pressable>
|
||||
) : null}
|
||||
</View>
|
||||
@@ -142,6 +153,25 @@ const styles = StyleSheet.create((theme) => ({
|
||||
paddingVertical: 0,
|
||||
paddingHorizontal: theme.spacing[1.5],
|
||||
},
|
||||
fieldCard: {
|
||||
// Matches a collapsed SettingsCard row: 44pt inner row height + 1px top/bottom border = 46pt.
|
||||
height: 46,
|
||||
paddingVertical: 0,
|
||||
paddingHorizontal: { xs: theme.spacing[4], md: theme.spacing[3] },
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
},
|
||||
leadingSlot: {
|
||||
width: 16,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
clearSlot: {
|
||||
width: ICON_SIZE.sm,
|
||||
height: ICON_SIZE.sm,
|
||||
marginRight: -theme.spacing[1],
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
fieldFullWidth: {
|
||||
maxWidth: "100%",
|
||||
},
|
||||
|
||||
@@ -13,6 +13,7 @@ import { ModelProviderGlyph } from "@/components/model-browser";
|
||||
import type { ModelPickerActions } from "@/components/model-browser-panes";
|
||||
import {
|
||||
CollapsibleProfilesCard,
|
||||
getSheetSearchFooterStyle,
|
||||
MobileModelPageView,
|
||||
SheetSearchDock,
|
||||
useMobileModelPage,
|
||||
@@ -352,6 +353,7 @@ export function AgentSettingsDrawer({
|
||||
snapPoints={SNAP_POINTS}
|
||||
scrollable={false}
|
||||
footer={footer}
|
||||
footerContainerStyle={getSheetSearchFooterStyle()}
|
||||
keyboard={keyboard}
|
||||
contentStyle={styles.sheetBody}
|
||||
contextBridge={contextBridge}
|
||||
|
||||
@@ -27,8 +27,12 @@ import { StatusBadge } from "@/components/ui/status-badge";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { useToast } from "@/contexts/toast-api-context";
|
||||
import { useHostRuntimeClient } from "@/runtime/host-runtime";
|
||||
import { useInstalledPlugin, usePluginEvaluationError } from "@/plugins/registry";
|
||||
import { useHostRuntimeClient, useHostRuntimeIsConnected } from "@/runtime/host-runtime";
|
||||
import {
|
||||
useInstalledPlugin,
|
||||
usePluginCatalogStatus,
|
||||
usePluginEvaluationError,
|
||||
} from "@/plugins/registry";
|
||||
import { pluginDisplayName } from "@/plugins/plugin-list";
|
||||
import { PluginSettingsContent } from "@/plugins/settings";
|
||||
import { usePluginActions, type PluginAction } from "./actions";
|
||||
@@ -276,8 +280,6 @@ interface PluginPageModel {
|
||||
error?: string;
|
||||
/** Why the last update failed, while the update is still offered. The installed version keeps running. */
|
||||
updateError?: string;
|
||||
/** The plugin's own settings screen, shown inline. */
|
||||
screenId?: string;
|
||||
overview?: string;
|
||||
}
|
||||
|
||||
@@ -301,12 +303,10 @@ function usePluginPageModel({
|
||||
const directory = usePluginDirectory(serverId);
|
||||
const meta = useListingMeta();
|
||||
const pluginId = plugin?.id ?? "";
|
||||
const installedPlugin = useInstalledPlugin(serverId, pluginId);
|
||||
const evaluationError = usePluginEvaluationError(serverId, pluginId);
|
||||
const pluginOperation = usePluginOperation(serverId, pluginId);
|
||||
const updates = usePluginUpdates(serverId);
|
||||
const text = listing ? listingText(listing, i18n.language) : undefined;
|
||||
const requestedScreen = subject.kind === "installed" ? subject.screenId : undefined;
|
||||
return {
|
||||
name: plugin ? pluginDisplayName(plugin) : (text?.name ?? subjectId(subject)),
|
||||
description: text?.description ?? plugin?.description,
|
||||
@@ -316,11 +316,22 @@ function usePluginPageModel({
|
||||
authorAvatar: listing && listingAuthorAvatar(listing),
|
||||
error: plugin ? (evaluationError ?? plugin.error) : failedError(installOperation),
|
||||
updateError: failedUpdateError(pluginOperation, updates.data, pluginId),
|
||||
screenId: plugin ? (requestedScreen ?? installedPlugin?.settingsScreens[0]?.id) : undefined,
|
||||
overview: detail && listingOverview(detail, i18n.language),
|
||||
};
|
||||
}
|
||||
|
||||
function usePluginPageSettings(
|
||||
serverId: string,
|
||||
subject: PluginPageSubject,
|
||||
plugin: PluginListItem | undefined,
|
||||
) {
|
||||
const pluginId = subject.kind === "installed" ? subject.pluginId : (plugin?.id ?? "");
|
||||
const installedPlugin = useInstalledPlugin(serverId, pluginId);
|
||||
const requestedScreen = subject.kind === "installed" ? subject.screenId : undefined;
|
||||
const screenId = requestedScreen ?? installedPlugin?.settingsScreens[0]?.id;
|
||||
return (plugin || installedPlugin) && screenId ? { pluginId, screenId } : undefined;
|
||||
}
|
||||
|
||||
function subjectId(subject: PluginPageSubject): string {
|
||||
return subject.kind === "listing" ? subject.listingId : subject.pluginId;
|
||||
}
|
||||
@@ -408,6 +419,9 @@ export function PluginPage({
|
||||
const { t } = useTranslation();
|
||||
const compact = useIsCompactFormFactor();
|
||||
const { plugin, listingId, listing, detail, loading } = useResolvedPlugin(serverId, subject);
|
||||
const settings = usePluginPageSettings(serverId, subject, plugin);
|
||||
const catalogStatus = usePluginCatalogStatus(serverId);
|
||||
const connected = useHostRuntimeIsConnected(serverId);
|
||||
const installOperation = usePluginOperation(serverId, listingId);
|
||||
const model = usePluginPageModel({
|
||||
serverId,
|
||||
@@ -436,14 +450,20 @@ export function PluginPage({
|
||||
<SettingsBackLink label={t("settings.plugins.screens.backToPlugins")} onPress={onBack} />
|
||||
</View>
|
||||
);
|
||||
if (loading)
|
||||
const waitingForSettings =
|
||||
subject.kind === "installed" &&
|
||||
!plugin &&
|
||||
!settings &&
|
||||
connected &&
|
||||
catalogStatus === "loading";
|
||||
if (loading || waitingForSettings)
|
||||
return (
|
||||
<View>
|
||||
{back}
|
||||
<PluginPageSkeleton />
|
||||
</View>
|
||||
);
|
||||
if (!plugin && !listing)
|
||||
if (!plugin && !listing && !settings)
|
||||
return (
|
||||
<Alert
|
||||
size="sm"
|
||||
@@ -486,6 +506,7 @@ export function PluginPage({
|
||||
listing={listing}
|
||||
overviewLoading={detail.isLoading}
|
||||
model={model}
|
||||
settings={settings}
|
||||
/>
|
||||
{installTarget ? (
|
||||
<InstallPluginSheet serverId={serverId} target={installTarget} onClose={closeInstall} />
|
||||
@@ -500,12 +521,14 @@ function PluginPageBody({
|
||||
listing,
|
||||
overviewLoading,
|
||||
model,
|
||||
settings,
|
||||
}: {
|
||||
serverId: string;
|
||||
plugin?: PluginListItem;
|
||||
listing?: PluginListing;
|
||||
overviewLoading: boolean;
|
||||
model: PluginPageModel;
|
||||
settings?: { pluginId: string; screenId: string };
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
@@ -523,9 +546,9 @@ function PluginPageBody({
|
||||
</View>
|
||||
) : null}
|
||||
{listing ? <MediaStrip urls={listingImages(listing)} /> : null}
|
||||
{plugin && model.screenId ? (
|
||||
{settings ? (
|
||||
// The plugin's settings screen brings its own sections.
|
||||
<PluginSettingsContent serverId={serverId} pluginId={plugin.id} screenId={model.screenId} />
|
||||
<PluginSettingsContent serverId={serverId} {...settings} />
|
||||
) : null}
|
||||
{model.overview || (listing && overviewLoading) ? (
|
||||
<SettingsSection title={t("settings.plugins.gallery.sections.overview")}>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* A ratio keeps the step equally visible on every base; a lightness delta disappears near black.
|
||||
* The numbers come from the default themes: Paseo dark and Light.
|
||||
*/
|
||||
import { contrastRatio, mixHexColors, stepContrast } from "@/utils/color";
|
||||
import { contrastRatio, mixHexColors, stepContrast, translucentStep } from "@/utils/color";
|
||||
|
||||
export type ColorScheme = "light" | "dark";
|
||||
|
||||
@@ -19,6 +19,11 @@ const SURFACE_STATE_STEPS = {
|
||||
light: { hover: 1.15, selected: 1.35 },
|
||||
} as const;
|
||||
|
||||
// The 1px line under each open folder in a tree, measured on the sidebar. It starts above the
|
||||
// selected fill so a hovered row does not swallow it. Light needs the larger step to read as the
|
||||
// same weight.
|
||||
const TREE_GUIDE_STEPS = { dark: 1.35, light: 1.47 } as const;
|
||||
|
||||
// Fills for chips, bubbles, tracks and secondary buttons, as `surface3` and `surface4`.
|
||||
const NEUTRAL_FILL_STEPS = {
|
||||
dark: { surface3: 1.8, surface4: 2.5 },
|
||||
@@ -53,6 +58,14 @@ export function deriveSurfaceStates(
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Translucent, because trees also sit on the page, workspace panes and sheets. A solid color picked
|
||||
* for the sidebar fades on those.
|
||||
*/
|
||||
export function deriveTreeGuide(sidebar: string, foreground: string, scheme: ColorScheme): string {
|
||||
return translucentStep(sidebar, foreground, TREE_GUIDE_STEPS[scheme]);
|
||||
}
|
||||
|
||||
/** The neutral fills that sit on the page background. */
|
||||
export function deriveNeutralFills(
|
||||
background: string,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { PluginThemeContribution } from "@getpaseo/plugin";
|
||||
import { buildPluginTheme } from "@/plugins/themes";
|
||||
import { contrastRatio } from "@/utils/color";
|
||||
import { contrastRatio, mixHexColors } from "@/utils/color";
|
||||
import { THEME_OPTIONS, type Theme } from "./theme";
|
||||
|
||||
// Palettes of the plugin themes users run into: Catppuccin (the e2e fixture) and
|
||||
@@ -92,10 +92,21 @@ const SELECTED_TEXT_FLOOR = 2.5;
|
||||
const NEUTRAL_FILL_STEP = 1.2;
|
||||
const NEUTRAL_FILL_TEXT_FLOOR = 3;
|
||||
const TERTIARY_TEXT_FLOOR = 2.5;
|
||||
// A tree guide is one quiet line in every theme. Trees also sit on the page, a workspace pane and
|
||||
// a hovered row, and the line has to stay a line on all of them.
|
||||
const TREE_GUIDE_STEP = { dark: 1.35, light: 1.47 };
|
||||
const TREE_GUIDE_FLOOR = 1.18;
|
||||
// The bright hues are dim on a cream or white background by design; the floor only has to catch a
|
||||
// color that disappears.
|
||||
const TERMINAL_COLOR_FLOOR = 1.5;
|
||||
|
||||
/** The color a translucent `rgba()` token shows once painted over `surface`. */
|
||||
function paintedOver(surface: string, token: string): string {
|
||||
const [r, g, b, alpha] = (token.match(/[\d.]+/g) ?? []).map(Number);
|
||||
const ink = `#${[r, g, b].map((channel) => channel.toString(16).padStart(2, "0")).join("")}`;
|
||||
return mixHexColors(surface, ink, alpha);
|
||||
}
|
||||
|
||||
it("keeps Solarized Dark's selected workspace timestamp readable", () => {
|
||||
const { colors } = buildPluginTheme(SOLARIZED_DARK);
|
||||
expect(
|
||||
@@ -118,6 +129,22 @@ describe.each(themes)("$name", ({ theme }) => {
|
||||
).toBeGreaterThanOrEqual(SELECTED_OVER_HOVER_STEP);
|
||||
});
|
||||
|
||||
it("draws tree guides at the same strength on the sidebar", () => {
|
||||
const painted = paintedOver(colors.surfaceSidebar, colors.treeGuide);
|
||||
expect(contrastRatio(colors.surfaceSidebar, painted)).toBeCloseTo(
|
||||
TREE_GUIDE_STEP[theme.colorScheme],
|
||||
1,
|
||||
);
|
||||
});
|
||||
|
||||
it.each(["surfaceSidebarHover", "surface0", "surfaceWorkspace"] as const)(
|
||||
"keeps tree guides visible on %s",
|
||||
(surface) => {
|
||||
const painted = paintedOver(colors[surface], colors.treeGuide);
|
||||
expect(contrastRatio(colors[surface], painted)).toBeGreaterThanOrEqual(TREE_GUIDE_FLOOR);
|
||||
},
|
||||
);
|
||||
|
||||
it("keeps the selected row's title readable", () => {
|
||||
const onSidebar = contrastRatio(colors.foreground, colors.surfaceSidebar);
|
||||
const onSelected = contrastRatio(colors.foreground, colors.surfaceSidebarSelected);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Platform, type ViewStyle } from "react-native";
|
||||
import { isWeb } from "@/constants/platform";
|
||||
import { darkHighlightColors, lightHighlightColors } from "@getpaseo/highlight";
|
||||
import { deriveSurfaceStates } from "./derive-colors";
|
||||
import { deriveSurfaceStates, deriveTreeGuide } from "./derive-colors";
|
||||
|
||||
export const baseColors = {
|
||||
// Base colors
|
||||
@@ -276,6 +276,7 @@ export function buildLightSemanticColors(tint: LightThemeConfig) {
|
||||
surfaceSidebarSelected: tint.surfaceSidebarSelected ?? sidebarStates.selected,
|
||||
foregroundSidebarHover: tint.foregroundSidebarHover ?? tint.foregroundExtraMuted,
|
||||
foregroundSidebarSelected: tint.foregroundSidebarSelected ?? tint.foregroundExtraMuted,
|
||||
treeGuide: deriveTreeGuide(tint.surfaceSidebar, tint.foreground, "light"),
|
||||
surfaceWorkspace: tint.surface0,
|
||||
interactionHighlight: "rgba(0, 0, 0, 0.06)",
|
||||
|
||||
@@ -404,6 +405,7 @@ export function buildDarkSemanticColors(tint: DarkThemeConfig) {
|
||||
surfaceSidebarSelected: tint.surfaceSidebarSelected ?? sidebarStates.selected,
|
||||
foregroundSidebarHover: tint.foregroundSidebarHover ?? tint.foregroundExtraMuted,
|
||||
foregroundSidebarSelected: tint.foregroundSidebarSelected ?? tint.foregroundExtraMuted,
|
||||
treeGuide: deriveTreeGuide(tint.surfaceSidebar, foreground, "dark"),
|
||||
surfaceWorkspace: tint.surface1,
|
||||
interactionHighlight: "rgba(255, 255, 255, 0.08)",
|
||||
|
||||
|
||||
@@ -159,6 +159,22 @@ export function stepContrast(hex: string, toward: string, ratio: number): string
|
||||
return `#${channels.join("")}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* `ink` made translucent enough to sit at `ratio` WCAG contrast from `surface` once painted on it.
|
||||
* Unlike `stepContrast`, the result follows whatever it is painted over, so it keeps its weight on
|
||||
* neighbouring surfaces too.
|
||||
*/
|
||||
export function translucentStep(surface: string, ink: string, ratio: number): string {
|
||||
let low = 0;
|
||||
let high = 1;
|
||||
for (let step = 0; step < 8; step += 1) {
|
||||
const middle = (low + high) / 2;
|
||||
if (contrastRatio(surface, mixHexColors(surface, ink, middle)) < ratio) low = middle;
|
||||
else high = middle;
|
||||
}
|
||||
return hexColorWithAlpha(mixHexColors(ink, ink, 0), Number(high.toFixed(3)));
|
||||
}
|
||||
|
||||
/** Blends `hex` toward `toward` by `amount` (0 keeps `hex`, 1 is `toward`) in sRGB. */
|
||||
export function mixHexColors(hex: string, toward: string, amount: number): string {
|
||||
const from = requireRgb(hex);
|
||||
|
||||
@@ -2672,11 +2672,19 @@ it.each([false, true])(
|
||||
process.stdout.write(Array.from({ length: count }, nextRow).join(""));
|
||||
}
|
||||
process.stdout.write("READY\\r\\n");
|
||||
// A PTY can split one input write across reads (ConPTY does on Windows),
|
||||
// so match commands against everything read so far, not one chunk.
|
||||
let input = "";
|
||||
process.stdin.on("data", data => {
|
||||
if(data.toString().includes("BURST")) {
|
||||
input += data.toString();
|
||||
if (input.includes("BURST")) {
|
||||
input = "";
|
||||
for (let i = 0; i < 4000; i++) process.stdout.write(nextRow());
|
||||
process.stdout.write("BURST-DONE\\r\\n");
|
||||
} else process.stdout.write("ECHO:" + data.toString() + "\\r\\n");
|
||||
} else if (input.includes("AFTER-CATCH-UP")) {
|
||||
input = "";
|
||||
process.stdout.write("ECHO:AFTER-CATCH-UP\\r\\n");
|
||||
}
|
||||
});
|
||||
setInterval(()=>{},1000);
|
||||
`),
|
||||
|
||||
Reference in New Issue
Block a user