add some features

This commit is contained in:
2026-06-27 23:47:15 +02:00
parent 5b44a65e51
commit 433085a895
6 changed files with 623 additions and 18 deletions
+59 -9
View File
@@ -7,6 +7,7 @@
import CommitPanel from "./lib/components/CommitPanel.svelte";
import CompareDialog from "./lib/components/CompareDialog.svelte";
import ComparePanel from "./lib/components/ComparePanel.svelte";
import CredentialDialog from "./lib/components/CredentialDialog.svelte";
import ExplorerPanel from "./lib/components/ExplorerPanel.svelte";
import FileHistoryPanel from "./lib/components/FileHistoryPanel.svelte";
import HistoryPanel from "./lib/components/HistoryPanel.svelte";
@@ -79,6 +80,10 @@
let preparedResolutions: Record<string, PreparedResolution> = {};
let autoRefreshEnabled = true;
let autoRefreshInFlight = false;
let credDialogOpen = false;
let credDialogAction: "push" | "pull" | null = null;
let credDialogError = "";
let sessionCredentials: { username: string; password: string } | null = null;
let lastStatusFingerprint = "";
const AUTO_REFRESH_INTERVAL = 4000;
let autoRefreshTimer: ReturnType<typeof setInterval> | undefined;
@@ -265,26 +270,60 @@
});
}
async function pullRepo() {
function openCredentialDialog(action: "push" | "pull") {
if (!activeRepoPath) return;
credDialogError = "";
credDialogAction = action;
credDialogOpen = true;
}
async function doActualPull(username: string, password: string) {
errorMessage = "";
await runOperation("Pulling", async () => {
applyStatus(await pull(activeRepoPath));
applyStatus(await pull(activeRepoPath, username, password));
await refreshBranchList(activeRepoPath);
await refreshCommitHistory(activeRepoPath);
await refreshExplorerFiles(activeRepoPath);
await refreshFileHistory(activeRepoPath);
});
if (errorMessage) { credDialogError = errorMessage; errorMessage = ""; }
else { credDialogOpen = false; credDialogAction = null; }
}
async function doActualPush(username: string, password: string) {
errorMessage = "";
await runOperation("Pushing", async () => {
applyStatus(await push(activeRepoPath, username, password));
await refreshBranchList(activeRepoPath);
await refreshCommitHistory(activeRepoPath);
await refreshFileHistory(activeRepoPath);
});
if (errorMessage) { credDialogError = errorMessage; errorMessage = ""; }
else { credDialogOpen = false; credDialogAction = null; }
}
async function handleCredentialSubmit(username: string, password: string, save: boolean) {
if (credDialogAction === "pull") await doActualPull(username, password);
else if (credDialogAction === "push") await doActualPush(username, password);
if (!credDialogOpen && save) sessionCredentials = { username, password };
}
async function pullRepo() {
if (!activeRepoPath) return;
if (sessionCredentials) {
await doActualPull(sessionCredentials.username, sessionCredentials.password);
} else {
openCredentialDialog("pull");
}
}
async function pushRepo() {
if (!activeRepoPath) return;
await runOperation("Pushing", async () => {
applyStatus(await push(activeRepoPath));
await refreshBranchList(activeRepoPath);
await refreshCommitHistory(activeRepoPath);
await refreshExplorerFiles(activeRepoPath);
await refreshFileHistory(activeRepoPath);
});
if (sessionCredentials) {
await doActualPush(sessionCredentials.username, sessionCredentials.password);
} else {
openCredentialDialog("push");
}
}
// ── File staging / restore ─────────────────────────────────────────────────
@@ -697,6 +736,17 @@
/>
{/if}
<!-- Credential dialog for push/pull -->
{#if credDialogOpen && credDialogAction}
<CredentialDialog
action={credDialogAction}
error={credDialogError}
{isBusy}
onSubmit={handleCredentialSubmit}
onCancel={() => { credDialogOpen = false; credDialogAction = null; credDialogError = ""; }}
/>
{/if}
<!-- Conflict resolve dialog -->
{#if resolveDialogOpen}
<ResolveDialog