Introduce a PR tab in the explorer sidebar that shows status checks, reviews, and the merged timeline for the current branch's pull request. Extend checkout PR status with number, draft flag, repo identity, and per-check workflow/duration; add a new pull_request_timeline request/response pair backed by a GraphQL query; enrich the workspace git snapshot to carry the fields through to the client; and extend the checkout-git-actions store so timeline queries are invalidated alongside status when mutations land.
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
export type ExplorerTab = "changes" | "files" | "pr";
|
|
|
|
export function isExplorerTab(value: unknown): value is ExplorerTab {
|
|
return value === "changes" || value === "files" || value === "pr";
|
|
}
|
|
|
|
export function buildExplorerCheckoutKey(serverId: string, cwd: string): string | null {
|
|
const trimmedServerId = serverId.trim();
|
|
const trimmedCwd = cwd.trim();
|
|
if (!trimmedServerId || !trimmedCwd) {
|
|
return null;
|
|
}
|
|
return `${trimmedServerId}::${trimmedCwd}`;
|
|
}
|
|
|
|
export function coerceExplorerTabForCheckout(tab: ExplorerTab, isGit: boolean): ExplorerTab {
|
|
if (!isGit && tab === "changes") {
|
|
return "files";
|
|
}
|
|
return tab;
|
|
}
|
|
|
|
export function resolveExplorerTabForCheckout(params: {
|
|
serverId: string;
|
|
cwd: string;
|
|
isGit: boolean;
|
|
explorerTabByCheckout: Record<string, ExplorerTab>;
|
|
}): ExplorerTab {
|
|
const key = buildExplorerCheckoutKey(params.serverId, params.cwd);
|
|
const stored = key ? params.explorerTabByCheckout[key] : null;
|
|
const defaultTab: ExplorerTab = params.isGit ? "changes" : "files";
|
|
const nextTab = stored && isExplorerTab(stored) ? stored : defaultTab;
|
|
return coerceExplorerTabForCheckout(nextTab, params.isGit);
|
|
}
|