pub struct ReviewSession<S: ReviewStore> { /* private fields */ }Implementations§
Source§impl<S: ReviewStore> ReviewSession<S>
impl<S: ReviewStore> ReviewSession<S>
Sourcepub fn open(
store: S,
doc: PlanDocument,
view: DiffView,
) -> Result<Self, EngineError>
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.
pub fn doc(&self) -> &PlanDocument
Sourcepub fn plan(&self) -> &ReviewView
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.
pub fn plan_hash(&self) -> &str
pub fn findings(&self) -> &[Finding]
Sourcepub fn threads(&self) -> &[RemoteThread]
pub fn threads(&self) -> &[RemoteThread]
The forge’s review threads as last fetched, placed against this plan.
pub fn thread(&self, id: &str) -> Option<&RemoteThread>
Sourcepub fn me(&self) -> Option<&str>
pub fn me(&self) -> Option<&str>
The login the forge knows the reader as, if the forge has been asked.
Sourcepub fn own_comment(&self, thread: &str, comment: &str) -> Option<OwnComment>
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.
Sourcepub fn own_root(&self, thread: &str) -> Option<OwnComment>
pub fn own_root(&self, thread: &str) -> Option<OwnComment>
The thread’s root as the reader’s own comment, if it is theirs.
Sourcepub fn own_of_finding(&self, id: &str) -> Option<OwnComment>
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.
Sourcepub fn unpublished(&self) -> impl Iterator<Item = &Finding>
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).
Sourcepub fn is_twinned(&self, finding: &Finding) -> bool
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.
Sourcepub fn publish_plan(&self, kind: ForgeKind) -> PublishPlan
pub fn publish_plan(&self, kind: ForgeKind) -> PublishPlan
What a publish would send now, and what it would leave and why.
Sourcepub fn hunk_key(&self, hunk: usize) -> &str
pub fn hunk_key(&self, hunk: usize) -> &str
The reviewed-mark key of hunk — its exact content digest.
pub fn is_reviewed(&self, hunk_key: &str) -> bool
Sourcepub fn reviewed_count(&self) -> usize
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.
Sourcepub fn reviewed_hunks(&self) -> HashSet<usize>
pub fn reviewed_hunks(&self) -> HashSet<usize>
Canonical hunk indices marked reviewed (owned — safe to hold while borrowing the session elsewhere).
pub fn cursor(&self) -> Option<&(String, usize)>
Sourcepub fn split_diff(&self) -> Option<bool>
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.
pub fn file_view(&self) -> bool
Sourcepub fn wrap(&self) -> Option<bool>
pub fn wrap(&self) -> Option<bool>
The reader’s recorded wrap choice, or None if they have not pressed
w on this review.
Sourcepub fn findings_summary(&self) -> String
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).
Sourcepub fn toggle_reviewed(&mut self, hunk: usize) -> Result<bool, EngineError>
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).
Sourcepub fn set_reviewed(
&mut self,
hunk_keys: &[String],
on: bool,
) -> Result<(), EngineError>
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.
Sourcepub fn save_cursor(&mut self, id: String, row: usize) -> Result<(), EngineError>
pub fn save_cursor(&mut self, id: String, row: usize) -> Result<(), EngineError>
Persist the resume position: (group id or file path, row offset).
Sourcepub fn set_split_diff(&mut self, on: bool) -> Result<(), EngineError>
pub fn set_split_diff(&mut self, on: bool) -> Result<(), EngineError>
Persist the diff layout (unified / side-by-side).
Sourcepub fn set_file_view(&mut self, on: bool) -> Result<(), EngineError>
pub fn set_file_view(&mut self, on: bool) -> Result<(), EngineError>
Persist the left-pane view (semantic groups / flat file list).
Sourcepub fn add_finding(
&mut self,
hunk: usize,
lines: Option<Lines>,
body: String,
) -> Result<&Finding, EngineError>
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).
Sourcepub fn edit_finding(
&mut self,
id: &str,
body: String,
) -> Result<bool, EngineError>
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.
Sourcepub fn delete_finding(&mut self, id: &str) -> Result<bool, EngineError>
pub fn delete_finding(&mut self, id: &str) -> Result<bool, EngineError>
Delete a finding by id. Returns whether anything was removed.
Sourcepub fn add_reply(
&mut self,
thread_id: &str,
body: String,
) -> Result<&Finding, EngineError>
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).
Sourcepub fn set_threads(
&mut self,
threads: Vec<RemoteThread>,
) -> Result<usize, EngineError>
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.
Sourcepub fn set_me(&mut self, login: String)
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.
Sourcepub fn set_thread_resolved(
&mut self,
id: &str,
resolved: bool,
) -> Result<bool, EngineError>
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.
Sourcepub fn edit_comment(
&mut self,
thread: &str,
comment: &str,
body: String,
) -> Result<bool, EngineError>
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.
Sourcepub fn delete_comment(
&mut self,
thread: &str,
comment: &str,
) -> Result<bool, EngineError>
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.
Sourcepub fn mark_published(
&mut self,
published: &[Published],
) -> Result<usize, EngineError>
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.
Sourcepub fn record_publish(
&mut self,
sent: &[String],
published: &[Published],
threads: Result<Vec<RemoteThread>, ForgeError>,
) -> Result<Recorded, EngineError>
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.
Sourcepub fn clear_findings(&mut self) -> Result<usize, EngineError>
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.