This commit is contained in:
2026-05-26 18:15:37 +03:00
parent 0b6f61623e
commit ee08e2f3dd
15 changed files with 13702 additions and 7702 deletions

View File

@@ -3,17 +3,22 @@
<!-- @LAYER UI -->
<!-- @RELATION DEPENDS_ON -> [GitUtils] -->
<!-- @RELATION CALLS -> [EXT:frontend:gitService] -->
<!-- @UX_STATE Idle -> Commit form with diff viewer. -->
<!-- @PRE hasWorkspaceChanges and workspaceDiff are propagated from GitManager. -->
<!-- @UX_STATE Idle -> "Нет изменений" placeholder when !hasWorkspaceChanges. -->
<!-- @UX_STATE Changes -> workspaceDiff rendered when hasWorkspaceChanges && workspaceDiff. -->
<!-- @UX_STATE Loading -> GeneratingMessage spinner, workspace loading. -->
<!-- @UX_STATE Error -> Toast on failure. -->
<script>
import { t } from "$lib/i18n";
import { Button } from "$lib/ui";
import * as Diff2Html from 'diff2html';
import 'diff2html/bundles/css/diff2html.min.css';
let {
hasWorkspaceChanges,
changedFilesCount,
workspaceLoading,
workspaceDiff = '',
committing,
generatingMessage,
commitMessage = $bindable(),
@@ -24,6 +29,16 @@
onGenerateMessage,
onCommit,
} = $props();
// ── Render diff as HTML via diff2html ──
let diffHtml = $derived(workspaceDiff
? Diff2Html.html(workspaceDiff, {
outputFormat: 'side-by-side',
drawFileList: true,
matching: 'lines',
highlight: true,
})
: '');
</script>
<div class="grid grid-cols-1 gap-4 lg:grid-cols-2">
@@ -85,6 +100,10 @@
<div class="h-4 animate-pulse rounded bg-slate-200"></div>
{/each}
</div>
{:else if hasWorkspaceChanges && diffHtml}
<div class="diff-view">{@html diffHtml}</div>
{:else if hasWorkspaceChanges}
<pre class="overflow-x-auto whitespace-pre-wrap font-mono text-xs leading-relaxed text-slate-500">Загрузка diff... (повторите синхронизацию)</pre>
{:else}
<div class="flex h-full items-center justify-center text-sm text-slate-500">
Нет изменений для коммита