Repository navigation
Fail knip on import cycles, and break the cycle between drafts.js and composing/input.js - #6907
Merged
Merged
Conversation
… composing/input.js
The knip hook printed import cycles and passed: knip 6.44.1 grades
`cycles` a warning by default, and a warning doesn't set the exit code,
so CI's pre-commit job showed `knip ... Passed` over a cycle. Now
`.config/knip.js` sets `rules: { cycles: "error" }`, so a cycle fails the
hook as the header and browser/AGENTS.md ("Runtime ownership") already
said it did.
The cycle that stood on main, since #6514 added it:
`drafts.js` imported `takesNoWords` from `composing/input.js` for Resume
writing's check that the box it reaches takes words now, while
`composing/input.js` imports `rememberWriting` from `drafts.js` to move
the writing place on a media edit. The box wiring is a view of the draft
store (drafts.js header: "each box's view of it"), so input.js depending
on drafts.js is the direction that stays. drafts.js already learns what
it knows of a box from the box's subscription, as its `resume` route
("Reveal capabilities belong to the editor's existing owner"), and
`mirrorDraft` is already handed the box's wiring. So the subscription now
also carries whether the box takes words now (`closed`, default false),
`mirrorDraft` passes the wiring's own `sync.closed`, and `resumeAt` asks
the editor it reached. drafts.js no longer imports composing/input.js.
Resume writing answers as before: every box whose wiring supplies
`closed` (the floating panel's page field and its thread replies)
registers through `mirrorDraft`, so the subscription's `closed` is the
same function `takesNoWords` read through the box; every other editor
answered false and still does. `takesNoWords` stays for its caller in
`composing/surface.js`.
Checks: knip exits 0 with no cycles, and exits 1 with the import put
back; dependency-cruiser, `pnpm run check:browser` and the runtime tests
for drafts, composing-input, message-edit, words-watch and
annotation-inventory pass. A `leaf-dev probe` journey on incident-report
resumes both a page draft and a closed thread's reply through `g i`
with the words in the field and no "That writing place is unavailable".
leaf-agent
approved these changes
Nov 23, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
#6860, still open, extends the import this PR removes (import { boxOf, takesNoWords } from "./composing/input.js" in drafts.js). Whichever lands second will conflict there, and with cycles: "error" it will fail knip until it routes boxOf the way this PR routes closed.
max-sixty
added a commit
that referenced
this pull request
Nov 24, 2026
Main carries #6799 (thread-link-back) as the squash ba22bcc. This branch already held #6799 up to d940bb9, so the merge is taken against that commit rather than the older main the two histories share: each side contributes only what it changed since #6799's d940, which leaves #6799's later commits (df8a9c7, a step commits once) and main's newer work to main's side. Six files conflicted on that base: - drafts.js: main (#6907) dropped drafts.js's import of composing/input.js to break their cycle, and has a draft subscription carry what Resume writing asked the wiring (`closed`). The draft focus history keeps asks which box an editor's words are written in the same way: the subscription carries `box`, which mirrorDraft, the page's composer and the options addition supply, and composing/input.js no longer exports `boxOf`. - floating-panel.js: main's Show on page button (it moves the thread, with its preview), with this branch's `data-lf-carry` key on it. - thread/selectors.js: both `move` (main) and `controls` (this branch) parts. - thread/address.js: the header keeps both the record's list return and main's account of the threads-in-panel choice. - thread-preview.js: both the card's carry key and main's preview. - test_navigation.py: Back to Show on page returns to the control, landing where main's Show on page now lands, on the card's thread. It also drops two references the earlier merge left to code neither side keeps: leaf.js's `threadReader` and floating-panel.js's `afterSettling`. > _This was written by Claude Code on behalf of max-sixty_
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.
The knip pre-commit hook printed import cycles and still passed, because knip grades
cyclesa warning by default and a warning doesn't set the exit code. So the cyclebrowser/runtime/drafts.js↔browser/runtime/composing/input.js, added in #6514, has stood on main with CI green..config/knip.jsnow setsrules: { cycles: "error" }, which makes the hook do what its header andbrowser/AGENTS.md("Runtime ownership") already said it did.The fix keeps
input.js→drafts.js(the box wiring is a view of the draft store) and dropsdrafts.js→input.js. Resume writing neededtakesNoWordsto ask whether the box it reaches takes words now. Instead, a draft subscription now carries that answer (closed, default false),mirrorDraftpasses the wiring's ownsync.closed, andresumeAtasks the editor it found. The only boxes that supplyclosed, the floating panel's field and its thread replies, both register throughmirrorDraft, so Resume writing answers as before.To weigh:
watchDraftis in the public widget API, so it gains an undocumentedclosedoption, like its existingresumeandmirrored.Checks: knip exits 0 on this branch and 1 with the import restored; dependency-cruiser,
pnpm run check:browser, and the runtime tests for drafts, composing-input, message-edit, words-watch and annotation-inventory pass; aleaf-dev probejourney resumes a page draft and a closed thread's reply throughg i.Found while porting deslop-please's lints to Leaf.