Skip to content

fix(chat): /untangle in a view navigated into another file's workflow - #238

Merged
endrix merged 2 commits into
mainfrom
fix/untangle-nested-view
Nov 24, 2026
Merged

endrix merged 2 commits into
mainfrom
fix/untangle-nested-view

Conversation

@endrix

@endrix endrix commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

What was wrong

/untangle failed in a view navigated in place into another file's workflow. A live run on jpeg_flow.py › flow › placed (place) showed two faults:

  1. untangle-propose failed: "No chat panel is open on this diagram to put the try to the person."
    • Navigated in place, the editor of jpeg_flow.py draws place.py's workflow, and its GLSP session's sourceUri is place.py.
    • The untangle tools asked the chat host for a panel open on place.py. The chat panel is the editor's, and it speaks for jpeg_flow.py.
    • So the try was never put to the person, and after the turn untangle-end found no session of the chat's file.
  2. The first untangle-start failed with no sessionId. Claude over ACP loads a tool's schema on first use, so the first call had no sessionId. It then asked session-info and called again.

What changes

  • diagram-server: a session names itself to the chat host by its GLSP client id, beside the file it draws (DiagramChatTarget). The untangle tools pass the base handler's clientId.
  • extension-core:
    • routeDiagramChat (diagram-chat-routing.ts) maps the client to its editor's document, spelled as VS Code spells it, which is the webview's workflowUri (getChatUriForClientId). The drawn file is tried after it.
    • diagramToolSession takes the session the editor shows first, whatever file its view draws.
    • /untangle looks the session up before the turn and names it in the prompt ("This diagram's session is "…": pass it as sessionId to every untangle tool."). afterTurn ends that same session.

Tests

  • diagram-chat-routing.test.ts:
    • a nested view's card goes to the editor's panel;
    • with no editor known, it goes to the drawn file;
    • with no panel open, or no chat running, nothing is sent.
  • untangle-command.test.ts:
    • the prompt names the session;
    • a nested view's session is the one untangled and ended;
    • the command is refused with no open diagram, or when the tools don't answer.
  • untangle-kept-in-layout.test.ts: the tools ask the chat with {clientId, sourceUri}.

Review (/code-review medium), fixed in 44ffe9b

  1. (important) Preferring the shown session whatever file it draws changed every chat command: /agent or a rename in a nested view would write into the nested file while its auto-layout went to the chat's file. That rule is now diagramToolSession's anyView option, and only /untangle passes it.
  2. (important) With two editors on one file, the session came from the file's last-used editor, not from the panel the command was typed in. Each chat message now carries its diagram's client id (ChatCommandContext.diagramClientId), and /untangle uses it.
  3. (nit) If the editor closed while the card waited, a follow-up could fall back to another editor's chat on the nested file. Follow-ups now go to the chat the card went to, or nowhere.
  4. (pre-existing) The transport routes by file, to that file's panel that spoke last. The docs now say that; routing to a single panel is left as it was.
  5. (nit) afterTurn looks the session up again when ending the captured one fails, for example when the editor was reopened during the turn.

Live check (wfpy harness)

nested_untangle.py's workflow instantiates tangled from untangle_demo.py. Navigated in place (crumbs outer / inner), the session draws untangle_demo.py while the chat is nested_untangle.py's.

  • untangle-start succeeded on its first call.
  • The card came up in this editor's chat (25 → 23 crossings).
  • Apply wrote untangle_parts.py, the "applied" message reached the same chat, and Undo put the file back.

https://claude.ai/code/session_011UYzzUKxNqKPdmLsRmJ6Xu

Navigated in place, the editor of jpeg_flow.py drew place.py's workflow
and its GLSP session drew place.py. The untangle tools asked the chat
host for a panel open on place.py; the panel is the editor's, on
jpeg_flow.py, so untangle-propose failed ("No chat panel is open on this
diagram"), and untangle-end found no session of the chat's file after
the turn.

- A session names itself to the chat host by its GLSP client id beside
  the file it draws (DiagramChatTarget). The extension maps the client to
  its editor's document as VS Code spells it, the webview's workflowUri
  (getChatUriForClientId, diagram-chat-routing.ts), the drawn file after.
- diagramToolSession takes the session the editor shows first, whatever
  file its view draws.
- /untangle looks the session up before the turn and names it in the
  prompt: Claude over ACP loads tool schemas on first use and called
  untangle-start with no sessionId.

Claude-Session: https://claude.ai/code/session_011UYzzUKxNqKPdmLsRmJ6Xu
…ds unchanged

- The other chat commands keep acting on a diagram of the chat's file:
  "the session shown here, whatever file it draws" is diagramToolSession's
  anyView, /untangle's alone. Without it /agent or a rename in a view of
  another file's workflow would write into that file while its
  auto-layout went to the chat's.
- Each chat message carries its diagram's GLSP client id
  (ChatCommandContext.diagramClientId): of two editors on a file,
  /untangle untangles the one whose panel it was typed in, not the file's
  last-used editor.
- A session's follow-ups go to the chat its card went to, or nowhere: an
  editor closed while its card waited no longer sends "Untangle
  discarded" to another editor's chat of the drawn file.
- afterTurn looks the session up again when the one it untangled is gone
  (the editor reopened during the turn).
- The docs say what is routed: the chat of the editor's file, its panel
  that spoke last.

Claude-Session: https://claude.ai/code/session_011UYzzUKxNqKPdmLsRmJ6Xu
@endrix
endrix merged commit 3283ca6 into main Nov 24, 2026
1 check passed
@endrix
endrix deleted the fix/untangle-nested-view branch November 24, 2026 15:49
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