fix(usage): preserve platform test contracts

This commit is contained in:
Mohamed Boudra
2026-09-26 23:15:22 +02:00
parent ef90b8e313
commit fa90f6726c
5 changed files with 21 additions and 12 deletions
@@ -11,6 +11,7 @@ interface PageLayoutProps {
/** Compact back button. Defaults to navigating back. */
onBack?: () => void;
testID?: string;
titleTestID?: string;
children: ReactNode;
}
@@ -19,7 +20,7 @@ interface PageLayoutProps {
* document heading inside the page and the header only keeps the titlebar drag
* region and window controls; on compact the title moves into a back header.
*/
export function PageLayout({ title, onBack, testID, children }: PageLayoutProps) {
export function PageLayout({ title, onBack, testID, titleTestID, children }: PageLayoutProps) {
const isCompact = useIsCompactFormFactor();
const insets = useSafeAreaInsets();
const scrollContentStyle = useMemo(() => ({ paddingBottom: insets.bottom }), [insets.bottom]);
@@ -31,7 +32,7 @@ export function PageLayout({ title, onBack, testID, children }: PageLayoutProps)
<ScrollView style={styles.scroll} contentContainerStyle={scrollContentStyle} testID={testID}>
<View style={styles.content}>
{showTitle ? (
<Text style={styles.title} testID="page-title">
<Text style={styles.title} testID={titleTestID ?? "page-title"}>
{title}
</Text>
) : null}
+3 -1
View File
@@ -1478,7 +1478,9 @@ export default function SettingsScreen({ view, openAddHostIntent = null }: Setti
</WindowChromeRegion>
<WindowChromeRegion corners="top-right">
<View style={desktopStyles.contentPane} testID="settings-detail-pane">
<PageLayout title={detailTitle}>{content}</PageLayout>
<PageLayout title={detailTitle} titleTestID="settings-detail-header-title">
{content}
</PageLayout>
</View>
</WindowChromeRegion>
</View>
@@ -242,13 +242,18 @@ test("named profile ignores agent override and uses existing XDG profile data",
);
profileDb.close();
expect(
resolveOmpUsageReference("session-1", "openai-codex", {
OMP_PROFILE: "work",
PI_PROFILE: "other",
PI_CODING_AGENT_DIR: f.agentDir,
PI_CONFIG_DIR: join(root, "config"),
XDG_DATA_HOME: join(root, "xdg"),
}),
resolveOmpUsageReference(
"session-1",
"openai-codex",
{
OMP_PROFILE: "work",
PI_PROFILE: "other",
PI_CODING_AGENT_DIR: f.agentDir,
PI_CONFIG_DIR: join(root, "config"),
XDG_DATA_HOME: join(root, "xdg"),
},
"linux",
),
).toEqual({ source: "codex", input: { accessToken: "profile-token" } });
});
@@ -129,6 +129,7 @@ export function resolveOmpUsageReference(
sessionId: string,
provider: string,
env: NodeJS.ProcessEnv,
platform: NodeJS.Platform = process.platform,
): UsageReference | null {
let source: string;
if (provider === "openai-codex") source = "codex";
@@ -136,7 +137,7 @@ export function resolveOmpUsageReference(
else return null;
if (!sessionId) return null;
// Upstream: packages/utils/src/dirs.ts:82-94,330-343,583-585 (profile, override, agent dir).
const paths = resolveOmpDiagnosticPaths(env);
const paths = resolveOmpDiagnosticPaths(env, undefined, platform);
if (hasKeyOverride(provider, env, paths.agentDir)) return null;
let db: UsageDb;
try {
@@ -29,7 +29,7 @@ async function checkInternalPluginBoundary(directory: string): Promise<void> {
if (hostModules.has(specifier) || isBuiltin(specifier)) continue;
const resolved = reader.resolve(specifier, file, dependency.kind);
const relative = resolved && path.relative(directory, resolved);
const owned = relative && /^(server|shared)\//.test(relative);
const owned = relative && /^(server|shared)[\\/]/.test(relative);
if (!specifier.startsWith(".") || !owned) {
throw new Error(`Internal plugin import boundary: ${file} imports ${specifier}`);
}