Skip to content

Unify Questions and their typed answers - #2240

Merged
max-sixty merged 9 commits into
mainfrom
codex/questions-api
Oct 10, 2026
Merged

max-sixty merged 9 commits into
mainfrom
codex/questions-api

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Questions now expose one immutable record containing the prompt, typed answer, lifecycle, and next actor. Standalone decision widgets register automatically; lf-ask supplies optional presentation context. Answers remain derived from their existing widget state, while prose replies and required version approval join the same Question inventory.

The server owns the admitted inventory and the application publisher combines it with immediate local input. Questions feed queues, navigation, markers, and package consumers directly; explicit Tasks represent committed work. The cutover removes the old Asks and display-answer APIs and updates registry declarations, bundled consumers, authoring references, examples, and checks together.

For review, questions.py owns the server reading, build/browser/application.ts owns publication, and runtime/questions/ owns selection and placement. references/module-authoring.md describes readQuestions, watchQuestions, and questionActions.open. Each frozen Question retains its exact owning message. Thread opening separates the addressed part from taking focus, so native controls can materialize while editing continues; compact reply controls use that same destination owner. Browser Back restores the departure’s viewport, focus, and selection even during a smooth arrival. Lifecycle coverage includes revisions, withdrawn requests, partial and empty answers, undo/refusal, discussion holds, frozen threads, and exact-version approval.

Local validation: Claude reviewed the API and implementation; focused Python model/projection and rendered interaction checks pass, along with 306 runtime tests, 90 browser-framework tests, browser typechecking and reproducible bundles. Fresh browser reviews cover desktop and touch navigation, answer/undo, native replies, and draft preservation. The pull request runs the complete landing and website delivery gates.

Served startup comparison against the integrated base adds one request and less than 10 KB, with no console errors or layout shifts. The shared placement module runs before presentation so rings, markers, and work order agree on each Question’s source and context from the first paint.

This was written by Codex on behalf of max-sixty

Register widget and prose questions independently of lf-ask, derive typed answers from their existing owners, and select questions directly in queues and navigation. Keep explicit Tasks separate, preserve question lifecycle and answer provenance across revisions, and cut over registry declarations, package consumers, references, examples, and checks.
Preserve the newer conversation, admitted-sequence, registry-domain, and documentation contracts. Represent required exact-version approval in the same Question inventory with its typed answer rather than a synthesized Task, retaining immediate approval/undo/refusal and banner navigation. Generate shared typed-answer fixtures on demand alongside the existing served records.
Render pending approval undo and refusal consistently from the canonical Question record, preserve independent approval timeline history, and expose the real approval-control target. Retire the completed design note now that its contract lives in owning modules and authoring references; the live review page remains available.
Show the approval timeline row in the same turn as its Question and banner result. Use the unresolved ledger identity and queued timestamp, and restore all three together on definitive refusal. Hold the browser POST to verify first approval, refusal, undo and reapproval.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undoing an empty completed Question still publishes an answer during the pending gesture. The inline change lets the Question reflect the widget’s immediate Undo result.

Comment thread build/browser/application.ts Resolved
Undo completed empty answers immediately while preserving admitted lifecycle and restoring refused reversals. Use the canonical Question formatter and completion rule across package consumers.

Separate addressed thread parts from focus, retain exact owning-message provenance, and route native reader arrivals through shared clearance and Back history. Exercise narrow panels, frozen later replies, cancellation, drafts, geometry and empty answers.

Refresh reviewed macOS inline-thread snapshots to the appearance already present on the integrated base.
Keep the reviewed Question and native-reader contracts while integrating main. Store viewport position with focus and selection in the existing history checkpoint, cancel outgoing smooth motion before traversal restoration, and cover immediate Back from primary and sibling readers.
leaf-agent
leaf-agent previously approved these changes Oct 10, 2026

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test job is red on this head (run). Two failures remain after the Questions cutover:

  • test_the_shipped_long_thread_keeps_the_margin_and_its_height looks for “Page actions for task · iOS reconnect stall,” but the rendered group is “Page actions for section · iOS reconnect stall.” With that selector corrected locally, the test reaches a second failure: after resizing to 480px tall, the open margin preview ends at 555.7px, beyond the 472.5px viewport bound. The preview placement needs to keep its reply controls in view at that height.
  • test_ask_repaints_keep_the_queues_reading_until_an_explicit_arrival still selects data-lf-at="ask-0" and ask-1. The new Question IDs are widget:options-0 and widget:options-1; queue-panel.js writes those IDs to data-lf-at. The test passes locally after updating both selectors, and then exercises the intended reading-continuity behavior.

@leaf-agent
leaf-agent dismissed their stale review October 10, 2026 09:23

CI failed on the reviewed head: stale Question selectors and a margin preview overflow after resize.

Queue rows use Question IDs and answered records remain in Done when a thread is hidden. Keep the long-thread attachment visible with ordinary scrolling when testing compact-height bounds; offscreen attachments correctly carry their cards out of view.
Preserve canonical Question identities and native reader return checkpoints while integrating current delivery, editor reflow, and preview ownership changes. Reconcile the shared visible-passage containment test and accept the reviewed merged thread appearance.
@max-sixty
max-sixty merged commit 79551e8 into main Oct 10, 2026
6 checks passed
@max-sixty
max-sixty deleted the codex/questions-api branch October 10, 2026 10:25
max-sixty added a commit that referenced this pull request Oct 10, 2026
"How it works" becomes the place that explains Leaf's high-level design:
how the harness, the `leaf` CLI and page server, the page directory and
the browser runtime fit together, and how a move travels between them.

## How it works (`docs/how-it-works.html`)

- **Loop** opens with an Architecture section: one diagram of harness,
Leaf and browser, then short entries for the one validated path into the
event log, the one server reading of the page, the browser runtime,
delivery to the agent, registry declarations and the state home. Pi
joins the harness rows, marked experimental. What the agent reads is
folded into the typical flows; the transport detail and channel table
move out. The Stop hook's checks sit in a disclosure under page ending.
- **Updates** now holds Stages of a move, so it no longer overlaps Loop.
- **Runtime** (formerly Serving) keeps the server sections and adds the
browser runtime: its three inputs (authored document, server reading,
moves awaiting an answer), freshness checks and state reads, drawing and
presentation proof, live revisions, and startup phases. It uses the
Questions vocabulary from #2240.
- **Phone** is a new tab: Leaf stays desktop-first, and the tab says
what touch reaches today and what it lacks.
- Headings name topics rather than slogans throughout.

## Other pages

- `docs/threads.html` gains anchoring, revisions, drawings, widgets in
messages, titles, summaries and resolving.
- `docs/website.html` is a new short page at `/website/` on how
leaf.page serves Leaf; `dev/leaf_dev/site.py` routes it and
`tests/test_product_page.py` lists it.
- `worker/README.md` points at `max_instances` instead of a hardcoded
container count; `TODO.md` drops a stale clause asking for visible
passage threads on touch.

`how-it-works`, `threads` and `event-log` carry a TODO comment for a
third-person pass, which follows in the next change.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 12, 2026
`leaf page check` now refuses an `lf-ask` that registers no Question. A
page went out with four Asks whose `lf-options` lacked `choose`: each
read as a question, but the banner counted none of them and the user
could answer none. The check passed because #2240 dropped the old
exactly-one-source rule so an Ask could frame several Questions, and
nothing kept its lower bound.

The rule lives in `question_context_errors`
(`skills/leaf/scripts/leaf/validation/instances.py`), so it covers page
source and thread message markup alike, and it reads declarations only:
an `x-question-context` region needs at least one `x-awaits` widget,
outside an `x-exhibit`, whose nearest context is that region and which
asks or was retired. The error names what each framed widget lacks, for
example `<lf-options id="pick"> (line 12) asks only where choose is
present`.

A retired Question keeps its context. `x-awaits` gains `retired`, naming
the flag an author sets to end a Question already asked; `lf-options`
declares `"retired": "settled"`, and registry validation requires `when`
to read that flag's presence as not asking, so retirement and
registration agree. The review-queue and comparison fixtures and the
corpus keep settled decisions inside their Asks. A `when` condition a
recorded value writes counts too, since a gesture can still meet it, and
an Ask quoted inside an exhibit is exempt. `references/packages.md`
documents `retired` and the rule.

Behavior changes in tests: an empty `lf-ask` was asserted valid and is
now refused. The shared `PAGE` fixture framed a choose-less `lf-options`
in an `lf-ask`, the incident's shape; it is now a `div` with the same
id. Two server tests' added Asks gain `choose`, and one render case
drops a nested Ask around a draft without `needed`.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 12, 2026
…-card sample, and bring the What-needs-you note up to date (#2619)

Three small changes from the code-quality survey.

**Catalog previews wait the way every other browser command does.**
`leaf-dev refresh-previews` keeps launching the locked headless shell
the browser suite uses, so published preview pixels do not follow each
host's Chrome (#342). It now opens its tab with `leaf_dev.browser.tab()`
and waits with `load()`, which runs `settle()`: ready, fonts loaded, and
the runtime's `pageSettled`. Its own `wait_until_ready` call is gone.
Captures also take reduced motion, as other stills do. A one-example
capture through the real command (publishing stubbed out) produced the
expected still.

**The feature gallery's "Move a card" live sample is cut.** It repeated
the drag the delivery board on the Data & work tab already offers. The
Interactions guide now links to that board (`#bg-delivery`, which opens
its tab), the eyebrow drops the board elements, the site test expects
three interaction samples, and the corpus is regenerated.

**`notes/what-needs-you/page.html` matches the current model.** It said
an Ask is a task on you and that a record says how it `ends`. Since
#2240, #2451 and #2506, an ask is its own record the lists select
directly, the shared work record is a to-do with no `ends` field, the
lists are `queues.questions` and `queues.tasks`, and replies ask with
`--ask`. The lede, plan, naming sections, "How it works" (with a fresh
`page state` reading) and open questions now say so. The step-5 tab
keeps its decision record in the past tense and notes what holds now.
The `#task-hierarchy` and `#task-done` anchors cited by TODO.md are
unchanged.

No user-visible Leaf behaviour changes beyond the gallery losing one
sample.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants