Repository navigation
Expose shared Thread readings to package widgets - #1257
Merged
Merged
Conversation
leaf-agent
previously approved these changes
Sep 27, 2026
# Conflicts: # skills/leaf/references/packages.md
leaf-agent
approved these changes
Sep 27, 2026
max-sixty
added a commit
that referenced
this pull request
Sep 27, 2026
…ning message takes replies (#1260) A thread's `id` is now its one identity in the runtime, and its `root` is a real message. Before this, the user could not reply to or resolve a thread whose opening log line was torn: the append door refused both with `unknown parent`. **The bug.** When a torn line loses a thread's opening comment, `build_threads` keeps the thread under the lost id. #1237 made the thread read correctly by giving the surviving reply a copy of the lost id as its root (`{**reply, "id": parent}` in `events.py`, and the same fallback in `thread/model.js`). The runtime keyed threads on `root.id`, so that made attention and the card id line up. But the root is also what a reply or resolve addresses as its `parent`, and the lost id names no message. So the panel drew the thread, and then the append door answered 400 to every reply and resolve in it. `test_a_panel_reads_a_log_that_lost_the_message_a_reply_answers` now replies and resolves in such a thread and checks that both land with `parent: "tv-kept"`. On main the reply is refused. **One identity.** - `build_threads` gives each thread an `id` field. For a torn thread, `root` is the surviving reply under its own id, the same record as `msgs[0]`. The served state now carries `id` from the fold instead of adding it separately, and `thread_digest` reads it. - The runtime keys every thread on `thread.id`: placement and marks (`anchor-paint`, `drawing-paint`, `placement`, `surfaces`, `thread-list`), travel and reveal (`anchor-travel`, `narrowing`, `margin-projection`), attention and workflows (`application.ts`, `thread/model.js`), news (`semantic-news`), frozen message documents (`state-application`), holds (`presentation`, `heldBy`), and card ids. `root.id` is read only where a message is meant: the `parent` of a reply or settlement, and a thread's turns. - `threadNames` in `thread/model.js` maps every name that reaches a thread to it: its id, each message's id, and each pending id this tab sent. `foldThreads` uses it to attach pending replies and settlements. The publisher uses it to find which thread a local or refused reply belongs to. That replaces `message.parent` used as a thread id, and the separate `PENDING + root.attempt` lookup for recovery. - The thread card's model carries `root` (the message that replies and settlements address) beside `id`. `wireReply` takes the draft key and a `parent` reader instead of a stand-in thread object, and `settleThread` takes `parent`. **Selectors.** `thread/selectors.js` now exports `THREAD` (`.lf-thread, .lf-page-thread`), and `SAYS_IN` is built from it. `thread/replies.js`, `thread/landing.js` and `thread/focus.js` spelled those selectors out; they now import them. **Contract.** `references/packages.md` now says `openThread` takes the Thread's `id`, that `heldBy` is a Thread id, and that `root` can differ from `id`. The Thread-filter widget test from #1257 opens threads by `thread.id`. **Tests.** Thread fixtures in `application.test.mjs` and `tests/runtime/` now carry the served `id`. A new publisher test covers a torn thread: its Ask attention, the subject of a pending reply's workflow, and recovery after a refused reply, all under the lost id. With `threadOf` reverted to `message.parent`, that test fails. The Python torn-thread test checks that `id` is the lost id and `root` is `msgs[0]`. Helpers that looked up served threads by `root.id` (`model_folds.threads`, `test_read_state`, `test_interact_session`, `test_render_pages`) now use `id`. For every thread whose opening message survives, `id == root.id`, so nothing moves outside the torn case. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Package widgets can read Leaf's immutable Thread collection, but had no read-only subscription to it. This adds
watchThreads(owner, callback)on the existing projection watcher, keeping per-widget display state outside the shared Thread authority. Widgets can use the existingopenThreadroute to navigate to the canonical conversation.The browser test mounts two instances with independent filters, checks that both receive new Threads, removes one and verifies its subscription stops, and opens a Thread from the remaining widget. The package guide documents the read and navigation boundary.
On the same served triage page, the new synchronous API adds one JavaScript request (543 bytes for the watcher module) before presentation: 179 to 180 JavaScript requests and about 2.745 MB in either version. Synchronous registration lets widgets subscribe in
connectedCallbackwithout an async loading race.Local checks: before integrating main, 1,433 Python tests passed (1 expected failure). On the current head, 18 affected browser tests and 127 runtime tests passed, and pre-commit passed on the changed files. CI passed on the current head.