Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion protoagent.plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Keep `version` in lockstep with pyproject.toml (tests/test_version.py asserts it).
id: github
name: GitHub (read/write tools)
version: 0.1.2
version: 0.1.3
description: >-
Read AND write GitHub tools over the `gh` CLI, with PER-AGENT write gating. The
read tools (PRs, issues, diffs, CI, repo files/contents) are always on; the write
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "github-plugin"
version = "0.1.2"
version = "0.1.3"
description = "Read/write GitHub tools for protoAgent over the gh CLI, with per-agent write gating."
requires-python = ">=3.11"

Expand Down
10 changes: 10 additions & 0 deletions tests/test_board_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ def test_board_page_is_read_only():
assert "/api/plugins/github/issues" in PAGE and "/api/plugins/github/prs" in PAGE # reads only


def test_pages_boot_once():
"""#13 regression — each page boots via the kit ONCE. A second direct ``boot();`` ran two
overlapping config+load sequences → the list flicker/thrash on mount."""
from ghplugin.view import NEW_ISSUE_PAGE, PAGE

for page in (PAGE, NEW_ISSUE_PAGE):
assert "kit.initPluginView(boot)" in page # booted via the handshake callback
assert "boot();" not in page # …and NOT also called directly


def test_config_route_returns_repos_and_default():
c = TestClient(_app())
body = c.get("/api/plugins/github/config").json()
Expand Down
14 changes: 11 additions & 3 deletions view.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,25 @@
+ ' '+labelPills(it.labels)+'</div></a>';
}

// A monotonic token so an in-flight load() whose fetch resolves AFTER a newer load()
// started (rapid tab/filter clicks, or any double-trigger) drops its stale result instead
// of clobbering the fresh list — no thrash.
let loadSeq = 0;
async function load(){
const my = ++loadSeq;
const repo = $("repo").value, list = $("list");
if(!repo){ list.innerHTML = '<div class="hint">No repositories configured. Add some under <b>Settings ▸ GitHub</b> (github.repos).</div>'; return; }
list.innerHTML = '<div class="hint">Loading…</div>';
const path = (tab==="issues"?"/api/plugins/github/issues":"/api/plugins/github/prs")
+ "?repo="+encodeURIComponent(repo)+"&state="+encodeURIComponent($("state").value);
try {
const data = await kit.apiFetch(path).then(r => r.json());
if(my !== loadSeq) return; // a newer load() superseded this one — drop the stale result
if(data.error){ list.innerHTML = '<div class="empty">'+esc(data.error)+'</div>'; return; }
const items = data.items||[];
if(!items.length){ list.innerHTML = '<div class="empty">No '+tab+' for this filter.</div>'; return; }
list.innerHTML = items.map(tab==="issues"?issueRow:prRow).join("");
} catch(e){ list.innerHTML = '<div class="empty">Failed to load — is the agent reachable?</div>'; }
} catch(e){ if(my===loadSeq) list.innerHTML = '<div class="empty">Failed to load — is the agent reachable?</div>'; }
}

async function boot(){
Expand All @@ -128,8 +134,10 @@
$("t-issues").onclick = () => setTab("issues");
$("t-prs").onclick = () => setTab("prs");
$("repo").onchange = load; $("state").onchange = load; $("refresh").onclick = load;
// Boot ONCE — via the kit so it runs after the theme/auth handshake (the fallback kit calls
// it immediately). A second direct boot() here caused two overlapping config+load sequences
// → the list flicker/thrash on mount (#13).
kit.initPluginView(boot);
boot();
</script></body></html>"""


Expand Down Expand Up @@ -195,6 +203,6 @@
} catch(e){ $("res").textContent = "Request failed."; }
}
$("submit").onclick = submit;
// Boot ONCE via the kit (after the theme/auth handshake) — not also directly (#13).
kit.initPluginView(boot);
boot();
</script></body></html>"""
Loading