Translate commit AI prompts, model labels, and git/keychain errors to English so the app and generated messages are consistent. Also add a discard confirmation dialog and update the UI text/styles to match the new flow. - src-tauri/crates/commit_ai/src/cloud.rs - Translate HTTP and API error messages to English. - Keep request timeout and token sizing behavior unchanged. - src-tauri/crates/commit_ai/src/lib.rs - Translate model labels, prompt text, and validation errors. - Keep diff truncation and message sanitization logic intact. - src-tauri/src/git.rs - Translate git, credential, merge, and history errors. - Update AI provider validation messages to English. - src/lib/components/* - Update AI settings, commit panel, credential, and loading UI text. - Add discard confirmation dialog for destructive actions. - src/App.svelte, src/app.css - Adjust app layout and styling for the new dialog and text changes.
75 lines
2.5 KiB
Svelte
75 lines
2.5 KiB
Svelte
<script lang="ts">
|
|
import { AlertTriangle, LoaderCircle, RotateCcw, X } from "@lucide/svelte";
|
|
import type { GitFileStatus } from "../types";
|
|
|
|
interface Props {
|
|
file: GitFileStatus;
|
|
staged: boolean;
|
|
scope: "file" | "hunk";
|
|
isBusy: boolean;
|
|
onConfirm: () => void | Promise<void>;
|
|
onClose: () => void;
|
|
}
|
|
|
|
let {
|
|
file,
|
|
staged = false,
|
|
scope = "file",
|
|
isBusy = false,
|
|
onConfirm = () => {},
|
|
onClose = () => {},
|
|
}: Props = $props();
|
|
|
|
let targetPath = $derived(file.old_path ? `${file.old_path} -> ${file.path}` : file.path);
|
|
let title = $derived(scope === "hunk" ? "Discard hunk?" : "Discard file changes?");
|
|
let scopeLabel = $derived(scope === "hunk" ? "Selected hunk" : "File changes");
|
|
let sourceLabel = $derived(staged ? "staged changes" : "unstaged changes");
|
|
|
|
function closeFromBackdrop(event: MouseEvent) {
|
|
if (isBusy || event.target !== event.currentTarget) return;
|
|
onClose();
|
|
}
|
|
</script>
|
|
|
|
<div class="dialog-backdrop" role="presentation" onclick={closeFromBackdrop}>
|
|
<div class="dialog discard-confirm-dialog" role="dialog" aria-modal="true" aria-label={title}>
|
|
<header class="dialog-header">
|
|
<div>
|
|
<span class="eyebrow">Confirm discard</span>
|
|
<p class="dialog-title">{title}</p>
|
|
</div>
|
|
<button class="btn-sm dialog-close" type="button" onclick={onClose} disabled={isBusy} aria-label="Close">
|
|
<X size={16} aria-hidden="true" />
|
|
</button>
|
|
</header>
|
|
|
|
<div class="discard-confirm-body">
|
|
<div class="discard-warning-icon" aria-hidden="true">
|
|
<AlertTriangle size={22} />
|
|
</div>
|
|
|
|
<div class="discard-confirm-copy">
|
|
<p>
|
|
This will reset the {sourceLabel} for the {scopeLabel.toLowerCase()} below.
|
|
</p>
|
|
<code class="discard-target" title={targetPath}>{targetPath}</code>
|
|
<p class="discard-warning-text">
|
|
This cannot be undone. If the file only exists in your working tree, it can be deleted entirely.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<footer class="discard-confirm-actions">
|
|
<button class="btn-secondary" type="button" onclick={onClose} disabled={isBusy}>Cancel</button>
|
|
<button class="btn-danger" type="button" onclick={onConfirm} disabled={isBusy}>
|
|
{#if isBusy}
|
|
<LoaderCircle class="spin" size={15} aria-hidden="true" />
|
|
{:else}
|
|
<RotateCcw size={15} aria-hidden="true" />
|
|
{/if}
|
|
Discard
|
|
</button>
|
|
</footer>
|
|
</div>
|
|
</div>
|