0
Fork 0
mirror of https://github.com/zeronsh/comet.git synced 2026-11-18 18:56:11 +00:00
comet/apps/zgx/plugins-builtin/github/pulls.luau
Daniel Katulevskiy 7a2a3f5f3b
zgx GitHub plugin: a session's PR badge only from its own repository (#1166)
Every chat showed the same open PR badge (ucsd-cse-x24-sp25/lab-3-katulevskiy#1,
a GitHub Classroom "Feedback" PR: head main, base feedback).

Cause: watch.luau resolved a session's repository with `gh repo view`, which
fails for remotes on a host gh doesn't know (here every remote goes through a
local proxy, http://127.0.0.1:7457/github.com/owner/name.git) and for folders
on other devices. Such a session fell back to a GitHub search,
`is:pr head:<branch> involves:@me`, across all repositories, and took the
first non-fork hit. For a chat on `main` that is any PR of yours from any
repository's `main`. The guess was also kept in the plugin's cache.

- Remove the branch-name search: a session's PR is only its own
  repository's, from its own branch (head repo and branch must match). A
  session whose repository can't be told shows none from gh; the engine's
  watch on the session's device can still report one.
- Resolve a folder's repository from its remotes when gh can't (proxy
  URLs that keep GitHub's path, ssh and https forms), picking the remote as
  gh does (upstream, github, origin, else the only GitHub one). The plugin
  may now run `git`.
- Check headRefName against the session's branch in the batch answer.
- Keep heard PRs under a new cache key, so the poisoned `watch` entries
  aren't shown at launch; and publish a session's first answer even when
  it is "none", so a hot reload clears a badge its state still held.

Test: two chats on `main` in different repositories, one in a folder that
isn't here, an unrelated repository's open PR from `main` -> no badges; a
chat whose repository and branch have a PR -> its badge. Fails on the old
code with the unrelated PR shown.
2026-11-03 13:54:58 -07:00

573 lines
20 KiB