Skip to content

Fail knip on import cycles, and break the cycle between drafts.js and composing/input.js - #6907

Merged
max-sixty merged 2 commits into
mainfrom
agent-ac41797cb4913a3e4
Nov 23, 2026
Merged

max-sixty merged 2 commits into
mainfrom
agent-ac41797cb4913a3e4

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The knip pre-commit hook printed import cycles and still passed, because knip grades cycles a warning by default and a warning doesn't set the exit code. So the cycle browser/runtime/drafts.js ↔ browser/runtime/composing/input.js, added in #6514, has stood on main with CI green. .config/knip.js now sets rules: { cycles: "error" }, which makes the hook do what its header and browser/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 drops drafts.js → input.js. Resume writing needed takesNoWords to ask whether the box it reaches takes words now. Instead, a draft subscription now carries that answer (closed, default false), mirrorDraft passes the wiring's own sync.closed, and resumeAt asks the editor it found. The only boxes that supply closed, the floating panel's field and its thread replies, both register through mirrorDraft, so Resume writing answers as before.

To weigh: watchDraft is in the public widget API, so it gains an undocumented closed option, like its existing resume and mirrored.

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; a leaf-dev probe journey resumes a page draft and a closed thread's reply through g i.

Found while porting deslop-please's lints to Leaf.

This was written by Claude Code on behalf of max-sixty

… 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 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.

#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
max-sixty merged commit 782d5cf into main Nov 23, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-ac41797cb4913a3e4 branch November 23, 2026 22:45
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_
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