feat(tui): render Mermaid diagrams as terminal images (#6320)

* feat(tui): render Mermaid diagrams as terminal images

* perf(tui): streamline Mermaid rendering and resource ownership

* fix(tui): clarify diagram navigation hints

* fix(tui): release viewer layout leases and retain retry targets

* docs(tui): keep Mermaid guide focused on usage
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-20 17:28:36 +08:00
1 parent 9b5d552f40
commit 9adbcc2cef
31 files changed
+1983 -21

No files matched your search

+23 -1
View File
@@ -376,7 +376,7 @@ export class NanobotTui {
},
{
onPrimaryMouseDown: () => {
const restoreComposerFocus = !this.diffViewer.visible
const restoreComposerFocus = !this.diffViewer.visible && !this.transcript.diagrams.viewer.visible
if (restoreComposerFocus) this.composer.focus()
// Runtime pickers are transient popovers. A primary click anywhere
// outside their trigger or body dismisses them; hide() restores the
@@ -405,6 +405,16 @@ export class NanobotTui {
this.status = layout.status
this.meta = layout.meta
this.renderer.root.add(this.shell)
this.renderer.root.add(this.transcript.diagrams.viewer.root)
this.transcript.diagrams.onOpen = () => {
this.composer.blur()
}
this.transcript.diagrams.viewer.onClose = () => {
this.composer.focus()
if (this.activeTurn) this.renderActiveStatus()
else this.status.content = this.readyStatus()
this.updateMeta()
}
this.shell.renderBefore = () => {
const selection = this.renderer.getSelection()
if (selection) applySelectionColors(selection, this.palette.selection)
@@ -562,6 +572,7 @@ export class NanobotTui {
else if (command.command.action === "context") void this.openContext()
else if (command.command.action === "usage") this.openUsage()
else if (command.command.action === "diff") this.openDiff()
else if (command.command.action === "diagrams") { this.clearComposer(); this.transcript.diagrams.open() }
else if (command.command.action === "branch") void this.openBranch()
else if (command.command.action === "detach") this.quit(true)
else if (command.command.action === "exit") this.quit()
@@ -1313,6 +1324,17 @@ export class NanobotTui {
return
}
}
if (this.transcript.diagrams.viewer.visible) {
this.transcript.diagrams.viewer.handleKey(key)
key.preventDefault()
return
}
if (key.ctrl && key.name === "g") {
this.commandMenu.hide()
this.transcript.diagrams.open()
key.preventDefault()
return
}
if (this.diffViewer.visible) {
if (key.ctrl && key.name === "c") {
const selected = this.renderer.getSelection()?.getSelectedText()