Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(agentic-ide): count files an agent changed by script once it commits them

rubenluetke10-beepb10fa943a38e
diff --git a/jarvis/agentic_ide/change_authors.py b/jarvis/agentic_ide/change_authors.py
index ce16b74927..629ba27c77 100644
--- a/jarvis/agentic_ide/change_authors.py
+++ b/jarvis/agentic_ide/change_authors.py
@@ -161,6 +161,9 @@ def _relative(raw: str, base: Path, root: Path) -> str | None:
return None if text in ("", ".") else text
+#: Public name for callers that resolve a record's paths themselves.
+relative_path = _relative
+
Reader = Callable[[PaneRecord], list[dict[str, Any]] | None]
@@ -226,25 +229,6 @@ def change_authors(
return by_path
-def first_write_ms(
- workspace_folder: str | Path,
- record: PaneRecord,
- *,
- reader: Reader = _read_events,
- now: float | None = None,
-) -> int:
- """When ``record``'s agent first wrote a file inside the workspace; 0 if never or unknown."""
- root = Path(workspace_folder).expanduser().resolve(strict=False)
- base = Path(record.folder or root).expanduser()
- moment = time.monotonic() if now is None else now
- firsts = [
- first
- for raw, (first, _last) in _pane_spans(record, reader, moment).items()
- if first and _relative(raw, base, root) is not None
- ]
- return min(firsts, default=0)
-
-
def authors_for(
path: str, is_directory: bool, by_path: dict[str, list[ChangeAuthor]]
) -> list[ChangeAuthor]:
diff --git a/jarvis/agentic_ide/git_changes.py b/jarvis/agentic_ide/git_changes.py
index 58cfdc0716..27e2bc6803 100644
--- a/jarvis/agentic_ide/git_changes.py
+++ b/jarvis/agentic_ide/git_changes.py
@@ -83,12 +83,19 @@ class FileDiff:
truncated: bool = False
-def _git(args: list[str], cwd: Path) -> subprocess.CompletedProcess[str] | None:
- """Run git; None when git is missing or does not answer in time."""
+def _git(
+ args: list[str], cwd: Path, stdin: str | None = None
+) -> subprocess.CompletedProcess[str] | None:
+ """Run git; None when git is missing or does not answer in time.
+
+ ``stdin`` is fed to git when given; otherwise git reads nothing, so a
+ command that would wait for input can never hang the caller.
+ """
try:
return subprocess.run(
["git", "-c", "core.quotePath=false", *args],
cwd=str(cwd),
+ input=stdin if stdin is not None else "",
capture_output=True,
text=True,
encoding="utf-8",
diff --git a/jarvis/agentic_ide/pane_changes.py b/jarvis/agentic_ide/pane_changes.py
index 2a8d95077c..0595c480c4 100644
--- a/jarvis/agentic_ide/pane_changes.py
+++ b/jarvis/agentic_ide/pane_changes.py
@@ -8,6 +8,13 @@ write: the last commit on the checkout's first-parent line made before that
moment (:func:`session_base`), diffed against the file on disk now. That
covers work the agent committed, work still uncommitted, and new files.
+Which files are the agent's (:func:`pane_work`): the ones its editing tools
+named, plus every file in the commits its own shell commands made — found by
+the ids those commands printed and the subjects they passed. That second half
+is what catches a file the agent changed with a script. Files
+``.gitattributes`` marks ``linguist-generated`` (a built bundle) are counted,
+not listed, so they cannot bury the agent's real changes.
+
Another agent's commits to the same files after that moment show up in the
diff too — git cannot split one file's history by author once it is merged
into one line. The file list itself stays this agent's own.
@@ -19,9 +26,14 @@ the repository root works the same.
from __future__ import annotations
+import json
import re
+from collections.abc import Iterable
+from dataclasses import dataclass, field
from pathlib import Path
+from typing import Any
+from . import change_authors
from .git_changes import (
MAX_CHANGED_FILES,
ChangedFile,
@@ -33,7 +45,6 @@ from .git_changes import (
_repo_prefix,
file_diff,
normalize_workspace_path,
- workspace_changes,
)
#: Paths handed to one git call; keeps the command line far below Windows' limit.
@@ -132,8 +143,25 @@ def pane_changes(
truncated = True
break
files.append(ChangedFile(path=path, status=word, added=added, removed=removed))
- pending = {item.path for item in workspace_changes(root, only=set(wanted)).files}
- return files, pending, truncated
+ return files, _pending(root, [item.path for item in files]), truncated
+
+
+def _pending(root: Path, paths: list[str]) -> set[str]:
+ """Which of ``paths`` git still reports as changed or untracked in the working tree."""
+ pending: set[str] = set()
+ _is_repo, prefix, _reason = _repo_prefix(root)
+ for chunk in _chunks(paths):
+ status = _git(
+ ["status", "--porcelain=v1", "-z", "--no-renames", "--untracked-files=all"]
+ + ["--", *chunk],
+ root,
+ )
+ if status is None or status.returncode != 0:
+ continue
+ for record in status.stdout.split("\0"):
+ if len(record) >= 4 and record[3:].startswith(prefix):
+ pending.add(record[3 + len(prefix) :])
+ return pending
def pane_file_diff(folder: str | Path, path: str, base: str) -> FileDiff:
@@ -169,4 +197,207 @@ def pane_file_diff(folder: str | Path, path: str, base: str) -> FileDiff:
)
-__all__ = ["BASE_PATTERN", "pane_changes", "pane_file_diff", "session_base"]
+#: A tool that runs a shell command: Bash, PowerShell, Codex's shell, exec tools.
+_SHELL_TOOL = re.compile(r"bash|shell|powershell|pwsh|exec|command|terminal", re.IGNORECASE)
+#: git commit's summary line: ``[main 4f7ae66] subject`` or ``[main (root-commit) 4f7ae66]``.
+_COMMIT_SUMMARY = re.compile(r"^\[[^\]\n]*?\b([0-9a-f]{7,40})\]", re.MULTILINE)
+#: A full commit id printed by a script around ``git commit-tree`` and the like.
+_FULL_ID = re.compile(r"\b[0-9a-f]{40}\b")
+#: ``-m "…"`` / ``-am '…'`` / ``--message=…`` in a commit command.
+_MESSAGE_FLAG = re.compile(
+ r"""(?:\s-[A-Za-z]*m|--message)(?:\s+|=)(?:"((?:[^"\\]|\\.)*)"|'([^']*)')""", re.DOTALL
+)
+#: A here-document body, as agents write multi-line commit messages.
+_HEREDOC = re.compile(r"<<-?\s*['\"]?(\w+)['\"]?[^\n]*\n(.*?)\n\s*\1\b", re.DOTALL)
+#: Most commit ids checked per record; one git call each.
+_MAX_COMMIT_IDS = 200
+
+
+@dataclass(frozen=True, slots=True)
+class CommitRefs:
+ """What an agent's own shell commands say about the commits they made."""
+
+ ids: frozenset[str]
+ subjects: frozenset[str]
+
+
+@dataclass(slots=True)
+class PaneWork:
+ """The files one agent changed: ``{path: last change ms}``, and when it started."""
+
+ files: dict[str, int] = field(default_factory=dict)
+ #: The earliest change (edit or commit), 0 when unknown.
+ since_ms: int = 0
+
+
+def _command_text(args: Any) -> str:
+ if isinstance(args, str):
+ return args
+ if isinstance(args, dict):
+ for key in ("command", "cmd", "script", "commands"):
+ value = args.get(key)
+ if isinstance(value, str):
+ return value
+ if isinstance(value, list):
+ return " ".join(str(part) for part in value)
+ return ""
+
+
+def _subject(message: str) -> str:
+ """A commit message's first line, from a here-document when it is written as one."""
+ heredoc = _HEREDOC.search(message)
+ if heredoc:
+ message = heredoc.group(2)
+ return next((line.strip() for line in message.splitlines() if line.strip()), "")
+
+
+def agent_commit_refs(events: Iterable[dict[str, Any]]) -> CommitRefs:
+ """The commits an agent's shell commands made, by id (from the output) and subject.
+
+ Only commands that mention ``commit`` count, so an id printed by ``git log``
+ in some unrelated command never makes another person's commit look like
+ this agent's.
+ """
+ commands: set[str] = set()
+ ids: set[str] = set()
+ subjects: set[str] = set()
+ for event in events:
+ payload = event.get("payload") or {}
+ call_id = str(payload.get("call_id"))
+ if event.get("kind") == "tool_call":
+ if not _SHELL_TOOL.search(str(payload.get("name") or "")):
+ continue
+ text = _command_text(payload.get("input"))
+ if "commit" not in text:
+ continue
+ commands.add(call_id)
+ for match in _MESSAGE_FLAG.finditer(text):
+ if match.group(1) is not None:
+ message = re.sub(r"\\(.)", r"\1", match.group(1))
+ else:
+ message = match.group(2)
+ if subject := _subject(message):
+ subjects.add(subject)
+ # `git commit -F - <<'EOF'`: the message is the here-document itself.
+ for heredoc in _HEREDOC.finditer(text):
+ opener = text[: heredoc.start()].rsplit("\n", 1)[-1]
+ if "commit" in opener and (subject := _subject(heredoc.group(2))):
+ subjects.add(subject)
+ elif event.get("kind") == "tool_result" and call_id in commands:
+ output = payload.get("output")
+ text = output if isinstance(output, str) else json.dumps(output)
+ ids.update(_COMMIT_SUMMARY.findall(text))
+ ids.update(_FULL_ID.findall(text))
+ return CommitRefs(frozenset(ids), frozenset(subjects))
+
+
+def resolve_commits(folder: str | Path, refs: CommitRefs, since_ms: int) -> dict[str, int]:
+ """``{commit id: commit time ms}`` for the refs that are real commits of this session.
+
+ A commit older than the record (less a minute of clock slack) is not this
+ session's, whatever printed its id.
+ """
+ root = Path(folder).expanduser()
+ floor = max(0, since_ms // 1000 - 60) if since_ms > 0 else 0
+ found: dict[str, int] = {}
+ for ref in sorted(refs.ids)[:_MAX_COMMIT_IDS]:
+ result = _git(["log", "-1", "--format=%H%x1f%ct", f"{ref}^{{commit}}", "--"], root)
+ if result is None or result.returncode != 0:
+ continue
+ sha, _sep, seconds = result.stdout.strip().partition("\x1f")
+ if sha and seconds.isdigit() and int(seconds) >= floor:
+ found[sha] = int(seconds) * 1000
+ if refs.subjects:
+ window = [f"--since=@{floor}"] if floor else ["-n", "2000"]
+ result = _git(["log", "--branches", *window, "--format=%H%x1f%ct%x1f%s"], root)
+ for line in (result.stdout.splitlines() if result and result.returncode == 0 else []):
+ sha, _a, rest = line.partition("\x1f")
+ seconds, _b, subject = rest.partition("\x1f")
+ if subject.strip() in refs.subjects and seconds.isdigit():
+ found[sha] = int(seconds) * 1000
+ return found
+
+
+def commit_files(folder: str | Path, commits: dict[str, int]) -> dict[str, int]:
+ """``{workspace-relative path: newest commit time ms}`` across ``commits``."""
+ root = Path(folder).expanduser()
+ files: dict[str, int] = {}
+ shas = sorted(commits)
+ for start in range(0, len(shas), 50):
+ chunk = shas[start : start + 50]
+ result = _git(
+ ["show", "--no-renames", "--name-only", "--relative", "--format=%x1e%H", *chunk, "--"],
+ root,
+ )
+ if result is None or result.returncode != 0:
+ continue
+ for block in result.stdout.split("\x1e"):
+ lines = [line for line in block.splitlines() if line.strip()]
+ if not lines or lines[0] not in commits:
+ continue
+ when = commits[lines[0]]
+ for path in lines[1:]:
+ files[path] = max(files.get(path, 0), when)
+ return files
+
+
+def generated_paths(folder: str | Path, paths: set[str]) -> set[str]:
+ """The paths ``.gitattributes`` marks ``linguist-generated`` (build output, bundles)."""
+ root = Path(folder).expanduser()
+ found: set[str] = set()
+ if not paths:
+ return found
+ result = _git(
+ ["check-attr", "--stdin", "-z", "linguist-generated"], root, stdin="\0".join(sorted(paths))
+ )
+ if result is None or result.returncode != 0:
+ return found
+ parts = result.stdout.split("\0")
+ for path, _attr, value in zip(parts[0::3], parts[1::3], parts[2::3], strict=False):
+ if value in ("set", "true"):
+ found.add(path)
+ return found
+
+
+def pane_work(
+ folder: str | Path, events: list[dict[str, Any]], record_folder: str | Path | None = None
+) -> PaneWork:
+ """Every file one agent changed: through its editing tools, and in the commits it made.
+
+ The commits catch what an editing tool never names — a file a script or
+ a shell command changed, once the agent committed it.
+ """
+ root = Path(folder).expanduser().resolve(strict=False)
+ base = Path(record_folder or root).expanduser()
+ work = PaneWork()
+ starts: list[int] = []
+ for raw, (first, last) in change_authors.write_spans(events).items():
+ relative = change_authors.relative_path(raw, base, root)
+ if relative is None:
+ continue
+ work.files[relative] = max(work.files.get(relative, 0), last)
+ if first:
+ starts.append(first)
+ session_start = min((int(e.get("ts_ms") or 0) for e in events if e.get("ts_ms")), default=0)
+ commits = resolve_commits(root, agent_commit_refs(events), session_start)
+ for path, when in commit_files(root, commits).items():
+ work.files[path] = max(work.files.get(path, 0), when)
+ # A commit carries whole seconds: one second earlier is safely before it.
+ starts.extend(when - 1000 for when in commits.values())
+ work.since_ms = min(starts, default=0)
+ return work
+
+
+__all__ = [
+ "BASE_PATTERN",
+ "CommitRefs",
+ "PaneWork",
+ "agent_commit_refs",
+ "commit_files",
+ "generated_paths",
+ "pane_changes",
+ "pane_file_diff",
+ "pane_work",
+ "resolve_commits",
+ "session_base",
+]
diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.py
index 5afbd676fd..29565b2f68 100644
--- a/jarvis/ui/web/agentic_ide_routes.py
+++ b/jarvis/ui/web/agentic_ide_routes.py
@@ -939,7 +939,10 @@ class PaneChangesResponse(BaseModel):
truncated: bool = False
reason: str = ""
base: str = Field(default="", description="The commit the files are compared with.")
- since_ms: int = Field(default=0, description="The agent's first write; 0 when unknown.")
+ since_ms: int = Field(default=0, description="The agent's first change; 0 when unknown.")
+ generated: int = Field(
+ default=0, description="Generated files (build output) the agent changed, not listed."
+ )
class DiffLineItem(BaseModel):
@@ -1797,12 +1800,23 @@ def _pane_of(workspace_id: str, name: str) -> tuple[Any, Any]:
def _read_pane_changes(
folder: str, record: change_authors.PaneRecord | None
-) -> tuple[dict[str, list[change_authors.ChangeAuthor]], int, str | None, Any]:
- authors = change_authors.change_authors(folder, [record] if record else [])
- since = change_authors.first_write_ms(folder, record) if record else 0
- base = pane_changes.session_base(folder, since) if authors else None
- listed = pane_changes.pane_changes(folder, set(authors), base) if base else ([], set(), False)
- return authors, since, base, listed
+) -> tuple[pane_changes.PaneWork, str | None, int, Any]:
+ """(the agent's work, the base it is compared with, generated files left out, listing)."""
+ events: list[dict[str, Any]] = []
+ if record is not None:
+ try:
+ events = (
+ agent_transcript.read_events(record.agent, record.session_id, home=record.home)
+ or []
+ )
+ except Exception as exc: # a record the CLI rewrote mid-read: an empty review this time
+ log.info("Pane changes: %s record unreadable: %s", record.pane, exc)
+ work = pane_changes.pane_work(folder, events, record.folder if record else None)
+ generated = pane_changes.generated_paths(folder, set(work.files))
+ wanted = set(work.files) - generated
+ base = pane_changes.session_base(folder, work.since_ms) if wanted else None
+ listed = pane_changes.pane_changes(folder, wanted, base) if base else ([], set(), False)
+ return work, base, len(generated), listed
@router.get(
@@ -1826,8 +1840,9 @@ async def get_pane_changes(workspace_id: str, name: str) -> PaneChangesResponse:
return PaneChangesResponse(
workspace_id=workspace_id, available=False, reason=changes.reason
)
- authors, since, base, (files, pending, truncated) = await asyncio.to_thread(
- _read_pane_changes, folder, _pane_record(session, term)
+ record = _pane_record(session, term)
+ work, base, generated, (files, pending, truncated) = await asyncio.to_thread(
+ _read_pane_changes, folder, record
)
return PaneChangesResponse(
workspace_id=workspace_id,
@@ -1836,14 +1851,23 @@ async def get_pane_changes(workspace_id: str, name: str) -> PaneChangesResponse:
files=[
PaneChangedFileItem(
**asdict(item),
- authors=[ChangeAuthorItem(**asdict(a)) for a in authors.get(item.path, [])],
+ authors=[
+ ChangeAuthorItem(
+ pane=term.name,
+ history_id=term.history_id,
+ agent=term.agent,
+ display_name=term.display_name,
+ last_edit_ms=work.files.get(item.path, 0),
+ )
+ ],
committed=item.path not in pending,
)
for item in files
],
truncated=truncated,
base=base or "",
- since_ms=since,
+ since_ms=work.since_ms,
+ generated=generated,
)
diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.test.tsx
index c9c3022910..80ef0caf41 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.test.tsx
@@ -62,6 +62,7 @@ beforeEach(() => {
? {
...CHANGES,
base: "abc1234",
+ generated: 412,
since_ms: 1_700_000_000_000,
// The pane route answers committed work too, and marks it.
files: CHANGES.files
@@ -138,6 +139,7 @@ describe("PaneChangesDialog", () => {
await screen.findByText("new src/app.ts");
expect(urls.some((url) => url.includes("/terminals/T1/diff?path=src%2Fapp.ts&base=abc1234"))).toBe(true);
expect(screen.getByText(/compared with the code before its first edit/)).toBeTruthy();
+ expect(screen.getByTestId("pane-changes-generated").textContent).toBe("+ 412 generated files (build output), not listed");
});
it("asks the pane route for a worktree pane too", async () => {
diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.tsx
index a323273867..ee187e1c85 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.tsx
@@ -222,6 +222,11 @@ export function PaneChangesDialog({
<Counts added={totals.added} removed={totals.removed} />
</span>
)}
+ {changes && changes.generated > 0 && (
+ <span data-testid="pane-changes-generated">
+ {fill(t("pane_review.generated_hidden"), { count: changes.generated })}
+ </span>
+ )}
</Dialog.Description>
</div>
<div className="flex shrink-0 items-center gap-1.5">
diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneChangesApi.ts b/jarvis/ui/web/frontend/src/components/agentic/paneChangesApi.ts
index 1945f1bcf2..7fa30aa240 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/paneChangesApi.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/paneChangesApi.ts
@@ -46,8 +46,10 @@ export interface PaneChanges {
truncated: boolean;
/** The commit the pane's files are compared with; empty for an uncommitted-only reading. */
base: string;
- /** When the agent first wrote a file (epoch ms); 0 when unknown. */
+ /** When the agent first changed a file (epoch ms); 0 when unknown. */
sinceMs: number;
+ /** Generated files (build output) the agent changed, counted rather than listed. */
+ generated: number;
}
/** Where a pane's work lives: its own worktree folder, else the workspace's shared one. */
@@ -90,6 +92,7 @@ interface ChangesBody {
reason: string;
base?: string;
since_ms?: number;
+ generated?: number;
}
/** The files whose agent records name `pane` as a writer. Directories are kept only when named too. */
@@ -120,6 +123,7 @@ function reading(body: ChangesBody, extra: Pick<PaneChanges, "folderTotal" | "ow
truncated: body.truncated,
base: body.base ?? "",
sinceMs: body.since_ms ?? 0,
+ generated: body.generated ?? 0,
...extra,
};
}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/pane_review/de.json b/jarvis/ui/web/frontend/src/i18n/locales/pane_review/de.json
index 8bc72f2640..c45ef1689f 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/pane_review/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/pane_review/de.json
@@ -19,7 +19,7 @@
"diff_failed": "Dieser Unterschied konnte nicht gelesen werden: {error}",
"unavailable": "Änderungen können hier nicht angezeigt werden: {reason}",
"empty_pane": "Dieser Agent hat noch keine Dateien geändert.",
- "empty_pane_hint": "Es zählen nur Dateien, die er selbst bearbeitet hat. Eine Datei, die ein Shell-Befehl geändert hat, steht unter „Ganzer Ordner“, solange sie nicht committet ist.",
+ "empty_pane_hint": "Dateien, die er per Skript oder Shell-Befehl geändert hat, zählen, sobald er sie committet; bis dahin stehen sie unter „Ganzer Ordner“.",
"empty_folder": "In diesem Ordner ist nichts unkommittet.",
"empty_hint": "Was schon committet ist, steht im Git-Tab.",
"file_list": "Geänderte Dateien",
@@ -39,6 +39,7 @@
"conflicted": "Konflikt"
},
"committed": "Committet",
- "pending": "Nicht committet"
+ "pending": "Nicht committet",
+ "generated_hidden": "+ {count} generierte Dateien (Build-Ausgabe), nicht aufgelistet"
}
}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/pane_review/en.json b/jarvis/ui/web/frontend/src/i18n/locales/pane_review/en.json
index b00ccb15c3..4769019e7e 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/pane_review/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/pane_review/en.json
@@ -19,7 +19,7 @@
"diff_failed": "This diff could not be read: {error}",
"unavailable": "Changes cannot be shown here: {reason}",
"empty_pane": "This agent has not changed any files yet.",
- "empty_pane_hint": "Only files it edited itself count. A file changed by a shell command shows under Whole folder while it is uncommitted.",
+ "empty_pane_hint": "Files it changed with a script or a shell command count once it commits them; until then they show under Whole folder.",
"empty_folder": "Nothing in this folder is uncommitted.",
"empty_hint": "Work that was already committed is in the Git tab.",
"file_list": "Changed files",
@@ -39,6 +39,7 @@
"conflicted": "Conflict"
},
"committed": "Committed",
- "pending": "Not committed"
+ "pending": "Not committed",
+ "generated_hidden": "+ {count} generated files (build output), not listed"
}
}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/pane_review/es.json b/jarvis/ui/web/frontend/src/i18n/locales/pane_review/es.json
index 830268ea7e..301f67fb8b 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/pane_review/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/pane_review/es.json
@@ -19,7 +19,7 @@
"diff_failed": "No se pudo leer esta diferencia: {error}",
"unavailable": "Los cambios no se pueden mostrar aquí: {reason}",
"empty_pane": "Este agente aún no ha cambiado ningún archivo.",
- "empty_pane_hint": "Solo cuentan los archivos que editó él mismo. Un archivo cambiado por un comando de shell aparece en «Carpeta entera» mientras no tenga commit.",
+ "empty_pane_hint": "Los archivos que cambió con un script o un comando de shell cuentan en cuanto hace commit; hasta entonces aparecen en «Carpeta entera».",
"empty_folder": "No hay nada sin commit en esta carpeta.",
"empty_hint": "Lo que ya tiene commit está en la pestaña Git.",
"file_list": "Archivos cambiados",
@@ -39,6 +39,7 @@
"conflicted": "Conflicto"
},
"committed": "Con commit",
- "pending": "Sin commit"
+ "pending": "Sin commit",
+ "generated_hidden": "+ {count} archivos generados (salida de compilación), no listados"
}
}
diff --git a/tests/unit/web/test_agentic_ide_pane_changes_route.py b/tests/unit/web/test_agentic_ide_pane_changes_route.py
index 22ae5e04ab..791e1b10b1 100644
--- a/tests/unit/web/test_agentic_ide_pane_changes_route.py
+++ b/tests/unit/web/test_agentic_ide_pane_changes_route.py
@@ -34,6 +34,13 @@ def _git(cwd: Path, *args: str, at: int | None = None) -> None:
subprocess.run(["git", *args], cwd=cwd, check=True, capture_output=True, env=env)
+def _head(cwd: Path) -> str:
+ result = subprocess.run(
+ ["git", "rev-parse", "HEAD"], cwd=cwd, capture_output=True, text=True, check=True
+ )
+ return result.stdout.strip()
+
+
@pytest.fixture
def repo(tmp_path: Path) -> Path:
_git(tmp_path, "init", "-q")
@@ -79,9 +86,21 @@ def workspace(repo: Path, monkeypatch: pytest.MonkeyPatch) -> SimpleNamespace:
monkeypatch.setattr(agent_transcript, "can_read", lambda agent: True)
monkeypatch.setattr(agent_transcript, "read_events", lambda agent, sid, home=None: records[sid])
monkeypatch.setattr(change_authors, "_cache", {})
+ session.records = records
return session
+def _shell(call_id: str, command: str, output: str) -> list[dict]:
+ return [
+ {
+ "kind": "tool_call",
+ "ts_ms": FIRST_WRITE_MS + 1000,
+ "payload": {"call_id": call_id, "name": "Bash", "input": {"command": command}},
+ },
+ {"kind": "tool_result", "payload": {"call_id": call_id, "output": output}},
+ ]
+
+
async def test_work_the_agent_already_committed_is_listed(
repo: Path, workspace: SimpleNamespace
) -> None:
@@ -126,6 +145,57 @@ async def test_a_file_back_to_its_old_text_is_not_listed(
assert answer.files == []
+async def test_a_file_a_script_changed_shows_once_the_agent_committed_it(
+ repo: Path, workspace: SimpleNamespace
+) -> None:
+ # The agent rewrote theirs.py with a script — no editing tool names it —
+ # then committed. Its commit command's own output names the commit.
+ (repo / "theirs.py").write_text("scripted\n", encoding="utf-8")
+ _git(repo, "commit", "-q", "-am", "chore: rewrite by script", at=NOW - 20)
+ workspace.records["s1"] += _shell(
+ "c9", 'git commit -am "chore: rewrite by script"', "[main 1234567] chore: rewrite by script"
+ )
+
+ answer = await routes.get_pane_changes("w1", "T1")
+
+ assert [(f.path, f.committed) for f in answer.files] == [("theirs.py", True)]
+
+
+async def test_a_commit_id_printed_by_an_unrelated_command_is_not_the_agents(
+ repo: Path, workspace: SimpleNamespace
+) -> None:
+ (repo / "theirs.py").write_text("someone else\n", encoding="utf-8")
+ _git(repo, "commit", "-q", "-am", "other agent", at=NOW - 20)
+ other = _head(repo)
+ workspace.records["s1"] += _shell("c9", "git log -1 --format=%H", other)
+
+ answer = await routes.get_pane_changes("w1", "T1")
+
+ assert answer.files == []
+
+
+async def test_generated_files_are_counted_not_listed(
+ repo: Path, workspace: SimpleNamespace
+) -> None:
+ (repo / ".gitattributes").write_text("dist/** linguist-generated\n", encoding="utf-8")
+ _git(repo, "add", ".gitattributes")
+ _git(repo, "commit", "-q", "-m", "attributes", at=NOW - 90)
+ (repo / "dist").mkdir()
+ for index in range(3):
+ (repo / "dist" / f"chunk{index}.js").write_text("x\n", encoding="utf-8")
+ (repo / "mine.py").write_text("two\n", encoding="utf-8")
+ _git(repo, "add", "-A")
+ _git(repo, "commit", "-q", "-m", "build and fix", at=NOW - 20)
+ workspace.records["s1"] += _shell(
+ "c9", "git add -A && git commit -q -m 'build and fix'", ""
+ )
+
+ answer = await routes.get_pane_changes("w1", "T1")
+
+ assert [f.path for f in answer.files] == ["mine.py"]
+ assert answer.generated == 3
+
+
async def test_a_diff_refuses_a_base_that_is_not_a_commit_id(workspace: SimpleNamespace) -> None:
with pytest.raises(HTTPException) as refused:
await routes.get_pane_file_diff("w1", "T1", "mine.py", "HEAD; rm -rf")