pi-durable-bot 0.8.16 → 0.8.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-durable-bot",
3
- "version": "0.8.16",
3
+ "version": "0.8.17",
4
4
  "description": "Open-source AI coworkers that read every channel, decide what matters, and act on their own computer. Self-hosted, any model.",
5
5
  "license": "MIT AND MPL-2.0",
6
6
  "type": "module",
@@ -27,8 +27,8 @@ Never ask for a secret in a chat message, and never write your own page for one.
27
27
 
28
28
  | Kind | Example | Who writes it |
29
29
  |---|---|---|
30
- | Display page | A report, a plan, tables, charts, a calculator. To read and explore | You, freely, in the best form for each piece of information. The kit saves time |
31
- | Answer page | Feedback, choices, text, a comment on a section, approve or reject | You, with the kit's components, or fully your own. Change the style and layout as you like: the components are a start, not a limit |
30
+ | Display page | A report, a plan, tables, charts, a calculator. To read and explore | You, with your own HTML and CSS, in the layout and look that fit this content and this reader |
31
+ | Answer page | Feedback, choices, text, a comment on a section, approve or reject | You. `pots.js` sends the answers; the layout and the look are yours |
32
32
  | Password page | A token for an app | Pots. You choose only the text on it, the keys and the file |
33
33
 
34
34
  ## Where pages live
@@ -56,173 +56,58 @@ pots page list # your pages, their links, whe
56
56
 
57
57
  ## The kit
58
58
 
59
- Pots serves a kit for pages, all optional:
59
+ Pots serves two scripts for pages, both optional:
60
60
 
61
- - `pots.css`: a calm look for reading, light and dark, with Inter for Latin text (in `fonts/`). One column on a phone; on a computer, the contents at the side and blocks that use the width.
62
- - `pots-ui.js`: charts from tables, tabs, sorting, filtering, contents that follow the reader, and a light and dark switch. Offline, and it works under the private-page CSP (see Content-Security-Policy).
63
- - `pots.js`: sends a form's answers to Pots, and gives the same light and dark switch.
61
+ - `pots.js`: sends a form's answers to Pots, all at once or part by part, and keeps what the person filled until then (see Answer pages); shows data from JSON files as text, reloads a page that changed, and adds a light and dark switch.
62
+ - `pots-ui.js`: tabs, sorting and filtering, and the same switch. Offline, and it works under the private-page CSP (see Content-Security-Policy). [Its first lines](../../kit/pots-ui.js) say how to use it and what to style.
64
63
 
65
- Link them relative to the page's link, not its folder on disk: from a page's `index.html`, also in `keep/`, use `../../__pots/kit/`, and add one `../` for each subfolder of the page. The source is in [../../kit/](../../kit/pots.css).
64
+ There is no shared stylesheet. Write each page's HTML and CSS yourself, for its content, and draw charts yourself, with inline SVG or CSS. Earlier pages may link `pots.css`, a shared look that Pots used to offer; it is still served, so they keep working.
65
+
66
+ Link the scripts relative to the page's link, not its folder on disk: from a page's `index.html`, also in `keep/`, use `../../__pots/kit/`, and add one `../` for each subfolder of the page. The source is in [../../kit/](../../kit/pots.js).
66
67
 
67
68
  ## Display pages
68
69
 
69
70
  **The goal.** A display page exists to get information across better than plain text in a chat can. That is its only job. For each piece of information, ask what lets the reader take it in fastest. When a better form fits the information, use it: a chart for amounts, a timeline for dates, two options side by side, a table to sort and search, a calculator for "what if". When a sentence says it faster, write the sentence. Never put in a chart, a card or a widget for show: a special form that does not help the reader is noise. A page of clear text with one good chart is better than a page full of components.
70
71
 
72
+ **The shape of the page.** Pages of different kinds need different shapes. Before you write, decide who reads this page and what they do with it: decide something, look something up, follow a plan, or read a text. Then choose the layout, the forms and the interactions that get this information across best for that. A trip plan can start with today and the next step; a table of results can be just the table. There is no set opening, and an earlier page is not a template for the next one.
73
+
71
74
  All that follows serves this goal: plain words make the text fast to read, the right form makes the shape of the information visible, and the layout puts more of it in view at once.
72
75
 
73
76
  **The text.** Always write in ASD-STE100 Simplified Technical <the reader's language>, and use the reader's ubiquitous language. Put the answer first.
74
77
 
75
78
  **The form.** A guide, not a rule. Use a row only when the information has that shape:
76
79
 
77
- | Information | A good form | With the kit |
78
- |---|---|---|
79
- | The answer, the conclusion | One sentence under the title, and key numbers if they help | `<header>`, `pots-stats` |
80
- | How much each of a few things is | A sorted bar chart, with a line for the limit or the target | `<table data-pots-chart="bar" data-marks="10000 Budget">` |
81
- | Parts of a whole | One bar in parts, with percentages | `data-pots-chart="stack"` |
82
- | Change over time | A line chart | `data-pots-chart="line"` |
83
- | Many records to look up | A table; past a dozen rows, sorting and a search box | `data-pots-sort`, `data-pots-filter` |
84
- | Many items × many properties, on a phone | One property at a time, or one card per row | `data-pots-tabs`, `table.pots-stack` |
85
- | A plan by day or week | A calendar: side by side on a computer, one day at a time on a phone | `pots-grid` or `pots-cols` with `data-pots-tabs="phone"` |
86
- | Steps in order | Numbered steps; a timeline for things at the same time | `ol.pots-steps`, `ul.pots-steps` |
87
- | A list to work through | A checklist that counts what is left | Your own script |
88
- | "What if…" | A slider or a field, and the result changes at once | Your own script |
89
- | A structure, a flow, how something works | An inline SVG drawing, with words on the arrows | Your own SVG |
90
- | A choice between options | Side by side, the differences marked, then an answer form | `pots-cols`, an answer form |
91
- | Details that only some readers need | Folded away | `<details>` |
92
-
93
- **The layout.** Use the device. On a computer, put text next to its chart, cards in columns and calendars side by side; on a phone, one column. Text keeps a comfortable line length; `pots-wide` lets a block, also a table or a bar chart, use the full width. The page itself never scrolls sideways; a wide table scrolls inside itself.
94
-
95
- **The look.** A page is an information page that the reader reads and answers, not a landing page. The kit draws it clean and calm: near-black text on a plain background, hairlines instead of boxes, and one accent colour for what the reader acts on or looks for: links, numbers, the chosen and the recommended choice, focus.
96
-
97
- - **Icons.** `data-icon="name"` puts a small line icon before an element's text; notes and questions get theirs from the kit. The names: check, x, info, warn, question, ban, arrow, up, down, clock, calendar, user, users, bot, chat, mail, link, lock, key, shield, eye, search, chart, file, code, terminal, settings, money, place, globe, star, bolt, flag, bell, list.
98
- - **Colour.** Choose an accent for each page that fits its content, with one line in its CSS: `:root { --pots-accent: light-dark(#305a88, #8bb0db); }` (the light and the dark colour; this one is a muted slate blue). The kit's muted teal is only the fallback for a page that sets none. Choose a muted, darker, low-saturation colour; bright, common colours (bright blue, purple, violet) look cheap. `pots-good`, `pots-warn` and `pots-bad` mark a status.
99
-
100
- In your own CSS, use the kit's parts so yours match: `--pots-line`, `--pots-soft` (a quiet surface), `--pots-accent-soft` (a light accent tint), `--pots-radius`.
101
-
102
- ### What the kit gives
103
-
104
- - Plain HTML already looks right: headings, lists, tables, code, quotes, images, `<details>`.
105
- - Layout: `pots-cols` (side by side on a computer, one under the other on a phone), `pots-grid` (cards in as many columns as fit), `pots-row` (boxes that wrap), `pots-wide`. `<nav class="pots-toc">` after the header: links to the sections, at the side on a computer and a row at the top on a phone.
106
- - The opening: `<header>` first in `<main>`, with `pots-eyebrow`, `<h1>`, one sentence, and `pots-meta` (the facts about the page in one line, a `<span>` for each).
107
- - Blocks:
108
- - `pots-stats` with `pots-stat` (`<div class="pots-stat"><b>€8,400</b><span>total</span></div>`); a change in a stat: `<small class="pots-delta pots-good" data-icon="up">12% on May</small>`.
109
- - `pots-points`, key points: `ul.pots-points` with dots, `ol.pots-points` with numbers.
110
- - `pots-card`, in `pots-grid` or `pots-cols`: a hairline over it, and its first `<h3>` is its title.
111
- - `pots-note`: a `<b>` at its start is its title.
112
- - `pots-steps`: `ol.pots-steps` with numbers, `ul.pots-steps` with dots (a timeline); a `<time>` first in an item shows a date over it.
113
- - `pots-flow`: `pots-node` boxes joined by arrows; a fork goes in `pots-lanes`, one `pots-lane` for each way.
114
- - `dl.pots-terms`: each `<div><dt>…</dt><dd>…</dd></div>` is a term and its meaning.
115
- - `blockquote.pots-quote`, with a `<footer>` for who said it.
116
- - `pots-kv` (a `<dl>` of names and values), `pots-badge`, `pots-no` (a section number in a heading: `<h2><span class="pots-no">2</span>Costs</h2>`).
117
- - Icons: `data-icon="name"` on any element; `<i data-icon="name"></i>` is the icon alone. They are CSS masks from `data:` URLs, so a page's CSP must allow `img-src data:`, as the one under Content-Security-Policy does. In your own CSS, `var(--pots-i-lock)` is the lock as a mask image.
118
- - Colours with a meaning: `pots-good`, `pots-warn`, `pots-bad` on a note, a card, a badge, a stat, a chart row or a `<span>` in `pots-meta`; `pots-info` on a badge, and on a card to mark the one you recommend (a fine accent border and tint). Text: `pots-muted`, `pots-num` (a right-aligned number cell). `pots-hl` highlights anything your script points at.
119
- - Light and dark: the page follows the system, and a small switch at its top corner (from `pots-ui.js` or `pots.js`) lets the reader choose; the choice is kept for all pages. A colour of your own must follow it: write `light-dark(<light>, <dark>)`, never `@media (prefers-color-scheme: dark)`, which does not follow the switch.
120
- - In your own CSS, use the kit's colours so dark mode works: `--pots-bg`, `--pots-soft`, `--pots-text`, `--pots-muted`, `--pots-faint`, `--pots-line`, `--pots-accent`, `--pots-accent-soft`, `--pots-accent-line`, `--pots-good`, `--pots-warn`, `--pots-bad` (each also `-soft`), and the chart colours `--pots-c1` (the accent) to `--pots-c7`; and its shapes: `--pots-radius-s`, `--pots-radius`, `--pots-radius-l`.
121
- - With `pots-ui.js`:
122
- - `<table data-pots-chart="bar|stack|line">` becomes a chart. Bar and stack: the first column names the rows, the second gives the values. Line: each row is a point on the x axis, each number column a line. `data-marks="380 You; 300 Her"` draws reference lines on bars, `data-max` or `data-min` fixes the scale (a line chart starts at zero unless its values sit far from zero; `data-min="0"` keeps zero), a `<caption>` becomes the title, and `data-pots-show="…"` names the button that shows the numbers. The table stays on the page, folded, so the numbers are one tap away.
123
- - `<div data-pots-tabs>` with `<section data-tab="Name">` children shows one at a time; `data-pots-tabs="phone"` does so only on a phone and shows all of them on a computer. `data-current` on a section opens it first; `box.potsSelect(i)` opens one from your script, and the box sends a `pots-tab` event.
124
- - Every table goes in a `<div class="pots-scroll">`, so it can take the full width and a wide one scrolls inside it.
125
- - Numbers in charts and sorting: a cell is read as a number only when all of it is one, written as in the page's `lang` (`€1,234.50` in English, `1.234,50 €` in German, `−3`), with at most a short unit. Give a cell `data-value="1234.5"` when its text is not a plain number, such as "about two weeks" or "high"; that value is used first. Other columns sort as text.
126
- - `<table data-pots-sort>`: a click on a column header sorts it. `<input type="search" data-pots-filter="#list">` hides the rows of that table, or its `[data-pots-item]` elements, that do not contain the text, and sends a `pots-filter` event.
80
+ | Information | A good form |
81
+ |---|---|
82
+ | How much each of a few things is | A sorted bar chart, with a line for the limit or the target |
83
+ | Parts of a whole | One bar in parts, with percentages |
84
+ | Change over time | A line chart |
85
+ | Many records to look up | A table; past a dozen rows, sorting and a search box |
86
+ | Many items × many properties, on a phone | One property at a time, or one card per row |
87
+ | A plan by day or week | A calendar: side by side on a computer, one day at a time on a phone |
88
+ | Steps in order | Numbered steps; a timeline for things at the same time |
89
+ | A list to work through | A checklist that counts what is left |
90
+ | "What if…" | A slider or a field, and the result changes at once |
91
+ | A structure, a flow, how something works | An inline SVG drawing, with words on the arrows |
92
+ | Places and routes | A map |
93
+ | A choice between options | Side by side, the differences marked, then an answer form |
94
+ | Details that only some readers need | Folded away |
95
+
96
+ **The layout.** Use the device. On a computer, put text next to its chart, cards in columns and calendars side by side; on a phone, one column. Text keeps a comfortable line length; a table or a chart can use the full width. The page itself never scrolls sideways; a wide table scrolls inside itself.
97
+
98
+ **The look.** A page is an information page that the reader reads and answers, not a landing page. Give it the look that fits its content, and keep it calm: a plain background, near-black text, thin lines rather than boxes, and one muted accent colour for what the reader acts on or looks for. Bright, common colours (bright blue, purple, violet) look cheap. Text must be easy to read: body text about 16–17 px, also in tables and notes; Chinese text with a line height of about 1.8–1.9 and at most about 40 characters to a line; clear space between paragraphs and above each section.
99
+
100
+ - **Light and dark.** Give each page both: `color-scheme: light dark`, and each colour as `light-dark(<light>, <dark>)`, never `@media (prefers-color-scheme: dark)`. Then the switch that `pots.js` or `pots-ui.js` adds follows the page: a 32-pixel `button.pots-theme` over the top corner of the page, with a plain look of its own. Keep that corner free, or place and style the button in your CSS.
127
101
 
128
102
  ### Your own components
129
103
 
130
- When a form in the table above has no kit part, write it: a calendar, a checklist, a calculator, a diagram. Do it when it lets the reader see or try something that text cannot show; else write the sentence.
104
+ When a form in the table above needs a part, write it: a calendar, a checklist, a calculator, a diagram. Do it when it lets the reader see or try something that text cannot show; else write the sentence.
131
105
 
132
106
  - Write the full content in the HTML first, so the page reads well without your script, for example in a phone's reader mode or when the script fails. The script adds the interaction.
133
107
  - Put the script in a file of the page, such as `cost.js`, loaded with `defer`. Then the page works under the private-page CSP.
134
108
  - A library (maps, formulas, diagrams, a chart library) loads under the private-page CSP only from the page itself: download it into the page's folder and load it from there.
135
- - Set text with `textContent`, never `innerHTML`, and keep nothing in `localStorage` (see One browser origin).
136
- - Use the kit's colour variables, and test it with the mouse, a finger and the keyboard.
137
-
138
- ### An example
139
-
140
- A page that compares three cities for a team trip, in `pages/offsite/`:
141
-
142
- ```html
143
- <!doctype html>
144
- <html lang="en">
145
- <head>
146
- <meta charset="utf-8">
147
- <meta name="viewport" content="width=device-width, initial-scale=1">
148
- <meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; base-uri 'none'; form-action 'self'">
149
- <title>Team offsite: where and what it costs</title>
150
- <link rel="stylesheet" href="../../__pots/kit/pots.css">
151
- <script src="../../__pots/kit/pots-ui.js" defer></script>
152
- <script src="cost.js" defer></script>
153
- </head>
154
- <body>
155
- <main>
156
- <header>
157
- <p class="pots-eyebrow" data-icon="place">Team offsite · Proposal</p>
158
- <h1>Team offsite: where and what it costs</h1>
159
- <p>Lisbon is the best choice. It costs €8,400 for 12 people, €1,600 under the budget.</p>
160
- <p class="pots-meta"><span data-icon="calendar">Prices from 16 November</span><span data-icon="users">For the team leads</span><span class="pots-warn" data-icon="warn">Flight prices change each day</span></p>
161
- <div class="pots-stats">
162
- <div class="pots-stat" data-icon="money"><b>€8,400</b><span>total</span><small class="pots-delta pots-good" data-icon="down">€900 on 2025</small></div>
163
- <div class="pots-stat pots-good" data-icon="check"><b>€1,600</b><span>under the budget</span></div>
164
- <div class="pots-stat" data-icon="users"><b>12</b><span>people</span></div>
165
- </div>
166
- </header>
167
- <nav class="pots-toc"><a href="#cities">Cities</a> <a href="#days">The three days</a> <a href="#size">Group size</a></nav>
168
-
169
- <h2 id="cities" data-icon="place">Three cities compared</h2>
170
- <div class="pots-cols pots-wide">
171
- <table data-pots-chart="bar" data-marks="10000 Budget">
172
- <caption>Total cost for 12 people</caption>
173
- <thead><tr><th>City</th><th class="pots-num">Cost</th></tr></thead>
174
- <tbody>
175
- <tr><td>Lisbon</td><td class="pots-num">€8,400</td></tr>
176
- <tr><td>Porto</td><td class="pots-num">€7,900</td></tr>
177
- <tr class="pots-bad"><td>Berlin</td><td class="pots-num">€11,200</td></tr>
178
- </tbody>
179
- </table>
180
- <ul class="pots-points">
181
- <li><b>Lisbon:</b> direct flights from all three offices.</li>
182
- <li><b>Porto</b> costs less. But two of our offices have no direct flights to Porto.</li>
183
- <li><b>Berlin</b> is over the budget. Hotels in Berlin cost more in March.</li>
184
- </ul>
185
- </div>
186
-
187
- <h2 id="days" data-icon="calendar">The three days</h2>
188
- <div class="pots-grid pots-wide" data-pots-tabs="phone">
189
- <section class="pots-card" data-tab="Thursday"><h3 data-icon="calendar">Thursday</h3>
190
- <ul class="pots-steps"><li><time>by 14:00</time>Flights arrive</li><li><time>19:30</time>Dinner together</li></ul></section>
191
- <section class="pots-card pots-info" data-tab="Friday"><h3 data-icon="star">Friday</h3>
192
- <ul class="pots-steps"><li><time>9:00–12:30</time>Planning for next year</li><li><time>afternoon</time>Free</li></ul></section>
193
- <section class="pots-card" data-tab="Saturday"><h3 data-icon="calendar">Saturday</h3>
194
- <ul class="pots-steps"><li><time>by 11:00</time>Check out</li><li><time>from 13:00</time>Flights leave</li></ul></section>
195
- </div>
196
- <p class="pots-note pots-warn"><b>Book by 30 November</b> The hotel holds the 12 rooms until then.</p>
197
-
198
- <h2 id="size" data-icon="users">If more people come</h2>
199
- <p id="cost-text">Each extra person adds about €700. With 14 people, the total is €9,800. This is still under the budget.</p>
200
- <div id="cost" hidden>
201
- <label>People <input type="range" id="people" min="8" max="16" value="12"></label>
202
- <p class="pots-note" id="cost-result" aria-live="polite"></p>
203
- </div>
204
- </main>
205
- </body>
206
- </html>
207
- ```
208
-
209
- `cost.js`, a small calculator. Without it, the sentence above it says the same:
210
-
211
- ```js
212
- const people = document.getElementById("people");
213
- const result = document.getElementById("cost-result");
214
- function show() {
215
- const total = 8400 + (people.value - 12) * 700;
216
- const left = 10000 - total;
217
- result.textContent = `${people.value} people: €${total.toLocaleString("en")}. ` +
218
- (left >= 0 ? `€${left.toLocaleString("en")} under the budget.` : `€${(-left).toLocaleString("en")} over the budget.`);
219
- result.classList.toggle("pots-warn", left < 0);
220
- }
221
- people.addEventListener("input", show);
222
- show();
223
- document.getElementById("cost-text").hidden = true;
224
- document.getElementById("cost").hidden = false;
225
- ```
109
+ - Set text with `textContent`, never `innerHTML`, and keep nothing private in the browser's storage (see One browser origin).
110
+ - Test it with the mouse, a finger and the keyboard.
226
111
 
227
112
  ### Look at it before you send it
228
113
 
@@ -241,7 +126,7 @@ It sets the page's width as a phone does (`--window-size` can not make a window
241
126
 
242
127
  ## Answer pages
243
128
 
244
- The kit's components make an answer page quickly. A complete one:
129
+ `pots.js` sends the answers of a form marked `data-pots`; the rest of the page is yours. A complete answer page, with its own `page.css` (not shown):
245
130
 
246
131
  ```html
247
132
  <!doctype html>
@@ -250,17 +135,13 @@ The kit's components make an answer page quickly. A complete one:
250
135
  <meta charset="utf-8">
251
136
  <meta name="viewport" content="width=device-width, initial-scale=1">
252
137
  <title>Deploy plan 4.2</title>
253
- <link rel="stylesheet" href="../../__pots/kit/pots.css">
138
+ <link rel="stylesheet" href="page.css">
254
139
  <script src="../../__pots/kit/pots.js" defer></script>
255
140
  </head>
256
141
  <body>
257
142
  <main>
258
- <header>
259
- <p class="pots-eyebrow">Needs your answer</p>
260
- <h1>Deploy plan 4.2</h1>
261
- <p>Five questions. I start the deploy when I have your answers.</p>
262
- <p class="pots-meta"><span class="pots-warn">Answer by Friday</span><span>About 2 minutes</span></p>
263
- </header>
143
+ <h1>Deploy plan 4.2</h1>
144
+ <p>Five questions, by Friday. I start the deploy when I have your answers.</p>
264
145
  <form data-pots data-pots-done="Thanks, I have your answers.">
265
146
  <fieldset data-pots-question="target">
266
147
  <legend>Where should I deploy first?</legend>
@@ -277,11 +158,11 @@ The kit's components make an answer page quickly. A complete one:
277
158
  <section data-pots-question="step-3">
278
159
  <h2>3. Migrate the data</h2>
279
160
  <p>Runs on the live database, with about 10 minutes of read-only mode.</p>
280
- <div class="pots-approve">
161
+ <div>
281
162
  <label><input type="radio" name="step-3" value="approve" required> Approve</label>
282
163
  <label><input type="radio" name="step-3" value="reject"> Needs changes</label>
283
164
  </div>
284
- <details class="pots-comment"><summary>Comment</summary>
165
+ <details><summary>Comment</summary>
285
166
  <textarea name="step-3-comment" data-pots-comment></textarea>
286
167
  </details>
287
168
  </section>
@@ -311,21 +192,21 @@ All are normal form elements inside `<form data-pots>`; `pots.js` reads them whe
311
192
  | Multiple choice | checkbox inputs | `[{"value": "support", "label": "Support"}, …]`, maybe `[]` |
312
193
  | Text, one line | `<input type="text">` (or `email`, `number`, `date` …) | the text |
313
194
  | Text, several lines | `<textarea>` | the text |
314
- | A comment on a section | a `<section>` with your content and a `<textarea data-pots-comment>`, best inside `<details class="pots-comment">` so it opens only when wanted | `"comment": "…"` next to the section's answer, only when written |
315
- | Approve or reject | radio inputs with values `approve` and `reject` in `<div class="pots-approve">` | like a single choice; add a comment field for the reason |
195
+ | A comment on a section | a `<section>` with your content and a `<textarea data-pots-comment>`, best inside a `<details>` so it opens only when wanted | `"comment": "…"` next to the section's answer, only when written |
196
+ | Approve or reject | radio inputs with values `approve` and `reject` | like a single choice; add a comment field for the reason |
316
197
 
317
198
  - A `<select>` works too: like a single choice, and with `multiple` like a multiple choice. Fields of different kinds, or several text fields, in one question give an object with one value per field `name`. A field outside every question is a question of its own, named by its `name`.
318
199
  - The question's text, which comes back with the answer, is `data-pots-text="…"` when you set it, else its first `data-pots-label` element, `legend` or heading, else the label's own text. A choice's label is the text of its `<label>`.
319
200
  - `required` works as in any form: the browser asks for the field before it sends. Do not put a required field in a closed `<details>`.
320
- - `data-pots-done="…"` on the form is the text shown after the answers are sent. `<p data-pots-status></p>` places the status line; without it, it goes after the submit button.
321
- - After a successful send the form is disabled and says so; reloading the page gives an empty form, and sending again is a new answer.
201
+ - `data-pots-done="…"` on the form is the text shown after the answers are sent. `<p data-pots-status></p>` places the status line; without it, it goes after the submit button. Its `data-state` is `sending`, `retrying`, `done` or `failed`.
202
+ - pots.js keeps what the person fills in, in their browser, so leaving or reloading the page loses nothing. A form of two or more questions also gets a bar, `.pots-partial`, that stays in view while they scroll and sends the questions they filled or changed since their last send, as a partial answer; the form stays open, and each question whose answer you have gets `data-pots-sent`. The submit button still sends everything. The bar and the mark have a plain look: style, place or hide them in your CSS.
203
+ - After the full send the form is disabled and says so, and what the browser kept of it is deleted; reloading the page gives an empty form, and sending again is a new answer.
322
204
 
323
- How pots.js sends: it takes the page's version that Pots sent with the HTML file, in the response header `Server-Timing: pots-version;desc="<version>"`. When the browser does not give it, it reads the version from `__pots/info` of the link, once, on load; if that fails, it never sends the answers with a version read later, which could be a newer page's, but asks the person to reload the page, with their answers still on screen. On submit it posts `{"submission": "<ID>", "version": "<the version the person saw>", "answers": {…}}` to `__pots/submit`, with one submission ID for every try of the same submit. If the network fails, or Pots answers with a server error, it shows "trying again" and tries again, with longer waits up to 30 seconds, and at once when the phone is back online. Pots wakes you once per submission ID, also when only its reply got lost. A revoked link gets "This link no longer works". Answers are at most 64 KB.
205
+ How pots.js sends: it takes the page's version that Pots sent with the HTML file, in the response header `Server-Timing: pots-version;desc="<version>"`. When the browser does not give it, it reads the version from `__pots/info` of the link, once, on load; if that fails, it never sends the answers with a version read later, which could be a newer page's, but asks the person to reload the page, with their answers still on screen. On submit it posts `{"submission": "<ID>", "version": "<the version the person saw>", "answers": {…}}` to `__pots/submit` (with `"partial": true` for a part), with one submission ID for every try of the same submit. If the network fails, or Pots answers with a server error, it shows "trying again" and tries again, with longer waits up to 30 seconds, and at once when the phone is back online. Pots wakes you once per submission ID, also when only its reply got lost. A revoked link gets "This link no longer works". Answers are at most 64 KB.
324
206
 
325
- ### Other classes and attributes
207
+ ### More of pots.js
326
208
 
327
- - Everything in "What the kit gives" works on an answer page too. A choice can have an explanation on a line of its own: `<label><input type="radio" name="target" value="test"> Test <small>Nobody outside the team sees it</small></label>`. `pots-secondary` is a quieter button.
328
- - `<body data-pots-refresh="5">`: every 5 seconds the page asks Pots whether any of its files changed, and reloads when one did; when the person has started to fill a form, it shows "This page has changed" with a Reload button instead. Use it for progress pages. A Quick Tunnel cannot push to the browser (no Server-Sent Events), so pages poll.
209
+ - `<body data-pots-refresh="5">`: every 5 seconds the page asks Pots whether any of its files changed, and reloads when one did; when the person has started to fill a form, it shows "This page has changed" with a Reload button instead, in a `.pots-banner` at the top of the page. Use it for progress pages. A Quick Tunnel cannot push to the browser (no Server-Sent Events), so pages poll.
329
210
  - Text that other people wrote (comments, names, messages) must never become HTML: someone's `<script>` would run on the page. Write it into a JSON file next to the page and let the kit show it as text:
330
211
  ```html
331
212
  <div data-pots-source="comments.json">
@@ -334,11 +215,11 @@ How pots.js sends: it takes the page's version that Pots sent with the HTML file
334
215
  </div>
335
216
  ```
336
217
  With `comments.json` = `{"updated": "10:02", "items": [{"who": "Alice", "text": "Looks good"}]}`, the first child of a `data-pots-list` repeats for each item. pots.js sets only `textContent`, never `innerHTML`. If you write such text into HTML yourself, escape `&`, `<`, `>` and `"`.
337
- - `window.PotsKit.submit(answers)` sends answers your own script built, with the same version, submission ID and retries; it resolves `{ok: true}` or `{ok: false, status, message}`. `PotsKit.collect(form)` gives a kit form's answers without sending them. The kit's source is [../../kit/pots.js](../../kit/pots.js), [../../kit/pots-ui.js](../../kit/pots-ui.js) and [../../kit/pots.css](../../kit/pots.css).
218
+ - `window.PotsKit.submit(answers)` sends answers your own script built, with the same version, submission ID and retries (`PotsKit.submit(answers, {partial: true})` for a part); it resolves `{ok: true}` or `{ok: false, status, message}`. `PotsKit.collect(form)` gives a kit form's answers without sending them. The kit's source is [../../kit/pots.js](../../kit/pots.js) and [../../kit/pots-ui.js](../../kit/pots-ui.js).
338
219
 
339
- ### Fully custom pages
220
+ ### Answers without pots.js
340
221
 
341
- Write any HTML, CSS and JavaScript, with any libraries. To send answers without pots.js, post JSON to `__pots/submit` under the link's base (`/p/<token>/__pots/submit`): `{"submission": "<a random ID you make once and send again on every retry>", "version": "<the version of the page on screen: the pots-version Server-Timing entry of the page's load, in performance.getEntriesByType(\"navigation\")[0].serverTiming, or else GET __pots/info as soon as the page loads>", "answers": {…}}`, at most 64 KB. Pots answers `200 {"ok": true}`, also for a repeat of a submission ID, which does not wake you again; `400` for a bad body; `404` for a revoked or unknown link. Give each answer its question's text, as the kit does, so that you can judge an answer to an older version.
222
+ To send answers without pots.js, post JSON to `__pots/submit` under the link's base (`/p/<token>/__pots/submit`): `{"submission": "<a random ID you make once and send again on every retry>", "version": "<the version of the page on screen: the pots-version Server-Timing entry of the page's load, in performance.getEntriesByType(\"navigation\")[0].serverTiming, or else GET __pots/info as soon as the page loads>", "answers": {…}}`, and `"partial": true` when more may follow, at most 64 KB. Pots answers `200 {"ok": true}`, also for a repeat of a submission ID, which does not wake you again; `400` for a bad body; `404` for a revoked or unknown link. Give each answer its question's text, as the kit does, so that you can judge an answer to an older version.
342
223
 
343
224
  ## How answers come back
344
225
 
@@ -348,6 +229,8 @@ A submission wakes you at once, as a timed wake with this note:
348
229
  page answer: someone used link <link ID> (made for <person address | anyone>) on page <name> (version <version>): <answers as JSON>
349
230
  ```
350
231
 
232
+ A part of the answers starts `page answer (partial: some answers now, more may follow):`.
233
+
351
234
  The answers of the example page look like this:
352
235
 
353
236
  ```json
@@ -359,6 +242,7 @@ The answers of the example page look like this:
359
242
  ```
360
243
 
361
244
  - The version is the page as the person saw it. The version changes whenever any file of the page changes; `curl -s <link URL>__pots/info` gives the version now. When they differ, the person answered an older page: the question texts show what they saw, and you judge whether the answer still counts.
245
+ - A partial answer has the questions the person filled or changed since their last send, and they may send more. The answer without "(partial…)" is the whole form, also what they sent before.
362
246
  - An answer through a link made for Alice was sent by someone who had that link. Usually that is Alice; when it matters, ask her.
363
247
  - Answers are in your log like other wakes. Tell the people what you did with them, in the chat where you sent the link.
364
248
 
@@ -433,7 +317,7 @@ What a Quick Tunnel means, from Cloudflare's docs and how it works:
433
317
  3. If `tailscale status` says this computer is not signed in, run `tailscale up`. It prints a link: send it to the person, who opens it and signs in (Google, GitHub, Apple, Microsoft and others).
434
318
  4. See what is mapped already: `tailscale funnel status` and `tailscale serve status`. Tailscale is one per computer, shared by every user and every Pots on it, and Funnel listens only on ports 443, 8443 and 10000. On a computer that others use, take a port that is free, or a path under a port (`--set-path /<path>`), and never change, replace or `reset` a mapping you did not make.
435
319
  5. Map the page port (`pagePort` in `~/.pots/settings.json`): `tailscale funnel --bg <pagePort>` for port 443, or `tailscale funnel --bg --https=8443 <pagePort>`, or add `--set-path /<path>`. `--bg` keeps it after restarts. The first time, Tailscale prints a link to a page where the person approves Funnel for their tailnet: send it to them.
436
- 6. The address can take up to 10 minutes to work the first time (DNS). Check it: `curl -sS https://<machine>.<tailnet>.ts.net[:<port>][/<path>]/__pots/kit/pots.css` must print the stylesheet. If it does not after 10 minutes, the mapping is wrong; do not use it.
320
+ 6. The address can take up to 10 minutes to work the first time (DNS). Check it: `curl -sS https://<machine>.<tailnet>.ts.net[:<port>][/<path>]/__pots/kit/pots.js` must print the script. If it does not after 10 minutes, the mapping is wrong; do not use it.
437
321
  7. Ask the person before you set or change `publicUrl`: every link that any bot of this computer sent before stops working, because it points at the old address. Then write `"publicUrl": "https://<machine>.<tailnet>.ts.net[:<port>][/<path>]"` into `~/.pots/settings.json`, keeping `pagePort`. The next `pots page link` should say `"via": "public-url"`. Note the change and the date in the memory all bots share (`~/.pots/memory/`), so the other bots know why their old links stopped.
438
322
  8. Tell the person about [key expiry](https://tailscale.com/docs/features/access-control/key-expiry): Tailscale signs a computer out after 180 days by default, and then the links stop working until someone signs in again. They can turn it off for this computer in the Tailscale admin console (Machines, the menu of this machine, Disable key expiry). Key expiry is a security feature: with it off, a lost or stolen computer stays in their tailnet until they remove it. Let them choose.
439
323
 
@@ -449,7 +333,7 @@ Pots puts no browser restrictions on your pages, so they can use any outside scr
449
333
 
450
334
  ## One browser origin
451
335
 
452
- All pages of this computer, of every bot, are under one address, so the browser treats them as one site. A script on one page can read what another page keeps in the browser. So never keep private data in `localStorage`, `sessionStorage`, IndexedDB or cookies; the kit keeps only the reader's light or dark choice there.
336
+ All pages of this computer, of every bot, are under one address, so the browser treats them as one site. A script on one page can read what another page keeps in the browser. So never keep private data in `localStorage`, `sessionStorage`, IndexedDB or cookies. The kit keeps the reader's light or dark choice there, and each form's draft encrypted with a key made from the page's link, which other pages do not know.
453
337
 
454
338
  ## Website projects
455
339