feat(#1888): read-before-comment guard via forge notification read-state
Rebuild on forge's own notification read-state instead of the local seen-cursor mirror (operator-nacked: mirrors state forge owns + drifts on restart). - comment refuses to post when forge has an unread notification for the thread (someone commented since you last read it); --force overrides. Degrades open if the notification check itself fails. - comments / view mark the thread's notification read (the "I've seen it" signal), clearing the guard for a subsequent reply. - new crate::notify (no local file): unread_thread_id pages repo-scoped unread notifications (newest-first, capped) + subject-url number match; mark_thread_read via the new client.patch_no_content. Pairs with the forge_notify harness change (#1895, merged) that leaves delivered notifications unread until the agent actually reads. Covers pr/issue comment too (they delegate to comment::run).
This commit is contained in:
parent
edad6f863c
commit
156ca70b1e
6 changed files with 201 additions and 5 deletions
|
|
@ -229,6 +229,22 @@ impl Client {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// PATCH `<api>/<path>` for an endpoint that returns a 2xx with an
|
||||
/// empty body (nothing to decode). Used to mark a notification thread
|
||||
/// read (`/notifications/threads/{id}` answers `205 Reset Content`).
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if the request fails to send (transport/network
|
||||
/// error) or the server responds with a non-2xx status (the response
|
||||
/// body is included in the error).
|
||||
pub fn patch_no_content(&self, path: &str) -> Result<()> {
|
||||
let url = format!("{}{}", self.api(), path);
|
||||
let resp = self.http.patch(&url).send().context("PATCH")?;
|
||||
check_status(resp, &format!("PATCH {url}"))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// POST a JSON body to `<api>/<path>` for an endpoint that returns a
|
||||
/// 2xx with an empty body (so there is nothing to decode). Used by
|
||||
/// `pr-merge` — Forgejo's merge endpoint answers `200 OK` with no body
|
||||
|
|
|
|||
Loading…
Reference in a new issue