Skip to content

Your lightweight open-source personal agent.

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

chengyongru6bf604d43c2e
diff --git a/tui/RELINKING.md b/tui/RELINKING.md
index 9e625f917..c065fc561 100644
--- a/tui/RELINKING.md
+++ b/tui/RELINKING.md
@@ -2,7 +2,7 @@
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
-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
LGPL 2.1 license texts.
@@ -13,8 +13,8 @@ Corresponding upstream source:
<https://github.com/oven-sh/bun/tree/bun-v1.3.13>
- Bun's patched WebKit (`4d5e75ebd84a14edbc7ae264245dcd77fe597c10`):
<https://github.com/oven-sh/WebKit/tree/4d5e75ebd84a14edbc7ae264245dcd77fe597c10>
-- OpenTUI 0.5.10: <https://www.npmjs.com/package/@opentui/core/v/0.5.10>
- (source: <https://github.com/anomalyco/opentui/tree/f6673a04ccb671b9207da358c57152bfd27c781f>)
+- OpenTUI 0.5.11: <https://www.npmjs.com/package/@opentui/core/v/0.5.11>
+ (source: <https://github.com/anomalyco/opentui/tree/6b9863ea7c5fae22bfebb23c242ddcc4c2b0aa0e>)
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
diff --git a/tui/bun.lock b/tui/bun.lock
index ba827a7e9..b7bbd0676 100644
--- a/tui/bun.lock
+++ b/tui/bun.lock
@@ -5,7 +5,7 @@
"": {
"name": "@nanobot/tui",
"dependencies": {
- "@opentui/core": "0.5.10",
+ "@opentui/core": "0.5.11",
},
"devDependencies": {
"@types/bun": "^1.3.13",
@@ -14,23 +14,23 @@
},
},
"packages": {
- "@opentui/core": ["@opentui/[email protected]", "", { "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/[email protected]", "", { "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/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Vyb+nTbhab8ZcRy5gg1loEEGwRcIbjAeVRIBfHBcbFDqmITBOg7x2gqJ+x/TnoOy4uwMhCmICUN2wiyREw3r1Q=="],
+ "@opentui/core-darwin-arm64": ["@opentui/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-DRXY5ioq+n1ZNAMAcaFaBunr0cmi2gqucjbTW7lgFp8t9uN3fNZnLTDOqkCTQtT2XhrU4GXqySaPSQ4qFG/EAQ=="],
- "@opentui/core-darwin-x64": ["@opentui/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-tTFLcM7Oj1gTyhm/bUdAt3C6grZdCxPk6+/g2azcZBUlI3/62LwbeRS6HbQKFFmm+1fUmX8cq6kWrtul885mVg=="],
+ "@opentui/core-darwin-x64": ["@opentui/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-yP/8GliJDiJNm8YYJKvgWuy6xyCEd8d4GwBVOIzCFOI7ZIbGP8GOTvmwIjRW4Paw20pTttWMWyRoQiCvOXvH2g=="],
- "@opentui/core-linux-arm64": ["@opentui/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-ncJXcgudhBf2GdJyF3xVQN/Ec+1F7GOL+pRrURmgBYSj2v1w6EyoDQFAACtPTK2c3R38W6fvZwL4JSLlm4EFXQ=="],
+ "@opentui/core-linux-arm64": ["@opentui/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-zBIsRFHlLUYFNhapRSNt9dz4mC8gZ4Wxcfy3A+2AwqsgCipcr2FkIuAXYqN08q+IvqFX7DfqgIFGWDNedHTPUg=="],
- "@opentui/core-linux-arm64-musl": ["@opentui/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-dGMphDKexSdeYqwl0wgoFBP88Ta/cdi1Zc1mk29/ENkSCGz+74zlCHgqTHRNGLmI8W5TfuUtCyktQH11/Z+TBQ=="],
+ "@opentui/core-linux-arm64-musl": ["@opentui/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-x+xeR2LYibvIi/qQetRjJR008sFRve60QuDcO8ItxUwzFeKTDzl5CEiZpBXfm5I4FhRNuyuj0TSPIFadMvrjFQ=="],
- "@opentui/core-linux-x64": ["@opentui/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-5qtYaOgwVycZD1GaGshTRsi0rXPAmVExO03N1JQaHu+NYxK/vXSOc7Bu4QW0sPXx3Sp0SpzpP+FHjXABfoK66g=="],
+ "@opentui/core-linux-x64": ["@opentui/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-pSOXqOADrv+zINOgR3FDFA9zVRaim3zl8/yhtO+X9rEJ6f34z3gDund0Gf88hNJSMpZK5xWtipEVm28RY5VF8w=="],
- "@opentui/core-linux-x64-musl": ["@opentui/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-Oj4H9hApuvuTKPWxh4SoZAgGJorR7vbvnrZA/cAkSMAk2VGSoHRRcqeXQbcH8IcdjVZ0KFpv8Zkl/D5Ye+2mew=="],
+ "@opentui/core-linux-x64-musl": ["@opentui/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-MyqOnSs8pTYG2xmFr1xt6xZIuHu2Xu4pkle9my9JdE+WClmusHf0YN9Eas6jQLAq5XUi34r22wMeK0juk93zyw=="],
- "@opentui/core-win32-arm64": ["@opentui/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-A9VhgvTxQoUdZ+8LmUumEng1sQNbj9QQQT3NYG9mSxI54qTANi7vOWNSphMiY6RMVsr22pgm6nUvSSvJXv7Jog=="],
+ "@opentui/core-win32-arm64": ["@opentui/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-MGGRXIDJ//HyaqC5ndSr7/CUl+ICdYEAMcjbA00UWsthh4ZO/rYhPkyqOaTn5ck6+G4ca3/+M76J+jImMYTjNg=="],
- "@opentui/core-win32-x64": ["@opentui/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-u3KHa7kEeWrmKVDRJYpxSGO+g5E9cMGlrmTsPN3GVPHUmQMiREUawLXUvsU8+IHaQnqG3Q5nuE1yf4fPBzS+Qw=="],
+ "@opentui/core-win32-x64": ["@opentui/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-sMEGX9rhiPd1gBa190jzj5uIdzKCMImxHmr22hJLxIRWqejxWvqGnRBkW68wT8NfMViDiMtZWavgWL7GgmYCAQ=="],
"@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.3.14" } }, "sha512-h1hFqFVcvAvD9j9K7ZW7vd82aSA+rTdznZa+5bwvCwqSB1jmmfLcbIWhOLx1/+boy/xmjgCs/OMUL8hRJSmnPw=="],
diff --git a/tui/package.json b/tui/package.json
index 488bd5f98..bb3dda0cc 100644
--- a/tui/package.json
+++ b/tui/package.json
@@ -10,7 +10,7 @@
"test": "bun test"
},
"dependencies": {
- "@opentui/core": "0.5.10"
+ "@opentui/core": "0.5.11"
},
"devDependencies": {
"@types/bun": "^1.3.13",
diff --git a/tui/src/app.test.ts b/tui/src/app.test.ts
index 75650b7c2..289f523d2 100644
--- a/tui/src/app.test.ts
+++ b/tui/src/app.test.ts
@@ -11,6 +11,7 @@ import {
MockTreeSitterClient,
TestRecorder,
createTestRenderer,
+ setRendererCapabilities,
type TestRendererSetup,
} 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 () => {
setup = await createRenderer({ width: 100, height: 30, screenMode: "alternate-screen" })
const app = mount(setup)