feat: push checkout (#14)
Reviewed-on: https://git.reya.su/reya/signed/pulls/14
This commit was merged in pull request #14.
This commit is contained in:
+72
-38
@@ -11,23 +11,22 @@ state.
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
A["New pull request dialog"] --> B{"Patch source"}
|
||||
B -->|"Paste"| C["Paste git format-patch output"]
|
||||
B -->|"Local checkout"| D["Browse for checkout"]
|
||||
D --> E["Defaults: source = current branch, target = announced HEAD"]
|
||||
E --> F["Generate: merge-base plus format-patch base..tip"]
|
||||
F --> G["Apply check vs mirror clone - non-blocking warning"]
|
||||
C --> H["Submit"]
|
||||
F --> H
|
||||
G --> H
|
||||
A["New pull request panel"] --> B{"Compare source"}
|
||||
B -->|"Local checkout"| C["Pick folder (or auto-prefilled from remembered checkouts)"]
|
||||
B -->|"Announced fork"| D["Pick fork repo + branch"]
|
||||
D --> D1["Ensure base mirror (GitCache), fetch origin"]
|
||||
D1 --> D2["Import fork heads as refs/fork/<owner>/<id>/*"]
|
||||
C --> E["Defaults: target = announced HEAD, source = current branch / fork main"]
|
||||
E --> F["merge-base + commits + diff of target..source (Files/Commits tabs)"]
|
||||
F --> H["Submit: format-patch base..tip at publish time"]
|
||||
H --> I["split_patch_series: one part per commit"]
|
||||
I --> J{"Any part over 60 KB?"}
|
||||
J -->|"Yes"| K["Refuse with message"]
|
||||
J -->|"No"| L["tip = last part's From commit"]
|
||||
L --> M["Publish kind-1617 patch series: first has t root, later parts e-reply chained"]
|
||||
M --> N["Build kind-1618 PR event: c = tip, e = root patch, branch-name, merge-base"]
|
||||
M --> N["Build kind-1618 PR event: c = tip, e = root patch, branch-name, merge-base, clone"]
|
||||
N --> O["Sign early - learn the event id"]
|
||||
O --> P["Push tip to refs/nostr/event-id on every announced grasp server"]
|
||||
O --> P["Push tip to refs/nostr/event-id: author /prs/ grasp servers first, then the announced servers"]
|
||||
P -->|"All rejected"| Q["last_warning banner in PR list"]
|
||||
P --> R["Publish kind-1618 PR event"]
|
||||
Q --> R
|
||||
@@ -50,47 +49,81 @@ graph TD
|
||||
|
||||
Key points of the write side:
|
||||
|
||||
- **Merge base**: only computable in the local-checkout path
|
||||
(`signed_git::merge_base`); the paste path publishes none. The dialog
|
||||
reuses it at submit only while the patch textarea is unchanged.
|
||||
- **Compare sources** (NIP-34 / GRASP-06 native, no fork identity on the
|
||||
wire):
|
||||
- *Local checkout*: both branch selectors list a picked folder's
|
||||
branches; all git ops run in that folder. Checkouts of the target repo
|
||||
are remembered (folder pick + app clones) and matched implicitly
|
||||
(origin URL or EUC against the announcement), so the panel prefills the
|
||||
freshest one - no folder dialog for the common case.
|
||||
- *Announced fork*: the fork's heads are fetched into the target repo's
|
||||
GitCache mirror under `refs/fork/<owner-hex>/<id>/*` (private
|
||||
namespace; the browser never sees them). "Merge Into" lists the
|
||||
mirror's `refs/remotes/origin/*`, "Pull From" the imported fork
|
||||
branches, and every git op - merge-base, range diff/commits,
|
||||
format-patch, tip push - runs in the mirror, which holds both
|
||||
histories. Fork candidates are announcements related to the target by
|
||||
`u` tag or shared EUC, own forks first, without `clone` URLs excluded.
|
||||
- **GRASP-06 hosting**: the tip is pushed under `refs/nostr/<event-id>`
|
||||
(nak's convention) to the *author's* grasp servers first -
|
||||
`https://<host>/prs/<author-npub>/<repo-id>.git`, resolved from the
|
||||
author's kind-10317 grasp list, falling back to the settings defaults -
|
||||
then to the base repository's announced grasp servers. The `clone` tag
|
||||
lists those `/prs/` URLs first, then the announced clone URLs (fixed
|
||||
before signing; dead URLs are inert, the patches stay the source of
|
||||
truth). Contributing therefore never depends on the other project's
|
||||
servers accepting a push.
|
||||
- **Patch series**: each commit becomes its own kind-1617 event so no event
|
||||
grows past NIP-34's 60 KB guidance; the PR's `c` tag carries the *last*
|
||||
commit of the series (the tip), and each part carries its own
|
||||
`commit`/`r` tags.
|
||||
- **Push before publish**: the tip is pushed to every announced grasp
|
||||
server under `refs/nostr/<event-id>` (nak's convention) so the announced
|
||||
`clone` URLs really can serve the commit. Failure is non-fatal — the
|
||||
patch events remain the source of truth — and surfaces as a
|
||||
`last_warning` banner.
|
||||
- **Push before publish**: failure is non-fatal - the patch events remain
|
||||
the source of truth - and surfaces as a `last_warning` banner.
|
||||
- **1619 updates are paste-only today** (no repo path holds the new tip's
|
||||
objects), so updates are not pushed; hosting them is deferred until the
|
||||
update dialog gains a local-checkout source.
|
||||
|
||||
## Creating a pull request - event ordering
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant User
|
||||
participant App
|
||||
participant Checkout as Local checkout
|
||||
participant Grasp as Grasp servers
|
||||
participant Relays as Nostr relays
|
||||
participant P as Base mirror (GitCache)
|
||||
participant F as Fork grasp server
|
||||
participant A as Author grasp (GRASP-06 /prs/)
|
||||
participant B as Base repo grasps
|
||||
participant R as Nostr relays
|
||||
|
||||
User->>App: pick checkout and branches, Generate
|
||||
App->>Checkout: merge-base(source, target)
|
||||
Checkout-->>App: base commit
|
||||
App->>Checkout: format-patch base..tip
|
||||
Checkout-->>App: patch series
|
||||
App->>App: split series, check per-part size
|
||||
User->>P: ensure mirror (fork mode) / pick local checkout
|
||||
P-->>F: fetch fork heads -> refs/fork/... (fork mode)
|
||||
User->>P: merge-base, range commits, range diff
|
||||
User->>P: submit: format-patch base..compare-ref
|
||||
loop each patch of the series
|
||||
App->>Relays: publish kind-1617 (first: t root, later: e reply)
|
||||
User->>R: publish kind-1617 (first: t root, later: e reply)
|
||||
end
|
||||
App->>App: build and sign kind-1618 PR event
|
||||
App->>Grasp: push tip to refs/nostr/event-id
|
||||
Grasp-->>App: accepted or rejected (best-effort)
|
||||
App->>Relays: publish kind-1618 PR event
|
||||
User->>User: build and sign kind-1618 (clone = /prs/ URLs + announced)
|
||||
User->>A: push tip to refs/nostr/event-id (author servers, first)
|
||||
User->>B: push tip to refs/nostr/event-id (best-effort)
|
||||
A-->>User: accepted or rejected (all rejected -> warning)
|
||||
User->>R: publish kind-1618 PR event
|
||||
opt draft
|
||||
App->>Relays: publish kind-1633 draft status
|
||||
User->>R: publish kind-1633 draft status
|
||||
end
|
||||
```
|
||||
|
||||
## Ready to contribute (suggestions)
|
||||
|
||||
Local checkouts are matched to announced repositories (remembered records
|
||||
freshest-first ∪ scanned matches by origin URL or EUC). While a repository's
|
||||
detail panel is open, each associated checkout is checked off the main
|
||||
thread: current branch vs its base (announced HEAD, else `main`, else the
|
||||
first branch), commits ahead, dirty worktrees excluded. A banner in the
|
||||
repository panel then offers a prefilled New PR panel for the first branch
|
||||
that is ahead with **no open PR by you** proposing it (`branch-name` tag,
|
||||
falling back to the `c` tip tag) - NIP-34-native dedupe, refreshed
|
||||
periodically and whenever the checkouts/announcements change. The panel
|
||||
never submits anything on its own; suggestions only navigate and prefill.
|
||||
|
||||
## Updating and merging
|
||||
|
||||
```mermaid
|
||||
@@ -100,7 +133,7 @@ sequenceDiagram
|
||||
participant Maintainer
|
||||
participant Clone as Mirror clone
|
||||
|
||||
Note over Author,Relays: Update - PR author only
|
||||
Note over Author,Relays: Update - PR author only (paste flow, no push yet)
|
||||
Author->>Relays: publish revision patch series (t root-revision, e reply to original root)
|
||||
Author->>Relays: publish kind-1619 update (E/P tags, c = new tip)
|
||||
|
||||
@@ -132,8 +165,9 @@ Reader rules that keep the flow consistent:
|
||||
|
||||
- **Status**: only status events by the root author or a repository
|
||||
maintainer count; the newest wins, `Open` is the default.
|
||||
- **Tip**: only kind-1619 updates by the PR author move the tip — a
|
||||
- **Tip**: only kind-1619 updates by the PR author move the tip - a
|
||||
stranger's update is ignored.
|
||||
- **Diff**: the patch set is preferred (NIP-34 `e`-linked chain); PRs from
|
||||
other clients without patch events fall back to diffing
|
||||
`merge-base..tip` in the local clone.
|
||||
`merge-base..tip` in the local clone. Fetching tips from `clone` URLs
|
||||
(ngit `pr checkout` analog) is not implemented yet.
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
# TODO
|
||||
|
||||
## Fork support
|
||||
|
||||
- [x] Fork badge on repo list cards (`repo_list.rs::render_card`).
|
||||
- [x] "Forked from …" text button in the repo detail header (`repo_detail/mod.rs::render_header`) and About dialog.
|
||||
- [x] Clicking the upstream opens it as a center panel (shared `open_repo_panel` helper).
|
||||
|
||||
## Pull request improvement
|
||||
|
||||
### New pull request panel (replaces the dialog)
|
||||
|
||||
- [x] "New pull request" (PR list header + repo header `New PR`) opens a center panel instead of the paste dialog:
|
||||
- [x] Base/compare branch selectors fed from a user-chosen local checkout (GitHub-style; defaults: announced HEAD for base, checkout's current branch for compare).
|
||||
- [x] Files/Commits tabs like the repo panel: diff of `merge-base..compare` (shared `DiffPane` widget, also extracted for the commit diff panel) + virtual commit list with count badge; clicking a commit opens its diff panel.
|
||||
- [x] Only two inputs: title (required, gates the Create button) and description (optional).
|
||||
- [x] Patch is generated from the checkout at submit time (`format_patch_between` on the stored merge base); panel closes after publishing, errors surface in the PR list banner.
|
||||
- [x] Removed with the dialog: paste textarea, draft checkbox, branch-name input and the mirror-clone apply-check hint (store behavior unchanged: `open_pull_request` still publishes the series + `branch-name`/`merge-base`/`r` tags and pushes the tip).
|
||||
|
||||
### Send patch panel (classic paste flow)
|
||||
|
||||
- [x] "Send patch" entry in the repo header PRs dropdown (`RepoAction::SendPatch`) and a "New pull request ▾ Send patch" dropdown replacing the PR list's plain new-PR button.
|
||||
- [x] `send_patch.rs` center panel: title + optional description + `git format-patch` paste area; submits through `RepoStore::open_pull_request` (no checkout, no `branch-name`/`merge-base`). Synchronous store errors (malformed/oversized patch, sign-in) keep the panel open with an inline error; the panel closes once the publish is underway.
|
||||
|
||||
- [x] P1: `branch-name` tag + `r` EUC tag on PR creation; draft checkbox in the new-PR dialog (dialog since replaced by the panel above).
|
||||
- [x] P1: `RepoStore::update_pull_request` (kind 1619 + root-revision patch) with an author-only "Update" button on the PR detail header.
|
||||
- [x] P1: `latest_update` filters by PR author.
|
||||
- [x] P2: local checkout picker in the new-PR dialog (folder picker + source/target branches + Generate): `signed_git::{merge_base, format_patch_between, patch_applies}`; `merge-base` tag now published; best-effort apply check shown under the patch field (superseded by the panel's live compare view).
|
||||
- [x] P3: push tip to grasp servers under `refs/nostr/<event-id>` before publishing (from the local checkout); multi-commit series published as NIP-10-chained 1617 events with a 60 KB per-patch cap; PR list shows dismissible error/warning banners (incl. push failures).
|
||||
- [x] P4: merge status tags — `merge_pull_request` publishes 1631 with `applied-as-commits` + `r` per applied commit and `q`/`e`-reply tags per applied patch event.
|
||||
|
||||
### Pull request follow-ups
|
||||
|
||||
- [ ] GRASP-06 `/prs/<npub>/<id>.git` contributor endpoints + kind-10317 user grasp-list fallback.
|
||||
- [ ] Merge button in the PR detail view (`merge_pull_request` is store-only today), then fetch-and-merge (`merge-commit`) when the push backend is guaranteed.
|
||||
- [ ] Local-checkout generation for the update-PR dialog (currently paste-only).
|
||||
- [ ] Fork-aware compare in the New PR panel: today both branch selectors come from the user-picked local checkout, so a cross-fork PR (GitHub's "compare across forks") requires the fork's branch to exist locally. Add picking the fork repository from announced repos (its 30617 may point at this repo via the `u` tag, or share the EUC) + a branch, fetch it into the `GitCache` mirror, and run the `merge-base`/diff/`format-patch` flow against the base repo's mirror — like `choose_checkout` today but repo-driven.
|
||||
|
||||
## Performance: render path
|
||||
|
||||
- [ ] Virtualize issue/PR comment threads (`issue_detail.rs::render_comments`, `pull_request_detail.rs::render_comments`). Harder than the list tabs: comment cards have variable heights and live inside a scrolling page together with the body and the comment form, so this needs either measured item sizes or restructuring the whole discussion tab into one virtual list. (Comment bodies are already cached as `SharedString`, so re-renders are cheap element constructions, not byte copies.)
|
||||
|
||||
## Performance: relay/subscription behavior
|
||||
|
||||
- [ ] Narrow `RepoStore`'s `BackendEvent::NostrUpdate` relevance filter (`crates/signed_state/src/repo.rs:65-98`): any comment/status/label/deletion from anywhere wakes every open repo store; match only events referencing this repo's roots or coordinate.
|
||||
- [ ] Reconsider `ban_relay_on_mismatch(true)` (`crates/signed_nostr/src/backend.rs:49`): combined with many short-lived auto-close subscriptions, a late event after EOSE can permanently ban a relay for the session.
|
||||
- [ ] Relays added for a repo stay in the pool forever and grow unboundedly (`crates/signed_state/src/backend.rs`); consider removing repo relays when the last panel for that repo closes.
|
||||
Reference in New Issue
Block a user