Skip to content

/untangle in every product, its port orders kept with the layout where the source takes none - #237

Merged
endrix merged 3 commits into
mainfrom
feat/untangle-every-product
Nov 24, 2026
Merged

endrix merged 3 commits into
mainfrom
feat/untangle-every-product

Conversation

@endrix

@endrix endrix commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

What changes

/untangle no longer needs a producer that can write a port order. Wherever a product's diagram tools are on and Dialogram's own diagram module serves the diagram, the agent untangles and the person applies or discards the result. Before this PR, every product but wfpy refused with "This diagram's source cannot be given a port order, so it cannot be untangled here." That includes picorv32 in streamblocks-ide.

When a try is applied, each definition's port order goes to one of two places:

The card says which. It lists the orders kept with the layout by definition, then the files written, each with its definitions. Its button reads Apply when no file changes, and Apply to N files otherwise. Undo puts the layout back, and the files too when some were written.

How

  • diagram-server (src/untangle/): the four tools, the session and the Apply handler move here from sidecar-toolkit.
    • The Apply handler is registered above the read-only cut. An untangle applied only saves a layout unless a writer is bound.
    • The tools are bound in read-only and editable sessions alike.
    • SourcePortOrderWriter (SOURCE_PORT_ORDER_WRITER, optional) is the neutral hook: canWrite, fileOf, write and usedElsewhere.
  • sidecar-toolkit: SidecarPortOrderWriter holds what the tools used to do with the sidecar: supportsOp(reorderEntityPorts), entityFileOf, the op itself, and usesAcrossProject for "Also drawn in the new order". It is bound in createSidecarServerModule, but not for a readOnly profile, which has no sidecar to ask.
  • extension-core:
    • /untangle moves from the edit capability to untangle-command.ts. profile-runtime adds it for every chat profile with mcp.enabled and a server URL, through the new platformCommands argument of assembleChatRuntimeConfig (after the capability's commands, before the profile's).
    • The reorderEntityPorts gate is gone; only "the diagram's tools are turned off" still refuses.
    • The session lookup is shared (diagram-tool-session.ts).

Products with a diagram module of their own

mlir-viewer serves its diagrams with its own GLSP DiagramModule. That module registers no untangle Apply, always lays out with FIXED_SIDE (ELK already orders the ports within a side), and keeps no layout file, so a try has nowhere to be kept. Such a product gets neither the tools nor the command:

  • DiagramMcpModuleOptions.untangle is false when diagramModuleFactory is set;
  • platformChatCommands leaves /untangle out for a profile with serverDiagramModule.

Before this, the live check on mlir-viewer ran the tries and then failed on Apply with "No handler registered for action kind: dialogram.applyPortOrders".

yliko leaves the diagram MCP server off, so it had no /untangle before either.

Tests

  • diagram-server mcp-diagram-module.test.ts: the untangle tools in a read-only session as in an editable one; mcp-di.test.ts counts them.
  • diagram-server untangle-kept-in-layout.test.ts:
    • a card with no writer, and a card whose writer says no: orders kept, Apply, writes: [];
    • Apply with no writer saves portOrders and writes nothing, even when sent writes; undo puts the layout back.
  • sidecar-toolkit:
    • the untangle tests now run through SidecarPortOrderWriter;
    • a new card test writes one definition and keeps a split one;
    • operation-modules.test.ts: the Apply handler is in core, the read-only set includes it, the toolkit's MCP tools are its own two, and the writer is bound only with a sidecar.
  • diagram-server custom-diagram-module.test.ts: the MCP module beside a custom diagram module binds no untangle tools.
  • extension-core:
    • untangle-command.test.ts: no capability gate, untangle-end after the turn, refused with the tools off, not offered to a profile with its own diagram module;
    • an assembly test for the order, including a profile with no edit backend.

Live checks

  • streamblocks-ide, picorv32 Core: /untangle from 12 crossings to 1. The card kept the orders of Cpu and MemIf with the layout, with no file changes. Apply changed only .layout/picorv32.py.layout.json; Undo restored it byte for byte; a reopen drew the same rows.
  • wfpy, untangle_demo.py: 25 crossings to 21. Apply wrote the Stage and Merge orders into untangle_parts.py, comments kept, and drew image in the declared order again. Undo put the file back exactly.
  • mlir-viewer: after the fix, no /untangle in its chat and no untangle tools on its MCP server.

https://claude.ai/code/session_011UYzzUKxNqKPdmLsRmJ6Xu

…t where the source takes none

The untangle tools, session and Apply move from sidecar-toolkit into
diagram-server (src/untangle), bound in read-only and editable sessions
alike. Apply saves the try's layout with the port orders it draws; a
product writes an order into its source by binding a SourcePortOrderWriter,
which the sidecar toolkit does where its profile has a sidecar
(reorderEntityPorts, wfpy). The card lists the orders kept with the layout,
then the files written; its button reads Apply when no file changes.

/untangle becomes the platform's chat command, offered to every chat
profile whose diagram tools are on, edit backend or not; the
reorderEntityPorts gate is gone.

Claude-Session: https://claude.ai/code/session_011UYzzUKxNqKPdmLsRmJ6Xu
… is bound

From the review of #237:
- The orders the card says the layout keeps are those Apply saves (the
  try's, less those written), and a definition the layout kept that the try
  draws as declared again is said to be let go, in the card and the message.
- Two kept definitions of one name are told apart by their instances.
- A read-only diagram's host binds no undo key: its card promises none.
- The edit capability and /untangle share one client of the diagram's tools.

Claude-Session: https://claude.ai/code/session_011UYzzUKxNqKPdmLsRmJ6Xu
…he diagram

mlir-viewer serves its diagrams with a diagram module of its own, which
registers no untangle Apply: its /untangle ran the tries and then failed
on Apply ("No handler registered for action kind:
dialogram.applyPortOrders"). Its module also lays out without Free Ports
and keeps no layout file, so a try has nowhere to be kept.

The server binds the untangle tools only beside the stock diagram module
(DiagramMcpModuleOptions.untangle), and the chat offers /untangle only to
a profile without serverDiagramModule (platformChatCommands).

Claude-Session: https://claude.ai/code/session_011UYzzUKxNqKPdmLsRmJ6Xu
@endrix
endrix merged commit 1247e4b into main Nov 24, 2026
1 check passed
@endrix
endrix deleted the feat/untangle-every-product branch November 24, 2026 15:14
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.

1 participant