open-swe/ui/src/components/agents/utils/diffStats.ts
Christian Bromann abf354bb05
feat(open-swe): stream agent chat via @langchain/react v2 protocol (#1475)
* feat(dashboard): stream agent chat via @langchain/react v2 protocol

Replace the bespoke SSE + React Query polling path with LangGraph’s
v2 event stream through credentialed dashboard proxies. Run starts go
through stream commands; mid-run follow-ups still queue via /messages.

* fix import path

* fix tests after rebase

* format

* PR feedback

* improved model fallback

* fix image handling

* embrace sdk

* cleanup

* cr

* more cleanup

* fix cors

* harden security

---------

Co-authored-by: open-swe[bot] <215916821+open-swe[bot]@users.noreply.github.com>
Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-06-11 09:54:35 -07:00

20 lines
556 B
TypeScript

import { parseDiffFromFile } from "@pierre/diffs";
export function countLineChanges(
originalContent: string | null | undefined,
newContent: string,
filePath = "file",
): { additions: number; deletions: number } {
const meta = parseDiffFromFile(
{ name: filePath, contents: originalContent ?? "" },
{ name: filePath, contents: newContent },
);
let additions = 0;
let deletions = 0;
for (const hunk of meta.hunks) {
additions += hunk.additionLines;
deletions += hunk.deletionLines;
}
return { additions, deletions };
}