Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121import type { ChangedFile, EgressMode, EgressSettingsInfo, ExecTarget, ExternalFile, IndexInfo, IntelKind, IntelQuery, IntelResult, ProjectInfo, FileView, MarkdownBlock, RemoteImage, BranchStat, GitRef, RecentRepo, RepoInfo, RepoSource, Subject, SandboxEvent, SandboxInfo, TreeEntry} from '../shared/types'import type { ReviewApi, ReviewChange } from '../shared/reviews'import type { GithubAuthSource, GithubAuthStatus } from '../shared/github'import type { OpenedDestination } from '../shared/systems'import type { ConfigValue, SettingsSaveResult, SettingsSnapshot } from '../shared/settings'
export interface Api extends ReviewApi { // Reviews (docs/REVIEW-FORMAT.md): the ReviewApi methods, stored locally in the main process. /** The store changed (from any window, a fetch or an export); returns an unsubscribe function. */ onReviewsChanged(cb: (change: ReviewChange) => void): () => void /** Opens a destination's URL (a pull request, a merge request) for review: its repository, head and merge base (integrations §3). */ openDestination(url: string): Promise<{ repo: RepoInfo; subject: Subject; opened: OpenedDestination }> // GitHub. The token stays in the main process. githubStatus(host: string): Promise<GithubAuthStatus> githubSetSource(host: string, source: GithubAuthSource): Promise<GithubAuthStatus> /** Checks the token with GitHub, then saves it in the OS keychain. */ githubSaveToken(host: string, token: string): Promise<GithubAuthStatus> githubRemoveToken(host: string): Promise<GithubAuthStatus> pickFolder(): Promise<string | null> openRepo(source: RepoSource): Promise<RepoInfo> /** Repositories opened lately, newest first. */ recentRepos(): Promise<RecentRepo[]> /** Opens a repository without contacting a remote: fails for a clone that isn't cached. */ openRepoOffline(source: RepoSource): Promise<RepoInfo> forgetRepo(source: RepoSource): Promise<void> /** With a pull request subject, fetches it again too: that subject at its new head, when it moved. */ fetchRepo(id: string, subject?: Subject | null): Promise<{ info: RepoInfo; subject: Subject | null }> refs(id: string): Promise<GitRef[]> /** Commits ahead of `base` and files changed since the merge-base, per branch (short names). */ branchStats(id: string, base: string, branches: string[]): Promise<Record<string, BranchStat>> openSubject(id: string, head: string, base?: string): Promise<Subject> tree(subject: Subject): Promise<TreeEntry[]> changes(subject: Subject): Promise<ChangedFile[]> file(subject: Subject, path: string, withBase: boolean): Promise<FileView> /** An image at head as a data: URL (null if missing, too large or not an image). */ image(subject: Subject, path: string): Promise<string | null> /** Parses a Markdown file at head (or at base) in the review's sandbox; the HTML is untrusted. */ /** `dark`: diagrams are drawn for the dark theme. */ markdownRender(sandboxId: string, subject: Subject, path: string, side?: 'head' | 'base', opts?: { dark?: boolean }): Promise<MarkdownBlock[]> /** A remote image, fetched in the sandbox through the egress proxy; hosts off the allow-list are not asked. */ markdownRemoteImage(sandboxId: string, url: string): Promise<RemoteImage> sandboxStatus(): Promise<{ id: string; ok: boolean; reason?: string }[]> createSandbox(subject: Subject): Promise<SandboxInfo> disposeSandbox(id: string): Promise<void> exec(sandboxId: string, command: string, target: ExecTarget): Promise<string> /** Run `devcontainer up` inside the sandbox VM; returns the exec id of the build. */ devcontainerUp(sandboxId: string): Promise<string> kill(execId: string): Promise<void> /** SCIP indexes cached on the host for the review's head commit. */ intelStatus(subject: Subject): Promise<IndexInfo[]> /** Fetch dependencies and build SCIP indexes in the sandbox (default: projects with changes, then a few more); returns the exec id. */ intelIndex(sandboxId: string, subject: Subject, projectIds?: string[]): Promise<string> /** The review's projects: ecosystem, root, resolved version and where it came from. */ intelProjects(subject: Subject): Promise<ProjectInfo[]> /** Force a project's toolchain version for this repository (null: detect again). */ intelSetVersion(subject: Subject, projectId: string, version: string | null): Promise<ProjectInfo[]> /** Definition / references / hover: SCIP first, then a language server in the sandbox. */ intelQuery(kind: IntelKind, q: IntelQuery): Promise<IntelResult> /** Start the file's language server early (no-op when a SCIP index covers it). */ intelWarm(q: Omit<IntelQuery, 'line' | 'character'>): Promise<void> /** A dependency's file (from a definition outside the repo), read from the sandbox. */ intelExternal(ext: ExternalFile): Promise<FileView> /** Egress policy (app-wide): mode and the user's allow-list additions. Changes apply to running sandboxes. */ egressGet(): Promise<EgressSettingsInfo> egressSetMode(mode: EgressMode): Promise<EgressSettingsInfo> /** Add hostnames or `*.domain` patterns to the allow-list. */ egressAllow(patterns: string[]): Promise<EgressSettingsInfo> egressRemove(pattern: string): Promise<EgressSettingsInfo> onEgressChange(cb: (info: EgressSettingsInfo) => void): () => void /** Subscribe to exec output; returns an unsubscribe function. */ onSandboxEvent(cb: (e: SandboxEvent) => void): () => void
/** The settings page's rows; with a repo id, its per-clone and repository layers too. */ settingsGet(repoId?: string): Promise<SettingsSnapshot> /** Save to the user's config (null removes a key). All or nothing: any refused key writes nothing. */ settingsSave(changes: Record<string, ConfigValue | null>, repoId?: string): Promise<SettingsSaveResult> /** The value in effect for one key. */ settingsEffective(key: string, repoId?: string): Promise<ConfigValue> /** Open the user's config file in the default editor (creating it if needed). */ settingsOpenUserFile(): Promise<void> /** The repository's config file at its trusted tip, or null. */ settingsRepoFile(repoId: string): Promise<string | null> /** The user's config changed (a save, or an edit to the file). */ onSettingsChange(cb: () => void): () => void /** Settings… was chosen from the menu (⌘,). */ onMenuSettings(cb: () => void): () => void /** Back or Forward from the Go menu (⌘[ / ⌘]) or a trackpad swipe. */ onMenuNav(cb: (dir: 'back' | 'forward') => void): () => void /** A menu item with a key was used, by that key or by clicking the menu: `id` names it in the renderer's shortcuts.ts. */ onMenuShortcut(cb: (id: string, via: 'key' | 'menu') => void): () => void}
declare global { interface Window { api: Api }}