Compare commits

...
Author SHA1 Message Date
bcf52f93b1 fix(app): draw Mermaid flowcharts whose labels contain an @ (#10165)
Mermaid 11's lexer reads an edge id (`e1@-->`) from any run of
non-space characters ending in "@". In `F[@mention] --> G` that run
starts at the node id and crosses the label's opening bracket, so the
parse fails and the card falls back to the source. Backport the lexer
half of mermaid-js/mermaid#8459, which stops the edge id at the node
shape characters, onto the pinned mermaid 11.16.0 and rebuild the
runtime. Moving to mermaid 12 instead changes the default layout and
look of every diagram and raises the browser floor, so it stays a
separate decision.

Closes #10157

Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
Co-authored-by: monarchmaisuriya <37824914+monarchmaisuriya@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 21:52:18 +00:00
4 changed files with 52 additions and 1 deletions
File diff suppressed because one or more lines are too long
@@ -215,6 +215,32 @@ describe("Mermaid sandbox runtime", () => {
expect(widths).toEqual([240, 350, 900]);
});
/**
* Agents often write a label that starts with a mention or holds an email address. Mermaid 11
* read the text up to the "@" as an edge id, so these diagrams failed to parse.
*/
it.each([
"flowchart LR\n F[@mention in any workspace] --> G[Look up token]",
"flowchart LR\n A[ops@example.com] --> B",
"flowchart LR\n A -->|@user approves| B",
"graph TD\n A(@x) --> B{@x?}",
])("renders a flowchart whose label contains an @: %s", async (source) => {
const frame = await mountRuntime();
const result = await render(frame, { revision: 1, source });
expect(result).toMatchObject({ type: "rendered", revision: 1, source });
});
it("still renders a flowchart edge id", async () => {
const frame = await mountRuntime();
const source = "flowchart LR\n A[Start] e1@--> B[End]";
const result = await render(frame, { revision: 1, source });
expect(result).toMatchObject({ type: "rendered", revision: 1, source });
});
it("coalesces queued input and never reports an obsolete result", async () => {
const frame = await mountRuntime();
const obsoleteSource = `flowchart TD\n${Array.from({ length: 250 }, (_, index) => `A${index} --> A${index + 1}`).join("\n")}`;
File diff suppressed because one or more lines are too long
+6
View File
@@ -86,6 +86,12 @@ const patchedPackages = [
nodeModulesPath: "node_modules/@mattermost/react-native-paste-input",
patchPrefix: "@mattermost+react-native-paste-input+",
},
// Backport of https://github.com/mermaid-js/mermaid/pull/8459 (lexer half): a flowchart label
// with an "@" parses. The patch header has the details. Remove when the app uses mermaid 12.
{
nodeModulesPath: "node_modules/mermaid",
patchPrefix: "mermaid+",
},
{
nodeModulesPath: "packages/server/node_modules/@opencode-ai/sdk",
patchPrefix: "@opencode-ai+sdk+",