fix(tui): make Markdown links clickable (#5829)

* fix(tui): make Markdown links clickable

* docs(tui): sync OpenTUI relinking version
This commit is contained in:
chengyongru authored and GitHub committed 2026-09-22 13:20:13 +08:00
1 parent 12a9a8a692
commit 6bf604d43c
4 files changed
+51 -14

No files matched your search

+3 -3
View File
@@ -2,7 +2,7 @@
The nanobot TUI release archive contains the executable, its complete JavaScript/TypeScript The nanobot TUI release archive contains the executable, its complete JavaScript/TypeScript
application source, dependency lockfile, build scripts, and third-party notices. It is built with application source, dependency lockfile, build scripts, and third-party notices. It is built with
Bun 1.3.13 and OpenTUI 0.5.10. See `SOURCE_OFFER.md` for the corresponding-source Bun 1.3.13 and OpenTUI 0.5.11. See `SOURCE_OFFER.md` for the corresponding-source
offer that accompanies the executable. The archive also contains the complete LGPL 2.0 and offer that accompanies the executable. The archive also contains the complete LGPL 2.0 and
LGPL 2.1 license texts. LGPL 2.1 license texts.
@@ -13,8 +13,8 @@ Corresponding upstream source:
<https://github.com/oven-sh/bun/tree/bun-v1.3.13> <https://github.com/oven-sh/bun/tree/bun-v1.3.13>
- Bun's patched WebKit (`4d5e75ebd84a14edbc7ae264245dcd77fe597c10`): - Bun's patched WebKit (`4d5e75ebd84a14edbc7ae264245dcd77fe597c10`):
<https://github.com/oven-sh/WebKit/tree/4d5e75ebd84a14edbc7ae264245dcd77fe597c10> <https://github.com/oven-sh/WebKit/tree/4d5e75ebd84a14edbc7ae264245dcd77fe597c10>
- OpenTUI 0.5.10: <https://www.npmjs.com/package/@opentui/core/v/0.5.10> - OpenTUI 0.5.11: <https://www.npmjs.com/package/@opentui/core/v/0.5.11>
(source: <https://github.com/anomalyco/opentui/tree/f6673a04ccb671b9207da358c57152bfd27c781f>) (source: <https://github.com/anomalyco/opentui/tree/6b9863ea7c5fae22bfebb23c242ddcc4c2b0aa0e>)
To rebuild against a modified JavaScriptCore/WebKit, first build Bun 1.3.13 from its complete To rebuild against a modified JavaScriptCore/WebKit, first build Bun 1.3.13 from its complete
source checkout together with the WebKit revision above by following Bun's pinned license and source checkout together with the WebKit revision above by following Bun's pinned license and
+10 -10
View File
@@ -5,7 +5,7 @@
"": { "": {
"name": "@nanobot/tui", "name": "@nanobot/tui",
"dependencies": { "dependencies": {
"@opentui/core": "0.5.10", "@opentui/core": "0.5.11",
}, },
"devDependencies": { "devDependencies": {
"@types/bun": "^1.3.13", "@types/bun": "^1.3.13",
@@ -14,23 +14,23 @@
}, },
}, },
"packages": { "packages": {
"@opentui/core": ["@opentui/core@0.5.10", "", { "dependencies": { "bun-ffi-structs": "0.3.1", "diff": "9.0.0", "marked": "17.0.1", "string-width": "7.2.0", "strip-ansi": "7.1.2" }, "optionalDependencies": { "@opentui/core-darwin-arm64": "0.5.10", "@opentui/core-darwin-x64": "0.5.10", "@opentui/core-linux-arm64": "0.5.10", "@opentui/core-linux-arm64-musl": "0.5.10", "@opentui/core-linux-x64": "0.5.10", "@opentui/core-linux-x64-musl": "0.5.10", "@opentui/core-win32-arm64": "0.5.10", "@opentui/core-win32-x64": "0.5.10" }, "peerDependencies": { "web-tree-sitter": "0.25.10" } }, "sha512-C3a2UbmefeAjIxAgm4BqjuSxKT4oqutfvYFwVvUgMxmGRHkNbBc/s7sukV0JgwcxFcV3uMFrXxo+E+BQtvuOiw=="], "@opentui/core": ["@opentui/core@0.5.11", "", { "dependencies": { "bun-ffi-structs": "0.3.1", "diff": "9.0.0", "marked": "17.0.1", "string-width": "7.2.0", "strip-ansi": "7.1.2" }, "optionalDependencies": { "@opentui/core-darwin-arm64": "0.5.11", "@opentui/core-darwin-x64": "0.5.11", "@opentui/core-linux-arm64": "0.5.11", "@opentui/core-linux-arm64-musl": "0.5.11", "@opentui/core-linux-x64": "0.5.11", "@opentui/core-linux-x64-musl": "0.5.11", "@opentui/core-win32-arm64": "0.5.11", "@opentui/core-win32-x64": "0.5.11" }, "peerDependencies": { "web-tree-sitter": "0.25.10" } }, "sha512-pImMfjCNx7JUp9Df1LRZBDLisWqgzOLXZKXO+hh3jA9ujBFPQnZOqbG+/N5uVAAX8IZGaqhYSQRwSZIFBmcfbQ=="],
"@opentui/core-darwin-arm64": ["@opentui/core-darwin-arm64@0.5.10", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Vyb+nTbhab8ZcRy5gg1loEEGwRcIbjAeVRIBfHBcbFDqmITBOg7x2gqJ+x/TnoOy4uwMhCmICUN2wiyREw3r1Q=="], "@opentui/core-darwin-arm64": ["@opentui/core-darwin-arm64@0.5.11", "", { "os": "darwin", "cpu": "arm64" }, "sha512-DRXY5ioq+n1ZNAMAcaFaBunr0cmi2gqucjbTW7lgFp8t9uN3fNZnLTDOqkCTQtT2XhrU4GXqySaPSQ4qFG/EAQ=="],
"@opentui/core-darwin-x64": ["@opentui/core-darwin-x64@0.5.10", "", { "os": "darwin", "cpu": "x64" }, "sha512-tTFLcM7Oj1gTyhm/bUdAt3C6grZdCxPk6+/g2azcZBUlI3/62LwbeRS6HbQKFFmm+1fUmX8cq6kWrtul885mVg=="], "@opentui/core-darwin-x64": ["@opentui/core-darwin-x64@0.5.11", "", { "os": "darwin", "cpu": "x64" }, "sha512-yP/8GliJDiJNm8YYJKvgWuy6xyCEd8d4GwBVOIzCFOI7ZIbGP8GOTvmwIjRW4Paw20pTttWMWyRoQiCvOXvH2g=="],
"@opentui/core-linux-arm64": ["@opentui/core-linux-arm64@0.5.10", "", { "os": "linux", "cpu": "arm64" }, "sha512-ncJXcgudhBf2GdJyF3xVQN/Ec+1F7GOL+pRrURmgBYSj2v1w6EyoDQFAACtPTK2c3R38W6fvZwL4JSLlm4EFXQ=="], "@opentui/core-linux-arm64": ["@opentui/core-linux-arm64@0.5.11", "", { "os": "linux", "cpu": "arm64" }, "sha512-zBIsRFHlLUYFNhapRSNt9dz4mC8gZ4Wxcfy3A+2AwqsgCipcr2FkIuAXYqN08q+IvqFX7DfqgIFGWDNedHTPUg=="],
"@opentui/core-linux-arm64-musl": ["@opentui/core-linux-arm64-musl@0.5.10", "", { "os": "linux", "cpu": "arm64" }, "sha512-dGMphDKexSdeYqwl0wgoFBP88Ta/cdi1Zc1mk29/ENkSCGz+74zlCHgqTHRNGLmI8W5TfuUtCyktQH11/Z+TBQ=="], "@opentui/core-linux-arm64-musl": ["@opentui/core-linux-arm64-musl@0.5.11", "", { "os": "linux", "cpu": "arm64" }, "sha512-x+xeR2LYibvIi/qQetRjJR008sFRve60QuDcO8ItxUwzFeKTDzl5CEiZpBXfm5I4FhRNuyuj0TSPIFadMvrjFQ=="],
"@opentui/core-linux-x64": ["@opentui/core-linux-x64@0.5.10", "", { "os": "linux", "cpu": "x64" }, "sha512-5qtYaOgwVycZD1GaGshTRsi0rXPAmVExO03N1JQaHu+NYxK/vXSOc7Bu4QW0sPXx3Sp0SpzpP+FHjXABfoK66g=="], "@opentui/core-linux-x64": ["@opentui/core-linux-x64@0.5.11", "", { "os": "linux", "cpu": "x64" }, "sha512-pSOXqOADrv+zINOgR3FDFA9zVRaim3zl8/yhtO+X9rEJ6f34z3gDund0Gf88hNJSMpZK5xWtipEVm28RY5VF8w=="],
"@opentui/core-linux-x64-musl": ["@opentui/core-linux-x64-musl@0.5.10", "", { "os": "linux", "cpu": "x64" }, "sha512-Oj4H9hApuvuTKPWxh4SoZAgGJorR7vbvnrZA/cAkSMAk2VGSoHRRcqeXQbcH8IcdjVZ0KFpv8Zkl/D5Ye+2mew=="], "@opentui/core-linux-x64-musl": ["@opentui/core-linux-x64-musl@0.5.11", "", { "os": "linux", "cpu": "x64" }, "sha512-MyqOnSs8pTYG2xmFr1xt6xZIuHu2Xu4pkle9my9JdE+WClmusHf0YN9Eas6jQLAq5XUi34r22wMeK0juk93zyw=="],
"@opentui/core-win32-arm64": ["@opentui/core-win32-arm64@0.5.10", "", { "os": "win32", "cpu": "arm64" }, "sha512-A9VhgvTxQoUdZ+8LmUumEng1sQNbj9QQQT3NYG9mSxI54qTANi7vOWNSphMiY6RMVsr22pgm6nUvSSvJXv7Jog=="], "@opentui/core-win32-arm64": ["@opentui/core-win32-arm64@0.5.11", "", { "os": "win32", "cpu": "arm64" }, "sha512-MGGRXIDJ//HyaqC5ndSr7/CUl+ICdYEAMcjbA00UWsthh4ZO/rYhPkyqOaTn5ck6+G4ca3/+M76J+jImMYTjNg=="],
"@opentui/core-win32-x64": ["@opentui/core-win32-x64@0.5.10", "", { "os": "win32", "cpu": "x64" }, "sha512-u3KHa7kEeWrmKVDRJYpxSGO+g5E9cMGlrmTsPN3GVPHUmQMiREUawLXUvsU8+IHaQnqG3Q5nuE1yf4fPBzS+Qw=="], "@opentui/core-win32-x64": ["@opentui/core-win32-x64@0.5.11", "", { "os": "win32", "cpu": "x64" }, "sha512-sMEGX9rhiPd1gBa190jzj5uIdzKCMImxHmr22hJLxIRWqejxWvqGnRBkW68wT8NfMViDiMtZWavgWL7GgmYCAQ=="],
"@types/bun": ["@types/bun@1.3.14", "", { "dependencies": { "bun-types": "1.3.14" } }, "sha512-h1hFqFVcvAvD9j9K7ZW7vd82aSA+rTdznZa+5bwvCwqSB1jmmfLcbIWhOLx1/+boy/xmjgCs/OMUL8hRJSmnPw=="], "@types/bun": ["@types/bun@1.3.14", "", { "dependencies": { "bun-types": "1.3.14" } }, "sha512-h1hFqFVcvAvD9j9K7ZW7vd82aSA+rTdznZa+5bwvCwqSB1jmmfLcbIWhOLx1/+boy/xmjgCs/OMUL8hRJSmnPw=="],
+1 -1
View File
@@ -10,7 +10,7 @@
"test": "bun test" "test": "bun test"
}, },
"dependencies": { "dependencies": {
"@opentui/core": "0.5.10" "@opentui/core": "0.5.11"
}, },
"devDependencies": { "devDependencies": {
"@types/bun": "^1.3.13", "@types/bun": "^1.3.13",
+37
View File
@@ -11,6 +11,7 @@ import {
MockTreeSitterClient, MockTreeSitterClient,
TestRecorder, TestRecorder,
createTestRenderer, createTestRenderer,
setRendererCapabilities,
type TestRendererSetup, type TestRendererSetup,
} from "@opentui/core/testing" } from "@opentui/core/testing"
@@ -2065,6 +2066,42 @@ describe("NanobotTui layout", () => {
} }
}) })
test("keeps finalized streamed Markdown link labels clickable", async () => {
setup = await createRenderer({ width: 100, height: 24, screenMode: "alternate-screen" })
setRendererCapabilities(setup.renderer, { hyperlinks: true })
const label = "HKUDS/nanobot#1234"
const url = "https://github.com/HKUDS/nanobot/pull/1234"
const content = `PR updated: [${label}](${url})`
const labelStart = content.indexOf(label)
const urlStart = content.indexOf(url)
const treeSitterClient = new MockTreeSitterClient({ autoResolveTimeout: 0 })
treeSitterClient.setMockResult({
highlights: [
[labelStart - 1, labelStart, "markup.link"],
[labelStart, labelStart + label.length, "markup.link.label"],
[labelStart + label.length, urlStart, "markup.link"],
[urlStart, urlStart + url.length, "markup.link.url"],
[urlStart + url.length, content.length, "markup.link"],
],
})
const app = NanobotTui.mount(setup.renderer, options, client(), treeSitterClient)
app.accept({ event: "attached", chat_id: "chat" })
app.accept({ event: "delta", chat_id: "chat", text: content })
app.accept({ event: "stream_end", chat_id: "chat" })
app.accept({ event: "turn_end", chat_id: "chat" })
await setup.flush()
const lines = setup.captureCharFrame().split("\n")
const y = lines.findIndex((line) => line.includes(label))
const x = y >= 0 ? lines[y]!.indexOf(label) : -1
expect([x, y]).not.toContain(-1)
for (let offset = 0; offset < label.length; offset += 1) {
expect(setup.renderer.getLinkAt(x + offset, y)).toBe(url)
}
})
test("keeps streamed fenced code visible while completing the response", async () => { test("keeps streamed fenced code visible while completing the response", async () => {
setup = await createRenderer({ width: 100, height: 30, screenMode: "alternate-screen" }) setup = await createRenderer({ width: 100, height: 30, screenMode: "alternate-screen" })
const app = mount(setup) const app = mount(setup)