Page properties: builders, commands and predict
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Read issue #84’s Events and Commands and IPC sections, then use the existing addBlock path as the entry point across @pbnotes/pages, pages-session.ts, pages-ipc.ts, src/shared/pages.ts, and src/preload/index.ts. Check the existing block builder, command and tests, plus pagesFold and list(page) for the expected property data. Done means the four property operations follow those patterns, preserve write order, expose properties in PagesState.showing, and pass the listed builder, command, session and store cases.
Written by the indexing model from the issue text.
Description
Part of #84. This is the write side of the page properties domain model, all in @pbnotes/pages: the builders that make each event, the commands that check against the fold and write, and predict for writes not yet recorded. It sits on #132 (events, projection and reads). Nothing here touches the app: connecting the app to it is #142.
The design is #84's description. This ticket doesn't restate it; where they differ, #84 wins.
What already exists
- After #132: the
page.property.*events with theirHANDLESentries, thePropertiesprojection, the gate, and the reads (get,getValue,getItems,list,children). - The block side has the same three parts: pure builders (
blockCreatedand the rest), commands that check against the fold and write throughPagesView.dispatch(addBlockand the rest), andpredict.
What it takes
- Builders, one per event, beside
blockCreated, each returning{ v, type, payload }withvfromHANDLES. Pure, like the block builders: they read no clock and check nothing against a page. They are the only place a property payload is built, so a writer and a prediction always build the same bytes. - Commands:
setProperty(view, page, path, value),unsetProperty(view, page, path),addPropertyItem(view, page, path, item)removePropertyItem(view, page, path, item), and:removeProperty(view, page, path): oneremovedlisting whatview.stateholds atpathand under it. Nothing there appends nothing.renameProperty(view, page, from, to): the writes that copy whatview.stateholds at and underfromtoto, then oneremovedoffrom, additions first. Refuses atothat already holds something, rather than merging into it.- They refuse what the gate would skip: a path that isn't a non-empty array of strings, a segment that is empty once trimmed, a value or item that isn't a scalar. A non-finite number matters most:
JSON.stringifywould write it asnull, a real value. So nothing is written that folds to nothing. - They don't trim or normalize anything themselves; the fold does. Their checks compare the way the fold does: segments trimmed, strings in NFC.
- A write that changes nothing appends nothing and resolves, like
indentBlockwith nothing above: setting the value a path already has, unsetting a path with no value, adding an item already there, removing one that isn't.
- Prediction:
predictfolds property events too, so a caller can draw a write before it is recorded. Its inputs and result carry a page's properties beside its blocks. Noatis needed: the projection keeps none (#84). Folding a property event twice leaves the same value and the same items, but a seconditem.addedmoves that item to the end ofitems, which is what "the latest item" reads. Eitherlandedgets a case for it, or that reordering is shown to be harmless. - Exports and docs: the builders and commands exported from the package, and listed in
packages/pages/README.mdbeside the block ones.
Test
All under node --test in packages/pages, with a PagesView whose dispatch folds into a held state; no app, no ledger.
- Each builder writes
vfromHANDLESand the payload the schema gives, and folds throughpagesFoldto what the command meant. - Each command refuses a malformed path, value or item and appends nothing,
NaN,Infinityand a" "segment among them;nulland""as a value are written. - Each no-op case above appends nothing, including one that differs only by trimming or NFC.
removePropertylists exactly what the state holds at and under the path; folded, it leaves nothing there.renamePropertywrites its additions before its removal, and a crash after the additions (only some events dispatched) leaves both keys.predictover each property event, alone and mixed with block events, gives the state the fold gives; folding one that has already landed changes nothing.
Out of scope
- The app: session, IPC, preload and
PagesState(#142). - The table, and keeping in-flight writes for
predict(#137). - Any meaning for an
["app", ...]key: aliases (#85), the cover (#107).
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 1
- Avg merge
- 29m
- Merged PRs (30d)
- 27
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from shovon/pbnotes
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Website for Pb NotesOpenenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 1-2 days Newbie friendliness 58/100
Maintainers usually reply within 1 day
Similar issues
-
b:minor bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
software-mansion/argent#1698 ·
Maintainers usually reply within 1 day
-
e2e-failure ready-to-code
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
redhat-developer/rhdh-plugin-export-overlays#4624 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
better-auth/better-auth#12132 · 1 reaction ·
Maintainers usually reply within 1 day
-
automation missing-model model-sync provider:tinfoil
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
anomalyco/models.dev#12053 ·
Maintainers usually reply within 1 day
-
o8 next debug build aborts on Glass to Dark appearance switch (nil identifier messaged before check)Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
hurttlocker/o8#5112 ·