Files
paseo/packages/app/src/git/pull-request-connection.tsx
T
Mohamed Boudra a264f41d4a feat(app): retain Explorer across layout and appearance changes
Keep one workspace Explorer host and destination-aware navigation so folding, theme updates and compact sheets preserve the current panel. Scope pull request discovery and timeline demand to active surfaces.
2026-10-19 16:57:57 +02:00

28 lines
1.1 KiB
TypeScript

import { createContext, useContext, type ReactNode } from "react";
import type { DaemonClient } from "@getpaseo/client/internal/daemon-client";
import { useHostRuntimeClient, useHostRuntimeIsConnected } from "@/runtime/host-runtime";
export interface PullRequestConnection {
client: Pick<DaemonClient, "checkoutPrStatus" | "pullRequestTimeline"> | null;
isConnected: boolean;
}
const ConnectionContext = createContext<((serverId: string) => PullRequestConnection) | null>(null);
/** Supplies the PR read connection, shared by discovery, rail status and timeline content. */
export function PullRequestConnectionProvider({
connection,
children,
}: {
connection: (serverId: string) => PullRequestConnection;
children: ReactNode;
}) {
return <ConnectionContext value={connection}>{children}</ConnectionContext>;
}
export function usePullRequestConnection(serverId: string): PullRequestConnection {
const supplied = useContext(ConnectionContext);
const client = useHostRuntimeClient(serverId);
const isConnected = useHostRuntimeIsConnected(serverId);
return supplied ? supplied(serverId) : { client, isConnected };
}