The Windows overlay badge now renders a single combined number and includes an additional “changes” component in the total. This makes the badge more informative while keeping the icon compact and legible across small sizes. - Simplify badge rendering to one circle with centered text - Extend the Tauri command and frontend call to pass changes count
282 lines
8.1 KiB
TypeScript
282 lines
8.1 KiB
TypeScript
import { invoke } from "@tauri-apps/api/core";
|
|
|
|
import type {
|
|
CommitAiLocalProfile,
|
|
CommitAiProvider,
|
|
CommitAiStatus,
|
|
ConflictFile,
|
|
GitBranch,
|
|
GitCommit,
|
|
GitCommitComparison,
|
|
GitRepositoryFile,
|
|
GitSearchHit,
|
|
GitStatus,
|
|
LocalModelOption,
|
|
PatchApplyAction,
|
|
RepositoryBundle,
|
|
StoredCredential,
|
|
} from "./types";
|
|
|
|
export function openRepository(path: string): Promise<GitStatus> {
|
|
return invoke<GitStatus>("open_repository", { path });
|
|
}
|
|
|
|
export function openRepoInExplorer(path: string): Promise<void> {
|
|
return invoke<void>("open_repo_in_explorer", { path });
|
|
}
|
|
|
|
export function openRepositoryFile(path: string, file: string): Promise<void> {
|
|
return invoke<void>("open_repository_file", { path, file });
|
|
}
|
|
|
|
export function openRepositoryBundle(path: string, commitLimit = 100): Promise<RepositoryBundle> {
|
|
return invoke<RepositoryBundle>("open_repository_bundle", { path, commitLimit });
|
|
}
|
|
|
|
export function getStatus(path: string): Promise<GitStatus> {
|
|
return invoke<GitStatus>("get_status", { path });
|
|
}
|
|
|
|
// Sets the taskbar icon badge to ahead + behind + changed status files (0 clears it). Windows only — a no-op on
|
|
// other platforms, since Windows has no native numeric badge to fall back to.
|
|
export function setSyncBadge(ahead: number, behind: number, changes: number): Promise<void> {
|
|
return invoke<void>("set_sync_badge", { ahead, behind, changes });
|
|
}
|
|
|
|
export function listBranches(path: string): Promise<GitBranch[]> {
|
|
return invoke<GitBranch[]>("list_branches", { path });
|
|
}
|
|
|
|
export function checkoutBranch(path: string, branch: string): Promise<GitStatus> {
|
|
return invoke<GitStatus>("checkout_branch", { path, branch });
|
|
}
|
|
|
|
export function createBranch(
|
|
path: string,
|
|
branch: string,
|
|
startPoint?: string,
|
|
): Promise<GitStatus> {
|
|
return invoke<GitStatus>("create_branch", { path, branch, startPoint: startPoint ?? null });
|
|
}
|
|
|
|
export function renameBranch(
|
|
path: string,
|
|
oldBranch: string,
|
|
newBranch: string,
|
|
): Promise<GitStatus> {
|
|
return invoke<GitStatus>("rename_branch", { path, oldBranch, newBranch });
|
|
}
|
|
|
|
export function deleteBranch(path: string, branch: string): Promise<GitStatus> {
|
|
return invoke<GitStatus>("delete_branch", { path, branch });
|
|
}
|
|
|
|
export function stageFiles(path: string, files: string[]): Promise<GitStatus> {
|
|
return invoke<GitStatus>("stage_files", { path, files });
|
|
}
|
|
|
|
export function unstageFiles(path: string, files: string[]): Promise<GitStatus> {
|
|
return invoke<GitStatus>("unstage_files", { path, files });
|
|
}
|
|
|
|
export function restoreFiles(
|
|
path: string,
|
|
files: string[],
|
|
staged: boolean,
|
|
): Promise<GitStatus> {
|
|
return invoke<GitStatus>("restore_files", { path, files, staged });
|
|
}
|
|
|
|
export function getFilePatch(path: string, file: string, staged: boolean): Promise<string> {
|
|
return invoke<string>("get_file_patch", { path, file, staged });
|
|
}
|
|
|
|
export function applyFilePatch(
|
|
path: string,
|
|
file: string,
|
|
patch: string,
|
|
action: PatchApplyAction,
|
|
): Promise<GitStatus> {
|
|
return invoke<GitStatus>("apply_file_patch", { path, file, patch, action });
|
|
}
|
|
|
|
export function commit(path: string, message: string): Promise<GitStatus> {
|
|
return invoke<GitStatus>("commit", { path, message });
|
|
}
|
|
|
|
export function commitAiStatus(): Promise<CommitAiStatus> {
|
|
return invoke<CommitAiStatus>("commit_ai_status");
|
|
}
|
|
|
|
export function commitAiLoad(modelId: string): Promise<void> {
|
|
return invoke<void>("commit_ai_load", { modelId });
|
|
}
|
|
|
|
export function commitAiLocalModels(): Promise<LocalModelOption[]> {
|
|
return invoke<LocalModelOption[]>("commit_ai_local_models");
|
|
}
|
|
|
|
export interface CommitAiGenerateOptions {
|
|
notes?: string;
|
|
provider: CommitAiProvider;
|
|
localProfile?: CommitAiLocalProfile;
|
|
model?: string;
|
|
apiKey?: string;
|
|
baseUrl?: string;
|
|
}
|
|
|
|
export function commitAiGenerate(path: string, options: CommitAiGenerateOptions): Promise<string> {
|
|
return invoke<string>("commit_ai_generate", {
|
|
path,
|
|
notes: options.notes,
|
|
provider: options.provider,
|
|
localProfile: options.localProfile,
|
|
model: options.model,
|
|
apiKey: options.apiKey,
|
|
baseUrl: options.baseUrl,
|
|
});
|
|
}
|
|
|
|
export function pull(path: string, username?: string, password?: string): Promise<GitStatus> {
|
|
return invoke<GitStatus>("pull", { path, username: username ?? null, password: password ?? null });
|
|
}
|
|
|
|
export function fetchRemote(path: string, username?: string, password?: string): Promise<GitStatus> {
|
|
return invoke<GitStatus>("fetch", { path, username: username ?? null, password: password ?? null });
|
|
}
|
|
|
|
export function push(path: string, username?: string, password?: string): Promise<GitStatus> {
|
|
return invoke<GitStatus>("push", { path, username: username ?? null, password: password ?? null });
|
|
}
|
|
|
|
export function getRemoteUrl(path: string): Promise<string | null> {
|
|
return invoke<string | null>("get_remote_url", { path });
|
|
}
|
|
|
|
export function credLoad(key: string): Promise<StoredCredential | null> {
|
|
return invoke<StoredCredential | null>("cred_load", { key });
|
|
}
|
|
|
|
export function credSave(
|
|
key: string,
|
|
username: string,
|
|
password: string,
|
|
expiresAt: string | null,
|
|
): Promise<void> {
|
|
return invoke<void>("cred_save", { key, username, password, expiresAt });
|
|
}
|
|
|
|
export function credDelete(key: string): Promise<void> {
|
|
return invoke<void>("cred_delete", { key });
|
|
}
|
|
|
|
export function listCommits(path: string, limit = 100): Promise<GitCommit[]> {
|
|
return invoke<GitCommit[]>("list_commits", { path, limit });
|
|
}
|
|
|
|
export function restoreToCommit(path: string, commit: string): Promise<GitStatus> {
|
|
return invoke<GitStatus>("restore_to_commit", { path, commit });
|
|
}
|
|
|
|
export function restoreFileFromCommit(
|
|
path: string,
|
|
commit: string,
|
|
file: string,
|
|
): Promise<GitStatus> {
|
|
return invoke<GitStatus>("restore_file_from_commit", { path, commit, file });
|
|
}
|
|
|
|
export function mergeBranch(path: string, branch: string): Promise<GitStatus> {
|
|
return invoke<GitStatus>("merge_branch", { path, branch });
|
|
}
|
|
|
|
export function listRepositoryFiles(path: string): Promise<GitRepositoryFile[]> {
|
|
return invoke<GitRepositoryFile[]>("list_repository_files", { path });
|
|
}
|
|
|
|
export function listFileHistory(
|
|
path: string,
|
|
file: string,
|
|
limit = 100,
|
|
requestId?: string,
|
|
): Promise<GitCommit[]> {
|
|
return invoke<GitCommit[]>("list_file_history", { path, file, limit, requestId: requestId ?? null });
|
|
}
|
|
|
|
export function cancelFileHistory(requestId: string): Promise<void> {
|
|
return invoke<void>("cancel_file_history", { requestId });
|
|
}
|
|
|
|
export function compareCommits(
|
|
path: string,
|
|
from: string,
|
|
to: string,
|
|
): Promise<GitCommitComparison> {
|
|
return invoke<GitCommitComparison>("compare_commits", { path, from, to });
|
|
}
|
|
|
|
export function diffFileAgainstWorkingTree(
|
|
path: string,
|
|
commit: string,
|
|
file: string,
|
|
): Promise<GitCommitComparison> {
|
|
return invoke<GitCommitComparison>("diff_file_against_working_tree", { path, commit, file });
|
|
}
|
|
|
|
export function compareFileToHead(
|
|
path: string,
|
|
commit: string,
|
|
file: string,
|
|
): Promise<GitCommitComparison> {
|
|
return invoke<GitCommitComparison>("compare_file_to_head", { path, commit, file });
|
|
}
|
|
|
|
export function compareFileToParent(
|
|
path: string,
|
|
commit: string,
|
|
file: string,
|
|
oldFile: string | null = null,
|
|
): Promise<GitCommitComparison> {
|
|
return invoke<GitCommitComparison>("compare_file_to_parent", { path, commit, file, oldFile });
|
|
}
|
|
|
|
export function searchCodeIntroductions(
|
|
path: string,
|
|
query: string,
|
|
caseSensitive = false,
|
|
limit = 250,
|
|
searchId?: string,
|
|
): Promise<GitSearchHit[]> {
|
|
return invoke<GitSearchHit[]>("search_code_introductions", {
|
|
path,
|
|
query,
|
|
caseSensitive,
|
|
limit,
|
|
searchId: searchId ?? null,
|
|
});
|
|
}
|
|
|
|
export function cancelCodeSearch(searchId: string): Promise<void> {
|
|
return invoke<void>("cancel_code_search", { searchId });
|
|
}
|
|
|
|
export function readConflict(path: string, file: string): Promise<ConflictFile> {
|
|
return invoke<ConflictFile>("read_conflict", { path, file });
|
|
}
|
|
|
|
export function resolveConflict(
|
|
path: string,
|
|
file: string,
|
|
content: string,
|
|
): Promise<GitStatus> {
|
|
return invoke<GitStatus>("resolve_conflict", { path, file, content });
|
|
}
|
|
|
|
export function resolveConflictSide(
|
|
path: string,
|
|
file: string,
|
|
side: "ours" | "theirs",
|
|
): Promise<GitStatus> {
|
|
return invoke<GitStatus>("resolve_conflict_side", { path, file, side });
|
|
}
|