<script lang="ts">
import { getFleetDiff } from "../../api/client.js";
import UnifiedDiff from "./UnifiedDiff.svelte";
import { viewWorktree } from "../../stores/worktree-scope.svelte.js";
interface Props {
path: string;
repoPath: string | null;
}
let { path, repoPath }: Props = $props();
const worktree = viewWorktree("the diff view");
let diff = $state<string | null>(null);
let error = $state<string | null>(null);
let loading = $state(true);
$effect(() => {
// Re-fetch whenever path or repoPath changes.
void (async () => {
loading = true;
error = null;
diff = null;
try {
diff = await getFleetDiff(path, repoPath, worktree);
} catch (e) {
error = e instanceof Error ? e.message : String(e);
} finally {
loading = false;
}
})();
});
</script>
<UnifiedDiff
{diff}
{loading}
{error}
emptyMessage="No changes relative to HEAD."
/>