Scope git history to current diagram by default
- History panel defaults to "This diagram" / "All" toggle - "This diagram" filters git log to commits that touched only that diagram's JSON file (git log -- diagrams/0001_*.json) - Automatically switches to "All" when no diagram is open - Restore flow still works per-commit, per-file Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+23
-1
@@ -2024,8 +2024,26 @@ class WiringApp {
|
||||
commitBtn._gitBound = true;
|
||||
commitBtn.addEventListener("click", () => this._gitCommit());
|
||||
document.getElementById("btn-git-push").addEventListener("click", () => this._gitPush());
|
||||
|
||||
// History scope toggle
|
||||
const btnDiagram = document.getElementById("btn-git-log-diagram");
|
||||
const btnAll = document.getElementById("btn-git-log-all");
|
||||
btnDiagram.addEventListener("click", () => {
|
||||
btnDiagram.classList.add("active"); btnAll.classList.remove("active");
|
||||
this._gitLoadLog();
|
||||
});
|
||||
btnAll.addEventListener("click", () => {
|
||||
btnAll.classList.add("active"); btnDiagram.classList.remove("active");
|
||||
this._gitLoadLog();
|
||||
});
|
||||
}
|
||||
|
||||
// Default scope: "this diagram" if one is open, else "all"
|
||||
const hasDiagram = !!this.diagramId;
|
||||
document.getElementById("btn-git-log-diagram").classList.toggle("active", hasDiagram);
|
||||
document.getElementById("btn-git-log-all").classList.toggle("active", !hasDiagram);
|
||||
document.getElementById("btn-git-log-diagram").disabled = !hasDiagram;
|
||||
|
||||
await this._gitRefresh();
|
||||
}
|
||||
|
||||
@@ -2051,9 +2069,13 @@ class WiringApp {
|
||||
async _gitLoadLog() {
|
||||
const list = document.getElementById("git-log-list");
|
||||
if (!list) return;
|
||||
const diagramScope = document.getElementById("btn-git-log-diagram")?.classList.contains("active");
|
||||
const diagramId = diagramScope && this.diagramId ? this.diagramId : null;
|
||||
const title = document.getElementById("git-log-title");
|
||||
if (title) title.textContent = diagramId ? "History — this diagram" : "History — all commits";
|
||||
list.innerHTML = '<div style="color:#556;padding:4px">Loading…</div>';
|
||||
try {
|
||||
const entries = await api.git.log();
|
||||
const entries = await api.git.log(diagramId);
|
||||
if (!entries.length) {
|
||||
list.innerHTML = '<div style="color:#556;padding:4px">No commits yet</div>';
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user