Skip to main content

ReviewSession

Struct ReviewSession 

Source
pub struct ReviewSession<S: ReviewStore> { /* private fields */ }

Implementations§

Source§

impl<S: ReviewStore> ReviewSession<S>

Source

pub fn open( store: S, doc: PlanDocument, view: DiffView, ) -> Result<Self, EngineError>

Open (or resume) the review identified by (review_base, head_spec): persist the plan, load and re-anchor findings, load state.

review_base/head_spec are the review’s IDENTITY, not necessarily the diff endpoints: reviewing uncommitted changes keys on the HEAD sha plus a stable literal while the synthesized trees churn.

Source

pub fn doc(&self) -> &PlanDocument

Source

pub fn plan(&self) -> &ReviewView

The document’s projection: groups, files, counts, dependency edges and reviewed-mark keys. Renderers read this instead of re-deriving it.

Source

pub fn plan_hash(&self) -> &str

Source

pub fn findings(&self) -> &[Finding]

Source

pub fn threads(&self) -> &[RemoteThread]

The forge’s review threads as last fetched, placed against this plan.

Source

pub fn thread(&self, id: &str) -> Option<&RemoteThread>

Source

pub fn me(&self) -> Option<&str>

The login the forge knows the reader as, if the forge has been asked.

Source

pub fn own_comment(&self, thread: &str, comment: &str) -> Option<OwnComment>

Whether comment in thread is the reader’s, and how to act on it: by a linked record — a marker or a publish’s recorded address — or by author. None for anyone else’s comment, which is reply-only.

Source

pub fn own_root(&self, thread: &str) -> Option<OwnComment>

The thread’s root as the reader’s own comment, if it is theirs.

Source

pub fn own_of_finding(&self, id: &str) -> Option<OwnComment>

A published finding as the comment it became, whether or not its twin has been fetched back yet.

Source

pub fn unpublished(&self) -> impl Iterator<Item = &Finding>

Open findings not yet on the request: what P would send and what y copies (ADR 0029).

Source

pub fn is_twinned(&self, finding: &Finding) -> bool

Whether a published finding’s fetched twin is present, so the renderer draws the thread and not the note.

Source

pub fn publish_plan(&self, kind: ForgeKind) -> PublishPlan

What a publish would send now, and what it would leave and why.

Source

pub fn hunk_key(&self, hunk: usize) -> &str

The reviewed-mark key of hunk — its exact content digest.

Source

pub fn is_reviewed(&self, hunk_key: &str) -> bool

Source

pub fn reviewed_count(&self) -> usize

Marks that land on a hunk of THIS document.

Keys from an earlier plan stay on disk and revive if their content comes back, so counting the stored set would count hunks the reader cannot see — and could outrun the total the renderer draws it against.

Source

pub fn reviewed_hunks(&self) -> HashSet<usize>

Canonical hunk indices marked reviewed (owned — safe to hold while borrowing the session elsewhere).

Source

pub fn cursor(&self) -> Option<&(String, usize)>

Source

pub fn split_diff(&self) -> Option<bool>

The reader’s recorded layout choice, or None if they have not made one and the caller should fall back to its configured default.

Source

pub fn file_view(&self) -> bool

Source

pub fn wrap(&self) -> Option<bool>

The reader’s recorded wrap choice, or None if they have not pressed w on this review.

Source

pub fn findings_summary(&self) -> String

The open, unpublished findings as markdown: one - file:lines: note per line.

The human-readable projection of findings(), and domain policy rather than a renderer’s formatting — the reviewer’s y and dfr findings --summary are the same text, so one cannot drift from the other.

Deliberately says nothing about groups. A group is how THIS reviewer chose to read the branch, and the summary is pasted somewhere that has no idea what g7 was. A published finding is left out for the same reason a group is: it is already where it was going (ADR 0029).

Source

pub fn toggle_reviewed(&mut self, hunk: usize) -> Result<bool, EngineError>

Toggle the reviewed mark of hunk itself. Returns the new mark (true = now reviewed).

Source

pub fn set_reviewed( &mut self, hunk_keys: &[String], on: bool, ) -> Result<(), EngineError>

Mark a whole set of hunks reviewed (or not) in one write.

Set semantics, not toggle: a partially reviewed group resolves to the requested state instead of inverting member by member, and the batch costs one save_state rather than one per hunk.

Source

pub fn save_cursor(&mut self, id: String, row: usize) -> Result<(), EngineError>

Persist the resume position: (group id or file path, row offset).

Source

pub fn set_split_diff(&mut self, on: bool) -> Result<(), EngineError>

Persist the diff layout (unified / side-by-side).

Source

pub fn set_wrap(&mut self, on: bool) -> Result<(), EngineError>

Persist the soft-wrap choice.

Source

pub fn set_file_view(&mut self, on: bool) -> Result<(), EngineError>

Persist the left-pane view (semantic groups / flat file list).

Source

pub fn add_finding( &mut self, hunk: usize, lines: Option<Lines>, body: String, ) -> Result<&Finding, EngineError>

Create a finding on hunk and persist it.

lines is what the reviewer pointed at; None anchors the hunk’s first changed line, which is what a finding filed from its header annotates. Either way the anchor is stored as an OFFSET into the hunk, so it survives the hunk moving in the file (see Anchor::offset).

Source

pub fn edit_finding( &mut self, id: &str, body: String, ) -> Result<bool, EngineError>

Rewrite a finding’s body in place. Returns whether one was found.

The id is a handle, not a hash of the text: rewriting a note is not filing a different one, and the anchor it was written against is the thing worth keeping. plan_hash stays too — the note still describes the plan it was written on.

Source

pub fn delete_finding(&mut self, id: &str) -> Result<bool, EngineError>

Delete a finding by id. Returns whether anything was removed.

Source

pub fn add_reply( &mut self, thread_id: &str, body: String, ) -> Result<&Finding, EngineError>

Draft a reply under a forge thread: a finding that carries the thread’s id and sits where the thread does. Nothing reaches the forge until a publish sends it (ADR 0029).

Source

pub fn set_threads( &mut self, threads: Vec<RemoteThread>, ) -> Result<usize, EngineError>

Replace the thread cache with a fresh fetch, placed against this plan.

Then reconcile: a finding with no upstream whose marker a fetched comment carries IS published, whatever the publish’s answer said, and gets its address now. Returns how many were reconciled. This is what makes a publish idempotent across a lost answer (ADR 0029).

When the session knows who the reader is (set_me), a comment by that author with no marker — one sent before markers existed, or written on the forge’s own page — is matched to an unpublished note on the same file and line with the same text, and the two are linked; a reply the same way, by thread and text. Weaker than the marker, and enough: the same author, place and words.

Source

pub fn set_me(&mut self, login: String)

Tell the session who the reader is on the forge. Asked of the forge once per sitting; a comment by this author is the reader’s own.

Source

pub fn set_thread_resolved( &mut self, id: &str, resolved: bool, ) -> Result<bool, EngineError>

Mirror a resolve the forge has already accepted. Returns whether the thread was known.

Source

pub fn edit_comment( &mut self, thread: &str, comment: &str, body: String, ) -> Result<bool, EngineError>

A comment of the reader’s, rewritten: the forge has already taken the new body, so the cached thread follows it, and the record too when a finding is linked to the comment — fetched twin or not. Returns whether anything was known.

Source

pub fn delete_comment( &mut self, thread: &str, comment: &str, ) -> Result<bool, EngineError>

A comment of the reader’s the forge has already deleted: drop it from the cache, the thread with it when nothing is left, and the linked finding’s record — fetched twin or not. Returns whether anything was known.

Source

pub fn mark_published( &mut self, published: &[Published], ) -> Result<usize, EngineError>

Record where a publish put each finding, so the next publish sends only what is new and the renderer can hide each behind its twin.

Source

pub fn record_publish( &mut self, sent: &[String], published: &[Published], threads: Result<Vec<RemoteThread>, ForgeError>, ) -> Result<Recorded, EngineError>

Record a publish: the answer first, then what the refetched threads carry by marker, then how much of THIS batch is now on the request.

The order is the point, and it is written once so the reviewer’s P and dfr findings --post cannot count differently. A finding is published when either the answer or a marker says so, and the count reads the batch’s findings afterwards rather than the answer alone: an answer can be lost on the way back while the comments stand.

Source

pub fn clear_findings(&mut self) -> Result<usize, EngineError>

Delete every finding not on the request. Returns how many went.

A published finding is kept: its record is what lets the reader edit or delete the comment on the forge, and what stops the next publish from sending it again (ADR 0029). Deleting one is dd, which asks.

One write, not one per note: the store rewrites the whole file on every save, so a loop over delete_finding would rewrite it N times to reach the same file.

Auto Trait Implementations§

§

impl<S> Freeze for ReviewSession<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for ReviewSession<S>
where S: RefUnwindSafe,

§

impl<S> Send for ReviewSession<S>
where S: Send,

§

impl<S> Sync for ReviewSession<S>
where S: Sync,

§

impl<S> Unpin for ReviewSession<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for ReviewSession<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for ReviewSession<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.