Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/EDGE_FUNCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3522,6 +3522,8 @@ curl -sS "${SUPABASE_URL}/functions/v1/get-estimate-public-terms" \

> **v2.9096 — a signed paper keeps its link** (finding 698, punch list #458): the update that signs a copy no longer empties `public_token_hash` and `public_token_expires_at`. The link opened again then finds its row, and [get-contract-for-signer](#get-contract-for-signer) answers its `409 already_signed`, which the page draws as **Thank you**; a signature sent twice answers `{ ok: true, alreadySigned: true }`. Before this both read as a dead link, since the row was looked up by a hash it no longer held. Nothing signs twice: the update still takes only a row whose `status` is `sent`, and every road that mints a link writes only an `unsent` or `sent` row. Tests `src/lib/contracts/signedPaperLink.test.ts`. **Deployed** 2026-12-01 (`accept-contract` version 78, 02:43 UTC, read back with `supabase functions list`); the signing road was walked on it at once and passed.

> **v2.9281 — a blank nobody filled prints as a ruled line**: the signed copy this function draws and emails (`sendSignerCopy`, over `paperParagraphs` in [`_shared/personPaperPdf.ts`](../supabase/functions/_shared/personPaperPdf.ts)) prints a name in square brackets, such as `[Company legal name]`, as a line of eighteen underscores, by the one rule in [`_shared/paperRuledBlanks.ts`](../supabase/functions/_shared/paperRuledBlanks.ts). The signing itself is unchanged: the row keeps the words as written, bracket and name, and nothing is kept for such a blank in `blank_values`. **Owes a deploy after v2.9281 merges.**

**A plain paper's blanks (v2.9066, punch list #457):** before a signature is stored the function reads the copy's blanks as the signer's page did. One with no value answers `409 paper_not_ready` and nothing is signed. A signature whose `blankSeal` is not the seal of the values read now, or that carries none, answers `409 paper_changed` (`blanksShownAtSigning`), so a site's code name changed after the page read it, or since v2.9111 the company's legal name, turns the page back to read the paper again. Otherwise the value each blank read is written to `person_contract_documents.blank_values` in the update that signs the copy, and the copy's words stay as the library's. **Deployed** 2026-11-30 (`accept-contract` version 77, 17:09 UTC, read back with `supabase functions list`). The v2.9111 change **deployed** 2026-12-02 (`accept-contract` version 80, 13:59 UTC, read back with `supabase functions list`).

> **v2.9054 — whoever made the signing link is told, and a push goes beside the email** (punch list #458, step 2): `sendPaperSignedNotice` ([`_shared/paperSignedNoticeSend.ts`](../supabase/functions/_shared/paperSignedNoticeSend.ts)) first reads `person_contract_documents.link_made_by` by itself, best effort ([`_shared/paperLinkMaker.ts`](../supabase/functions/_shared/paperLinkMaker.ts), migration [`20261130081355`](./migrations/20261130081355_paper_link_made_by.md)). A link made by hand tells its maker in the email sender's place (`paperSignedTeller`), and makes any signed agreement one to tell of, a teammate's or a sub's own too (`paperSignedNoticeDue(row, byHand)`); a paper that only went by email is told of as before. Whoever is told gets a push through their own hours (`sendPushHonouringHours`, kind `paper_signed`, *Tallgrass Supply Co. signed* with the paper's name and no site), to an account that is here, with or without an address, and the email's foot says whether they sent the paper or made its link. The call from the function is unchanged, and so are the eight seconds. A database behind the migration reads no maker and behaves as before. **Deployed** 2026-11-30 (`accept-contract` version 76, 09:06 UTC, read back with `supabase functions list`). `paperLinkMaker.test.ts` and `paperSignedNotice.test.ts` hold it.
Expand Down Expand Up @@ -3682,6 +3684,8 @@ curl -sS "${SUPABASE_URL}/functions/v1/get-estimate-public-terms" \

> **v2.9129 — a signed copy by email** (punch list #458, call 15): a body with `email_to` emails a signed agreement's PDF to that address and answers `{ ok: true, emailed: true, to, sent_at }`, never a link or a file. It is **Email the signed copy…** on a signed record, for a walk-up off a signing code who gave a mobile and no email, or a copy that went to a wrong address. Only the four roles, never a training account or a digital twin, and an estimator is refused (`copyResendCallerRefusal`, *Only the office emails a signed copy.*); the caller's own client must still read the row. Only a signed agreement (`copyResendPaperRefusal`): an hours statement, a W-9, a certificate and a licence answer `400 not_a_copy`. An address that is not one answers `400 address`. The send is `sendSignedCopyTo` ([`_shared/signedCopyResendSend.ts`](../supabase/functions/_shared/signedCopyResendSend.ts)): the PDF kept for the paper, made when an older one has none, or a form's filled PDF, with `buildSignedCopyEmail`, filed as a sent copy with whoever pressed. A two-party form that waits for the office's half answers `409 office_step`, a paper with no PDF `409 no_pdf`, and a mail that did not go `502`, with the mail service's own reason in the words when it gave one (`copyResendMissWords`). It writes `signed_copy_sent_at` on the signed row and nothing else: `signer_email` stays as the signer gave it. The rules are [`_shared/signedCopyResend.ts`](../supabase/functions/_shared/signedCopyResend.ts), read by the press too; the file sits beside `personPaperSignedCopy.ts` and changes nothing in it, so [accept-contract](#accept-contract) owes no deploy. A request without the key is answered as before. Tests `src/lib/contracts/signedCopyEmail.test.ts`. **Deployed** 2026-12-01 (`person-paper-pdf` version 10, 07:19 UTC, read back with `supabase functions list`).

> **v2.9281 — a blank nobody filled prints as a ruled line**: `paperParagraphs` rules a name in square brackets, such as `[Company legal name]`, as a line of eighteen underscores ([`_shared/paperRuledBlanks.ts`](../supabase/functions/_shared/paperRuledBlanks.ts)), after the app's own blanks are filled and after the words are made plain. It holds for a signed paper's PDF drawn here, for a client's copy, and for the PDF of a paper that is out and not signed, which is then a copy to fill in by pen. A PDF kept before this deploy is handed back as it was drawn. **Owes a deploy after v2.9281 merges.**

**A plain paper's blanks (v2.9066, punch list #457):** `paperParagraphs` (`_shared/personPaperPdf.ts`) fills a copy's blanks from the `blank_values` kept at its signature, so the PDF and the signer's emailed copy print what was signed. A copy not yet signed keeps none, and its PDF shows a blank as written. Since v2.9111 the kernel it carries knows a ninth blank, `{outside_paper_goes_to}`. **Deployed** 2026-11-30 (`person-paper-pdf` version 9, 17:09 UTC, read back with `supabase functions list`). The v2.9111 change **deployed** 2026-12-02 (`person-paper-pdf` version 11, 13:59 UTC, read back with `supabase functions list`).

> **v2.9012 — a paper as sent names who was to sign** (finding 603, from the first live walk of the contract editor; the person's go of 2026-11-30): the *For* line of an unsigned paper's PDF named who the paper is with and nobody else, so a company's paper read *For ZZ Test Supply* and did not say who was to sign. It now reads *For ZZ Test Supply, to be signed by ZZ Test Signer*, from the signer's name on the row (`paperPdfAsSentForWords`, `drawPaperPdfAsSentNamed` in [`_shared/personPaperAsSent.ts`](../supabase/functions/_shared/personPaperAsSent.ts)). A person's own paper names a signer only when someone else signs for them, and a trade company's paper names the business its signer signs for. The file's name, the gate, the answer's shape and a signed paper's PDF are unchanged. The press still writes nothing: no row, no log, no kept file. The words live in a file of their own, which this function alone reads, so `accept-contract` and `get-contract-for-signer` are not behind for it; `drawPaperPdfAsSent` in `personPaperSignedCopy.ts` is left where it is and no function calls it now. **Deployed** on 2026-11-30 at 05:42 UTC (version 8), the one deploy that carries v2.9011 too (`supabase functions list` read on 2026-11-30 at 06:28 UTC, in the docs pass after #10416).
Expand Down
4 changes: 4 additions & 0 deletions docs/GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,10 @@ A **blank** in a plain paper (v2.9059, punch list #457, step 2) is a key in brac
Until v2.9068 the app held every paper that carried a blank (`PLAIN_BLANKS_ARE_FILLED`, the app's own switch, kept in `src/lib/contracts/plainBlanksLive.ts` since v2.9066 and false until then), and the signing page still offers no words that show a blank (`showsUnfilledBlank`).
Since v2.9066 the three functions fill them (`paperBlanksFor` in `supabase/functions/_shared/paperBlankValues.ts`): the signer's page answers the words filled, the signing keeps what each blank read in `blank_values`, the PDF prints a signed copy from it, and a blank with no value answers `paper_not_ready`.
Since v2.9068 that switch is on, a send is held only for a blank that has no value, named with its door (`blankSendHoldWords` in [`blankSendHold.ts`](../src/lib/contracts/blankSendHold.ts), over the functions' own `blankValuesNow` read with the sender's client), and the signed record window shows a signed copy's blanks as the values it kept (`signedCopyWords`).
Since v2.9281 a **blank nobody fills** is a second kind: a name in square brackets a person typed, such as `[Company legal name]`, which the app fills from nowhere and draws as a ruled line of eighteen underscores wherever a signer reads the paper ([`paperRuledBlanks.ts`](../supabase/functions/_shared/paperRuledBlanks.ts), read by the client and by the two functions that draw a paper's PDF).
The line is drawn on the signing page, the signed record, **Read the paper** in the send window, the library's **Preview** and both PDFs (`paperParagraphs`), and never written: the row keeps the bracket and its name, and nothing is kept for it in `blank_values`.
The library's **Edit**, **View** and **History** and the preview's **Download** keep the name.
One rule decides what is a blank (`isRuledBlankName`, `ruledBlanksInText`): a one-line name of 2 to 60 characters that starts with a letter, not a tick box, a footnote, a list mark, a lawyer's mark such as `[sic]` or `[Reserved]`, a bracket that touches a letter, or a Markdown link.
Since v2.9099 (finding 707) the three roads that call `send-contract-for-signature` themselves hold such a paper too, a trade company's paper on People → Contracts, a GC-mode partner's paper and a job's **Copy the signing link**, each through `blankHoldForCopy` in [`personPaperSendIo.ts`](../src/lib/contracts/personPaperSendIo.ts) with the door of its own road (`BlankHoldRoad`).
Since v2.9081 the company's own two values for a secrecy paper have a home, two rows of `app_settings` set by the owner or a dev on Settings → Company → **The company on our secrecy papers** ([`SecrecyCompanyValuesCard.tsx`](../src/components/settings/SecrecyCompanyValuesCard.tsx) over [`companyPaperValues.ts`](../src/lib/contracts/companyPaperValues.ts)): the company's legal name, which `{company_name}` prints, and who a secrecy paper from outside the company goes to first.
Since v2.9111 the functions read both (`COMPANY_BLANK_SETTINGS` in `supabase/functions/_shared/paperBlankValues.ts`, held to the app's two keys by a test), so `{company_name}` and the ninth blank `{outside_paper_goes_to}` fill on the signer's page, at the signing and on the PDF, and a send is held by name while one is not set, with the door *The owner or a dev sets it on Settings, Company, under The company on our secrecy papers.*
Expand Down
58 changes: 58 additions & 0 deletions docs/recent-features/v2.9281.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# v2.9281 — Papers: a blank nobody filled reads as a ruled line (2026-12-03)

The owner was asked whether a signer should ever be shown a paper with unfilled blanks like `[Company legal name]`. Their words: *no, make them "__________________"*.

**Owes prod two function deploys after the merge: `accept-contract` and `person-paper-pdf`.** No migration. The client's half is live with the Pages deploy.

## What a blank is, as the source had it

A paper had one kind of blank: a key in braces off the app's list of nine, such as `{code_name}`, put in by **Add a blank** and filled by the functions when the paper is read ([`plainPaperBlanks.ts`](../../src/lib/contracts/plainPaperBlanks.ts), `paperBlanksFor`). A signed copy keeps what each read in `blank_values`.

A name in square brackets, such as `[Company legal name]`, was plain words to the app. Nothing filled it, at the send or after, and the signer read the brackets. The secrecy papers hold these.

## What changed

One kernel decides what is a blank nobody fills and draws it: [`paperRuledBlanks.ts`](../../supabase/functions/_shared/paperRuledBlanks.ts), under `supabase/functions/_shared` so the client and the functions read the one file. The braces kernel is untouched.

**The line** is eighteen underscores, the string the owner typed. The words before it are kept: *Company:* and then the line.

**Where the rule holds:**

- **The signer's page** (`/contract/accept`), a plain paper's box and the full agreement of a paper built from clauses (`ContractBodyDisplay`'s `ruleBlanks`).
- **The PDFs** (`paperParagraphs` in `_shared/personPaperPdf.ts`): the signed copy `accept-contract` draws and emails, and every PDF `person-paper-pdf` draws, a paper that is out and not signed among them.
- **The signed record** window, beside the values a signature kept.
- **Read the paper** in the send window, which draws the paper as the signer reads it. Under the paper it names each blank nothing fills (`ruledBlanksNote`), so the sender still knows what each line stands for.
- **Preview**, the Contract library's page that prints.

**Where it does not, on purpose:** the library's **Edit**, **View** and **History**, and the preview's **Download**, keep the name in brackets. The office writes there, and that file is for editing. The email carries no words of the paper: the PDF is its copy.

## What counts as a blank

A pair of square brackets on one line, holding a name of 2 to 60 characters that starts with a letter and is made of letters, digits, spaces and `' - / & . , #`. These are the paper's own words and stay as typed:

- a tick box (`[x]`, `[ ]`), a footnote (`[1]`, `[^1]`), a list mark (`[a]`, `[ii]`), an ellipsis;
- a lawyer's or an editor's mark: `[sic]`, `[Reserved]`, `[Signature page follows]`, `[Remainder of page intentionally left blank]`, `[emphasis added]`, `[Seal]`, `[N/A]`;
- a bracket that touches a letter or a digit: `[T]he`, `employee[s]`;
- a bracket that holds a quote mark, a colon, a dollar sign or a sentence's other marks;
- in Markdown, a link, a picture and a link's reference.

Markdown is ruled after it is made plain words or HTML, never before: a line of underscores in Markdown source is a rule across the page, or a bold mark.

## What the signed record holds

Nothing new. The line is drawn, never written. A paper signed with a line still ruled keeps its words as written, bracket and name (`signing_body_html`), and `blank_values` holds nothing for it, since nothing was typed. The signed record window and the signed PDF draw the line there. So the record says that the blank was left empty, and the row still says which blank it was.

A signer cannot type into a ruled line on the page. Filling one is by pen, on a print.

## Seen and left

- A short name in square brackets that an older paper meant as its own words is now a line. One test's placeholder, `[brackets]`, was such a name and now reads `[sic]`. **Read the paper** names every line before a send.
- A signed PDF kept before the deploy is handed back as it was drawn, brackets and all. The signed record window draws the line for the same paper.
- Between the Pages deploy and the two function deploys, a signer reads lines on the page and a new PDF still prints the brackets.
- `/contract/sign`, the job's own contract, is another page with another PDF and is not ruled.
- A paper built from clauses is ruled in its full agreement's words, not in the clauses the database assembles.
- HTML's own writing of a bracket (`[`), and a name cut in two by a tag, are not read as blanks.

## Tests

`paperRuledBlanks.test.ts` (38: the rule, the own words, Markdown, HTML), `personPaperPdf.test.ts` (the PDF's paragraphs, the app's blanks filled first), `readThePaper.test.ts` (the note), and render tests for the signer's page, the signed record, the send window and the preview.
1 change: 1 addition & 0 deletions scripts/lowest-kernels.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
"../supabase/functions/_shared/paintedMapLink.ts",
"../supabase/functions/_shared/paperBlankValues.ts",
"../supabase/functions/_shared/paperChecks.ts",
"../supabase/functions/_shared/paperRuledBlanks.ts",
"../supabase/functions/_shared/paperSignedNotice.ts",
"../supabase/functions/_shared/paperSigner.ts",
"../supabase/functions/_shared/paperSitePrint.ts",
Expand Down
12 changes: 10 additions & 2 deletions src/components/contracts/ContractBodyDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import type { CSSProperties } from 'react'
import { renderContractBodyToSafeHtml } from '../../lib/renderContractBodyToSafeHtml'
import { ruleBlanksInHtml } from '../../../supabase/functions/_shared/paperRuledBlanks'

type ContractBodyDisplayProps = {
format: string | null | undefined
bodyHtml: string | null | undefined
/** Extra style for scroll container (modal views). */
scrollStyles?: CSSProperties
/**
* Draw a blank nobody filled, a name in square brackets like `[Company legal name]`, as a ruled line (v2.9281).
* For a window where a signer reads the paper, or the office reads it as the signer does. The office's own windows
* on the library leave it off and keep the name.
*/
ruleBlanks?: boolean
}

export function ContractBodyDisplay({ format, bodyHtml, scrollStyles }: ContractBodyDisplayProps) {
const safe = renderContractBodyToSafeHtml(bodyHtml, format)
export function ContractBodyDisplay({ format, bodyHtml, scrollStyles, ruleBlanks = false }: ContractBodyDisplayProps) {
const drawn = renderContractBodyToSafeHtml(bodyHtml, format)
const safe = ruleBlanks ? ruleBlanksInHtml(drawn) : drawn
if (!safe.trim()) return null

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ describe('ContractSendWindow · a copy whose words are in no version of the pape
})

describe('ContractSendWindow · Read the paper', () => {
it('draws a blank nobody fills as the line the signer reads, and names what each line stands for (v2.9281)', async () => {
open({ plan: { kind: 'insert', source: { ...SOURCE, signingBodyHtml: '<p>Company: [Company legal name]</p><p>Site: [address]</p>' } }, docId: null })
fireEvent.click(await screen.findByRole('button', { name: 'Read the paper' }))
expect(screen.getByTestId('contract-send-paper-words').textContent).toBe('Company: __________________Site: __________________')
expect(screen.getByTestId('contract-send-ruled-blanks').textContent).toBe('The signer reads a line to write on for each of these 2 blanks: Company legal name and address. Nothing fills them.')
})

it('says nothing of lines under a paper with no such blank', async () => {
open({ plan: { kind: 'insert', source: { ...SOURCE, signingBodyHtml: '<p>Section 4. [Reserved]</p>' } }, docId: null })
fireEvent.click(await screen.findByRole('button', { name: 'Read the paper' }))
expect(screen.getByTestId('contract-send-paper-words').textContent).toBe('Section 4. [Reserved]')
expect(screen.queryByTestId('contract-send-ruled-blanks')).toBeNull()
})

it('a first send shows its plan’s words at once, a change for this send among them, and reads no row', async () => {
open({ plan: { kind: 'insert', source: { ...SOURCE, signingBodyHtml: '<p>Changed for ZZ Test Supply alone.</p>' } }, docId: null })
const press = await screen.findByRole('button', { name: 'Read the paper' })
Expand Down
Loading
Loading