Skip to content

Let agent replies reattach threads - #317

Merged
max-sixty merged 3 commits into
mainfrom
codex/thread-reattachment
Sep 5, 2026
Merged

max-sixty merged 3 commits into
mainfrom
codex/thread-reattachment

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • let an agent reply atomically replace a thread's current anchor with a passage, element, or declared visual part from the active revision
  • preserve the opening comment's anchor as immutable history while every current-state projection follows the replacement
  • reject moves for held command-goal and version-response threads, and document the authoring workflow

Verification

  • uv run pre-commit run --all-files
  • uv run pytest tests (888 passed)
  • browser sweep across detached and reattached diagram states at 1200px, 1440px dark, and 390px dark
  • context-blind usability pass using only the shipped guidance and CLI help

This was written by Codex on behalf of max-sixty

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

One correctness finding, reproduced locally: leaf reply validates --markup against the revision that was active before the anchor capture activates the agent's edited index.html, so a reply that both moves the thread and carries a widget is checked against a stale page. leaf comment has the opposite order and gets it right. Reproduction and consequence are below; the two inline suggestions are one fix and need applying together.

Reproduction

Publish v1, open a thread, then write a revised index.html that adds <p id="moved-note">The retry lives here.</p> without stamping it — the exact shape the new conversation-threads.md workflow describes. Then:

leaf reply <page> --to <root> --quote "The retry lives here." \
  --markup '<lf-ask id="moved-note">…</lf-ask>' --text "moved it"

Observed: exit 0, and the accepted event carries "revision": 2 alongside markup whose id is moved-note — an id revision 2, activated by this very command, already holds. leaf version check then refuses the page for good with ids already taken by widget markup in a reply: ['moved-note'], against an append-only log. leaf comment given the same input refuses up front with comment widget ids already taken by the page or an earlier message.

check_markup reads version_ids(page_dir) and list_revisions(page_dir)[-1], so every id, fragment-reference, and data-binding check it runs sees the pre-activation page; _current_anchor calls activate_source, which writes the new revision. Hoisting the capture above check_markup restores the cmd_comment order and closes it — with the hoist applied, the reply is refused and version check stays green. tests/test_interact_anchors.py and tests/test_interact_contract.py (305 tests) pass with the change.

Comment thread skills/leaf/scripts/leaf/events.py Resolved
@max-sixty
max-sixty merged commit 5100d89 into main Sep 5, 2026
7 checks passed
@max-sixty
max-sixty deleted the codex/thread-reattachment branch September 5, 2026 23:35
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