One shared draft a contract, locked when all agree (phase 13, step 2)
CI / secret scan (push) Successful in 6s
CI / fmt, clippy, tests (push) Successful in 1m27s
CI / release (push) Skipped

Until a contract is set, it is one open text for every side, as Alex
asked: our team edits it in the app, each other party on its link. Edits
are tracked changes in the author's color (crossed out, added,
highlighted with a comment) until the other side accepts or rejects
them. When no change or highlight is open and Lanna Desk and every party
agree, the text becomes a contract version that never changes, and the
draft locks.

- One side edits at a time: Edit takes the draft for 45 seconds, which
  every save renews; Done editing, leaving the page or silence gives it
  up. The editor saves 0.7 s after the last keystroke; the other pages
  ask for news every 3 s, so each side sees edits, who edits, agreements
  and the lock without reloading.
- A save may only touch the saver's own marks (reviews::check_save);
  accept, reject (or withdraw) and resolve are their own steps, journaled
  with the text concerned. A later change voids the agreements given.
- Notices: the other side's edits (one a half hour of editing), settled
  changes, agreements, the lock. The bell in the top bar counts the
  unseen (every 15 s); Notices lists them and marks them seen.
- The draft as a diff: the standing text against every open change taken.
- Migration 0015: contract_drafts, draft_saves and draft_agreements (both
  kept unchanged by a trigger), notices, notice_reads; drops step 1's
  review_rounds (only the demo held any). The review links stay as each
  party's way in.
- Property tests for the save rule and settling, the fuzz text target
  runs the parser, the save check and settling; integration tests play
  both sides to the lock. The demo's recording agreement has an open
  draft with the label's changes and a notice.
- PLAN: phase 13 rewritten; step 3 is the PDF and signing.
This commit is contained in:
grabowski committed 2026-11-23 16:14:14 +07:00
1 parent a4155548b8
commit 3dd9ab60e8
36 files changed
+3812 -2161

No files matched your search

+29 -31
View File
@@ -74,37 +74,35 @@
</details>
<datalist id="roles">{% for r in roles %}<option value="{{ r }}"></option>{% endfor %}</datalist>
</section>
<section class="card" id="reviews">
<header><h2>Review by the other side</h2><span class="muted small">a link where a party marks up a version and sends it back</span></header>
{% for l in reviews %}
<div class="item{% if not l.open %} old{% endif %}" id="review-link-{{ l.id }}">
<div class="row"><b>{{ l.party }}</b><span class="muted small">{{ l.state }}</span>
{% if l.open %}<form method="post" action="/contracts/{{ id }}/review-links/{{ l.id }}/close" class="inline-form" data-confirm="Close {{ l.party }}'s review link? It stops working; sending again makes a new one."><input type="hidden" name="csrf" value="{{ csrf }}"><button type="submit" class="btn sm ghost">Close the link</button></form>{% endif %}
</div>
<ul class="rvrounds">
{% for r in l.rounds %}
<li id="round-{{ r.id }}">Version {{ r.version }} sent {{ r.sent }} by {{ r.by }}:
{% if r.replied %}<a href="/contracts/{{ id }}/reviews/{{ r.id }}">sent back {{ r.replied }}</a>, <span class="chip {% if r.changes %}warn{% else %}ok{% endif %}">{{ r.changes }} {% if r.changes == 1 %}change{% else %}changes{% endif %}</span>{% if r.highlights %} <span class="chip plain">{{ r.highlights }} {% if r.highlights == 1 %}highlight{% else %}highlights{% endif %}</span>{% endif %}
{% elif loop.first %}<span class="muted">waiting for them</span>{% else %}<span class="muted">not sent back; a newer version followed</span>{% endif %}</li>
{% endfor %}
</ul>
</div>
{% endfor %}
{% if live_parties and text_versions %}
<details class="addparty"{% if not reviews %} open{% endif %}>
<summary class="btn sm" id="send-review-open">Send a version for review</summary>
<form method="post" action="/contracts/{{ id }}/reviews" class="form" id="send-form">
<input type="hidden" name="csrf" value="{{ csrf }}">
<div class="grid">
{{ fm.select("review_party", "To", "", review_parties, req=true, blank="Choose the party") }}
{{ fm.select("review_version", "Version", text_versions[0][0], text_versions, req=true, blank="Choose") }}
{{ fm.area("review_message", "Message to them", "", rows=3, fcls="wide", hint="Optional: what to look at, by when.") }}
</div>
<div class="formactions"><button type="submit" class="btn pri" id="send-review">Send</button></div>
</form>
</details>
{% elif not live_parties %}<p class="empty-inline">Add the other party above to send them a version to review.</p>
{% else %}<p class="empty-inline">Add a version with a text to send it for review: the editor works on the text.</p>{% endif %}
<section class="card" id="draft">
<header><h2>Shared draft</h2><span class="muted small">one text for every side, with tracked changes, until all agree</span></header>
{% if draft.state == "open" %}
<p><b>Open for edits</b>, revision {{ draft.revision }}, last change {{ draft.changed }}.{% if draft.editing %} <span class="chip warn">{{ draft.editing }} is editing</span>{% endif %}</p>
<p>{% if draft.changes %}<span class="chip warn">{{ draft.changes }} open {% if draft.changes == 1 %}change{% else %}changes{% endif %}</span> {% endif %}{% if draft.highlights %}<span class="chip plain">{{ draft.highlights }} {% if draft.highlights == 1 %}highlight{% else %}highlights{% endif %}</span> {% endif %}<span class="chip {% if draft.have == draft.need %}ok{% else %}plain{% endif %}">{{ draft.have }} of {{ draft.need }} sides agree</span></p>
<div class="formactions"><a class="btn pri" href="/contracts/{{ id }}/draft" id="open-draft">Open the draft</a></div>
{% elif draft.state == "locked" %}
<p><span class="chip ok">Locked</span> Every side agreed; the text is <a href="/contracts/{{ id }}?v={{ draft.locked_version }}#reading">version {{ draft.locked_version }}</a>, which never changes. <a href="/contracts/{{ id }}/draft">See the draft</a>.</p>
{% endif %}
{% if draft.state != "open" %}
{% if text_versions %}
<form method="post" action="/contracts/{{ id }}/draft/open" class="form inline-form" id="draft-open-form">
<input type="hidden" name="csrf" value="{{ csrf }}">
<div class="grid">{{ fm.select("draft_version", "Start a shared draft from", text_versions[0][0], text_versions, req=true, blank="Choose") }}</div>
<div class="formactions"><button type="submit" class="btn pri" id="draft-open">{% if draft.state == "locked" %}Start a new draft{% else %}Start the shared draft{% endif %}</button></div>
</form>
{% else %}<p class="empty-inline">Add a version with a text to start a shared draft: the editor works on the text.</p>{% endif %}
{% endif %}
{% if draft.parties %}
<h3 class="minihead">The other parties' links</h3>
<ul class="rvrounds">
{% for p in draft.parties %}
<li id="party-link-{{ p.id }}"><b>{{ p.name }}</b>: {{ p.link_state }}
<form method="post" action="/contracts/{{ id }}/invites" class="inline-form"><input type="hidden" name="csrf" value="{{ csrf }}"><input type="hidden" name="party" value="{{ p.id }}"><button type="submit" class="btn sm ghost">{% if p.link %}New link{% else %}Make the link{% endif %}</button></form>
{% if p.link %}<form method="post" action="/contracts/{{ id }}/review-links/{{ p.link }}/close" class="inline-form" data-confirm="Close {{ p.name }}'s link? It stops working at once."><input type="hidden" name="csrf" value="{{ csrf }}"><button type="submit" class="btn sm ghost">Close the link</button></form>{% endif %}
</li>
{% endfor %}
</ul>
{% elif not live_parties %}<p class="empty-inline">Add the other parties above: each gets a link to the draft, and each must agree before it locks.</p>{% endif %}
</section>
{% if reading %}
<section class="card" id="reading">