Read a PDF, select text, press a key, write what is wrong with it. Every comment is saved to a JSON file together with the exact text and position it refers to, so a script or a coding assistant can find the right place in the source.
just-doc book.pdf # open for commenting
just-doc book.pdf --read # print the comments
just-doc book.pdf --export # write book.commented.pdf with the comments inside
just-doc notes.md # a markdown file works the same way
just-doc slides.html # and an HTML file, such as a slide deck
just-doc page.html --live # an HTML page as it is, scripts running, to comment and answer
just-doc page.html --shot page.png # a picture of that page, to check it before showing it
just-doc # list the open documents; open the window again if it was closed,
# or start just-doc again with the documents it had
just-doc book.pdf --wait # open it, wait for Ctrl+Enter, then print the comments
just-doc book.pdf --reply 2 "text" # add a reply to comment 2
just-doc --hc-terminal t12 # bring the window up with the last document from hc terminal t12
just-doc --guide # how a coding assistant reviews a document with youWith uv:
uv tool install git+https://github.com/ladisk/just-docor with pipx: pipx install git+https://github.com/ladisk/just-doc.
To try it without installing: uvx --from git+https://github.com/ladisk/just-doc just-doc book.pdf.
Needs Python 3.9 or newer; the only dependency is pypdf, used for the export. The window is a Chromium, Brave or
Chrome app window if one is installed, otherwise a tab in the default browser.
One just-doc serves all open documents as tabs of one window. It runs in the
background: the first just-doc FILE starts it as a process of its own (its own
session, no terminal, and on Linux with systemd its own scope, systemd-run --user --scope) and returns as soon as the document is open, like every later command,
which hands its document over as a new tab. Closing the terminal of that command,
or stopping the process group, service or scope it ran in, leaves just-doc
running; so does a SIGHUP. SIGTERM and q y in the window stop it.
just-doc keeps the list of its tabs in ~/.cache/just-doc/session-<port>.json
(written again whenever a tab opens, closes or is selected). A just-doc that
starts with none running opens these tabs again, so just-doc without a file
brings back the documents of the last one, after q y, a crash or a restart,
and just-doc FILE adds its document to them. A tab whose file is gone is left
out; a page of another machine (--hc-machine) is kept and reached again through
ssh when it is shown. Closing every tab empties the list; with an empty list (or
none), just-doc without a file starts nothing and ends with status 1.
Each just-doc writes one line to ~/.cache/just-doc/server-<port>.log when it
starts (with the tabs it restored and the ones it left out, and why), when a
command restarts it for an update, on an error in a request or a thread, on a
SIGHUP, and when it ends (q y, stopped for an update, SIGTERM, SIGINT, an
error). A start line with no exit after it means it was killed with no chance
to write (SIGKILL, a crash). The file keeps its last 200 lines.
One just-doc serves all open documents, and it keeps running after just-doc
was updated. The next just-doc command that finds it running another version
(the package version and a hash of its code, so an editable install with new
commits counts too) restarts it as the new version on the same port, with the
same tabs, the hc terminals they came from, the pages of other machines and a
Ctrl+Enter that no --wait has taken yet. Comments and answers are on disk
already. The tabs go through session-<port>.json, so if the new just-doc does
not start, just-doc without a file starts it with them. The window stays and loads itself again once nothing is being typed
in it; fields filled in on a live page keep it on the old version until F5.
The window of a just-doc older than this behaviour closes, and a new one opens.
Commands started at the same moment take turns (a lock file in the cache
folder), so they start, or update, one just-doc with one window between them.
While a just-doc --wait waits on it, it is not restarted: the command prints
one line saying so and is done by the old just-doc, or ends with that line when
the old one cannot do it. The update follows when the --wait ends and no
other --wait starts within a few seconds.
| key | action |
|---|---|
a |
highlight the selection and write a comment; Enter in an empty field leaves a plain highlight. On a comment (the selected one, the one of the open card or the one under the cursor): edit what you wrote last, the comment or your last reply, while the assistant has not seen it; after that, reply (see "Reviewing with a coding assistant"); an empty field takes an edited reply away |
x |
mark the comment done yourself, when the assistant's answer needs no reply; x again opens it |
za |
open or close the row of the comment in the list, or on a change the group of changes; zR / zM open / close all rows |
D |
show or hide the comments that are done |
m / M |
mark what changed since the last hand-over / since the last commit; the same key again hides the marks (see "What changed") |
a on the card of a change |
comment on that change |
gb |
show the page at the cursor as it was before the changes; gb or Esc goes back |
gh |
history: the rounds so far, each with what you handed over, the answers and the changes; Enter shows the document as it was at the end of a round (see "Rounds and history") |
Ctrl Enter |
hand the comments over to the just-doc --wait that is waiting for them |
s |
strike through the selection: this text should be deleted |
r |
draw a rectangle (for a figure, an equation or code) and comment on it; a click with no drag puts a point instead, for a place with no text |
d |
delete the selected highlight or rectangle (click it first) |
u |
undo the last delete |
c |
hide or show the comment list, so the page gets the full width |
C |
hide or show the highlights and the link marks on the page, to read the clean text; the selected one stays visible |
n / p |
go to the next / previous in the comment list, top to bottom: the answered comments first, then the open ones, then the changes; done comments of earlier rounds are skipped unless D shows them; a card shows the reply, your comment and the changes near it (see "What changed"); gn / gN do the same |
Enter |
follow the link under the cursor (a click on a link does the same); Tab / Shift Tab move the cursor to the next / previous link on the page |
K |
preview the target of the link under the cursor: a crop of the target page in a popup (resting the mouse on a link does the same); j / k or the mouse wheel scroll it within the target page, a click on it goes there, Esc or K closes it |
Ctrl o / Ctrl i |
jump back to where you were before a jump / forward again; the back / forward buttons of the mouse do the same |
/ |
search the whole PDF: type the text, Enter; then n / N go to the next / previous match and Esc ends the search |
t |
table of contents: j / k move, Enter goes there, Esc closes |
h j k l, w b e, 0 $ |
move the cursor (see below); the page follows it |
↓ / ↑ |
move the cursor a line down / up, as j / k do; also in a selection |
f / F + a character |
move the cursor to that character after / before it on the line (fa, 3fa); the wait for the character ends after 1.5 s |
; / , |
repeat the last f or F / repeat it the other way |
gg / G |
go to the top / bottom of the document, with the cursor on the first word / the last line; with a number first (12G) go to that page |
Ctrl d / Ctrl u |
half a page down / up |
zt / zz / zb |
scroll so that the cursor line is near the top / in the middle / near the bottom of the window, with about two lines above or below it; also in a selection |
← / → |
go to the previous / next page |
P |
single page view: show one page at a time, fitted to the window; P again goes back to the continuous view and the zoom from before |
v / V |
start a visual / visual line selection (see below) |
Ctrl + wheel, Ctrl + / - / 0 |
zoom the page around the pointer; the toolbar and comment list keep their size |
Ctrl S |
export a copy of the PDF with the comments inside |
Ctrl Shift S |
markdown or HTML file: save the PDF made from it as notes.pdf next to it, without comments |
H / L |
previous / next tab of the group, when several documents are open; Alt ← / Alt → do the same |
Alt ↑ / Alt ↓ |
previous / next group of tabs, see below |
Alt s |
hide or show the list of groups at the left of the window; the choice is kept |
Ctrl w |
close the tab; Alt w does the same |
q then y |
stop just-doc and close its windows; a --wait that is waiting ends too. The tabs are kept: just-doc without a file starts it again with them. Closing the window alone leaves just-doc running, and just-doc without a file opens the window again |
? |
show or hide the full key list; in it / filters the keys by what you type |
Esc |
deselect |
A comment, a reply and an edit are written in a field at the bottom of the
comment's card, under its text. Enter saves, Shift+Enter starts a new
line, Esc cancels.
The browser's own shortcuts (print, find, history, bookmarks and so on) are
switched off in the window. Copy (Ctrl+C), reload (Ctrl+R, F5), full
screen (F11) and the developer tools (F12) still work.
The first just-doc book.pdf opens the window. While it runs, every further
just-doc other.pdf adds the document as a new tab of the same window and
returns at once. H and L change the tab and Ctrl+w closes it; the
tab bar shows only when more than one document is open. Each tab keeps its
page, zoom, cursor and search.
One session of an assistant often opens several documents. The tabs are grouped
by the hc terminal that opened them (HC_TERMINAL_ID, on its machine); documents
opened without a terminal form the group other. The row of tabs at the top
has the tabs of the shown group only; the × on a tab closes it, as Ctrl+w
does. With several groups a list at the left of the window has one row per
group: its name, the machine of a group of another machine, the number of new
replies of its tabs, an orange dot when a --wait waits or a Ctrl+Enter was
not taken yet, and its tab count. The groups keep their order. The shown group
has a lighter row with a blue bar at its left. Alt+s hides or shows the list;
the window keeps the choice, and with the list hidden the name of the shown
group is in front of its tabs. Drag the right edge of the list to change its
width (kept too); a double-click on the edge sets it back. With one group there is no list. A click on a
row, or Alt+Down / Alt+Up, shows that group (its tab shown last). H / L and Alt+Left / Alt+Right change the
tab within the group and wrap. --hc-terminal and a new document show their own
group. A group ends with its last tab.
The name is the project folder of the documents: the folder that has a .git
above the document, otherwise its folder; for several documents the folder they
share. A group of another machine has the machine in front (work2: thesis);
two groups with the same name get the terminal id after it. /api/tabs has
group on every tab and the list groups (id, label, machine,
terminal, count).
Closing the window leaves just-doc running; the next just-doc opens a new
window with the tabs (see "Start, stop and the documents kept").
A blue block marks the cursor. It moves as in vim, so no mouse is needed:
| key | move |
|---|---|
h / l |
one character left / right |
w / b / e |
next word / start of the word / end of the word |
j / k |
one line down / up |
0 / $ |
start / end of the line |
A number first repeats the move: 3w, 5j. The page scrolls to follow the
cursor, and when you scroll the page the cursor stays on the screen. A click
puts the cursor on the clicked character.
v starts a selection at the cursor; V does the same but selects whole
lines. The same keys then extend the selection, also onto the next page, and
o switches to its other end. Press a to comment on the selection or s to
strike it through. Esc cancels. Text selected with the mouse (a drag, a
double or a triple click) is the same selection: the cursor is at its end and
the keys go on from there.
In a selection, i and one more key select the thing around the cursor:
| keys | select |
|---|---|
iw |
the word |
is |
the sentence |
ip |
the paragraph |
i( i[ i{ i< |
the text inside the brackets around the cursor |
i" i' |
the text inside the quotes, straight or typographic |
So vis a comments on the sentence under the cursor. The selection can be
extended with the usual keys afterwards.
In vim, a is the "around" form (va( takes the brackets too). Here a in a
selection writes the comment, so va( does not exist; the capital A takes
its place: vA(, vA".
A sentence ends at ., ? or ! before a capital letter, so it can stop too
early after an abbreviation that is not known. A PDF stores lines and not
paragraphs, so a paragraph is guessed from a larger gap between lines, an
indented first line or a change of the text size. Both stay on one page. A
margin note next to the text is left out of the sentence or paragraph, and it
is a paragraph of its own.
c and P remember their state between runs.
In the single page view, j on the last line and k on the first line turn
the page, and so do PageDown and PageUp. A selection stays on its page.
Links inside the PDF (a reference to an equation, a citation, an entry of the
printed contents) are marked with a blue underline and work: put the cursor on one and press Enter, or click it.
To look at the target without going there, rest the mouse on the link or press K: a popup shows that part of the target page. The wheel or j / k scroll it
up and down within that page.
Ctrl+o then returns to the place of the link, with the cursor where it was.
The same key returns from every other jump: a search, the contents panel,
n / p, gg, G. Ctrl+i goes forward again. A web link opens in the
browser.
/ searches all pages, not only the ones on the screen. Lower-case text
matches both cases; a capital letter in the query makes the search exact. The
cursor moves to the match, so v can start a selection there. While a search
is active, n and N step through the matches and not through the comments.
book.pdf → book.comments.json, in the same folder, rewritten after every
change (a page shown with --live has its own, see "Comments on a live page"). Each entry holds the selected text, the comment, and rects: page
number p and position in PDF points measured from the top-left corner.
An entry with kind strike is struck-through text that should be deleted,
kind box is a rectangle, and kind pin is a point: its one rectangle has
no size, text is empty, and near holds the text line just above it. An
entry without kind is a highlight.
before and after hold the letters and digits around the text, to find it
again in a changed document (see "When the document changes"); was is the
text as it was when it has changed since, and lost marks a comment whose
text is not found any more. n is the number of the comment, given when it is
written; it never changes, and the window, --read, --wait and --reply
use it. change marks a comment on a change (a on
the card of a change, see "What changed"): it holds the text as it was before the change, and
an empty text with a change means that the text was removed.
A comment can have replies, a list of entries with text, the time at and
from, the name given with --reply. A reply without from was written in
the window. done marks a comment as done, and done_at holds when. seen
lists the times a just-doc --wait showed the comment to the assistant.
A coding assistant (Claude Code, opencode, pi or any other that can run shell commands) can answer your comments in the window and fix the source, so the whole review happens in just-doc. Tell it:
Run
just-doc --guide, then reviewnotes.mdwith me.
just-doc --guide prints the instructions for the assistant: which commands
to run and how to read their output. Nothing is set up for a particular
assistant; it only runs the three commands below.
The round goes like this:
- The assistant runs
just-doc notes.md --wait. The window opens. - You write comments and press
Ctrl+Enter. The message at the bottom says whether somebody is waiting for them. - The assistant replies. Each reply shows at once in the list. A blue mark
in the toolbar counts the comments with a new reply, and so do the tab and
the title of the window. The answered comments come first in the list,
and
ngoes through them from the top; a comment that you go to is no longer new. While no reply has come, the mark says that the comments are handed over; while ajust-doc --waitwaits for you, a green mark says so, and an amber one says that no--waithas taken yourCtrl+Enteryet: the assistant has to run--waitagain. The replies come one by one while the assistant works ("the assistant is answering … 2 replies so far"); when it waits again, its answers are complete: a large green mark says "✓ answers ready", a message pops up, and the title of the window and the tab get a ✓. The changes in the document are marked too, and come last in the list (see "What changed"). - To answer a reply, press
aon its card (or on the selected comment), write in the field that opens at the bottom of the card, and pressCtrl+Enteragain. BeforeCtrl+Enter,aagain edits that reply. When the answer needs no reply, pressxto mark the comment done. - When you agree, the assistant changes the source. The window loads the new version by itself and the comment is marked as done.
Each row of the list is two lines: a mark that says where the comment stands,
the page and the text;
then who spoke last and what. The selected comment has a red frame and its row
is open, with the whole conversation; za opens or closes a row, zR / zM
all of them. Below the comments, one closed line counts the changes that have
no comment; the row that n is on shows under it, and za on a
change (or a click on the line) shows them all.
The marks (the ? key list explains them too):
| mark | meaning |
|---|---|
| not handed over | written or answered after your last Ctrl+Enter |
| not seen yet | handed over, but no --wait has shown it to the assistant yet |
| seen 10:42, no reply | the assistant was shown it then and neither answered nor marked it done |
| new reply / new: done | the assistant answered or marked it done, and you have not looked yet |
| answered | the assistant spoke last and you have looked at it |
| done ✓ | done; it leaves the list at your next Ctrl+Enter |
| change | a change since the last hand-over that no comment asked for |
When the assistant is shown a comment again that it left unanswered before,
--wait marks it with "(shown to you before and not answered)".
just-doc book.pdf --waitopens the document if it is not open, waits for Ctrl+Enter in the window,
prints the open comments and ends. A comment is open when it is not done and
you spoke last. A Ctrl+Enter pressed while nobody waits is kept for the next
--wait. With --timeout 100 the command gives up after 100 seconds with
exit status 2, for an assistant whose shell limits the run time; it then runs
the command again.
just-doc book.pdf --reply 2 "it converges only for a simple root" --from Anaadds a reply to comment 2: its number (#2 in the window, [2] in the
--read output), or its id from --read --json. The number stays with the
comment, also when the document changes and the comments move. --from is the name shown on the reply. --reply can be
given several times in one command. The export writes the replies into the
note of the highlight.
just-doc book.pdf --done 2marks comment 2 as done (done in the JSON file). Its highlight fades and
it is greyed in the list. At your
next Ctrl+Enter the done comments that you have looked at leave the page
and the list, so each round starts with what is still open; nothing leaves
before that. D shows them again, and the
top of the list says how many there are. The card says whether the comment is
done. Answering a done comment opens it again, so the next
--wait prints it. --done can be combined
with --reply and given several times.
--read prints all comments with their replies, and marks each one that is
(done) or (answered).
When the file of an open document changes on disk (the markdown or HTML file was edited, the PDF was compiled again), the window loads it again by itself and stays on the page. It then looks for the text of every comment in the new version:
- Text that only moved, to another line or page, gets its highlight at the new place.
- Text that was changed is found by the text around it. What stands there
now is marked green, and the list shows both:
«teh»→ «the».--readprints the new text and the old one. The card shows the old text above the replies. - When the text around it is gone too, the comment keeps its old place and the list says "text not found". A short text, such as one word, is not looked for on other pages, because the same word stands in many places.
- A comment on a page that the new version does not have (it got shorter) goes to the end of the last page, also with "text not found".
Each comment remembers 120 letters and digits before and after its text for
this. A changed text next to another changed text is found as one piece, so
two comments can then point to the same new sentence. A rectangle or a point
(r) stays where it was drawn. The search runs in the window, so a document that changed
while it was not open is handled when it is opened next.
After a round you see the new document, but only the places you commented on.
After your first Ctrl+Enter everything that is not as it was then is marked:
changed and new text is underlined in blue, and a red line stands where text
was removed. A change has only a line and no fill, so it is not mistaken for
a comment, which is filled. m hides the marks and shows them again; M marks everything
that is not as it was at the last commit instead. The marks stay on when the
window loads a new version of the file.
A change with a wavy line was not asked for: no comment of the round is within two
lines of it. These are the ones to read first, when an assistant changed more
than you asked. A comment of the round is an open one, or one that was done
since your last Ctrl+Enter. A change near a comment belongs to it.
n and p go through the comment list as it is shown, from the selected
comment (or the first one after the cursor): the comments that the assistant
answered (or marked done) since your last Ctrl+Enter, the open ones, and
last the changes that have no comment. The comments that were done before
that are skipped, unless D shows them; changes a few lines
apart on one page are one stop, with a card that lists them. n then p
comes back to the same place; a click on a comment, in the list or on the page,
opens its card too. A card beside the page (the pages move left to make room for it; under the text when the window is too narrow) says who replied and what, with your comment above in
grey, and shows the changes that belong to it, each as a sentence with the old
words struck out in red and the new ones in green; the other changes have
cards of their own, which name your comment only when it is still open. The card says where you are ("3 of 7"); the toolbar counts what you have not looked at yet,
and what you have seen fades. Esc closes the card. On the card of a change, a comments on the change
itself: the box and the comment keep the change in view, and --wait shows
the assistant the text as it was before.
Words are compared, so a change in an equation, a figure or the layout is
easy to miss. gb covers the page at the cursor with the same page of the
old version; press gb again to flip back and see what moved.
The words of the two versions are compared in reading order, so text that
only moved to another line or page is not a change. Page numbers and running
heads are left out. Figures and the layout are not compared (use gb).
For "the last commit":
- A file that is in git (a markdown or HTML file, a PDF that is committed) is taken from the last commit.
- A PDF that is built from a source and is not in git has no version there. just-doc keeps a copy of it whenever a commit is made in its repository while the document is open, so compile the PDF before you commit. A PDF that is older than the last commit counts as that version too.
The copies are kept in the cache folder (~/.cache/just-doc).
Every Ctrl+Enter starts a round, and just-doc keeps a copy of the document
as it was then. The comment list is always in page order, top to bottom;
the mark on each row says whether it is new, answered or still open, and
the comments done before the last Ctrl+Enter are greyed. The changes that
no comment asked for come after the comments.
gh opens the history, newest round first. j / k move through the rounds,
and the selected one shows the comments and replies you handed over, the
answers that came back, and the changes in the document from that
Ctrl+Enter to the next one (for the last round, to now). A click on a
comment goes to it.
Enter shows the document in the window as it was at the end of that round,
as if it were then: the version of the next Ctrl+Enter, the changes of the
round marked, and only the comments and replies there were by then. The
toolbar turns purple and says which round it is. This view is read only;
gh and Enter on the last round go back to now. Esc closes the history.
The comments are not stored in the PDF, so other viewers do not show them.
Ctrl+S (or --export) writes book.commented.pdf: a copy of the PDF with
every highlight, strike-through, rectangle, point (a sticky note) and comment as an ordinary PDF annotation, readable in Okular,
Evince, Acrobat and others. The original PDF is never changed. The JSON file
stays the working copy; export again after adding comments.
If book.synctex.gz is next to the PDF (compile with -synctex=1), --read
adds the .tex file and line for each comment:
[1] p. 37 /path/chapters/chapter_02.tex:1228
text: the roots are found with a method that always converges
comment: too strong, say when it converges
The lookup uses the position of the comment in the PDF. After compiling again
the window moves the comments to their text in the new PDF (see "When the
document changes"), so the lines stay right as long as the document is open
in the window, or is opened once before --read.
just-doc notes.md converts the file to a PDF with pandoc
and opens that, so pandoc must be installed (with typst
or a LaTeX installation to make the PDF; typst is used when it is found). The
PDF is kept in ~/.cache/just-doc and made again when the markdown file has
changed. Comments go to notes.comments.json next to the markdown file, and
--export writes notes.commented.pdf there. Ctrl+Shift+S saves the PDF
without comments as notes.pdf next to the markdown file, replacing a
notes.pdf that is there.
A ```mermaid block is drawn as a diagram when mmdc
(mermaid-cli) is installed;
without it the block shows as code. The text in a diagram can be selected and
searched like the rest of the page.
--read adds the line in the markdown file for each comment. It finds the
line by searching for the selected text, so it also works after the file was
edited elsewhere; a text that occurs more than once gets its first line and a
note:
[1] p. 1 notes.md:3 (first of 2 places)
text: always converges
comment: too strong
After the markdown file was edited, the highlights move to their text in the new PDF (see "When the document changes").
just-doc slides.html prints the page to a PDF with the browser that shows the
window (Chromium, Brave or Chrome, run without a window) and opens that. The
rest is as for a markdown file: the PDF is kept in ~/.cache/just-doc and made
again when the HTML file has changed, Ctrl+Shift+S saves it as slides.pdf,
and --read adds the line in the HTML file for each comment. Only the text of
the page is searched, not the tags, scripts, styles or title; text that a
script writes has no line.
The page decides the paper and the page breaks with its print rules, so a slide deck needs them to get one slide per page:
@page { size: 1280px 720px; margin: 0 }
section { page-break-after: always }A reveal.js deck does this by itself: the page is
opened as slides.html?print-pdf, which is reveal's print view. Scripts run
for up to ten seconds of page time before the page is printed. Pictures and
styles are loaded as the page links them, also from the internet.
A change in a linked file (a style sheet, a picture) is not seen; save the HTML file again to make the PDF again.
just-doc page.html --live shows an HTML page as it is, with its scripts
running, as a tab of the just-doc window: a Plotly plot zooms, a three.js model
turns. The tab carries a green live mark, a green dot while another tab is
shown, and the tab bar shows also when the live page is the only tab. Its comments are kept apart from those of the
PDF of the same file (see "Comments on a live page"); without --live the
same file is printed to a PDF for commenting as before, and both can be open
at the same time.
The page is served from its own folder, so its relative links (pictures, scripts, data files) work; nothing outside that folder is served. When the HTML file changes, the page is loaded again and keeps its scroll position. A change in another file of the folder is not seen; save the HTML file again.
just-doc serves Plotly and three.js at fixed addresses, so a page that an assistant writes needs neither the internet nor copies of them:
/_lib/page.css a small style sheet: a readable text column, light
and dark, tables, and the classes card, grid, stat,
plot (480 px high), view (75 % of the window high),
controls and pair; plots and views use the full width
/_lib/plotly.min.js Plotly 4.1.2, the global Plotly; plots follow light and
dark and the width of the window by themselves
(colours in the layout and config.responsive win)
/_lib/three/three.module.js three.js r186 as an ES module
/_lib/three/addons/OrbitControls.js also GLTFLoader.js and STLLoader.js
/_lib/three/touchpad.js touchpad(controls): two-finger scroll pans, pinch
zooms, shift + scroll turns; a mouse wheel zooms
/_lib/three/fast.js mergeByMaterial(root, {keep}): a model of thousands of
meshes in a few draw calls; sharpWhenStill(renderer,
render): coarse pixels while the view moves
/_lib/three/scene.js <jd-scene>: a viewer of one or more parts (STL, STEP,
GLB) with part list, views and section plane; the
author can comment on a point of the surface
/_lib/occt/ the STEP reader (occt-import-js) that scene.js loads
by itself
The three.js add-ons import three.module.js by a relative path, so a page
needs no import map. A plot:
<!doctype html>
<meta charset="utf-8">
<title>Frequency response</title>
<link rel="stylesheet" href="/_lib/page.css">
<script src="/_lib/plotly.min.js"></script>
<h1>Frequency response</h1>
<div id="plot" class="plot"></div>
<script>
const f = Array.from({length: 500}, (_, i) => i * 0.2);
const H = f.map(x => 1 / Math.hypot(1 - (x / 40) ** 2, 0.05 * x / 40));
Plotly.newPlot('plot', [{x: f, y: H}], {xaxis: {title: {text: 'f [Hz]'}},
yaxis: {type: 'log', title: {text: '|H|'}}}, {responsive: true});
</script>and a model, in a <jd-scene> (STL, STEP or GLB files next to the page, one or
several parts):
<!doctype html>
<meta charset="utf-8">
<title>Bracket</title>
<link rel="stylesheet" href="/_lib/page.css">
<script type="module" src="/_lib/three/scene.js"></script>
<h1>Bracket</h1>
<jd-scene id="bracket">
<script type="application/json">
{"parts": [{"src": "housing.stl"},
{"src": "cover.step", "colour": "#e15759", "opacity": 0.7}],
"units": "mm"}
</script>
</jd-scene>
<p>What the view shows and what to look at.</p>The element shows a bar above the view (view buttons iso, top, front, side,
reset and fit; a section plane X, Y or Z with a slider and a flip; the size of
the shown parts) and the view, as wide as the page. The part list is a narrow
column over the left edge of the view, one line per part (checkbox, colour,
name; the opacity slider shows on the row under the mouse), groups as headers;
a hidden part has a grey name. The Parts button hides the column; in a view
narrower than 700 px it starts hidden. It follows light and dark,
navigates as touchpad() does, draws only when something changed, merges the
meshes of a part when there are many, and loads the parts in parallel; a part
that fails shows its error in its row. Give it an id. The config is read once, so
save the page to change it:
| key | meaning |
|---|---|
parts |
the parts, at least one; each has: |
src |
.stl, .step, .stp or .glb file, next to the page |
name, group |
the name in the list (default: the file name); parts with the same group are a folder |
colour, opacity |
a hex colour such as #e15759 (STEP and GLB colours are used without it), 0 to 1 |
visible |
false: not loaded until the author shows it |
split |
STEP only: one part for each solid, named from the file |
units |
"mm", shown with the size and the section |
height |
pixels; default: the class view of page.css |
up |
"z" (default) or "y"; GLB files are Y-up |
src (top level) |
a .json file with these keys instead of the script |
Write three.js yourself only for what the element cannot do: a scene that you build in code (a mesh, a field, a plot in 3D) or an animation of your own. A model that turns with the mouse, with its controls above it:
<!doctype html>
<meta charset="utf-8">
<title>Part</title>
<link rel="stylesheet" href="/_lib/page.css">
<h1>Torus knot</h1>
<div class="controls">
<label><input id="wire" type="checkbox" class="toggle"> wireframe</label>
</div>
<div id="view" class="view"></div>
<script type="module">
import * as THREE from '/_lib/three/three.module.js';
import { OrbitControls } from '/_lib/three/addons/OrbitControls.js';
import { touchpad } from '/_lib/three/touchpad.js';
const box = document.getElementById('view');
const renderer = new THREE.WebGLRenderer({antialias: true});
box.append(renderer.domElement);
const scene = new THREE.Scene(), camera = new THREE.PerspectiveCamera(45, 1, 0.1, 100);
camera.position.set(3, 2, 4);
const mesh = new THREE.Mesh(new THREE.TorusKnotGeometry(1, 0.3, 128, 16), new THREE.MeshNormalMaterial());
scene.add(mesh);
const controls = new OrbitControls(camera, renderer.domElement);
// two-finger scroll pans, pinch zooms, shift + scroll turns; a mouse wheel zooms
touchpad(controls);
// draw only when something changed: a view that stands still costs nothing
let queued = false;
const draw = () => { if (queued) return; queued = true;
requestAnimationFrame(() => { queued = false; renderer.render(scene, camera); }); };
controls.addEventListener('change', draw);
// the view follows the width of the page, which narrows while the comment panel is open
new ResizeObserver(() => {
renderer.setSize(box.clientWidth, box.clientHeight);
camera.aspect = box.clientWidth / box.clientHeight;
camera.updateProjectionMatrix();
draw();
}).observe(box);
document.getElementById('wire').onchange = e => { mesh.material.wireframe = e.target.checked; draw(); };
</script>just-doc page.html --shot page.png [--size 1500x900] saves a picture of the
page as it looks live, so an assistant can check the layout before it shows
the page. The page is served by a just-doc inside the command, so /_lib/
works, and a headless Chromium, Brave or Chrome draws it; it waits until the
page is still (plots drawn), up to eight seconds of page time, with WebGL in
software. Nothing opens in the window. Without a browser that starts, the
command ends with status 1 and "no browser to take a screenshot here; check
the layout in the HTML".
Decide the layout for each page. What matters most (a 3D model, a plot) gets
the full width: page.css gives .plot and .view the full width of the page
and keeps text in a readable column. The page narrows while the comment panel
is open; Plotly follows it by itself, a three.js view with a ResizeObserver
as in the example. The sliders, choices and switches of a plot or a view
usually go in a bar above it, <div class="controls">. Put parts side by side
only when each still has enough room: <div class="pair"> (or a .grid)
puts two side by side while each gets 560 px, otherwise one above the other.
A control needs a name only when its value should be handed over with
Ctrl+Enter. Do not enable damping in OrbitControls: the model must stop
when the user lets go. Draw only when something changed, as in the example:
call draw() after each change to the scene. Do not use setAnimationLoop for a
view that stands still: it draws 60 times a second, and a large model (a
PCB, an assembly) keeps the author's machine busy and hot. Use it only while
something moves by itself, and stop it after.
Every 3D view of a part or an assembly has a section: the author must be
able to cut it open. <jd-scene> has one. In your own three.js, add the
same: buttons off, X, Y, Z and a slider for the position, in the controls
bar above the view, with a clipping plane on the renderer:
// Section: off / X / Y / Z buttons and a position slider in the controls bar
const plane = new THREE.Plane(new THREE.Vector3(-1, 0, 0), 0);
function section(axis, at) { // axis: null (off), 'x', 'y' or 'z'; at: position in model units
renderer.clippingPlanes = axis ? [plane] : [];
if (axis) plane.set(new THREE.Vector3(...['x', 'y', 'z'].map(a => a === axis ? -1 : 0)), at);
draw();
}Your own three.js with hundreds of parts or more (CAD, KiCad) is slow, one
draw call per part (<jd-scene> merges the meshes of a part by itself). After loading it, and after measuring and finding parts by name,
merge it with mergeByMaterial (one mesh per material, the picture stays the
same; keep names the meshes you still move, pick or recolour). Draw with
sharpWhenStill: coarse pixels while the view moves, sharp when it stops.
import { mergeByMaterial, sharpWhenStill } from '/_lib/three/fast.js';
mergeByMaterial(model, { keep: m => moved.has(m) });
const draw = sharpWhenStill(renderer, () => renderer.render(scene, camera)); // use draw() as in the exampleA live page can ask questions with plain form fields; it needs no script.
Every field with a name counts: text fields, text areas, selects, radios and
checkboxes. A choice keeps its state and can be changed until Ctrl+Enter
hands all fields over, as Ctrl+Enter does in a PDF. page.css shows radios
in a <fieldset class="choice"> as pills and a checkbox with
class="toggle" as a switch:
<!doctype html>
<meta charset="utf-8">
<title>Mount</title>
<link rel="stylesheet" href="/_lib/page.css">
<h1>Which mount?</h1>
<fieldset class="choice"><legend>Variant</legend>
<label><input type="radio" name="variant" value="A"> A: four bolts</label>
<label><input type="radio" name="variant" value="B"> B: clamp</label>
<label><input type="radio" name="variant" value="C"> C: glued</label>
</fieldset>
<p><label><input type="checkbox" class="toggle" name="damping"> add rubber damping</label></p>
<p><label>Notes<br><textarea name="notes"></textarea></label></p>
<p class="muted">Press Ctrl+Enter when you are done.</p>The answers are written to page.answers.json next to the page, one round per
Ctrl+Enter, and
just-doc page.html --live --wait # opens the page if needed, waits for Ctrl+Enter, prints open comments and answers
just-doc page.html --live --read # prints all comments and the answers of the last Ctrl+Enterprint the last round after the comments (see "Comments on a live page"):
answers (round 1, 2026-11-25T10:31:07.512Z):
{"variant": "B", "damping": true, "notes": "clamp must not scratch"}
A single checkbox gives true or false, checkboxes that share a name the list of
the checked values, radios the chosen value (null: none), a select with
multiple a list. A form is not sent anywhere, and buttons count for nothing.
Without --live, --wait and --read are about the comments of the PDF of
the same file, as before. On a page of another machine the answers are kept on
that machine, where its agent runs --wait.
A live page is commented as a PDF is, and its plots and models keep working.
Select text and press a, or point at an element with the mouse (a plot, a
figure, a table) and press a. With the mouse over the model of a
<jd-scene>, a pins the comment to the point of its surface under the
mouse (see "A comment on a 3D model" below). The comments are listed in a panel at the
right of the window; the page narrows to make room and keeps its own layout.
On the page they are marked over it in the colours of the PDF viewer: selected
text is yellow (orange with a comment), an element is outlined in orange with a
dot where the mouse was, the selected comment has a red frame and the other
marks step back. A card beside the selected mark (under it when there is no
room) shows your comment, the last replies and the keys; a writes in it. The
list has the rows, the status words (new reply, answered, done ✓, not handed over, not seen yet, seen 10:31, no reply) and the folding of the
PDF viewer. A new reply stays blue until the comment is selected; a done
comment leaves the list and the page at the next Ctrl Enter.
| key (outside a text field) | action |
|---|---|
a |
comment on the selected text, or on the element under the mouse (over a 3D model: on the surface point under the mouse); on the selected comment: edit what you wrote last while the assistant has not seen it, after that reply; on the card of a change: comment on the change |
Enter / Shift Enter / Esc |
in the comment field: save / new line / cancel |
x |
mark the selected comment done; again opens it |
za / zR / zM |
open or close the row of the selected comment in the list / open all rows / close all rows |
D |
show or hide the comments that are done and filed (they left the list at a Ctrl Enter) |
C |
hide or show the marks on the page; the selected comment stays marked |
n / p |
select the next / previous comment in the list (page order) and scroll the page to it; with the changes marked, after the comments the changes that no comment is near; a click on a row or on a mark does the same |
m / M |
mark what is not as it was at the last Ctrl Enter / at the last commit; again hides the marks (see "What changed on a live page") |
gb |
show the page as it was at the last Ctrl Enter (after M: at the last commit) in place of the page, read only; gb or Esc goes back |
gh |
the history of the rounds; j / k move, Enter shows the page at the end of that round, Esc closes |
d / u |
delete the selected comment / undo the delete |
c |
hide or show the comment panel |
Esc |
unselect the comment |
Ctrl Enter |
hand the comments and the answers over to the just-doc --live --wait that waits |
q y |
stop just-doc and close its windows |
? |
show or hide the list of these keys; / filters it |
As in the PDF viewer, a bar at the bottom of the window shows the main keys; the page and the panel end above it.
Alt+Left / Alt+Right, Alt+Up / Alt+Down (the group), Alt+s (the list of groups), Ctrl+w and,
outside a text field, H / L still change or close the tab. All other keys belong to the page.
The comments are kept in page.live.comments.json next to the page, with the
fields of the PDF comments where they apply (n, text for the quote,
comment, created, replies, done, done_at, seen), and in addition:
{
"kind": "text",
"anchor": {"id": "fig-psd", "src": "plots.py:120", "path": "figcaption:nth-of-type(1)",
"selector": "body > section:nth-of-type(2) > figure:nth-of-type(1) > figcaption:nth-of-type(1)",
"tag": "figcaption", "quote": "peak at 42 Hz", "prefix": "Figure 3: ", "suffix": " is the first",
"at": null},
"detached": false
}kind is text (selected text) or element (the element under the mouse;
at is where the mouse was, as fractions of its width and height). The HTML
file is never written to: the anchor finds the place again when the page is
loaded. A comment is placed by id (the id, or the data-src, of the element
or of its nearest ancestor that has one; for text the quote is searched inside
it), then by the quote with the text before and after it, then by the CSS
selector. A comment on an element is put on the nearest element with an id
or data-src around the mouse. A comment that cannot be placed stays in the
list, marked detached, and is never dropped. So give sections, figures and
plots an id, and where it helps data-src="plots.py:120" for the code that
makes them; then a comment stays in place when the page is rewritten, and the
assistant knows where to change it.
The hand-over times (/api/rounds) are those of the Ctrl Enter presses,
kept in page.answers.json.
With the mouse over the model of a <jd-scene>, a makes a comment pinned to
the point of the surface under the mouse. The anchor is the element, as for
any element (its id), with the point added:
"anchor": {"id": "bracket", "...": "...",
"scene": {"part": "housing", "point": [12.3, 4.5, 8.0],
"normal": [0, 0, 1], "units": "mm"}}part is the name in the part list, point is in the units of the model
files and normal is the direction the surface faces. The model draws a
numbered marker at the point, in the colour of the state of the comment (as the
status word in the list); the marker is tested against the depth of the model,
so a point behind it is hidden, and it follows when the view turns. A click on
a marker selects its comment. Selecting a comment in any other way (n, p, a
click in the list) turns the view to look at the point along its normal only
when the point is off the screen, behind the model or on its far side; a point
that is seen does not move the view. After the page is loaded again the
markers are placed again from the anchors. --read and --wait print such a
comment as
[4] #bracket part: housing at (12.3, 4.5, 8) mm
surface: a point on the surface of a 3D model, normal (0, 0, 1)
comment: this edge is too sharp
m, M, gb and gh work as in the PDF viewer (see "What changed" and
"Rounds and history"), with the same marks, words and cards:
- At every
CtrlEnterjust-doc keeps a copy of the page file and the words of the page as the window showed them, in the cache folder (~/.cache/just-doc), one pair for each round. mcompares the words of the page now with those at the lastCtrlEnter;Mwith the page file of the last commit (git show HEAD:./page.html; the window loads it out of sight, next to the page, and reads its words when it has stopped changing). A new or changed text is underlined in blue, a thin red mark stands where text was removed, and a wavy line marks a change that no comment is near (within 20 words of it). The marks stay on when the page is loaded again. Without a hand-over yet, or for a page that is not in git, the window says so.- Below the comments the list has "N changes without a comment";
nandpgo through them after the comments, each with a card of its own (the old words struck out in red, the new ones in green).aon it comments on the change: the comment haschangewith the text as it was (empty: new text),textwith the new text, and for removed textkindiselement,textis empty and the comment sits on the element around the place.--live --waitand--live --readprint it as the PDF ones do: a line with the text as it was before the change, andremoved:for deleted text. gbcovers the page with the page as it was at the lastCtrlEnter(the saved copy, served from the folder of the page, so its relative files work), read only and without marks; the key bar turns purple.ghlists the rounds with what you handed over, the answers and the changes up to the nextCtrlEnter;Enteron a round shows the page at the end of it the same way.
What is compared is the text a reader sees: words in reading order, ignoring
punctuation, capital letters and layout. Changes to plots (svg), canvas, WebGL
views, pictures, form fields, styles and scripts are not detected: use gb to
look. The copies of the page keep the page file only, so an old page shows the
current version of its style sheets, scripts and data files.
--live --wait and --live --read print the comments as --wait and
--read do for a PDF, with the anchor in place of the page:
[2] #fig-psd plots.py:120
text: peak at 42 Hz
comment: is this the first mode?
selector: body > section:nth-of-type(2) > figure:nth-of-type(1) > figcaption:nth-of-type(1)
reply (assistant): yes, the first bending mode
answers (round 1, 2026-11-25T10:31:07.512Z):
{"damping": true}
With --json they print {"comments": [...], "answers": {"round", "at", "answers"} or null}. --live --reply N "text" and --live --done N answer
and close a comment; the panel shows it at once. On a page of another machine
the comments are kept on that machine, next to the page, where its agent
reads them.
Limits: a comment is on text or on a whole element, not on a point inside a plot's data (the dot shows where the mouse was, and moves with the element, not with the data); text inside a canvas or a WebGL view cannot be selected; the comment keys work once the page has finished loading.
When just-doc FILE (with or without --live) runs in a shell where
HC_TERMINAL_ID is set, as in an hc or herdr terminal pane (for example
t12), the document is noted with that terminal. Then
just-doc --hc-terminal t12shows the tab of the document that was opened or changed last from that
terminal and brings the just-doc window to the front (on Hyprland, through
hyprctl; elsewhere only the tab changes). It is meant for a key binding: when
no running just-doc has a document from that terminal, it prints a short
message to stderr, exits with status 1 and opens nothing.
The just-doc server also labels such a terminal for the hc sidebar, with the
hc command when it is on the PATH: just-doc=live while a document of the
terminal is open, just-doc=waiting while a --wait waits for one, and no
label once its last document is closed or just-doc stops with q. An update
keeps the labels. Without hc nothing happens.
To pick among all pages of a terminal, --list prints them newest first (the
time of the last open or change), one JSON object per line with id, name,
path, live, file, time (epoch seconds) and port; --doc ID shows one
of them instead of the latest, also with --hc-machine:
just-doc --hc-terminal t12 --list
just-doc --hc-terminal t12 --doc ID
just-doc --hc-terminal t12 --hc-machine work2 --list # each line has "machine"An agent on another machine (an hc machine reached over ssh) runs
just-doc page.html --live there as usual. Without a display (no
WAYLAND_DISPLAY or DISPLAY) just-doc opens no window; its server runs on
127.0.0.1 there and notes the terminal. On that machine
just-doc --hc-terminal t12 --print # {"port": 8700, "id": ..., "name": ..., "url": "/live/...", ...}prints where the terminal's latest document is (status 1: none). Here,
just-doc --hc-terminal t12 --hc-machine work2asks work2 over ssh (just-doc --hc-terminal t12 --print), forwards a local
port to the just-doc there (ssh -N -L, also through an open shared connection
of the host), and shows the document as a tab named work2: page.html. The page,
its relative files and its changes come through the forward; /_lib/ comes
from the just-doc here. The forward closes ten minutes after the tab was
closed or the window was closed, and when just-doc stops. A PDF (also one
made from markdown) of the other machine is shown in the viewer here, as a tab
named work2: deck.pdf: the PDF, its comments, the export and Ctrl+Enter go
to the just-doc there, so a just-doc deck.pdf --wait on work2 gets the
comments. For --list and --doc the just-doc there must be a version that has them. With --hc-machine "" the terminal is one of this
machine, so a key binding can always pass $HC_FOCUSED_MACHINE:
just-doc --hc-terminal "$HC_FOCUSED_TERMINAL" --hc-machine "$HC_FOCUSED_MACHINE"The machine name is taken as the ssh target, unless hc machine ls names
another target for it, or ~/.config/just-doc/config.json does:
{"machines": {"lab": {"target": "klemen@lab.example.org", "just-doc": "~/bin/just-doc"}}}just-doc there is run as PATH="$HOME/.local/bin:$PATH" just-doc unless the
config names another command; a top-level "ssh" replaces the ssh command.
ssh runs with BatchMode=yes, so the host must be reachable without typing a
password (a key in the agent).
web/pdfjs/ is a copy of PDF.js 4.10.38
(Apache License 2.0, see web/pdfjs/LICENSE).
web/_lib/three/scene.js (<jd-scene>) is derived from <canvas-scene> of
agent-canvas by Tibor Barši Palmić (MIT): the loading of STL, STEP and GLB, the
part list, the views and the section plane are his; the header of the file says
what changed. web/_lib/occt/ is occt-import-js
0.0.23 (LGPL 2.1; it contains Open CASCADE Technology, also LGPL 2.1), the
STEP reader, taken from the npm package with its licences in web/_lib/licenses/
(occt-import-js.LICENSE, occt.LICENSE). The 7.6 MB .wasm file is loaded only
when a page shows a STEP file.
web/_lib/plotly.min.js is Plotly 4.1.2 (MIT)
and web/_lib/three/ is three.js r186 (0.186.1, MIT),
taken from the npm packages; their licences are in web/_lib/licenses/. In
the three.js add-ons and utils the import from 'three' is changed to
'../three.module.js'; nothing else is changed. just-doc serves /_lib/plotly.min.js with
web/_lib/plotly-theme.js (ours) appended: it gives every plot a default
template with a transparent background and text and grid colours that suit the
page (the colours of page.css when it is linked), and draws the plots again
when the system switches between light and dark. Colours in a page's own
layout, and a template it sets, win.